Skip to content

dump triggers with their timing instead of always AFTER - #557

Merged
deitch merged 1 commit into
databacker:mainfrom
jayhemnani9910:fix/dump-trigger-timing
Nov 20, 2026
Merged

deitch merged 1 commit into
databacker:mainfrom
jayhemnani9910:fix/dump-trigger-timing

Conversation

@jayhemnani9910

Copy link
Copy Markdown
Contributor

With --triggers, every trigger is written to the dump as AFTER <event>. dumpTriggers reads the timing from SHOW TRIGGERS, but the CREATE TRIGGER line hardcodes AFTER. A BEFORE INSERT trigger that sets a NEW column then fails on restore with ERROR 1362: Updating of NEW row is not allowed in after trigger, and other BEFORE triggers come back with the wrong timing.

The line now uses the scanned timing. The integration test fixture only had an AFTER trigger; I added a BEFORE INSERT one that fills a default, so the test covers both.

Checked against MySQL 8.4: a BEFORE INSERT trigger that sets NEW.pid, dumped with --triggers, is written as BEFORE INSERT, restores, and still fills the column on insert. I didn't run the full integration suite locally.

@deitch deitch left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good catch, thank you.

Signed-off-by: Jay Hemnani <193022578+jayhemnani9910@users.noreply.github.com>
@deitch
deitch force-pushed the fix/dump-trigger-timing branch from 0c150f2 to 443e850 Compare November 20, 2026 10:45
@deitch
deitch merged commit b55a64c into databacker:main Nov 20, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants