From 8b6f87614b1817e5d97cf88f966ed2f582f8670e Mon Sep 17 00:00:00 2001 From: Jeff Davis Date: Tue, 15 Mar 2022 16:52:05 -0700 Subject: [PATCH] external funcs --- src/backend/distributed/Makefile | 2 -- src/backend/distributed/shared_library_init.c | 36 ++++++++++++++++--- src/include/distributed/shared_library_init.h | 2 ++ 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/backend/distributed/Makefile b/src/backend/distributed/Makefile index 30d733ba9..ef47a79bf 100644 --- a/src/backend/distributed/Makefile +++ b/src/backend/distributed/Makefile @@ -19,8 +19,6 @@ DATA_built = $(generated_sql_files) # directories with source files SUBDIRS = . commands connection ddl deparser executor metadata operations planner progress relay safeclib test transaction utils worker -# columnar modules -SUBDIRS += ../columnar # enterprise modules SUBDIRS += diff --git a/src/backend/distributed/shared_library_init.c b/src/backend/distributed/shared_library_init.c index 35909dad9..2047bfade 100644 --- a/src/backend/distributed/shared_library_init.c +++ b/src/backend/distributed/shared_library_init.c @@ -360,6 +360,11 @@ _PG_init(void) */ load_file(COLUMNAR_LIB_NAME, false); + /* + * Now, acquire symbols from columnar module. First, acquire + * the address of the set options hook, and set it so that we + * can propagate options changes. + */ ColumnarTableSetOptions_hook_type **ColumnarTableSetOptions_hook_ptr = (ColumnarTableSetOptions_hook_type **) find_rendezvous_variable( "ColumnarTableSetOptions_hook"); @@ -368,11 +373,34 @@ _PG_init(void) Assert(ColumnarTableSetOptions_hook_ptr != NULL); Assert(*ColumnarTableSetOptions_hook_ptr != NULL); - /* - * Set the hook, so that when the options change on a columnar - * table, we propagate the changes to shards. - */ **ColumnarTableSetOptions_hook_ptr = ColumnarTableSetOptionsHook; + + /* + * Next, acquire symbols for columnar functions that citus + * needs to call. + */ + void *handle = NULL; + ColumnarSupportsIndexAM = (ColumnarSupportsIndexAM_type) + load_external_function(COLUMNAR_LIB_NAME, "ColumnarSupportsIndexAM", + true, &handle); + CompressionTypeStr = (CompressionTypeStr_type) + load_external_function(COLUMNAR_LIB_NAME, "CompressionTypeStr", + true, &handle); + IsColumnarAmTable = (IsColumnarAmTable_type) + load_external_function(COLUMNAR_LIB_NAME, "IsColumnarAmTable", + true, &handle); + ReadColumnarOptions = (ReadColumnarOptions_type) + load_external_function(COLUMNAR_LIB_NAME, "ReadColumnarOptions", + true, &handle); + + /* + * Finally, acquire symbols the "pass through" to columnar so + * that a SQL function declared on the citus module can be + * defined in the columnar module. This helps with the upgrade + * transition, where some columnar functions + * (e.g. columnar_handler) are declared in SQL to be in the + * citus module. + */ } diff --git a/src/include/distributed/shared_library_init.h b/src/include/distributed/shared_library_init.h index b5bc09da3..1ca5d9f78 100644 --- a/src/include/distributed/shared_library_init.h +++ b/src/include/distributed/shared_library_init.h @@ -11,6 +11,8 @@ #ifndef SHARED_LIBRARY_INIT_H #define SHARED_LIBRARY_INIT_H +#include "columnar/columnar.h" + #define GUC_STANDARD 0 #define MAX_SHARD_COUNT 64000 #define MAX_SHARD_REPLICATION_FACTOR 100