Skip to content

Commit

Permalink
BABEL: Add reverse dependency between TSQL trigger and trigger functi…
Browse files Browse the repository at this point in the history
…on during restore (yugabyte#22)

TSQL triggers needs reverse dependency from trigger function to
trigger. It helps in dropping function when trigger itself is dropped
as trigger functions are internal to TSQL triggers. This dependency
is added specifically for TSQL triggers only.

During restore, TSQL triggers are restored using two parts, first function
restore followed by trigger restore using PG semantics. This code path
does not execute TSQL logic to add reverse dependency. As a fix, we have
moved reverse dependency addition to a place which executes during both
normal trigger creation and restore.

Task: BABEL-3249

Signed-off-by: Surendra Vishnoi <[email protected]>
(cherry picked from commit 86cb849947ddb702a5f21e0f637fd97f3e10be63)
  • Loading branch information
surendravishnoi authored and abhinab-yb committed Nov 14, 2024
1 parent c372ef9 commit 16007fe
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/postgres/src/backend/commands/trigger.c
Original file line number Diff line number Diff line change
Expand Up @@ -1183,6 +1183,15 @@ CreateTriggerFiringOn(CreateTrigStmt *stmt, const char *queryString,
referenced.objectSubId = 0;
recordDependencyOn(&myself, &referenced, DEPENDENCY_NORMAL);

/*
* For composite triggers, add dependency from trigger function
* to trigger so that a drop trigger will result in cascade drop
* for function as well. Trigger functions are created as part of
* create trigger for composite triggers.
*/
if (is_composite_trigger)
recordDependencyOn(&referenced, &myself, DEPENDENCY_NORMAL);

if (isInternal && OidIsValid(constraintOid))
{
/*
Expand Down

0 comments on commit 16007fe

Please sign in to comment.