PassFail TestSQLSpecialColumns(TestInfo *pTestInfo, int MX_MP_SPECIFIC) { TEST_DECLARE; TCHAR Heading[MAX_HEADING_SIZE]; RETCODE returncode; SQLHANDLE henv; SQLHANDLE hdbc; SQLHANDLE hstmt; TCHAR TQualifier[NAME_LEN],TOwner[NAME_LEN],TName[NAME_LEN]; UWORD fColType[NUM_COLTYPE] = {SQL_BEST_ROWID,SQL_ROWVER}; UWORD Scope[NUM_SCOPE] = {SQL_SCOPE_CURROW,SQL_SCOPE_TRANSACTION,SQL_SCOPE_SESSION}; UWORD Nullable[NUM_NULL] = {SQL_NO_NULLS,SQL_NULLABLE}; TCHAR ocname[MAX_COLUMN_NAME],octype[MAX_COLUMN_NAME]; SWORD oscope,ocdatatype,ocsca,ocpc; SDWORD ocprec,oclen; SQLLEN oscopelen,ocnamelen,ocdatatypelen,octypelen,ocpreclen,oclenlen,ocscalen,ocpclen; struct { TCHAR *ColName; SWORD ColDataType; TCHAR *ColTypeName; TCHAR *ColTypeOutput; TCHAR *ColTypeLen; SDWORD ColPrec; SWORD ColSca; SDWORD ColLen; } Columns[] = { {_T("--"),SQL_CHAR,_T("char"),_T("CHAR"),_T("(10) CHARACTER SET ISO88591"),10,0,10}, {_T("--"),SQL_VARCHAR,_T("varchar"),_T("VARCHAR"),_T("(10) CHARACTER SET ISO88591"),10,0,10}, {_T("--"),SQL_VARCHAR,_T("varchar"),_T("VARCHAR"),_T("(255) CHARACTER SET ISO88591"),255,0,255}, {_T("--"),SQL_WCHAR,_T("char"),_T("NCHAR"),_T("(10) CHARACTER SET UCS2"),10,0,20}, {_T("--"),SQL_WVARCHAR,_T("varchar"),_T("NCHAR VARYING"),_T("(10) CHARACTER SET UCS2"),10,0,20}, {_T("--"),SQL_WVARCHAR,_T("varchar"),_T("NCHAR VARYING"),_T("(255) CHARACTER SET UCS2"),255,0,510}, {_T("--"),SQL_DECIMAL,_T("decimal"),_T("DECIMAL SIGNED"),_T("(10,5)"),10,5,12}, {_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC SIGNED"),_T("(10,5)"),10,5,12}, {_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC SIGNED"),_T("(19,0)"),19,0,21}, //Bignum {_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC SIGNED"),_T("(19,6)"),19,6,21}, //Bignum {_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC SIGNED"),_T("(128,0)"),128,0,130}, //Bignum {_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC SIGNED"),_T("(128,128)"),128,128,130}, //Bignum {_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC SIGNED"),_T("(128,64)"),128,64,130}, //Bignum {_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC UNSIGNED"),_T("(10,5) unsigned"),10,5,12}, //Bignum {_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC UNSIGNED"),_T("(18,5) unsigned"),18,5,20}, //Bignum {_T("--"),SQL_NUMERIC,_T("numeric"),_T("NUMERIC UNSIGNED"),_T("(30,10) unsigned"),30,10,32}, //Bignum {_T("--"),SQL_SMALLINT,_T("smallint"),_T("SMALLINT SIGNED"),_T(""),5,0,2}, {_T("--"),SQL_INTEGER,_T("integer"),_T("INTEGER SIGNED"),_T(""),10,0,4}, {_T("--"),SQL_BIGINT,_T("bigint"),_T("BIGINT SIGNED"),_T(""),19,0,20}, {_T("--"),SQL_DATE,_T("date"),_T("DATE"),_T(""),10,0,6}, {_T("--"),SQL_TIME,_T("time"),_T("TIME"),_T(""),8,0,6}, {_T("--"),SQL_TIMESTAMP,_T("TIMESTAMP"),_T("timestamp"),_T(""),26,6,16}, {_T("--"),SQL_BIT,_T("bit"),_T("BIT"),_T(""),1,1,0}, {_T("--"),SQL_TINYINT,_T("tinyint"),_T("TINYINT"),_T(""),3,0,2}, {_T("--"),SQL_BINARY,_T("binary"),_T("BINARY"),_T("(10)"),10,0,10}, {_T("--"),SQL_VARBINARY,_T("varbinary"),_T("VARBINARY"),_T("(10)"),10,0,10}, {_T("--"),SQL_WCHAR,_T("char"),_T("NCHAR"),_T("(10) CHARACTER SET UTF8"),10,0,20}, {_T("--"),SQL_WVARCHAR,_T("varchar"),_T("NCHAR VARYING"),_T("(10) CHARACTER SET UTF8"),10,0,20}, {_T("--"),SQL_WVARCHAR,_T("varchar"),_T("NCHAR VARYING"),_T("(255) CHARACTER SET UTF8"),255,0,510}, {_T("--"),0,_T("endloop"),_T(""),0,0,0,0} }; TCHAR *TableStr[4]; TCHAR ColStr[MAX_NOS_SIZE], KeyStr[MAX_NOS_SIZE], CreateTbl[MAX_NOS_SIZE],END_LOOP[10]; int i = 0, k = 0,ct = 0, s = 0, t = 0, n = 0, psc = 1; BOOL found = FALSE; //TCHAR *charNameUCS2 = _T("NCHAR"); //TCHAR *varcharNameUCS2 = _T("NCHAR VARYING"); //=========================================================================================================== var_list_t *var_list; var_list = load_api_vars(_T("SQLSpecialColumns"), charset_file); if (var_list == NULL) return FAILED; //print_list(var_list); Columns[0].ColName = var_mapping(_T("SQLSpecialColumns_Columns_1"), var_list); Columns[1].ColName = var_mapping(_T("SQLSpecialColumns_Columns_2"), var_list); Columns[2].ColName = var_mapping(_T("SQLSpecialColumns_Columns_3"), var_list); Columns[3].ColName = var_mapping(_T("SQLSpecialColumns_Columns_4"), var_list); Columns[4].ColName = var_mapping(_T("SQLSpecialColumns_Columns_5"), var_list); Columns[5].ColName = var_mapping(_T("SQLSpecialColumns_Columns_6"), var_list); Columns[6].ColName = var_mapping(_T("SQLSpecialColumns_Columns_7"), var_list); Columns[7].ColName = var_mapping(_T("SQLSpecialColumns_Columns_8"), var_list); Columns[8].ColName = var_mapping(_T("SQLSpecialColumns_Columns_9"), var_list); Columns[9].ColName = var_mapping(_T("SQLSpecialColumns_Columns_10"), var_list); Columns[10].ColName = var_mapping(_T("SQLSpecialColumns_Columns_11"), var_list); Columns[11].ColName = var_mapping(_T("SQLSpecialColumns_Columns_12"), var_list); Columns[12].ColName = var_mapping(_T("SQLSpecialColumns_Columns_13"), var_list); Columns[13].ColName = var_mapping(_T("SQLSpecialColumns_Columns_14"), var_list); Columns[14].ColName = var_mapping(_T("SQLSpecialColumns_Columns_15"), var_list); Columns[15].ColName = var_mapping(_T("SQLSpecialColumns_Columns_16"), var_list); Columns[16].ColName = var_mapping(_T("SQLSpecialColumns_Columns_17"), var_list); Columns[17].ColName = var_mapping(_T("SQLSpecialColumns_Columns_18"), var_list); Columns[18].ColName = var_mapping(_T("SQLSpecialColumns_Columns_19"), var_list); Columns[19].ColName = var_mapping(_T("SQLSpecialColumns_Columns_20"), var_list); Columns[20].ColName = var_mapping(_T("SQLSpecialColumns_Columns_21"), var_list); Columns[21].ColName = var_mapping(_T("SQLSpecialColumns_Columns_22"), var_list); Columns[22].ColName = var_mapping(_T("SQLSpecialColumns_Columns_23"), var_list); Columns[23].ColName = var_mapping(_T("SQLSpecialColumns_Columns_24"), var_list); Columns[24].ColName = var_mapping(_T("SQLSpecialColumns_Columns_25"), var_list); Columns[25].ColName = var_mapping(_T("SQLSpecialColumns_Columns_26"), var_list); Columns[26].ColName = var_mapping(_T("SQLSpecialColumns_Columns_27"), var_list); Columns[27].ColName = var_mapping(_T("SQLSpecialColumns_Columns_28"), var_list); Columns[28].ColName = var_mapping(_T("SQLSpecialColumns_Columns_29"), var_list); TableStr[0] = var_mapping(_T("SQLSpecialColumns_TableStr_1"), var_list); TableStr[1] = var_mapping(_T("SQLSpecialColumns_TableStr_2"), var_list); TableStr[2] = var_mapping(_T("SQLSpecialColumns_TableStr_3"), var_list); TableStr[3] = var_mapping(_T("SQLSpecialColumns_TableStr_4"), var_list); //========================================================================================= //if(isUCS2) { // LogMsg(NONE,_T("Setup for UCS2 mode testing: ColPrec has to be doubled\n")); // i = 0; // while(_tcsicmp(Columns[i].ColTypeName,_T("endloop")) != 0) { // if (Columns[i].ColDataType == SQL_WCHAR){ // Columns[i].ColDataType = SQL_WCHAR; // Columns[i].ColTypeOutput = charNameUCS2; // //Columns[i].ColPrec *= 2; --> This is in character, no need to double // Columns[i].ColLen *= 2; // } // else if (Columns[i].ColDataType == SQL_WVARCHAR) { // Columns[i].ColDataType = SQL_WVARCHAR; // Columns[i].ColTypeOutput = varcharNameUCS2; // //Columns[i].ColPrec *= 2; --> This is in character, no need to double // Columns[i].ColLen *= 2; // } // else if (Columns[i].ColDataType == SQL_WLONGVARCHAR) { // Columns[i].ColDataType = SQL_WLONGVARCHAR; // Columns[i].ColTypeOutput = varcharNameUCS2; // //Columns[i].ColPrec *= 2; --> This is in character, no need to double // Columns[i].ColLen *= 2; // } // i++; // } // i = 0; //} //========================================================================================= if (MX_MP_SPECIFIC == MX_SPECIFIC) LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API => MX Specific SQLSpecialColumns.\n")); else LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API => MP Specific SQLSpecialColumns.\n")); TEST_INIT; TESTCASE_BEGIN("Setup for SQLSpecialColumns tests\n"); if(!FullConnect(pTestInfo)){ LogMsg(NONE,_T("Unable to connect\n")); TEST_FAILED; TEST_RETURN; } henv = pTestInfo->henv; hdbc = pTestInfo->hdbc; hstmt = (SQLHANDLE)pTestInfo->hstmt; returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt")){ LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; TEST_RETURN; } TESTCASE_END; _tcscpy(ColStr,_T("")); _tcscpy(KeyStr,_T("")); _tcscpy(END_LOOP,_T("")); _tcscpy(TName,TableStr[2]); if (MX_MP_SPECIFIC == MX_SPECIFIC) { _tcscpy(TQualifier,pTestInfo->Catalog); _tcscpy(TOwner,pTestInfo->Schema); _tcscpy(END_LOOP,_T("bit")); } else { _tcscpy(TQualifier,_T("")); _tcscpy(TOwner,pTestInfo->UserID); _tcscpy(END_LOOP,_T("endloop")); } while (_tcsicmp(Columns[i].ColTypeName,END_LOOP) != 0) { SQLExecDirect(hstmt,(SQLTCHAR*) (SQLTCHAR *)TableStr[1],SQL_NTS); // cleanup if (i > 0) { _tcscat(ColStr,_T(",")); _tcscat(KeyStr,_T(",")); } _tcscat(ColStr,Columns[i].ColName); _tcscat(ColStr,_T(" ")); _tcscat(ColStr,Columns[i].ColTypeName); _tcscat(ColStr,Columns[i].ColTypeLen); _tcscat(ColStr,_T(" not null")); _tcscat(KeyStr,Columns[i].ColName); _tcscpy(CreateTbl,_T("")); _tcscat(CreateTbl,TableStr[0]); _tcscat(CreateTbl,_T("(")); _tcscat(CreateTbl,ColStr); _tcscat(CreateTbl,_T(", primary key(")); _tcscat(CreateTbl,KeyStr); _tcscat(CreateTbl,_T("))")); _stprintf(Heading,_T("Test Positive Functionality of SQLSpecialColumns for this table:\n")); _tcscat(Heading,CreateTbl); _tcscat(Heading,_T("\n")); TESTCASE_BEGINW(Heading); returncode = SQLExecDirect(hstmt,(SQLTCHAR*)CreateTbl,SQL_NTS); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")){ TEST_FAILED; LogAllErrors(henv,hdbc,hstmt); } else{ if (_tcslen(TQualifier) > 0) returncode = SQLSpecialColumns(hstmt,fColType[ct],(SQLTCHAR*)TQualifier,(SWORD)_tcslen(TQualifier),(SQLTCHAR*)TOwner,(SWORD)_tcslen(TOwner),(SQLTCHAR*)TName,(SWORD)_tcslen(TName),Scope[s],Nullable[n]); else returncode = SQLSpecialColumns(hstmt,fColType[ct],NULL,0,(SQLTCHAR*)TOwner,(SWORD)_tcslen(TOwner),(SQLTCHAR*)TName,(SWORD)_tcslen(TName),Scope[s],Nullable[n]); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSpecialColumns")){ TEST_FAILED; LogAllErrors(henv,hdbc,hstmt); } else{ oscope = 0; _tcscpy(ocname,_T("")); ocdatatype = 0; _tcscpy(octype,_T("")); ocprec = 0; oclen = 0; ocsca = 0; ocpc = 0; SQLBindCol(hstmt,1,SQL_C_SHORT,&oscope,0,&oscopelen); SQLBindCol(hstmt,2,SQL_C_TCHAR,ocname,MAX_COLUMN_NAME,&ocnamelen); SQLBindCol(hstmt,3,SQL_C_SHORT,&ocdatatype,0,&ocdatatypelen); SQLBindCol(hstmt,4,SQL_C_TCHAR,octype,MAX_COLUMN_NAME,&octypelen); SQLBindCol(hstmt,5,SQL_C_LONG,&ocprec,0,&ocpreclen); SQLBindCol(hstmt,6,SQL_C_LONG,&oclen,0,&oclenlen); SQLBindCol(hstmt,7,SQL_C_SHORT,&ocsca,0,&ocscalen); SQLBindCol(hstmt,8,SQL_C_SHORT,&ocpc,0,&ocpclen); k = 0; while (returncode == SQL_SUCCESS){ returncode = SQLFetch(hstmt); if((returncode!=SQL_NO_DATA_FOUND) &&(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))){ TEST_FAILED; LogAllErrors(henv,hdbc,hstmt); } else{ if (returncode == SQL_SUCCESS){ if (MX_MP_SPECIFIC == MX_SPECIFIC) { psc = SQL_PC_NOT_PSEUDO; } else { psc = 1; } LogMsg(NONE,_T("Comparing results for SQLSpecialColumns\n")); t = 0; found = FALSE; while(_tcscmp(Columns[t].ColTypeName,_T("endloop"))!=0) { if(cwcscmp(ocname, Columns[t].ColName,TRUE) == 0) { if ((oscope == Scope[s]) && (ocdatatype == Columns[t].ColDataType) && (_tcsicmp(octype,Columns[t].ColTypeOutput) == 0) && (ocprec == Columns[t].ColPrec) && (oclen == Columns[t].ColLen) && (ocsca == Columns[t].ColSca) && (ocpc == (SWORD)psc)){ /* LogMsg(NONE,_T("Scope expect: %d and actual: %d are matched\n"),Scope[s],oscope); LogMsg(NONE,_T("colname expect: %s and actual: %s are matched\n"),Columns[t].ColName,ocname); LogMsg(NONE,_T("ColDataType expect: %d and actual: %d are matched\n"),Columns[t].ColDataType,ocdatatype); LogMsg(NONE,_T("ColTypeOutput expect: %s and actual: %s are matched\n"),Columns[t].ColTypeOutput,octype); LogMsg(NONE,_T("ColPrec expect: %d and actual: %d are matched\n"),Columns[t].ColPrec,ocprec); LogMsg(NONE,_T("ColLen expect: %d and actual: %d are matched\n"),Columns[t].ColLen,oclen); LogMsg(NONE,_T("ColScale expect: %d and actual: %d are matched\n"),Columns[t].ColSca,ocsca); LogMsg(NONE,_T("ColPseudoCol expect: %d and actual: %d are matched\n\n"),(SWORD)psc,ocpc); */ } else { TEST_FAILED; if (oscope != Scope[s]) LogMsg(ERRMSG,_T("Scope expect: %d and actual: %d are not matched\n"),Scope[t],oscope); if (ocdatatype != Columns[t].ColDataType) LogMsg(ERRMSG,_T("ColDataType expect: %d and actual: %d are not matched\n"),Columns[t].ColDataType,ocdatatype); if (_tcsicmp(octype,Columns[t].ColTypeOutput) != 0) LogMsg(ERRMSG,_T("ColTypeName expect: %s and actual: %s are not matched\n"),Columns[t].ColTypeOutput,octype); if (ocprec != Columns[t].ColPrec) LogMsg(ERRMSG,_T("ColPrec expect: %d and actual: %d are not matched\n"),Columns[t].ColPrec,ocprec); if (oclen != Columns[t].ColLen) LogMsg(ERRMSG,_T("ColLen expect: %d and actual: %d are not matched\n"),Columns[t].ColLen,oclen); if (ocsca != Columns[t].ColSca) LogMsg(ERRMSG,_T("ColScale expect: %d and actual: %d are not matched\n"),Columns[t].ColSca,ocsca); if (ocpc != (SWORD)psc) LogMsg(ERRMSG,_T("ColPseudoCol expect: %d and actual: %d are not matched\n\n"),(SWORD)psc,ocpc); } found = TRUE; break; } else { t++; } } if(!found) { TEST_FAILED; LogMsg(ERRMSG,_T("Unexpected returned data: %s\n"), ocname); } } } if (returncode == SQL_SUCCESS) k++; } // end while if(k == 0) { TEST_FAILED; LogMsg(ERRMSG,_T("No Data Found => Atleast one row should be fetched\n")); } } SQLFreeStmt(hstmt,SQL_UNBIND); SQLFreeStmt(hstmt,SQL_CLOSE); } SQLExecDirect(hstmt,(SQLTCHAR*) (SQLTCHAR *)TableStr[1],SQL_NTS); i++; TESTCASE_END; } // end while //======================================================================================================== _stprintf(Heading,_T("SQLSpecialColumns: Negative test with NULL handle\n")); TESTCASE_BEGINW(Heading); hstmt = (SQLHANDLE)NULL; _tcscpy(TQualifier,_T("")); _tcscpy(TOwner,pTestInfo->UserID); _tcscpy(TName,TableStr[3]); i = 0; returncode = SQLSpecialColumns(hstmt,fColType[i],(SQLTCHAR*)TQualifier,(SWORD)_tcslen(TQualifier),(SQLTCHAR*)TOwner,(SWORD)_tcslen(TOwner),(SQLTCHAR*)TName,(SWORD)_tcslen(TName),Scope[i],Nullable[i]); if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLSpecialColumns")) { TEST_FAILED; LogAllErrors(henv,hdbc,hstmt); } TESTCASE_END; //======================================================================================================== FullDisconnect(pTestInfo); LogMsg(SHORTTIMESTAMP+LINEAFTER,_T("End testing API => SQLSpecialColumns.\n")); free_list(var_list); TEST_RETURN; }
/* --------------------------------------------------------- TestSQLDescribeCol for MP Specific --------------------------------------------------------- */ PassFail TestMXSQLDescribeCol(TestInfo *pTestInfo) { TEST_DECLARE; TCHAR Heading[MAX_STRING_SIZE]; RETCODE returncode; SQLHANDLE henv, hdbc, hstmt; UWORD icol; SWORD numcol, st, cs, cnull, cl, colsize = 2; SQLULEN cp; TCHAR cn[COLNAME_LEN]; TCHAR *colname[COL_LEN]; TCHAR *ExecDirStr[12]; TCHAR *colVal[2]; #ifndef _WM #ifdef UNICODE SWORD SQLType[] = {SQL_WCHAR,SQL_WVARCHAR,SQL_DECIMAL,SQL_NUMERIC,SQL_SMALLINT,SQL_INTEGER, SQL_REAL,SQL_DOUBLE,SQL_DOUBLE,SQL_DATE,SQL_TIME,SQL_TIMESTAMP,SQL_WVARCHAR,SQL_BIGINT, SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC, SQL_WCHAR,SQL_WVARCHAR,SQL_WVARCHAR,SQL_CHAR,SQL_VARCHAR,SQL_WVARCHAR}; SQLULEN ColPrec[] = {254,254,18,18,5,10,7,15,15,10,8,26,2000,19,19,19,128,128,10,18,30,254,254,2000,1016,1016,2000}; SWORD ColScale[]= {0,0,6,6,0,0,0,0,0,0,0,6,0,0,0,6,0,128,5,5,10,0,0,0,0,0,0}; #else SWORD SQLType[] = {SQL_CHAR,SQL_VARCHAR,SQL_DECIMAL,SQL_NUMERIC,SQL_SMALLINT,SQL_INTEGER, SQL_REAL,SQL_DOUBLE,SQL_DOUBLE,SQL_DATE,SQL_TIME,SQL_TIMESTAMP,SQL_VARCHAR,SQL_BIGINT, SQL_WCHAR,SQL_WVARCHAR,SQL_WVARCHAR, SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC }; SQLULEN ColPrec[] = {254,254,18,18,5,10,7,15,15,10,8,26,2000,19,254,127,2000,19,19,128,128,10,18,30}; SWORD ColScale[]= {0, 0, 6, 6, 0,0, 0,0, 0, 0, 0,6, 0, 0, 0, 0, 0, 0, 6, 0, 128,5, 5, 10}; #endif #else SWORD SQLType[] = {SQL_CHAR,SQL_VARCHAR,SQL_DECIMAL,SQL_NUMERIC,SQL_SMALLINT,SQL_INTEGER, SQL_REAL,SQL_DOUBLE,SQL_DOUBLE,SQL_CHAR,SQL_TIME,SQL_TIMESTAMP,SQL_LONGVARCHAR,SQL_BIGINT, SQL_WCHAR,SQL_WVARCHAR,SQL_WLONGVARCHAR, SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC}; SQLULEN ColPrec[] = {254,127,18,18,5,10,7,15,15,8,8,26,2000,19,254,127,2000,19,19,128,128,10,18,30}; SWORD ColScale[]= {0,0,6,6,0,0,0,0,0,0,0,6,0,0,0,6,0,128,5,5,10,0,0,0,0,0,0}; #endif TCHAR TempType1[50],TempType2[50]; SWORD ColNullable[] = {SQL_NULLABLE,SQL_NO_NULLS,SQL_NULLABLE}; TCHAR *TestCase[] = { _T("before preparing stmt "), _T("before preparing & executing stmt "), _T("before preparing, executing & fetching stmt "), _T("before execdirect stmt "), _T("before execdirect & fetching stmt "), _T("before preparing param stmt "), _T("before preparing & binding stmt "), _T("before preparing, binding & executing stmt "), _T("before preparing, binding, executing & fetching stmt ") }; int lend = 9, iend = 3; SQLUSMALLINT i = 0, l = 0; SQLLEN cbIn = SQL_NTS; //=========================================================================================================== var_list_t *var_list; var_list = load_api_vars(_T("SQLDescribeColumns"), charset_file); if (var_list == NULL) return FAILED; //print_list(var_list); colname[0] = var_mapping(_T("SQLDescribeColumns_colname_1"), var_list); colname[1] = var_mapping(_T("SQLDescribeColumns_colname_2"), var_list); colname[2] = var_mapping(_T("SQLDescribeColumns_colname_3"), var_list); colname[3] = var_mapping(_T("SQLDescribeColumns_colname_4"), var_list); colname[4] = var_mapping(_T("SQLDescribeColumns_colname_5"), var_list); colname[5] = var_mapping(_T("SQLDescribeColumns_colname_6"), var_list); colname[6] = var_mapping(_T("SQLDescribeColumns_colname_7"), var_list); colname[7] = var_mapping(_T("SQLDescribeColumns_colname_8"), var_list); colname[8] = var_mapping(_T("SQLDescribeColumns_colname_9"), var_list); colname[9] = var_mapping(_T("SQLDescribeColumns_colname_10"), var_list); colname[10] = var_mapping(_T("SQLDescribeColumns_colname_11"), var_list); colname[11] = var_mapping(_T("SQLDescribeColumns_colname_12"), var_list); colname[12] = var_mapping(_T("SQLDescribeColumns_colname_13"), var_list); colname[13] = var_mapping(_T("SQLDescribeColumns_colname_14"), var_list); colname[14] = var_mapping(_T("SQLDescribeColumns_colname_15"), var_list); colname[15] = var_mapping(_T("SQLDescribeColumns_colname_16"), var_list); colname[16] = var_mapping(_T("SQLDescribeColumns_colname_17"), var_list); colname[17] = var_mapping(_T("SQLDescribeColumns_colname_18"), var_list); colname[18] = var_mapping(_T("SQLDescribeColumns_colname_19"), var_list); colname[19] = var_mapping(_T("SQLDescribeColumns_colname_20"), var_list); colname[20] = var_mapping(_T("SQLDescribeColumns_colname_21"), var_list); colname[21] = var_mapping(_T("SQLDescribeColumns_colname_22"), var_list); colname[22] = var_mapping(_T("SQLDescribeColumns_colname_23"), var_list); colname[23] = var_mapping(_T("SQLDescribeColumns_colname_24"), var_list); #ifdef UNICODE colname[24] = var_mapping(_T("SQLDescribeColumns_colname_25"), var_list); colname[25] = var_mapping(_T("SQLDescribeColumns_colname_26"), var_list); colname[26] = var_mapping(_T("SQLDescribeColumns_colname_27"), var_list); #endif ExecDirStr[0] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_1"), var_list); ExecDirStr[1] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_2"), var_list); ExecDirStr[2] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_3"), var_list); ExecDirStr[3] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_4"), var_list); ExecDirStr[4] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_5"), var_list); ExecDirStr[5] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_6"), var_list); ExecDirStr[6] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_7"), var_list); ExecDirStr[7] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_8"), var_list); ExecDirStr[8] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_9"), var_list); ExecDirStr[9] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_10"), var_list); ExecDirStr[10] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_11"), var_list); ExecDirStr[11] = var_mapping(_T("SQLDescribeColumns_ExecDirStr_12"), var_list); colVal[0] = var_mapping(_T("SQLDescribeColumns_colVal_1"), var_list); colVal[1] = var_mapping(_T("SQLDescribeColumns_colVal_2"), var_list); //=========================================================================================================== //if(isUCS2) { // LogMsg(NONE,_T("Setup for UCS2 mode testing: ColPrec has to be doubled\n")); // l = sizeof(SQLType)/sizeof(SQLType[0]); // while(i < l) { // if(SQLType[i] == SQL_WCHAR) { // SQLType[i] = SQL_WCHAR; // //ColPrec[i] *= 2; --> This is in character, so no need to double // } // else if (SQLType[i] == SQL_WVARCHAR) { // SQLType[i] = SQL_WVARCHAR; // //ColPrec[i] *= 2; --> This is in character, so no need to double // } // else if (SQLType[i] == SQL_WLONGVARCHAR) { // SQLType[i] = SQL_WLONGVARCHAR; // //ColPrec[i] *= 2; --> This is in character, so no need to double // } // else { // } // i++; // } // i = 0; // l = 0; //} //=========================================================================================================== LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API => MX Specific SQLDescribeColumns.\n")); TEST_INIT; TESTCASE_BEGIN("Setup for SQLDescribCol tests\n"); if(!FullConnect(pTestInfo)) { LogMsg(NONE,_T("Unable to connect\n")); TEST_FAILED; TEST_RETURN; } henv = pTestInfo->henv; hdbc = pTestInfo->hdbc; hstmt = (SQLHANDLE)pTestInfo->hstmt; returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; TEST_RETURN; } TESTCASE_END; // end of setup for (l = 0; l < lend; l++) { for (i = 0; i < iend; i++) { //================================================================================== _stprintf(Heading,_T("SQLDescribeCol: Test #%d.%d\n"),l,i); TESTCASE_BEGINW(Heading); if ((i != (iend-1)) && (l < 5)) { SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i],SQL_NTS); /* cleanup */ returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i+iend],SQL_NTS); /* create table */ LogMsg(NONE,_T("%s\n"), ExecDirStr[i+iend]); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } else { returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend],SQL_NTS); /* insert into table */ if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } else { LogMsg(NONE,_T("SQLDescribeCol: %s\n"),TestCase[l]); LogMsg(NONE,_T(" %s\n"),ExecDirStr[i+iend+iend+iend]); switch( l ) { case 0: returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } break; case 1 : returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } else { returncode = SQLExecute(hstmt); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } } break; case 2 : returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } else { returncode = SQLExecute(hstmt); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } else { returncode = SQLFetch(hstmt); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } } } break; case 3 : returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } break; case 4 : returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } else { returncode = SQLFetch(hstmt); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } } break; } if (returncode == SQL_SUCCESS) { returncode=SQLNumResultCols(hstmt, &numcol); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultCols")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } for (icol = 1; icol <= numcol; icol++) { LogMsg(LINEBEFORE,_T("SQLDescribeCol: checking Column #%d\n"),icol); returncode = SQLDescribeCol(hstmt,icol,(SQLTCHAR*)cn,COLNAME_LEN,&cl,&st,&cp,&cs,&cnull); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLDescribeCol")) { TEST_FAILED; LogAllErrors(henv,hdbc,hstmt); } colsize=_tcslen(colname[icol-1]); if(isCharSet == TRUE) colsize -= 2; if ((cwcscmp(cn,colname[icol-1],FALSE) == 0) && (cl == colsize) && (st == SQLType[icol-1]) && (cp == ColPrec[icol-1]) && (cs == ColScale[icol-1]) && (cnull == ColNullable[i])) { LogMsg(NONE,_T("colname expect: %s and actual: %s are matched\n"),colname[icol-1],cn); LogMsg(NONE,_T("ColNameLen expect: %d and actual: %d are matched\n"),colsize,cl); LogMsg(NONE,_T("SQLType expect: %s and actual: %s are matched\n"), SQLTypeToChar(SQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2)); LogMsg(NONE,_T("ColPrec expect: %d and actual: %d are matched\n"),ColPrec[icol-1],cp); LogMsg(NONE,_T("ColScale expect: %d and actual: %d are matched\n"),ColScale[icol-1],cs); LogMsg(NONE,_T("ColNullable expect: %s and actual: %s are matched\n\n"), SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2)); } else { TEST_FAILED; if (cwcscmp(cn,colname[icol-1],FALSE) != 0) LogMsg(ERRMSG,_T("colname expect: %s and actual: %s are not matched line %d\n"),colname[icol-1],cn,__LINE__); if (cl != colsize) LogMsg(ERRMSG,_T("ColNameLen expect: %d and actual: %d are not matched line %d\n"),colsize,cl,__LINE__); if (st != SQLType[icol-1]) LogMsg(ERRMSG,_T("SQLType expect: %s and actual: %s are not matched line %d\n"), SQLTypeToChar(SQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2),__LINE__); if (cp != ColPrec[icol-1]) LogMsg(ERRMSG,_T("ColPrec expect: %d and actual: %d are not matched line %d\n"),ColPrec[icol-1],cp,__LINE__); if (cs != ColScale[icol-1]) LogMsg(ERRMSG,_T("ColScale expect: %d and actual: %d are not matched line %d\n"),ColScale[icol-1],cs,__LINE__); if (cnull != ColNullable[i]) LogMsg(ERRMSG,_T("ColNullable expect: %s and actual: %s are not matched line %d\n\n"), SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2),__LINE__); } } /* end icol loop */ } else { TEST_FAILED; LogAllErrors(henv,hdbc,hstmt); } SQLFreeStmt(hstmt,SQL_CLOSE); SQLExecDirect(hstmt,(SQLTCHAR*) ExecDirStr[i],SQL_NTS); /* cleanup */ } } } else if ((i == (iend-1)) && (l >= 5)) { SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i],SQL_NTS); /* cleanup */ returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i+iend],SQL_NTS); /* create table */ LogMsg(NONE,_T("%s\n"), ExecDirStr[i+iend]); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } else { returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend],SQL_NTS); /* insert into table */ if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } else { LogMsg(NONE,_T("SQLDescribeCol: %s\n"),TestCase[l]); LogMsg(NONE,_T(" %s\n"),ExecDirStr[i+iend+iend+iend]); switch( l ) { case 5 : returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } break; case 6 : returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } else { returncode = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_TCHAR,SQL_WCHAR,2000,0,(SQLPOINTER)colVal[0],300,&cbIn); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } returncode = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_TCHAR,SQL_WCHAR,2000,0,(SQLPOINTER)colVal[1],300,&cbIn); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } } break; case 7 : returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } else { returncode = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_TCHAR,SQL_WCHAR,2000,0,(SQLPOINTER)colVal[0],300,&cbIn); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } returncode = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_TCHAR,SQL_WCHAR,2000,0,(SQLPOINTER)colVal[1],300,&cbIn); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } returncode = SQLExecute(hstmt); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } } break; case 8 : returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } else { returncode = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_TCHAR,SQL_WCHAR,2000,0,(SQLPOINTER)colVal[0],300,&cbIn); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } returncode = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_TCHAR,SQL_WCHAR,2000,0,(SQLPOINTER)colVal[1],300,&cbIn); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } returncode = SQLExecute(hstmt); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } else { returncode = SQLFetch(hstmt); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } } } break; } if (returncode == SQL_SUCCESS) { SQLNumResultCols(hstmt, &numcol); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultCols")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } for (icol = 1; icol <= numcol; icol++) { LogMsg(LINEBEFORE,_T("SQLDescribeCol: checking Column #%d\n"),icol); returncode = SQLDescribeCol(hstmt,icol,(SQLTCHAR*)cn,COLNAME_LEN,&cl,&st,&cp,&cs,&cnull); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLDescribeCol")) { TEST_FAILED; LogAllErrors(henv,hdbc,hstmt); } colsize=_tcslen(colname[icol-1]); if(isCharSet == TRUE) colsize -= 2; if ((cwcscmp(cn,colname[icol-1],FALSE) == 0) && (cl == colsize) && (st == SQLType[icol-1]) && (cp == ColPrec[icol-1]) && (cs == ColScale[icol-1]) && (cnull == ColNullable[i])) { LogMsg(NONE,_T("colname expect: %s and actual: %s are matched\n"),colname[icol-1],cn); LogMsg(NONE,_T("ColNameLen expect: %d and actual: %d are matched\n"),colsize,cl); LogMsg(NONE,_T("SQLType expect: %s and actual: %s are matched\n"), SQLTypeToChar(SQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2)); LogMsg(NONE,_T("ColPrec expect: %d and actual: %d are matched\n"),ColPrec[icol-1],cp); LogMsg(NONE,_T("ColScale expect: %d and actual: %d are matched\n"),ColScale[icol-1],cs); LogMsg(NONE,_T("ColNullable expect: %s and actual: %s are matched\n\n"), SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2)); } else { TEST_FAILED; if (cwcscmp(cn,colname[icol-1],FALSE) != 0) LogMsg(ERRMSG,_T("colname expect: %s and actual: %s are not matched at line %d\n"),colname[icol-1],cn,__LINE__); if (cl != colsize) LogMsg(ERRMSG,_T("ColNameLen expect: %d and actual: %d are not matched at line %d\n"),colsize,cl,__LINE__); if (st != SQLType[icol-1]) LogMsg(ERRMSG,_T("SQLType expect: %s and actual: %s are not matched at line %d\n"), SQLTypeToChar(SQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2),__LINE__); if (cp != ColPrec[icol-1]) LogMsg(ERRMSG,_T("ColPrec expect: %d and actual: %d are not matched at line %d\n"),ColPrec[icol-1],cp,__LINE__); if (cs != ColScale[icol-1]) LogMsg(ERRMSG,_T("ColScale expect: %d and actual: %d are not matched at line %d\n"),ColScale[icol-1],cs,__LINE__); if (cnull != ColNullable[i]) LogMsg(ERRMSG,_T("ColNullable expect: %s and actual: %s are not matched at line %d\n\n"), SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2),__LINE__); } } } } SQLFreeStmt(hstmt,SQL_CLOSE); SQLExecDirect(hstmt,(SQLTCHAR*) ExecDirStr[i],SQL_NTS); } } TESTCASE_END; } /* iend loop */ } /* lend loop */ FullDisconnect(pTestInfo); LogMsg(SHORTTIMESTAMP+LINEAFTER,_T("End testing API => MX Specific SQLDescribeColumns.\n")); free_list(var_list); TEST_RETURN; }
PassFail TestMXSQLTables (TestInfo *pTestInfo) { TEST_DECLARE; TCHAR Heading[MAX_HEADING_SIZE]; RETCODE returncode; SQLHANDLE henv; SQLHANDLE hdbc; SQLHANDLE hstmt, hstmt1; TCHAR TableQualifier[NAME_LEN],TableOwner[NAME_LEN],Remark[REM_LEN],*TableStr; TCHAR oTableQualifier[NAME_LEN]; TCHAR oTableOwner[NAME_LEN]; TCHAR oTableName[NAME_LEN]; TCHAR oTableType[NAME_LEN]; TCHAR oRemark[REM_LEN]; SQLLEN oTableQualifierlen,oTableOwnerlen,oTableNamelen,oTableTypelen,oRemarklen; int cols, iatt; SWORD numOfCols = 0; SWORD pcbDesc; SQLLEN pfDesc; TCHAR cn[TabType_LEN]; SWORD cl; SWORD st; SQLULEN cp; SWORD cs, cnull; TCHAR rgbDesc[RGB_MAX_LEN]; TCHAR *CharOutput[12]; SQLLEN stringlength; struct { TCHAR *TableName; TCHAR *TableType; TCHAR *TableTypeIn; } Table[] = { {_T("--") ,_T("TABLE") ,_T("")}, {_T("--") ,_T("TABLE") ,_T("TABLE")}, {_T("--") ,_T("TABLE") ,_T("TABLE,VIEW,SYSTEM TABLE")}, {_T("--") ,_T("TABLE") ,_T("TABLE,SYSTEM TABLE,VIEW")}, {_T("--") ,_T("TABLE") ,_T("TABLE,VIEW,SYSTEM TABLE,SYNONYM,MV,MVG")}, {_T("--") ,_T("VIEW"),_T("VIEW")}, {_T("--") ,_T("VIEW"),_T("TABLE,VIEW,SYSTEM TABLE")}, {_T("--") ,_T("MATERIALIZED VIEW"),_T("")}, {_T("--") ,_T("MATERIALIZED VIEW"),_T("MV")}, {_T("--") ,_T("SYNONYM"),_T("")}, {_T("--") ,_T("SYNONYM"),_T("SYNONYM")}, {_T("endloop"),} }; struct { TCHAR *TabQua; TCHAR *TabOwner; TCHAR *TabName; TCHAR *TabType; int changedSchema; } TableWC[] = { {_T(SQL_ALL_CATALOGS),_T("") ,_T("--") ,_T("") ,-1}, //0 {_T("") ,_T(SQL_ALL_SCHEMAS),_T("--") ,_T("") ,-1}, //1 {_T("") ,_T("") ,_T("--") ,_T(SQL_ALL_TABLE_TYPES) ,-1}, //2 {pTestInfo->Catalog ,pTestInfo->Schema ,_T("--") ,_T("TABLE") ,-1}, //3 {pTestInfo->Catalog ,_T(SQL_ALL_SCHEMAS),_T("--") ,_T(SQL_ALL_TABLE_TYPES) ,-1}, //4 {pTestInfo->Catalog ,_T(SQL_ALL_SCHEMAS),_T("--") ,_T(SQL_ALL_TABLE_TYPES) ,-1}, //5 {pTestInfo->Catalog ,_T(SQL_ALL_SCHEMAS),_T("--") ,_T("TABLE") ,-1}, //6 {pTestInfo->Catalog ,_T(SQL_ALL_SCHEMAS),_T("--") ,_T(SQL_ALL_TABLE_TYPES) ,-1}, //7 {pTestInfo->Catalog ,_T(SQL_ALL_SCHEMAS),_T("--") ,_T(SQL_ALL_TABLE_TYPES) ,-1}, //8 {pTestInfo->Catalog ,_T(SQL_ALL_SCHEMAS),_T("--") ,_T("TABLE") ,-1}, //9 {pTestInfo->Catalog ,_T("--") ,_T("--") ,_T("TABLE") ,1}, //10 {pTestInfo->Catalog ,_T("--") ,_T("--") ,_T("TABLE") ,1}, //11 {pTestInfo->Catalog ,pTestInfo->Schema ,_T("--") ,_T("TABLE") ,-1}, //12 {pTestInfo->Catalog ,pTestInfo->Schema ,_T("--") ,_T("TABLE") ,-1}, //13 {pTestInfo->Catalog ,pTestInfo->Schema ,_T("--") ,_T(SQL_ALL_TABLE_TYPES) ,-1}, //14 {pTestInfo->Catalog ,pTestInfo->Schema ,_T("--") ,_T("TABLE") ,-1}, //15 {pTestInfo->Catalog ,pTestInfo->Schema ,_T("--") ,_T("TABLE") ,-1}, //16 {pTestInfo->Catalog ,pTestInfo->Schema ,_T("--") ,_T("TABLE") ,-1}, //17 {pTestInfo->Catalog ,pTestInfo->Schema ,_T("--") ,_T("TABLE") ,-1}, //18 {pTestInfo->Catalog ,_T(SQL_ALL_SCHEMAS),_T("--") ,_T(SQL_ALL_TABLE_TYPES) ,-1}, //19 {pTestInfo->Catalog ,_T(SQL_ALL_SCHEMAS),_T("--") ,_T("TABLE") ,-1}, //20 {pTestInfo->Catalog ,_T(SQL_ALL_SCHEMAS),_T("--") ,_T("TABLE") ,-1}, //21 {pTestInfo->Catalog ,_T("--") ,_T("--") ,_T("TABLE") ,1}, //22 {pTestInfo->Catalog ,_T(SQL_ALL_SCHEMAS),_T("--") ,_T("TABLE") ,-1}, //23 {pTestInfo->Catalog ,_T("--") ,_T("--") ,_T("TABLE") ,1}, //24 {pTestInfo->Catalog ,pTestInfo->Schema ,_T("--") ,_T("TABLE") ,-1}, //25 {pTestInfo->Catalog ,_T("--") ,_T("--") ,_T("TABLE") ,1}, //26 {pTestInfo->Catalog ,pTestInfo->Schema ,_T("--") ,_T("VIEW") ,-1}, //27 {pTestInfo->Catalog ,pTestInfo->Schema ,_T("--") ,_T("TABLE") ,-1}, //28 {pTestInfo->Catalog ,pTestInfo->Schema ,_T("--") ,_T(SQL_ALL_TABLE_TYPES) ,-1}, //29 {pTestInfo->Catalog ,pTestInfo->Schema ,_T("--") ,_T("TABLE") ,-1}, //30 {pTestInfo->Catalog ,pTestInfo->Schema ,_T("--") ,_T("VIEW") ,-1}, //31 {pTestInfo->Catalog ,pTestInfo->Schema ,_T("--") ,_T("TABLE") ,-1}, //32 {pTestInfo->Catalog ,pTestInfo->Schema ,_T("--") ,_T("TABLE") ,-1}, //33 {pTestInfo->Catalog ,pTestInfo->Schema ,_T("--") ,_T("TABLE") ,-1}, //34 {_T("NULL") ,pTestInfo->Schema ,_T("--") ,_T("TABLE") ,-1}, //35 {pTestInfo->Catalog ,pTestInfo->Schema ,_T("--") ,_T("TABLE") ,-1}, //36 {pTestInfo->Catalog ,pTestInfo->Schema ,_T("--") ,_T("TABLE") ,-1}, //37 {_T("NULL") ,_T("--") ,_T("--") ,_T("TABLE") ,0}, //38 {_T("NULL") ,pTestInfo->Schema ,_T("--") ,_T("TABLE") ,-1}, //39 {_T("NULL") ,_T("NULL") ,_T("--") ,_T("TABLE") ,-1}, //40 {pTestInfo->Catalog ,_T("--") ,_T("--") ,_T(SQL_ALL_TABLE_TYPES) ,0}, //41 {pTestInfo->Catalog ,_T("--") ,_T("--") ,_T(SQL_ALL_TABLE_TYPES) ,0}, //42 {pTestInfo->Catalog ,_T("--") ,_T("--") ,_T(SQL_ALL_TABLE_TYPES) ,2}, //43 {_T("endloop"),} }; struct { TCHAR *TabQua; SWORD TabQuaLen; TCHAR *TabOwner; SWORD TabOwnerLen; TCHAR *TabName; SWORD TabNameLen; TCHAR *TabType; SWORD TabTypeLen; } TableWC2[] = { // wild cards from here {pTestInfo->Catalog, (SWORD)-1, pTestInfo->Schema,(SWORD)-1, _T("--"),(SWORD)-1, _T(""), (SWORD)-1}, //{pTestInfo->Catalog, (SWORD)4, pTestInfo->Schema,(SWORD)2, "OBJECTS",(SWORD)2, _T(""), (SWORD)2}, //{pTestInfo->Catalog, (SWORD)3, pTestInfo->Schema,(SWORD)7, "OBJECTS",(SWORD)3, _T(""), (SWORD)0}, {_T("endloop"),} }; //attributes for columns added for negative testing UWORD DescrType[] = { SQL_COLUMN_AUTO_INCREMENT,SQL_COLUMN_CASE_SENSITIVE,SQL_COLUMN_COUNT, SQL_COLUMN_DISPLAY_SIZE,SQL_COLUMN_LENGTH,SQL_COLUMN_MONEY, SQL_COLUMN_NULLABLE,SQL_COLUMN_PRECISION,SQL_COLUMN_SCALE, SQL_COLUMN_SEARCHABLE,SQL_COLUMN_TYPE,SQL_COLUMN_UNSIGNED, SQL_COLUMN_UPDATABLE,SQL_COLUMN_NAME,SQL_COLUMN_TYPE_NAME, SQL_COLUMN_OWNER_NAME,SQL_COLUMN_QUALIFIER_NAME,SQL_COLUMN_TABLE_NAME, SQL_COLUMN_LABEL }; struct { TCHAR cat[STR_LEN]; TCHAR sch[STR_LEN]; TCHAR tab[STR_LEN]; TCHAR typ[STR_LEN]; } displayBuf; int i = 0, k = 0, NullValue = 0; TCHAR tmpSchema[129]; TCHAR schemaList[3][256]; int myInd=1; int len = _tcslen(pTestInfo->Schema); TCHAR *CrtCol[] = { _T("--"), _T("--") }; TCHAR *DrpTab[] = { _T("--"), _T("--"), _T("--")}; TCHAR *CrtTab[] = { _T("--"), _T("--"), _T("--")}; //=========================================================================================================== var_list_t *var_list; var_list = load_api_vars(_T("SQLTables"), charset_file); if (var_list == NULL) return FAILED; Table[0].TableName = var_mapping(_T("SQLTables_Table_TableName_0"), var_list); Table[1].TableName = var_mapping(_T("SQLTables_Table_TableName_1"), var_list); Table[2].TableName = var_mapping(_T("SQLTables_Table_TableName_2"), var_list); Table[3].TableName = var_mapping(_T("SQLTables_Table_TableName_3"), var_list); Table[4].TableName = var_mapping(_T("SQLTables_Table_TableName_4"), var_list); Table[5].TableName = var_mapping(_T("SQLTables_Table_TableName_5"), var_list); Table[6].TableName = var_mapping(_T("SQLTables_Table_TableName_6"), var_list); Table[7].TableName = var_mapping(_T("SQLTables_Table_TableName_7"), var_list); Table[8].TableName = var_mapping(_T("SQLTables_Table_TableName_8"), var_list); Table[9].TableName = var_mapping(_T("SQLTables_Table_TableName_9"), var_list); Table[10].TableName = var_mapping(_T("SQLTables_Table_TableName_10"), var_list); TableWC[10].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_10"), var_list); TableWC[11].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_11"), var_list); TableWC[22].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_22"), var_list); TableWC[24].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_24"), var_list); TableWC[26].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_26"), var_list); TableWC[38].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_38"), var_list); TableWC[41].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_10"), var_list); TableWC[42].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_41"), var_list); TableWC[43].TabOwner = var_mapping(_T("SQLTables_TableWC_TabOwner_43"), var_list); TableWC[0].TabName = var_mapping(_T("SQLTables_TableWC_TabName_0"), var_list); TableWC[1].TabName = var_mapping(_T("SQLTables_TableWC_TabName_1"), var_list); TableWC[2].TabName = var_mapping(_T("SQLTables_TableWC_TabName_2"), var_list); TableWC[3].TabName = var_mapping(_T("SQLTables_TableWC_TabName_3"), var_list); TableWC[4].TabName = var_mapping(_T("SQLTables_TableWC_TabName_4"), var_list); TableWC[5].TabName = var_mapping(_T("SQLTables_TableWC_TabName_5"), var_list); TableWC[6].TabName = var_mapping(_T("SQLTables_TableWC_TabName_6"), var_list); TableWC[7].TabName = var_mapping(_T("SQLTables_TableWC_TabName_7"), var_list); TableWC[8].TabName = var_mapping(_T("SQLTables_TableWC_TabName_8"), var_list); TableWC[9].TabName = var_mapping(_T("SQLTables_TableWC_TabName_9"), var_list); TableWC[10].TabName = var_mapping(_T("SQLTables_TableWC_TabName_10"), var_list); TableWC[11].TabName = var_mapping(_T("SQLTables_TableWC_TabName_11"), var_list); TableWC[12].TabName = var_mapping(_T("SQLTables_TableWC_TabName_12"), var_list); TableWC[13].TabName = var_mapping(_T("SQLTables_TableWC_TabName_13"), var_list); TableWC[14].TabName = var_mapping(_T("SQLTables_TableWC_TabName_14"), var_list); TableWC[15].TabName = var_mapping(_T("SQLTables_TableWC_TabName_15"), var_list); TableWC[16].TabName = var_mapping(_T("SQLTables_TableWC_TabName_16"), var_list); TableWC[17].TabName = var_mapping(_T("SQLTables_TableWC_TabName_17"), var_list); TableWC[18].TabName = var_mapping(_T("SQLTables_TableWC_TabName_18"), var_list); TableWC[19].TabName = var_mapping(_T("SQLTables_TableWC_TabName_19"), var_list); TableWC[20].TabName = var_mapping(_T("SQLTables_TableWC_TabName_20"), var_list); TableWC[21].TabName = var_mapping(_T("SQLTables_TableWC_TabName_21"), var_list); TableWC[22].TabName = var_mapping(_T("SQLTables_TableWC_TabName_22"), var_list); TableWC[23].TabName = var_mapping(_T("SQLTables_TableWC_TabName_23"), var_list); TableWC[24].TabName = var_mapping(_T("SQLTables_TableWC_TabName_24"), var_list); TableWC[25].TabName = var_mapping(_T("SQLTables_TableWC_TabName_25"), var_list); TableWC[26].TabName = var_mapping(_T("SQLTables_TableWC_TabName_26"), var_list); TableWC[27].TabName = var_mapping(_T("SQLTables_TableWC_TabName_27"), var_list); TableWC[28].TabName = var_mapping(_T("SQLTables_TableWC_TabName_28"), var_list); TableWC[29].TabName = var_mapping(_T("SQLTables_TableWC_TabName_29"), var_list); TableWC[30].TabName = var_mapping(_T("SQLTables_TableWC_TabName_30"), var_list); TableWC[31].TabName = var_mapping(_T("SQLTables_TableWC_TabName_31"), var_list); TableWC[32].TabName = var_mapping(_T("SQLTables_TableWC_TabName_32"), var_list); TableWC[33].TabName = var_mapping(_T("SQLTables_TableWC_TabName_33"), var_list); TableWC[34].TabName = var_mapping(_T("SQLTables_TableWC_TabName_34"), var_list); TableWC[35].TabName = var_mapping(_T("SQLTables_TableWC_TabName_35"), var_list); TableWC[36].TabName = var_mapping(_T("SQLTables_TableWC_TabName_36"), var_list); TableWC[37].TabName = var_mapping(_T("SQLTables_TableWC_TabName_37"), var_list); TableWC[38].TabName = var_mapping(_T("SQLTables_TableWC_TabName_38"), var_list); TableWC[39].TabName = var_mapping(_T("SQLTables_TableWC_TabName_39"), var_list); TableWC[40].TabName = var_mapping(_T("SQLTables_TableWC_TabName_40"), var_list); TableWC[41].TabName = var_mapping(_T("SQLTables_TableWC_TabName_41"), var_list); TableWC[42].TabName = var_mapping(_T("SQLTables_TableWC_TabName_42"), var_list); TableWC[43].TabName = var_mapping(_T("SQLTables_TableWC_TabName_43"), var_list); TableWC2[0].TabName = var_mapping(_T("SQLTables_TableWC2_TabName_0"), var_list); CrtCol[0] = var_mapping(_T("SQLTables_CrtCol_0"), var_list); CrtCol[1] = var_mapping(_T("SQLTables_CrtCol_1"), var_list); DrpTab[0] = var_mapping(_T("SQLTables_DrpTab_0"), var_list); DrpTab[1] = var_mapping(_T("SQLTables_DrpTab_1"), var_list); DrpTab[2] = var_mapping(_T("SQLTables_DrpTab_2"), var_list); CrtTab[0] = var_mapping(_T("SQLTables_CrtTab_0"), var_list); CrtTab[1] = var_mapping(_T("SQLTables_CrtTab_1"), var_list); CrtTab[2] = var_mapping(_T("SQLTables_CrtTab_2"), var_list); //=========================================================================================================== memset(schemaList[0],'\0', 256*sizeof(TCHAR)); memset(schemaList[1],'\0', 256*sizeof(TCHAR)); memset(schemaList[2],'\0', 256*sizeof(TCHAR)); myInd = len - 2; if (len>5) myInd=4; /* #ifndef UNICODE if (_tcscmp("English", _tsetlocale(LC_ALL, _T(""))) != 0) { _mbsncpy(schemaList[0],pTestInfo->Schema,myInd); _mbscat(schemaList[0], "%"); _mbsncpy(schemaList[1],pTestInfo->Schema,myInd+1); _mbscat(schemaList[1], "%"); } else { #endif */ _tcsncpy(schemaList[0],pTestInfo->Schema,myInd); _tcscat(schemaList[0], _T("%")); _tcsncpy(schemaList[1],pTestInfo->Schema,myInd+1); _tcscat(schemaList[1], _T("%")); /* #ifndef UNICODE } #endif */ len = 0; myInd = 0; do { if (pTestInfo->Schema[myInd] == '_') schemaList[2][len++] = '\\'; schemaList[2][len++] = pTestInfo->Schema[myInd]; } while (pTestInfo->Schema[myInd++] != '\0'); LogMsg(NONE,_T("%s %s %s\n"), schemaList[0], schemaList[1], schemaList[2]); if (isCharSet) { _stprintf(tmpSchema, _T("\"SQLTABLES_%s\""), pTestInfo->Schema); } else { _stprintf(tmpSchema, _T("SQLTABLES_%s"), pTestInfo->Schema); } _tcsupr(tmpSchema); //====================================================================================================== LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API => MX SPECIFIC SQLTables.\n")); TEST_INIT; TESTCASE_BEGIN("Setup for SQLTables tests\n"); // for ODBC 3.0 if(!FullConnectWithOptions(pTestInfo, CONNECT_ODBC_VERSION_3)) { LogMsg(NONE,_T("Unable to connect as ODBC3.0 application.\n")); TEST_FAILED; TEST_RETURN; } henv = pTestInfo->henv; hdbc = pTestInfo->hdbc; hstmt = (SQLHANDLE)pTestInfo->hstmt; returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt")) { TEST_FAILED; LogAllErrors(henv,hdbc,hstmt); } else { LogMsg(NONE,_T("Allocate a stmt handle successfully.\n")); } TESTCASE_END; _tcscpy(pTestInfo->Catalog, _T("TRAFODION")); if (returncode == SQL_SUCCESS) { _stprintf(Heading,_T("drop schema %s.%s cascade"),pTestInfo->Catalog,tmpSchema); returncode = SQLExecDirect(hstmt,(SQLTCHAR*)Heading, SQL_NTS); _stprintf(Heading,_T("create schema %s.%s"),pTestInfo->Catalog,tmpSchema); returncode = SQLExecDirect(hstmt,(SQLTCHAR*)Heading, SQL_NTS); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; TEST_RETURN; } _stprintf(Heading,_T("set schema %s.%s"),pTestInfo->Catalog,tmpSchema); returncode = SQLExecDirect(hstmt,(SQLTCHAR*)Heading, SQL_NTS); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; TEST_RETURN; } _tcscpy(TableQualifier,pTestInfo->Catalog); _tcscpy(TableOwner, tmpSchema); _tcscpy(Remark,_T("")); TableStr = (TCHAR *)malloc(MAX_NOS_SIZE); i = 0; while (_tcsicmp(Table[i].TableName,_T("endloop")) != 0) // cleanup { _tcscpy(TableStr,_T("")); _tcscat(TableStr,_T("drop ")); _tcscat(TableStr,Table[i].TableType); _tcscat(TableStr,_T(" ")); _tcscat(TableStr,Table[i].TableName); _tcscat(TableStr,_T(" cascade")); LogMsg(NONE,_T("Cleanup: %s\n"),TableStr); returncode = SQLExecDirect(hstmt,(SQLTCHAR*) TableStr,SQL_NTS); i++; } i = 0; while (_tcsicmp(Table[i].TableName,_T("endloop")) != 0) { _tcscpy(TableStr,_T("")); _tcscat(TableStr,_T("create ")); _tcscat(TableStr,Table[i].TableType); _tcscat(TableStr,_T(" ")); _tcscat(TableStr,Table[i].TableName); if (_tcsicmp(Table[i].TableType,_T("VIEW")) == 0) { _tcscat(TableStr,CrtCol[1]); _tcscat(TableStr, Table[0].TableName); } else if (_tcsicmp(Table[i].TableType,_T("MATERIALIZED VIEW")) == 0) { _tcscat(TableStr, _T(" REFRESH ON REQUEST INITIALIZE ON REFRESH ")); _tcscat(TableStr,CrtCol[1]); _tcscat(TableStr, Table[0].TableName); } else if (_tcsicmp(Table[i].TableType,_T("SYNONYM")) == 0) { _tcscat(TableStr, _T(" FOR ")); _tcscat(TableStr, Table[0].TableName); } else { _tcscat(TableStr,CrtCol[0]); } _stprintf(Heading,_T("SQLTables: Test %d: using the following table create command=> \n"),i); _tcscat(Heading,TableStr); _tcscat(Heading,_T("\n")); TESTCASE_BEGINW(Heading); returncode = SQLExecDirect(hstmt,(SQLTCHAR*)TableStr,SQL_NTS); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } else { LogMsg(NONE,_T("Created table successfully.\n")); } if(isCharSet) { returncode = SQLSetStmtAttr(hstmt,SQL_ATTR_METADATA_ID,(SQLPOINTER)SQL_TRUE,0); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetStmtAttr(SQL_ATTR_METADATA_ID")) { TEST_FAILED; LogAllErrors(henv,hdbc,hstmt); } } if (returncode == SQL_SUCCESS) { if (_tcslen(TableQualifier) > 0) returncode = SQLTables(hstmt,(SQLTCHAR*)TableQualifier,(SWORD)_tcslen(TableQualifier),(SQLTCHAR*)TableOwner,(SWORD)_tcslen(TableOwner),(SQLTCHAR*)Table[i].TableName,(SWORD)_tcslen(Table[i].TableName),(SQLTCHAR*)Table[i].TableTypeIn,(SWORD)_tcslen(Table[i].TableTypeIn)); else returncode = SQLTables(hstmt,NULL,(SWORD)_tcslen(TableQualifier),(SQLTCHAR*)TableOwner,(SWORD)_tcslen(TableOwner),(SQLTCHAR*)Table[i].TableName,(SWORD)_tcslen(Table[i].TableName),(SQLTCHAR*)Table[i].TableTypeIn,(SWORD)_tcslen(Table[i].TableTypeIn)); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLTables")) { TEST_FAILED; LogAllErrors(henv,hdbc,hstmt); } else { LogMsg(NONE,_T("Call to SQLTables() executed successfully.\n")); _tcscpy(oTableQualifier,_T("")); _tcscpy(oTableOwner,_T("")); _tcscpy(oTableName,_T("")); _tcscpy(oTableType,_T("")); _tcscpy(oRemark,_T("")); returncode=SQLBindCol(hstmt,1,SQL_C_TCHAR,oTableQualifier,NAME_LEN,&oTableQualifierlen); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")){ LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } returncode=SQLBindCol(hstmt,2,SQL_C_TCHAR,oTableOwner,NAME_LEN,&oTableOwnerlen); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")){ LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } returncode=SQLBindCol(hstmt,3,SQL_C_TCHAR,oTableName,NAME_LEN,&oTableNamelen); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")){ LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } returncode=SQLBindCol(hstmt,4,SQL_C_TCHAR,oTableType,NAME_LEN,&oTableTypelen); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")){ LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } returncode=SQLBindCol(hstmt,5,SQL_C_TCHAR,oRemark,NAME_LEN,&oRemarklen); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")){ LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } k = 0; while (returncode == SQL_SUCCESS) { returncode = SQLFetch(hstmt); if((returncode != SQL_NO_DATA_FOUND)&&(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } else if (returncode == SQL_SUCCESS) { if (_tcslen(TableQualifier) == 0) { //_tcscpy(TableQualifier, _T("TRAFODION")); _tcscpy(TableQualifier, _T("TRAFODION")); } if ((_tcsicmp(TableQualifier,oTableQualifier) == 0) && (cwcscmp(TableOwner,oTableOwner,TRUE) == 0) && (cwcscmp(Table[i].TableName,oTableName,TRUE) == 0) && (_tcsnicmp(Table[i].TableType,oTableType,_tcslen(Table[i].TableType)) == 0) && (_tcsicmp(Remark,oRemark) == 0)) { LogMsg(NONE,_T("TableQualifier expect: '%s' and actual: '%s' are matched\n"),(SQLTCHAR*)TableQualifier,oTableQualifier); LogMsg(NONE,_T("TableOwner expect: '%s' and actual: '%s' are matched\n"),(SQLTCHAR*)TableOwner,oTableOwner); LogMsg(NONE,_T("TableName expect: '%s' and actual: '%s' are matched\n"),(SQLTCHAR*)Table[i].TableName,oTableName); LogMsg(NONE,_T("TableType expect: '%s' and actual: '%s' are matched\n"),Table[i].TableType,oTableType); LogMsg(NONE,_T("Remark expect: '%s' and actual: '%s' are matched\n"),Remark,oRemark); } else { TEST_FAILED; if (_tcsicmp(TableQualifier,oTableQualifier) != 0) LogMsg(ERRMSG,_T("TableQualifier expect: '%s' and actual: '%s' are not matched\n"),(SQLTCHAR*)TableQualifier,oTableQualifier); if (cwcscmp(TableOwner,oTableOwner,TRUE) != 0) LogMsg(ERRMSG,_T("TableOwner expect: '%s' and actual: '%s' are not matched\n"),(SQLTCHAR*)TableOwner,oTableOwner); if (cwcscmp(Table[i].TableName,oTableName,TRUE) != 0) LogMsg(ERRMSG,_T("TableName expect: '%s' and actual: '%s' are not matched\n"),(SQLTCHAR*)Table[i].TableName,oTableName); if (_tcsnicmp(Table[i].TableType,oTableType,10) != 0) LogMsg(ERRMSG,_T("TableType expect: '%s' and actual: '%s' are not matched\n"),Table[i].TableType,oTableType); if (_tcsicmp(Remark,oRemark) != 0) LogMsg(ERRMSG,_T("Remark expect: '%s' and actual: '%s' are not matched\n"),Remark,oRemark); } k++; } }//End while loop if(k != 1) { TEST_FAILED; LogMsg(ERRMSG,_T("Only one row should be fetched, the actual number of rows fetched: %d\n"), k); } else { LogMsg(NONE, _T("Number of rows fetched: %d\n"), k); } } SQLFreeStmt(hstmt,SQL_UNBIND); SQLFreeStmt(hstmt,SQL_CLOSE); } TESTCASE_END; i++; } // i = 0; // while (_tcsicmp(Table[i].TableName,"endloop") != 0) // cleanup // { // _tcscpy(TableStr,_T("")); // _tcscat(TableStr,"drop "); // _tcscat(TableStr,Table[i].TableType); // _tcscat(TableStr," "); // _tcscat(TableStr,Table[i].TableName); // SQLExecDirect(hstmt,(SQLTCHAR*) TableStr,SQL_NTS); // i++; // } _stprintf(Heading,_T("drop schema %s.%s cascade"),pTestInfo->Catalog,tmpSchema); returncode = SQLExecDirect(hstmt,(SQLTCHAR*)Heading, SQL_NTS); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; TEST_RETURN; } if (isCharSet) { _stprintf(Heading,_T("set schema %s.\"%s\""),pTestInfo->Catalog,pTestInfo->Schema); } else { _stprintf(Heading,_T("set schema %s.%s"),pTestInfo->Catalog,pTestInfo->Schema); } returncode = SQLExecDirect(hstmt,(SQLTCHAR*)Heading, SQL_NTS); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; TEST_RETURN; } //====================================================================================================== _stprintf(Heading,_T("Setting up Table & view to test SQLTables for wildcard options => \n")); _tcscat(Heading,_T("\n")); TESTCASE_BEGINW(Heading); SQLExecDirect(hstmt,(SQLTCHAR*)DrpTab[0],SQL_NTS); SQLExecDirect(hstmt,(SQLTCHAR*)DrpTab[1],SQL_NTS); SQLExecDirect(hstmt,(SQLTCHAR*)DrpTab[2],SQL_NTS); LogMsg(NONE,_T("%s\n"), CrtTab[0]); returncode = SQLExecDirect(hstmt,(SQLTCHAR*)CrtTab[0],SQL_NTS); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } else { returncode = SQLExecDirect(hstmt,(SQLTCHAR*)CrtTab[1],SQL_NTS); LogMsg(NONE,_T("%s\n"), CrtTab[1]); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } else { LogMsg(NONE,_T("setting up tables & views executed successfully.\n")); TESTCASE_END; } } returncode = SQLExecDirect(hstmt,(SQLTCHAR*)CrtTab[2],SQL_NTS); LogMsg(NONE,_T("%s\n"), CrtTab[2]); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } i = 0; while (_tcsicmp(TableWC[i].TabQua,_T("endloop")) != 0) { if(TableWC[i].changedSchema == -1) { printSymbol(TableWC[i].TabQua,displayBuf.cat); printSymbol(TableWC[i].TabOwner,displayBuf.sch); printSymbol(TableWC[i].TabName,displayBuf.tab); printSymbol(TableWC[i].TabType,displayBuf.typ); _stprintf(Heading,_T("Test Positive Functionality of SQLTables for following wildcard options => \n TableQualifier: %s\n TableOwner: %s\n TableName: %s\n TableType: %s\n"), displayBuf.cat, displayBuf.sch, displayBuf.tab, displayBuf.typ); } else { printSymbol(TableWC[i].TabQua,displayBuf.cat); printSymbol(schemaList[TableWC[i].changedSchema],displayBuf.sch); printSymbol(TableWC[i].TabName,displayBuf.tab); printSymbol(TableWC[i].TabType,displayBuf.typ); _stprintf(Heading,_T("Test Positive Functionality of SQLTables for following wildcard options => \n TableQualifier: %s\n TableOwner: %s\n TableName: %s\n TableType: %s\n"), displayBuf.cat, displayBuf.sch, displayBuf.tab, displayBuf.typ); } TESTCASE_BEGINW(Heading); NullValue = 0; returncode = SQLSetStmtAttr(hstmt,SQL_ATTR_METADATA_ID,(SQLPOINTER)SQL_FALSE,0); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetStmtAttr(SQL_ATTR_METADATA_ID")) { TEST_FAILED; LogAllErrors(henv,hdbc,hstmt); } if (_tcsicmp(TableWC[i].TabType,_T("NULL")) == 0) { TableWC[i].TabType = NULL; NullValue = 1; returncode = SQLTables(hstmt,NULL,0,NULL,0,NULL,0,NULL,0); } else if (_tcsicmp(TableWC[i].TabName,_T("NULL")) == 0) { TableWC[i].TabName = NULL; NullValue = 1; returncode = SQLTables(hstmt,NULL,0,NULL,0,NULL,0,(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType)); } else if (_tcsicmp(TableWC[i].TabOwner,_T("NULL")) == 0) { TableWC[i].TabOwner = NULL; NullValue = 1; returncode = SQLTables(hstmt,NULL,0,NULL,0,(SQLTCHAR*)removeQuotes(TableWC[i].TabName,displayBuf.tab),(SWORD)_tcslen(displayBuf.tab),(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType)); } else if (_tcsicmp(TableWC[i].TabQua,_T("NULL")) == 0) { TableWC[i].TabQua = NULL; NullValue = 1; if (TableWC[i].changedSchema == -1) returncode = SQLTables(hstmt,NULL,0,(SQLTCHAR*)TableWC[i].TabOwner,(SWORD)_tcslen(TableWC[i].TabOwner),(SQLTCHAR*)removeQuotes(TableWC[i].TabName,displayBuf.tab),(SWORD)_tcslen(displayBuf.tab),(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType)); else returncode = SQLTables(hstmt,NULL,0,(SQLTCHAR*)schemaList[TableWC[i].changedSchema],(SWORD)_tcslen(schemaList[TableWC[i].changedSchema]),(SQLTCHAR*)removeQuotes(TableWC[i].TabName,displayBuf.tab),(SWORD)_tcslen(displayBuf.tab),(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType)); } else { if (TableWC[i].changedSchema == -1) returncode = SQLTables(hstmt,(SQLTCHAR*)TableWC[i].TabQua,(SWORD)_tcslen(TableWC[i].TabQua),(SQLTCHAR*)TableWC[i].TabOwner,(SWORD)_tcslen(TableWC[i].TabOwner),(SQLTCHAR*)removeQuotes(TableWC[i].TabName,displayBuf.tab),(SWORD)_tcslen(displayBuf.tab),(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType)); else returncode = SQLTables(hstmt,(SQLTCHAR*)TableWC[i].TabQua,(SWORD)_tcslen(TableWC[i].TabQua),(SQLTCHAR*)schemaList[TableWC[i].changedSchema],(SWORD)_tcslen(schemaList[TableWC[i].changedSchema]),(SQLTCHAR*)removeQuotes(TableWC[i].TabName,displayBuf.tab),(SWORD)_tcslen(displayBuf.tab),(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType)); } if(!CHECKRC(SQL_SUCCESS,returncode,"SQLTables")) { TEST_FAILED; LogAllErrors(henv,hdbc,hstmt); } else { LogMsg(NONE,_T("Call to SQLTables() executed successfully.\n")); _tcscpy(oTableQualifier,_T("")); _tcscpy(oTableOwner,_T("")); _tcscpy(oTableName,_T("")); _tcscpy(oTableType,_T("")); _tcscpy(oRemark,_T("")); returncode=SQLBindCol(hstmt,1,SQL_C_TCHAR,oTableQualifier,NAME_LEN,&oTableQualifierlen); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } returncode=SQLBindCol(hstmt,2,SQL_C_TCHAR,oTableOwner,NAME_LEN,&oTableOwnerlen); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } returncode=SQLBindCol(hstmt,3,SQL_C_TCHAR,oTableName,NAME_LEN,&oTableNamelen); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } returncode=SQLBindCol(hstmt,4,SQL_C_TCHAR,oTableType,NAME_LEN,&oTableTypelen); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } returncode=SQLBindCol(hstmt,5,SQL_C_TCHAR,oRemark,NAME_LEN,&oRemarklen); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } k = 0; while (returncode == SQL_SUCCESS) { returncode = SQLFetch(hstmt); if((returncode!=SQL_NO_DATA_FOUND) && (!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } if (returncode == SQL_SUCCESS) k++; } if(k == 0) { TEST_FAILED; LogMsg(ERRMSG,_T("No Data Found => Atleast one row should be fetched\n")); } else { LogMsg(NONE, _T("Number of rows fetched: %d\n"), k); } } SQLFreeStmt(hstmt,SQL_CLOSE); i++; TESTCASE_END; } free(TableStr); } //========================================================================================= TESTCASE_BEGIN("SQLTables: Negative test with NULL handle.\n"); hstmt1 = (SQLHANDLE)NULL; i = 0; returncode = SQLTables(hstmt1,(SQLTCHAR*)TableWC[i].TabQua,(SWORD)_tcslen(TableWC[i].TabQua),(SQLTCHAR*)TableWC[i].TabOwner,(SWORD)_tcslen(TableWC[i].TabOwner),(SQLTCHAR*)TableWC[i].TabName,(SWORD)_tcslen(TableWC[i].TabName),(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType)); if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLTables")) { TEST_FAILED; LogAllErrors(henv,hdbc,hstmt); } TESTCASE_END; //========================================================================================= TESTCASE_BEGIN("SQLTables: Negative test with invalid arg lengths.\n"); i = 0; while (_tcsicmp(TableWC2[i].TabQua,_T("endloop")) != 0) { returncode = SQLTables(hstmt,(SQLTCHAR*)TableWC2[i].TabQua,TableWC2[i].TabQuaLen,(SQLTCHAR*)TableWC2[i].TabOwner,TableWC2[i].TabOwnerLen,(SQLTCHAR*)TableWC2[i].TabName,TableWC2[i].TabNameLen,(SQLTCHAR*)TableWC2[i].TabType,TableWC2[i].TabTypeLen); if(!CHECKRC(SQL_ERROR,returncode,"SQLTables")) { TEST_FAILED; LogAllErrors(henv,hdbc,hstmt); } i++; } TESTCASE_END; //========================================================================================= TESTCASE_BEGIN("Testing SQLColAttribute, SQLDescribeCol, SQLBindCol and SQLFetch functions for catalog names.\n"); if(isCharSet) { returncode = SQLSetStmtAttr(hstmt,SQL_ATTR_METADATA_ID,(SQLPOINTER)SQL_FALSE,0); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetStmtAttr(SQL_ATTR_METADATA_ID")) { TEST_FAILED; LogAllErrors(henv,hdbc,hstmt); } } for(i = 0; i < 5; i++) { returncode = SQLTables(hstmt,(SQLTCHAR*)TableWC[i].TabQua,(SWORD)_tcslen(TableWC[i].TabQua),(SQLTCHAR*)TableWC[i].TabOwner,(SWORD)_tcslen(TableWC[i].TabOwner),(SQLTCHAR*)TableWC[i].TabName,(SWORD)_tcslen(TableWC[i].TabName),(SQLTCHAR*)TableWC[i].TabType,(SWORD)_tcslen(TableWC[i].TabType)); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLColumns")) { TEST_FAILED; LogAllErrors(henv,hdbc,hstmt); } returncode = SQLNumResultCols(hstmt, &numOfCols); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultsCol")) { TEST_FAILED; LogMsg(ERRMSG,_T("Test failed while executing call for SQLNUMRESULTSCOL")); LogAllErrors(henv,hdbc,hstmt); } for(cols = 0; cols < numOfCols; cols++) { returncode = SQLDescribeCol(hstmt,(SWORD)(cols+1),(SQLTCHAR*)cn,TabType_LEN,&cl,&st,&cp,&cs,&cnull); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLDescribeCol")) { TEST_FAILED; LogMsg(ERRMSG,_T("Test failed while executing call for SQLDESCRIBECOL of column")); LogAllErrors(henv,hdbc,hstmt); } CharOutput[cols] = (TCHAR *)malloc(STR_LEN); for (iatt = 0; iatt <= TOTALATTRIBS; iatt++) { _tcscpy(rgbDesc,_T("")); pcbDesc = 0; pfDesc = 0; returncode = SQLColAttributes(hstmt,(SWORD)(cols+1),DescrType[iatt],(SQLTCHAR*)rgbDesc,STR_LEN,&pcbDesc,&pfDesc); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLColAttribute")) { TEST_FAILED; LogAllErrors(henv,hdbc,hstmt); } } returncode = SQLBindCol(hstmt,(SWORD)(cols+1),SQL_C_TCHAR,(SQLTCHAR*)CharOutput[cols],STR_LEN,&stringlength); if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")) { TEST_FAILED; LogMsg(ERRMSG,_T("Test failed while executing call for SQLBindCols of column : %d.\n"),cols); LogAllErrors(henv,hdbc,hstmt); } } k = 0; while (returncode == SQL_SUCCESS) { returncode = SQLFetch(hstmt); if((returncode!=SQL_NO_DATA_FOUND) && (!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))) { LogAllErrors(henv,hdbc,hstmt); TEST_FAILED; } if (returncode == SQL_SUCCESS) k++; } if(k == 0) { _stprintf(Heading,_T("\n TableQualifier: %s\n TableOwner: %s\n TableName: %s\n TableType: %s\n"), printSymbol(TableWC[i].TabQua,displayBuf.cat), printSymbol(TableWC[i].TabOwner,displayBuf.sch), printSymbol(TableWC[i].TabName,displayBuf.tab), printSymbol(TableWC[i].TabType,displayBuf.typ)); LogMsg(NONE,Heading); TEST_FAILED; LogMsg(ERRMSG,_T("No Data Found => Atleast one row should be fetched\n")); } else { LogMsg(NONE, _T("Number of rows fetched: %d\n"), k); } for(cols = 0; cols < numOfCols; cols++) { free(CharOutput[cols]); } TESTCASE_END; } // Clean up SQLExecDirect(hstmt,(SQLTCHAR*)DrpTab[0],SQL_NTS); SQLExecDirect(hstmt,(SQLTCHAR*)DrpTab[1],SQL_NTS); SQLExecDirect(hstmt,(SQLTCHAR*)DrpTab[2],SQL_NTS); //========================================================================================= FullDisconnect(pTestInfo); LogMsg(SHORTTIMESTAMP+LINEAFTER,_T("End testing API => SQLTables.\n")); free_list(var_list); TEST_RETURN; }