Remove process_utility hooks used by multinode

This commit is contained in:
Sven Klemm 2023-12-13 16:58:00 +01:00 committed by Sven Klemm
parent 19f1395191
commit dde86ac116
11 changed files with 1 additions and 1639 deletions

View File

@ -396,9 +396,6 @@ TSDLLEXPORT CrossModuleFunctions ts_cm_functions_default = {
.set_rel_pathlist_dml = NULL,
.set_rel_pathlist_query = NULL,
.set_rel_pathlist = NULL,
.ddl_command_start = NULL,
.ddl_command_end = NULL,
.sql_drop = NULL,
.process_altertable_cmd = NULL,
.process_rename_cmd = NULL,

View File

@ -92,9 +92,6 @@ typedef struct CrossModuleFunctions
PGFunction copy_chunk_proc;
PGFunction subscription_exec;
PGFunction copy_chunk_cleanup_proc;
void (*ddl_command_start)(ProcessUtilityArgs *args);
void (*ddl_command_end)(EventTriggerData *command);
void (*sql_drop)(List *dropped_objects);
/* Vectorized queries */
bool (*push_down_aggregation)(PlannerInfo *root, AggPath *aggregation_path, Path *subpath);

View File

@ -4439,9 +4439,6 @@ timescaledb_ddl_command_start(PlannedStmt *pstmt, const char *query_string,
* standard process utility hook to maintain proper invocation
* order of sql_drop and ddl_command_end triggers.
*/
if (ts_cm_functions->ddl_command_start)
ts_cm_functions->ddl_command_start(&args);
if (result == DDL_CONTINUE)
prev_ProcessUtility(&args);
}
@ -4454,9 +4451,6 @@ process_ddl_event_command_end(EventTriggerData *trigdata)
/* Inhibit collecting new commands while in the trigger */
EventTriggerInhibitCommandCollection();
if (ts_cm_functions->ddl_command_end)
ts_cm_functions->ddl_command_end(trigdata);
switch (nodeTag(trigdata->parsetree))
{
case T_AlterTableStmt:
@ -4479,9 +4473,6 @@ process_ddl_event_sql_drop(EventTriggerData *trigdata)
ListCell *lc;
List *dropped_objects = ts_event_trigger_dropped_objects();
if (ts_cm_functions->sql_drop)
ts_cm_functions->sql_drop(dropped_objects);
foreach (lc, dropped_objects)
process_ddl_sql_drop(lfirst(lc));
}

View File

@ -210,9 +210,6 @@ CrossModuleFunctions tsl_cm_functions = {
.remote_txn_heal_data_node = remote_txn_heal_data_node,
.remote_connection_cache_show = remote_connection_cache_show,
.set_rel_pathlist = tsl_set_rel_pathlist,
.ddl_command_start = tsl_ddl_command_start,
.ddl_command_end = tsl_ddl_command_end,
.sql_drop = tsl_sql_drop,
.set_distributed_id = dist_util_set_id,
.set_distributed_peer_id = dist_util_set_peer_id,
.is_access_node_session = dist_util_is_access_node_session_on_data_node,
@ -240,7 +237,6 @@ CrossModuleFunctions tsl_cm_functions = {
static void
ts_module_cleanup_on_pg_exit(int code, Datum arg)
{
_tsl_process_utility_fini();
_remote_dist_txn_fini();
_remote_connection_cache_fini();
_continuous_aggs_cache_inval_fini();
@ -261,7 +257,6 @@ ts_module_init(PG_FUNCTION_ARGS)
_skip_scan_init();
_remote_connection_cache_init();
_remote_dist_txn_init();
_tsl_process_utility_init();
/* Register a cleanup function to be called when the backend exits */
if (register_proc_exit)
on_proc_exit(ts_module_cleanup_on_pg_exit, 0);

View File

@ -16,18 +16,6 @@
#include "process_utility.h"
#include "remote/dist_commands.h"
#include "remote/connection_cache.h"
#include "remote/dist_ddl.h"
void
tsl_ddl_command_start(ProcessUtilityArgs *args)
{
if (IsA(args->parsetree, DropdbStmt))
{
DropdbStmt *stmt = castNode(DropdbStmt, args->parsetree);
remote_connection_cache_dropped_db_callback(stmt->dbname);
}
dist_ddl_start(args);
}
/* AlterTableCmds that need tsl side processing invoke this function
* we only process AddColumn command right now.
@ -90,61 +78,3 @@ tsl_process_rename_cmd(Oid relid, Cache *hcache, const RenameStmt *stmt)
}
}
}
void
tsl_ddl_command_end(EventTriggerData *command)
{
dist_ddl_end(command);
}
void
tsl_sql_drop(List *dropped_objects)
{
dist_ddl_drop(dropped_objects);
}
static void
tsl_process_utility_xact_abort(XactEvent event, void *arg)
{
switch (event)
{
case XACT_EVENT_ABORT:
case XACT_EVENT_PARALLEL_ABORT:
dist_ddl_state_reset();
break;
default:
break;
}
}
static void
tsl_process_utility_subxact_abort(SubXactEvent event, SubTransactionId mySubid,
SubTransactionId parentSubid, void *arg)
{
switch (event)
{
case SUBXACT_EVENT_ABORT_SUB:
dist_ddl_state_reset();
break;
default:
break;
}
}
void
_tsl_process_utility_init(void)
{
dist_ddl_state_init();
RegisterXactCallback(tsl_process_utility_xact_abort, NULL);
RegisterSubXactCallback(tsl_process_utility_subxact_abort, NULL);
}
void
_tsl_process_utility_fini(void)
{
dist_ddl_state_reset();
UnregisterXactCallback(tsl_process_utility_xact_abort, NULL);
UnregisterSubXactCallback(tsl_process_utility_subxact_abort, NULL);
}

View File

@ -7,11 +7,5 @@
#include <process_utility.h>
extern void _tsl_process_utility_init(void);
extern void _tsl_process_utility_fini(void);
extern void tsl_ddl_command_start(ProcessUtilityArgs *args);
extern void tsl_ddl_command_end(EventTriggerData *command);
extern void tsl_sql_drop(List *dropped_objects);
extern void tsl_process_altertable_cmd(Hypertable *ht, const AlterTableCmd *cmd);
extern void tsl_process_rename_cmd(Oid relid, Cache *hcache, const RenameStmt *stmt);

View File

@ -8,7 +8,6 @@ set(SOURCES
${CMAKE_CURRENT_SOURCE_DIR}/data_format.c
${CMAKE_CURRENT_SOURCE_DIR}/dist_txn.c
${CMAKE_CURRENT_SOURCE_DIR}/dist_commands.c
${CMAKE_CURRENT_SOURCE_DIR}/dist_ddl.c
${CMAKE_CURRENT_SOURCE_DIR}/prepared_statement_fetcher.c
${CMAKE_CURRENT_SOURCE_DIR}/copy_fetcher.c
${CMAKE_CURRENT_SOURCE_DIR}/stmt_params.c

File diff suppressed because it is too large Load Diff

View File

@ -1,14 +0,0 @@
/*
* This file and its contents are licensed under the Timescale License.
* Please see the included NOTICE for copyright information and
* LICENSE-TIMESCALE for a copy of the license.
*/
#pragma once
#include <process_utility.h>
extern void dist_ddl_state_init(void);
extern void dist_ddl_state_reset(void);
extern void dist_ddl_start(ProcessUtilityArgs *args);
extern void dist_ddl_end(EventTriggerData *command);
extern void dist_ddl_drop(List *dropped_objects);

View File

@ -1,5 +1,5 @@
set(SOURCES test_chunk_stats.c test_merge_chunk.c test_compression.c
test_continuous_agg.c test_ddl_hook.c)
test_continuous_agg.c)
include(${PROJECT_SOURCE_DIR}/tsl/src/build-defs.cmake)

View File

@ -1,221 +0,0 @@
/*
* This file and its contents are licensed under the Timescale License.
* Please see the included NOTICE for copyright information and
* LICENSE-TIMESCALE for a copy of the license.
*/
#include <string.h>
#include <unistd.h>
#include <postgres.h>
#include <fmgr.h>
#include "export.h"
#include "test_utils.h"
#include "process_utility.h"
#include "compat/compat.h"
#include "event_trigger.h"
#include "cross_module_fn.h"
TS_FUNCTION_INFO_V1(ts_test_ddl_command_hook_reg);
TS_FUNCTION_INFO_V1(ts_test_ddl_command_hook_unreg);
static List *tsl_delayed_execution_list = NIL;
static void (*ddl_command_start)(ProcessUtilityArgs *args);
static void (*ddl_command_end)(EventTriggerData *command);
static void (*sql_drop)(List *dropped_objects);
static void
test_ddl_command_start(ProcessUtilityArgs *args)
{
Cache *hcache;
ListCell *cell;
Hypertable *ht;
elog(NOTICE,
"test_ddl_command_start: %d hypertables, query: %s",
list_length(args->hypertable_list),
args->query_string);
/*
* Hypertable oid from those commands is available in hypertable_list but
* cannot be resolved here until standard utility hook will synchronize new
* relation name and schema.
*
* Save hypertable list here for command_end execution to avoid statement
* parsing for second time.
*/
switch (nodeTag(args->parsetree))
{
case T_AlterObjectSchemaStmt:
case T_RenameStmt:
elog(NOTICE, "test_ddl_command_start: wait for ddl_command_end");
tsl_delayed_execution_list = list_copy(args->hypertable_list);
return;
default:
break;
}
hcache = ts_hypertable_cache_pin();
foreach (cell, args->hypertable_list)
{
Oid relid = lfirst_oid(cell);
ht = ts_hypertable_cache_get_entry(hcache, relid, false);
elog(NOTICE,
"test_ddl_command_start: %s.%s",
NameStr(ht->fd.schema_name),
NameStr(ht->fd.table_name));
}
ts_cache_release(hcache);
}
static void
test_ddl_command_end(EventTriggerData *command)
{
Cache *hcache;
ListCell *cell;
Hypertable *ht;
elog(NOTICE, "test_ddl_command_end: %s", GetCommandTagName(command->tag));
if (tsl_delayed_execution_list == NIL)
return;
elog(NOTICE,
"test_ddl_command_end: %d hypertables scheduled",
list_length(tsl_delayed_execution_list));
hcache = ts_hypertable_cache_pin();
foreach (cell, tsl_delayed_execution_list)
{
Oid relid = lfirst_oid(cell);
ht = ts_hypertable_cache_get_entry(hcache, relid, false);
elog(NOTICE,
"test_ddl_command_end: %s.%s",
NameStr(ht->fd.schema_name),
NameStr(ht->fd.table_name));
}
ts_cache_release(hcache);
pfree(tsl_delayed_execution_list);
tsl_delayed_execution_list = NIL;
}
static int
event_trigger_event_cmp(const void *obj1, const void *obj2)
{
const EventTriggerDropObject *obj[] = { *((const EventTriggerDropObject **) obj1),
*((const EventTriggerDropObject **) obj2) };
/* This only orders on object type for simplicity. Thus it is assumed that
* the order of objects with the same type is predictible across
* PostgreSQL versions */
return obj[0]->type - obj[1]->type;
}
static void
test_sql_drop(List *dropped_objects)
{
ListCell *lc;
int num_objects = list_length(dropped_objects);
EventTriggerDropObject **objects = palloc(num_objects * sizeof(EventTriggerDropObject *));
int i = 0;
/* Sort the list of dropped objects for predictible order in tests across
* PostgreSQL versions. Note that PG11 introduced a list_qsort function,
* but it is not available in earlier PostgreSQL versions so we're doing
* our own sorting. */
foreach (lc, dropped_objects)
objects[i++] = lfirst(lc);
qsort(objects, num_objects, sizeof(EventTriggerDropObject *), event_trigger_event_cmp);
for (i = 0; i < num_objects; i++)
{
EventTriggerDropObject *obj = objects[i];
switch (obj->type)
{
case EVENT_TRIGGER_DROP_TABLE_CONSTRAINT:
{
EventTriggerDropTableConstraint *event = (EventTriggerDropTableConstraint *) obj;
elog(NOTICE,
"test_sql_drop: constraint: %s.%s.%s",
event->schema,
event->table,
event->constraint_name);
break;
}
case EVENT_TRIGGER_DROP_INDEX:
{
elog(NOTICE, "test_sql_drop: index");
break;
}
case EVENT_TRIGGER_DROP_FOREIGN_TABLE:
case EVENT_TRIGGER_DROP_TABLE:
{
EventTriggerDropRelation *event = (EventTriggerDropRelation *) obj;
elog(NOTICE, "test_sql_drop: table: %s.%s", event->schema, event->name);
break;
}
case EVENT_TRIGGER_DROP_SCHEMA:
{
EventTriggerDropSchema *event = (EventTriggerDropSchema *) obj;
elog(NOTICE, "test_sql_drop: schema: %s", event->schema);
break;
}
case EVENT_TRIGGER_DROP_TRIGGER:
{
elog(NOTICE, "test_sql_drop: trigger");
break;
}
case EVENT_TRIGGER_DROP_VIEW:
{
elog(NOTICE, "test_sql_drop: view");
break;
}
case EVENT_TRIGGER_DROP_FOREIGN_SERVER:
{
elog(NOTICE, "test_sql_drop: foreign server");
break;
}
}
}
}
Datum
ts_test_ddl_command_hook_reg(PG_FUNCTION_ARGS)
{
ddl_command_start = ts_cm_functions->ddl_command_start;
ddl_command_end = ts_cm_functions->ddl_command_end;
sql_drop = ts_cm_functions->sql_drop;
ts_cm_functions->ddl_command_start = test_ddl_command_start;
ts_cm_functions->ddl_command_end = test_ddl_command_end;
ts_cm_functions->sql_drop = test_sql_drop;
PG_RETURN_VOID();
}
Datum
ts_test_ddl_command_hook_unreg(PG_FUNCTION_ARGS)
{
TestAssertTrue(ts_cm_functions->ddl_command_start == test_ddl_command_start);
ts_cm_functions->ddl_command_start = ddl_command_start;
ts_cm_functions->ddl_command_end = ddl_command_end;
ts_cm_functions->sql_drop = sql_drop;
PG_RETURN_VOID();
}