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

function last_insert_id behavior on two tables updates

    XMLWordPrintable

Details

    • Not for Release Notes

    Description

      Hello,

      function last_insert_id() delivers correct and expected values before and after "insert" statement execued on first table modified within stored procedure.

      function last_insert_id() seems to deliver unexpected/wrong values before and after "insert" statement on second table modified within the same stored procedure.

      Both tables rely on "int unsigned" primary keys with "auto_increment" flag set.
      This finding was initially discovered on two tables with primary keys of type "serial".

      use-case:
      function last_insert_id() precedes and follows "insert" command, their results get compared in aim to verify if insert was successful.

      business use-case:
      Transaction within stored procedure modifies both tables with commit or
      transaction gets rolled back.

      How to verify the finding:
      import attached 'sandbox' schema with 2 tables and 1 stored procedure into your Maria instance, please execute
      call Sandbox();
      from within mysql client several times.

      Calls of procedure "Sandbox" display expected values of variables pairs "var1_before" and "var1_after": var1_after is bigger than var1_before.

      Results for pairs of values of var2_before and var2_after variables remain inconsistent.

      Attachments

        Activity

          People

            Unassigned Unassigned
            grb357 Prefer To Stay Anonymous
            Votes:
            0 Vote for this issue
            Watchers:
            3 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.