Uploaded image for project: 'IMPALA'
  1. IMPALA
  2. IMPALA-1792

ImpalaODBC: Can not get the value in the SQLGetData(m-x th column) after the SQLBindCol(m th column)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Invalid
    • Impala 2.1
    • None
    • Clients
    • OS: CentOS release 6.4 (Final)
      Impala: 2.1.0
      ImpalaODBC: 2.5.23

    Description

      Steps to reproduce

      1. Create table and insert data in impala.
        create table t (c1 string, c2 string, c3 string);
        insert into t (c1, c2, c3) values ('AAA', 'BBB', 'CCC');
        
      2. Query the t table with the following code.
        #include <stdio.h>
        #include <string.h>
        #include <sql.h>
        #include <sqlext.h>
        
        int main() {
            SQLHENV env;
            SQLHDBC dbc;
            SQLHSTMT stmt;
            SQLRETURN ret;
        
            SQLAllocHandle(SQL_HANDLE_ENV, SQL_NULL_HANDLE, &env);
            SQLSetEnvAttr(env, SQL_ATTR_ODBC_VERSION, (void *) SQL_OV_ODBC3, 0); 
            SQLAllocHandle(SQL_HANDLE_DBC, env, &dbc);
            SQLDriverConnect(dbc, (SQLCHAR*)NULL, (SQLCHAR*)"DSN=Impala", SQL_NTS, NULL, 0, NULL, SQL_DRIVER_COMPLETE);
            SQLAllocHandle(SQL_HANDLE_STMT, dbc, &stmt);
            SQLExecDirect(stmt, (SQLCHAR*)"select c1, c2, c3 from t", SQL_NTS);
        
            char szCol1[11];
            char szCol2[11];
            char szCol3[11];
            SQLLEN nColLen1;
            SQLLEN nColLen2;
            SQLLEN nColLen3;
        
            /*************************/
            /**** Bind 2nd column ****/
            /*************************/
            SQLBindCol(stmt, 2, SQL_C_CHAR, szCol2, sizeof(szCol2), &nColLen2);
        
            ret = SQLFetch(stmt);
            if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO) {
        
                /************************/
                /**** Get 1st column ****/
                /************************/
                ret = SQLGetData(stmt, 1, SQL_C_CHAR, szCol1, sizeof(szCol1), &nColLen1);
        
                if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO) {
                    printf("c1: %s\n", szCol1);
                } else {
                    printf("no data\n");
                }
        
                printf("c2: %s\n", szCol2);
        
                /************************/
                /**** Get 3rd column ****/
                /************************/
                ret = SQLGetData(stmt, 3, SQL_C_CHAR, szCol3, sizeof(szCol3), &nColLen3);
        
                if (ret == SQL_SUCCESS || ret == SQL_SUCCESS_WITH_INFO) {
                    printf("c3: %s\n", szCol3);
                } else {
                    printf("no data\n");
                }
            } else {
                printf("no row\n");
            }
        
            return 0;
        }
        

      Expected result

      c1: AAA
      c2: BBB
      c3: CCC
      

      Actual result

      no data
      c2: BBB
      c3: CCC
      

      Attachments

        1. odbc.c
          2 kB
          Tim Armstrong
        2. odbc.ini
          5 kB
          Tim Armstrong
        3. odbcinst.ini
          0.6 kB
          Tim Armstrong

        Activity

          People

            Unassigned Unassigned
            kogam_impala_d4fd Mitsuhiro Koga
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: