Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some code related to pre 1.0 triggers #6187

Merged
merged 1 commit into from
Oct 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions sql/updates/pre-update.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,6 @@ SET LOCAL max_parallel_workers = 0;
DROP EVENT TRIGGER IF EXISTS timescaledb_ddl_command_end;
DROP EVENT TRIGGER IF EXISTS timescaledb_ddl_sql_drop;

-- These are legacy triggers. They need to be disabled here even
-- though they don't exist in newer versions, because they might still
-- exist when upgrading from older versions. Thus we need to DROP all
-- triggers here that have ever been created.
DROP TRIGGER IF EXISTS "0_cache_inval" ON _timescaledb_catalog.hypertable;
DROP TRIGGER IF EXISTS "0_cache_inval" ON _timescaledb_catalog.chunk;
DROP TRIGGER IF EXISTS "0_cache_inval" ON _timescaledb_catalog.chunk_constraint;
DROP TRIGGER IF EXISTS "0_cache_inval" ON _timescaledb_catalog.dimension_slice;
DROP TRIGGER IF EXISTS "0_cache_inval" ON _timescaledb_catalog.dimension;

-- Since we want to call the new version of restart_background_workers we
-- create a function that points to that version. The proper restart_background_workers
-- may either be in _timescaledb_internal or in _timescaledb_functions
Expand Down
60 changes: 0 additions & 60 deletions src/hypertable.c
Original file line number Diff line number Diff line change
Expand Up @@ -1509,56 +1509,6 @@ ts_hypertable_insert_blocker(PG_FUNCTION_ARGS)
PG_RETURN_NULL();
}

/*
* Get the legacy insert blocker trigger on a table.
*
* Note that we cannot get the old insert trigger by name since internal triggers
* are made unique by appending the trigger OID, which we do not
* know. Instead, we have to search all triggers.
*/
static Oid
old_insert_blocker_trigger_get(Oid relid)
{
Relation tgrel;
ScanKeyData skey[1];
SysScanDesc tgscan;
HeapTuple tuple;
Oid tgoid = InvalidOid;

tgrel = table_open(TriggerRelationId, AccessShareLock);

ScanKeyInit(&skey[0],
Anum_pg_trigger_tgrelid,
BTEqualStrategyNumber,
F_OIDEQ,
ObjectIdGetDatum(relid));

tgscan = systable_beginscan(tgrel, TriggerRelidNameIndexId, true, NULL, 1, skey);

while (HeapTupleIsValid(tuple = systable_getnext(tgscan)))
{
Form_pg_trigger trig = (Form_pg_trigger) GETSTRUCT(tuple);

if (TRIGGER_TYPE_MATCHES(trig->tgtype,
TRIGGER_TYPE_ROW,
TRIGGER_TYPE_BEFORE,
TRIGGER_TYPE_INSERT) &&
strncmp(OLD_INSERT_BLOCKER_NAME,
NameStr(trig->tgname),
strlen(OLD_INSERT_BLOCKER_NAME)) == 0 &&
trig->tgisinternal)
{
tgoid = trig->oid;
break;
}
}

systable_endscan(tgscan);
table_close(tgrel, AccessShareLock);

return tgoid;
}

/*
* Add an INSERT blocking trigger to a table.
*
Expand Down Expand Up @@ -1621,7 +1571,6 @@ Datum
ts_hypertable_insert_blocker_trigger_add(PG_FUNCTION_ARGS)
{
Oid relid = PG_GETARG_OID(0);
Oid old_trigger;

ts_hypertable_permissions_check(relid, GetUserId());

Expand All @@ -1641,15 +1590,6 @@ ts_hypertable_insert_blocker_trigger_add(PG_FUNCTION_ARGS)
"> COMMIT;",
get_rel_name(relid))));

/* Now drop the old trigger */
old_trigger = old_insert_blocker_trigger_get(relid);
if (OidIsValid(old_trigger))
{
ObjectAddress objaddr = { .classId = TriggerRelationId, .objectId = old_trigger };

performDeletion(&objaddr, DROP_RESTRICT, 0);
}

/* Add the new trigger */
PG_RETURN_OID(insert_blocker_trigger_add(relid));
}
Expand Down
Loading