Exemplo n.º 1
0
/*
---------------------------------------------------------
   TestSQLNumResultsCol
---------------------------------------------------------
*/
PassFail TestSQLNumResultCols(TestInfo *pTestInfo)
{                  
	TEST_DECLARE;
  	TCHAR			Heading[MAX_STRING_SIZE];
	RETCODE			returncode;
	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt;
	SWORD			col;
	TCHAR			*ExecDirStr[] = {_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--")};
	TCHAR			*TestCase[] = {
						_T("after preparing stmt "),
						_T("after preparing & executing stmt "),
						_T("after preparing, executing & fetching stmt "),
						_T("after execdirect stmt "),
						_T("after execdirect & fetching stmt "),
						_T("after preparing param stmt "),
						_T("after preparing & binding stmt "),
						_T("after preparing, binding & executing stmt "),
						_T("after preparing, binding, executing & fetching stmt ")
					};
	int				lend = 9, iend = 5;
	SQLUSMALLINT	i = 0, l = 0;
	int				expcol[] = {1,2,6,9,2};
	SQLLEN			cbIn = SQL_NTS;

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars(_T("SQLNumResultCols"), charset_file);
	if (var_list == NULL) return FAILED;

	ExecDirStr[0] = var_mapping(_T("SQLNumResultCols_ExecDirStr_0"), var_list);
	ExecDirStr[1] = var_mapping(_T("SQLNumResultCols_ExecDirStr_1"), var_list);
	ExecDirStr[2] = var_mapping(_T("SQLNumResultCols_ExecDirStr_2"), var_list);
	ExecDirStr[3] = var_mapping(_T("SQLNumResultCols_ExecDirStr_3"), var_list);
	ExecDirStr[4] = var_mapping(_T("SQLNumResultCols_ExecDirStr_4"), var_list);
	ExecDirStr[5] = var_mapping(_T("SQLNumResultCols_ExecDirStr_5"), var_list);
	ExecDirStr[6] = var_mapping(_T("SQLNumResultCols_ExecDirStr_6"), var_list);
	ExecDirStr[7] = var_mapping(_T("SQLNumResultCols_ExecDirStr_7"), var_list);
	ExecDirStr[8] = var_mapping(_T("SQLNumResultCols_ExecDirStr_8"), var_list);
	ExecDirStr[9] = var_mapping(_T("SQLNumResultCols_ExecDirStr_9"), var_list);
	ExecDirStr[10] = var_mapping(_T("SQLNumResultCols_ExecDirStr_10"), var_list);
	ExecDirStr[11] = var_mapping(_T("SQLNumResultCols_ExecDirStr_11"), var_list);
	ExecDirStr[12] = var_mapping(_T("SQLNumResultCols_ExecDirStr_12"), var_list);
	ExecDirStr[13] = var_mapping(_T("SQLNumResultCols_ExecDirStr_13"), var_list);
	ExecDirStr[14] = var_mapping(_T("SQLNumResultCols_ExecDirStr_14"), var_list);
	ExecDirStr[15] = var_mapping(_T("SQLNumResultCols_ExecDirStr_15"), var_list);
	ExecDirStr[16] = var_mapping(_T("SQLNumResultCols_ExecDirStr_16"), var_list);
	ExecDirStr[17] = var_mapping(_T("SQLNumResultCols_ExecDirStr_17"), var_list);
	ExecDirStr[18] = var_mapping(_T("SQLNumResultCols_ExecDirStr_18"), var_list);
	ExecDirStr[19] = var_mapping(_T("SQLNumResultCols_ExecDirStr_19"), var_list);

//===========================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API =>SQLNumResultcols.\n"));

	TEST_INIT;
	   
	TESTCASE_BEGIN("Setup for SQLNumResultCols 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("Test Positive Functionality of SQLNumResultCols "));
			_tcscat(Heading, TestCase[l]);
			_tcscat(Heading, ExecDirStr[i+iend+iend+iend]);
			_tcscat(Heading, _T("\n"));
			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 */
				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{
						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, &col);
							if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultCols")){
								LogAllErrors(henv,hdbc,hstmt);
								TEST_FAILED;
								}
							if (col == expcol[i])
								{
									LogMsg(NONE,_T("expect: %d and actual: %d are matched\n"),expcol[i], col);
								}	
							else
								{
									TEST_FAILED;	
									LogMsg(NONE,_T("expect: %d and actual: %d are not matched\n"),expcol[i], col);
								}
							}
							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 */
				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{
						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_INTEGER,0,0,(SQLPOINTER)_T("10"),300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindparameter")){
										LogAllErrors(henv,hdbc,hstmt);
										TEST_FAILED;
										}
									else{
										returncode = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_TCHAR,SQL_INTEGER,0,0,(SQLPOINTER)_T("20"),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_INTEGER,0,0,(SQLPOINTER)_T("10"),300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindparameter")){
										LogAllErrors(henv,hdbc,hstmt);
										TEST_FAILED;
										}
									else{
										returncode = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_TCHAR,SQL_INTEGER,0,0,(SQLPOINTER)_T("20"),300,&cbIn);
										if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter")){
											LogAllErrors(henv,hdbc,hstmt);
											TEST_FAILED;
											}
										else{
											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_INTEGER,0,0,(SQLPOINTER)_T("10"),300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindparameter")){
										LogAllErrors(henv,hdbc,hstmt);
										TEST_FAILED;
										}
									else{
										returncode = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_TCHAR,SQL_INTEGER,0,0,(SQLPOINTER)_T("20"),300,&cbIn);
										if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter")){
											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;
							}
						if (returncode == SQL_SUCCESS){
								returncode = SQLNumResultCols(hstmt, &col);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultCols"))
								{
									TEST_FAILED;
									LogAllErrors(henv,hdbc,hstmt);
								}
								if (col == expcol[i])
								{
									LogMsg(NONE,_T("expect: %d and actual: %d are matched\n"),expcol[i], col);
								}	
								else
								{
									TEST_FAILED;	
									LogMsg(NONE,_T("expect: %d and actual: %d are not matched\n"),expcol[i], col);
								}
							}
							SQLFreeStmt(hstmt,SQL_CLOSE);
							SQLExecDirect(hstmt,(SQLTCHAR*) ExecDirStr[i],SQL_NTS); /* cleanup */
						}
					}
				}
			TESTCASE_END;
			} /* iend loop */
		} /* lend loop */
	FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,_T("End testing API => SQLNumResultcols.\n"));
	free_list(var_list);
	TEST_RETURN;
}
Exemplo n.º 2
0
PassFail TestSQLPrepare(TestInfo *pTestInfo)
{   
	TEST_DECLARE;

 	char			Heading[MAX_STRING_SIZE];
 	RETCODE			returncode;
 	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt;
	CHAR			*PrepStr[6];

	CHAR			*szInput[] = {"Insert char","Insert varchar"};
	SQLLEN	cbInput = SQL_NTS;
	SQLUSMALLINT	i;
	SQLSMALLINT	Type[] = {SQL_CHAR,SQL_VARCHAR};

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars("SQLPrepare", charset_file);
	if (var_list == NULL) return FAILED;

	PrepStr[0] = var_mapping("SQLPrepare_PrepStr_0", var_list);
	PrepStr[1] = var_mapping("SQLPrepare_PrepStr_1", var_list);
	PrepStr[2] = var_mapping("SQLPrepare_PrepStr_2", var_list);
	PrepStr[3] = var_mapping("SQLPrepare_PrepStr_3", var_list);
	PrepStr[4] = var_mapping("SQLPrepare_PrepStr_4", var_list);
	PrepStr[5] = var_mapping("SQLPrepare_PrepStr_5", var_list);
//===========================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API =>SQLPrepare | SQLPrepare | prepare.c\n");

	TEST_INIT;

	TESTCASE_BEGIN("Setup for SQLPrepare tests\n");

	if(!FullConnect(pTestInfo)){
		LogMsg(NONE,"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

	TESTCASE_BEGIN("Test Positive Functionality of SQLPrepare/SQLExecute\n");
	returncode=SQLExecDirect(hstmt,(SQLCHAR*)PrepStr[0],strlen(PrepStr[0])); /* cleanup */
	returncode = SQLPrepare(hstmt,(SQLCHAR*)PrepStr[1],strlen(PrepStr[1]));
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	else
	{
		returncode = SQLExecute(hstmt); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
	}	
	TESTCASE_END;

	sprintf(Heading,"Test Positive Functionality of SQLPrepare/SQLExecute with SQL_NTS\n");
	TESTCASE_BEGIN(Heading);
	returncode=SQLExecDirect(hstmt,(SQLCHAR*)PrepStr[0],SQL_NTS);	/* cleanup */
	returncode = SQLPrepare(hstmt,(SQLCHAR*)PrepStr[1],SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	else
	{
		returncode = SQLExecute(hstmt); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
	}	
	TESTCASE_END;

	sprintf(Heading,"Test Positive Functionality of SQLPrepare then SQLExecute twice\n");
	TESTCASE_BEGIN(Heading);
	returncode = SQLPrepare(hstmt,(SQLCHAR*)PrepStr[2],strlen(PrepStr[2]));
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	else
	{
		returncode = SQLExecute(hstmt); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		returncode = SQLExecute(hstmt); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
	}	
	SQLExecDirect(hstmt,(SQLCHAR*)PrepStr[0],strlen(PrepStr[0])); /* cleanup */
	TESTCASE_END;
		
	sprintf(Heading,"Test Positive Functionality of SQLPrepare with params\n");
	TESTCASE_BEGIN(Heading);
	SQLExecDirect(hstmt,(SQLCHAR*)PrepStr[3],SQL_NTS); /* cleanup */
	returncode = SQLPrepare(hstmt,(SQLCHAR*)PrepStr[4],SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	else
	{
		for (i = 0; i <= 1; i++)
		{
			returncode = SQLBindParameter(hstmt,(SWORD)(i+1),SQL_PARAM_INPUT,SQL_C_CHAR,Type[i],PREP_LEN,0,szInput[i],0,&cbInput);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
			}
		}
		returncode = SQLExecute(hstmt); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
	}	
	SQLExecDirect(hstmt,(SQLCHAR*)PrepStr[3],SQL_NTS); /* cleanup */
	TESTCASE_END;

	sprintf(Heading,"Test negative Functionality of SQLPrepare with strlen less than sqlstr\n");
	TESTCASE_BEGIN(Heading);
	SQLExecDirect(hstmt,(SQLCHAR*)PrepStr[0],SQL_NTS); /* cleanup */
	returncode = SQLPrepare(hstmt,(SQLCHAR*)PrepStr[1],(strlen(PrepStr[1])-5));
	if(!CHECKRC(SQL_ERROR,returncode,"SQLPrepare"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	TESTCASE_END;

	sprintf(Heading,"Test negative Functionality of SQLPrepare with invalid sqlstr\n");
	TESTCASE_BEGIN(Heading);
	returncode = SQLPrepare(hstmt,NULL,strlen(PrepStr[2]));
	if(!CHECKRC(SQL_ERROR,returncode,"SQLPrepare"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	TESTCASE_END;

	sprintf(Heading,"Test negative Functionality of SQLPrepare with invalid handle\n");
	TESTCASE_BEGIN(Heading);
	returncode = SQLPrepare((SQLHANDLE)NULL,(SQLCHAR*)PrepStr[2],strlen(PrepStr[2]));
	if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLPrepare"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	TESTCASE_END;

	FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => SQLPrepare.\n");

	free_list(var_list);

	TEST_RETURN;
}
Exemplo n.º 3
0
/*
---------------------------------------------------------
   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;
}
Exemplo n.º 4
0
PassFail TestSQLDescribeParam(TestInfo *pTestInfo, int MX_MP_SPECIFIC)
{                  
	TEST_DECLARE;
 	char			Heading[MAX_STRING_SIZE];
	RETCODE			returncode;
	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt;
	SWORD			numparam;
	UWORD			icol;

	SWORD		st, 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_BIGINT,SQL_LONGVARCHAR,
								SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC
																												
							};										// SQL_DOUBLE for SQL_FLOAT MX limitation
																	//SQL_BIGINT replaced by SQL_NUMERIC in MX
	SWORD		MPSQLType[] = 
							{
								SQL_CHAR,SQL_VARCHAR,SQL_DECIMAL,SQL_NUMERIC,SQL_SMALLINT,SQL_INTEGER,SQL_REAL,
								SQL_FLOAT,SQL_FLOAT,SQL_DATE,SQL_TIME,SQL_TIMESTAMP,SQL_BIGINT,SQL_LONGVARCHAR,
								SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC
							};						
    SQLULEN cp; 
	SQLULEN		ColPrec[] = {10,10,10,10,5,10,7,15,15,10,8,26,19,2000,19,19,128,128,128,10,18,30};
    SQLULEN		MPColPrec[] = {10,10,10,10,5,10,7,15,15,10,8,26,19,10,19,19,128,128,128,10,18,30};	
	SWORD		cs, cnull, ColScale[] = {0,0,5,5,0,0,0,0,0,0,0,6,0,0,0,6,0,128,64,5,5,10};

	CHAR		*DropStr[] = {"--","--","endloop"};
	CHAR		*CrtStr[] = {"--", "--", "endloop"};
	CHAR		*MPCrtStr[] = {"--", "--", "endloop"};
	CHAR		*ExecDirStr[] = {"--","--","--","--","--","--","--","--","--","--","endloop"};

	char		TempType1[50],TempType2[50];
	SWORD		ColNullable[] = {SQL_NULLABLE,SQL_NO_NULLS,SQL_NULLABLE,SQL_NO_NULLS,SQL_NULLABLE,SQL_NO_NULLS,SQL_NULLABLE,SQL_NO_NULLS,SQL_NULLABLE,SQL_NO_NULLS};

	CHAR		*TestCase[] = 
						{
							"before preparing stmt ",
							"endloop"
						};

	SQLUSMALLINT i = 0, l = 0;

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars("SQLDescribeParam", charset_file);
	if (var_list == NULL) return FAILED;

//=====================Modified for Longvarchar Changes========================================================
	if(!pTestInfo->bLongOn)
	{
		int i = 0;
		char *noLong = "SQL_VARCHAR"; 
		SWORD iNoLong = SQL_VARCHAR;

		SQLType[13] = iNoLong;
		MPSQLType[13] = iNoLong;
	}
//=====================Modified for Longvarchar Changes========================================================


	//print_list(var_list);
	DropStr[0] = var_mapping("SQLDescribeParam_DropStr_1", var_list);
	DropStr[1] = var_mapping("SQLDescribeParam_DropStr_2", var_list);

	CrtStr[0] = var_mapping("SQLDescribeParam_CrtStr_1", var_list);
	CrtStr[1] = var_mapping("SQLDescribeParam_CrtStr_2", var_list);

	MPCrtStr[0] = var_mapping("SQLDescribeParam_MPCrtStr_1", var_list);
	MPCrtStr[1] = var_mapping("SQLDescribeParam_MPCrtStr_2", var_list);

	ExecDirStr[0] = var_mapping("SQLDescribeParam_ExecDirStr_1", var_list);
	ExecDirStr[1] = var_mapping("SQLDescribeParam_ExecDirStr_2", var_list);
	ExecDirStr[2] = var_mapping("SQLDescribeParam_ExecDirStr_3", var_list);
	ExecDirStr[3] = var_mapping("SQLDescribeParam_ExecDirStr_4", var_list);
	ExecDirStr[4] = var_mapping("SQLDescribeParam_ExecDirStr_5", var_list);
	ExecDirStr[5] = var_mapping("SQLDescribeParam_ExecDirStr_6", var_list);
	ExecDirStr[6] = var_mapping("SQLDescribeParam_ExecDirStr_7", var_list);
	ExecDirStr[7] = var_mapping("SQLDescribeParam_ExecDirStr_8", var_list);
	ExecDirStr[8] = var_mapping("SQLDescribeParam_ExecDirStr_9", var_list);
	ExecDirStr[9] = var_mapping("SQLDescribeParam_ExecDirStr_10", var_list);

//=================================================================================================

	if(isUCS2) {
		LogMsg(NONE,"Setup for UCS2 mode testing: ColPrec has to be doubled\n");

		l = sizeof(SQLType)/sizeof(SQLType[0]);
		while(i < l) {
			if(SQLType[i] == SQL_CHAR) {
				//SQLType[i] = SQL_WCHAR;
				ColPrec[i] *= 2;  //--> This is in character, so no need to double
			}
			else if (SQLType[i] == SQL_VARCHAR) {
				//SQLType[i] = SQL_WVARCHAR;
				ColPrec[i] *= 2;  //--> This is in character, so no need to double
			}
			else if (SQLType[i] == SQL_LONGVARCHAR)	{
				//SQLType[i] = SQL_WLONGVARCHAR;
				ColPrec[i] *= 2;  //--> This is in character, so no need to double
			}
			else {
			}

			i++;
		}
		i = 0;

		l = sizeof(MPSQLType)/sizeof(MPSQLType[0]);
		while(i < l) {
			if(MPSQLType[i] == SQL_CHAR) {
		        //MPSQLType[i] = SQL_WCHAR;
				MPColPrec[i] *= 2;  //--> This is in character, so no need to double
			}
			else if (MPSQLType[i] == SQL_VARCHAR) {
				//MPSQLType[i] = SQL_WVARCHAR;
				MPColPrec[i] *= 2;  //--> This is in character, so no need to double
			}
			else if (MPSQLType[i] == SQL_LONGVARCHAR)	{
				//MPSQLType[i] = SQL_WLONGVARCHAR;
				MPColPrec[i] *= 2;  //--> This is in character, so no need to double
			}
			else {
			}
			i++;
		}
		i = 0;
		l = 0;
	}

//===========================================================================================================

    if (MX_MP_SPECIFIC == MX_SPECIFIC)
        LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API => MX Specific SQLDescribeParam | SQLDescribeParam | desparam.c\n");
    else
        LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API => MP Specific SQLDescribeParam | SQLDescribeParam | desparam.c\n");

	TEST_INIT;
	   
	TESTCASE_BEGIN("Setup for SQLDescribeParam tests\n");

	if(!FullConnect(pTestInfo)){
		LogMsg(NONE,"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;
	}

	i = 0;
	while (_stricmp(DropStr[i],"endloop") != 0)
	{
		SQLExecDirect(hstmt,(SQLCHAR*)DropStr[i],SQL_NTS); /* cleanup */
		i++;
	}
	i = 0;
	if (MX_MP_SPECIFIC == MX_SPECIFIC)
	{
		while (_stricmp(CrtStr[i],"endloop") != 0)
		{
			returncode = SQLExecDirect(hstmt,(SQLCHAR*)CrtStr[i],SQL_NTS); /* create table */
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				TEST_RETURN;
			}
			//LogMsg(NONE,"%s\n",	CrtStr[i]);
			i++;
		}
	}
	else
	{
		while (_stricmp(MPCrtStr[i],"endloop") != 0)
		{
			returncode = SQLExecDirect(hstmt,(SQLCHAR*)MPCrtStr[i],SQL_NTS); /* create table */
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				TEST_RETURN;
			}
			//LogMsg(NONE,"%s\n",	MPCrtStr[i]);
			i++;
		}
	}
	TESTCASE_END;  // end of setup

	l = 0;
	while (_stricmp(TestCase[l],"endloop") != 0)
	{
		i = 0;
		while (_stricmp(ExecDirStr[i],"endloop") != 0)
		{
			//==================================================================================
			sprintf(Heading,"SQLDescribeParam: Test #%d.%d\n",l,i);
			TESTCASE_BEGIN(Heading);
			returncode = SQLPrepare(hstmt,(SQLCHAR*)ExecDirStr[i], SQL_NTS);
			//LogMsg(NONE,"%s\n", ExecDirStr[i]);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			}
			else
			{
				returncode=SQLNumParams(hstmt, &numparam);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultCols"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				//LogMsg(NONE,"SQLNumParams returns %d\n", numparam);
				for (icol = 1; icol <= numparam; icol++)
				{
					LogMsg(LINEBEFORE,"SQLDescribeParam: checking Column #%d\n",icol);
					returncode = SQLDescribeParam(hstmt,icol,&st,&cp,&cs,&cnull);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLDescribeParam"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt);
					}
					if (MX_MP_SPECIFIC == MX_SPECIFIC)
					{
						if ((st==SQLType[icol-1]) && (cp==ColPrec[icol-1]) && (cs==ColScale[icol-1]) && (cnull==ColNullable[i]))
						{
							//LogMsg(NONE,"SQLType expect: %s and actual: %s are matched\n",
							//	SQLTypeToChar(SQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2));
							//LogMsg(NONE,"ColPrec expect: %d and actual: %d are matched\n",ColPrec[icol-1],cp);
							//LogMsg(NONE,"ColScale expect: %d and actual: %d are matched\n",ColScale[icol-1],cs);
							//LogMsg(NONE,"ColNullable expect: %s and actual: %s are matched\n\n",
							//	SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2));
						}	
						else
						{
							TEST_FAILED;	
							if (st != SQLType[icol-1])
								LogMsg(ERRMSG,"SQLType expect: %s and actual: %s are not matched\n",SQLTypeToChar(SQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2));
							if (cp != ColPrec[icol-1])
								LogMsg(ERRMSG,"ColPrec expect: %d and actual: %d are not matched\n",ColPrec[icol-1],cp);
							if (cs != ColScale[icol-1])
								LogMsg(ERRMSG,"ColScale expect: %d and actual: %d are not matched\n",ColScale[icol-1],cs);
							if (cnull != ColNullable[i])
								LogMsg(ERRMSG,"ColNullable expect: %s and actual: %s are not matched\n\n",SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2));
						}
					}
					else
					{
						if ((st==MPSQLType[icol-1]) && (cp==MPColPrec[icol-1]) && (cs==ColScale[icol-1]) && (cnull==ColNullable[i]))
						{
							//LogMsg(NONE,"SQLType expect: %s and actual: %s are matched\n",
							//	SQLTypeToChar(MPSQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2));
							//LogMsg(NONE,"ColPrec expect: %d and actual: %d are matched\n",MPColPrec[icol-1],cp);
							//LogMsg(NONE,"ColScale expect: %d and actual: %d are matched\n",ColScale[icol-1],cs);
							//LogMsg(NONE,"ColNullable expect: %s and actual: %s are matched\n\n",
							//	SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2));
						}	
						else
						{
							TEST_FAILED;	
							if (st != MPSQLType[icol-1])
								LogMsg(ERRMSG,"SQLType expect: %s and actual: %s are not matched\n",SQLTypeToChar(MPSQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2));
							if (cp != MPColPrec[icol-1])
								LogMsg(ERRMSG,"ColPrec expect: %d and actual: %d are not matched\n",MPColPrec[icol-1],cp);
							if (cs != ColScale[icol-1])
								LogMsg(ERRMSG,"ColScale expect: %d and actual: %d are not matched\n",ColScale[icol-1],cs);
							if (cnull != ColNullable[i])
								LogMsg(ERRMSG,"ColNullable expect: %s and actual: %s are not matched\n\n",SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2));
						}
					}
				} /* end icol loop */
			}
			SQLFreeStmt(hstmt,SQL_CLOSE);
			i++;
			TESTCASE_END;
		}
		l++;
	}

	i = 0;
	while (_stricmp(DropStr[i],"endloop") != 0)
	{
		SQLExecDirect(hstmt,(SQLCHAR*)DropStr[i],SQL_NTS); /* cleanup */
		i++;
	}

	FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => MX Specific SQLDescribeParam.\n");
	free_list(var_list);
	TEST_RETURN;
}
Exemplo n.º 5
0
		#ifndef _WM
			{_T("0.12345678901234567890000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),_T("123.456780"),_T("1234567899"),_T("1234.567899"),_T("0.1234567890"),_T("1234.6789012345"),_T("1234567890123456"),_T("12345678.012345600"),_T("0.123456789012345670"),_T("12.12345678901234567800")}},
        #else
			{_T(".12345678901234567890000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),_T("123.456780"),_T("1234567899"),_T("1234.567899"),_T(".1234567890"),_T("1234.6789012345"),_T("1234567890123456"),_T("12345678.012345600"),_T(".123456789012345670"),_T("12.12345678901234567800")}},
        #endif
		{6, _T("--"),{ld_input,ld_input_half,ld_input,ld_input_half,datastr2_input,datastr2_input},_T("--"),{ld_output,datastr3_output,datastr3_output,datastr3_output,datastr3_output,datastr3_output}},
		{6, _T("--"),{ld_input,ld_input_half,ld_input,ld_input_half,datastr2_input,datastr2_input},_T("--"),{ld_output,ld_output_half,datastr4_output,ld_output_half,datastr4_output,datastr2_output}},
		{6, _T("--"),{ld_input,ld_input_half,ld_input,ld_input_half,datastr2_input,datastr2_input},_T("--"),{ld_output,datastr3_output,ld_output,datastr3_output,datastr2_output,datastr3_output}},
//#endif
		{9999}
	};

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars(_T("LargeBlock"), charset_file);
	if (var_list == NULL) return FAILED;

	DrpTable = var_mapping(_T("LargeBlock_DrpTable"), var_list);
	CrtTable = var_mapping(_T("LargeBlock_CrtTable"), var_list);
	InsTable = var_mapping(_T("LargeBlock_InsTable"), var_list);
	SelTable = var_mapping(_T("LargeBlock_SelTable"), var_list);
	UpdTable = var_mapping(_T("LargeBlock_UpdTable"), var_list);
	DelTable = var_mapping(_T("LargeBlock_DelTable"), var_list);
	
	if(isUCS2) {
		_stprintf(keysize, _T("%d"), MAX_SIZE_KEY_UCS2);
	} else {
		_stprintf(keysize, _T("%d"), MAX_SIZE_KEY);
	}
Exemplo n.º 6
0
/*
---------------------------------------------------------
   TestSQLEndTran
---------------------------------------------------------
*/
PassFail TestMXSQLEndTran(TestInfo *pTestInfo)
{                  
	TEST_DECLARE;
	RETCODE			returncode;
	TCHAR			Heading[MAX_STRING_SIZE];
	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt;
	TCHAR			*ExecDirStr[] = 
							{
								//"create table testtransact(c1 TCHAR(20),c2 integer)",
								//"create table testtransact(c1 TCHAR(20),c2 integer) NO PARTITION",
                                // The  NO PARTITION is to help speed up this test on NEO/clustered systems with POS turned on.
								_T("--"),
								_T("--"),
								_T("--"),
								_T("--"),
								_T("--"),
								_T("--")
							};
	UWORD			fType[] = { SQL_ROLLBACK, SQL_COMMIT };
	TCHAR			*TypeDesc[] = { _T("SQL_ROLLBACK"), _T("SQL_COMMIT") };
	TCHAR			*Output;
	SQLLEN			OutputLen; // sushil
	struct
	{
		SWORD	ExeRes[2];
		SWORD	FetchRes[2];
		TCHAR	*DataRes[2];
	} CheckRes[] =	{
						{SQL_ERROR,SQL_SUCCESS,SQL_NO_DATA_FOUND,SQL_NO_DATA_FOUND,_T(""),_T("")},
						{SQL_SUCCESS,SQL_SUCCESS,SQL_NO_DATA_FOUND,SQL_SUCCESS,_T(""),_T("--")},
						{SQL_SUCCESS,SQL_SUCCESS,SQL_SUCCESS,SQL_SUCCESS,_T("--"),_T("--")},
						{SQL_SUCCESS,SQL_SUCCESS,SQL_SUCCESS,SQL_NO_DATA_FOUND,_T("--"),_T("")},
						{SQL_SUCCESS,SQL_ERROR,SQL_NO_DATA_FOUND,SQL_NO_DATA_FOUND,_T(""),_T("")}
					};
	int	i = 0, j = 0, iend = 5, jend = 1, commit_on_off = 0;

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars(_T("SQLEndTran"), charset_file);
	if (var_list == NULL) return FAILED;

	ExecDirStr[0] = var_mapping(_T("SQLEndTran_ExecDirStr_0"), var_list);
	ExecDirStr[1] = var_mapping(_T("SQLEndTran_ExecDirStr_1"), var_list);
	ExecDirStr[2] = var_mapping(_T("SQLEndTran_ExecDirStr_2"), var_list);
	ExecDirStr[3] = var_mapping(_T("SQLEndTran_ExecDirStr_3"), var_list);
	ExecDirStr[4] = var_mapping(_T("SQLEndTran_ExecDirStr_4"), var_list);
	ExecDirStr[5] = var_mapping(_T("SQLEndTran_ExecDirStr_5"), var_list);

	CheckRes[1].DataRes[1] = var_mapping(_T("SQLEndTran_Insert"), var_list);
	CheckRes[2].DataRes[0] = var_mapping(_T("SQLEndTran_Insert"), var_list);
	CheckRes[2].DataRes[1] = var_mapping(_T("SQLEndTran_Update"), var_list);
	CheckRes[3].DataRes[0] = var_mapping(_T("SQLEndTran_Update"), var_list);

//========================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API => SQLEndTran.\n"));
	TEST_INIT;

	TESTCASE_BEGIN("Initializing SQLEndTran test environment\n");
	if(!FullConnectWithOptions(pTestInfo, CONNECT_ODBC_VERSION_3))
	{
		LogMsg(NONE,_T("Unable to connect\n"));
		TEST_FAILED;
		TEST_RETURN;
	}
	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
	returncode = SQLAllocHandle(SQL_HANDLE_STMT, (SQLHANDLE)hdbc, &hstmt);	
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocHandle"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		FullDisconnect(pTestInfo);
		TEST_FAILED;
		TEST_RETURN;
	}
	//setting CQD to set POS OFF,as some tests fail otherwise. (to be fixed)
	//SQLExecDirect (hstmt,"CONTROL QUERY DEFAULT POS 'OFF'",SQL_NTS);

	for (commit_on_off = 0; commit_on_off < 10; commit_on_off++)
	{
		returncode = SQLSetConnectAttr((SQLHANDLE)hdbc,SQL_AUTOCOMMIT,(void *)SQL_AUTOCOMMIT_ON,0);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetConnectAttr"))
		{
			LogAllErrorsVer3(henv,hdbc,hstmt);
			FullDisconnect(pTestInfo);
			TEST_FAILED;
			TEST_RETURN;
		}
		TESTCASE_END;
		SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[4],SQL_NTS); /* CLEANUP */
		for (i = 0; i <= (iend-1); i++)
		{
			_stprintf(Heading,_T("Test Positive Functionality of SQLEndTran while Autocommit is ON and executing\n"));
			_tcscat(Heading, ExecDirStr[i]);
			_tcscat(Heading, _T("\n"));
			TESTCASE_BEGINW(Heading);
			returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i],SQL_NTS);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrorsVer3(henv,hdbc,hstmt);
				TEST_FAILED;
			}
		}
		SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[4],SQL_NTS); /* CLEANUP */
		returncode = SQLSetConnectAttr((SQLHANDLE)hdbc,SQL_AUTOCOMMIT,(void *)SQL_AUTOCOMMIT_OFF,0);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetConnectAttr"))
		{
			LogAllErrorsVer3(henv,hdbc,hstmt);
			FullDisconnect(pTestInfo);
			TEST_FAILED;
			TEST_RETURN;
		}
		TESTCASE_END;
		
		for (i = 0; i <= (iend-1); i++)
		{
			for (j = 0; j <= jend; j++)
			{
				_stprintf(Heading,_T("Test Positive Functionality of SQLEndTran while Autocommit is OFF and executing\n"));
				_tcscat(Heading, ExecDirStr[i]);
				_tcscat(Heading, _T(" & "));
				_tcscat(Heading, TypeDesc[j]);
				_tcscat(Heading, _T("\n"));
				TESTCASE_BEGINW(Heading);
				
				returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i],SQL_NTS);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
				{
					LogAllErrorsVer3(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				else
				{
					returncode=SQLEndTran(SQL_HANDLE_DBC,(SQLHANDLE)hdbc,fType[j]);
					Sleep(2);																// tmf rollback is slower.
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLTransact"))
					{
						LogAllErrorsVer3(henv,hdbc,hstmt);
						TEST_FAILED;
					}

					returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[iend],SQL_NTS);
					if(!CHECKRC(CheckRes[i].ExeRes[j],returncode,"SQLExecDirect"))
					{
						LogAllErrorsVer3(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					else
					{
						if (returncode == SQL_SUCCESS || returncode == SQL_SUCCESS_WITH_INFO)
						{
							Output = (TCHAR *)malloc(NAME_LEN);
							returncode=SQLBindCol(hstmt,1,SQL_C_TCHAR,Output,NAME_LEN,&OutputLen);
							if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
							{
								LogAllErrorsVer3(henv,hdbc,hstmt);
								TEST_FAILED;
							}
							else
							{
								returncode = SQLFetch(hstmt);
								if(!CHECKRC(CheckRes[i].FetchRes[j],returncode,"SQLFetch"))
								{
									LogAllErrorsVer3(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									if (returncode != SQL_NO_DATA_FOUND && returncode != SQL_ERROR)
									{
										if (_tcscspn(CheckRes[i].DataRes[j],Output) == 0)
										{
											//LogMsg(NONE,_T("expect: %s and actual: %s are matched\n"),Output,CheckRes[i].DataRes[j]);
										}	
										else
										{
											LogMsg(ERRMSG,_T("expect: %s and actual: %s are not matched at line %d \n"),Output,CheckRes[i].DataRes[j],__LINE__);
											TEST_FAILED;	
										}
									}
								}
								free(Output);
								SQLFreeStmt(hstmt,SQL_CLOSE);
							}
						}
					}
				}
			//SQLFreeStmt(hstmt,SQL_CLOSE);
			TESTCASE_END;
			}/* end i loop */
		//SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[4],SQL_NTS); /* CLEANUP */
		}/* end j loop */
	}

//========================================================================================================

	SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[4],SQL_NTS); /* CLEANUP */
    
	returncode = SQLDisconnect((SQLHANDLE)hdbc);
    if(!CHECKRC(SQL_ERROR,returncode,"SQLDisconnect")) 
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		TEST_FAILED;	
	}	
	
	// Free the open transactions.
	returncode=SQLEndTran(SQL_HANDLE_DBC,(SQLHANDLE)hdbc,SQL_ROLLBACK);
	Sleep(2);	

	returncode=FullDisconnect3(pTestInfo);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFullDisconnect"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		TEST_FAILED;
	}

	LogMsg(SHORTTIMESTAMP+LINEAFTER,_T("End testing API => SQLEndTran.\n"));
	free_list(var_list);
	TEST_RETURN;
}
Exemplo n.º 7
0
/*
---------------------------------------------------------
   TestSQLExecute
---------------------------------------------------------
*/
PassFail TestSQLExecute(TestInfo *pTestInfo, int MX_MP_SPECIFIC)
{                  
	TEST_DECLARE;

 	RETCODE			returncode;
 	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt;
	TCHAR			*ExecStr[15];
	TCHAR			*szInput[] = {_T("Inst char"),_T("Inst vchar"),_T("1234.56789"),_T("1234.56789"),_T("1200"),_T("12000"),_T("123.45"),_T("123.45"),_T("123.45"),_T("1993-07-01"),_T("09:45:30"),_T("1993-08-02 08:44:31.001"),_T("120000"),_T("1234567890.56789"),_T("1234567890.456789"),_T("1234567890.456789"),_T("0.01234567890123456789"),_T("1234.56789"),_T("1234567890.56789"),_T("12345678901234567890.0123456789"),_T("Inst char"),_T("Inst vchar")};
	SQLLEN			cbInput = SQL_NTS;
	SQLUSMALLINT	i = 0;
	SQLSMALLINT		Type[] = {SQL_WCHAR,SQL_WVARCHAR,SQL_DECIMAL,SQL_NUMERIC,SQL_SMALLINT,SQL_INTEGER,SQL_REAL,SQL_FLOAT,SQL_DOUBLE,SQL_DATE,SQL_TIME,SQL_TIMESTAMP,SQL_BIGINT,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_NUMERIC,SQL_WCHAR,SQL_WVARCHAR};
	SQLUINTEGER		ColPrec[] = {254,254,10,10,5,10,7,15,15,10,8,26,19,19,19,128,128,10,18,30,254,254};
	SQLSMALLINT		ColScale[]= {0,0,5,5,0,0,0,0,0,0,0,0,0,0,6,0,128,5,5,10,0,0};
	short			CCharOutput1,CCharOutput2;
	SQLLEN			OutputLen1,OutputLen2;
	int				actual_insert=0,num_insert=0;
	SWORD			param = 0;

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars(_T("SQLExecute"), charset_file);
	if (var_list == NULL) return FAILED;

	//print_list(var_list);
	ExecStr[0] = var_mapping(_T("SQLExecute_ExecStr_0"), var_list);
	ExecStr[1] = var_mapping(_T("SQLExecute_ExecStr_1"), var_list);
	ExecStr[2] = var_mapping(_T("SQLExecute_ExecStr_2"), var_list);
	ExecStr[3] = var_mapping(_T("SQLExecute_ExecStr_3"), var_list);

	ExecStr[4] = var_mapping(_T("SQLExecute_ExecStr_4"), var_list);
	ExecStr[5] = var_mapping(_T("SQLExecute_ExecStr_5"), var_list);
	ExecStr[6] = var_mapping(_T("SQLExecute_ExecStr_6"), var_list); 
	ExecStr[7] = var_mapping(_T("SQLExecute_ExecStr_7"), var_list);
	ExecStr[8] = var_mapping(_T("SQLExecute_ExecStr_8"), var_list);
	ExecStr[9] = var_mapping(_T("SQLExecute_ExecStr_9"), var_list);
	ExecStr[10] = var_mapping(_T("SQLExecute_ExecStr_10"), var_list);
	ExecStr[11] = var_mapping(_T("SQLExecute_ExecStr_11"), var_list);
	ExecStr[12] = var_mapping(_T("SQLExecute_ExecStr_12"), var_list);
	ExecStr[13] = var_mapping(_T("SQLExecute_ExecStr_13"), var_list);
	ExecStr[14] = var_mapping(_T("SQLExecute_ExecStr_14"), var_list);

//=================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API => SQLExecute.\n"));

	TEST_INIT;

	TESTCASE_BEGIN("Setup for SQLExecute 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;
		}

	returncode=SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[4],SQL_NTS);

	returncode=SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[5],SQL_NTS); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
		}

	returncode=SQLExecDirect(hstmt,(SQLTCHAR *)ExecStr[6],SQL_NTS); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
		}

	returncode=SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[7],SQL_NTS); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
		}
	returncode=SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[8],SQL_NTS); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
		}

	TESTCASE_END;  // end of setup

	TESTCASE_BEGIN("Test #1: Positive Functionality of SQLExecute\n");

	returncode = SQLPrepare(hstmt,(SQLTCHAR *)ExecStr[9],SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	returncode = SQLExecute(hstmt); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	returncode = SQLBindCol(hstmt,1,SQL_C_SHORT,&CCharOutput1,0,&OutputLen1);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	returncode = SQLBindCol(hstmt,2,SQL_C_SHORT,&CCharOutput2,0,&OutputLen2);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	while (returncode != SQL_NO_DATA_FOUND)
	{
		returncode = SQLFetch(hstmt);
		if (returncode != SQL_NO_DATA_FOUND)
		{
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
			}
		}
	}
	SQLFreeStmt(hstmt,SQL_CLOSE);
	returncode = SQLPrepare(hstmt,(SQLTCHAR *)ExecStr[10],SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	returncode = SQLExecute(hstmt); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	SQLFreeStmt(hstmt,SQL_CLOSE);
	SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[4],SQL_NTS); 
	TESTCASE_END;

	TESTCASE_BEGIN("Test #2: Positive Functionality of SQLExecute\n");
	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[0],_tcslen(ExecStr[0])); /* cleanup */

	returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecStr[1],_tcslen(ExecStr[1]));
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	returncode = SQLExecute(hstmt); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}
	TESTCASE_END;
	
	TESTCASE_BEGIN("Test #3: Positive Functionality of SQLExecute with SQL_NTS\n");
	returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecStr[2],SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	returncode = SQLExecute(hstmt); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}
	TESTCASE_END;

	TESTCASE_BEGIN("Test #4: Positive Functionality of SQLPrepare then SQLExecute twice\n");
	returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecStr[2],_tcslen(ExecStr[2]));
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	returncode = SQLExecute(hstmt); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	returncode = SQLExecute(hstmt); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}

	TESTCASE_END;

	SQLFreeStmt(hstmt,SQL_CLOSE);
	SQLFreeStmt(hstmt,SQL_UNBIND);
	SQLFreeStmt(hstmt,SQL_RESET_PARAMS);
		
	TESTCASE_BEGIN("Test #5: Positive Functionality of SQLExecute with params\n");
	returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecStr[3],SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}
	else{
		for (i = 0; i <= 3; i++){
			    
			if (i==0) Type[0] = 1;	
			returncode = SQLBindParameter(hstmt,(SWORD)(i+1),SQL_PARAM_INPUT,SQL_C_TCHAR,Type[i],EXEC_LEN,0,szInput[i],0,&cbInput);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter")){
				LogMsg(NONE,_T("Type[i]: %d  \n"),Type[i]);
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				}
			
			}
		returncode = SQLExecute(hstmt); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			}
		}
	TESTCASE_END;
		
	TESTCASE_BEGIN("Test #6: Negative Functionality of SQLExecute with less params\n");
	returncode = SQLFreeStmt(hstmt,SQL_DROP);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFreeStmt")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}
	else{
		returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt")){
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			}
		else{
			returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecStr[3],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,Type[0],EXEC_LEN,0,szInput[0],0,&cbInput);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter")){
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
					}
				else{
					returncode = SQLExecute(hstmt); 
					if(!CHECKRC(SQL_ERROR,returncode,"SQLExecute")){
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
						}
					}
				}	
			}
		}
	TESTCASE_END;

	TESTCASE_BEGIN("Test #7: Negative Functionality of SQLExecute with not prepared stmt\n");
	returncode = SQLFreeStmt(hstmt,SQL_DROP);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFreeStmt")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}
	else{
		returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt")){
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			}
		else{
			returncode = SQLExecute(hstmt);
			if(!CHECKRC(SQL_ERROR,returncode,"SQLExecute")){
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				}
			}
		}
	TESTCASE_END;

	TESTCASE_BEGIN("Test #8: Negative Functionality of SQLExecute with invalid handle\n");
	returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecStr[2],_tcslen(ExecStr[2]));
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare")){
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		}
	else{
		returncode = SQLExecute((SQLHANDLE)NULL); 
		if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLExecute")){
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			}
		}
	TESTCASE_END;

	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[0],_tcslen(ExecStr[0])); /* cleanup */
 
	TESTCASE_BEGIN("Test #9: Stress Positive Functionality of SQLExecute.\n");
	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[11],SQL_NTS);

	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[12],SQL_NTS); 
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	else
	{
		returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecStr[13],SQL_NTS); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		else
		{
			actual_insert = 0;
			for (num_insert = 0; num_insert < MAX_INSERTED_ROWS; num_insert++)
			{
				returncode = SQLExecute(hstmt);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}
				else
					actual_insert++;
			}
			if (actual_insert != MAX_INSERTED_ROWS)
			{
				TEST_FAILED;
				LogMsg(ERRMSG,_T("failed to insert rows actual => %d & excepted => %d.\n"),actual_insert,MAX_INSERTED_ROWS);
			}
		}
	}

	SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[11],SQL_NTS); 
	TESTCASE_END;
 
	TESTCASE_BEGIN("Test #10: Stress Positive Functionality of SQLExecute with Params.\n");
	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[11],SQL_NTS); 

	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[12],SQL_NTS); 
	LogMsg(NONE,_T("ExecStr[12]: %s\n"), ExecStr[12]);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	else
	{
		returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecStr[14],SQL_NTS); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		else
		{
			actual_insert = 0;
			returncode = SQLNumParams(hstmt, &param);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumParams"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			}
			for (num_insert = 0; num_insert < MAX_INSERTED_ROWS; num_insert++)
			{
				for (i = 0; i < param; i++)
				{
					if (i==0) Type[0] = 1;

					if (MX_MP_SPECIFIC == MX_SPECIFIC)
					{
						returncode = SQLBindParameter(hstmt,(SWORD)(i+1),SQL_PARAM_INPUT,SQL_C_TCHAR,Type[i],ColPrec[i],ColScale[i],szInput[i],0,&cbInput);
					}
					else
					{
						returncode = SQLBindParameter(hstmt,(SWORD)(i+1),SQL_PARAM_INPUT,SQL_C_TCHAR,Type[i],ColPrec[i],ColScale[i],szInput[i],300,&cbInput);
					}
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
				}
				returncode = SQLExecute(hstmt);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}
				else
					actual_insert++;
			}
			if (actual_insert != MAX_INSERTED_ROWS)
			{
				TEST_FAILED;
				LogMsg(ERRMSG,_T("failed to insert rows actual => %d & excepted => %d.\n"),actual_insert,MAX_INSERTED_ROWS);
			}
		}
	}

	SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[11],SQL_NTS); 
	TESTCASE_END;

	TESTCASE_BEGIN("Test #11: Negative Functionality of SQLExecute with already existing table\n");
	returncode = SQLFreeStmt(hstmt,SQL_DROP);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFreeStmt"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
	}
	else
	{
		returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
		}
		else
		{
			SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[0],_tcslen(ExecStr[0])); /* cleanup */
			returncode = SQLPrepare(hstmt,(SQLTCHAR*)ExecStr[1],_tcslen(ExecStr[1]));
			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 = SQLExecute(hstmt); 
					if(!CHECKRC(SQL_ERROR,returncode,"SQLExecute"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
				}
			}
			SQLExecDirect(hstmt,(SQLTCHAR*)ExecStr[0],_tcslen(ExecStr[0])); /* cleanup */
		}
	}
	TESTCASE_END;

//=================================================================================================
	
	FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,_T("End testing API => SQLExecute.\n"));
	free_list(var_list);
	TEST_RETURN;
}
Exemplo n.º 8
0
/*
---------------------------------------------------------
   TestSQLError Minimum tests since this is tested all over the places
---------------------------------------------------------
*/
PassFail TestSQLError(TestInfo *pTestInfo)
{                  
	TEST_DECLARE;
	RETCODE		returncode;
	SQLHANDLE 	henv;
	SQLHANDLE 	hdbc;
	SQLHANDLE	hstmt;
	CHAR		SqlState[STATE_SIZE];
	SDWORD		NativeError;
	CHAR		ErrorMsg[MAX_STRING_SIZE];
	SWORD		ErrorMsglen;

	CHAR		*CrtTab = "--";

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars("SQLError", charset_file);
	if (var_list == NULL) return FAILED;

	CrtTab = var_mapping("SQLError_CrtTab", var_list);
//===========================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API =>SQLError | SQLError | error.c\n");
	
  TEST_INIT;

	returncode=FullConnect(pTestInfo);
  if (pTestInfo->hdbc == (SQLHANDLE)NULL)
	{
		TEST_FAILED;
		TEST_RETURN;
	}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = pTestInfo->hstmt;

	returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
  if (returncode == SQL_SUCCESS)
	{
		TESTCASE_BEGIN("Test syntax while creating a table SQLError\n");
		returncode = SQLExecDirect(hstmt,(SQLCHAR*)CrtTab,SQL_NTS);
	  if (returncode == SQL_ERROR)
		{
			returncode = SQLError((SQLHANDLE)henv, (SQLHANDLE)hdbc, hstmt, (SQLCHAR*)SqlState, &NativeError, (SQLCHAR*)ErrorMsg, MAX_STRING_SIZE, &ErrorMsglen);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLError"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
			}
			else
			{
				LogMsg(NONE,"SqlState: %s and ErrorMsg: %s\n",SqlState,ErrorMsg);
				TESTCASE_END;
			}
		}
	}
	FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => SQLError.\n");
	free_list(var_list);
	TEST_RETURN;
}
Exemplo n.º 9
0
/*
---------------------------------------------------------
   TestSQLNativeSql
---------------------------------------------------------
*/
PassFail TestSQLNativeSql(TestInfo *pTestInfo)
{                  
	TEST_DECLARE;
	RETCODE		returncode;
 	SQLHANDLE 	henv;
 	SQLHANDLE 	hdbc;
 	SQLHANDLE	hstmt;
	CHAR		*szSqlStrIn[3];
	CHAR		szSqlStrOut[SQLSTR_LEN];
	SDWORD	pcbSqlStr;
   
//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars("SQLNativeSql", charset_file);
	if (var_list == NULL) return FAILED;

	//print_list(var_list);
	szSqlStrIn[0] = var_mapping("SQLNativeSql_szSqlStrIn_1", var_list);
	szSqlStrIn[1] = var_mapping("SQLNativeSql_szSqlStrIn_2", var_list);
	szSqlStrIn[2] = var_mapping("SQLNativeSql_szSqlStrIn_3", var_list);
//===========================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API =>SQLNativeSql | SQLNativeSQL | natsql.c\n");

	TEST_INIT;

	returncode=FullConnect(pTestInfo);
   if (pTestInfo->hdbc == (SQLHANDLE)NULL)
	{
		TEST_FAILED;
		TEST_RETURN;
	}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
	returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
	if (returncode == SQL_SUCCESS)
	{
	//==================================================================================================

		TESTCASE_BEGIN("Test the positive functionality of SQLNativeSql with null terminated string\n");
		returncode = SQLNativeSql((SQLHANDLE)hdbc, (SQLCHAR*)szSqlStrIn[0], SQL_NTS, (SQLCHAR*)szSqlStrOut, SQLSTR_LEN, &pcbSqlStr); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNativeSql"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		if (strcmp(szSqlStrOut,szSqlStrIn[0]) == 0)
		{
			LogMsg(NONE,"expect: %s and actual: %s are matched\n", szSqlStrIn[0], szSqlStrOut);
		}	
		else
		{
			TEST_FAILED;	
			LogMsg(NONE,"expect: %s and actual: %s are not matched\n", szSqlStrIn[0], szSqlStrOut);
		}
		TESTCASE_END;

		//==================================================================================================

		TESTCASE_BEGIN("Test the positive functionality of SQLNativeSql with string length as input\n");
		returncode = SQLNativeSql((SQLHANDLE)hdbc, (SQLCHAR*)szSqlStrIn[1], strlen(szSqlStrIn[1]), (SQLCHAR*)szSqlStrOut, SQLSTR_LEN, &pcbSqlStr); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNativeSql"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		if (strcmp(szSqlStrOut,szSqlStrIn[1]) == 0)
		{
			LogMsg(NONE,"expect: %s and actual: %s are matched\n", szSqlStrIn[1], szSqlStrOut);
		}	
		else
		{
			TEST_FAILED;	
			LogMsg(NONE,"expect: %s and actual: %s are not matched\n", szSqlStrIn[1], szSqlStrOut);
		}
		TESTCASE_END;

		//==================================================================================================
		TESTCASE_BEGIN("Test the positive functionality of SQLNativeSql with max length same as string length\n");
		returncode = SQLNativeSql((SQLHANDLE)hdbc, (SQLCHAR*)szSqlStrIn[2], strlen(szSqlStrIn[2]), (SQLCHAR*)szSqlStrOut, strlen(szSqlStrIn[2])+1, &pcbSqlStr); 
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNativeSql"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		if (strcmp(szSqlStrOut,szSqlStrIn[2]) == 0)
		{
			LogMsg(NONE,"expect: %s and actual: %s are matched\n", szSqlStrIn[2], szSqlStrOut);
		}	
		else
		{
			TEST_FAILED;	
			LogMsg(NONE,"expect: %s and actual: %s are not matched\n", szSqlStrIn[2], szSqlStrOut);
		}
		TESTCASE_END;
	}
//==================================================================================================

	FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => SQLNativeSql.\n");
	free_list(var_list);
	TEST_RETURN;
}
Exemplo n.º 10
0
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;
}
Exemplo n.º 11
0
/*
---------------------------------------------------------
   TestSQLDescribeColVer3 for MP Specific
---------------------------------------------------------
*/
PassFail TestMXSQLDescribeColVer3(TestInfo *pTestInfo)
{
	TEST_DECLARE;
 	char			Heading[MAX_STRING_SIZE];
	RETCODE			returncode;
	SQLHANDLE 		henv, hdbc, hstmt;
	UWORD			icol;
	SWORD			numcol, st, cs, cnull, cl, colsize = 2;
	SQLULEN         cp; 
	CHAR			cn[COLNAME_LEN];
	CHAR			*colname[21];
	CHAR			*ExecDirStr[12];

#ifndef _WM
	SWORD			SQLType[] = {SQL_CHAR,SQL_VARCHAR,SQL_DECIMAL,SQL_NUMERIC,SQL_SMALLINT,SQL_INTEGER,
									SQL_REAL,SQL_DOUBLE,SQL_DOUBLE,SQL_TYPE_DATE,SQL_TYPE_TIME,SQL_TYPE_TIMESTAMP,SQL_LONGVARCHAR,SQL_BIGINT,
									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,19,19,128,128,10,18,30};
#else
	SWORD			SQLType[] = {SQL_CHAR,SQL_VARCHAR,SQL_DECIMAL,SQL_NUMERIC,SQL_SMALLINT,SQL_INTEGER,
									SQL_REAL,SQL_DOUBLE,SQL_DOUBLE,SQL_CHAR,SQL_TYPE_TIME,SQL_TYPE_TIMESTAMP,SQL_LONGVARCHAR,SQL_BIGINT,
									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,8,8,26,2000,19,19,19,128,128,10,18,30};
#endif
	SWORD			ColScale[]= {0,  0,  6, 6, 0,0, 0,0, 0, 0, 0,6, 0,   0, 0, 6, 0,  128,5, 5, 10};
	char			TempType1[50],TempType2[50];
	SWORD			ColNullable[] = {SQL_NULLABLE,SQL_NO_NULLS,SQL_NULLABLE};

	CHAR			*TestCase[] = {
					"before preparing stmt ",
					"before preparing & executing stmt ",
					"before preparing, executing & fetching stmt ",
					"before execdirect stmt ",
					"before execdirect & fetching stmt ",
					"before preparing param stmt ",
					"before preparing & binding stmt ",
					"before preparing, binding & executing stmt ",
					"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("SQLDescribeColumns30", charset_file);
	if (var_list == NULL) return FAILED;
//================Modified for Longvarchar Changes===========================================================
	if(!pTestInfo->bLongOn)
	{
		SWORD iNoLong = SQL_VARCHAR;
		SQLType[12] = iNoLong;
	}
//================Modified for Longvarchar Changes===========================================================
	//print_list(var_list);
	colname[0] = var_mapping("SQLDescribeColumns30_colname_1", var_list);
	colname[1] = var_mapping("SQLDescribeColumns30_colname_2", var_list);
	colname[2] = var_mapping("SQLDescribeColumns30_colname_3", var_list);
	colname[3] = var_mapping("SQLDescribeColumns30_colname_4", var_list);
	colname[4] = var_mapping("SQLDescribeColumns30_colname_5", var_list);
	colname[5] = var_mapping("SQLDescribeColumns30_colname_6", var_list);
	colname[6] = var_mapping("SQLDescribeColumns30_colname_7", var_list);
	colname[7] = var_mapping("SQLDescribeColumns30_colname_8", var_list);
	colname[8] = var_mapping("SQLDescribeColumns30_colname_9", var_list);
	colname[9] = var_mapping("SQLDescribeColumns30_colname_10", var_list);
	colname[10] = var_mapping("SQLDescribeColumns30_colname_11", var_list);
	colname[11] = var_mapping("SQLDescribeColumns30_colname_12", var_list);
	colname[12] = var_mapping("SQLDescribeColumns30_colname_13", var_list);
	colname[13] = var_mapping("SQLDescribeColumns30_colname_14", var_list);
	colname[14] = var_mapping("SQLDescribeColumns30_colname_15", var_list);
	colname[15] = var_mapping("SQLDescribeColumns30_colname_16", var_list);
	colname[16] = var_mapping("SQLDescribeColumns30_colname_17", var_list);
	colname[17] = var_mapping("SQLDescribeColumns30_colname_18", var_list);
	colname[18] = var_mapping("SQLDescribeColumns30_colname_19", var_list);
	colname[19] = var_mapping("SQLDescribeColumns30_colname_20", var_list);
	colname[20] = var_mapping("SQLDescribeColumns30_colname_21", var_list);

	ExecDirStr[0] = var_mapping("SQLDescribeColumns30_ExecDirStr_1", var_list);
	ExecDirStr[1] = var_mapping("SQLDescribeColumns30_ExecDirStr_2", var_list);
	ExecDirStr[2] = var_mapping("SQLDescribeColumns30_ExecDirStr_3", var_list);
	ExecDirStr[3] = var_mapping("SQLDescribeColumns30_ExecDirStr_4", var_list);
	ExecDirStr[4] = var_mapping("SQLDescribeColumns30_ExecDirStr_5", var_list);
	ExecDirStr[5] = var_mapping("SQLDescribeColumns30_ExecDirStr_6", var_list);
	ExecDirStr[6] = var_mapping("SQLDescribeColumns30_ExecDirStr_7", var_list);
	ExecDirStr[7] = var_mapping("SQLDescribeColumns30_ExecDirStr_8", var_list);
	ExecDirStr[8] = var_mapping("SQLDescribeColumns30_ExecDirStr_9", var_list);
	ExecDirStr[9] = var_mapping("SQLDescribeColumns30_ExecDirStr_10", var_list);
	ExecDirStr[10] = var_mapping("SQLDescribeColumns30_ExecDirStr_11", var_list);
	ExecDirStr[11] = var_mapping("SQLDescribeColumns30_ExecDirStr_12", var_list);

//=========================================================================================

	if(isUCS2) {
		LogMsg(NONE,"Setup for UCS2 mode testing: ColPrec has to be doubled\n");

        ExecDirStr[3] = replace_str(ExecDirStr[3],"$$$","127");
        ExecDirStr[4] = replace_str(ExecDirStr[4],"$$$","127");
        ExecDirStr[5] = replace_str(ExecDirStr[5],"$$$","127");

		l = sizeof(SQLType)/sizeof(SQLType[0]);
		while(i < l) {
			if(SQLType[i] == SQL_CHAR) {
				//SQLType[i] = SQL_WCHAR;
				ColPrec[i] *= 2;  //--> This is in character, so no need to double
			}
			else if (SQLType[i] == SQL_VARCHAR) {
				//SQLType[i] = SQL_WVARCHAR;
			}
			else if (SQLType[i] == SQL_LONGVARCHAR)	{
				//SQLType[i] = SQL_WLONGVARCHAR;
				ColPrec[i] *= 2;  //--> This is in character, so no need to double
			}
			else {
			}
			i++;
		}
		i = 0;
		l = 0;
	} else {
        ExecDirStr[3] = replace_str(ExecDirStr[3],"$$$","254");
        ExecDirStr[4] = replace_str(ExecDirStr[4],"$$$","254");
        ExecDirStr[5] = replace_str(ExecDirStr[5],"$$$","254");
    }

//===========================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API => MX Specific SQLDescribeColumns | SQLDescribeColumns30 | sqldescribecolver3.c\n");
	TEST_INIT;

	TESTCASE_BEGIN("Setup for SQLDescribCol tests\n");

	if(!FullConnectWithOptions(pTestInfo, CONNECT_ODBC_VERSION_3))
	{
		LogMsg(NONE,"Unable to connect\n");
		TEST_FAILED;
		TEST_RETURN;
	}

	henv = pTestInfo->henv;
	hdbc = pTestInfo->hdbc;
	hstmt = (SQLHANDLE)pTestInfo->hstmt;
	
	returncode = SQLAllocHandle(SQL_HANDLE_STMT, (SQLHANDLE)hdbc, &hstmt);	
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocHandle"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	TESTCASE_END;  // end of setup
	for (l = 0; l < lend; l++)
	{
		for (i = 0; i < iend; i++)
		{
			//==================================================================================
			sprintf(Heading,"SQLDescribeCol: Test #%d.%d\n",l,i);
			TESTCASE_BEGIN(Heading);
			if ((i != (iend-1)) && (l < 5))
			{
				rerutncode = SQLExecDirect(hstmt,(SQLCHAR*)ExecDirStr[i],SQL_NTS); /* cleanup */
				 if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
                                        {
                                                LogAllErrorsVer3(henv,hdbc,hstmt);
                                                TEST_FAILED;
                                        }

                                returncode = SQLExecDirect(hstmt,(SQLCHAR*)ExecDirStr[i+iend],SQL_NTS); /* create table */
				LogMsg(NONE,"%s\n", ExecDirStr[i+iend]);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
				{
					LogAllErrorsVer3(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				else
				{
					returncode = SQLExecDirect(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend],SQL_NTS); /* insert into table */
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
					{
						LogAllErrorsVer3(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					else
					{
						LogMsg(NONE,"SQLDescribeCol: %s\n",TestCase[l]);
						LogMsg(NONE,"     %s\n",ExecDirStr[i+iend+iend+iend]);
						switch( l )
						{
							case 0:
								returncode = SQLPrepare(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
								{
									LogAllErrorsVer3(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								break;
							case 1 :
								returncode = SQLPrepare(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
								{
									LogAllErrorsVer3(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									returncode = SQLExecute(hstmt);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
								}
								break;
							case 2 :
								returncode = SQLPrepare(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
								{
									LogAllErrorsVer3(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									returncode = SQLExecute(hstmt);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
									else
									{
										returncode = SQLFetch(hstmt);
										if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
										{
											LogAllErrorsVer3(henv,hdbc,hstmt);
											TEST_FAILED;
										}
									}
								}
								break;
							case 3 :
								returncode = SQLExecDirect(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
								{
									LogAllErrorsVer3(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								break;
							case 4 :
								returncode = SQLExecDirect(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
								{
									LogAllErrorsVer3(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									returncode = SQLFetch(hstmt);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
								}
								break;
						}
						if (returncode == SQL_SUCCESS)
						{
							returncode=SQLNumResultCols(hstmt, &numcol);
							if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultCols"))
							{
								LogAllErrorsVer3(henv,hdbc,hstmt);
								TEST_FAILED;
							}
							for (icol = 1; icol <= numcol; icol++)
							{
								LogMsg(LINEBEFORE,"SQLDescribeCol: checking Column #%d\n",icol);
								returncode = SQLDescribeCol(hstmt,icol,(SQLCHAR*)cn,COLNAME_LEN,&cl,&st,&cp,&cs,&cnull);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLDescribeCol"))
								{
									TEST_FAILED;
									LogAllErrorsVer3(henv,hdbc,hstmt);
								}
								colsize=strlen(colname[icol-1]);
								if(isCharSet == TRUE)
									colsize -= 2;
								if ((cstrcmp(cn,colname[icol-1],FALSE,isCharSet) == 0) 
									 && (cl == colsize) 
									 && (st == SQLType[icol-1]) 
									 && (cp == ColPrec[icol-1]) 
									 && (cs == ColScale[icol-1]) 
									 && (cnull == ColNullable[i]))
								{
									//LogMsg(NONE,"colname expect: %s and actual: %s are matched\n",colname[icol-1],cn);
									//LogMsg(NONE,"ColNameLen expect: %d and actual: %d are matched\n",colsize,cl);
									//LogMsg(NONE,"SQLType expect: %s and actual: %s are matched\n",
									//SQLTypeToChar(SQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2));
									//LogMsg(NONE,"ColPrec expect: %d and actual: %d are matched\n",ColPrec[icol-1],cp);
									//LogMsg(NONE,"ColScale expect: %d and actual: %d are matched\n",ColScale[icol-1],cs);
									//LogMsg(NONE,"ColNullable expect: %s and actual: %s are matched\n\n",
									//SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2));
								}
								else
								{
									TEST_FAILED;	
									if (cstrcmp(cn,colname[icol-1],FALSE,isCharSet) != 0)
										LogMsg(ERRMSG,"colname expect: %s and actual: %s are not matched\n",colname[icol-1],cn);
									if (cl != colsize)
										LogMsg(ERRMSG,"ColNameLen expect: %d and actual: %d are not matched\n",colsize,cl);
									if (st != SQLType[icol-1])
										LogMsg(ERRMSG,"SQLType expect: %s and actual: %s are not matched\n",
											SQLTypeToChar(SQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2));
									if (cp != ColPrec[icol-1])
										LogMsg(ERRMSG,"ColPrec expect: %d and actual: %d are not matched\n",ColPrec[icol-1],cp);
									if (cs != ColScale[icol-1])
										LogMsg(ERRMSG,"ColScale expect: %d and actual: %d are not matched\n",ColScale[icol-1],cs);
									if (cnull != ColNullable[i])
										LogMsg(ERRMSG,"ColNullable expect: %s and actual: %s are not matched\n\n",
											SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2));
								}
							} /* end icol loop */
						}
						else
						{
							TEST_FAILED;
							LogAllErrorsVer3(henv,hdbc,hstmt);
						}
						SQLFreeStmt(hstmt,SQL_CLOSE);
						SQLExecDirect(hstmt,(SQLCHAR*) ExecDirStr[i],SQL_NTS); /* cleanup */
					}
				}
			}
			else if ((i == (iend-1)) && (l >= 5))
			{
				SQLExecDirect(hstmt,(SQLCHAR*)ExecDirStr[i],SQL_NTS); /* cleanup */ 
				returncode = SQLExecDirect(hstmt,(SQLCHAR*)ExecDirStr[i+iend],SQL_NTS); /* create table */
				LogMsg(NONE,"%s\n", ExecDirStr[i+iend]);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
				{
					LogAllErrorsVer3(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				else
				{
					returncode = SQLExecDirect(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend],SQL_NTS); /* insert into table */
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
					{
						LogAllErrorsVer3(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					else
					{
						LogMsg(NONE,"SQLDescribeCol: %s\n",TestCase[l]);
						LogMsg(NONE,"     %s\n",ExecDirStr[i+iend+iend+iend]);
						switch( l ) 
						{
							case 5 :
								returncode = SQLPrepare(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
								{
									LogAllErrorsVer3(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								break;
							case 6 :
								returncode = SQLPrepare(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
								{
									LogAllErrorsVer3(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									returncode = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,2000,0,(SQLPOINTER) "0123456789",300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
									returncode = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,2000,0,(SQLPOINTER)"0123456789",300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
								}
								break;
							case 7 :
								returncode = SQLPrepare(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
								{
									LogAllErrorsVer3(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									returncode = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,2000,0,(SQLPOINTER)"0123456789",300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
									returncode = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,2000,0,(SQLPOINTER)"0123456789",300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
									returncode = SQLExecute(hstmt);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
								}
								break;
							  case 8 :
								returncode = SQLPrepare(hstmt,(SQLCHAR*)ExecDirStr[i+iend+iend+iend], SQL_NTS);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
								{
									LogAllErrorsVer3(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									returncode = SQLBindParameter(hstmt,1,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,2000,0,(SQLPOINTER)"0123456789",300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
									returncode = SQLBindParameter(hstmt,2,SQL_PARAM_INPUT,SQL_C_CHAR,SQL_CHAR,2000,0,(SQLPOINTER)"0123456789",300,&cbIn);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindParameter"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
									returncode = SQLExecute(hstmt);
									if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
									{
										LogAllErrorsVer3(henv,hdbc,hstmt);
										TEST_FAILED;
									}
									else
									{
										returncode = SQLFetch(hstmt);
										if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
										{
											LogAllErrorsVer3(henv,hdbc,hstmt);
											TEST_FAILED;
										}
									}
								}
								break;
						}
						if (returncode == SQL_SUCCESS)
						{
							SQLNumResultCols(hstmt, &numcol);
							if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultCols"))
							{
								LogAllErrorsVer3(henv,hdbc,hstmt);
								TEST_FAILED;
							}
							for (icol = 1; icol <= numcol; icol++)
							{
								LogMsg(LINEBEFORE,"SQLDescribeCol: checking Column #%d\n",icol);
								returncode = SQLDescribeCol(hstmt,icol,(SQLCHAR*)cn,COLNAME_LEN,&cl,&st,&cp,&cs,&cnull);
								if(!CHECKRC(SQL_SUCCESS,returncode,"SQLDescribeCol"))
								{
									TEST_FAILED;
									LogAllErrorsVer3(henv,hdbc,hstmt);
								}
								colsize=strlen(colname[icol-1]);
								if(isCharSet == TRUE)
									colsize -= 2;
								if ((cstrcmp(cn,colname[icol-1],FALSE,isCharSet) == 0) 
									 && (cl == colsize) 
									 && (st == SQLType[icol-1]) 
									 && (cp == ColPrec[icol-1]) 
									 && (cs == ColScale[icol-1]) 
									 && (cnull == ColNullable[i]))
								{
									//LogMsg(NONE,"colname expect: %s and actual: %s are matched\n",colname[icol-1],cn);
									//LogMsg(NONE,"ColNameLen expect: %d and actual: %d are matched\n",colsize,cl);
									//LogMsg(NONE,"SQLType expect: %s and actual: %s are matched\n",
									//	SQLTypeToChar(SQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2));
									//LogMsg(NONE,"ColPrec expect: %d and actual: %d are matched\n",ColPrec[icol-1],cp);
									//LogMsg(NONE,"ColScale expect: %d and actual: %d are matched\n",ColScale[icol-1],cs);
									//LogMsg(NONE,"ColNullable expect: %s and actual: %s are matched\n\n",
									//	SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2));
								}
								else
								{
									TEST_FAILED;	
									if (cstrcmp(cn,colname[icol-1],FALSE,isCharSet) != 0)
										LogMsg(ERRMSG,"colname expect: %s and actual: %s are not matched\n",colname[icol-1],cn);
									if (cl != colsize)
										LogMsg(ERRMSG,"ColNameLen expect: %d and actual: %d are not matched\n",colsize,cl);
									if (st != SQLType[icol-1])
										LogMsg(ERRMSG,"SQLType expect: %s and actual: %s are not matched\n",
											SQLTypeToChar(SQLType[icol-1],TempType1),SQLTypeToChar(st,TempType2));
									if (cp != ColPrec[icol-1])
										LogMsg(ERRMSG,"ColPrec expect: %d and actual: %d are not matched\n",ColPrec[icol-1],cp);
									if (cs != ColScale[icol-1])
										LogMsg(ERRMSG,"ColScale expect: %d and actual: %d are not matched\n",ColScale[icol-1],cs);
									if (cnull != ColNullable[i])
										LogMsg(ERRMSG,"ColNullable expect: %s and actual: %s are not matched\n\n",
											SQLNullToChar(ColNullable[i],TempType1),SQLNullToChar(cnull,TempType2));
								}
							}
						}
					}
					SQLFreeStmt(hstmt,SQL_CLOSE);
					SQLExecDirect(hstmt,(SQLCHAR*) ExecDirStr[i],SQL_NTS); 
				}
			}
			TESTCASE_END;
		} /* iend loop */
	} /* lend loop */
	SQLFreeHandle(SQL_HANDLE_STMT, hstmt);
	FullDisconnect3(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => MX Specific SQLDescribeColumns.\n");
	free_list(var_list);
	TEST_RETURN;
}
Exemplo n.º 12
0
//---------------------------------------------------------
//   TestSQLAllocStmt()
//---------------------------------------------------------
PassFail TestSQLAllocStmt (TestInfo *pTestInfo, int MX_MP_SPECIFIC)
{
	TEST_DECLARE;
 	char			Heading[MAX_STRING_SIZE];
 	RETCODE			returncode;
 	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt[NUM_STMT];
	//RETCODE		AsyncStmt[NUM_ASYNC_STMT];
	char			*StmtHndlStr;
	int				i = 0, j = 0, k = 0;
	int				AnyAsync;
	int				AsyncOper[] = {CREATE_TABLE,INSERT_TABLE,SELECT_TABLE,DROP_TABLE,999};

	char			*teststmthndl[21];

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars("SQLAllocateStatement", charset_file);
	if (var_list == NULL) return FAILED;

	teststmthndl[0] = var_mapping("TestStmtHndl_0", var_list);
	teststmthndl[1] = var_mapping("TestStmtHndl_1", var_list);
	teststmthndl[2] = var_mapping("TestStmtHndl_2", var_list);
	teststmthndl[3] = var_mapping("TestStmtHndl_3", var_list);
	teststmthndl[4] = var_mapping("TestStmtHndl_4", var_list);
	teststmthndl[5] = var_mapping("TestStmtHndl_5", var_list);
	teststmthndl[6] = var_mapping("TestStmtHndl_6", var_list);
	teststmthndl[7] = var_mapping("TestStmtHndl_7", var_list);
	teststmthndl[8] = var_mapping("TestStmtHndl_8", var_list);
	teststmthndl[9] = var_mapping("TestStmtHndl_9", var_list);
	teststmthndl[10] = var_mapping("TestStmtHndl_10", var_list);
	teststmthndl[11] = var_mapping("TestStmtHndl_11", var_list);
	teststmthndl[12] = var_mapping("TestStmtHndl_12", var_list);
	teststmthndl[13] = var_mapping("TestStmtHndl_13", var_list);
	teststmthndl[14] = var_mapping("TestStmtHndl_14", var_list);
	teststmthndl[15] = var_mapping("TestStmtHndl_15", var_list);
	teststmthndl[16] = var_mapping("TestStmtHndl_16", var_list);
	teststmthndl[17] = var_mapping("TestStmtHndl_17", var_list);
	teststmthndl[18] = var_mapping("TestStmtHndl_18", var_list);
	teststmthndl[19] = var_mapping("TestStmtHndl_19", var_list);
	teststmthndl[20] = var_mapping("TestStmtHndl_20", var_list);
//======================================================================================

	if (MX_MP_SPECIFIC == MX_SPECIFIC)
		LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API => MX specific SQLAllocStmt | SQLAllocStmt | alocstmt.c\n");
	else
		LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API => MP specific SQLAllocStmt | SQLAllocStmt | alocstmt.c\n");

	TEST_INIT;

	TESTCASE_BEGIN("Setup for SQLAllocStmt/SQLFreeStmt tests\n");

	/* 6-5-00:
	Need to turn Autocommit off since MX will close all open cursors that are
	open if the end of ANY of the cursors is reached. */
	if(!FullConnectWithOptions(pTestInfo, CONNECT_ODBC_VERSION_2))
	{
		LogMsg(NONE,"Unable to connect\n");
		TEST_FAILED;
		TEST_RETURN;
	}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
	//set the connection attribute to SQL_AUTOCOMMIT_OFF to enable use of multiple stmt  without errors 
	SQLSetConnectAttr((SQLHANDLE)hdbc, SQL_ATTR_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF, SQL_IS_UINTEGER);

	TESTCASE_END;  // end of setup

	StmtHndlStr = (char *)malloc(MAX_NOS_SIZE);

//====================================================================================================
// General statement handle exercise testcases.

	for (k = 0; k < 2; k++)
	{
		for (i = 0; i < NUM_STMT; i++)
		{
			hstmt[i] = (SQLHANDLE)pTestInfo->hstmt;

			sprintf(Heading,"SQLAllocstmt: Test #%d\n",i);
			TESTCASE_BEGIN(Heading);
			returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt[i]);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt[i]);
			}
			TESTCASE_END;
			if (returncode == SQL_SUCCESS)
			{
		 		if (i == 0)									// cleanup 
				{
					for (j = 0; j < NUM_STMT; j++)
					{
						SQLExecDirect(hstmt[0],StmtQueries(DROP_TABLE,teststmthndl[j],StmtHndlStr),SQL_NTS); 
					}
				}
				sprintf(Heading,"SQLAllocStmt: create table teststmthndl%d\n",i+1);
				TESTCASE_BEGIN(Heading);
				if (k == 0)	// prepare & execute 
				{
					returncode = SQLPrepare(hstmt[i],StmtQueries(CREATE_TABLE,teststmthndl[i],StmtHndlStr),SQL_NTS); 
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
					}
					else{
						returncode = SQLExecute(hstmt[i]);
						if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
							TEST_FAILED;
							LogAllErrors(henv,hdbc,hstmt[i]);
							}
						}
					}
				else	// execdirect 
				{
					returncode = SQLExecDirect(hstmt[i],StmtQueries(CREATE_TABLE,teststmthndl[i],StmtHndlStr),SQL_NTS);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
					}
				}
				}
				if (returncode == SQL_SUCCESS) TESTCASE_END;
			}

		for (i = 0; i < NUM_STMT; i++)
		{
			sprintf(Heading,"SQLAllocStmt: inserts on Stmt Handle(%d)\n",i);
			TESTCASE_BEGIN(Heading);
			if (k == 0)	// prepare & execute 
			{
				returncode = SQLPrepare(hstmt[i],StmtQueries(INSERT_TABLE,teststmthndl[i],StmtHndlStr),SQL_NTS); 
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt[i]);
				}
				else
				{
					returncode = SQLExecute(hstmt[i]);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
					}
				}
			}
			else	// execdirect 
			{
				returncode = SQLExecDirect(hstmt[i],StmtQueries(INSERT_TABLE,teststmthndl[i],StmtHndlStr),SQL_NTS); 
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt[i]);
				}
			}
			if (returncode == SQL_SUCCESS)TESTCASE_END;
		}

		for (i = 0; i < NUM_STMT; i++)
		{
			sprintf(Heading,"SQLAllocStmt: selects on Stmt Handle(%d)\n",i);
			TESTCASE_BEGIN(Heading);
			if (k == 0)	// prepare & execute 
			{
				returncode = SQLPrepare(hstmt[i],StmtQueries(SELECT_TABLE,teststmthndl[i],StmtHndlStr),SQL_NTS); 
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt[i]);
				}
				else{
					returncode = SQLExecute(hstmt[i]);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute")){
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
						}
					}
			}
			else	// execdirect 
			{
				returncode = SQLExecDirect(hstmt[i],StmtQueries(SELECT_TABLE,teststmthndl[i],StmtHndlStr),SQL_NTS); 
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt[i]);
				}
			}
			if (returncode == SQL_SUCCESS) TESTCASE_END;
		}

		for (i = (NUM_STMT-1); i > -1; i--)
		{
			sprintf(Heading,"SQLAllocStmt: fetches on selects on Stmt Handle(%d)\n",i);
			TESTCASE_BEGIN(Heading);
			returncode = SQLFetch(hstmt[i]);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt[i]);
			}			
			if (returncode == SQL_SUCCESS) TESTCASE_END;
		}

		for (i = 0; i < NUM_STMT; i++)
		{
			sprintf(Heading,"SQLAllocStmt: SQLFreeStmt(%d) with SQL_CLOSE\n",i);
			TESTCASE_BEGIN(Heading);
			returncode = SQLFreeStmt(hstmt[i],SQL_CLOSE);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFreeStmt"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt[i]);
			}
			else{
				TESTCASE_END;
				}

			if (i == (NUM_STMT-1))					// cleanup 
			{
				for (j = 0; j < NUM_STMT; j++)
				{
					SQLExecDirect(hstmt[0],StmtQueries(DROP_TABLE,teststmthndl[j],StmtHndlStr),SQL_NTS); 
				}
			}
		}

		for (i = 0; i < NUM_STMT; i++)
		{
			sprintf(Heading,"SQLAllocStmt: SQLFreeStmt(%d) with SQL_DROP\n",i);
			TESTCASE_BEGIN(Heading);
			returncode = SQLFreeStmt(hstmt[i],SQL_DROP);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFreeStmt"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt[i]);
			}
			else{
				TESTCASE_END;
				}
		}

		sprintf(Heading,"SLQAllocStmt: same sql operations on different of SQLAllocstmt(%d)s\n",i);
		TESTCASE_BEGIN(Heading);
 		for (i = 0; i < NUM_STMT; i++)
		{
			hstmt[i] = (SQLHANDLE)pTestInfo->hstmt;
			returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt[i]);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt[i]);
			}
			if (returncode == SQL_SUCCESS)
			{
		 		if (i == 0)									// cleanup
				{
					SQLExecDirect(hstmt[0],StmtQueries(DROP_TABLE,teststmthndl[20],StmtHndlStr),SQL_NTS); 
					returncode = SQLExecDirect(hstmt[0],StmtQueries(CREATE_TABLE,teststmthndl[20],StmtHndlStr),SQL_NTS); 
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[0]);
					}			
				}
				if (k == 0)	// prepare & execute 
				{
					returncode = SQLPrepare(hstmt[i],StmtQueries(INSERT_TABLE,teststmthndl[20],StmtHndlStr),SQL_NTS);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
					}			
					returncode = SQLExecute(hstmt[i]);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
					}
				}
				else	// execdirect
				{
					returncode = SQLExecDirect(hstmt[i],StmtQueries(INSERT_TABLE,teststmthndl[20],StmtHndlStr),SQL_NTS);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
					}
				}
				if (k == 0)	// prepare & execute 
				{
					returncode = SQLPrepare(hstmt[i],StmtQueries(SELECT_TABLE,teststmthndl[20],StmtHndlStr),SQL_NTS);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
					}			
					returncode = SQLExecute(hstmt[i]);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
					}
				}
				else
				{
					returncode = SQLExecDirect(hstmt[i],StmtQueries(SELECT_TABLE,teststmthndl[20],StmtHndlStr),SQL_NTS);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
					}
				}
				returncode = SQLFetch(hstmt[i]); 
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt[i]);
				}
			}
		}
 		for (i = 0; i < NUM_STMT; i++)
		{
			returncode = SQLFreeStmt(hstmt[i],SQL_CLOSE);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt[i]);
			}
			if (i == 0)
			{
				SQLExecDirect(hstmt[0],StmtQueries(DROP_TABLE,teststmthndl[20],StmtHndlStr),SQL_NTS); 
			}
			returncode = SQLFreeStmt(hstmt[i],SQL_DROP);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFreeStmt"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt[i]);
			}
		}
		TESTCASE_END;
	}

//====================================================================================================
// Asynchronus Testcases

	if (MX_MP_SPECIFIC == MX_SPECIFIC)
	{
		for (i = 0; i < NUM_ASYNC_STMT; i++)
		{
			hstmt[i] = (SQLHANDLE)pTestInfo->hstmt;
			// Creating statement handles
			sprintf(Heading,"SQLAllocstmt: Test #%d and Enable the ASYNC MODE ON.\n",i);
			TESTCASE_BEGIN(Heading);
			returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt[i]);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLAllocStmt"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt[i]);
			}
			else
			{
		 		if (i == 0)									// cleanup 
				{
					// Creating tables to be used by each of the stmt handles
					for (j = 0; j < NUM_ASYNC_STMT; j++)
					{
						SQLExecDirect(hstmt[0],StmtQueries(DROP_TABLE,teststmthndl[j],StmtHndlStr),SQL_NTS); 
					}
				}
				// Putting each stmthandle into Asynchronus mode
				returncode = SQLSetStmtOption(hstmt[i],SQL_ASYNC_ENABLE,SQL_ASYNC_ENABLE_ON);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetStmtOptions"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt[i]);
				}
			}
			TESTCASE_END;
		}

		// Running the Asynchronus tests
		// WHAT IS GOING ON
		//   Two tests cases are being checked:
		//     1. That the status of an asynchronus stmt handle CAN be checked.
		//     2. That the stmt handle completes correctly.
		//
		// HOW IT'S BEING RUN
		//   Steps being performed until all handles are no longer executing:
		//     1. Prepare the async test data structure.
		//     2. Generate table name based on statement handle being used.
		//     3. If handle's status has not been checked already, check as test case 1.
		//        Else, check it's status NOT as a test case.
		//     4. Run the statement (also used to check the status of the handle).
		//     5. If the stmt completes, verify that it does so successfully. Test case 2.
		//
		//   Once all of the handles have completed, perform the next Async Operation
		//   until the terminating operation (a.k.a "999") is reached.
		k = 0;
		while (AsyncOper[k] != 999)
		{
			// 1. Preparing the async test data structure
			for (i = 0; i < NUM_ASYNC_STMT; i++)
			{
				AsyncStmt[i].status = SQL_STILL_EXECUTING;
				AsyncStmt[i].checked = FALSE;
			}
			AnyAsync = 1;
			// Testing begins
			while (AnyAsync > 0)
			{
				for (i = 0; i < NUM_ASYNC_STMT; i++)
				{
					if (AsyncStmt[i].status == SQL_STILL_EXECUTING)
					{
						// 3. Has the handle been checked for its status?
						if (AsyncStmt[i].checked)
						{
							// 4. Run the statement.
							returncode = SQLExecDirect(hstmt[i],StmtQueries(AsyncOper[k],teststmthndl[i],StmtHndlStr),SQL_NTS);
							AsyncStmt[i].status = returncode;
							// 5. Result Test: Verifying that the statement completes correctly.
							if (returncode != SQL_STILL_EXECUTING)
							{
								sprintf(Heading,"SQLAllocStmt: Result Test: %d; SQLStmt: %s.\n",i,StmtQueries(AsyncOper[k],teststmthndl[i],StmtHndlStr));
								TESTCASE_BEGIN(Heading);
								if (returncode != SQL_SUCCESS)
								{
									TEST_FAILED;
									LogAllErrors(henv,hdbc,hstmt[i]);
								}
								TESTCASE_END;
							}
						}
						else
						{
							// Status Test (Test case 1):
							// Only EXECUTING and SUCCESS are acceptable, others are errors.
							//   This test is only run once!
							sprintf(Heading,"SQLAllocStmt: Status Test: %d; SQLStmt: %s.\n",i,StmtQueries(AsyncOper[k],teststmthndl[i],StmtHndlStr));
							TESTCASE_BEGIN(Heading);
							
							// 4. Run the statement.
							returncode = SQLExecDirect(hstmt[i],StmtQueries(AsyncOper[k],teststmthndl[i],StmtHndlStr),SQL_NTS);
							AsyncStmt[i].status = returncode;
							AsyncStmt[i].checked = TRUE;
							if ((returncode != SQL_STILL_EXECUTING) && (returncode != SQL_SUCCESS))
							{
								TEST_FAILED;
								LogAllErrors(henv,hdbc,hstmt[i]);
							}
							TESTCASE_END;
							
							// 5. If the stmt completes, verify that it does so successfully.
							if (returncode != SQL_STILL_EXECUTING)
							{
								// Result Test: Verifying that the stmt completes successfully.
								sprintf(Heading,"SQLAllocStmt: Result Test: %d; SQLStmt: %s.\n",i,StmtQueries(AsyncOper[k],teststmthndl[i],StmtHndlStr));
								TESTCASE_BEGIN(Heading);
								if (returncode != SQL_SUCCESS)
								{
									TEST_FAILED;
									LogAllErrors(henv,hdbc,hstmt[i]);
								}
								TESTCASE_END;
							}
							//Sleep (500);
						}
					}
				}
				AnyAsync = 0;
				for (i = 0; i < NUM_ASYNC_STMT; i++)
				{
					if (AsyncStmt[i].status == SQL_STILL_EXECUTING)
					{
						AnyAsync = AnyAsync + 1;
					}
				}
			}

			// Special tests for Fetching after doing a SELECT
			// Steps are identical to the above steps.
			if (AsyncOper[k] == SELECT_TABLE)
			{
				// Preparing data structure
				for (i = 0; i < NUM_ASYNC_STMT; i++)
				{
					AsyncStmt[i].status = SQL_STILL_EXECUTING;
					AsyncStmt[i].checked = FALSE;
				}
				AnyAsync = 1;
				// Select testing begins
				while (AnyAsync > 0)
				{
					for (i = 0; i < NUM_ASYNC_STMT; i++)
					{
						if (AsyncStmt[i].status == SQL_STILL_EXECUTING)
						{
							if (AsyncStmt[i].checked)
							{
								returncode = SQLFetch(hstmt[i]);
								AsyncStmt[i].status = returncode;									
								if (returncode != SQL_STILL_EXECUTING)
								{
									// Result Test
									sprintf(Heading,"SQLAllocStmt: Result Test:%d; performing SQLFetch.\n",i);
									TESTCASE_BEGIN(Heading);
									if (returncode != SQL_SUCCESS)
									{
										TEST_FAILED;
										LogAllErrors(henv,hdbc,hstmt[i]);
									}
									TESTCASE_END;
								}
							}
							else
							{
								// Status Test
								sprintf(Heading,"SQLAllocStmt: Status Test:%d; performing SQLFetch.\n",i);
								TESTCASE_BEGIN(Heading);
								returncode = SQLFetch(hstmt[i]);
								AsyncStmt[i].status = returncode;
								AsyncStmt[i].checked = TRUE;
								if ((returncode != SQL_STILL_EXECUTING) && (returncode != SQL_SUCCESS))
								{
									TEST_FAILED;
									LogAllErrors(henv,hdbc,hstmt[i]);
								}
								TESTCASE_END;

								// Result Test
								if (returncode != SQL_STILL_EXECUTING)
								{
									sprintf(Heading,"SQLAllocStmt: Result Test:%d; performing SQLFetch.\n",i);
									TESTCASE_BEGIN(Heading);
									if (returncode != SQL_SUCCESS)
									{
										TEST_FAILED;
										LogAllErrors(henv,hdbc,hstmt[i]);
									}
									TESTCASE_END;
								}
							}
						}
					}
					AnyAsync = 0;
					for (i = 0; i < NUM_ASYNC_STMT; i++)
					{
						if (AsyncStmt[i].status == SQL_STILL_EXECUTING)
						{
							AnyAsync = AnyAsync + 1;
						}
					}
				}
				// Closing the cursor from the SELECT stmt result set.
				for (i = 0; i < NUM_ASYNC_STMT; i++)
				{
					sprintf(Heading,"SQLFreeStmt: %d.\n",i);
					TESTCASE_BEGIN(Heading);
					returncode = SQLFreeStmt(hstmt[i],SQL_CLOSE);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFreeStmt"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt[i]);
					}
					TESTCASE_END;
				}
			} // End of async SELECT test.

			// Resetting the checked status for the next operation.
			for (i = 0; i < NUM_ASYNC_STMT; i++)
			{
				AsyncStmt[i].checked = FALSE;
			}

			k++;
		}
	}
//====================================================================================================

	free(StmtHndlStr);
	returncode = SQLDisconnect((SQLHANDLE)hdbc);
    if(!CHECKRC(SQL_ERROR,returncode,"SQLDisconnect")) 
	{
		TEST_FAILED;	
		LogAllErrorsVer3(henv,hdbc,hstmt[0]);
	}	
	
	// Free the open transactions.
	returncode=SQLTransact((SQLHANDLE)henv,(SQLHANDLE)hdbc,SQL_ROLLBACK);
	Sleep(2);	

	returncode=FullDisconnect(pTestInfo);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFullDisconnect"))
	{
		TEST_FAILED;
		LogAllErrorsVer3(henv,hdbc,hstmt[0]);
	}
	
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => SQLAllocStmt.\n");

	free_list(var_list);

	TEST_RETURN;
}
Exemplo n.º 13
0
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;
}
Exemplo n.º 14
0
/*
---------------------------------------------------------
   TestSQLTransact
---------------------------------------------------------
*/
PassFail TestSQLTransact(TestInfo *pTestInfo)
{                  
	TEST_DECLARE;
	RETCODE			returncode;
	TCHAR			Heading[MAX_STRING_SIZE];
	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt;
	TCHAR			*ExecDirStr[6];
	UWORD			fType[] = { SQL_ROLLBACK,SQL_COMMIT };
	TCHAR			*TypeDesc[] = { _T("SQL_ROLLBACK"),_T("SQL_COMMIT") };
	TCHAR			*Output;
	SQLLEN			OutputLen;
	struct
	{
		SWORD	ExeRes[2];
		SWORD	FetchRes[2];
		TCHAR	*DataRes[2];
	} CheckRes[] =	
		{
			{SQL_ERROR,SQL_SUCCESS,SQL_NO_DATA_FOUND,SQL_NO_DATA_FOUND,_T(""),_T("")},
			{SQL_SUCCESS,SQL_SUCCESS,SQL_NO_DATA_FOUND,SQL_SUCCESS,_T(""),_T("--")},
			{SQL_SUCCESS,SQL_SUCCESS,SQL_SUCCESS,SQL_SUCCESS,_T("--"),_T("--")},
			{SQL_SUCCESS,SQL_SUCCESS,SQL_SUCCESS,SQL_NO_DATA_FOUND,_T("--"),_T("")},
			{SQL_SUCCESS,SQL_ERROR,SQL_NO_DATA_FOUND,SQL_NO_DATA_FOUND,_T(""),_T("")}
		};
	int	i = 0, j = 0, iend = 5, jend = 1, commit_on_off = 0;

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars(_T("SQLTransact"), charset_file);
	if (var_list == NULL) return FAILED;

	ExecDirStr[0] = var_mapping(_T("SQLTransact_ExecDirStr_0"), var_list);
	ExecDirStr[1] = var_mapping(_T("SQLTransact_ExecDirStr_1"), var_list);
	ExecDirStr[2] = var_mapping(_T("SQLTransact_ExecDirStr_2"), var_list);
	ExecDirStr[3] = var_mapping(_T("SQLTransact_ExecDirStr_3"), var_list);
	ExecDirStr[4] = var_mapping(_T("SQLTransact_ExecDirStr_4"), var_list);
	ExecDirStr[5] = var_mapping(_T("SQLTransact_ExecDirStr_5"), var_list);

	CheckRes[1].DataRes[1] = var_mapping(_T("SQLTransact_Insert"), var_list);
	CheckRes[2].DataRes[0] = var_mapping(_T("SQLTransact_Insert"), var_list);
	CheckRes[2].DataRes[1] = var_mapping(_T("SQLTransact_Update"), var_list);
	CheckRes[3].DataRes[0] = var_mapping(_T("SQLTransact_Update"), var_list);

//========================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API => SQLTransact.\n"));
	TEST_INIT;

	TESTCASE_BEGIN("Initializing SQLTransact test environment\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);
		FullDisconnect(pTestInfo);
		TEST_FAILED;
		TEST_RETURN;
	}
	
	for (commit_on_off = 0; commit_on_off < 10; commit_on_off++)
	{
		returncode = SQLSetConnectOption((SQLHANDLE)hdbc,SQL_AUTOCOMMIT,SQL_AUTOCOMMIT_ON);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetConnectOption"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			FullDisconnect(pTestInfo);
			TEST_FAILED;
			TEST_RETURN;
		}
		TESTCASE_END;
		SQLExecDirect(hstmt, (SQLTCHAR*)ExecDirStr[4], SQL_NTS); /* CLEANUP */
		for (i = 0; i <= (iend-1); i++)
		{
			_stprintf(Heading,_T("Test Positive Functionality of SQLTransact while Autocommit is ON and executing\n"));
			_tcscat(Heading, ExecDirStr[i]);
			_tcscat(Heading, _T("\n"));
			TESTCASE_BEGINW(Heading);
			
			returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i],SQL_NTS);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			}
		}
		SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[4],SQL_NTS); /* CLEANUP */
		returncode = SQLSetConnectOption((SQLHANDLE)hdbc,SQL_AUTOCOMMIT,SQL_AUTOCOMMIT_OFF);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetConnectOption"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			FullDisconnect(pTestInfo);
			TEST_FAILED;
			TEST_RETURN;
		}
		TESTCASE_END;
		
		for (i = 0; i <= (iend-1); i++)
		{
			for (j = 0; j <= jend; j++)
			{
				_stprintf(Heading,_T("Test Positive Functionality of SQLTransact while Autocommit is OFF and executing\n"));
				_tcscat(Heading, ExecDirStr[i]);
				_tcscat(Heading, _T(" & "));
				_tcscat(Heading, TypeDesc[j]);
				_tcscat(Heading, _T("\n"));
				TESTCASE_BEGINW(Heading);
				
				//MAY 9, 2014 - TURNING AUTOCOMMIT ON FOR DDLs FOR TRAF, AS DDLs ARE NOT SUPPORTED WITH AUTOCOMMIT OFF
				if (i == 4 || i == 0)
					SQLSetConnectOption((SQLHANDLE)hdbc, SQL_AUTOCOMMIT, SQL_AUTOCOMMIT_ON);
				returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[i],SQL_NTS);
				SQLSetConnectOption((SQLHANDLE)hdbc, SQL_AUTOCOMMIT, SQL_AUTOCOMMIT_OFF);
				if (!CHECKRC(SQL_SUCCESS, returncode, "SQLExecDirect"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				else
				{
					returncode=SQLTransact((SQLHANDLE)henv,(SQLHANDLE)hdbc,fType[j]);
					Sleep(2);																// tmf rollback is slower.
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLTransact"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}

					returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[iend],SQL_NTS);
					if(!CHECKRC(CheckRes[i].ExeRes[j],returncode,"SQLExecDirect"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					else
					{
						if (returncode == SQL_SUCCESS || returncode == SQL_SUCCESS_WITH_INFO)
						{
							Output = (TCHAR *)malloc(NAME_LEN);
							returncode=SQLBindCol(hstmt,1,SQL_C_TCHAR,Output,NAME_LEN,&OutputLen);
							if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
							{
								LogAllErrors(henv,hdbc,hstmt);
								TEST_FAILED;
							}
							else
							{
								returncode = SQLFetch(hstmt);
								if(!CHECKRC(CheckRes[i].FetchRes[j],returncode,"SQLFetch"))
								{
									LogAllErrors(henv,hdbc,hstmt);
									TEST_FAILED;
								}
								else
								{
									if (returncode != SQL_NO_DATA_FOUND && returncode != SQL_ERROR)
									{
										if (_tcscspn(CheckRes[i].DataRes[j],Output) == 0)
										{
											LogMsg(NONE,_T("expect: %s and actual: %s are matched\n"),Output,CheckRes[i].DataRes[j]);
										}	
										else
										{
											LogMsg(NONE,_T("expect: %s and actual: %s are not matched\n"),Output,CheckRes[i].DataRes[j]);
											TEST_FAILED;	
										}
									}
								}
								free(Output);
								SQLFreeStmt(hstmt,SQL_CLOSE);
							}
						}
					}
				}
				TESTCASE_END;
			}/* end j loop */
		}/* end i loop */
	}

//========================================================================================================

	SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[4],SQL_NTS); /* CLEANUP */
	returncode = SQLDisconnect((SQLHANDLE)hdbc);
    if(!CHECKRC(SQL_ERROR,returncode,"SQLDisconnect")) 
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		TEST_FAILED;	
	}	
	
	// Free the open transactions.
	returncode=SQLTransact((SQLHANDLE)henv,(SQLHANDLE)hdbc,SQL_ROLLBACK);
	Sleep(2);	

	returncode=FullDisconnect(pTestInfo);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFullDisconnect"))
	{
		LogAllErrorsVer3(henv,hdbc,hstmt);
		TEST_FAILED;
	}

	LogMsg(SHORTTIMESTAMP+LINEAFTER,_T("End testing API => SQLTransact.\n"));

	free_list(var_list);

	TEST_RETURN;
}
Exemplo n.º 15
0
/*
---------------------------------------------------------
   TestSQLMoreResults
---------------------------------------------------------
*/
PassFail TestSQLMoreResults(TestInfo *pTestInfo)
{                  
	TEST_DECLARE;
 	char			Heading[MAX_STRING_SIZE];
	RETCODE			returncode;
 	SQLHANDLE 		henv;
 	SQLHANDLE 		hdbc;
 	SQLHANDLE		hstmt;
	CHAR			*SetupStr[] =  { "--", "--", "--", "--", "--", "--", "--", "endloop" };
	CHAR			*TestStr[] = { "--", "--", "--", "--", "--","endloop" };
	int				cnt, fail = 0;
//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars("SQLMoreResults", charset_file);
	if (var_list == NULL) return FAILED;

	SetupStr[0] = var_mapping("SQLMoreResults_SetupStr_0", var_list);
	SetupStr[1] = var_mapping("SQLMoreResults_SetupStr_1", var_list);
	SetupStr[2] = var_mapping("SQLMoreResults_SetupStr_2", var_list);
	SetupStr[3] = var_mapping("SQLMoreResults_SetupStr_3", var_list);
	SetupStr[4] = var_mapping("SQLMoreResults_SetupStr_4", var_list);
	SetupStr[5] = var_mapping("SQLMoreResults_SetupStr_5", var_list);
	SetupStr[6] = var_mapping("SQLMoreResults_SetupStr_6", var_list);

	TestStr[0] = var_mapping("SQLMoreResults_TestStr_0", var_list);
	TestStr[1] = var_mapping("SQLMoreResults_TestStr_1", var_list);
	TestStr[2] = var_mapping("SQLMoreResults_TestStr_2", var_list);
	TestStr[3] = var_mapping("SQLMoreResults_TestStr_3", var_list);
	TestStr[4] = var_mapping("SQLMoreResults_TestStr_4", var_list);

//===========================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API =>SQLMoreResults | SQLMoreResults | moreres.c\n");

  TEST_INIT;
	returncode=FullConnect(pTestInfo);
   if (pTestInfo->hdbc == (SQLHANDLE)NULL)
	{
		TEST_FAILED;
		TEST_RETURN;
	}

	henv = pTestInfo->henv;
 	hdbc = pTestInfo->hdbc;
 	hstmt = (SQLHANDLE)pTestInfo->hstmt;
   	
	returncode = SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
  if (returncode == SQL_SUCCESS)
	{
		cnt = 0;
		while (_stricmp(SetupStr[cnt],"endloop") != 0)
		{
			returncode = SQLExecDirect(hstmt,(SQLCHAR*) SetupStr[cnt],SQL_NTS);
			if (returncode == SQL_ERROR)
				fail++;
			cnt++;
		}
		if (fail != cnt)
		{
			cnt = 0;
			while (_stricmp(TestStr[cnt],"endloop") != 0)
			{
				sprintf(Heading,"Positive Test SQLMoreResults for ");
				strcat(Heading,TestStr[cnt]);
				strcat(Heading,"\n");
				TESTCASE_BEGIN(Heading);
				returncode = SQLExecDirect(hstmt,(SQLCHAR*)TestStr[cnt],SQL_NTS);
				if (returncode == SQL_SUCCESS)
				{
					SQLFetch(hstmt);
					returncode=SQLMoreResults(hstmt);
					if(!CHECKRC(SQL_NO_DATA_FOUND,returncode,"SQLMoreResults"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt);
					}
				}
				TESTCASE_END;
				cnt++;
			}
			SQLExecDirect(hstmt,(SQLCHAR*)SetupStr[0],SQL_NTS); // CLEANUP 
			SQLExecDirect(hstmt,(SQLCHAR*)SetupStr[1],SQL_NTS); // CLEANUP 
		}
	}

//==============================================================================*/

	FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => SQLMoreResults.\n");
	free_list(var_list);
	TEST_RETURN;
}
Exemplo n.º 16
0
/*
---------------------------------------------------------
   TestSQLTablePrivileges
---------------------------------------------------------
*/
PassFail TestMXSQLTablePrivileges( TestInfo *pTestInfo)
{
	TEST_DECLARE;
 	char			Heading[MAX_HEADING_SIZE];
	/*  */char	ColumnWC4_TabOwner[NAME_LEN];
 	RETCODE			returncode;
 	SQLHANDLE 		henv = (SQLHANDLE)NULL;
 	SQLHANDLE 		hdbc = (SQLHANDLE)NULL;
 	SQLHANDLE		hstmt = (SQLHANDLE)NULL, hstmt1 = (SQLHANDLE)NULL;
	CHAR			TableQualifier[NAME_LEN],TableOwner[NAME_LEN],*TableStr;

	CHAR			*TableName;
	
	// CHAR			*Grantor; //Assume that we log on as role.user
	CHAR            Grantor[SQL_MAX_ROLENAME_LEN+2];

	CHAR			oTableQualifier[NAME_LEN];  
	CHAR			oTableOwner[NAME_LEN];
	CHAR			oTableName[NAME_LEN];
	CHAR			oGrantor[NAME_LEN];
	CHAR			oGrantee[NAME_LEN];
	CHAR			oPrivilege[NAME_LEN];
	CHAR			oIs_Grantable[3];

	SQLLEN		oTableQualifierlen;
	SQLLEN		oTableOwnerlen;
	SQLLEN		oTableNamelen;
	SQLLEN		oGrantorlen = SQL_NTS;
	SQLLEN		oGranteelen;
	SQLLEN		oPrivilegelen;
	SQLLEN		oIs_Grantablelen;

/*  */
	struct
	{
		CHAR		*Col;
		CHAR		*Grantee;
		CHAR		*Is_Grantable;
		CHAR		*Privilege;
	} TableCol[] = {
		{"--",SQ_GRANTEE,"YES","DELETE"},
		{"--",SQ_GRANTEE,"NO","DELETE,SELECT"},
		{"--",SQ_GRANTEE,"YES","SELECT"},
		{"--",SQ_GRANTEE,"NO","DELETE"},
		{"--",SQ_GRANTEE,"YES","INSERT"},
		{"--",SQ_GRANTEE,"NO","UPDATE"},
		{"--",SQ_GRANTEE,"YES","REFERENCES"},
		{"--",SQ_GRANTEE,"NO","SELECT"},
		{"--",SQ_GRANTEE,"YES","INSERT"},
		{"--",SQ_GRANTEE,"NO","REFERENCES"},
		{"--",SQ_GRANTEE,"YES","UPDATE"},
		{"--",SQ_GRANTEE,"NO","REFERENCES"},
		{"--",SQ_GRANTEE,"YES","UPDATE"},
		{"--",SQ_GRANTEE,"NO","INSERT",},
		{"--",SQ_GRANTEE,"YES","SELECT"},
		{"--",SQ_GRANTEE,"NO","REFERENCES,SELECT"},
		{"--",SQ_GRANTEE,"YES","DELETE,INSERT,SELECT"},
		{"--",SQ_GRANTEE,"NO","INSERT,REFERENCES,UPDATE"},
		{"--",SQ_GRANTEE,"YES","SELECT,DELETE,INSERT,UPDATE"},
		{"--",SQ_GRANTEE,"NO","DELETE,INSERT,REFERENCES,UPDATE",},
		{"--",SQ_GRANTEE,"YES","DELETE,INSERT,REFERENCES,SELECT,UPDATE"},
		{"--",SQ_GRANTEE,"NO","DELETE"},						//Bignum
		{"--",SQ_GRANTEE,"YES","SELECT"},					//Bignum
		{"--",SQ_GRANTEE,"NO","INSERT"},						//Bignum
		{"--",SQ_GRANTEE,"YES","UPDATE"},					//Bignum
		{"--",SQ_GRANTEE,"NO","REFERENCES"},					//Bignum
		{"--",SQ_GRANTEE,"YES","SELECT,DELETE,INSERT,UPDATE"},//Bignum
		{"--",SQ_GRANTEE,"NO","INSERT,REFERENCES,UPDATE"},	//Bignum
		{"endloop",}
	};

	struct
	{
		CHAR		*TabQua;
		CHAR		*TabOwner;
		CHAR		*TabName;
		RETCODE		CheckCode;
		int			isEscape;
	} ColumnWC[] = {								// wild cards from here 
							{"--","--","--", SQL_SUCCESS,0},// Have a row with all valid values here so that 
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_ERROR,0},
							{"--","--","--", SQL_ERROR,0},
							{"--","--","--", SQL_ERROR,0},
							{"--","--","--", SQL_ERROR,0},
							{"--","--","--", SQL_ERROR,0}, 
							{"--","--","--", SQL_ERROR,0}, 
							{"--","--","--", SQL_ERROR,0}, 
							{"--","--","--", SQL_ERROR,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							{"--","--","--", SQL_SUCCESS,0},
							//	Testing escape sequences
							{"--","--","--", SQL_SUCCESS,1},
							{"--","--","--", SQL_SUCCESS,1},
							{"--","--","--", SQL_SUCCESS,1},
							{"--","--","--", SQL_SUCCESS,1},
							{"endloop",}
						};

	struct
	{
		CHAR		*TabQua;
		SWORD		TabQuaLen;
		CHAR		*TabOwner;
		SWORD		TabOwnerLen;
		CHAR		*TabName;
		SWORD		TabNameLen;
		CHAR		*ColName;
		SWORD		ColNameLen;
	} ColumnWC2[] = {								//	wild cards from here
							{"--", (SWORD)-1, "--",(SWORD)-1, "--",(SWORD)-1, "", (SWORD)-1},
							{"--", (SWORD)4,  "--",(SWORD)2,  "--",(SWORD)2,  "", (SWORD)2},
//							{"TEST_CATALOG", (SWORD)0, "TEST_SCHEMA",(SWORD)0, "TEST_TABLE",(SWORD)0, "", (SWORD)0},
							{"endloop",}
						};

	int cols;
	int	iatt;
	SWORD numOfCols = 0;
	SWORD pcbDesc;
	SQLLEN pfDesc;
	CHAR cn[COLNAME_LEN];
	SWORD cl;
	SWORD st;
	SQLULEN cp;
	SWORD cs, cnull;
	CHAR rgbDesc[RGB_MAX_LEN];
	CHAR *CharOutput[12];
	SQLLEN stringlength;	//	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
				};

	CHAR	*TestColumn;
	int		i = 0, k = 0;

    struct {
        char cat[STR_LEN];
        char sch[STR_LEN];
        char tab[STR_LEN];
    } displayBuf;

//	DWORD	nSize;


//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars("SQLTablePrivileges", charset_file);
	if (var_list == NULL) return FAILED;

	TableName = var_mapping("SQLTablePrivileges_TableName", var_list);

	TestColumn = var_mapping("SQLTablePrivileges_TestColumn", var_list);

	TableCol[0].Col = var_mapping("SQLTablePrivileges_TableCol_Col_0", var_list);
	TableCol[1].Col = var_mapping("SQLTablePrivileges_TableCol_Col_1", var_list);
	TableCol[2].Col = var_mapping("SQLTablePrivileges_TableCol_Col_2", var_list);
	TableCol[3].Col = var_mapping("SQLTablePrivileges_TableCol_Col_3", var_list);
	TableCol[4].Col = var_mapping("SQLTablePrivileges_TableCol_Col_4", var_list);
	TableCol[5].Col = var_mapping("SQLTablePrivileges_TableCol_Col_5", var_list);
	TableCol[6].Col = var_mapping("SQLTablePrivileges_TableCol_Col_6", var_list);
	TableCol[7].Col = var_mapping("SQLTablePrivileges_TableCol_Col_7", var_list);
	TableCol[8].Col = var_mapping("SQLTablePrivileges_TableCol_Col_8", var_list);
	TableCol[9].Col = var_mapping("SQLTablePrivileges_TableCol_Col_9", var_list);
	TableCol[10].Col = var_mapping("SQLTablePrivileges_TableCol_Col_10", var_list);
	TableCol[11].Col = var_mapping("SQLTablePrivileges_TableCol_Col_11", var_list);
	TableCol[12].Col = var_mapping("SQLTablePrivileges_TableCol_Col_12", var_list);
	TableCol[13].Col = var_mapping("SQLTablePrivileges_TableCol_Col_13", var_list);
	TableCol[14].Col = var_mapping("SQLTablePrivileges_TableCol_Col_14", var_list);
	TableCol[15].Col = var_mapping("SQLTablePrivileges_TableCol_Col_15", var_list);
	TableCol[16].Col = var_mapping("SQLTablePrivileges_TableCol_Col_16", var_list);
	TableCol[17].Col = var_mapping("SQLTablePrivileges_TableCol_Col_17", var_list);
	TableCol[18].Col = var_mapping("SQLTablePrivileges_TableCol_Col_18", var_list);
	TableCol[19].Col = var_mapping("SQLTablePrivileges_TableCol_Col_19", var_list);
	TableCol[20].Col = var_mapping("SQLTablePrivileges_TableCol_Col_20", var_list);
	TableCol[21].Col = var_mapping("SQLTablePrivileges_TableCol_Col_21", var_list);
	TableCol[22].Col = var_mapping("SQLTablePrivileges_TableCol_Col_22", var_list);
	TableCol[23].Col = var_mapping("SQLTablePrivileges_TableCol_Col_23", var_list);
	TableCol[24].Col = var_mapping("SQLTablePrivileges_TableCol_Col_24", var_list);
	TableCol[25].Col = var_mapping("SQLTablePrivileges_TableCol_Col_25", var_list);
	TableCol[26].Col = var_mapping("SQLTablePrivileges_TableCol_Col_26", var_list);
	TableCol[27].Col = var_mapping("SQLTablePrivileges_TableCol_Col_27", var_list);

	ColumnWC[0].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_0", var_list);
	ColumnWC[0].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_0", var_list);
	ColumnWC[0].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_0", var_list);

	ColumnWC[1].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_1", var_list);
	ColumnWC[1].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_1", var_list);
	ColumnWC[1].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_1", var_list);

	ColumnWC[2].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_2", var_list);
	ColumnWC[2].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_2", var_list);
	ColumnWC[2].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_2", var_list);

	ColumnWC[3].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_3", var_list);
	ColumnWC[3].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_3", var_list);
	ColumnWC[3].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_3", var_list);

	ColumnWC[4].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_4", var_list);
        ColumnWC[4].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_4", var_list); 
	ColumnWC[4].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_4", var_list);

	ColumnWC[5].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_5", var_list);
	ColumnWC[5].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_5", var_list);
	ColumnWC[5].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_5", var_list);

	ColumnWC[6].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_6", var_list);
	ColumnWC[6].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_6", var_list);
	ColumnWC[6].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_6", var_list);

	ColumnWC[7].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_7", var_list);
	ColumnWC[7].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_7", var_list);
	ColumnWC[7].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_7", var_list);

	ColumnWC[8].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_8", var_list);
	ColumnWC[8].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_8", var_list);
	ColumnWC[8].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_8", var_list);

	ColumnWC[9].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_9", var_list);
	ColumnWC[9].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_9", var_list);
	ColumnWC[9].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_9", var_list);

	ColumnWC[10].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_10", var_list);
	ColumnWC[10].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_10", var_list);
	ColumnWC[10].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_10", var_list);

	ColumnWC[11].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_11", var_list);
	ColumnWC[11].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_11", var_list);
	ColumnWC[11].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_11", var_list);

	ColumnWC[12].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_12", var_list);
	ColumnWC[12].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_12", var_list);
	ColumnWC[12].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_12", var_list);

	ColumnWC[13].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_13", var_list);
	ColumnWC[13].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_13", var_list);
	ColumnWC[13].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_13", var_list);

	ColumnWC[14].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_14", var_list);
	ColumnWC[14].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_14", var_list);
	ColumnWC[14].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_14", var_list);

	ColumnWC[15].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_15", var_list);
	ColumnWC[15].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_15", var_list);
	ColumnWC[15].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_15", var_list);

	ColumnWC[16].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_16", var_list);
	ColumnWC[16].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_16", var_list);
	ColumnWC[16].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_16", var_list);

	ColumnWC[17].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_17", var_list);
	ColumnWC[17].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_17", var_list);
	ColumnWC[17].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_17", var_list);

	ColumnWC[18].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_18", var_list);
	ColumnWC[18].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_18", var_list);
	ColumnWC[18].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_18", var_list);

	ColumnWC[19].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_19", var_list);
	ColumnWC[19].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_19", var_list);
	ColumnWC[19].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_19", var_list);

	ColumnWC[20].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_20", var_list);
	ColumnWC[20].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_20", var_list);
	ColumnWC[20].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_20", var_list);

	ColumnWC[21].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_21", var_list);
	ColumnWC[21].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_21", var_list);
	ColumnWC[21].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_21", var_list);

	ColumnWC[22].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_22", var_list);
	ColumnWC[22].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_22", var_list);
	ColumnWC[22].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_22", var_list);

	ColumnWC[23].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_23", var_list);
	ColumnWC[23].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_23", var_list);
	ColumnWC[23].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_23", var_list);

	ColumnWC[24].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_24", var_list);
	ColumnWC[24].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_24", var_list);
	ColumnWC[24].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_24", var_list);

	ColumnWC[25].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_25", var_list);
	ColumnWC[25].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_25", var_list);
	ColumnWC[25].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_25", var_list);

	ColumnWC[26].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_26", var_list);
	ColumnWC[26].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_26", var_list);
	ColumnWC[26].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_26", var_list);

	ColumnWC[27].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_27", var_list);
	ColumnWC[27].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_27", var_list);
	ColumnWC[27].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_27", var_list);

	ColumnWC[28].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_28", var_list);
	ColumnWC[28].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_28", var_list);
	ColumnWC[28].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_28", var_list);

	ColumnWC[29].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_29", var_list);
	ColumnWC[29].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_29", var_list);
	ColumnWC[29].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_29", var_list);

	ColumnWC[30].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_30", var_list);
	ColumnWC[30].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_30", var_list);
	ColumnWC[30].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_30", var_list);

	ColumnWC[31].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_31", var_list);
	ColumnWC[31].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_31", var_list);
	ColumnWC[31].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_31", var_list);

	ColumnWC[32].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_32", var_list);
	ColumnWC[32].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_32", var_list);
	ColumnWC[32].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_32", var_list);

	ColumnWC[33].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_33", var_list);
	ColumnWC[33].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_33", var_list);
	ColumnWC[33].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_33", var_list);

	ColumnWC[34].TabQua = var_mapping("SQLTablePrivileges_ColumnWC_TabQua_34", var_list);
	ColumnWC[34].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC_TabOwner_34", var_list);
	ColumnWC[34].TabName = var_mapping("SQLTablePrivileges_ColumnWC_TabName_34", var_list);

	ColumnWC2[0].TabQua = var_mapping("SQLTablePrivileges_ColumnWC2_TabQua_0", var_list);
	ColumnWC2[0].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC2_TabOwner_0", var_list);
	ColumnWC2[0].TabName = var_mapping("SQLTablePrivileges_ColumnWC2_TabName_0", var_list);

	ColumnWC2[1].TabQua = var_mapping("SQLTablePrivileges_ColumnWC2_TabQua_1", var_list);
	ColumnWC2[1].TabOwner = var_mapping("SQLTablePrivileges_ColumnWC2_TabOwner_1", var_list);
	ColumnWC2[1].TabName = var_mapping("SQLTablePrivileges_ColumnWC2_TabName_1", var_list);

//=================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing API => SQLTablePrivileges | SQLTablePriv | tabpriv.c\n");

	TEST_INIT;

	TESTCASE_BEGIN("Setup for SQLTablePrivileges tests\n");

	if(!FullConnectWithOptions(pTestInfo, CONNECT_ODBC_VERSION_3))
	{
		LogMsg(NONE,"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;
	}

#ifdef LDAP
	// Grantor = var_mapping("SQLTablePrivileges_Grantor", var_list);
/*
	returncode = SQLGetConnectAttr(hdbc, (SQLINTEGER)SQL_ATTR_ROLENAME, (SQLCHAR*)Grantor, SQL_MAX_ROLENAME_LEN+2, (SQLINTEGER *) &oGrantorlen);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetConnectAttr"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
*/
/* hardcode it for now */ strcpy (Grantor, "DB__ROOT");
#else
        sprintf(Grantor, "%s", var_mapping("SQLTablePrivileges_Grantor", var_list)); 
#endif

	LogMsg(NONE,"Grantor is: %s\n", Grantor);

	TESTCASE_END;  // end of setup
 
	strcpy(TableQualifier,pTestInfo->Catalog);
	strcpy(TableOwner,pTestInfo->Schema);

	TableStr = (char *)malloc(MAX_NOS_SIZE);
	i = 0;
	while (_stricmp(TableCol[i].Col,"endloop") != 0)
	{
		sprintf(Heading,"Test #%d\n",i);
		TESTCASE_BEGIN(Heading);

		if (_stricmp(TableCol[i].Privilege,"ALL PRIVILEGES") == 0)
			strcpy(TableCol[i].Privilege,"DELETE");

		// clean up left over table, if any.  We don't care about returncode from SQLExecDirect
		sprintf(TableStr,"drop table %s",TableName);
		SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);
		
		// create table to test against
		sprintf(TableStr,"create table %s (%s) no partition;",TableName,TableCol[i].Col);
		returncode = SQLExecDirect(hstmt,(SQLCHAR*)TableStr,SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
		}
		else
		{
			// execute GRANT statement to set up some table privileges
			sprintf(TableStr,"GRANT %s ON %s TO \"%s\"",TableCol[i].Privilege,TableName,TableCol[i].Grantee);
			if (_stricmp(TableCol[i].Is_Grantable,"YES") == 0)
				strcat(TableStr, " WITH GRANT OPTION");
			LogMsg(NONE,"%s\n",TableStr);
			returncode = SQLExecDirect(hstmt,(SQLCHAR*)TableStr,SQL_NTS);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			}
			else
			{
				// Execute SQLTablePrivileges for test table
				if (strlen(TableQualifier) == 0)
					returncode = SQLTablePrivileges(hstmt,NULL,0,(SQLCHAR*)TableOwner,(SWORD)strlen(TableOwner),(SQLCHAR*)TableName,(SWORD)strlen(TableName));
				else
					returncode = SQLTablePrivileges(hstmt,(SQLCHAR*)TableQualifier,(SWORD)strlen(TableQualifier),(SQLCHAR*)TableOwner,(SWORD)strlen(TableOwner),(SQLCHAR*)TableName,(SWORD)strlen(TableName));
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLTablePrivileges"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
				}
				else
				{
					LogMsg(NONE,"SQLTablePrivileges function call executed correctly.\n");

					// clear all buffers
					strcpy(oTableQualifier,"");
					strcpy(oTableOwner,"");
					strcpy(oTableName,"");
					strcpy(oGrantor,"");
					strcpy(oGrantee,"");
					strcpy(oPrivilege,"");
					strcpy(oIs_Grantable,"");

					// Bind all columns to recieve data returned from SQLTablePrivileges
					returncode = SQLBindCol(hstmt,1,SQL_C_CHAR,oTableQualifier,NAME_LEN,&oTableQualifierlen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					} 
					returncode = SQLBindCol(hstmt,2,SQL_C_CHAR,oTableOwner,NAME_LEN,&oTableOwnerlen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					returncode = SQLBindCol(hstmt,3,SQL_C_CHAR,oTableName,NAME_LEN,&oTableNamelen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					returncode = SQLBindCol(hstmt,4,SQL_C_CHAR,oGrantor,NAME_LEN,&oGrantorlen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					returncode = SQLBindCol(hstmt,5,SQL_C_CHAR,oGrantee,NAME_LEN,&oGranteelen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					returncode = SQLBindCol(hstmt,6,SQL_C_CHAR,oPrivilege,NAME_LEN,&oPrivilegelen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					returncode = SQLBindCol(hstmt,7,SQL_C_CHAR,oIs_Grantable,NAME_LEN,&oIs_Grantablelen);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
					{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
					}
					
					
					// Loop, reading and checking all data retuned from SQLTablePrivileges call
					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 
						{
							// check for SQL_SUCCESS in case SQL_NO_DATA_FOUND was what was returned
							// compare results for rows where oGrantor is not the same as Grantor (super.super)
							if ((returncode == SQL_SUCCESS) && (_stricmp(Grantor,oGrantor) == 0) && (_stricmp(TableCol[i].Grantee,oGrantee) == 0))
							{
								k++;	// found a match, increment counter
								if ((_stricmp(TableQualifier,oTableQualifier) == 0) 
									&& (cstrcmp(TableOwner,oTableOwner,TRUE,isCharSet) == 0) 
									&& (cstrcmp(TableName,oTableName,TRUE,isCharSet) == 0) 
									//&& (_stricmp(oGrantor,Grantor) == 0) 
									//&& (_stricmp(TableCol[i].Grantee,oGrantee) == 0) // NOT NEEDED
									&& (strstr(TableCol[i].Privilege,oPrivilege) != NULL) 
									&& (_stricmp(TableCol[i].Is_Grantable,oIs_Grantable) == 0) )
								{
									LogMsg(NONE,"SQLTablePrivileges: compare results of rows fetched for following column.\n");
									LogMsg(NONE,"TableQualifier expect: %s and actual: %s are matched\n",TableQualifier,oTableQualifier);
									LogMsg(NONE,"TableOwner expect: %s and actual: %s are matched\n",TableOwner,oTableOwner);
									LogMsg(NONE,"TableName expect: %s and actual: %s are matched\n",TableName,oTableName);
									LogMsg(NONE,"Grantor expect: %s and actual: %s are matched\n",Grantor,oGrantor);
									LogMsg(NONE,"Grantee expect: %s and actual: %s are matched\n",TableCol[i].Grantee,oGrantee);
									LogMsg(NONE,"Privilege expect: %s and actual: %s are matched\n",TableCol[i].Privilege,oPrivilege);
									LogMsg(NONE,"Is_Grantable expect: %s and actual: %s are matched\n",TableCol[i].Is_Grantable,oIs_Grantable);
								}
								else
								{
									TEST_FAILED;	
									LogMsg(NONE,"SQLTablePrivileges: compare results of rows fetched for following column failed line %d.\n", __LINE__);
									if (_stricmp(TableQualifier,oTableQualifier) != 0)
										LogMsg(ERRMSG,"TableQualifier expect: %s and actual: %s are not matched\n",TableQualifier,oTableQualifier);
									if (cstrcmp(TableOwner,oTableOwner,TRUE,isCharSet) != 0) 
										LogMsg(ERRMSG,"TableOwner expect: %s and actual: %s are not matched\n",TableOwner,oTableOwner);
									if (cstrcmp(TableName,oTableName,TRUE,isCharSet) != 0) 
										LogMsg(ERRMSG,"TableName expect: %s and actual: %s are not matched\n",TableName,oTableName);
									//if (_stricmp(oGrantor,Grantor) != 0)
									//	LogMsg(ERRMSG,"Grantor expect: %s and actual: %s are not matched\n",Grantor,oGrantor);
									//if (_stricmp(TableCol[i].Grantee,oGrantee) != 0)
									//	LogMsg(ERRMSG,"Grantee expect: %s and actual: %s are not matched\n",TableCol[i].Grantee,oGrantee);
									if (strstr(TableCol[i].Privilege,oPrivilege) == NULL)
										LogMsg(ERRMSG,"Privilege expect: %s and actual: %s are not matched\n",TableCol[i].Privilege,oPrivilege);
									if (_stricmp(TableCol[i].Is_Grantable,oIs_Grantable) != 0)
										LogMsg(ERRMSG,"Is_Grantable expect: %s and actual: %s are not matched\n",TableCol[i].Is_Grantable,oIs_Grantable);
								}
							}
						}
					}
					if(k == 0){
						TEST_FAILED;
						LogMsg(ERRMSG,"No matching grantee record for '%s' found\n"
										  "   At least one row fetched should have matched\n",
										  TableCol[i].Grantee);
						}
					SQLFreeStmt(hstmt,SQL_UNBIND);
					SQLFreeStmt(hstmt,SQL_CLOSE);
				}
			}
		}
		TESTCASE_END;
		
		// clean up SQL table
		sprintf(TableStr,"drop table %s",TableName);
		SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);
		i++;
	} 

//=======================================================================================

	i = 0;
	sprintf(TableStr,"drop table %s.%s.%s",ColumnWC[i].TabQua, ColumnWC[i].TabOwner, ColumnWC[i].TabName);
	SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);
	LogMsg(NONE,"%s\n",TableStr);
	sprintf(TableStr,"drop schema %s.%s cascade",ColumnWC[i].TabQua, ColumnWC[i].TabOwner);
	SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);
	LogMsg(NONE,"%s\n",TableStr);

	sprintf(TableStr,"create schema %s.%s",ColumnWC[i].TabQua, ColumnWC[i].TabOwner);
	LogMsg(NONE,"%s\n",TableStr);
	returncode = SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
	}
	else
	{
		sprintf(TableStr,"create table %s.%s.%s(%s char(10)) no partition;",ColumnWC[i].TabQua, ColumnWC[i].TabOwner, ColumnWC[i].TabName, TestColumn);
		returncode = SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
		}
	}
	LogMsg(NONE,"%s\n",TableStr);
	returncode = SQLSetStmtAttr(hstmt,SQL_ATTR_METADATA_ID,(SQLPOINTER)SQL_FALSE,0);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetStmtAttr"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}// end of setup
	if (returncode == SQL_SUCCESS) 
	{
		while ((_stricmp(ColumnWC[i].TabQua,"endloop") != 0) && (ColumnWC[i].isEscape == 0))
		{
			sprintf(Heading,"SQLTablePrivileges: wildcard options => \n"
				"Table Qualifier: %s \nTable Owner: %s \nTable Name: %s\n", 
				printSymbol(ColumnWC[i].TabQua,displayBuf.cat), 
				printSymbol(ColumnWC[i].TabOwner,displayBuf.sch), 
				printSymbol(ColumnWC[i].TabName,displayBuf.tab));
			TESTCASE_BEGIN(Heading);
			if (_stricmp(ColumnWC[i].TabQua,"NULL") == 0)
				ColumnWC[i].TabQua = NULL;
			if (_stricmp(ColumnWC[i].TabOwner,"NULL") == 0)
				ColumnWC[i].TabOwner = NULL;
			if (_stricmp(ColumnWC[i].TabName,"NULL") == 0)
				ColumnWC[i].TabName = NULL;

			if (ColumnWC[i].TabQua == NULL || ColumnWC[i].TabOwner == NULL || ColumnWC[i].TabName == NULL)
				returncode = SQLTablePrivileges(hstmt,(SQLCHAR*)ColumnWC[i].TabQua,SQL_NTS,
                                                      (SQLCHAR*)ColumnWC[i].TabOwner,SQL_NTS,
                                                      (SQLCHAR*)removeQuotes(ColumnWC[i].TabName,displayBuf.tab),SQL_NTS);
			else
				returncode = SQLTablePrivileges(hstmt,(SQLCHAR*)ColumnWC[i].TabQua,(SWORD)strlen(ColumnWC[i].TabQua),
                                                      (SQLCHAR*)ColumnWC[i].TabOwner,(SWORD)strlen(ColumnWC[i].TabOwner),
                                                      (SQLCHAR*)removeQuotes(ColumnWC[i].TabName,displayBuf.tab),(SWORD)strlen(displayBuf.tab));
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLTablePrivileges"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
			}
			else
			{
				LogMsg(NONE,"SQLTablePrivileges: SQLTablePrivileges function call executed correctly.\n");
				strcpy(oTableQualifier,"");
				strcpy(oTableOwner,"");
				strcpy(oTableName,"");
				strcpy(oGrantor,"");
				strcpy(oGrantee,"");
				strcpy(oPrivilege,"");
				strcpy(oIs_Grantable,"");
				returncode = SQLBindCol(hstmt,1,SQL_C_CHAR,oTableQualifier,NAME_LEN,&oTableQualifierlen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				} 
				returncode = SQLBindCol(hstmt,2,SQL_C_CHAR,oTableOwner,NAME_LEN,&oTableOwnerlen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,3,SQL_C_CHAR,oTableName,NAME_LEN,&oTableNamelen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}

				returncode = SQLBindCol(hstmt,4,SQL_C_CHAR,oGrantor,NAME_LEN,&oGrantorlen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,5,SQL_C_CHAR,oGrantee,NAME_LEN,&oGranteelen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				
				returncode = SQLBindCol(hstmt,6,SQL_C_CHAR,oPrivilege,NAME_LEN,&oPrivilegelen);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
						LogAllErrors(henv,hdbc,hstmt);
						TEST_FAILED;
				}
				returncode = SQLBindCol(hstmt,7,SQL_C_CHAR,oIs_Grantable,NAME_LEN,&oIs_Grantablelen);
				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")))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt);
					}
					if (returncode == SQL_SUCCESS)
						k++;
				}
				if(k == 0 && ColumnWC[i].CheckCode == SQL_SUCCESS)
				{
					if(ColumnWC[i].isEscape == 1)
						LogMsg(ERRMSG, "Search string pattern in Catalog's Name is not supported\n");
					else {
						TEST_FAILED;
						LogMsg(ERRMSG,"No Data Found => Atleast one row should be fetched\n");
					}
				}
			}
			SQLFreeStmt(hstmt,SQL_CLOSE);
			TESTCASE_END;
			i++;
		}
	}

//======================================================================================================

	TESTCASE_BEGIN("SQLTablePrivileges: Negative test with invalid handle.\n");

	i = 0;
	returncode = SQLTablePrivileges(hstmt1,(SQLCHAR*)ColumnWC[i].TabQua,(SWORD)strlen(ColumnWC[i].TabQua),(SQLCHAR*)ColumnWC[i].TabOwner,(SWORD)strlen(ColumnWC[i].TabOwner),(SQLCHAR*)ColumnWC[i].TabName,(SWORD)strlen(ColumnWC[i].TabName));
	if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLTables"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	TESTCASE_END;

//=========================================================================================

	TESTCASE_BEGIN("SQLTables: Negative test with NULL handle.\n");

	hstmt1 = (SQLHANDLE)NULL;
	i = 0;
	returncode = SQLTablePrivileges(hstmt1,(SQLCHAR*)ColumnWC[i].TabQua,(SWORD)strlen(ColumnWC[i].TabQua),(SQLCHAR*)ColumnWC[i].TabOwner,(SWORD)strlen(ColumnWC[i].TabOwner),(SQLCHAR*)ColumnWC[i].TabName,(SWORD)strlen(ColumnWC[i].TabName));
	if(!CHECKRC(SQL_INVALID_HANDLE,returncode,"SQLTables"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	TESTCASE_END;

//=========================================================================================

	TESTCASE_BEGIN("SQLTablePrivileges: Negative test with invalid arg lengths.\n");

	returncode = SQLTablePrivileges(hstmt,(SQLCHAR*)ColumnWC2[0].TabQua,ColumnWC2[0].TabQuaLen,(SQLCHAR*)ColumnWC2[0].TabOwner,ColumnWC2[0].TabOwnerLen,(SQLCHAR*)ColumnWC2[0].TabName,ColumnWC2[0].TabNameLen);
	LogMsg(NONE, "Input parameters: CatalogLen %d SchemaLen %d TableLen %d\n", ColumnWC2[0].TabQuaLen, ColumnWC2[0].TabOwnerLen, ColumnWC2[0].TabNameLen);
	if(!CHECKRC(SQL_ERROR,returncode,"SQLTablePrivileges"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}

	TESTCASE_END;

//=========================================================================================

	TESTCASE_BEGIN("SQLTablePrivileges: Positive test with invalid arg lengths.\n");

	returncode = SQLTablePrivileges(hstmt,(SQLCHAR*)ColumnWC2[1].TabQua,ColumnWC2[1].TabQuaLen,(SQLCHAR*)ColumnWC2[1].TabOwner,ColumnWC2[1].TabOwnerLen,(SQLCHAR*)ColumnWC2[1].TabName,ColumnWC2[1].TabNameLen);
	LogMsg(NONE, "Input parameters: CatalogLen %d SchemaLen %d TableLen %d\n", ColumnWC2[1].TabQuaLen, ColumnWC2[1].TabOwnerLen, ColumnWC2[1].TabNameLen);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLTablePrivileges"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}
	else {
		LogMsg(NONE,"SQLTablePrivileges: SQLTablePrivileges function call executed correctly.\n");
		strcpy(oTableQualifier,"");
		strcpy(oTableOwner,"");
		strcpy(oTableName,"");
		strcpy(oGrantor,"");
		strcpy(oGrantee,"");
		strcpy(oPrivilege,"");
		strcpy(oIs_Grantable,"");
		returncode = SQLBindCol(hstmt,1,SQL_C_CHAR,oTableQualifier,NAME_LEN,&oTableQualifierlen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
		{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
		} 
		returncode = SQLBindCol(hstmt,2,SQL_C_CHAR,oTableOwner,NAME_LEN,&oTableOwnerlen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
		{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
		}
		returncode = SQLBindCol(hstmt,3,SQL_C_CHAR,oTableName,NAME_LEN,&oTableNamelen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
		{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
		}
		returncode = SQLBindCol(hstmt,4,SQL_C_CHAR,oGrantor,NAME_LEN,&oGrantorlen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
		{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
		}
		returncode = SQLBindCol(hstmt,5,SQL_C_CHAR,oGrantee,NAME_LEN,&oGranteelen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
		{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
		}
		
		returncode = SQLBindCol(hstmt,6,SQL_C_CHAR,oPrivilege,NAME_LEN,&oPrivilegelen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
		{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
		}
		returncode = SQLBindCol(hstmt,7,SQL_C_CHAR,oIs_Grantable,NAME_LEN,&oIs_Grantablelen);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
		{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
		}
		k = 0;
		while (returncode == SQL_SUCCESS) 
		{
			returncode = SQLFetch(hstmt);
			if (returncode == SQL_SUCCESS) k++;
		}
		if(k > 0)
		{
			TEST_FAILED;
			LogMsg(ERRMSG,"Should be no data found - check for similar objects unintentionally appear\n");
		}
	}

	TESTCASE_END;

//=========================================================================================

	TESTCASE_BEGIN("Testing SQLColAttribute, SQLDescribeCol, SQLBindCol and SQLFetch functions for catalog names.\n");

	returncode = SQLSetStmtAttr(hstmt,SQL_ATTR_METADATA_ID,(SQLPOINTER)SQL_FALSE,0);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetStmtAttr"))
	{
		TEST_FAILED;
		LogAllErrors(henv,hdbc,hstmt);
	}// end of setup

	for(i = 0; i < 5; i++)
	{
		sprintf(Heading,"======================================\n"
						"SQLTablePrivileges: wildcard options => \n"
						"Table Qualifier: %s \nTable Owner: %s \nTable Name: %s\n", 
						printSymbol(ColumnWC[i].TabQua,displayBuf.cat), 
						printSymbol(ColumnWC[i].TabOwner,displayBuf.sch), 
						printSymbol(ColumnWC[i].TabName,displayBuf.tab));
		LogMsg(NONE,Heading);

		returncode = SQLTablePrivileges(hstmt,(SQLCHAR*)ColumnWC[i].TabQua,(SWORD)strlen(ColumnWC[i].TabQua),
											  (SQLCHAR*)removeQuotes(ColumnWC[i].TabOwner, displayBuf.sch),(SWORD)strlen(displayBuf.sch),
											  (SQLCHAR*)removeQuotes(ColumnWC[i].TabName, displayBuf.tab),(SWORD)strlen(displayBuf.tab));
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLColumns"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		LogMsg(NONE,"after the call\n");

		returncode = SQLNumResultCols(hstmt, &numOfCols);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultsCol"))
		{
			TEST_FAILED;
			LogMsg(ERRMSG,"Test failed while executing call for SQLNUMRESULTSCOL");
			LogAllErrors(henv,hdbc,hstmt);
		}
		for(cols = 0; cols < numOfCols; cols++)
		{
			returncode = SQLDescribeCol(hstmt,(SWORD)(cols+1),(SQLCHAR*)cn,COLNAME_LEN,&cl,&st,&cp,&cs,&cnull);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLDescribeCol"))
			{
				TEST_FAILED;
				LogMsg(ERRMSG,"Test failed while executing call for SQLDESCRIBECOL of column");
				LogAllErrors(henv,hdbc,hstmt);
			}
			CharOutput[cols] = (char *)malloc(STR_LEN);
			for (iatt = 0; iatt <= TOTALATTRIBS; iatt++)
			{
				strcpy(rgbDesc,"");
				pcbDesc = 0;
				pfDesc = 0;
				returncode = SQLColAttributes(hstmt,(SWORD)(cols+1),DescrType[iatt],rgbDesc,STR_LEN,&pcbDesc,&pfDesc);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLColAttribute"))
				{
					TEST_FAILED;
					LogMsg(ERRMSG,"Test failed while executing call for SQLCOLATTRIBUTES of column : %d.\n",i+1);
					LogAllErrors(henv,hdbc,hstmt);
				}
			}
			returncode = SQLBindCol(hstmt,(SWORD)(cols+1),SQL_C_CHAR,CharOutput[cols],STR_LEN,&stringlength);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
			{
				TEST_FAILED;
				LogMsg(ERRMSG,"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_ERROR)
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			} else if (returncode == SQL_NO_DATA_FOUND) {
				break;
			}
			else {
				if (returncode == SQL_SUCCESS_WITH_INFO)
					LogAllErrors(henv,hdbc,hstmt);
				k++;
			}
		}
		if(k == 0)
		{
			TEST_FAILED;
			LogMsg(ERRMSG,"No Data Found => Atleast one row should be fetched\n");
		}
		
		for(cols = 0; cols < numOfCols; cols++)
		{
			free(CharOutput[cols]);
		}
		TESTCASE_END;
	}

//=========================================================================================
	// Cleanup
	i=0;
	sprintf(TableStr,"drop table %s.%s.%s",ColumnWC[i].TabQua, ColumnWC[i].TabOwner, ColumnWC[i].TabName);
	SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);
	sprintf(TableStr,"drop schema %s.%s cascade",ColumnWC[i].TabQua, ColumnWC[i].TabOwner);
	SQLExecDirect(hstmt,(SQLCHAR*) TableStr,SQL_NTS);

	FullDisconnect3(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing API => SQLTablePrivileges.\n");
	free(TableStr); 
	free_list(var_list);
	TEST_RETURN;
}
Exemplo n.º 17
0
PassFail TestSQLFetch(TestInfo *pTestInfo)
{   
	TEST_DECLARE;
 	TCHAR				Heading[MAX_STRING_SIZE];
 	RETCODE				returncode;
 	SQLHANDLE 			henv;
 	SQLHANDLE 			hdbc;
 	SQLHANDLE			hstmt;
	SQLUSMALLINT		i, j, k, fn, h;
	SWORD				col;
	TCHAR				*CCharOutput1[MAX_NUM1], CCharOutput2[NAME_LEN];
	SQLLEN				OutputLen1[MAX_NUM1], OutputLen2;
	SQLSMALLINT			CType[] = {SQL_C_TCHAR};
	//TCHAR					*TestCType[] = 
	//							{
	//								"SQL_C_TCHAR","SQL_C_BINARY","SQL_C_SSHORT","SQL_C_USHORT","SQL_C_SHORT","SQL_C_SLONG",
	//								"SQL_C_ULONG","SQL_C_FLOAT","SQL_C_DOUBLE","SQL_C_DATE","SQL_C_TIME","SQL_C_TIMESTAMP"
	//							};
	//TCHAR					*TestSQLType[] = 
	//							{
	//								"SQL_CHAR","SQL_VARCHAR","SQL_DECIMAL","SQL_NUMERIC","SQL_SMALLINT","SQL_INTEGER","SQL_REAL",
	//								"SQL_FLOAT","SQL_DOUBLE","SQL_DATE","SQL_TIME","SQL_TIMESTAMP","SQL_BIGINT",
	//								"SQL_DECIMAL","SQL_DECIMAL","SQL_DECIMAL","SQL_DECIMAL","SQL_DECIMAL","SQL_DECIMAL","SQL_DECIMAL","SQL_DECIMAL"
	//								"SQL_LONGVARCHAR","SQL_WCHAR","SQL_WVARCHAR","SQL_WLONGVARCHAR"
	//							};
	TCHAR					*ExecDirStr[5];
	TCHAR					*CResults[] = 
								{
#ifndef _WM
									_T("--"),_T("--"),_T("1234.56789"),_T("1234.56789"),_T("1200"),_T("12000"),
									_T("12345.0"),_T("123450.0"),_T("1234500.0"),_T("1993-07-01"),_T("09:45:30"),
									_T("1993-08-02 08:44:31.001000"),_T("120000"),
									_T("1234567890123456789"),
									_T("1234567890123.456789"),
									_T("1234567890123456789012345678901234567890"),
									_T("0.12345678901234567890123456789012345678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
									_T("1234567890.1234567890123456789012345678901234567890000000000000000000000000"),
									_T("12345.56789"),
									_T("1234567890123.56789"),
									_T("12345678901234567890.0123456789"),
#ifdef UNICODE
									_T("--"),_T("--"),_T("--"),_T("--"),_T("--"),_T("--")
#else
									_T("--"),_T("--"),_T("--"),_T("--")
#endif

#else
									_T("--"),_T("--"),_T("1234.56789"),_T("1234.56789"),_T("1200"),_T("12000"),
									_T("12345.0"),_T("123450.0"),_T("1234500.0"),_T("93/07/01"),_T("09:45:30"),
									_T("1993-08-02 08:44:31.001000"),_T("120000"),
									_T("1234567890123456789"),
									_T("1234567890123.456789"),
									_T("1234567890123456789012345678901234567890"),
									_T(".12345678901234567890123456789012345678900000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"),
									_T("1234567890.1234567890123456789012345678901234567890000000000000000000000000"),
									_T("12345.56789"),
									_T("1234567890123.56789"),
									_T("12345678901234567890.0123456789"),
									_T("--"),_T("--"),_T("--"),_T("--"),_T("--")
#endif
								};

	TCHAR					*FetchNStr[5];

	struct 
	{
		SQLULEN	AccessParam[2];
		SQLULEN	TransactParam[2];
	} ConnOption = {
			SQL_MODE_READ_WRITE,
			SQL_MODE_READ_ONLY,
			SQL_TXN_READ_COMMITTED,
			SQL_TXN_READ_UNCOMMITTED
		};

	struct _timeb	fetchstarttime;
	struct _timeb fetchendtime;
	long		AccessTime[2];

	//Added for transaction isolation problems
	TCHAR *iso_level_cqd[] = {
		_T("control query default isolation_level 'READ_COMMITTED'"),
		_T("control query default isolation_level 'READ_UNCOMMITTED'"),
		_T("control query default isolation_level 'REPEATABLE_READ'"),
		_T("control query default isolation_level 'SERIALIZABLE'"),
		_T("endloop")
	};

	TCHAR *access_mode[] = {
		_T("default"),
		_T("set transaction READ ONLY"),
		_T("set transaction READ WRITE"),
		_T("endloop")
	};

	SQLTCHAR *sqlstring0 = (SQLTCHAR*)_T("DROP TABLE YRWK_TY_POS_2");
	SQLTCHAR *sqlstring1 = (SQLTCHAR*)_T("CREATE TABLE YRWK_TY_POS_2 ( C1 NUMERIC (9, 2) , C2 NUMERIC (9, 2)) NO PARTITION");
	SQLTCHAR *sqlstring2 = (SQLTCHAR*)_T("INSERT INTO YRWK_TY_POS_2 VALUES (119.28, 6)");
	SQLTCHAR *sqlstring3 = (SQLTCHAR*)_T("SELECT SUM(C1) + SUM(C2) FROM YRWK_TY_POS_2");
	//SQLTCHAR sqlstring0[] = _T("DROP TABLE YRWK_TY_POS_2");
	//SQLTCHAR sqlstring1[] = _T("CREATE TABLE YRWK_TY_POS_2 ( C1 NUMERIC (9, 2) , C2 NUMERIC (9, 2)) NO PARTITION");
	//SQLTCHAR sqlstring2[] = _T("INSERT INTO YRWK_TY_POS_2 VALUES (119.28, 6)");
	//SQLTCHAR sqlstring3[] = _T("SELECT SUM(C1) + SUM(C2) FROM YRWK_TY_POS_2");

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars(_T("SQLFetch"), charset_file);
	if (var_list == NULL) return FAILED;

	//print_list(var_list);
	ExecDirStr[0] = var_mapping(_T("SQLFetch_ExecDirStr_1"), var_list);
	ExecDirStr[1] = var_mapping(_T("SQLFetch_ExecDirStr_2"), var_list);
	ExecDirStr[2] = var_mapping(_T("SQLFetch_ExecDirStr_3"), var_list);
	ExecDirStr[3] = var_mapping(_T("SQLFetch_ExecDirStr_4"), var_list);
	ExecDirStr[4] = var_mapping(_T("SQLFetch_ExecDirStr_5"), var_list);

	CResults[0] = var_mapping(_T("SQLFetch_CResults_1"), var_list);
	CResults[1] = var_mapping(_T("SQLFetch_CResults_2"), var_list);

#ifdef UNICODE	
	CResults[21] = var_mapping(_T("SQLFetch_datastr1"), var_list);
	CResults[22] = var_mapping(_T("SQLFetch_datastr2"), var_list);
	CResults[23] = var_mapping(_T("SQLFetch_datastr3"), var_list);

	CResults[24] = var_mapping(_T("SQLFetch_CResults_24"), var_list);
	CResults[25] = var_mapping(_T("SQLFetch_CResults_25"), var_list);
	CResults[26] = var_mapping(_T("SQLFetch_CResults_26"), var_list);
#else
	CResults[21] = var_mapping(_T("SQLFetch_CResults_21"), var_list);
	CResults[22] = var_mapping(_T("SQLFetch_CResults_22"), var_list);
	CResults[23] = var_mapping(_T("SQLFetch_CResults_23"), var_list);
	CResults[24] = var_mapping(_T("SQLFetch_CResults_24"), var_list);
#endif

	FetchNStr[0] = var_mapping(_T("SQLFetch_FetchNStr_1"), var_list);
	FetchNStr[1] = var_mapping(_T("SQLFetch_FetchNStr_2"), var_list);
	FetchNStr[2] = var_mapping(_T("SQLFetch_FetchNStr_3"), var_list);
	FetchNStr[3] = var_mapping(_T("SQLFetch_FetchNStr_4"), var_list);
	FetchNStr[4] = var_mapping(_T("SQLFetch_FetchNStr_5"), var_list);

//=================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,_T("Begin testing API =>SQLFetch.\n"));

	TEST_INIT;

	TESTCASE_BEGIN("Setup for SQLFetch tests\n");

	if(!FullConnect(pTestInfo))
	{
		LogMsg(ERRMSG,_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;
	}

	SQLExecDirect(hstmt,(SQLTCHAR*) ExecDirStr[0],SQL_NTS); /* cleanup */
	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[1],SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[2], SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	TESTCASE_END; // end of setup

	for (i = 0; i < 1; i++)
	{ // begin of 1st for loop 
		_stprintf(Heading,_T("Test 1.%d: Positive functionality of SQLFetch by doing SQLBindcol\n"),i);
		TESTCASE_BEGINW(Heading);
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[3], SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			TEST_RETURN;
		}

		for (j=0; j<MAX_NUM1; j++)
		{
			CCharOutput1[j] = (TCHAR *)malloc(sizeof(TCHAR)*NAME_LEN);
			*(CCharOutput1[j])=(TCHAR)'\0';
			returncode = SQLBindCol(hstmt,(SWORD)(j+1),CType[i],CCharOutput1[j],NAME_LEN,&OutputLen1[j]);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
				TEST_RETURN;
			}
		}

		returncode = SQLFetch(hstmt);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		else
		{
			for (j=0; j<MAX_NUM1; j++)
			{
				if (_tcscmp(CCharOutput1[j],CResults[j]) == 0)
				{
					LogMsg(NONE,_T("expect: '%s' and actual: '%s' of column %d are matched\n"),CResults[j],CCharOutput1[j],j+1);
				}	
				else
				{
					TEST_FAILED;	
					LogMsg(ERRMSG,_T("expect: '%s' and actual: '%s' of column %d are not match, at line %d\n"), CResults[j],CCharOutput1[j],j+1,__LINE__);
				}
				free(CCharOutput1[j]);
			} 
		}

		SQLFreeStmt(hstmt,SQL_CLOSE);
		TESTCASE_END;
	} // end of 1st for loop 

//============================================================================================

	TESTCASE_BEGIN("Setup for more SQLFetch tests\n");
	SQLFreeStmt(hstmt,SQL_DROP);
	SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
	SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[4],SQL_NTS);
	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[2], SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	TESTCASE_END;

	for (i = 0; i < 1; i++)
	{
		_stprintf(Heading,_T("Test 2.%d: Positive functionality of SQLFetch by doing SQLGetData\n"),i);
		TESTCASE_BEGINW(Heading);
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[3], SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			TEST_RETURN;
		}
		returncode = SQLFetch(hstmt);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
		{
			TEST_FAILED;
			LogAllErrors(henv,hdbc,hstmt);
		}
		else
		{
			for (j=0; j<MAX_NUM1; j++)
			{
				returncode = SQLGetData(hstmt,(SWORD)(j+1),CType[i],CCharOutput2,NAME_LEN,&OutputLen2);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetData"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				}

				if (_tcscmp(CCharOutput2,CResults[j]) == 0)
				{
					LogMsg(NONE,_T("expect: '%s' and actual: '%s' of column %d are matched\n"), CResults[j],CCharOutput2,j+1);
				}	
				else
				{
					TEST_FAILED;	
					LogMsg(ERRMSG,_T("expect: '%s' and actual: '%s' of column %d are not match, at line %d\n"),CResults[j],CCharOutput2,j+1,__LINE__);
				}
			}
		}

		SQLFreeStmt(hstmt,SQL_CLOSE);
		TESTCASE_END;
	} 
	
//============================================================================================

	for (fn = 0; fn < NUM_FETCH_LOOP; fn++)
	{
		_stprintf(Heading,_T("Setup for Fetch %d tests\n"),(ROWS_INSERTED*(fn+1)));
		TESTCASE_BEGINW(Heading);
		SQLFreeStmt(hstmt,SQL_DROP);
		SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
		SQLSetConnectOption((SQLHANDLE)hdbc,SQL_ACCESS_MODE,SQL_MODE_READ_WRITE);
		SQLSetConnectOption((SQLHANDLE)hdbc,SQL_TXN_ISOLATION,SQL_TXN_READ_COMMITTED);
		SQLExecDirect(hstmt,(SQLTCHAR*) FetchNStr[0],SQL_NTS); /* cleanup */
		returncode = SQLExecDirect(hstmt,(SQLTCHAR*)FetchNStr[1],SQL_NTS);
		if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
		{
			LogAllErrors(henv,hdbc,hstmt);
			TEST_FAILED;
			TEST_RETURN;
		}
		for (i = 0; i < (ROWS_INSERTED*(fn+1)); i++)
		{ 
			returncode = SQLExecDirect(hstmt,(SQLTCHAR*)FetchNStr[2], SQL_NTS);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				TEST_RETURN;
			}
		}
		TESTCASE_END; // end of setup

		_stprintf(Heading,_T("Test Positive functionality of Fetch %d by doing SQLBindcol\n"),(ROWS_INSERTED*(fn+1)));
		TESTCASE_BEGINW(Heading);
		for (k = 0; k < 2; k++)
		{
			returncode = SQLSetConnectOption((SQLHANDLE)hdbc,SQL_ACCESS_MODE,ConnOption.AccessParam[k]);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetConnection Access"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
				TEST_RETURN;
			}
			returncode = SQLSetConnectOption((SQLHANDLE)hdbc,SQL_TXN_ISOLATION,ConnOption.TransactParam[k]);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetConnection Transact"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
				TEST_RETURN;
			}
			returncode = SQLSetStmtOption(hstmt,SQL_ROWSET_SIZE,1);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLSetStmtOption"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
				TEST_RETURN;
			}
			returncode = SQLExecDirect(hstmt,(SQLTCHAR*)FetchNStr[3], SQL_NTS);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				TEST_RETURN;
			}
			returncode = SQLNumResultCols(hstmt, &col);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLNumResultCols"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
			}
			for (j = 0; j < col; j++)
			{
				CCharOutput1[j] = (TCHAR *)malloc(NAME_LEN);
				*(CCharOutput1[j])=(TCHAR)'\0';
				returncode = SQLBindCol(hstmt,(SWORD)(j+1),SQL_C_TCHAR,CCharOutput1[j],NAME_LEN,&OutputLen1[j]);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
				{
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
					TEST_RETURN;
				}
			} // end of 2nd for loop 

			returncode = SQL_SUCCESS;
			_ftime(&fetchstarttime);
			j = 0;
			while (returncode == SQL_SUCCESS)
			{
				returncode = SQLFetch(hstmt);
				if((returncode != SQL_SUCCESS) && (j < col)) // need to make sure we haven't fallen off the end of the table
				{
				   if (returncode == SQL_NO_DATA_FOUND)
				   {
					    if (!FindError(_T("00000"),henv,hdbc,hstmt)) // SQLState should be "00000" when return code is SQL_NO_DATA_FOUND.
						{	
							TEST_FAILED;
							//assert(0);
							LogMsg(NONE,_T("Rows #: %d : array %d suppose to be %d at line %d.\n"),j,k, (ROWS_INSERTED*(fn+1)),__LINE__);
							LogAllErrors(henv,hdbc,hstmt);
						}
				   }     
				   else
				   {
					TEST_FAILED;
					LogAllErrors(henv,hdbc,hstmt);
				   }
				}
				if (returncode == SQL_SUCCESS)
					j++;
			}
			_ftime(&fetchendtime);
			if (j == (ROWS_INSERTED*(fn+1)))
			{
				LogMsg(NONE,_T("Rows inserted Expected: %d and Actual: %d.\n"),(ROWS_INSERTED*(fn+1)),j);
			}	
			else
			{
				TEST_FAILED;	
				LogMsg(ERRMSG,_T("Rows inserted Expected: %d and Actual: %d at line%d.\n"),(ROWS_INSERTED*(fn+1)),j,__LINE__);
			}

			AccessTime[k] = (long)(((fetchendtime.time - fetchstarttime.time) * 1000) + (fetchendtime.millitm - fetchstarttime.millitm));
			for (j = 0; j < col; j++)
			{
				free(CCharOutput1[j]);
			} // end of 3rd for loop 
			SQLFreeStmt(hstmt,SQL_CLOSE);
		}
/*
		if (AccessTime[0] >= 	AccessTime[1])
		{
			LogMsg(NONE,_T("FETCH ONE: %d millisecs and FETCH N: %d millisecs.\n"),AccessTime[0],AccessTime[1]);
		}	
		else
		{
			TEST_FAILED;	
			LogMsg(ERRMSG,_T("FETCH ONE: %d millisecs and FETCH N: %d millisecs.\n"),AccessTime[0],AccessTime[1]);
		}
*/
		LogMsg(NONE,_T("FETCH ONE: %d millisecs and FETCH N: %d millisecs.\n"),AccessTime[0],AccessTime[1]);
		TESTCASE_END;
		SQLSetConnectOption((SQLHANDLE)hdbc,SQL_ACCESS_MODE,SQL_MODE_READ_WRITE);
		SQLSetConnectOption((SQLHANDLE)hdbc,SQL_TXN_ISOLATION,SQL_TXN_READ_COMMITTED);
		SQLExecDirect(hstmt,(SQLTCHAR*) FetchNStr[0],SQL_NTS); /* cleanup */
	}
	SQLExecDirect(hstmt,(SQLTCHAR*) ExecDirStr[0],SQL_NTS); /* cleanup */

//=====================================================================================================

	TESTCASE_BEGIN("Setup for SQLFetch isolation level tests\n");
	SQLFreeStmt(hstmt,SQL_DROP);
	SQLAllocStmt((SQLHANDLE)hdbc, &hstmt);	
	SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[0],SQL_NTS);/*clean up*/
	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[1], SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[2], SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	TESTCASE_END;

	i = 0; k = 0;
	while (_tcsicmp(iso_level_cqd[k],_T("endloop")) != 0)
	{
		h = 0;
		while (_tcsicmp(access_mode[h],_T("endloop")) != 0) {
			if ((_tcsstr(iso_level_cqd[k],_T("READ_UNCOMMITTED")) != NULL && _tcsstr(access_mode[h],_T("READ WRITE")) != NULL) ||
				(_tcsstr(iso_level_cqd[k],_T("REPEATABLE_READ")) != NULL && _tcsstr(access_mode[h],_T("default")) != NULL) ||
				(_tcsstr(iso_level_cqd[k],_T("SERIALIZABLE")) != NULL && _tcsstr(access_mode[h],_T("default")) != NULL))
			{
				h++;
				continue;
			}

			FullDisconnect(pTestInfo);

			_stprintf(Heading, _T("Setup for SQLFetch with: %s\nAnd access-mode: %s\n"), iso_level_cqd[k], access_mode[h]);
			TESTCASE_BEGINW(Heading);
			if(!FullConnect(pTestInfo))
			{
				LogMsg(ERRMSG,_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;
			}

			returncode = SQLExecDirect(hstmt,(SQLTCHAR*)iso_level_cqd[k],SQL_NTS);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				TEST_RETURN;
			}

			if (_tcsicmp(access_mode[h],_T("default")) != 0) {
				returncode = SQLExecDirect(hstmt,(SQLTCHAR*)access_mode[h],SQL_NTS);
				if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
				{
					LogAllErrors(henv,hdbc,hstmt);
					TEST_FAILED;
					TEST_RETURN;
				}
			}

			TESTCASE_END; // end of setup

			_stprintf(Heading,_T("SQLFetch by doing SQLGetData\n"));
			TESTCASE_BEGINW(Heading);
			returncode = SQLExecDirect(hstmt,(SQLTCHAR*)ExecDirStr[3], SQL_NTS);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
			{
				LogAllErrors(henv,hdbc,hstmt);
				TEST_FAILED;
				//TEST_RETURN;
			}
			returncode = SQLFetch(hstmt);
			if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
			{
				TEST_FAILED;
				LogAllErrors(henv,hdbc,hstmt);
			}
			else
			{
				for (j=0; j<MAX_NUM1; j++)
				{
					returncode = SQLGetData(hstmt,(SWORD)(j+1),CType[i],CCharOutput2,NAME_LEN,&OutputLen2);
					if(!CHECKRC(SQL_SUCCESS,returncode,"SQLGetData"))
					{
						TEST_FAILED;
						LogAllErrors(henv,hdbc,hstmt);
					}

					if (_tcscmp(CCharOutput2,CResults[j]) == 0)
					{
						LogMsg(NONE,_T("expect: '%s' and actual: '%s' of column %d are matched\n"),CResults[j],CCharOutput2,j+1);
					}	
					else
					{
						TEST_FAILED;	
						LogMsg(ERRMSG,_T("expect: '%s' and actual: '%s' of column %d are not match, at line %d\n"),CResults[j],CCharOutput2,j+1,__LINE__);
					}
				}
			}

			SQLFreeStmt(hstmt,SQL_CLOSE);
			TESTCASE_END;
			h++;
		}

		k++;
	}//End while

	SQLExecDirect(hstmt,(SQLTCHAR*) ExecDirStr[0],SQL_NTS); /* cleanup */
	
//============================================================================================
	TESTCASE_BEGIN("Testcase for Mode_special_1\n");

	returncode = SQLExecDirect(hstmt,sqlstring0,SQL_NTS);

	returncode = SQLExecDirect(hstmt,sqlstring1,SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}
	returncode = SQLExecDirect(hstmt,sqlstring2,SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecDirect"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLPrepare(hstmt,sqlstring3,SQL_NTS);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLPrepare"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLBindCol(hstmt,1,SQL_C_TCHAR,CCharOutput2,300,NULL);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLBindCol"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLExecute(hstmt);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLExecute"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

	returncode = SQLFetch(hstmt);
	if(!CHECKRC(SQL_SUCCESS,returncode,"SQLFetch"))
	{
		LogAllErrors(henv,hdbc,hstmt);
		TEST_FAILED;
		TEST_RETURN;
	}

#ifndef _WM
	if (_tcscmp(CCharOutput2,_T("125.2")) == 0)
	{
		LogMsg(NONE,_T("expect: '125.2' and actual: '%s' are matched\n"),CCharOutput2);
	}	
	else
	{
		TEST_FAILED;	
		LogMsg(ERRMSG,_T("expect: '125.2' and actual: '%s' are not match, at line %d\n"),CCharOutput2,__LINE__);
	}
#else
	if (_tcscmp(CCharOutput2,"125.28") == 0)
	{
		LogMsg(NONE,_T("expect: '125.28' and actual: '%s' are matched\n"),CCharOutput2);
	}	
	else
	{
		TEST_FAILED;	
		LogMsg(ERRMSG,_T("expect: '125.28' and actual: '%s' are not match, at line %d\n"),CCharOutput2,__LINE__);
	}
#endif

//============================================================================================
	
	FullDisconnect(pTestInfo);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,_T("End testing API => SQLFetch.\n"));
	free_list(var_list);
	TEST_RETURN;
}
Exemplo n.º 18
0
					SQL_COLUMN_SCALE,			// 
					SQL_COLUMN_SEARCHABLE,		//
					SQL_COLUMN_TYPE,			// Numeric
					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
					};

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars(_T("SQLColumnAttribute"), charset_file);
	if (var_list == NULL) return FAILED;

	//print_list(var_list);
	_tcscpy(tableName,var_mapping(_T("SQLColumnAttribute_tableName_1"), var_list));

	_tcscpy(columnName[0],var_mapping(_T("SQLColumnAttribute_columnName_1"), var_list));
	_tcscpy(columnName[1],var_mapping(_T("SQLColumnAttribute_columnName_2"), var_list));
	_tcscpy(columnName[2],var_mapping(_T("SQLColumnAttribute_columnName_3"), var_list));
	_tcscpy(columnName[3],var_mapping(_T("SQLColumnAttribute_columnName_4"), var_list));
	_tcscpy(columnName[4],var_mapping(_T("SQLColumnAttribute_columnName_5"), var_list));
	_tcscpy(columnName[5],var_mapping(_T("SQLColumnAttribute_columnName_6"), var_list));
	_tcscpy(columnName[6],var_mapping(_T("SQLColumnAttribute_columnName_7"), var_list));
	_tcscpy(columnName[7],var_mapping(_T("SQLColumnAttribute_columnName_8"), var_list));
	_tcscpy(columnName[8],var_mapping(_T("SQLColumnAttribute_columnName_9"), var_list));
	_tcscpy(columnName[9],var_mapping(_T("SQLColumnAttribute_columnName_10"), var_list));
Exemplo n.º 19
0
/*
---------------------------------------------------------
  TestSQLDrivers
	No negative tests since this functionality is done at
	driver manager level.
---------------------------------------------------------
*/
PassFail TestInfoStats(TestInfo *pTestInfo)
{                  
	TEST_DECLARE;

    SQLHANDLE	secHandle;
    SQLSMALLINT outLen = SQL_NTS;
    char		tempStr[MAX_STR_LEN*2];
	int			i,j;
	char		cursorName[MAX_STR_LEN] = "";
    RETCODE		returncode;

	char* strs[5];

    struct _test_data {
        char        front[2];
        char        back[MAX_SIZE];
        RETCODE     retcode;
        BOOL        cursor;
        char        *stmt;
    } testData[] = {{"", "",          SQL_SUCCESS,    TRUE,  ""},
                    {"", "",          SQL_SUCCESS,    TRUE,  ""},
                    {"", "",          SQL_SUCCESS,    TRUE,  ""},
                    {"", "SQL_CUR_2", SQL_ERROR,      FALSE, ""},
                    {"", "",          SQL_ERROR,      FALSE, ""},    // empty statement
                    {"'", "'",        SQL_SUCCESS,    TRUE,  ""},
                    {"\"", "\"",      SQL_SUCCESS,    TRUE,  ""},
                    {"", "SQL_CUR_9 ",SQL_ERROR,      FALSE, ""},
                    {"\"", "",        SQL_ERROR,      TRUE,  ""},
                    {"\"", "\"",      SQL_SUCCESS,    FALSE, ""},     // strs[3].txt
                    {"'", "'",        SQL_SUCCESS,    FALSE, ""},     // strs[3].txt
                    {"'", "",         SQL_ERROR,      FALSE, ""},     // strs[3].txt
                    {"\"", "",        SQL_ERROR,      FALSE, ""},     // strs[3].txt
                    {"", "\"",        SQL_ERROR,      FALSE, ""},     // strs[3].txt
                    {"", "'",         SQL_ERROR,      FALSE, ""},     // strs[3].txt
                    {"'", "'",        SQL_ERROR,      FALSE, ""},     // strs[4].txt
                    {"\"", "\"",      SQL_ERROR,      FALSE, ""},     // strs[4].txt
                    {"", "end"}
     };

//===========================================================================================================
	var_list_t *var_list;
	var_list = load_api_vars("InfoStats", charset_file);
	if (var_list == NULL) return FAILED;

    strs[0] = var_mapping("InfoStats_strs_0", var_list);
    strs[1] = var_mapping("InfoStats_strs_1", var_list);
    strs[2] = var_mapping("InfoStats_strs_2", var_list);
    strs[3] = var_mapping("InfoStats_strs_3", var_list);
    strs[4] = var_mapping("InfoStats_strs_4", var_list);
    strs[5] = var_mapping("InfoStats_strs_5", var_list);

	testData[9].stmt  = strs[3];
    testData[10].stmt = strs[3];
    testData[11].stmt = strs[3];
    testData[12].stmt = strs[3];
    testData[13].stmt = strs[3];
    testData[14].stmt = strs[3];

    testData[15].stmt = strs[4];
    testData[16].stmt = strs[4];

//===========================================================================================================

	LogMsg(LINEBEFORE+SHORTTIMESTAMP,"Begin testing => InfoStats | InfoStats | infostats.cpp\n");
    TEST_INIT;

	if(!FullConnectWithOptions(pTestInfo, CONNECT_ODBC_VERSION_3))
	{
		LogMsg(NONE,"Unable to connect\n");
		TEST_FAILED;
		TEST_RETURN;
	}

    returncode = SQLAllocStmt((SQLHANDLE)pTestInfo->hdbc, &(pTestInfo->hstmt));	
    if (returncode != SQL_SUCCESS) {
        TEST_FAILED;
        TEST_RETURN;
    }

    returncode = SQLAllocStmt((SQLHANDLE)pTestInfo->hdbc, &secHandle);
    if(returncode != SQL_SUCCESS) {
        TEST_FAILED;
        TEST_RETURN;
    }

    for(j = 0; j < 2; j++) {
        i = 0;
        while (strcmp(testData[i].back,"end")!=0) {

            if((j == 0) || (i==0)) {    // setup table and data
                LogMsg(NONE,"Setting up table and data\n");
                returncode = SQLExecDirect(pTestInfo->hstmt, (SQLCHAR*)strs[0], SQL_NTS);
	            returncode = SQLExecDirect(pTestInfo->hstmt, (SQLCHAR*)strs[1], SQL_NTS);
	            returncode = SQLExecDirect(pTestInfo->hstmt, (SQLCHAR*)strs[2], SQL_NTS);
	            returncode = SQLEndTran(SQL_HANDLE_DBC, pTestInfo->hdbc, SQL_COMMIT);
	            returncode = SQLFreeStmt(pTestInfo->hstmt, SQL_CLOSE);
            }
     
	        returncode = SQLPrepare(pTestInfo->hstmt, (SQLCHAR*)strs[3], SQL_NTS);

            strcpy(cursorName, "");

	        returncode = SQLGetCursorName(pTestInfo->hstmt, (SQLCHAR*)cursorName, sizeof(cursorName), &outLen);
            if(returncode != SQL_SUCCESS)
                LogAllErrors(pTestInfo->henv, pTestInfo->hdbc, pTestInfo->hstmt);

	        returncode = SQLExecute(pTestInfo->hstmt);

            sprintf(tempStr, "Starting test number %d\n", i);
            TESTCASE_BEGIN(tempStr);

            if(testData[i].cursor == TRUE)
                sprintf(tempStr, "INFOSTATS %s%s%s", testData[i].front, cursorName, testData[i].back);
            else
                sprintf(tempStr, "INFOSTATS %s%s%s", testData[i].front, testData[i].stmt, testData[i].back);

            returncode = execute(pTestInfo, secHandle, tempStr, testData[i].retcode);
            if(returncode == FALSE)
                TEST_FAILED;
			returncode = SQLFreeStmt(secHandle, SQL_CLOSE);
	        returncode = SQLFreeStmt(pTestInfo->hstmt,SQL_CLOSE);

            TESTCASE_END;
            i++;
        }

        returncode = SQLExecDirect(pTestInfo->hstmt, (SQLCHAR*)strs[0], SQL_NTS);
    }

	//==========================================================================================
      
	FullDisconnect3(pTestInfo);
	free_list(var_list);
	LogMsg(SHORTTIMESTAMP+LINEAFTER,"End testing => InfoStats.\n");
    TEST_RETURN;
}