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

SQLCOM_PREPARE of EXPLAIN & ANALYZE statement do not return correct metadata info

    XMLWordPrintable

Details

    Description

      Just now PREPARE for EXPLAIN SELECT return no metadata at all.

      it should work for SELECT/UPDATE/DELETE/INSERT.

      static void test_explain_meta()
      {
        MYSQL_STMT *stmt;
        int num_fields;
        char query[MAX_TEST_QUERY_LENGTH];
        MYSQL_FIELD *fields;
        MYSQL_RES *rs_metadata;
       
        myheader("test_explain_meta");
        mct_start_logging("test_explain_meta");
       
        strmov(query, "SELECT 1");
        stmt= mysql_simple_prepare(mysql, query);
        check_stmt(stmt);
       
        rs_metadata= mysql_stmt_result_metadata(stmt);
       
        num_fields= mysql_stmt_field_count(stmt);
        mct_log("SELECT num_fields: %d\n", (int) num_fields);
        if (num_fields != 1)
        {
          mct_close_log();
          DIE("num_fields != 1");
        }
        mysql_stmt_close(stmt);
       
        strmov(query, "EXPLAIN SELECT 1");
        stmt= mysql_simple_prepare(mysql, query);
        check_stmt(stmt);
       
        rs_metadata= mysql_stmt_result_metadata(stmt);
       
        num_fields= mysql_stmt_field_count(stmt);
        mct_log("EXPALIN num_fields: %d\n", (int) num_fields);
        if (num_fields != 10)
        {
          mct_close_log();
          DIE("num_fields != 10");
        }
       
        fields= mysql_fetch_fields(rs_metadata);
       
        for (int i = 0; i < num_fields; ++i)
        {
          mct_log("  - %d: name: '%s'/'%s'; table: '%s'/'%s'; "
              "db: '%s'; catalog: '%s'; length: %d; max_length: %d; "
              "type: %d; decimals: %d\n",
              (int) i,
              (const char *) fields[i].name,
              (const char *) fields[i].org_name,
              (const char *) fields[i].table,
              (const char *) fields[i].org_table,
              (const char *) fields[i].db,
              (const char *) fields[i].catalog,
              (int) fields[i].length,
              (int) fields[i].max_length,
              (int) fields[i].type,
              (int) fields[i].decimals);
       
        }
       
        mysql_stmt_close(stmt);
       
        mct_close_log();
      }
      

      Attachments

        Issue Links

          Activity

            People

              sanja Oleksandr Byelkin
              sanja Oleksandr Byelkin
              Votes:
              1 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.