Exemple #1
0
void FTP::ExecuteQueue(QueueExecOptions* op)
{
	if(!QuequeSize) return;

	FTPHost   oHost = Host;
	BOOL      oShowHosts = ShowHosts;
	char      oDir[MAX_PATH];
	GetCurPath(oDir, ARRAYSIZE(oDir));
	OverrideMsgCode = ocNone;
	ExecuteQueueINT(op);
	OverrideMsgCode = ocNone;

//Restore plugin state
	if(op->RestoreState)
	{
		if(oShowHosts)
		{
			BackToHosts();
		}
		else if(!Host.CmpConnected(&oHost))
		{
			Host = oHost;
			FullConnect();
			ResetCache=TRUE;
		}

		SetDirectory(oDir,0);
		Invalidate();
	}
}
Exemple #2
0
/**********************************************************************
** get_table_info
**
** This function fills in the needed information into the array of table
** descriptions.
**********************************************************************/
short get_table_info(table_description *table_ptr[],short table_count)
{
   short i;
   ReturnStatus *RSPtr;
	HENV	henv;
	HDBC	hdbc;
	HSTMT hstmt;
	Boolean connected;
	RETCODE rc;

	RSPtr=NULL;
	// start a connection so we can use it to get the table info
	connected=FullConnect(gDataSource,gUID,gPWD,&henv,&hdbc);
	if(!connected) return(FAILURE);
	rc=SQLAllocStmt(hdbc,&hstmt);
	//>>>> check return code ???

   /* for each table, determine its format */
   for(i=0;i<table_count;i++){

      /* get format of table records, including column names */
      if(table_ptr[i]->Organization==KEY_SEQ){
         table_ptr[i]->pTable=GetTableInfo(hdbc,table_ptr[i]->TableName,FALSE,&RSPtr);
         }
      else{
         table_ptr[i]->pTable=GetTableInfo(hdbc,table_ptr[i]->TableName,TRUE,&RSPtr);
         }

      if(table_ptr[i]->pTable==NULL) {
			LogReturnStatus(RSPtr);
			FreeReturnStatus(RSPtr);
			return(FAILURE);
			}
		else{
			table_ptr[i]->henv=NULL;
			table_ptr[i]->hdbc=NULL;
			table_ptr[i]->hstmt=NULL;
			}
      }

	FullDisconnect(henv,hdbc);
   return(SUCCESS);
   } /* end of get_table_info() */
Exemple #3
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;
}
Exemple #4
0
int FTP::ProcessShortcutLine(char *Line)
{
	char *m,*m1;
	char  str[20]; //Hold single dec number - need not use of String

	if(!Line)
		return FALSE;

	ReadCfg();

	if(StrCmp(Line,"FTP:",4) == 0)
	{
		/*
		FTP
		  Host
		  1
		  AskLogin    + 3
		  AsciiMode   + 3
		  PassiveMode + 3
		  UseFirewall + 3
		  HostTable
		  1
		  User
		  1
		  Password
		  1
		  ExtCmdView + 3
		  IOBuffSize (atoi)
		  1
		  FFDup + '0'
		  DecodeCmdLine + '0'
		  1
		*/
		Line += 4;
		m = strchr(Line,'\x1');

		if(!m || strlen(m) < 4) return FALSE;

		m++;
		Host.Init();
		StrCpy(Host.Host,     Line, Min((int)(m-Line), (int)ARRAYSIZE(Host.Host)));
		strcpy(Host.HostName, Host.Host);
		Host.AskLogin    = *(m++) - '\x3';

		if(*m == 0) return FALSE;

		Host.AsciiMode   = *(m++) - '\x3';

		if(*m == 0) return FALSE;

		Host.PassiveMode = *(m++) - '\x3';

		if(*m == 0) return FALSE;

		Host.UseFirewall = *(m++) - '\x3';

		if(*m == 0) return FALSE;

		m1 = m;
		m = strchr(m1,'\x1');

		if(!m) return FALSE;

		StrCpy(str, m1, (int)(m-m1+1));
		Host.ServerType = (WORD)atoi(str);
		m1 = m+1;
		m = strchr(m1,'\x1');

		if(!m) return FALSE;

		StrCpy(Host.HostTable, m1, (int)(m-m1+1));
		m1 = m+1;
		m  = strchr(m1,'\x1');

		if(!m) return FALSE;

		StrCpy(Host.User,m1,(int)(m-m1+1));
		m1 = m+1;
		m  = strchr(m1,'\x1');

		if(!m) return FALSE;

		StrCpy(Host.Password,m1,(int)(m-m1+1));

		do
		{
			Host.ExtCmdView    = Opt.ExtCmdView;
			Host.IOBuffSize    = Opt.IOBuffSize;
			Host.FFDup         = Opt.FFDup;
			Host.DecodeCmdLine = TRUE;
			//IOBuffSize
			m1 = m+1;

			if(!m1[0])
				break;

			Host.ExtCmdView = *(m1++) - '\x3';
			m = strchr(m1,'\x1');

			if(!m)
				return FALSE;

			StrCpy(str,m1,(int)(m-m1+1));
			Host.IOBuffSize = Max(FTR_MINBUFFSIZE,(DWORD)atoi(str));
			//FFDup
			m1 = m+1;

			if(!m1[0])
				break;

			m = strchr(m1,'\x1');

			if(!m)
				break;

			if(*m1 != '0' && *m1 != '1')
				break;

			Host.FFDup = *m1 - '0';
			//DecodeCmdLine
			m1++;

			if(!m1[0] ||
			        (*m1 != '0' && *m1 != '1'))
				break;

			Host.DecodeCmdLine = *m1 - '0';
		}
		while(0);

		return FullConnect();
	}
	else if(StrCmp(Line,"HOST:",5) == 0)
	{
		Line += 5;
		strcpy(HostsPath,Line);
		return 1;
	}

	return 0;
}
Exemple #5
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;
}
Exemple #6
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;
}
Exemple #7
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;
}
Exemple #8
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;
}
Exemple #9
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;
}
Exemple #10
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;
}
Exemple #11
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;
}
Exemple #12
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;
}
Exemple #13
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;
}
Exemple #14
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;
}
Exemple #15
0
void FTP::ExecuteQueueINT(QueueExecOptions* op)
{
	PROC(("ExecuteQueueINT","%d,%d",op->RestoreState,op->RemoveCompleted))
	FP_Screen       _scr;
	String          DefPath, LastPath, LastName;
	BOOL            rc;
	BOOL            needUpdate = FALSE;
	FTPUrl          *prev,*p,*tmp;
	FTPCopyInfo     ci;
	FAR_FIND_DATA   fd, ffd;
	//Copy info
	ci.asciiMode       = Host.AsciiMode;
	ci.ShowProcessList = FALSE;
	ci.AddToQueque     = FALSE;
	ci.MsgCode         = ocNone;
	ci.UploadLowCase   = Opt.UploadLowCase;
	//Check othe panel info
	PanelInfo pi;
	FP_Info->Control(INVALID_HANDLE_VALUE, FCTL_GETANOTHERPANELINFO, &pi);

	if(pi.PanelType != PTYPE_FILEPANEL ||
	        pi.Plugin)
		DefPath.Null();
	else
		DefPath = pi.CurDir;

	//DO full list
	prev        = NULL;
	p           = UrlsList;
	LastPath.Null();
	LastName.Null();

	while(p)
	{
//Check current host the same
		Log(("Queue: Check current host the same"));

		if(!hConnect ||
		        !Host.CmpConnected(&p->Host))
		{
			Host = p->Host;

			if(!FullConnect())
			{
				if(GetLastError() == ERROR_CANCELLED) break;

				p->Error.printf("%s: %s", FP_GetMsg(MQCanNotConnect), __WINError());
				goto Skip;
			}

			ResetCache=TRUE;
		}

//Apply other parameters
		Log(("Queue: Apply other parameters"));
		Host = p->Host;
		hConnect->InitData(&Host,-1);
		hConnect->InitIOBuff();
//Change local dir
		Log(("Queue: Change local dir"));

		do
		{
			char *m = p->Download ? p->DestPath.c_str() : p->SrcPath.c_str();

			if(!m[0]) m = DefPath.c_str();

			if(!m[0])
			{
				p->Error = FP_GetMsg(MQNotLocal);
				goto Skip;
			}

			if(SetCurrentDirectory(m)) break;

			if(DoCreateDirectory(m))
				if(SetCurrentDirectory(m)) break;

			p->Error.printf(FP_GetMsg(MQCanNotChangeLocal), m, __WINError());
			goto Skip;
		}
		while(0);

//Check local file
		Log(("Queue: Check local file"));

		if(!p->Download)
		{
			if(!FRealFile(p->FileName.cFileName, &fd))
			{
				p->Error.printf(FP_GetMsg(MQNotFoundSource), p->FileName.cFileName, __WINError());
				goto Skip;
			}
		}

//IO file
		Log(("Queue: IO file"));
		//Last used FTP path and name
		LastPath = p->Download ? p->SrcPath : p->DestPath;
		LastName = PointToName(p->FileName.cFileName);

		//DOWNLOAD ------------------------------------------------
		if(p->Download)
		{
			ci.Download  = TRUE;
			ci.SrcPath = p->SrcPath;
			AddEndSlash(ci.SrcPath, '/');
			ci.SrcPath.cat(p->FileName.cFileName);

			if(p->DestPath.Length())
			{
				FixFileNameChars(p->DestPath);
				ci.DestPath = p->DestPath;
			}
			else
				ci.DestPath = DefPath;

			AddEndSlash(ci.DestPath, '\\');
			ci.DestPath.cat(FixFileNameChars(p->FileName.cFileName,TRUE));
			__int64 fsz = FtpFileSize(hConnect, ci.SrcPath.c_str());
			hConnect->TrafficInfo->Init(hConnect, MStatusDownload, 0, NULL);
			hConnect->TrafficInfo->InitFile(fsz, ci.SrcPath.c_str(), ci.DestPath.c_str());

			if(FRealFile(ci.DestPath.c_str(),&fd))
			{
				if(fsz != -1)
				{
					ffd = fd;
					ffd.nFileSizeHigh = (DWORD)((fsz >> 32) & MAX_DWORD);
					ffd.nFileSizeLow  = (DWORD)(fsz & MAX_DWORD);
					ci.MsgCode  = AskOverwrite(MDownloadTitle, TRUE, &fd, &ffd, ci.MsgCode, FALSE);
				}
				else
					ci.MsgCode  = AskOverwrite(MDownloadTitle, TRUE, &fd, NULL, ci.MsgCode, FALSE);

				switch(ci.MsgCode)
				{
					case   ocOverAll:
					case      ocOver:
						break;
					case      ocSkip:
					case   ocSkipAll:
						goto Skip;
					case    ocResume:
					case ocResumeAll:
						break;
					case     ocNewer:
					case  ocNewerAll:
						goto Skip;
				}

				if(ci.MsgCode == ocCancel)
				{
					SetLastError(ERROR_CANCELLED);
					break;
				}
			}