Skip to content

Commit 33fc4cc

Browse files
committed
workload/schemachanger: fix trigger function generation
Previously, the triggers we generated on tables would silently discard IUD operations. This patch makes sure that the trigger does random work and allows the IUD operation to continue. Fixes: #150752 Release note: None
1 parent 97b756d commit 33fc4cc

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

pkg/workload/schemachange/operation_generator.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5398,8 +5398,9 @@ func (og *operationGenerator) createTrigger(ctx context.Context, tx pgx.Tx) (*op
53985398
if err != nil {
53995399
return nil, err
54005400
}
5401-
5402-
triggerFunction := fmt.Sprintf(`CREATE FUNCTION %s() RETURNS TRIGGER AS $FUNC_BODY$ BEGIN %s;RETURN NULL;END; $FUNC_BODY$ LANGUAGE PLpgSQL`, triggerFunctionName, selectStmt.sql)
5401+
// Our trigger function will always return the original value to avoid
5402+
// breaking inserts.
5403+
triggerFunction := fmt.Sprintf(`CREATE FUNCTION %s() RETURNS TRIGGER AS $FUNC_BODY$ BEGIN %s;RETURN NEW;END; $FUNC_BODY$ LANGUAGE PLpgSQL`, triggerFunctionName, selectStmt.sql)
54035404

54045405
og.LogMessage(fmt.Sprintf("Created trigger function %s", triggerFunction))
54055406

0 commit comments

Comments
 (0)