diff --git a/Makefile.in b/Makefile.in index 68ce9156..36bf5e32 100644 --- a/Makefile.in +++ b/Makefile.in @@ -43,6 +43,7 @@ src/catalog/tde_keyring.o \ src/catalog/tde_master_key.o \ src/common/pg_tde_shmem.o \ src/common/pg_tde_utils.o \ +src/pg_tde_defs.o \ src/pg_tde.o override PG_CPPFLAGS += @tde_CPPFLAGS@ diff --git a/configure b/configure index 1b040ebd..be3283ca 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.71 for pg_tde 0.1-mvp. +# Generated by GNU Autoconf 2.71 for pg_tde Alpha 1.0. # # Report bugs to . # @@ -610,8 +610,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='pg_tde' PACKAGE_TARNAME='pg_tde' -PACKAGE_VERSION='0.1-mvp' -PACKAGE_STRING='pg_tde 0.1-mvp' +PACKAGE_VERSION='Alpha 1.0' +PACKAGE_STRING='pg_tde Alpha 1.0' PACKAGE_BUGREPORT='https://github.com/Percona-Lab/pg_tde/issues' PACKAGE_URL='' @@ -1267,7 +1267,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures pg_tde 0.1-mvp to adapt to many kinds of systems. +\`configure' configures pg_tde Alpha 1.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1333,7 +1333,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of pg_tde 0.1-mvp:";; + short | recursive ) echo "Configuration of pg_tde Alpha 1.0:";; esac cat <<\_ACEOF @@ -1419,7 +1419,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -pg_tde configure 0.1-mvp +pg_tde configure Alpha 1.0 generated by GNU Autoconf 2.71 Copyright (C) 2021 Free Software Foundation, Inc. @@ -1575,7 +1575,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by pg_tde $as_me 0.1-mvp, which was +It was created by pg_tde $as_me Alpha 1.0, which was generated by GNU Autoconf 2.71. Invocation command line was $ $0$ac_configure_args_raw @@ -2418,6 +2418,9 @@ case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac # if there's a problem during the test compilation. + ac_config_headers="$ac_config_headers src/include/config.h" + + #======================================= @@ -3727,47 +3730,10 @@ test "x$prefix" = xNONE && prefix=$ac_default_prefix # Let make expand exec_prefix. test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' -# Transform confdefs.h into DEFS. -# Protect against shell expansion while executing Makefile rules. -# Protect against Makefile macro expansion. -# -# If the first sed substitution is executed (which looks for macros that -# take arguments), then branch to the quote section. Otherwise, -# look for a macro that doesn't take arguments. -ac_script=' -:mline -/\\$/{ - N - s,\\\n,, - b mline -} -t clear -:clear -s/^[ ]*#[ ]*define[ ][ ]*\([^ (][^ (]*([^)]*)\)[ ]*\(.*\)/-D\1=\2/g -t quote -s/^[ ]*#[ ]*define[ ][ ]*\([^ ][^ ]*\)[ ]*\(.*\)/-D\1=\2/g -t quote -b any -:quote -s/[ `~#$^&*(){}\\|;'\''"<>?]/\\&/g -s/\[/\\&/g -s/\]/\\&/g -s/\$/$$/g -H -:any -${ - g - s/^\n// - s/\n/ /g - p -} -' -DEFS=`sed -n "$ac_script" confdefs.h` - +DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= -U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' @@ -4172,7 +4138,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by pg_tde $as_me 0.1-mvp, which was +This file was extended by pg_tde $as_me Alpha 1.0, which was generated by GNU Autoconf 2.71. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -4190,11 +4156,15 @@ case $ac_config_files in *" "*) set x $ac_config_files; shift; ac_config_files=$*;; esac +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 # Files that config.status was made for. config_files="$ac_config_files" +config_headers="$ac_config_headers" _ACEOF @@ -4215,10 +4185,15 @@ Usage: $0 [OPTION]... [TAG]... --recheck update $as_me by reconfiguring in the same conditions --file=FILE[:TEMPLATE] instantiate the configuration file FILE + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE Configuration files: $config_files +Configuration headers: +$config_headers + Report bugs to ." _ACEOF @@ -4227,7 +4202,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -pg_tde config.status 0.1-mvp +pg_tde config.status Alpha 1.0 configured by $0, generated by GNU Autoconf 2.71, with options \\"\$ac_cs_config\\" @@ -4281,7 +4256,18 @@ do esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; - --he | --h | --help | --hel | -h ) + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) printf "%s\n" "$ac_cs_usage"; exit ;; -q | -quiet | --quiet | --quie | --qui | --qu | --q \ | -silent | --silent | --silen | --sile | --sil | --si | --s) @@ -4337,6 +4323,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 for ac_config_target in $ac_config_targets do case $ac_config_target in + "src/include/config.h") CONFIG_HEADERS="$CONFIG_HEADERS src/include/config.h" ;; "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;; *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; @@ -4350,6 +4337,7 @@ done # bizarre bug on SunOS 4.1.3. if $ac_need_defaults; then test ${CONFIG_FILES+y} || CONFIG_FILES=$config_files + test ${CONFIG_HEADERS+y} || CONFIG_HEADERS=$config_headers fi # Have a temporary directory for convenience. Make it in the build tree @@ -4537,8 +4525,116 @@ fi cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 fi # test -n "$CONFIG_FILES" +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$ac_tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. -eval set X " :F $CONFIG_FILES " +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :F $CONFIG_FILES :H $CONFIG_HEADERS " shift for ac_tag do @@ -4746,7 +4842,30 @@ which seems to be undefined. Please make sure it is defined" >&2;} esac \ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; - + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + printf "%s\n" "/* $configure_input */" >&1 \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { printf "%s\n" "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +printf "%s\n" "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + printf "%s\n" "/* $configure_input */" >&1 \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi + ;; esac diff --git a/configure.ac b/configure.ac index 409c2330..53ef650a 100644 --- a/configure.ac +++ b/configure.ac @@ -1,7 +1,7 @@ # Process this file with autoconf to produce a configure script. # configure.ac -AC_INIT([pg_tde], [0.1-mvp], [https://github.com/Percona-Lab/pg_tde/issues]) +AC_INIT([pg_tde], [Alpha 1.0], [https://github.com/Percona-Lab/pg_tde/issues], [pg_tde]) AC_CANONICAL_HOST @@ -43,6 +43,8 @@ AC_DEFUN([REQUIRE_LIB], [ { ]) } ] ) + AC_CONFIG_HEADERS(src/include/config.h) + #======================================= REQUIRE_LIB(libcurl, curl, curl, curl_easy_setopt, curl, curl/curl.h) diff --git a/meson.build b/meson.build index 221d996a..528f6cb7 100644 --- a/meson.build +++ b/meson.build @@ -1,6 +1,18 @@ curldep = dependency('libcurl') +pg_tde_version = 'Alpha 1.0' + +conf_data = configuration_data() +conf_data.set_quoted('PACKAGE_NAME', 'pg_tde') +conf_data.set_quoted('PACKAGE_BUGREPORT', 'https://github.com/Percona-Lab/pg_tde/issues') +conf_data.set_quoted('PACKAGE_VERSION', pg_tde_version) +conf_data.set_quoted('PACKAGE_STRING', 'pg_tde ' + pg_tde_version) +conf_data.set_quoted('PACKAGE_TARNAME', 'pg_tde') + +configure_file(output : 'config.h', + configuration : conf_data) + pg_tde_sources = files( 'src/pg_tde.c', 'src/transam/pg_tde_xact_handler.c', @@ -30,10 +42,11 @@ pg_tde_sources = files( 'src/catalog/tde_master_key.c', 'src/common/pg_tde_shmem.c', 'src/common/pg_tde_utils.c', + 'src/pg_tde_defs.c', 'src/pg_tde.c', ) -incdir = include_directories('src/include') +incdir = include_directories('src/include', '.') deps_update = {'dependencies': contrib_mod_args.get('dependencies') + [curldep]} diff --git a/pg_tde--1.0.sql b/pg_tde--1.0.sql index a43b4204..bf36c3be 100644 --- a/pg_tde--1.0.sql +++ b/pg_tde--1.0.sql @@ -123,6 +123,8 @@ RETURNS TABLE ( master_key_name text, AS 'MODULE_PATHNAME' LANGUAGE C; +CREATE FUNCTION pg_tde_version() RETURNS TEXT AS 'MODULE_PATHNAME' LANGUAGE C; + -- Access method CREATE ACCESS METHOD pg_tde TYPE TABLE HANDLER pg_tdeam_handler; COMMENT ON ACCESS METHOD pg_tde IS 'pg_tde table access method'; diff --git a/src/include/config.h.in b/src/include/config.h.in new file mode 100644 index 00000000..47c0c6f7 --- /dev/null +++ b/src/include/config.h.in @@ -0,0 +1,57 @@ +/* src/include/config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define to 1 if you have the `curl' library (-lcurl). */ +#undef HAVE_LIBCURL + +/* Define to 1 if you have the `intl' library (-lintl). */ +#undef HAVE_LIBINTL + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDIO_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the home page for this package. */ +#undef PACKAGE_URL + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* Define to 1 if all of the C90 standard headers exist (not just the ones + required in a freestanding environment). This macro is provided for + backward compatibility; new code need not use it. */ +#undef STDC_HEADERS diff --git a/src/include/pg_tde.h b/src/include/pg_tde.h index 59656e9f..6625c532 100644 --- a/src/include/pg_tde.h +++ b/src/include/pg_tde.h @@ -12,4 +12,4 @@ typedef void (*pg_tde_on_ext_install_callback)(int tde_tbl_count, void* arg); extern void on_ext_install(pg_tde_on_ext_install_callback function, void* arg); -#endif /*PG_TDE_UTILS_H*/ \ No newline at end of file +#endif /*PG_TDE_H*/ \ No newline at end of file diff --git a/src/include/pg_tde_defs.h b/src/include/pg_tde_defs.h new file mode 100644 index 00000000..86e88d72 --- /dev/null +++ b/src/include/pg_tde_defs.h @@ -0,0 +1,16 @@ +/*------------------------------------------------------------------------- + * + * pg_tde_defs.h + * src/include/pg_tde_defs.h + * + *------------------------------------------------------------------------- + */ +#ifndef PG_TDE_DEFS_H +#define PG_TDE_DEFS_H + + +extern const char *pg_tde_package_string(void); +extern const char * pg_tde_package_name(void); +extern const char *pg_tde_package_version(void); + +#endif /*PG_TDE_DEFS_H*/ \ No newline at end of file diff --git a/src/pg_tde.c b/src/pg_tde.c index 258668b1..7b076592 100644 --- a/src/pg_tde.c +++ b/src/pg_tde.c @@ -29,6 +29,8 @@ #include "catalog/tde_master_key.h" #include "keyring/keyring_file.h" #include "keyring/keyring_vault.h" +#include "utils/builtins.h" +#include "pg_tde_defs.h" #define MAX_ON_INSTALLS 5 @@ -45,12 +47,13 @@ static int on_ext_install_index = 0; static void run_extension_install_callbacks(void); void _PG_init(void); Datum pg_tde_extension_initialize(PG_FUNCTION_ARGS); +Datum pg_tde_version(PG_FUNCTION_ARGS); static shmem_startup_hook_type prev_shmem_startup_hook = NULL; static shmem_request_hook_type prev_shmem_request_hook = NULL; PG_FUNCTION_INFO_V1(pg_tde_extension_initialize); - +PG_FUNCTION_INFO_V1(pg_tde_version); static void tde_shmem_request(void) { @@ -144,3 +147,10 @@ run_extension_install_callbacks(void) on_ext_install_list[i] .function(tde_table_count, on_ext_install_list[i].arg); } + +/* Returns package version */ +Datum +pg_tde_version(PG_FUNCTION_ARGS) +{ + PG_RETURN_TEXT_P(cstring_to_text(pg_tde_package_string())); +} diff --git a/src/pg_tde_defs.c b/src/pg_tde_defs.c new file mode 100644 index 00000000..4414dc52 --- /dev/null +++ b/src/pg_tde_defs.c @@ -0,0 +1,36 @@ +/*------------------------------------------------------------------------- + * + * pg_tde_defs.c + * The configure script generates config.h which contains the package_* defs + * and these defines conflicts with the PG defines. + * This file is used to provide the package version string to the extension + * without including the config.h file. + * + * IDENTIFICATION + * contrib/pg_tde/src/pg_tde_defs.c + * + *------------------------------------------------------------------------- + */ + + +#include "config.h" +#include "pg_tde_defs.h" + + +/* Returns package version */ +const char* +pg_tde_package_string(void) +{ + return PACKAGE_STRING; +} + +const char * +pg_tde_package_name(void) +{ + return PACKAGE_NAME; +} +const char* +pg_tde_package_version(void) +{ + return PACKAGE_VERSION; +}