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

Prepared statement doesn't return metadata after prepare

    XMLWordPrintable

Details

    • 10.1.11

    Description

      According to the documentation metadata for a prepared statement should be available after preparing the statement: "mysql_stmt_field_count() can be called after you have prepared a statement by invoking mysql_stmt_prepare().".

      This doesn't work with all kind pf prepared statements.

      How to repeat:

      static int test_metadata(MYSQL *mysql)
      {
        int rc;
        char *query1= "SELECT 1,2 FROM DUAL";
        char *query2= "SHOW CREATE TABLE test_metadata";
        MYSQL_STMT *stmt= mysql_stmt_init(mysql);
       
        rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_metadata");
        check_mysql_rc(rc, mysql);
       
        rc= mysql_query(mysql, "CREATE TABLE test_metadata (a int)"); 
        check_mysql_rc(rc, mysql);
       
        rc= mysql_stmt_prepare(stmt, query1, strlen(query1));
        check_stmt_rc(rc, stmt);
        diag("Fields in result set after prepare: %u", mysql_stmt_field_count(stmt));
       
        rc= mysql_stmt_prepare(stmt, query2, strlen(query2));
        check_stmt_rc(rc, stmt);
        diag("Fields in result set after prepare: %u", mysql_stmt_field_count(stmt));
       
        rc= mysql_stmt_execute(stmt);
        diag("Fields in result set after execute: %u", mysql_stmt_field_count(stmt));
       
        mysql_stmt_close(stmt);
      }

      Output:

      # Fields in result set after prepare: 2
      # Fields in result set after prepare: 0
      # Fields in result set after execute: 2

      Attachments

        Activity

          People

            holyfoot Alexey Botchkov
            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.