cockroachdb / cockroachdb/cockroach
sql: support triggers on views
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
In Postgres, it is possible to define row-level INSTEAD OF triggers on view, as well as statement-level BEFORE and AFTER triggers. This issue tracks adding support for triggers on views. See also #126363.
https://www.postgresql.org/docs/18/trigger-definition.html
> On views, triggers can be defined to execute instead of INSERT, UPDATE, or DELETE operations. Such INSTEAD OF triggers are fired once for each row that needs to be modified in the view. It is the responsibility of the trigger's function to perform the necessary modifications to the view's underlying base table(s) and, where appropriate, return the modified row as it will appear in the view. Triggers on views can also be defined to execute once per SQL statement, before or after INSERT, UPDATE, or DELETE operations. However, such triggers are fired only if there is also an INSTEAD OF trigger on the view. Otherwise, any statement targeting the view must be rewritten into a statement affecting its underlying base table(s), and then the triggers that will be fired are the ones attached to the base table(s).
Epic: [CRDB-347](https://cockroachlabs.atlassian.net/browse/CRDB-347)
Jira issue: CRDB-44668
Epic CRDB-347
Contributor guide
Assessment
This issue has not been assessed yet.