timescaledb/scripts/export_prefix_check.sh.in
Erik Nordström 176b616e37 Refactor insert and copy paths
The INSERT and COPY paths have been refactored to better handle
differences between PostgreSQL versions. In particular, PostgreSQL 12
introduced the new table access mangement (AM) API which ties tuple
table slots to specific table AM implementations, requiring more
careful management of those data structures.

The code tries to adopt the new (PG12) API to the extent possible,
providing compatibility layers and functions for older PostgreSQL
versions where needed.
2020-04-14 23:12:15 +02:00

54 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
if [ ! -x "@NM@" ];
then
echo "Cannot check export format because nm is not installed" >&2
exit 1
fi
DEFINED_ONLY="--defined-only"
EXTERN_ONLY="--extern-only"
if nm --help | grep -q llvm; then
DEFINED_ONLY="-defined-only"
EXTERN_ONLY="-extern-only"
fi
# this script outputs all symbols not starting with an allowed prefix
# exported symbols are allowed to start with
# ts_ for regular timescaledb functions
# pg_finfo for metadata defined by PG_FUNCTION_INFO_V1
# we also whitelist a couple of special symbols
# _.*_init module startup functions
# _.*_fini module shutdown functions
# Pg_magic_func used by postgres to check extension compatability
# timescaledb_hello used to test that our name collision resistance works
# loader_hello used to test that our name collision resistance works
# test_symbol_conflict used to test that our name collision resistance works
# tsl_license_update_check used to check for valid license
# all of these symbols start with an additional leading '_' on macos
exports=$(find @CMAKE_BINARY_DIR@ -not -path '*/\.*' -name '*.so' -print0 \
| xargs -0 @NM@ ${DEFINED_ONLY} ${EXTERN_ONLY} \
| sed -e 's:^/.*$::' -e '/^$/d' -e 's/[a-f0-9]* [A-Za-z] //' \
| grep -v \
-e '^_\?ts_' \
-e '^_\?tsl_license_update_check$' \
-e '^_\?pg_finfo' \
-e '^_\?_.*_init$' \
-e '^_\?_.*_fini$' \
-e '^_\?Pg_magic_func$' \
-e '^_\?timescaledb_' \
-e '^_\?loader_hello$' \
-e '^_\?test_symbol_conflict$' \
)
num_exports=$(echo "${exports}" | grep -v '^$' | wc -l)
echo "${exports}"
if [ ${num_exports} -gt 0 ];
then
exit 1
else
exit 0
fi