[MDEV-11886] Trigger prevents insert after update to 10.1.21-MariaDB-1~trusty Created: 2017-01-23  Updated: 2017-03-07  Resolved: 2017-03-02

Status: Closed
Project: MariaDB Server
Component/s: Server, Triggers
Affects Version/s: 10.1.21
Fix Version/s: 10.1.22, 10.2.5

Type: Bug Priority: Blocker
Reporter: Jonathan Brown Assignee: Sergei Golubchik
Resolution: Fixed Votes: 1
Labels: None
Environment:

Ubuntu Trusty 14.04LTS


Issue Links:
Duplicate
is duplicated by MDEV-11842 Fail to insert on a table where a fie... Closed
Sprint: 10.1.22

 Description   

After upgrading to the latest version from repository (apt-get update && apt-get upgrade), I can no longer insert into tables that have a trigger.

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 211
Server version: 10.1.21-MariaDB-1~trusty mariadb.org binary distribution
 
Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.
 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
MariaDB [(none)]> use devdb;
 
MariaDB [devdb]> drop trigger token_user;
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [devdb]> insert into user (email) values ("junk1@r.com");
Query OK, 1 row affected, 4 warnings (0.01 sec)

MariaDB [devdb]> describe user;
| Field                    | Type             | Null | Key | Default             | Extra          |
| user_id                  | int(10) unsigned | NO   | PRI | NULL                | auto_increment |
| created                  | timestamp        | YES  |     | CURRENT_TIMESTAMP   |                |
| token                    | varchar(255)     | YES  |     |                     |                |
... There are 69 other rows ....
72 rows in set (0.00 sec)
 
MariaDB [devdb]> update user set token = SHA1(RAND()) where user_id = last_insert_id();
Query OK, 1 row affected, 1 warning (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 1

MariaDB [devdb]> DELIMITER ;;
MariaDB [devdb]> CREATE TRIGGER token_user
    -> BEFORE INSERT ON user
    -> FOR EACH ROW
    -> BEGIN
    -> SET NEW.token = SHA1(RAND());
    -> END ;;
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [devdb]> DELIMITER ;
MariaDB [devdb]> 
MariaDB [devdb]> insert into user (email) values ("junk2@r.com");
Query OK, 0 rows affected (0.00 sec)

MariaDB [devdb]> drop trigger token_user;
Query OK, 0 rows affected (0.00 sec)
 
MariaDB [devdb]> insert into user (email) values ("junk2@r.com");
Query OK, 1 row affected, 4 warnings (0.00 sec)
 
The warnings don't appear relevant as they were there before:
 
MariaDB [devdb]> show warnings;
+---------+------+-------------------------------------------------------+
| Level   | Code | Message                                               |
+---------+------+-------------------------------------------------------+
| Warning | 1364 | Field 'store' doesn't have a default value            |
| Warning | 1364 | Field 'expiration_date' doesn't have a default value  |
| Warning | 1364 | Field 'scope' doesn't have a default value            |
| Warning | 1364 | Field 'type' doesn't have a default value |
+---------+------+-------------------------------------------------------+
4 rows in set (0.00 sec)



 Comments   
Comment by Jonathan Brown [ 2017-01-23 ]

The warnings are the problem. This wasn't enforced in this manner in the previous version. I gave the columns default values and it went away.

Comment by Elena Stepanova [ 2017-01-23 ]

Thanks for the report, we have a similar one already, MDEV-11842.

Comment by Ján Regeš [ 2017-02-04 ]

Hi,

this is very insidious bug After yesterday's upgrade from 10.1.20 to 10.1.21, our e-shop works (at first look), but it was not possible to insert orders or
purchases on stores for 12 hours After downgrade it works again.

Comment by Ján Regeš [ 2017-02-08 ]

Could be this fatal issue added to issues that needs to be fixed in 10.1.22? (https://jira.mariadb.org/projects/MDEV/versions/22502)

Thank you.

Comment by Elena Stepanova [ 2017-02-08 ]

jan.reges,
it will be fixed in 10.1.22. The original report, MDEV-11842, has already been set to be a 'Blocker', which means just that.

Comment by Ján Regeš [ 2017-02-08 ]

Elena Stepanova, thank you

Generated at Thu Feb 08 07:53:25 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.