-
-
Notifications
You must be signed in to change notification settings - Fork 2k
MDEV-30645: Generalized triggers #3296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
andremralves
wants to merge
9
commits into
MariaDB:11.6
Choose a base branch
from
andremralves:trigger_as_event
base: 11.6
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3e6df94
Make create trigger a synonym for create event
andremralves 9ae502c
Implement startup and shutdown triggers
andremralves d19a72c
Standardize error messages
andremralves 591c15a
Fix upgrade_mysql
andremralves fddd07b
Fix windows build
andremralves e82d4ef
Fixup: some rpl and embedded test errors and other minor issues
andremralves d86d0ec
Fixup: remove unneeded sleep
andremralves d0cbf9a
Improve formatting
andremralves 1d73ccd
Improve implementation of Generalized triggers
andremralves File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| CREATE TABLE t1 (inc INT); | ||
| INSERT INTO t1 VALUES (0); | ||
| SELECT * FROM t1; | ||
| inc | ||
| 0 | ||
| CREATE OR REPLACE TRIGGER IF NOT EXISTS trg BEFORE SHUTDOWN DO UPDATE test.t1 SET inc = inc + 1; | ||
| ERROR HY000: Incorrect usage of OR REPLACE and IF NOT EXISTS | ||
| CREATE OR REPLACE TRIGGER trg AFTER SHUTDOWN DO UPDATE test.t1 SET inc = inc + 1; | ||
| ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SHUTDOWN DO UPDATE test.t1 SET inc = inc + 1' at line 1 | ||
| CREATE TRIGGER trg BEFORE SHUTDOWN DO UPDATE test.t1 SET inc = inc + 1; | ||
| # restart | ||
| SELECT * FROM t1; | ||
| inc | ||
| 1 | ||
| DROP TABLE t1; | ||
| DROP TRIGGER trg; | ||
| DROP TRIGGER trg; | ||
| ERROR HY000: Trigger does not exist | ||
| DROP TRIGGER IF EXISTS trg; | ||
| Warnings: | ||
| Note 1360 Trigger does not exist | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| --source include/not_embedded.inc | ||
| --source include/no_view_protocol.inc | ||
|
|
||
| CREATE TABLE t1 (inc INT); | ||
| INSERT INTO t1 VALUES (0); | ||
| SELECT * FROM t1; | ||
|
|
||
| --error ER_WRONG_USAGE | ||
| CREATE OR REPLACE TRIGGER IF NOT EXISTS trg BEFORE SHUTDOWN DO UPDATE test.t1 SET inc = inc + 1; | ||
| --error ER_PARSE_ERROR | ||
| CREATE OR REPLACE TRIGGER trg AFTER SHUTDOWN DO UPDATE test.t1 SET inc = inc + 1; | ||
|
|
||
| CREATE TRIGGER trg BEFORE SHUTDOWN DO UPDATE test.t1 SET inc = inc + 1; | ||
|
|
||
| --source include/restart_mysqld.inc | ||
|
|
||
| SELECT * FROM t1; | ||
|
|
||
| DROP TABLE t1; | ||
| DROP TRIGGER trg; | ||
| --error ER_TRG_DOES_NOT_EXIST | ||
| DROP TRIGGER trg; | ||
| DROP TRIGGER IF EXISTS trg; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| CREATE TABLE t1 (inc INT); | ||
| INSERT INTO t1 VALUES (0); | ||
| SELECT * FROM t1; | ||
| inc | ||
| 0 | ||
| CREATE OR REPLACE TRIGGER IF NOT EXISTS trg AFTER STARTUP DO UPDATE test.t1 SET inc = inc + 1; | ||
| ERROR HY000: Incorrect usage of OR REPLACE and IF NOT EXISTS | ||
| CREATE OR REPLACE TRIGGER trg BEFORE STARTUP DO UPDATE test.t1 SET inc = inc + 1; | ||
| ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'STARTUP DO UPDATE test.t1 SET inc = inc + 1' at line 1 | ||
| CREATE TRIGGER trg AFTER STARTUP DO UPDATE test.t1 SET inc = inc + 1; | ||
| # restart | ||
| SELECT * FROM t1; | ||
| inc | ||
| 1 | ||
| DROP TABLE t1; | ||
| DROP TRIGGER trg; | ||
| DROP TRIGGER trg; | ||
| ERROR HY000: Trigger does not exist | ||
| DROP TRIGGER IF EXISTS trg; | ||
| Warnings: | ||
| Note 1360 Trigger does not exist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| --source include/not_embedded.inc | ||
| --source include/no_view_protocol.inc | ||
|
|
||
| CREATE TABLE t1 (inc INT); | ||
| INSERT INTO t1 VALUES (0); | ||
| SELECT * FROM t1; | ||
|
|
||
| --error ER_WRONG_USAGE | ||
| CREATE OR REPLACE TRIGGER IF NOT EXISTS trg AFTER STARTUP DO UPDATE test.t1 SET inc = inc + 1; | ||
| --error ER_PARSE_ERROR | ||
| CREATE OR REPLACE TRIGGER trg BEFORE STARTUP DO UPDATE test.t1 SET inc = inc + 1; | ||
|
|
||
| CREATE TRIGGER trg AFTER STARTUP DO UPDATE test.t1 SET inc = inc + 1; | ||
|
|
||
| --source include/restart_mysqld.inc | ||
|
|
||
| SELECT * FROM t1; | ||
|
|
||
| DROP TABLE t1; | ||
| DROP TRIGGER trg; | ||
| --error ER_TRG_DOES_NOT_EXIST | ||
| DROP TRIGGER trg; | ||
| DROP TRIGGER IF EXISTS trg; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| SET GLOBAL event_scheduler=off; | ||
| CREATE TABLE t1 (a INT); | ||
| CREATE OR REPLACE TRIGGER IF NOT EXISTS ev1 ON SCHEDULE EVERY 1 SECOND DO DROP DATABASE db1; | ||
| ERROR HY000: Incorrect usage of OR REPLACE and IF NOT EXISTS | ||
| CREATE OR REPLACE TRIGGER ev1 IN SCHEDULE EVERY 1 SECOND DO DROP DATABASE db1; | ||
| ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'IN SCHEDULE EVERY 1 SECOND DO DROP DATABASE db1' at line 1 | ||
| CREATE OR REPLACE TRIGGER ev1 AFTER SCHEDULE EVERY 1 SECOND DO DROP DATABASE db1; | ||
| ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SCHEDULE EVERY 1 SECOND DO DROP DATABASE db1' at line 1 | ||
| CREATE OR REPLACE TRIGGER ev1 BEFORE SCHEDULE EVERY 1 SECOND DO DROP DATABASE db1; | ||
| ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'SCHEDULE EVERY 1 SECOND DO DROP DATABASE db1' at line 1 | ||
| CREATE TRIGGER ev1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO t1 VALUES (10); | ||
| Warnings: | ||
| Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. | ||
andremralves marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| SELECT EVENT_NAME, EVENT_DEFINITION FROM INFORMATION_SCHEMA.EVENTS; | ||
| EVENT_NAME EVENT_DEFINITION | ||
| ev1 INSERT INTO t1 VALUES (10) | ||
| SET GLOBAL event_scheduler=on; | ||
| SELECT DISTINCT a FROM t1; | ||
| a | ||
| 10 | ||
| SET GLOBAL event_scheduler=off; | ||
| DELETE FROM t1; | ||
| CREATE TRIGGER ev1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO t1 VALUES (11); | ||
| ERROR HY000: Trigger 'ev1' already exists | ||
| SELECT EVENT_NAME, EVENT_DEFINITION FROM INFORMATION_SCHEMA.EVENTS; | ||
| EVENT_NAME EVENT_DEFINITION | ||
| ev1 INSERT INTO t1 VALUES (10) | ||
| CREATE TRIGGER IF NOT EXISTS ev1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO t1 VALUES (12); | ||
| Warnings: | ||
| Note 1359 Trigger 'ev1' already exists | ||
| Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. | ||
| SELECT EVENT_NAME, EVENT_DEFINITION FROM INFORMATION_SCHEMA.EVENTS; | ||
| EVENT_NAME EVENT_DEFINITION | ||
| ev1 INSERT INTO t1 VALUES (10) | ||
| CREATE OR REPLACE TRIGGER ev1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO t1 VALUES (13); | ||
| Warnings: | ||
| Warning 1105 Event scheduler is switched off, use SET GLOBAL event_scheduler=ON to enable it. | ||
| SELECT EVENT_NAME, EVENT_DEFINITION FROM INFORMATION_SCHEMA.EVENTS; | ||
| EVENT_NAME EVENT_DEFINITION | ||
| ev1 INSERT INTO t1 VALUES (13) | ||
| SET GLOBAL event_scheduler=on; | ||
| SELECT DISTINCT a FROM t1; | ||
| a | ||
| 13 | ||
| SET GLOBAL event_scheduler=off; | ||
| DELETE FROM t1; | ||
| DROP TRIGGER IF EXISTS ev1; | ||
| SELECT EVENT_NAME, EVENT_DEFINITION FROM INFORMATION_SCHEMA.EVENTS; | ||
| EVENT_NAME EVENT_DEFINITION | ||
| DROP TRIGGER IF EXISTS ev1; | ||
| Warnings: | ||
| Note 1360 Trigger does not exist | ||
| DROP TRIGGER ev1; | ||
| ERROR HY000: Trigger does not exist | ||
| SELECT EVENT_NAME, EVENT_DEFINITION FROM INFORMATION_SCHEMA.EVENTS; | ||
| EVENT_NAME EVENT_DEFINITION | ||
| DROP TABLE t1; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| --source include/not_embedded.inc | ||
| --source include/no_view_protocol.inc | ||
andremralves marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| SET GLOBAL event_scheduler=off; | ||
|
|
||
| CREATE TABLE t1 (a INT); | ||
|
|
||
| --error ER_WRONG_USAGE | ||
| CREATE OR REPLACE TRIGGER IF NOT EXISTS ev1 ON SCHEDULE EVERY 1 SECOND DO DROP DATABASE db1; | ||
| --error ER_PARSE_ERROR | ||
| CREATE OR REPLACE TRIGGER ev1 IN SCHEDULE EVERY 1 SECOND DO DROP DATABASE db1; | ||
| --error ER_PARSE_ERROR | ||
| CREATE OR REPLACE TRIGGER ev1 AFTER SCHEDULE EVERY 1 SECOND DO DROP DATABASE db1; | ||
| --error ER_PARSE_ERROR | ||
| CREATE OR REPLACE TRIGGER ev1 BEFORE SCHEDULE EVERY 1 SECOND DO DROP DATABASE db1; | ||
|
|
||
| CREATE TRIGGER ev1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO t1 VALUES (10); | ||
| SELECT EVENT_NAME, EVENT_DEFINITION FROM INFORMATION_SCHEMA.EVENTS; | ||
| --source include/count_sessions.inc | ||
| SET GLOBAL event_scheduler=on; | ||
| let $wait_condition= SELECT count(*)>0 FROM t1; | ||
| --source include/wait_condition.inc | ||
| SELECT DISTINCT a FROM t1; | ||
| SET GLOBAL event_scheduler=off; | ||
| --source include/wait_until_count_sessions.inc | ||
| DELETE FROM t1; | ||
|
|
||
| --error ER_TRG_ALREADY_EXISTS | ||
| CREATE TRIGGER ev1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO t1 VALUES (11); | ||
| SELECT EVENT_NAME, EVENT_DEFINITION FROM INFORMATION_SCHEMA.EVENTS; | ||
| CREATE TRIGGER IF NOT EXISTS ev1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO t1 VALUES (12); | ||
| SELECT EVENT_NAME, EVENT_DEFINITION FROM INFORMATION_SCHEMA.EVENTS; | ||
| CREATE OR REPLACE TRIGGER ev1 ON SCHEDULE EVERY 1 SECOND DO INSERT INTO t1 VALUES (13); | ||
| SELECT EVENT_NAME, EVENT_DEFINITION FROM INFORMATION_SCHEMA.EVENTS; | ||
|
|
||
| SET GLOBAL event_scheduler=on; | ||
| let $wait_condition= SELECT count(*)>0 FROM t1; | ||
| --source include/wait_condition.inc | ||
| SELECT DISTINCT a FROM t1; | ||
| SET GLOBAL event_scheduler=off; | ||
| --source include/wait_until_count_sessions.inc | ||
| DELETE FROM t1; | ||
|
|
||
| DROP TRIGGER IF EXISTS ev1; | ||
| SELECT EVENT_NAME, EVENT_DEFINITION FROM INFORMATION_SCHEMA.EVENTS; | ||
| DROP TRIGGER IF EXISTS ev1; | ||
| --error ER_TRG_DOES_NOT_EXIST | ||
| DROP TRIGGER ev1; | ||
| SELECT EVENT_NAME, EVENT_DEFINITION FROM INFORMATION_SCHEMA.EVENTS; | ||
|
|
||
| DROP TABLE t1; | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
add
show triggersandshow create triggerhere, please.