Skip to content

sql: add pg_get_triggerdef builtin#165849

Merged
trunk-io[bot] merged 1 commit intocockroachdb:masterfrom
rafiss:pg-gettriggerdef
Mar 16, 2026
Merged

sql: add pg_get_triggerdef builtin#165849
trunk-io[bot] merged 1 commit intocockroachdb:masterfrom
rafiss:pg-gettriggerdef

Conversation

@rafiss
Copy link
Collaborator

@rafiss rafiss commented Mar 16, 2026

pg_dump calls pg_catalog.pg_get_triggerdef(oid, bool) when reading triggers, which previously failed with "unknown function". Add the builtin with both the 1-arg and 2-arg overloads, joining pg_trigger against crdb_internal.create_trigger_statements to produce the CREATE TRIGGER SQL. The pretty_bool parameter is accepted but not differentiated, matching our approach for pg_get_constraintdef.

Also update pg_get_constraintdef's info string from the generic notUsableInfo placeholder to a real description.

Informs: #20296
Epic: CRDB-42942

Release note (sql change): Added the pg_get_triggerdef builtin function, which returns the CREATE TRIGGER statement for a given trigger OID. This improves PostgreSQL compatibility for databases that contain triggers.

@rafiss rafiss requested review from bghal and spilchen March 16, 2026 20:22
@rafiss rafiss requested a review from a team as a code owner March 16, 2026 20:22
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@trunk-io
Copy link
Contributor

trunk-io bot commented Mar 16, 2026

😎 Merged directly without going through the merge queue, as the queue was empty and the PR was up to date with the target branch - details.

Copy link
Contributor

@bghal bghal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth a comment or mention that the pretty_bool parameter isn't used?

Copy link
Collaborator Author

@rafiss rafiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TFTR

/trunk merge

pg_dump calls pg_catalog.pg_get_triggerdef(oid, bool) when reading
triggers, which previously failed with "unknown function". Add the
builtin with both the 1-arg and 2-arg overloads, joining pg_trigger
against crdb_internal.create_trigger_statements to produce the
CREATE TRIGGER SQL. The pretty_bool parameter is accepted but not
differentiated, matching our approach for pg_get_constraintdef.

Also update pg_get_constraintdef's info string from the generic
notUsableInfo placeholder to a real description.

Informs: cockroachdb#20296
Epic: CRDB-42942

Release note (sql change): Added the pg_get_triggerdef builtin
function, which returns the CREATE TRIGGER statement for a given
trigger OID. This improves PostgreSQL compatibility for databases
that contain triggers.

Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
@rafiss rafiss force-pushed the pg-gettriggerdef branch from 730f553 to 8ac2f3d Compare March 16, 2026 22:22
@trunk-io trunk-io bot merged commit a3ec6a4 into cockroachdb:master Mar 16, 2026
24 checks passed
@rafiss rafiss deleted the pg-gettriggerdef branch March 18, 2026 01:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants