Skip to content

Create Trigger cannot be used in a transaction or with other statements #140053

Closed
@rmanibus

Description

Describe the problem

Executing a create trigger inside a transaction, or next to another statement fails with:
ERROR: CREATE TRIGGER is only implemented in the declarative schema changer
SQLSTATE: 0A000

I get that I should use the declarative schema changer, but it is confusing to understand when it is used or not.
The only way I managed to create a trigger is to run it in total isolation.

Please describe the issue you observed, and any steps we can take to reproduce it:

To Reproduce

begin;
create trigger the_table_trigger after insert or update or delete
                                            on the_table
                                                for each row
execute function the_table_journal_function();
commit;

What did you do? Describe in your own words.

If possible, provide steps to reproduce the behavior:

  1. Set up CockroachDB cluster ...
  2. Send SQL ... / CLI command ...
  3. Look at UI / log file / client app ...
  4. See error

Expected behavior
A clear and concise description of what you expected to happen.

Additional data / screenshots
If the problem is SQL-related, include a copy of the SQL query and the schema
of the supporting tables.

If a node in your cluster encountered a fatal error, supply the contents of the
log directories (at minimum of the affected node(s), but preferably all nodes).

Note that log files can contain confidential information. Please continue
creating this issue, but contact support@cockroachlabs.com to submit the log
files in private.

If applicable, add screenshots to help explain your problem.

Environment:

  • CockroachDB version [e.g. 2.0.x]
  • Server OS: [e.g. Linux/Distrib]
  • Client app [e.g. cockroach sql, JDBC, ...]

Additional context
What was the impact?

Add any other context about the problem here.

Jira issue: CRDB-46975

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

C-bugCode not up to spec/doc, specs & docs deemed correct. Solution expected to change code/behavior.O-communityOriginated from the communityT-sql-foundationsSQL Foundations Team (formerly SQL Schema + SQL Sessions)X-blathers-triagedblathers was able to find an ownerbranch-release-24.3Used to mark GA and release blockers, technical advisories, and bugs for 24.3branch-release-25.1target-release-25.2.0

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions