Uploaded image for project: 'MariaDB Connector/C'
  1. MariaDB Connector/C
  2. CONC-5

field->catalog is undefined when obtained from prepared statement resultset

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None
    • Environment:
      all platforms

      Description

      The field structure contains an invalid (undefined) value for catalog, if the resultset was obtained via mysql_stmt_result_metadata call().

      How to repeat:

      static int test_stmt_fields(MYSQL *mysql)
      {
        char *query= "SELECT a FROM t1";
        MYSQL_RES *res;
        MYSQL_STMT *stmt;
        MYSQL_FIELD *fields;
        int rc;
       
        rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1");
        check_mysql_rc(rc, mysql);
        rc= mysql_query(mysql, "CREATE TABLE t1 (a int)");
        check_mysql_rc(rc, mysql);
        rc= mysql_query(mysql, "INSERT INTO t1 VALUES (1)");
        check_mysql_rc(rc, mysql);
       
        stmt= mysql_stmt_init(mysql);
        FAIL_IF(!stmt, "couldn't allocate memory");
       
        rc= mysql_stmt_prepare(stmt, query, strlen(query));
        check_stmt_rc(rc, stmt);
        rc= mysql_stmt_execute(stmt);
        check_stmt_rc(rc, stmt);
       
        res= mysql_stmt_result_metadata(stmt);
        FAIL_IF(!res, "Can't obtain resultset");
       
        fields= mysql_fetch_fields(res);
        FAIL_IF(!fields, "Can't obtain fields");
       
        FAIL_IF(strcmp("def", fields[0].catalog), "unexpected value for field->catalog");
       
        mysql_free_result(res);
        mysql_stmt_close(stmt);
      }

        Attachments

          Activity

            People

            Assignee:
            georg Georg Richter
            Reporter:
            georg Georg Richter
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Git Integration