add rendezvous variable

separate-modules
Jeff Davis 2022-03-15 16:48:49 -07:00 committed by Jeff Davis
parent a5f4ef5943
commit d157496513
3 changed files with 29 additions and 10 deletions

View File

@ -103,8 +103,8 @@ typedef struct IndexFetchColumnarData
MemoryContext scanContext; MemoryContext scanContext;
} IndexFetchColumnarData; } IndexFetchColumnarData;
/* available to other extensions using find_rendezvous_variable() */
ColumnarTableSetOptions_hook_type ColumnarTableSetOptions_hook = NULL; static ColumnarTableSetOptions_hook_type ColumnarTableSetOptions_hook = NULL;
static object_access_hook_type PrevObjectAccessHook = NULL; static object_access_hook_type PrevObjectAccessHook = NULL;
static ProcessUtility_hook_type PrevProcessUtilityHook = NULL; static ProcessUtility_hook_type PrevProcessUtilityHook = NULL;
@ -1910,6 +1910,11 @@ ColumnarSubXactCallback(SubXactEvent event, SubTransactionId mySubid,
void void
columnar_tableam_init() columnar_tableam_init()
{ {
ColumnarTableSetOptions_hook_type **ColumnarTableSetOptions_hook_ptr =
(ColumnarTableSetOptions_hook_type **) find_rendezvous_variable(
"ColumnarTableSetOptions_hook");
*ColumnarTableSetOptions_hook_ptr = &ColumnarTableSetOptions_hook;
RegisterXactCallback(ColumnarXactCallback, NULL); RegisterXactCallback(ColumnarXactCallback, NULL);
RegisterSubXactCallback(ColumnarSubXactCallback, NULL); RegisterSubXactCallback(ColumnarSubXactCallback, NULL);

View File

@ -323,12 +323,6 @@ _PG_init(void)
original_client_auth_hook = ClientAuthentication_hook; original_client_auth_hook = ClientAuthentication_hook;
ClientAuthentication_hook = CitusAuthHook; ClientAuthentication_hook = CitusAuthHook;
/*
* When the options change on a columnar table, we may need to propagate
* the changes to shards.
*/
ColumnarTableSetOptions_hook = ColumnarTableSetOptionsHook;
InitializeMaintenanceDaemon(); InitializeMaintenanceDaemon();
/* initialize coordinated transaction management */ /* initialize coordinated transaction management */
@ -357,7 +351,28 @@ _PG_init(void)
{ {
DoInitialCleanup(); DoInitialCleanup();
} }
columnar_init();
/*
* For convenience and backwards compatibility, we avoid users
* having to add both citus and columnar to
* shared_preload_libraries by loading citus_columnar.so as
* part of loading citus.so.
*/
load_file(COLUMNAR_LIB_NAME, false);
ColumnarTableSetOptions_hook_type **ColumnarTableSetOptions_hook_ptr =
(ColumnarTableSetOptions_hook_type **) find_rendezvous_variable(
"ColumnarTableSetOptions_hook");
/* rendezvous variable registered during columnar initialization */
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;
} }

View File

@ -205,7 +205,6 @@ extern int columnar_compression_level;
/* called when the user changes options on the given relation */ /* called when the user changes options on the given relation */
typedef void (*ColumnarTableSetOptions_hook_type)(Oid relid, ColumnarOptions options); typedef void (*ColumnarTableSetOptions_hook_type)(Oid relid, ColumnarOptions options);
extern ColumnarTableSetOptions_hook_type ColumnarTableSetOptions_hook;
extern void columnar_init(void); extern void columnar_init(void);
extern void columnar_init_gucs(void); extern void columnar_init_gucs(void);