Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-12929

Cannot use nextval() inside trigger

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Not a Bug
    • 10.3.0
    • N/A
    • Triggers
    • 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)
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            anikitin Andrii Nikitin (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Git Integration

                Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.