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

BIGINT UNSIGNED value is out of range in '`test`.`edge`.`x1` - 1'

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Critical
    • Resolution: Duplicate
    • 10.5.4
    • 10.5.11
    • Data types
    • None

    Description

      When executing the following example server sends metadata + error packet instead of sending metadata and data:

      static int test_ps(MYSQL *mysql)
      {
        MYSQL_STMT *stmt;
        int rc, i;
        MYSQL_BIND bind[5];
        unsigned char vals[5]= {1,1,1,1,1};
       
        rc= mysql_query(mysql, "CREATE TEMPORARY TABLE edge ( id INTEGER NOT NULL AUTO_INCREMENT, x1 INTEGER, y1 INTEGER, x2 INTEGER, y2 INTEGER, PRIMARY KEY (id))ENGINE=MyISAM");
        check_mysql_rc(rc, mysql);
       
        rc= mysql_query(mysql, "INSERT INTO edge (x1, y1, x2, y2) VALUES (0, 0, 3, 5)");
        check_mysql_rc(rc, mysql);
       
        rc= mysql_query(mysql, "INSERT INTO edge (x1, y1, x2, y2) VALUES (0, 1, 3, 5)");
        check_mysql_rc(rc, mysql);
       
        stmt= mysql_stmt_init(mysql);
        check_stmt_rc(rc, stmt);
       
        rc= mysql_stmt_prepare(stmt, SL("SELECT edge.id AS edge_id, edge.x1 AS edge_x1, edge.y1 AS edge_y1, edge.x2 AS edge_x2, edge.y2 AS edge_y2 FROM edge WHERE (edge.x1 - ?) * (edge.x1 - ?) + (edge.y1 - ?) * (edge.y1 - ?) <= ?"));
        check_stmt_rc(rc, stmt);
       
        memset(bind, 0, sizeof(MYSQL_BIND) * 5);
        for (i=0; i < 5; i++)
        {
          bind[i].buffer_type= MYSQL_TYPE_TINY;
          bind[i].buffer= &vals[i];
          bind[i].is_unsigned= 1;
        }
       
        rc= mysql_stmt_bind_param(stmt, bind);
        check_stmt_rc(rc, stmt);
       
        rc= mysql_stmt_execute(stmt);
        check_stmt_rc(rc, stmt);
       
        /* Error will be read here */
        rc= mysql_stmt_store_result(stmt);
        check_stmt_rc(rc, stmt);
       
        mysql_stmt_close(stmt);
        return OK;
      }
      

      Output:

      Error: BIGINT UNSIGNED value is out of range in '`test`.`edge`.`x1` - 1'
      

      Running the same statement in text protocol returns correct result:

      mysql> SELECT edge.id AS edge_id, edge.x1 AS edge_x1, edge.y1 AS edge_y1, edge.x2 AS edge_x2, edge.y2 AS edge_y2 FROM edge WHERE (edge.x1 - 1) * (edge.x1 - 1) + (edge.y1 - 1) * (edge.y1 - 1) <= 1;
      +---------+---------+---------+---------+---------+
      | edge_id | edge_x1 | edge_y1 | edge_x2 | edge_y2 |
      +---------+---------+---------+---------+---------+
      |       2 |       0 |       1 |       3 |       5 |
      +---------+---------+---------+---------+---------+
      1 row in set (0,00 sec)
      

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              georg Georg Richter
              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.