Remove code related to pre 1.0 triggers

This code is no longer needed as no valid source timescaledb version
in upgrade path can have those legacy triggers.
This commit is contained in:
Sven Klemm 2023-10-12 05:58:58 +02:00 committed by Sven Klemm
parent 6af0cb00c9
commit ecd88f8c8e
2 changed files with 0 additions and 70 deletions

View File

@ -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

View File

@ -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.
*
@ -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());
@ -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));
}