[MDEV-12929] Cannot use nextval() inside trigger Created: 2017-05-26  Updated: 2017-05-26  Resolved: 2017-05-26

Status: Closed
Project: MariaDB Server
Component/s: Triggers
Affects Version/s: 10.3.0
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Andrii Nikitin (Inactive) Assignee: Unassigned
Resolution: Not a Bug Votes: 0
Labels: None


 Description   

Error 'FUNCTION test.nexval does not exist' is shown when trying to use nextval() from a trigger:

MariaDB [test]> create or replace trigger ti before insert on a for each row set new.a=nexval(aseq);
Query OK, 0 rows affected (0.07 sec)
 
MariaDB [test]> select nextval(aseq);
+---------------+
| nextval(aseq) |
+---------------+
|           133 |
+---------------+
1 row in set (0.00 sec)
 
MariaDB [test]> insert into a select null;
ERROR 1305 (42000): FUNCTION test.nexval does not exist
MariaDB [test]> show create table a\G
*************************** 1. row ***************************
       Table: a
Create Table: CREATE TABLE `a` (
  `a` int(11) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1
1 row in set (0.00 sec)

Note that stored procedures work properly:

MariaDB [test]> create procedure d() select nextval(aseq);
Query OK, 0 rows affected (0.01 sec)
 
MariaDB [test]> call d;
+---------------+
| nextval(aseq) |
+---------------+
|           134 |
+---------------+
1 row in set (0.00 sec)
 
Query OK, 0 rows affected (0.00 sec)



 Comments   
Comment by Elena Stepanova [ 2017-05-26 ]

You have a typo in the trigger, nexval instead of nextval.

Generated at Thu Feb 08 08:01:35 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.