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

mysql_stmt_errno() returns 0 after an error in mysql_stmt_execute()

Details

    • Bug
    • Status: Confirmed (View Workflow)
    • Critical
    • Resolution: Unresolved
    • 10.6.21, 10.11.10, 11.4.5
    • 10.11, 11.4, 11.8
    • Prepared Statements
    • None

    Description

      In my program, I use the C mariadb connector and since my upgrade of MariaDB server to the 10.11.10 version I noticed this:

      if (mysql_stmt_execute(stmt)) {
       int32_t err_code = mysql_stmt_errno(stmt);
        if (err_code == 0) {
          logger->info("This should not happen, but we are here...");
        }
      }
      

      I'm not sure the err_code is always 0. I know it is 0 when the statement is an INSERT and there are operations on the table like some repartitionning...

      I also noticed this when I insert a row in a table that doesn't exist.

      Attachments

        Issue Links

          Activity

            upgrade from what version?

            serg Sergei Golubchik added a comment - upgrade from what version?
            David David Boucher added a comment -

            I'm sure it works as expected in 10.11.8. I don't remember if that was the previous version I upgraded from.

            David David Boucher added a comment - I'm sure it works as expected in 10.11.8. I don't remember if that was the previous version I upgraded from.

            That's fine, thanks. I mainly needed to know that it's not from 10.6 or 10.4 or something.

            serg Sergei Golubchik added a comment - That's fine, thanks. I mainly needed to know that it's not from 10.6 or 10.4 or something.
            georg Georg Richter added a comment -

            Thank for your bug report!

            Would you please be more verbose and tell us the SQL statement which was previously prepared?

            georg Georg Richter added a comment - Thank for your bug report! Would you please be more verbose and tell us the SQL statement which was previously prepared?
            georg Georg Richter added a comment -

            Thank you for your bug report:

            Can you please additionally provide
            a) more code, e.g. mysql_stmt_prepare call and if possible the table definitions.
            b) the value of mysql_errno() after mysql_stmt_execute() failed.

            georg Georg Richter added a comment - Thank you for your bug report: Can you please additionally provide a) more code, e.g. mysql_stmt_prepare call and if possible the table definitions. b) the value of mysql_errno() after mysql_stmt_execute() failed.
            David David Boucher added a comment -

            The statement is an insert in a simple table. It looks like this:

            INSERT INTO data_bin (id_metric,ctime,status,value) VALUES (?,?,?,?)
            

            I can show you how the data_bin table is created:

            show create table data_bin\G
            *************************** 1. row ***************************
                   Table: data_bin
            Create Table: CREATE TABLE `data_bin` (
              `id_metric` int(11) DEFAULT NULL,
              `ctime` int(11) DEFAULT NULL,
              `value` float DEFAULT NULL,
              `status` enum('0','1','2','3','4') DEFAULT NULL,
              KEY `index_metric` (`id_metric`)
            ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci
            1 row in set (0.001 sec)
            

            The statement is executed as a bulk statement, so we insert many rows with one execution.
            Usually it works correctly.
            The data_bin table is huge so it is partitioned by day.
            The software doing the statement works continuously and keeps a connection to the database.

            We also have a script executed from a crontab that adds a new partition to the table every days.

            During this last operation, the bulk statement tries to insert new rows but fails. To have more information on the error, we use the mysql_stmt_errno() return value.
            But since the upgrade of mariadb, we get 0.

            I tried to reproduce the situation in a simple program, but it is not so easy.

            David David Boucher added a comment - The statement is an insert in a simple table. It looks like this: INSERT INTO data_bin (id_metric,ctime,status,value) VALUES (?,?,?,?) I can show you how the data_bin table is created: show create table data_bin\G *************************** 1 . row *************************** Table: data_bin Create Table: CREATE TABLE `data_bin` ( `id_metric` int ( 11 ) DEFAULT NULL, `ctime` int ( 11 ) DEFAULT NULL, `value` float DEFAULT NULL, `status` enum ( '0' , '1' , '2' , '3' , '4' ) DEFAULT NULL, KEY `index_metric` (`id_metric`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 COLLATE=latin1_swedish_ci 1 row in set ( 0.001 sec) The statement is executed as a bulk statement, so we insert many rows with one execution. Usually it works correctly. The data_bin table is huge so it is partitioned by day. The software doing the statement works continuously and keeps a connection to the database. We also have a script executed from a crontab that adds a new partition to the table every days. During this last operation, the bulk statement tries to insert new rows but fails. To have more information on the error, we use the mysql_stmt_errno() return value. But since the upgrade of mariadb, we get 0. I tried to reproduce the situation in a simple program, but it is not so easy.
            georg Georg Richter added a comment -

            Thanks for your feedback. I'm able to reproduce the issue (see attached python script). The server sends an error packet with error code 0:

            Wireshark error packet:

            FF 00 00 23 48 59 30 30 30   | ...#HY000
            

            georg Georg Richter added a comment - Thanks for your feedback. I'm able to reproduce the issue (see attached python script). The server sends an error packet with error code 0: Wireshark error packet: FF 00 00 23 48 59 30 30 30 | ...#HY000
            David David Boucher added a comment -

            Good news !!
            Thanks !

            David David Boucher added a comment - Good news !! Thanks !

            People

              serg Sergei Golubchik
              David David Boucher
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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