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

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

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

            #####################################
            1 of (1/1): test_explain_meta  
            #####################################
            SELECT num_fields: 1
            EXPALIN num_fields: 0
            tests/mysql_client_test.c:20277: check failed: '"num_fields != 10"'
            MySQL error 0: 
            

            sanja Oleksandr Byelkin added a comment - ##################################### 1 of (1/1): test_explain_meta ##################################### SELECT num_fields: 1 EXPALIN num_fields: 0 tests/mysql_client_test.c:20277: check failed: '"num_fields != 10"' MySQL error 0:

            revision-id: 346c8ab9533a3de6a4cb348428402ffee2aa8da2 (mariadb-10.3.6-16-g346c8ab9533)
            parent(s): cff60be7fe159fdcb2517ce8441610ad512aa7d0
            author: Oleksandr Byelkin
            committer: Oleksandr Byelkin
            timestamp: 2018-04-18 19:34:12 +0200
            message:

            MDEV-11975: SQLCOM_PREPARE of EXPLAIN & ANALYZE statement do not return correct metadata info

            Added metadate info after prepare EXPLAIN/ANALYZE.

            sanja Oleksandr Byelkin added a comment - revision-id: 346c8ab9533a3de6a4cb348428402ffee2aa8da2 (mariadb-10.3.6-16-g346c8ab9533) parent(s): cff60be7fe159fdcb2517ce8441610ad512aa7d0 author: Oleksandr Byelkin committer: Oleksandr Byelkin timestamp: 2018-04-18 19:34:12 +0200 message: MDEV-11975 : SQLCOM_PREPARE of EXPLAIN & ANALYZE statement do not return correct metadata info Added metadate info after prepare EXPLAIN/ANALYZE. —

            revision-id: 331034cb6e1552e1ab7c12b6f7341f557f76b807 (mariadb-10.3.6-16-g331034cb6e1)
            parent(s): cff60be7fe159fdcb2517ce8441610ad512aa7d0
            author: Oleksandr Byelkin
            committer: Oleksandr Byelkin
            timestamp: 2018-04-20 14:40:14 +0200
            message:

            MDEV-11975: SQLCOM_PREPARE of EXPLAIN & ANALYZE statement do not return correct metadata info

            Added metadate info after prepare EXPLAIN/ANALYZE.

            sanja Oleksandr Byelkin added a comment - revision-id: 331034cb6e1552e1ab7c12b6f7341f557f76b807 (mariadb-10.3.6-16-g331034cb6e1) parent(s): cff60be7fe159fdcb2517ce8441610ad512aa7d0 author: Oleksandr Byelkin committer: Oleksandr Byelkin timestamp: 2018-04-20 14:40:14 +0200 message: MDEV-11975 : SQLCOM_PREPARE of EXPLAIN & ANALYZE statement do not return correct metadata info Added metadate info after prepare EXPLAIN/ANALYZE. —

            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.