Uploaded image for project: 'MariaDB Connector/Python'
  1. MariaDB Connector/Python
  2. CONPY-259

When using callproc() to execute a SELECT statement, the results have different precision compared to directly executing SELECT

    XMLWordPrintable

Details

    • Bug
    • Status: Closed (View Workflow)
    • Major
    • Resolution: Not a Bug
    • 1.1.6
    • N/A
    • Generic
    • None
    • MariaDB 10.11
    • 3.9

    Description

      I create a table with a column type of FLOAT and have a stored procedure that selects all records in the table. When I call this stored procedure using cursor.callproc(), the precision of the returned results is different from the results of direct SELECT.
      In the test case I provided, cursor.callproc() returned `1898969600.0`, while "SELECT * FROM t0" returned `1898970000.0`. And the command-line client returns `1898970000`.

      The test case:

      def execute(con, sql):
          try:
              cursor = con.cursor()
              cursor.execute(sql)
              cursor.close()
          except Exception as e:
              print(e)
       
      conn_params = {
          "user": "user",
          "password": "password",
          "host": "127.0.0.1",
      }
       
      con = mariadb.connect(**conn_params)
      execute(con, "DROP DATABASE IF EXISTS test")
      execute(con, "CREATE DATABASE test")
      execute(con, "USE test")
      execute(con, "CREATE TABLE t0(c0 FLOAT UNIQUE)");
      execute(con, "CREATE PROCEDURE `t0_select_all`() BEGIN SELECT * FROM t0; END;");
      execute(con, "INSERT INTO t0 VALUES (1898969556)");
       
      # callproc
      cursor = con.cursor()
      cursor.callproc("t0_select_all")
      print(cursor.fetchall())
      cursor.close()
       
      # direct select
      cursor = con.cursor()
      cursor.execute("SELECT * FROM t0")
      for row in cursor:
          print(*row, sep=" * ")
      cursor.close()
       
      con.commit()
      con.close()
      

      Attachments

        Activity

          People

            georg Georg Richter
            dwenking Wenqian Deng
            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.