[MDEV-25659] trigger name is empty after upgrade to 10.4 Created: 2021-05-12 Updated: 2022-01-14 Resolved: 2022-01-14 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Stored routines, Triggers |
| Affects Version/s: | 10.4, 10.5 |
| Fix Version/s: | 10.4.23, 10.5.14, 10.6.6, 10.7.2, 10.8.1 |
| Type: | Bug | Priority: | Critical |
| Reporter: | Muhammad Irfan | Assignee: | Alexander Barkov |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Description |
|
Created trigger on 10.3 installation with oracle mode.
And after upgrade to 10.4, TRIGGER_NAME column is empty.
And can't find way to drop trigger or write to table in question. Tried to set same sql_mode as for trigger and bounce server but no luck.
|
| Comments |
| Comment by Alexander Barkov [ 2021-10-14 ] | ||||||||||||||||||||||||||||||||||
|
This is a combination of multiple issues. The trigger was actually wrong. MariaDB does not support yet Oracle's multi-event triggers like CREATE TRIGGER .. AFTER DELETE OR UPDATE and therefore does not support syntax IF DELETING or IF UPDATING inside the trigger. This task in on our TODO list: MDEV-10164 So DELETING is considered as a local undeclared variable. In 10.3 the CREATE PROCEDURE/FUNCTION/TRIGGER statement accepted undeclared variables, but the error later happened during the routine execution time. That was wrong. The trigger with the reported body should not have worked in 10.3 too - it should have returned the error during the execution time. In 10.4 we implemented a stricter control for undeclared variables. So 10.4 returns the error at CREATE time. I can confirm the empty trigger name in INFORMATION_SCHEMA.TRIGGERS output. I run this script in 10.3:
Then stop the 10.3 server and start the 10.4 server on top of the same database directory and run this statement:
Notice, the trigger_name value is empty. The same problem is repeatable with SHOW TRIGGERS. I can also reproduce that 10.4 cannot now drop the trigger:
This is certainly a bug. A simple workaround to drop the trigger:
Then you can recreate the trigger with a correct 10.4 syntax to avoid the undeclared variable error. | ||||||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2022-01-13 ] | ||||||||||||||||||||||||||||||||||
|
More observation: I run this script in 10.4, with a correct trigger definition:
Now I edit $DATADIR/test/tr1.TRG and change:
to
pretending that this trigger was created by some earlier MariaDB version. As a result, the trigger definition becomes incorrect (intentionally). Now I run:
Then check the database directory: Opps. The file $DATADIR/test/tr1.TRN was not deleted! After that it's not possible to create triggers for t1 any more. An attempt to re-run the above script returns an error when the CREATE OR REPLACE TRIGGER is being executed:
| ||||||||||||||||||||||||||||||||||
| Comment by Alexander Barkov [ 2022-01-13 ] | ||||||||||||||||||||||||||||||||||
|
Hi shulga, can you please review a patch: Thanks | ||||||||||||||||||||||||||||||||||
| Comment by Dmitry Shulga [ 2022-01-13 ] | ||||||||||||||||||||||||||||||||||
|
Looks good for me |