Details
-
Bug
-
Status: Resolved
-
Critical
-
Resolution: Invalid
-
Impala 2.1
-
None
-
OS: CentOS release 6.4 (Final)
Impala: 2.1.0
ImpalaODBC: 2.5.23
Description
Steps to reproduce
- 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');
- 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