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

Improved last_insert_id()

    XMLWordPrintable

Details

    • Task
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Won't Fix
    • N/A
    • Triggers
    • None

    Description

      Hi MariaDB captains,

      Working with custom sequences different from auto increment will break applications relying on last_insert_id()

      The following bug may be extended into a task to globally improve management of sequences
      Did you plan something new in 10.2. regarding sequences ?

      Test case

      CREATE TABLE `t` (
       `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
       `collection` bigint(20) unsigned DEFAULT NULL,
       `content` mediumblob,
       `inum` bigint(20) DEFAULT NULL,
       `istr` varbinary(40) DEFAULT NULL,
       PRIMARY KEY (`id`),
       KEY `idx1` (`inum`),
       KEY `idx2` (`istr`)
      ) ENGINE=InnoDB AUTO_INCREMENT=10688994220565331969 DEFAULT CHARSET=utf8
      CREATE   TRIGGER before_insert_t   BEFORE INSERT ON t    FOR EACH ROW   SET new.id = uuid_short();
       
      insert into t select null,1 ,"", null, null;
      select last_insert_id();
      

      This returning 0 and not the last inserted auto increment

      In a more generic case it would be appreciate if last_insert_id() could return at least the single column numeric PK of the last inserted record of the statement.

      Attachments

        Issue Links

          Activity

            People

              serg Sergei Golubchik
              stephane@skysql.com VAROQUI Stephane
              Votes:
              0 Vote for this issue
              Watchers:
              4 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.