Skip to content

Commit

Permalink
Remove code related to pre 1.0 triggers
Browse files Browse the repository at this point in the history
This code is no longer needed as no valid source timescaledb version
in upgrade path can have those legacy triggers.
  • Loading branch information
svenklemm committed Oct 12, 2023
1 parent 6af0cb0 commit ecd88f8
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 70 deletions.
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

0 comments on commit ecd88f8

Please sign in to comment.