//-------------------------------------------------------------------- // Microsoft OLE DB Test // // Copyright 1995-2000 Microsoft Corporation. // // @doc // // @module ICOLINFO.CPP | OLE DB IColumnsInfo tests for Provider, // #define DBINITCONSTANTS // Must be defined to initialize constants in OLEDB.H #define INITGUID #include "modstandard.hpp" #include "icolinfo.h" #include "ExtraLib.h" // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Module Values // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // {{ TCW_MODULE_GLOBALS DECLARE_MODULE_CLSID = { 0xf17d6f60, 0xd740, 0x11ce, { 0x88, 0xe7, 0x00, 0xaa, 0x00, 0xb5, 0xa9, 0x1b }}; DECLARE_MODULE_NAME("IColumnsInfo"); DECLARE_MODULE_OWNER("Microsoft"); DECLARE_MODULE_DESCRIP("The test module for IColumnsInfo interface."); DECLARE_MODULE_VERSION(795921705); // TCW_WizardVersion(2) // TCW_Automation(False) // }} TCW_MODULE_GLOBALS_END //Check whether the provider is read only BOOL g_fReadOnlyProvider = FALSE; LPCOLESTR g_pwszRowURL=NULL; LPCOLESTR g_pwszRowsetURL=NULL; GUID guidMod = { 0xf17d6f60, 0xd740, 0x11ce, { 0x88, 0xe7, 0x00, 0xaa, 0x00, 0xb5, 0xa9, 0x1b }}; //-------------------------------------------------------------------- // @func Module level initialization routine // // @rdesc Success or Failure // @flag TRUE | Successful initialization // @flag FALSE | Initialization problems // BOOL ModuleInit(CThisTestModule * pThisTestModule) { // Get connection and session objects if (ModuleCreateDBSession(pThisTestModule)) { //Check to see if the DSO is ReadOnly g_fReadOnlyProvider = GetProperty(DBPROP_DATASOURCEREADONLY, DBPROPSET_DATASOURCEINFO, pThisTestModule->m_pIUnknown); g_pwszRowURL = NULL; g_pwszRowsetURL = NULL; // Create a table we'll use for the whole test module, // store it in pVoid for now pThisTestModule->m_pVoid = new CTable( (IUnknown *)pThisTestModule->m_pIUnknown2, (LPWSTR)gwszModuleName); if (!pThisTestModule->m_pVoid) { odtLog << wszMemoryAllocationError; return FALSE; } // Start with a table with 5 rows TERM(FAILED(((CTable *)pThisTestModule->m_pVoid)->CreateTable(5,1,NULL,PRIMARY,TRUE))); return TRUE; } return FALSE; } //-------------------------------------------------------------------- // @func Module level termination routine // // @rdesc Success or Failure // @flag TRUE | Successful initialization // @flag FALSE | Initialization problems // BOOL ModuleTerminate(CThisTestModule * pThisTestModule) { // We still own the table since all of our testcases // have only used it and not deleted it. if (pThisTestModule->m_pVoid) { // Remove table from database ((CTable *)pThisTestModule->m_pVoid)->DropTable(); // Delete CTable object delete (CTable*)pThisTestModule->m_pVoid; pThisTestModule->m_pVoid = NULL; } return ModuleReleaseDBSession(pThisTestModule); } //////////////////////////////////////////////////////////////////////// // TCBase - Class for reusing Test Cases. // This is one of the base classes from which all the Test Case // classes will inherit. It is used to duplicate test cases, yet // maintain some sort of distinct identity for each. // //////////////////////////////////////////////////////////////////////// class TCBase { public: //constructor TCBase() { SetTestCaseParam(TC_Rowset); } //Set the m_fWarning and m_fBinder flags. virtual void SetTestCaseParam(ETESTCASE eTestCase = TC_Rowset) { m_eTestCase = eTestCase; switch(eTestCase) { case TC_Rowset: break; case TC_Cmd: break; case TC_OpenRW: break; case TC_Bind: break; case TC_IColInfo2: break; case TC_SingSel: break; default: ASSERT(!L"Unhandled Type..."); break; }; } //data ETESTCASE m_eTestCase; }; // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Base Class Section // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - class IColInfo : public CSessionObject, public TCBase { public: // @cmember Which HRESULT should I expect PREPARATION m_ePreparation; // @cmember What method METHOD_CHOICE m_Method; // @cmember Whether I want to check the structures coming back BOOL m_fCheckIColumnsInfo; // @cmember Supported Properties DBPROPID m_DBPROPID; // @cmember Count of rows affected, based on non-select statement DBROWCOUNT m_cRowsAffected; // @cmember Interface pointers IDBInitialize * m_pMyIDBInitialize; IColumnsInfo * m_pIColumnsInfo; IColumnsInfo2 * m_pIColumnsInfo2; ICommand * m_pICommand; IRowset * m_pIRowset; // @cmember GetColumnInfo params DBORDINAL m_cColumns; DBCOLUMNINFO * m_rgInfo; WCHAR * m_pStringsBuffer; // @cmember IColumnsInfo2 params DBORDINAL m_cColumns2; DBCOLUMNINFO* m_rgInfo2; DBID * m_rgColumnIDs2; DBORDINAL m_cMasks; DBID* m_rgMasks; BOOL m_fDocSource; // @cmember MapColumnIDs params DBORDINAL m_cColumnIDs; DBID * m_rgColumnIDs; DBORDINAL* m_rgColumns; // @cmember Pointer to Row Object CRowObject* m_pCRowObj; CRowset* m_pCRowset; // @cmember CheckProperty IUnknown * m_pIUnknown; // @cmember Ordinals of the SQL Statement DBORDINAL m_cOrdTbl1; DB_LORDINAL* m_prgOrdTbl1; DBORDINAL m_cOrdTbl2; DB_LORDINAL* m_prgOrdTbl2; // @member HResult HRESULT m_hr; // @cmember Constructor IColInfo(const LPWSTR wszTestCaseName): CSessionObject(wszTestCaseName) { // Interface pointer m_pIColumnsInfo = NULL; m_pIColumnsInfo2 = NULL; m_pICommand = NULL; m_pIRowset = NULL; m_pMyIDBInitialize = NULL; m_Method = INVALID_METHOD; m_fDocSource = FALSE; m_hr = E_FAIL; // GetColumnInfo m_cColumns = 0; m_rgInfo = NULL; m_pStringsBuffer = NULL; m_cColumns2 = 0; m_rgInfo2 = NULL; m_rgColumnIDs2 = NULL; m_cMasks = 0; m_rgMasks = NULL; m_pCRowObj = NULL; m_pCRowset = NULL; // MapColumnIDs m_cColumnIDs = 0; m_rgColumnIDs = NULL; m_rgColumns = NULL; m_pIUnknown = NULL; m_cOrdTbl1 = 0; m_prgOrdTbl1 = NULL; m_cOrdTbl2 = 0; m_prgOrdTbl2 = NULL; }; // @cmember Destructor virtual ~IColInfo() { // Interface pointer ASSERT(!m_pIColumnsInfo); ASSERT(!m_pIColumnsInfo2); ASSERT(!m_pICommand); ASSERT(!m_pIRowset); // GetColumnInfo ASSERT(!m_rgInfo); ASSERT(!m_pStringsBuffer); ASSERT(!m_rgInfo2); ASSERT(!m_rgColumnIDs2); ASSERT(!m_rgMasks); ASSERT(!m_pCRowObj); ASSERT(!m_pCRowset); // MapColumnIDs ASSERT(!m_rgColumnIDs); ASSERT(!m_rgColumns); }; // @cmember Test case Init BOOL Init(EINTERFACE eInterface); // @cmember Test case Terminate BOOL Terminate(); // @cmember GetDBIDs copies dbids form DBCOLUMNINFO structure and makes // param to pass to MapColIDs HRESULT GetDBIDs( BOOL fcColumnIDs=TRUE, BOOL frgColumnIDs=TRUE, BOOL frgColumns=TRUE, ULONG cExpectedRuns=1, BOOL fPrep = TRUE ); // @cmember MakeDBIDArrays copies dbids form DBCOLUMNINFO structure and makes // param to pass to MapColIDs HRESULT MakeDBIDArrays( BOOL fcColumnIDs=TRUE, BOOL frgColumnIDs=TRUE, BOOL frgColumns=TRUE ); // @cmember Compare Ordinal to CCol BOOL CheckOrdinal(HRESULT hr, BOOL bCheckOrder=TRUE); // @cmember Check HResult BOOL IfErrorParmsShouldBeNULL(); // @cmember Check Correctness of each column void CheckEachColumn(HRESULT hr,DBPROPID PropID=0,EQUERY eSQLStmt=NO_QUERY); // @cmember Variation-specific initialization BOOL Init_Var(); // @cmember Variation-specific initialization BOOL Free(BOOL fFreeIColInfo=TRUE); // @cmember Free the IColumnsInfo buffers BOOL FreeColumnInfo(DBORDINAL* pcColumns,DBCOLUMNINFO** prgInfo, OLECHAR** pStringsBuffer); // @cmember Executes MapColumnIDs on a rowset object HRESULT ExecuteMethod_row( BOOL fcColumnIDs, BOOL frgColumnIDs, BOOL frgColumns, STATEMENTKIND StmtKd, EQUERY sqlStmt, WCHAR * pStmt, EPREPARE ePrepare, ULONG cExpectedRuns=1, DBPROPID prop=0 ); // @cmember Executes MapClumnIDs on a command object HRESULT ExecuteMethod_cmd( BOOL fcColumnIDs, BOOL frgColumnIDs, BOOL frgColumns, STATEMENTKIND StmtKd, EQUERY sqlStmt, WCHAR * pStmt, EPREPARE ePrepare, ULONG cExpectedRuns=1, DBPROPID prop=0, BOOL fSingSel=FALSE ); // @cmember Obtains a row object from a rowset. BOOL GetRowFromRowset(BOOL bColInfo2); // @cmember Obtains a row object from a command. BOOL GetRowFromCommand(BOOL bColInfo2); // @cmember Obtains a row object from OpenRowset. BOOL GetRowFromOpenRW(BOOL bColInfo2); // @cmember Obtains a row object by direct binding. BOOL GetRowFromBind(BOOL bColInfo2); //Get IColumnsInfo interface on Row object BOOL GetRowIColumnsInfo(ICommand* pIC, IUnknown** pICI); // @cmember Calls a method on the row object in m_pCRowObj. HRESULT CallMethodOnRowObj(BOOL bColInfo2, METHOD_CHOICE method=INVALID_METHOD); // @cmember Checks the returned values of output params. BOOL CheckParams(HRESULT hr, METHOD_CHOICE method); // @cmember Checks the row specific columns returned by calls // on a Row object. BOOL CheckRowSpecificColumns(DBORDINAL cCols, DBCOLUMNINFO* rgInfo, DBORDINAL ulFirstOrd); // @cmember Checks the returned columns to see if the restrictions //were applied. BOOL VerifyRestrictions(); // compare the DBCOLUMNINFO struct except for: BOOL Compare_pwszName(CCol col,DBCOLUMNINFO dbColumnInfo,DBORDINAL ulIndex,EQUERY eSQLStmt); BOOL Compare_pTypeInfo(CCol col,DBCOLUMNINFO dbColumnInfo,DBORDINAL ulIndex); BOOL Compare_iOrdinal(DBORDINAL iOrdinal,DBCOLUMNINFO dbColumnInfo,DBORDINAL ulIndex); BOOL Compare_ulColumnSize(CCol col,DBCOLUMNINFO dbColumnInfo,DBORDINAL ulIndex); BOOL Compare_dwType(CCol col,DBCOLUMNINFO dbColumnInfo,DBORDINAL ulIndex); BOOL Compare_bPrecision(CCol col,DBCOLUMNINFO dbColumnInfo,DBORDINAL ulIndex); BOOL Compare_bScale(CCol col,DBCOLUMNINFO dbColumnInfo,DBORDINAL ulIndex); BOOL Compare_Columnid(CCol col,DBCOLUMNINFO dbColumnInfo,DBORDINAL ulIndex,EQUERY eSQLStmt); BOOL Compare_DBCOLUMNFLAGS_CACHEDEFERRED(CCol col,DBCOLUMNINFO dbColumnInfo,DBORDINAL ulIndex); BOOL Compare_DBCOLUMNFLAGS_ISBOOKMARK(DBCOLUMNINFO dbColumnInfo,DBORDINAL ulIndex); BOOL Compare_DBCOLUMNFLAGS_ISFIXEDLENGTH(CCol col,DBCOLUMNINFO dbColumnInfo,DBORDINAL ulIndex); BOOL Compare_DBCOLUMNFLAGS_ISLONG(CCol col,DBCOLUMNINFO dbColumnInfo,DBORDINAL ulIndex); BOOL Compare_DBCOLUMNFLAGS_ISNULLABLE(CCol col,DBCOLUMNINFO dbColumnInfo,DBORDINAL ulIndex); BOOL Compare_DBCOLUMNFLAGS_ISROWID(CCol col,DBCOLUMNINFO dbColumnInfo,DBORDINAL ulIndex); BOOL Compare_DBCOLUMNFLAGS_ISROWVER(CCol col,DBCOLUMNINFO dbColumnInfo,DBORDINAL ulIndex); BOOL Compare_DBCOLUMNFLAGS_MAYBENULLABLE(CCol col,DBCOLUMNINFO dbColumnInfo,DBORDINAL ulIndex,EQUERY eSQLStmt); BOOL Compare_DBCOLUMNFLAGS_MAYDEFER(CCol col,DBCOLUMNINFO dbColumnInfo,DBORDINAL ulIndex); BOOL Compare_DBCOLUMNFLAGS_WRITE(CCol col,DBCOLUMNINFO dbColumnInfo,DBORDINAL ulIndex); void PrintInfo(DBCOLUMNINFO * dbColumnInfo, DBORDINAL ulIndex); BOOL GetPreparation(); void SetRowsetProperties(GUID propset, DBPROPID propid); }; void IColInfo::SetRowsetProperties(GUID propset, DBPROPID propid) { //Set properties for rowsets DBPROP * rgDBProps; rgDBProps = (DBPROP *)PROVIDER_ALLOC(sizeof(DBPROP) * 1); rgDBProps->dwPropertyID = propid; rgDBProps->dwOptions = DBPROPOPTIONS_REQUIRED; rgDBProps->vValue.vt = VT_BOOL; V_BOOL(&(rgDBProps->vValue)) = VARIANT_TRUE; //Build the Set struct to set all our rowset properties m_cPropSets = 1; m_rgPropSets = (DBPROPSET *)PROVIDER_ALLOC(m_cPropSets * sizeof(DBPROPSET)); m_rgPropSets->rgProperties = rgDBProps; m_rgPropSets->rgProperties->colid = DB_NULLID; m_rgPropSets->cProperties = 1; m_rgPropSets->guidPropertySet = propset; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // GetPreparation // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BOOL IColInfo::GetPreparation() { BOOL fSucceed = FALSE; ICommand * pICommand = NULL; ICommandPrepare * pICommandPrepare = NULL; // Initialize m_ePreparation = NOTSUPPORTED; // Check for Command Support if (!m_pIDBCreateCommand) return TRUE; if (FAILED(m_pIDBCreateCommand->CreateCommand(NULL,IID_ICommand,(IUnknown **)&pICommand))) return FALSE; if (SUCCEEDED(pICommand->QueryInterface(IID_ICommandPrepare,(void **)&pICommandPrepare))) m_ePreparation = SUPPORTED; fSucceed = TRUE; SAFE_RELEASE(pICommand); SAFE_RELEASE(pICommandPrepare); return fSucceed; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // PrintInfo // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void IColInfo::PrintInfo(DBCOLUMNINFO * dbColumnInfo, DBORDINAL ulIndex) { odtLog < pwszName = " < iOrdinal = " < ulColumnSize = " < wType = " < bPrecision = " < bScale = " <m_pVoid, DELETETABLE_NO); // Create a second table for the Join variations m_pTable2 = new CTable((IUnknown *)m_pThisTestModule->m_pIUnknown2, (LPWSTR)gwszModuleName); if (!SUCCEEDED(m_pTable2->CreateTable(0,1,NULL,PRIMARY,TRUE))) return FALSE; m_cOrdTbl2 = m_pTable2->CountColumnsOnTable(); if(m_cOrdTbl2) { m_pTable2->CreateColList(FORWARD, &pwszColList, &m_cOrdTbl2, &m_prgOrdTbl2); PROVIDER_FREE(pwszColList); } // Set DSO pointer if (m_pThisTestModule->m_pIUnknown) { if(!VerifyInterface(m_pThisTestModule->m_pIUnknown, IID_IDBInitialize, DATASOURCE_INTERFACE, (IUnknown**)&m_pIDBInitialize)) return FALSE; } if (m_pIDBInitialize) m_pMyIDBInitialize = m_pIDBInitialize; // Create Data Source Object, Initialize, and get a IOpenRowset pointer. SetDBSession(m_pThisTestModule->m_pIUnknown2); // Fill in the Ordinals if (eInterface == ROWSET_INTERFACE) { m_cOrdTbl1 = m_pTable->CountColumnsOnTable(); if(m_cOrdTbl1) { m_pTable->CreateColList(FORWARD, &pwszColList, &m_cOrdTbl1, &m_prgOrdTbl1); PROVIDER_FREE(pwszColList); } } // Make sure base classes are working if ((!m_pIDBCreateCommand) && (eInterface == COMMAND_INTERFACE)) { odtLog << L"Commands not supported by Provider." << ENDL; return TEST_SKIPPED; } if (!GetPreparation()) return FALSE; return TRUE; } return FALSE; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Terminate // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BOOL IColInfo::Terminate() { COLEDB::Terminate(); SAFE_RELEASE(m_pIDBInitialize); PROVIDER_FREE(m_prgOrdTbl1); PROVIDER_FREE(m_prgOrdTbl2); m_cOrdTbl1 = 0; m_cOrdTbl2 = 0; // Drop the second table if(m_pTable2) CHECK(m_pTable2->DropTable(),S_OK); SAFE_DELETE(m_pTable2); // Release session object ReleaseDBSession(); SAFE_DELETE(m_pCRowObj); SAFE_DELETE(m_pCRowset); return(CTestCases::Terminate()); } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Init, inorder to clear properties, need to get rid of ICommand object // and get new ICommand Object // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BOOL IColInfo::Init_Var() { // Don't check columninfo by default m_fCheckIColumnsInfo = TRUE; // Reset Params m_cRowsAffected = 0; m_cColumns = 0; m_DBPROPID = 0; m_cColumnIDs = 0; m_cPropSets = 0; m_rgPropSets = NULL; m_hr = E_FAIL; // Check for Commands if (m_pIDBCreateCommand) if (FAILED(m_pIDBCreateCommand->CreateCommand(NULL,IID_ICommand,(IUnknown **)&m_pICommand))) return FALSE; // Initialize to the Command Object m_pIUnknown = m_pICommand; return TRUE; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Free_ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BOOL IColInfo::Free(BOOL fFreeIColInfo) { // Release if(fFreeIColInfo) { SAFE_RELEASE(m_pIColumnsInfo); SAFE_RELEASE(m_pIColumnsInfo2); } SAFE_RELEASE(m_pIRowset); SAFE_RELEASE(m_pICommand); if (m_rgInfo == INVALID(DBCOLUMNINFO*)) m_rgInfo = NULL; if (m_rgInfo2 == INVALID(DBCOLUMNINFO*)) m_rgInfo2 = NULL; if (m_pStringsBuffer == INVALID(WCHAR*)) m_pStringsBuffer = NULL; if (m_rgColumnIDs2!=INVALID(DBID*)) SAFE_FREE(m_rgColumnIDs2) else m_rgColumnIDs2 = NULL; if (m_rgColumns!=INVALID(DBORDINAL*)) SAFE_FREE(m_rgColumns) else m_rgColumns = NULL; if (m_rgColumnIDs!=INVALID(DBID*)) SAFE_FREE(m_rgColumnIDs) else m_rgColumnIDs = NULL; if (m_rgMasks!=INVALID(DBID*)) SAFE_FREE(m_rgMasks) else m_rgMasks = NULL; FreeColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer); FreeColumnInfo(&m_cColumns2,&m_rgInfo2,&m_pStringsBuffer); FreeProperties(&m_cPropSets, &m_rgPropSets); return TRUE; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Free_ // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BOOL IColInfo::FreeColumnInfo(DBORDINAL* pcColumns,DBCOLUMNINFO** prgInfo, OLECHAR** pStringsBuffer) { TBEGIN; // Check to see if we need to free the buffer if( prgInfo ) SAFE_FREE(*prgInfo); if( pStringsBuffer ) SAFE_FREE(*pStringsBuffer); return TRUE; } /// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // ExecuteMethod_row // // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - HRESULT IColInfo::ExecuteMethod_row ( BOOL fcColumnIDs, BOOL frgColumnIDs, BOOL frgColumns, STATEMENTKIND StmtKd, EQUERY sqlStmt, WCHAR * pStmt, EPREPARE ePrepare, ULONG cExpectedRuns, DBPROPID prop ) { HRESULT hr = E_FAIL; IID riid = IID_IRowset; // Make sure we cleanup SAFE_RELEASE(m_pIColumnsInfo); PROVIDER_FREE(m_prgOrdTbl1); m_cOrdTbl1 = 0; // SetText if (FAILED(hr=SetCommandText(m_pIMalloc,m_pICommand,m_pTable,m_pTable2->GetTableName(), StmtKd,sqlStmt,pStmt,&m_cOrdTbl1,&m_prgOrdTbl1))) goto CLEANUP; // Set property if writable if (SettableProperty(prop, DBPROPSET_ROWSET, m_pIDBInitialize)) CHECK(hr=SetRowsetProperty(m_pICommand,DBPROPSET_ROWSET,prop),S_OK); else { // If the Property is ReadOnly and the value is the same exp. S_OK if (GetProperty(prop, DBPROPSET_ROWSET, m_pICommand)) CHECK(hr=SetRowsetProperty(m_pICommand,DBPROPSET_ROWSET,prop),S_OK); else { hr=SetRowsetProperty(m_pICommand,DBPROPSET_ROWSET,prop); if(SUCCEEDED(hr)) { CHECKW(hr, DB_E_ERRORSOCCURRED); odtLog <Execute(NULL,riid,NULL, &m_cRowsAffected,(IUnknown **) &m_pIRowset))) goto CLEANUP; if (FAILED(hr=m_pIRowset->QueryInterface(IID_IColumnsInfo,(void **)&m_pIColumnsInfo))) goto CLEANUP; if (m_Method == GETCOLINFO) return hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns,&m_rgInfo,&m_pStringsBuffer); else if (m_Method == MAPCOLID) return hr=m_pIColumnsInfo->MapColumnIDs(m_cColumnIDs,m_rgColumnIDs,m_rgColumns); CLEANUP: odtLog << wszTestFailure; return hr; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // ExecuteMethod_cmd // // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - HRESULT IColInfo::ExecuteMethod_cmd ( BOOL fcColumnIDs, BOOL frgColumnIDs, BOOL frgColumns, STATEMENTKIND StmtKd, EQUERY sqlStmt, WCHAR * pStmt, EPREPARE ePrepare, ULONG cExpectedRuns, DBPROPID prop, BOOL fSingSel ) { HRESULT hr = E_FAIL; // Make sure we cleanup SAFE_RELEASE(m_pIColumnsInfo); PROVIDER_FREE(m_prgOrdTbl1); m_cOrdTbl1 = 0; // ICommandText::SetCommandText if (FAILED(hr=SetCommandText(m_pIMalloc,m_pICommand,m_pTable,m_pTable2->GetTableName(), StmtKd,sqlStmt,pStmt,&m_cOrdTbl1,&m_prgOrdTbl1))) goto CLEANUP; // Set property if writable if(prop) { if (SettableProperty(prop, DBPROPSET_ROWSET, m_pIDBInitialize)) CHECK(hr=SetRowsetProperty(m_pICommand,DBPROPSET_ROWSET,prop),S_OK); else { // If the Property is ReadOnly and the value is the same exp. S_OK if (GetProperty(prop, DBPROPSET_ROWSET, m_pICommand)) CHECK(hr=SetRowsetProperty(m_pICommand,DBPROPSET_ROWSET,prop),S_OK); else { hr=SetRowsetProperty(m_pICommand,DBPROPSET_ROWSET,prop); if(SUCCEEDED(hr)) { CHECKW(hr, DB_E_ERRORSOCCURRED); odtLog <QueryInterface(IID_IColumnsInfo,(void **) &m_pIColumnsInfo))) goto CLEANUP; } if (m_Method == MAPCOLID) { if (FAILED(hr=GetDBIDs(fcColumnIDs,frgColumnIDs,frgColumns,cExpectedRuns, !fSingSel))) goto CLEANUP; } // Prepare the Statement if ((m_ePreparation == SUPPORTED) && (!fSingSel) && (FAILED(hr=PrepareCommand(m_pICommand,ePrepare,cExpectedRuns)))) goto CLEANUP; if (m_Method == GETCOLINFO) { hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns,&m_rgInfo,&m_pStringsBuffer); if(SUCCEEDED(hr)) { // Adjust the column count for Joins if((sqlStmt == SELECT_LEFTOUTERJOIN) || (sqlStmt == SELECT_RIGHTOUTERJOIN)) COMPARE(m_cColumns, DBORDINAL((m_cOrdTbl1 + m_cOrdTbl2) + (m_cColumns ? !m_rgInfo[0].iOrdinal : 0))); else COMPARE(m_cColumns, DBORDINAL(m_cOrdTbl1 + (m_cColumns ? !m_rgInfo[0].iOrdinal : 0))); } } else if (m_Method == MAPCOLID) hr=m_pIColumnsInfo->MapColumnIDs(m_cColumnIDs,m_rgColumnIDs,m_rgColumns); else hr=E_FAIL; CLEANUP: return hr; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // GetRowFromRowset // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BOOL IColInfo::GetRowFromRowset(BOOL bColInfo2) { TBEGIN HRESULT hr = E_FAIL; BOOL bRowSup = FALSE; ULONG_PTR ulOleObj = 0; ULONG_PTR ulDSType = 0; DBCOUNTITEM cRowsObtained = 0; HROW* rghRows = NULL; //Required for using some ExtraLib functions. g_pIDBInitialize = m_pIDBInitialize; g_pIOpenRowset = m_pIOpenRowset; //Check if provider supports ROW Objects. If not, then SKIP //this test case. if(GetProperty(DBPROP_OLEOBJECTS, DBPROPSET_DATASOURCEINFO, m_pIDBInitialize, &ulOleObj)) { if((ulOleObj & DBPROPVAL_OO_ROWOBJECT) == DBPROPVAL_OO_ROWOBJECT) bRowSup = TRUE; } if(GetProperty(DBPROP_DATASOURCE_TYPE, DBPROPSET_DATASOURCEINFO, m_pIDBInitialize, &ulDSType)) { if(ulDSType & DBPROPVAL_DST_DOCSOURCE) m_fDocSource = TRUE; } m_pCRowset = new CRowset(); //Create the parent Rowset of the row objects used for testing //in the variations. m_pCRowset->SetProperty(DBPROP_CANHOLDROWS); m_pCRowset->SetProperty(DBPROP_IRowsetIdentity); m_pCRowset->SetSettableProperty(DBPROP_IRowsetLocate); TESTC_(m_pCRowset->CreateRowset(USE_OPENROWSET, IID_IRowset, m_pTable),S_OK); TESTC_(m_pCRowset->RestartPosition(),S_OK) TESTC_(m_pCRowset->GetNextRows(0, 1, &cRowsObtained, &rghRows),S_OK) m_pCRowObj = new CRowObject(); TEST3C_(hr = m_pCRowObj->CreateRowObject(m_pCRowset->pIRowset(), rghRows[0]), S_OK, DB_S_NOROWSPECIFICCOLUMNS, E_NOINTERFACE) if(bRowSup) TEST2C_(hr, S_OK, DB_S_NOROWSPECIFICCOLUMNS) else { if(E_NOINTERFACE == hr) TESTC_PROVIDER(FALSE) // ROW objects are not supported. else COMPAREW(FAILED(hr), TRUE); } if(bColInfo2) TESTC_PROVIDER(VerifyInterface(m_pCRowObj->pIRow(), IID_IColumnsInfo2, ROW_INTERFACE, (IUnknown**)&m_pIColumnsInfo2)) else TESTC(VerifyInterface(m_pCRowObj->pIRow(), IID_IColumnsInfo, ROW_INTERFACE, (IUnknown**)&m_pIColumnsInfo)) TESTC(VerifyInterface(m_pCRowset->pIRowset(), IID_IUnknown, ROWSET_INTERFACE, (IUnknown**)&m_pIUnknown)) CLEANUP: SAFE_FREE(rghRows); TRETURN } //GetRowFromRowset // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // GetRowFromCommand // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BOOL IColInfo::GetRowFromCommand(BOOL bColInfo2) { TBEGIN HRESULT hr = E_FAIL; BOOL bRowSup = FALSE; ULONG_PTR ulOleObj = 0; ULONG_PTR ulDSType = 0; DBROWCOUNT cRowsAffected = 0; IRow* pIRow = NULL; //Required for using some ExtraLib functions. g_pIDBInitialize = m_pIDBInitialize; g_pIOpenRowset = m_pIOpenRowset; //Check if provider supports ROW Objects. If not, then SKIP //this test case. if(GetProperty(DBPROP_OLEOBJECTS, DBPROPSET_DATASOURCEINFO, m_pIDBInitialize, &ulOleObj)) { if((ulOleObj & DBPROPVAL_OO_SINGLETON) == DBPROPVAL_OO_SINGLETON) bRowSup = TRUE; } if(GetProperty(DBPROP_DATASOURCE_TYPE, DBPROPSET_DATASOURCEINFO, m_pIDBInitialize, &ulDSType)) { if(ulDSType & DBPROPVAL_DST_DOCSOURCE) m_fDocSource = TRUE; } TESTC_PROVIDER(m_pIDBCreateCommand) TESTC_(m_pIDBCreateCommand->CreateCommand(NULL,IID_ICommand, (IUnknown **)&m_pICommand), S_OK) // SetText TESTC_(SetCommandText(m_pIMalloc,m_pICommand,m_pTable,m_pTable2->GetTableName(), eSELECT,SELECT_ALLFROMTBL,NULL,&m_cOrdTbl1,&m_prgOrdTbl1), S_OK) // Prepare the Statement if (m_ePreparation == SUPPORTED) TESTC_(PrepareCommand(m_pICommand,PREPARE,1), S_OK) TEST3C_(hr = m_pICommand->Execute(NULL,IID_IRow,NULL, &cRowsAffected, (IUnknown **) &pIRow), S_OK, DB_S_NOTSINGLETON, E_NOINTERFACE) if(bRowSup) TEST2C_(hr, S_OK, DB_S_NOTSINGLETON) else { if(E_NOINTERFACE == hr) TESTC_PROVIDER(FALSE) // ROW objects are not supported. else COMPAREW(FAILED(hr), TRUE); } m_pCRowObj = new CRowObject(); TESTC_(m_pCRowObj->SetRowObject(pIRow), S_OK) if(bColInfo2) TESTC_PROVIDER(VerifyInterface(m_pCRowObj->pIRow(), IID_IColumnsInfo2, ROW_INTERFACE, (IUnknown**)&m_pIColumnsInfo2)) else TESTC(VerifyInterface(m_pCRowObj->pIRow(), IID_IColumnsInfo, ROW_INTERFACE, (IUnknown**)&m_pIColumnsInfo)) TESTC(VerifyInterface(m_pICommand, IID_IUnknown, COMMAND_INTERFACE, (IUnknown**)&m_pIUnknown)) CLEANUP: SAFE_RELEASE(pIRow); SAFE_RELEASE(m_pICommand); TRETURN } //GetRowFromCommand // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // GetRowFromOpenRW // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BOOL IColInfo::GetRowFromOpenRW(BOOL bColInfo2) { TBEGIN HRESULT hr = E_FAIL; BOOL bRowSup = FALSE; ULONG_PTR ulOleObj = 0; ULONG_PTR ulDSType = 0; DBROWCOUNT cRowsAffected = 0; IRow* pIRow = NULL; //Required for using some ExtraLib functions. g_pIDBInitialize = m_pIDBInitialize; g_pIOpenRowset = m_pIOpenRowset; //Check if provider supports ROW Objects. If not, then SKIP //this test case. if(GetProperty(DBPROP_OLEOBJECTS, DBPROPSET_DATASOURCEINFO, m_pIDBInitialize, &ulOleObj)) { if((ulOleObj & DBPROPVAL_OO_SINGLETON) == DBPROPVAL_OO_SINGLETON) bRowSup = TRUE; } if(GetProperty(DBPROP_DATASOURCE_TYPE, DBPROPSET_DATASOURCEINFO, m_pIDBInitialize, &ulDSType)) { if(ulDSType & DBPROPVAL_DST_DOCSOURCE) m_fDocSource = TRUE; } TEST3C_(hr = m_pIOpenRowset->OpenRowset(NULL, &(m_pTable->GetTableID()), NULL, IID_IRow, 0, NULL, (IUnknown **) &pIRow), S_OK, DB_S_NOTSINGLETON, E_NOINTERFACE) if(bRowSup) TEST2C_(hr, S_OK, DB_S_NOTSINGLETON) else { if(E_NOINTERFACE == hr) TESTC_PROVIDER(FALSE) // ROW objects are not supported. else COMPAREW(FAILED(hr), TRUE); } m_pCRowObj = new CRowObject(); TESTC_(m_pCRowObj->SetRowObject(pIRow), S_OK) if(bColInfo2) TESTC_PROVIDER(VerifyInterface(m_pCRowObj->pIRow(), IID_IColumnsInfo2, ROW_INTERFACE, (IUnknown**)&m_pIColumnsInfo2)) else TESTC(VerifyInterface(m_pCRowObj->pIRow(), IID_IColumnsInfo, ROW_INTERFACE, (IUnknown**)&m_pIColumnsInfo)) TESTC_(hr = m_pIOpenRowset->OpenRowset(NULL, &(m_pTable->GetTableID()), NULL, IID_IRowset, 0, NULL, (IUnknown **) &m_pIUnknown), S_OK) CLEANUP: SAFE_RELEASE(pIRow); SAFE_RELEASE(m_pICommand); TRETURN } //GetRowFromOpenRW // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // GetRowFromBind // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BOOL IColInfo::GetRowFromBind(BOOL bColInfo2) { TBEGIN HRESULT hr = E_FAIL; BOOL bRowSup = FALSE; ULONG_PTR ulOleObj = 0; ULONG_PTR ulDSType = 0; ULONG cPropSets = 0; DBPROPSET* rgPropSets = NULL; DBROWCOUNT cRowsAffected = 0; IRow* pIRow = NULL; IBindResource* pIBR = NULL; IDBBinderProperties* pIDBBP = NULL; //Required for using some ExtraLib functions. g_pIDBInitialize = m_pIDBInitialize; g_pIOpenRowset = m_pIOpenRowset; //Check if provider supports direct binding. TESTC_PROVIDER(GetProperty(DBPROP_OLEOBJECTS, DBPROPSET_DATASOURCEINFO, m_pIDBInitialize, &ulOleObj) && ((ulOleObj & DBPROPVAL_OO_DIRECTBIND) == DBPROPVAL_OO_DIRECTBIND)) //Check if provider supports ROW Objects. If not, then SKIP //this test case. if((ulOleObj & DBPROPVAL_OO_ROWOBJECT) == DBPROPVAL_OO_ROWOBJECT) bRowSup = TRUE; if(GetProperty(DBPROP_DATASOURCE_TYPE, DBPROPSET_DATASOURCEINFO, m_pIDBInitialize, &ulDSType)) { if(ulDSType & DBPROPVAL_DST_DOCSOURCE) m_fDocSource = TRUE; } if(GetModInfo()->GetRootBinder()) { TESTC_PROVIDER(VerifyInterface(GetModInfo()->GetRootBinder(), IID_IBindResource, BINDER_INTERFACE, (IUnknown**)&pIBR)) TESTC(VerifyInterface(pIBR, IID_IDBBinderProperties, BINDER_INTERFACE, (IUnknown**)&pIDBBP)) TESTC(GetInitProps(&cPropSets, &rgPropSets)) TESTC_(pIDBBP->SetProperties(cPropSets, rgPropSets), S_OK) } else { TESTC_PROVIDER(VerifyInterface(m_pIOpenRowset, IID_IBindResource, SESSION_INTERFACE, (IUnknown**)&pIBR)) } if(!g_pwszRowURL) { g_pwszRowURL = GetModInfo()->GetParseObject()->GetURL(ROW_INTERFACE); if(!g_pwszRowURL) g_pwszRowURL = GetModInfo()->GetRootURL(); } if(!g_pwszRowsetURL) { g_pwszRowsetURL = GetModInfo()->GetParseObject()->GetURL(ROWSET_INTERFACE); if(!g_pwszRowsetURL) g_pwszRowsetURL = GetModInfo()->GetRootURL(); } TESTC_PROVIDER(g_pwszRowsetURL && wcslen(g_pwszRowsetURL)>3) TEST2C_(hr = pIBR->Bind(NULL, g_pwszRowURL, DBBINDURLFLAG_READ, DBGUID_ROW, IID_IRow, NULL, NULL, NULL, (IUnknown**)&pIRow), S_OK, DB_E_NOTSUPPORTED) if(bRowSup) { TESTC_(hr, S_OK) TESTC(pIRow != NULL) } else { if(DB_E_NOTSUPPORTED == hr) TESTC_PROVIDER(FALSE) // ROW objects are not supported. else COMPAREW(FAILED(hr), TRUE); } TESTC_(pIBR->Bind(NULL, g_pwszRowsetURL, DBBINDURLFLAG_READ, DBGUID_ROWSET, IID_IUnknown, NULL, NULL, NULL, (IUnknown**)&m_pIUnknown), S_OK) TESTC(m_pIUnknown != NULL) m_pCRowObj = new CRowObject(); TESTC_(m_pCRowObj->SetRowObject(pIRow), S_OK) if(bColInfo2) TESTC_PROVIDER(VerifyInterface(m_pCRowObj->pIRow(), IID_IColumnsInfo2, ROW_INTERFACE, (IUnknown**)&m_pIColumnsInfo2)) else TESTC(VerifyInterface(m_pCRowObj->pIRow(), IID_IColumnsInfo, ROW_INTERFACE, (IUnknown**)&m_pIColumnsInfo)) CLEANUP: FreeProperties(&cPropSets, &rgPropSets); SAFE_RELEASE(pIDBBP); SAFE_RELEASE(pIRow); SAFE_RELEASE(pIBR); TRETURN } //GetRowFromBind // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // CallMethodOnRowObj // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BOOL IColInfo::GetRowIColumnsInfo(ICommand* pIC, IUnknown** ppICI) { TBEGIN IRow* pIRow = NULL; TESTC(pIC && ppICI) //Get IColumnsInfo off the row object if(m_ePreparation == SUPPORTED) TESTC(SUCCEEDED(PrepareCommand(pIC,PREPARE,0))) TESTC(SUCCEEDED(pIC->Execute(NULL, IID_IRow, NULL, NULL, (IUnknown**)&pIRow))) TESTC(VerifyInterface(pIRow, IID_IColumnsInfo, ROW_INTERFACE, (IUnknown**)ppICI)) CLEANUP: SAFE_RELEASE(pIRow); TRETURN } //GetRowIColumnsInfo // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // CallMethodOnRowObj // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - HRESULT IColInfo::CallMethodOnRowObj(BOOL bColInfo2, METHOD_CHOICE method) { HRESULT hr = E_FAIL; METHOD_CHOICE methodused = INVALID_METHOD; TESTC(m_pCRowObj != NULL) if(method==INVALID_METHOD) methodused = m_Method; else methodused = method; switch (methodused) { case GETCOLINFO: if(bColInfo2) hr = m_pIColumnsInfo2->GetColumnInfo(&m_cColumns2,&m_rgInfo2,&m_pStringsBuffer); else hr = m_pIColumnsInfo->GetColumnInfo(&m_cColumns2,&m_rgInfo2,&m_pStringsBuffer); break; case MAPCOLID: if(bColInfo2) hr = m_pIColumnsInfo2->MapColumnIDs(m_cColumnIDs,m_rgColumnIDs,m_rgColumns); else hr = m_pIColumnsInfo->MapColumnIDs(m_cColumnIDs,m_rgColumnIDs,m_rgColumns); break; case GETRESCOLINFO: hr = m_pIColumnsInfo2->GetRestrictedColumnInfo(m_cMasks, m_rgMasks, 0, &m_cColumns2,&m_rgColumnIDs2,&m_rgInfo2,&m_pStringsBuffer); if(hr == DB_E_NOCOLUMN) odtLog<0 && m_pStringsBuffer!=NULL) TESTC(m_rgColumnIDs2!=NULL || m_rgInfo2!=NULL) } else TESTC(!m_cColumns2 && !m_rgColumnIDs2 && !m_rgInfo2 && !m_pStringsBuffer); break; default: TESTC(m_Method==GETCOLINFO) break; } //switch CLEANUP: TRETURN } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // CheckRowSpecificColumns // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - BOOL IColInfo::CheckRowSpecificColumns(DBORDINAL cCols, DBCOLUMNINFO* rgInfo, DBORDINAL ulFirstOrd) { TBEGIN DBORDINAL ulIndex=0; if(cCols==0) goto CLEANUP; else TESTC(cCols>0 && rgInfo!=NULL) for(ulIndex=0; ulIndex0 && m_rgMasks!=NULL) if(!m_rgInfo2 && !m_rgColumnIDs2) { TESTC(!m_pStringsBuffer) odtLog<0 && m_pStringsBuffer!=NULL) TESTC(m_rgColumnIDs2!=NULL || m_rgInfo2!=NULL) } for(iCol=0; iCol0) && (m_rgInfo2 != NULL)) COMPARE(m_rgInfo2[iCol].iOrdinal > m_rgInfo2[iCol-1].iOrdinal, TRUE); for(DBORDINAL iMask=0; iMaskeKind; //Types ofcourse must match... if(eKind != pColumnMask->eKind) continue; switch(eKind) { case DBKIND_GUID_NAME: if((pColumnID->uGuid.guid == pColumnMask->uGuid.guid) && (pColumnID->uName.pwszName)) { pwszTemp = wcsstr(pColumnID->uName.pwszName, pColumnMask->uName.pwszName); if(pwszTemp && (wcscmp(pwszTemp, pColumnID->uName.pwszName)==0)) bMatch = TRUE; } break; case DBKIND_GUID_PROPID: if((pColumnID->uGuid.guid == pColumnMask->uGuid.guid) && (pColumnID->uName.ulPropid == pColumnMask->uName.ulPropid)) bMatch = TRUE; break; case DBKIND_NAME: if(pColumnID->uName.pwszName) { pwszTemp = wcsstr(pColumnID->uName.pwszName, pColumnMask->uName.pwszName); if(pwszTemp && (wcscmp(pwszTemp, pColumnID->uName.pwszName)==0)) bMatch = TRUE; } break; case DBKIND_PGUID_NAME: if((!pColumnID->uGuid.pguid && pColumnMask->uGuid.pguid) || (pColumnID->uGuid.pguid && !pColumnMask->uGuid.pguid) ) continue; if(pColumnID->uGuid.pguid && pColumnMask->uGuid.pguid && *pColumnID->uGuid.pguid != *pColumnMask->uGuid.pguid) continue; if(pColumnID->uName.pwszName) { pwszTemp = wcsstr(pColumnID->uName.pwszName, pColumnMask->uName.pwszName); if(pwszTemp && (wcscmp(pwszTemp, pColumnID->uName.pwszName)==0)) bMatch = TRUE; } break; case DBKIND_PGUID_PROPID: if((!pColumnID->uGuid.pguid && pColumnMask->uGuid.pguid) || (pColumnID->uGuid.pguid && !pColumnMask->uGuid.pguid) ) continue; if(pColumnID->uGuid.pguid && pColumnMask->uGuid.pguid && *pColumnID->uGuid.pguid != *pColumnMask->uGuid.pguid) continue; if(pColumnID->uName.ulPropid == pColumnMask->uName.ulPropid) bMatch = TRUE; break; case DBKIND_PROPID: if(pColumnID->uName.ulPropid == pColumnMask->uName.ulPropid) bMatch = TRUE; break; case DBKIND_GUID: if(pColumnID->uGuid.guid == pColumnMask->uGuid.guid) bMatch = TRUE; break; default: //should not get here. COMPARE(TRUE, FALSE); break; }//switch } //Make sure we found a match for every column returned. TESTC(bMatch) } CLEANUP: TRETURN } //VerifyRestrictions // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // GetDBIDs // // Take DBID part of DBCOLUMNINFO and build array of DBIDs // // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - HRESULT IColInfo::GetDBIDs( BOOL fcColumnIDs, BOOL frgColumnIDs, BOOL frgColumns, ULONG cExpectedRuns, BOOL fPrep ) { HRESULT hr = E_FAIL; IColumnsInfo * pIColumnsInfo = NULL; if (!m_pICommand) return FALSE; if (FAILED(hr=m_pICommand->QueryInterface(IID_IColumnsInfo, (void **)&pIColumnsInfo))) return hr; // Prepare the Statement if ((m_ePreparation == SUPPORTED) && (fPrep) && (FAILED(hr=PrepareCommand(m_pICommand,PREPARE,cExpectedRuns)))) goto CLEANUP; if (!m_cColumns) if (FAILED(hr=pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer))) goto CLEANUP; // Make array of DBIDs if (FAILED(hr=MakeDBIDArrays(fcColumnIDs,frgColumnIDs,frgColumns))) goto CLEANUP; // Prepare the Statement if (m_ePreparation==SUPPORTED && fPrep) hr=PrepareCommand(m_pICommand,UNPREPARE,cExpectedRuns); CLEANUP: SAFE_RELEASE(pIColumnsInfo); return hr; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // MakeDBIDArrays // // Take DBID part of DBCOLUMNINFO and build array of DBIDs // // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - HRESULT IColInfo::MakeDBIDArrays( BOOL fcColumnIDs, BOOL frgColumnIDs, BOOL frgColumns ) { // Make array of DBIDs if (m_cColumns) { if (frgColumnIDs) { // Allocate memory for the array of DBID's m_rgColumnIDs = (DBID *) PROVIDER_ALLOC(sizeof(DBID) * m_cColumns); if (!m_rgColumnIDs) goto CLEANUP; // Copy values into members for(DBORDINAL ulIndex=0; ulIndex 0); TESTC(!cUnInit); TESTC(cErrors < m_cColumnIDs); break; case DB_E_ERRORSOCCURRED: TESTC(cErrors > 0); TESTC(!cUnInit); TESTC(cErrors == m_cColumnIDs); break; default: TESTC(!cErrors); TESTC(cUnInit > 0); TESTC(cUnInit == m_cColumnIDs); break; } return TRUE; CLEANUP: return FALSE; } // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // @mfunc General Compare routine that handles each part of the // DBCOLUMNINFO struct and the return code // // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - void IColInfo::CheckEachColumn ( HRESULT hr, DBPROPID PropID, EQUERY eSQLStmt ) { CCol ccol; CTable * pLocalCTable = NULL; DBORDINAL cLocalOrd = 0; DB_LORDINAL* pLocalrgOrd = NULL; DBORDINAL ulCount = 0; // If Success with a positive column count if (SUCCEEDED(hr) && m_cColumns) { // If on the Rowset change to the Rowset Object if (m_pIRowset) m_pIUnknown = m_pIRowset; //TO DO - if PropID==IRowsetLocate OR BOOKMARKS, then first //ordinal==0. // If bookmarks are present expect a 0 ordinal if (GetProperty(DBPROP_BOOKMARKS, DBPROPSET_ROWSET, m_pIUnknown)) if(!COMPARE(m_rgInfo[0].iOrdinal, 0)) odtLog<GetColInfo(pLocalrgOrd[ulCount%cLocalOrd],ccol))) ) { Compare_pwszName(ccol,m_rgInfo[ulIndex],ulIndex,eSQLStmt); Compare_pTypeInfo(ccol,m_rgInfo[ulIndex],ulIndex); Compare_iOrdinal((DBORDINAL)ulIndex+(m_rgInfo[0].iOrdinal),m_rgInfo[ulIndex],ulIndex); Compare_ulColumnSize(ccol,m_rgInfo[ulIndex],ulIndex); Compare_dwType(ccol,m_rgInfo[ulIndex],ulIndex); Compare_bPrecision(ccol,m_rgInfo[ulIndex],ulIndex); Compare_bScale(ccol,m_rgInfo[ulIndex],ulIndex); Compare_Columnid(ccol,m_rgInfo[ulIndex],ulIndex,eSQLStmt); Compare_DBCOLUMNFLAGS_CACHEDEFERRED(ccol,m_rgInfo[ulIndex],ulIndex); Compare_DBCOLUMNFLAGS_ISBOOKMARK(m_rgInfo[ulIndex],ulIndex); Compare_DBCOLUMNFLAGS_ISFIXEDLENGTH(ccol,m_rgInfo[ulIndex],ulIndex); Compare_DBCOLUMNFLAGS_ISLONG(ccol,m_rgInfo[ulIndex],ulIndex); Compare_DBCOLUMNFLAGS_ISNULLABLE(ccol,m_rgInfo[ulIndex],ulIndex); Compare_DBCOLUMNFLAGS_ISROWID(ccol,m_rgInfo[ulIndex],ulIndex); Compare_DBCOLUMNFLAGS_ISROWVER(ccol,m_rgInfo[ulIndex],ulIndex); Compare_DBCOLUMNFLAGS_MAYBENULLABLE(ccol,m_rgInfo[ulIndex],ulIndex,eSQLStmt); Compare_DBCOLUMNFLAGS_MAYDEFER(ccol,m_rgInfo[ulIndex],ulIndex); Compare_DBCOLUMNFLAGS_WRITE(ccol,m_rgInfo[ulIndex],ulIndex); } else { odtLog<< L"This is a Calculated column.\n"; PrintInfo(m_rgInfo, ulIndex); } // Incement the count ulCount++; } } } else if (SUCCEEDED(hr) && (!m_cColumns)) { // If cColumns is 0, the buffers are NULL if (m_rgInfo || m_pStringsBuffer) { odtLog<< L"ERROR: The rgInfo pointer or pStringsBuffer was not NULL where cColumns was 0.\n"; COMPARE(1, NULL); } } else COMPARE(IfErrorParmsShouldBeNULL(), TRUE); } //-------------------------------------------------------------------- // @mfunc Utility function that checks that the params of // IColumnsInfo::GetColumnInfo are correctly null if there is // an error as the return code // // hr must be a failure code before coming into this function // // @rdesc TRUE or FALSE // BOOL IColInfo::IfErrorParmsShouldBeNULL() { // Check the pointers on ERROR if (!m_rgInfo && !m_pStringsBuffer && !m_cColumns) return TRUE; odtLog<< L"ERROR: The rgInfo pointer or pStringsBuffer was not NULL on a Error.\n"; return FALSE; } //-------------------------------------------------------------------- // @mfunc Utility function that compares DBCOLUMNINFO.pwszName to the // column name in CCol.m_pwszColName // // @rdesc TRUE or FALSE // BOOL IColInfo::Compare_pwszName(CCol col,DBCOLUMNINFO dbColumnInfo,DBORDINAL ulIndex,EQUERY eSQLStmt) { // Get the Column name WCHAR wszColumnName[100] = L""; if( col.GetColName() ) wcscpy(wszColumnName,col.GetColName()); // Check to see if the Column names have been changed if( eSQLStmt == SELECT_CHANGECOLNAME ) wcscat(wszColumnName,L"X"); // Compare two strings, regarding upper and lower case if( ((wszColumnName) && (dbColumnInfo.pwszName) && (wcscmp(wszColumnName,dbColumnInfo.pwszName) == 0)) || (!(*wszColumnName) && !(dbColumnInfo.pwszName)) ) return TRUE; else odtLog<") <NAME]: expected " <<(*wszColumnName ? wszColumnName : L"") <") <ITYPEINFO]: expected NULL." <") <NUMBER]: expected " <") <TYPE]: expected " <") <COLUMNSIZE]: length of column expected " <") <PRECISION]: precision of column expected " <") <SCALE]: expects " <") <COLUMNID]: expected " <<(*wszColumnName ? wszColumnName : L"") <") <COLUMNID]: expected " <MapColumnIDs(1,rgColumnIDs,&ulOrdinal), S_OK); else if(m_pIColumnsInfo2) CHECK(m_pIColumnsInfo2->MapColumnIDs(1,rgColumnIDs,&ulOrdinal), S_OK); rgColumnIDs=NULL; // Compare two iOrdinal and ulPropid if (ulOrdinal == m_rgInfo[ulIndex].iOrdinal) return TRUE; else { odtLog<") <COLUMNID]: expected " <") <COLUMNID]: expected " <<(*wszColumnName ? wszColumnName : L"") <") <COLUMNID]: expected " <<(*wszColumnName ? wszColumnName : L"") <MapColumnIDs(1,rgColumnIDs,&ulOrdinal), S_OK); else if(m_pIColumnsInfo2) CHECK(m_pIColumnsInfo2->MapColumnIDs(1,rgColumnIDs,&ulOrdinal), S_OK); rgColumnIDs=NULL; // Compare two iOrdinal and ulPropid if (ulOrdinal == m_rgInfo[ulIndex].iOrdinal) return TRUE; else { odtLog<") <COLUMNID]: expected " <MapColumnIDs(1,rgColumnIDs,&ulOrdinal), S_OK); else if(m_pIColumnsInfo2) CHECK(m_pIColumnsInfo2->MapColumnIDs(1,rgColumnIDs,&ulOrdinal), S_OK); rgColumnIDs=NULL; // Compare two iOrdinal and ulPropid if (ulOrdinal == m_rgInfo[ulIndex].iOrdinal) return TRUE; else { odtLog<") <COLUMNID]: expected " <") <DBKIND_GUID]: Not tested. " <") <COLUMNID]: IS BAD " <") <CACHEDEFERRED]: expected, but isn't present."<") <CACHEDEFERRED]: was not expected, but was present."<ISBOOKMARK]: expected bookmark property to be set, but isn't set."<< ENDL; else if (!(dbColumnInfo.dwFlags & DBCOLUMNFLAGS_ISBOOKMARK)) odtLog<ISBOOKMARK]: expected bookmark, but isn't present."<< ENDL; else fSuccess = TRUE; } else { if (dbColumnInfo.dwFlags & DBCOLUMNFLAGS_ISBOOKMARK) odtLog<") <ISBOOKMARK]: didn't expect the bookmark, but it is present."<< ENDL; else fSuccess = TRUE; } return fSuccess; } //-------------------------------------------------------------------- // @mfunc Utility function that compares DBCOLUMNINFO.DBCOLUMNFLAGS_ISFIXEDLENGTH // // // @rdesc TRUE or FALSE // BOOL IColInfo::Compare_DBCOLUMNFLAGS_ISFIXEDLENGTH(CCol col,DBCOLUMNINFO dbColumnInfo,DBORDINAL ulIndex) { BOOL fSuccess = FALSE; // Check to see if the type is FixedLength if ((IsFixedLength(col.GetProviderType())) || (col.GetIsFixedLength())) { if (dbColumnInfo.dwFlags & DBCOLUMNFLAGS_ISFIXEDLENGTH) fSuccess = TRUE; else odtLog<") <FIXEDLENGTH]: type is fixedlen but flag not set."<") <FIXEDLENGTH]: type is not fixedlen but flag was set."<") <ISLONG]: type is Long but flag not set."<") <ISLONG]: type is not Long but flag was set."<< ENDL; else fSuccess = TRUE; } return fSuccess; } //-------------------------------------------------------------------- // @mfunc Utility function that compares DBCOLUMNINFO.DBCOLUMNFLAGS_ISNULLABLE // // // @rdesc TRUE or FALSE // BOOL IColInfo::Compare_DBCOLUMNFLAGS_ISNULLABLE(CCol col,DBCOLUMNINFO dbColumnInfo,DBORDINAL ulIndex) { BOOL fSuccess = FALSE; // See if the Column is NULLABLE if (col.GetNullable()) { if (dbColumnInfo.dwFlags & DBCOLUMNFLAGS_ISNULLABLE) fSuccess = TRUE; else odtLog<") <ISNULLABLE]: expected, but isn't present."<") <ISNULLABLE]: is not expected, but is present."<") <ISROWID]: returned for this column."<") <ISROWVER]: returned for this column and the column is NULLABLE or WRITEABLE."<") <MAYBENULL]: expected, but isn't present."<") <MAYDEFER]: expected, but isn't present."<") <MAYDEFER]: was not expected, but was present."<") <WRITE & WRITEUNKNOWN]: not expected, but both are present."<") <WRITE or WRITEUNKNOWN]: is not expected, but is present."<GetColumnInfo(&cColumns,&rgInfo,&pStringsBuffer),S_OK); // build array of DBIDs if(cColumns) { cColumnIDs = cColumns; rgColumnIDs = (DBID *) PROVIDER_ALLOC(sizeof(DBID) * cColumns); rgColumns = (DBORDINAL *) PROVIDER_ALLOC(sizeof(DBORDINAL) * cColumns); for(index=0;indexGetNextRows(0,0,1,&cRowsObtained,&rghRows), ExpectedHr); // Make sure everything still works after commit or abort if ((eTxn == ETXN_COMMIT && m_fPrepareCommitPreserve) || (eTxn == ETXN_ABORT && m_fPrepareAbortPreserve)) ExpColInfoHr = S_OK; // Transaction object prepares so I have to check for S_OK // Make sure everything still works after commit or abort CHECK(pIColumnsInfo->GetColumnInfo(&cColumns,&rgInfo,&pStringsBuffer), ExpColInfoHr); { // Transaction object doesn't prepare so I have to check for S_OK fSuccess = CHECK(pIColumnsInfo->MapColumnIDs(cColumnIDs,rgColumnIDs,rgColumns),ExpColInfoHr); } CLEANUP: // Release the objects and cleanup memory SAFE_RELEASE(pIColumnsInfo); PROVIDER_FREE(rgInfo); PROVIDER_FREE(pStringsBuffer); // Free the memory allocated for MapColIDs for(index=0;indexReleaseRows(cRowsObtained, rghRows, NULL, NULL, NULL),S_OK); PROVIDER_FREE(rghRows); } //Return code of Commit/Abort will vary depending on whether //or not we have an open txn, so adjust accordingly if (fRetaining) ExpectedHr = S_OK; else ExpectedHr = XACT_E_NOTRANSACTION; CleanUpTransaction(ExpectedHr); if (fSuccess) return TEST_PASS; else return TEST_FAIL; } //*----------------------------------------------------------------------- // @mfunc TestTxn // Tests commit/abort with respect to IAccessor on commands // // @rdesc TEST_PASS or TEST_FAIL // int Zombie::TestTxnRowset(ETXN eTxn,BOOL fRetaining,BOOL fMultRowsets) { BOOL fSuccess = FALSE; HRESULT ExpectedHr = E_UNEXPECTED; DBORDINAL index = 0; DBCOUNTITEM cRowsObtained = 0; HROW * rghRows = NULL; DBORDINAL cColumnIDs = 0; DBID * rgColumnIDs = NULL; DBORDINAL * rgColumns = NULL; DBORDINAL cColumns = 0; DBCOLUMNINFO * rgInfo = NULL; WCHAR * pStringsBuffer = NULL; IColumnsInfo * pIColumnsInfo = NULL; ULONG cPropSets = 0; DBPROPSET * rgPropSets = NULL; IColumnsInfo * pIRowset1 = NULL; DBORDINAL cColumns1 = 0; DBCOLUMNINFO * rgColumns1 = NULL; OLECHAR* pStringsBuffer1 = NULL; IColumnsInfo * pIRowset2 = NULL; DBORDINAL cColumns2 = 0; DBCOLUMNINFO * rgColumns2 = NULL; OLECHAR* pStringsBuffer2 = NULL; IColumnsInfo * pIRowset3 = NULL; DBORDINAL cColumns3 = 0; DBCOLUMNINFO * rgColumns3 = NULL; OLECHAR* pStringsBuffer3 = NULL; if( (SupportedProperty(DBPROP_BOOKMARKS, DBPROPSET_ROWSET, m_pIDBCreateSession)) && (SettableProperty(DBPROP_BOOKMARKS, DBPROPSET_ROWSET, m_pIDBCreateSession)) ) SetProperty(DBPROP_BOOKMARKS,DBPROPSET_ROWSET, &cPropSets,&rgPropSets,DBTYPE_BOOL,VARIANT_TRUE,DBPROPOPTIONS_REQUIRED); if (!StartTransaction(SELECT_ALLFROMTBL, (IUnknown **)&pIColumnsInfo, cPropSets, rgPropSets, NULL, ISOLATIONLEVEL_READUNCOMMITTED, TRUE)) goto CLEANUP; if (fMultRowsets) { if (m_pICommand) { CHECK(m_pICommand->Execute(NULL,IID_IColumnsInfo,NULL,NULL,(IUnknown**)&pIRowset1),S_OK); CHECK(m_pICommand->Execute(NULL,IID_IColumnsInfo,NULL,NULL,(IUnknown**)&pIRowset2),S_OK); CHECK(m_pICommand->Execute(NULL,IID_IColumnsInfo,NULL,NULL,(IUnknown**)&pIRowset3),S_OK); } } //Make sure everything still works after commit or abort CHECK(pIColumnsInfo->GetColumnInfo(&cColumns,&rgInfo,&pStringsBuffer),S_OK); // build array of DBIDs if(cColumns) { cColumnIDs = cColumns; rgColumnIDs = (DBID *) PROVIDER_ALLOC(sizeof(DBID) * cColumns); rgColumns = (DBORDINAL *) PROVIDER_ALLOC(sizeof(DBORDINAL) * cColumns); for(index=0;indexGetNextRows(0,0,1,&cRowsObtained,&rghRows), ExpectedHr); //Make sure everything still works after commit or abort if (CHECK(pIColumnsInfo->GetColumnInfo(&cColumns,&rgInfo,&pStringsBuffer),ExpectedHr)) { fSuccess = CHECK(pIColumnsInfo->MapColumnIDs(cColumnIDs,rgColumnIDs,rgColumns),ExpectedHr); // make sure rowset1-3 are still alive if (pIRowset1) CHECK(pIRowset1->GetColumnInfo(&cColumns1,&rgColumns1,&pStringsBuffer1),ExpectedHr); if (pIRowset2) CHECK(pIRowset2->GetColumnInfo(&cColumns2,&rgColumns2,&pStringsBuffer2),ExpectedHr); if (pIRowset3) CHECK(pIRowset3->GetColumnInfo(&cColumns3,&rgColumns3,&pStringsBuffer3),ExpectedHr); } CLEANUP: // Release the row handle on the 1st rowset if (rghRows) { CHECK(m_pIRowset->ReleaseRows(cRowsObtained, rghRows, NULL, NULL, NULL),S_OK); PROVIDER_FREE(rghRows); } // Release the objects and cleanup memory SAFE_RELEASE(pIColumnsInfo); PROVIDER_FREE(rgInfo); PROVIDER_FREE(pStringsBuffer); PROVIDER_FREE(pStringsBuffer1); PROVIDER_FREE(pStringsBuffer2); PROVIDER_FREE(pStringsBuffer3); // Free the memory allocated for MapColIDs for(index=0;indexGetColumnInfo(&cColumns,&rgInfo,&pStringsBuffer),S_OK); // build array of DBIDs if(cColumns) { cColumnIDs = cColumns; rgColumnIDs = (DBID *) PROVIDER_ALLOC(sizeof(DBID) * cColumns); rgColumns = (DBORDINAL *) PROVIDER_ALLOC(sizeof(DBORDINAL) * cColumns); for(index=0;indexGetNextRows(0,0,1,&cRowsObtained,&rghRows), ExpectedHr); //Make sure everything still works after commit or abort // Per spec, E_UNEXPECTED will only be returned for Rowsets. if (CHECK(pIColumnsInfo->GetColumnInfo(&cColumns,&rgInfo,&pStringsBuffer),S_OK)) { fSuccess = CHECK(pIColumnsInfo->MapColumnIDs(cColumnIDs,rgColumnIDs,rgColumns),S_OK); } CLEANUP: // Release the row handle on the 1st rowset if (rghRows) { CHECK(m_pIRowset->ReleaseRows(cRowsObtained, rghRows, NULL, NULL, NULL),S_OK); PROVIDER_FREE(rghRows); } // Release the objects and cleanup memory SAFE_RELEASE(pIColumnsInfo); PROVIDER_FREE(rgInfo); PROVIDER_FREE(pStringsBuffer); // Free the memory allocated for MapColIDs for(index=0;indexSetTestCaseParam(param); \ pCTestCase->SetOwningMod(iCase-1, pCThisTestModule); \ return pCTestCase; //2 COPY_TEST_CASE(GetColInfoRow_Cmd, GetColInfoRow_Rowset) COPY_TEST_CASE(MapColIDRow_Cmd, MapColIDRow_Rowset) COPY_TEST_CASE(GetResColInfoRow_Cmd, GetResColInfoRow_Rowset) //3 COPY_TEST_CASE(GetColInfoRow_OpenRW, GetColInfoRow_Rowset) COPY_TEST_CASE(MapColIDRow_OpenRW, MapColIDRow_Rowset) COPY_TEST_CASE(GetResColInfoRow_OpenRW, GetResColInfoRow_Rowset) //4 COPY_TEST_CASE(GetColInfoRow_Bind, GetColInfoRow_Rowset) COPY_TEST_CASE(MapColIDRow_Bind, MapColIDRow_Rowset) COPY_TEST_CASE(GetResColInfoRow_Bind, GetResColInfoRow_Rowset) //5 COPY_TEST_CASE(GetColInfoRow_IColInfo2, GetColInfoRow_Rowset) COPY_TEST_CASE(MapColIDRow_IColInfo2, MapColIDRow_Rowset) COPY_TEST_CASE(GetColInfo_SingSel, GetColInfo_Command) COPY_TEST_CASE(MapColID_SingSel, MapColID_Command) //NOTE: The #ifdef block below is only for test wizard. TestWizard has too many //strict rules in the parsing code and requires a 1:1 correspondence between //testcases and the map. What the #else section is doing is basically "reusing" //existing testcases by just passing in a parameter which changes the behvior. //So we make LTM think there are various cases in here with different names, but in //reality we only have to maintain code for the unique cases. #if 0 // {{ TCW_TESTMODULE(ThisModule) TEST_MODULE(13, ThisModule, gwszModuleDescrip) TEST_CASE(1, GetColInfo_Command) TEST_CASE(2, GetColInfo_ExecuteRowset) TEST_CASE(3, GetColInfo_OpenRowset) TEST_CASE(4, GetColInfoRow_Rowset) TEST_CASE(5, GetResColInfoRow_Rowset) TEST_CASE(6, MapColID_Command) TEST_CASE(7, MapColID_ExecuteRowset) TEST_CASE(8, MapColID_OpenRowset) TEST_CASE(9, MapColIDRow_Rowset) TEST_CASE(10, ZombieClassCmd) TEST_CASE(11, ZombieClassRowset) TEST_CASE(12, ZombieClassRow) TEST_CASE(13, ExtendedErrors) END_TEST_MODULE() // }} TCW_TESTMODULE_END #else TEST_MODULE(26, ThisModule, gwszModuleDescrip) TEST_CASE_WITH_PARAM(1, GetColInfo_Command, TC_Cmd) TEST_CASE_WITH_PARAM(2, GetColInfo_SingSel, TC_SingSel) TEST_CASE(3, GetColInfo_ExecuteRowset) TEST_CASE(4, GetColInfo_OpenRowset) TEST_CASE(5, GetColInfoRow_Rowset) TEST_CASE_WITH_PARAM(6, GetColInfoRow_Cmd, TC_Cmd) TEST_CASE_WITH_PARAM(7, GetColInfoRow_OpenRW, TC_OpenRW) TEST_CASE_WITH_PARAM(8, GetColInfoRow_Bind, TC_Bind) TEST_CASE_WITH_PARAM(9, GetColInfoRow_IColInfo2, TC_IColInfo2) TEST_CASE(10, GetResColInfoRow_Rowset) TEST_CASE_WITH_PARAM(11, GetResColInfoRow_Cmd, TC_Cmd) TEST_CASE_WITH_PARAM(12, GetResColInfoRow_OpenRW, TC_OpenRW) TEST_CASE_WITH_PARAM(13, GetResColInfoRow_Bind, TC_Bind) TEST_CASE_WITH_PARAM(14, MapColID_Command, TC_Cmd) TEST_CASE_WITH_PARAM(15, MapColID_SingSel, TC_SingSel) TEST_CASE(16, MapColID_ExecuteRowset) TEST_CASE(17, MapColID_OpenRowset) TEST_CASE(18, MapColIDRow_Rowset) TEST_CASE_WITH_PARAM(19, MapColIDRow_Cmd, TC_Cmd) TEST_CASE_WITH_PARAM(20, MapColIDRow_OpenRW, TC_OpenRW) TEST_CASE_WITH_PARAM(21, MapColIDRow_Bind, TC_Bind) TEST_CASE_WITH_PARAM(22, MapColIDRow_IColInfo2, TC_IColInfo2) TEST_CASE(23, ZombieClassCmd) TEST_CASE(24, ZombieClassRowset) TEST_CASE(25, ZombieClassRow) TEST_CASE(26, ExtendedErrors) END_TEST_MODULE() #endif // {{ TCW_TC_PROTOTYPE(GetColInfo_Command) //*----------------------------------------------------------------------- //| Test Case: GetColInfo_Command - IColumnsInfo on a command object //| Created: 09/20/96 //| Updated: 04/25/98 //*----------------------------------------------------------------------- //-------------------------------------------------------------------- // @mfunc TestCase Initialization Routine // // @rdesc TRUE or FALSE // BOOL GetColInfo_Command::Init() { // Initialize for IColumnsInfo::GetColumnInfo m_Method = GETCOLINFO; ULONG_PTR ulOleObj = 0; if(!GetProperty(DBPROP_OLEOBJECTS, DBPROPSET_DATASOURCEINFO, GetModInfo()->GetThisTestModule()->m_pIUnknown, &ulOleObj) || !(ulOleObj & DBPROPVAL_OO_SINGLETON)) { if(m_eTestCase == TC_SingSel) { odtLog<GetColumnInfo(NULL, &m_rgInfo, &m_pStringsBuffer), E_INVALIDARG); // Validate the columns CheckEachColumn(m_hr); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(2) //*----------------------------------------------------------------------- // @mfunc E_INVALIDARG: rgInfo is NULL // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_2() { TBEGIN; // Initialize the variation INIT; // Set text on command TESTC_(SetCommandText(m_pIMalloc, m_pICommand, m_pTable, NULL, eSELECT, SELECT_COLLISTFROMTBL, NULL),S_OK); // Prepare the Statement if( m_ePreparation == SUPPORTED ) { TESTC_(m_hr=PrepareCommand(m_pICommand,PREPARE,1),S_OK); } if(m_eTestCase == TC_SingSel) { TESTC(GetRowIColumnsInfo(m_pICommand, (IUnknown**)&m_pIColumnsInfo)) } else { TESTC(VerifyInterface(m_pICommand, IID_IColumnsInfo, COMMAND_INTERFACE, (IUnknown **)&m_pIColumnsInfo)); } // Dirty the output params m_cColumns = 99; m_pStringsBuffer = INVALID(WCHAR*); // Run testing interface, validate params TESTC_(m_hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, NULL, &m_pStringsBuffer), E_INVALIDARG); // Validate the columns CheckEachColumn(m_hr); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(3) //*----------------------------------------------------------------------- // @mfunc E_INVALIDARG: pStringsBuffer is NULL // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_3() { TBEGIN; // Initialize the variation INIT; // Set text on command TESTC_(SetCommandText(m_pIMalloc, m_pICommand, m_pTable, NULL, eSELECT, SELECT_COLLISTFROMTBL, NULL),S_OK); // Prepare the Statement if( m_ePreparation == SUPPORTED ) { TESTC_(m_hr=PrepareCommand(m_pICommand,PREPARE,1),S_OK); } if(m_eTestCase == TC_SingSel) { TESTC(GetRowIColumnsInfo(m_pICommand, (IUnknown**)&m_pIColumnsInfo)) } else { TESTC(VerifyInterface(m_pICommand, IID_IColumnsInfo, COMMAND_INTERFACE, (IUnknown **)&m_pIColumnsInfo)); } // Dirty the output params m_cColumns = 99; m_rgInfo = INVALID(DBCOLUMNINFO*); // Run testing interface, validate params TESTC_(m_hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, NULL), E_INVALIDARG); // Validate the columns CheckEachColumn(m_hr); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(4) //*----------------------------------------------------------------------- // @mfunc DB_E_NOCOMMAND: CommandText is not Set // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_4() { TBEGIN; // Initialize the variation INIT; if(m_eTestCase == TC_SingSel) goto CLEANUP; //skip test. TESTC(VerifyInterface(m_pICommand, IID_IColumnsInfo, COMMAND_INTERFACE, (IUnknown **)&m_pIColumnsInfo)); // Dirty the output params m_cColumns = 99; m_rgInfo = INVALID(DBCOLUMNINFO*); m_pStringsBuffer= INVALID(WCHAR*); // Validate return code TESTC_(m_hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer), DB_E_NOCOMMAND); // Validate the columns CheckEachColumn(m_hr); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(5) //*----------------------------------------------------------------------- // @mfunc DB_E_NOCOMMAND: CommandText is Set to Empty // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_5() { TBEGIN; WCHAR * pSQLSet = NULL; if(m_eTestCase==TC_SingSel) goto CLEANUP; // Initialize the variation INIT; // Dirty the output params m_cColumns = 99; m_rgInfo = INVALID(DBCOLUMNINFO*); m_pStringsBuffer= INVALID(WCHAR*); TESTC_(m_hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSQL, SELECT_ALLFROMTBL, pSQLSet, NEITHER, 1), DB_E_NOCOMMAND); // Validate the columns CheckEachColumn(m_hr); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(6) //*----------------------------------------------------------------------- // @mfunc DB_E_NOCOMMAND: CommandText is Set to NULL // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_6() { TBEGIN; if(m_eTestCase==TC_SingSel) goto CLEANUP; // Initialize the variation INIT; // Dirty the output params m_cColumns = 99; m_rgInfo = INVALID(DBCOLUMNINFO*); m_pStringsBuffer= INVALID(WCHAR*); TESTC_(m_hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSQL, SELECT_ALLFROMTBL, NULL, NEITHER, 1), DB_E_NOCOMMAND); // Validate the columns CheckEachColumn(m_hr); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(7) //*----------------------------------------------------------------------- // @mfunc DB_E_NOTPREPARED/S_OK: CommandText is Set, Prepared, and Unprepared // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_7() { TBEGIN; HRESULT Exphr = S_OK; if(m_eTestCase==TC_SingSel) goto CLEANUP; // Initialize the variation INIT; // Dirty the output params m_cColumns = 99; m_rgInfo = INVALID(DBCOLUMNINFO*); m_pStringsBuffer= INVALID(WCHAR*); // Check to see if the Provider supports ICommandPrepare if( m_ePreparation == SUPPORTED ) Exphr = DB_E_NOTPREPARED; TESTC_(m_hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_COLLISTFROMTBL, NULL, BOTH, 1), Exphr); // Validate the columns CheckEachColumn(m_hr); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(8) //*----------------------------------------------------------------------- // @mfunc DB_E_NOTPREPARED/S_OK: CommandText is Set, but not Prepared // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_8() { TBEGIN; HRESULT Exphr = S_OK; if(m_eTestCase==TC_SingSel) goto CLEANUP; // Initialize the variation INIT; // Dirty the output params m_cColumns = 99; m_rgInfo = INVALID(DBCOLUMNINFO*); m_pStringsBuffer= INVALID(WCHAR*); // Check to see if the Provider supports ICommandPrepare if( m_ePreparation == SUPPORTED ) Exphr = DB_E_NOTPREPARED; TESTC_(m_hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_COLLISTFROMTBL, NULL, NEITHER, 1), Exphr); // Validate the columns CheckEachColumn(m_hr); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(9) //*----------------------------------------------------------------------- // @mfunc S_OK: CommandText is Set and Prepared // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_9() { TBEGIN; // Initialize the variation INIT; TESTC_(m_hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_COLLISTFROMTBL, NULL, PREPARE, 1, 0, (m_eTestCase==TC_SingSel)), S_OK); // Validate the columns CheckEachColumn(m_hr); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(10) //*----------------------------------------------------------------------- // @mfunc S_OK: CommandText includes duplicate columns // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_10() { TBEGIN; // Initialize the variation INIT; // Run testing interface, validate params TEST2C_(m_hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_DUPLICATECOLUMNS, NULL, PREPARE,1, 0,(m_eTestCase==TC_SingSel)), S_OK, DB_E_NOTSUPPORTED); //Skip variation if query is not supported. TESTC_PROVIDER(m_hr != DB_E_NOTSUPPORTED) // Validate the columns CheckEachColumn(m_hr); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(11) //*----------------------------------------------------------------------- // @mfunc S_OK: CommandText is Set, then change the Text // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_11() { TBEGIN; HRESULT hr=E_FAIL; // Initialize the variation INIT; // Set text on command TESTC_(SetCommandText(m_pIMalloc, m_pICommand, m_pTable, NULL, eSELECT, SELECT_COLLISTFROMTBL, NULL),S_OK); // Prepare the Statement if( m_ePreparation == SUPPORTED ) { TESTC_(m_hr=PrepareCommand(m_pICommand,PREPARE,1),S_OK); } // Set text on command TEST2C_(hr = SetCommandText(m_pIMalloc, m_pICommand, m_pTable, NULL, eSELECT, SELECT_REVCOLLIST, NULL),S_OK, DB_E_NOTSUPPORTED); //Skip variation if query is not supported. TESTC_PROVIDER(hr != DB_E_NOTSUPPORTED) // Prepare the Statement if( m_ePreparation == SUPPORTED ) { TESTC_(m_hr=PrepareCommand(m_pICommand,PREPARE,1),S_OK); } TESTC_(m_hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_ALLFROMTBL, NULL, PREPARE,1, 0,(m_eTestCase==TC_SingSel)), S_OK); // Validate the columns CheckEachColumn(m_hr); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(12) //*----------------------------------------------------------------------- // @mfunc S_OK: CommandText contains a count(*) // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_12() { TBEGIN; // Initialize the variation INIT; TEST2C_(m_hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_COUNT, NULL, PREPARE,1, 0,(m_eTestCase==TC_SingSel)), S_OK, DB_E_NOTSUPPORTED); //Skip variation if query is not supported. TESTC_PROVIDER(m_hr != DB_E_NOTSUPPORTED); // Validate the columns CheckEachColumn(m_hr,0,SELECT_COUNT); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(13) //*----------------------------------------------------------------------- // @mfunc S_OK: CommandText contains different column names // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_13() { TBEGIN; // Initialize the variation INIT; TEST2C_(m_hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_CHANGECOLNAME, NULL, PREPARE,1, 0,(m_eTestCase==TC_SingSel)), S_OK, DB_E_NOTSUPPORTED); //Skip variation if query is not supported. TESTC_PROVIDER(m_hr != DB_E_NOTSUPPORTED) // Validate the columns CheckEachColumn(m_hr,0,SELECT_CHANGECOLNAME); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(14) //*----------------------------------------------------------------------- // @mfunc S_OK: CommandText contains a insert statement // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_14() { TBEGIN; if(m_eTestCase==TC_SingSel) goto CLEANUP; //If the provider is read only, skip the variation. if( g_fReadOnlyProvider || m_pTable->GetSQLSupport() == DBPROPVAL_SQL_NONE ) { odtLog << L"Provider is ReadOnly." << ENDL; return TEST_SKIPPED; } // Initialize the variation INIT; TESTC_(m_hr=ExecuteMethod_cmd(FALSE, FALSE, FALSE, eSELECT, INSERT_1ROW, NULL, PREPARE), S_OK); // Validate the columns CheckEachColumn(m_hr); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(15) //*----------------------------------------------------------------------- // @mfunc S_OK: CommandText contains a select from an Empty Rowset // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_15() { TBEGIN; HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; // Initialize the variation INIT; if(m_eTestCase==TC_SingSel) { IRow* pIRow = NULL; hr=SetCommandText(m_pIMalloc,m_pICommand,m_pTable,m_pTable2->GetTableName(), eSELECT,SELECT_EMPTYROWSET,NULL,NULL,NULL); //Skip variation if query is not supported. TESTC_PROVIDER(hr != DB_E_NOTSUPPORTED) CHECK(hr, S_OK); if(m_ePreparation == SUPPORTED) COMPARE(SUCCEEDED(PrepareCommand(m_pICommand,PREPARE,0)), TRUE); CHECK(m_pICommand->Execute(NULL, IID_IRow, NULL, NULL, (IUnknown**)&pIRow), DB_E_NOTFOUND); SAFE_RELEASE(pIRow); FREE; return TEST_PASS; } TEST2C_(hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_EMPTYROWSET, NULL, PREPARE), S_OK, DB_E_NOTSUPPORTED) //Skip variation if query is not supported. TESTC_PROVIDER(hr != DB_E_NOTSUPPORTED) // Validate the columns CheckEachColumn(hr); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(16) //*----------------------------------------------------------------------- // @mfunc S_OK: Base table contains no rows // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_16() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; ULONG cRows = 0; // Initialize the variation INIT; //Check to see if the DSO is ReadOnly //Commands are required for Delete if(!g_fReadOnlyProvider && m_pTable->GetSQLSupport() != DBPROPVAL_SQL_NONE) { // Delete all rows in the table. if (!CHECK(m_pTable->Delete(),S_OK)) goto CLEANUP; } else { // Drop the table and create an empty one if (!CHECK(m_pTable->DropTable(),S_OK)) goto CLEANUP; if (!SUCCEEDED(m_pTable->CreateTable(0,1,NULL,PRIMARY,TRUE))) goto CLEANUP; } if(m_eTestCase==TC_SingSel) { IRow* pIRow = NULL; TEST2C_(hr=SetCommandText(m_pIMalloc,m_pICommand,m_pTable,m_pTable2->GetTableName(), eSELECT,SELECT_EMPTYROWSET,NULL,NULL,NULL), S_OK, DB_E_NOTSUPPORTED); //Skip variation if query is not supported. if(hr == DB_E_NOTSUPPORTED) { FREE; return TEST_SKIPPED; } if(m_ePreparation == SUPPORTED) COMPARE(SUCCEEDED(PrepareCommand(m_pICommand,PREPARE,0)), TRUE); CHECK(m_pICommand->Execute(NULL, IID_IRow, NULL, NULL, (IUnknown**)&pIRow), DB_E_NOTFOUND); SAFE_RELEASE(pIRow); FREE; return TEST_PASS; } if (CHECK(hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_COLLISTFROMTBL, NULL, PREPARE), S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr); CLEANUP: for(cRows=0;cRows<10;cRows++) m_pTable->Insert(); FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(17) //*----------------------------------------------------------------------- // @mfunc S_OK: CommandText contains a update statement // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_17() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; if(m_eTestCase==TC_SingSel) return TEST_SKIPPED; //If the provider is read only, skip the variation. if(g_fReadOnlyProvider || m_pTable->GetSQLSupport() == DBPROPVAL_SQL_NONE) { odtLog << L"Provider is ReadOnly." << ENDL; return TEST_SKIPPED; } // Initialize the variation INIT; if (CHECK(hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eUPDATE, SELECT_EMPTYROWSET, NULL, PREPARE), S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr); FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(18) //*----------------------------------------------------------------------- // @mfunc S_OK: CommandText contains a delete statement // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_18() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; if(m_eTestCase==TC_SingSel) return TEST_SKIPPED; //If the provider is read only, skip the variation. if(g_fReadOnlyProvider || m_pTable->GetSQLSupport() == DBPROPVAL_SQL_NONE) { odtLog << L"Provider is ReadOnly." << ENDL; return TEST_SKIPPED; } // Initialize the variation INIT; hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eDELETE, SELECT_EMPTYROWSET, NULL, PREPARE); if (CHECK(hr, S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr); FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(19) //*----------------------------------------------------------------------- // @mfunc S_OK: Ask for DBPROP_IRowsetLocate on a Select Statement // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_19() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; if(m_eTestCase==TC_SingSel) return TEST_SKIPPED; if (!SupportedProperty(DBPROP_IRowsetLocate, DBPROPSET_ROWSET, m_pIDBInitialize)) { odtLog << L"IRowsetLocate is not supported.\n"; return TEST_SKIPPED; } // Initialize the variation INIT; if (CHECK(hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_ALLFROMTBL, NULL, PREPARE, 1, DBPROP_IRowsetLocate), S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr, DBPROP_IRowsetLocate); FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(20) //*----------------------------------------------------------------------- // @mfunc S_OK: Ask for DBPROP_BOOKMARKS on a Select Statement // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_20() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; if(m_eTestCase==TC_SingSel) return TEST_SKIPPED; if (!SupportedProperty(DBPROP_BOOKMARKS, DBPROPSET_ROWSET, m_pIDBInitialize)) { odtLog << L"Bookmarks are not supported.\n"; return TEST_SKIPPED; } // Initialize the variation INIT; if (CHECK(hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_ALLFROMTBL, NULL, PREPARE, 1, DBPROP_BOOKMARKS), S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr,DBPROP_BOOKMARKS); FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(21) //*----------------------------------------------------------------------- // @mfunc S_OK: Ask for DBPROP_BOOKMARKS on a Insert Statement // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_21() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; if(m_eTestCase==TC_SingSel) return TEST_SKIPPED; if (!SupportedProperty(DBPROP_BOOKMARKS, DBPROPSET_ROWSET, m_pIDBInitialize)) { odtLog << L"Bookmarks are not supported.\n"; return TEST_SKIPPED; } //If the provider is read only, skip the variation. if(g_fReadOnlyProvider || m_pTable->GetSQLSupport() == DBPROPVAL_SQL_NONE) { odtLog << L"Provider is ReadOnly." << ENDL; return TEST_SKIPPED; } // Initialize the variation INIT; hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, INSERT_1ROW, NULL, PREPARE, 1, DBPROP_BOOKMARKS); if (CHECK(hr, S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr,DBPROP_BOOKMARKS); FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(22) //*----------------------------------------------------------------------- // @mfunc S_OK: Ask for DBPROP_DEFERRED on a Select Statement // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_22() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; if(m_eTestCase==TC_SingSel) return TEST_SKIPPED; if (!SupportedProperty(DBPROP_DEFERRED, DBPROPSET_ROWSET, m_pIDBInitialize)) { odtLog << L"Deferred is not supported.\n"; return TEST_SKIPPED; } // Initialize the variation INIT; if (CHECK(hr=ExecuteMethod_cmd(FALSE, FALSE, FALSE, eSELECT, SELECT_ALLFROMTBL, NULL, PREPARE, 1, DBPROP_DEFERRED), S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr,DBPROP_DEFERRED); FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(23) //*----------------------------------------------------------------------- // @mfunc S_OK: Ask for DBPROP_CACHEDEFERRED on a Select Statement // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_23() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; if(m_eTestCase==TC_SingSel) return TEST_SKIPPED; if (!SupportedProperty(DBPROP_CACHEDEFERRED, DBPROPSET_ROWSET, m_pIDBInitialize)) { odtLog << L"Cache Deferred is not supported.\n"; return TEST_SKIPPED; } // Initialize the variation INIT; if (CHECK(hr=ExecuteMethod_cmd(FALSE, FALSE, FALSE, eSELECT, SELECT_ALLFROMTBL, NULL, PREPARE, 1, DBPROP_CACHEDEFERRED), S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr,DBPROP_CACHEDEFERRED); FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(24) //*----------------------------------------------------------------------- // @mfunc S_OK: Ask for DBPROP_MAYWRITECOLUMN on a Select Statement // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_24() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; if(m_eTestCase==TC_SingSel) return TEST_SKIPPED; if (!SupportedProperty(DBPROP_MAYWRITECOLUMN, DBPROPSET_ROWSET, m_pIDBInitialize)) { odtLog << L"May Write Column is not supported.\n"; return TEST_SKIPPED; } // Initialize the variation INIT; if (CHECK(hr=ExecuteMethod_cmd(FALSE, FALSE, FALSE, eSELECT, SELECT_ALLFROMTBL, NULL, PREPARE, 1, DBPROP_MAYWRITECOLUMN), S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr,DBPROP_MAYWRITECOLUMN); FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(25) //*----------------------------------------------------------------------- // @mfunc S_OK: CommandText contains a select from view // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_Command::Variation_25() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; if(m_eTestCase==TC_SingSel) return TEST_SKIPPED; //If the provider is read only, skip the variation. if(g_fReadOnlyProvider || m_pTable->GetSQLSupport() == DBPROPVAL_SQL_NONE) { odtLog << L"Provider is ReadOnly." << ENDL; return TEST_SKIPPED; } // Initialize the variation INIT; hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_REVCOLLISTFROMVIEW, NULL, PREPARE); // Check to see if the create view failed if (FAILED(hr)) { odtLog<GetSQLSupport() & DBPROPVAL_SQL_ODBC_CORE) ) { odtLog << L"Provider does not support outer joins." << ENDL; return TEST_SKIPPED; } // Initialize the variation INIT; hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_LEFTOUTERJOIN, NULL, PREPARE); // Check to see if the left outer joins work if (FAILED(hr)) { odtLog<GetSQLSupport() & DBPROPVAL_SQL_ODBC_CORE) ) { odtLog << L"Provider does not support outer joins." << ENDL; return TEST_SKIPPED; } // Initialize the variation INIT; if(m_eTestCase==TC_SingSel) { IRow* pIRow = NULL; CHECK(hr=SetCommandText(m_pIMalloc,m_pICommand,m_pTable,m_pTable2->GetTableName(), eSELECT,SELECT_RIGHTOUTERJOIN,NULL,NULL,NULL), S_OK); if(m_ePreparation == SUPPORTED) COMPARE(SUCCEEDED(PrepareCommand(m_pICommand,PREPARE,0)), TRUE); hr = m_pICommand->Execute(NULL, IID_IRow, NULL, NULL, (IUnknown**)&pIRow); COMPARE((hr==DB_E_NOTFOUND) || (hr==DB_E_ERRORSINCOMMAND), TRUE); SAFE_RELEASE(pIRow); FREE; return TEST_PASS; } hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_RIGHTOUTERJOIN, NULL, PREPARE); // Check to see if the right outer joins work if (FAILED(hr)) { odtLog<Execute(NULL, iid, NULL, &m_cRowsAffected, (IUnknown **) &m_pIRowset),S_OK)) goto CLEANUP; if (!m_pIRowset) goto CLEANUP; // Release the IColumnsInfo Pointer SAFE_RELEASE(m_pIColumnsInfo); if (FAILED(m_pIRowset->QueryInterface(IID_IColumnsInfo, (void **)&m_pIColumnsInfo))) goto CLEANUP; // Dirty the output params m_rgInfo = INVALID(DBCOLUMNINFO*); m_pStringsBuffer= INVALID(WCHAR*); // Run testing interface, validate params if (CHECK(hr=m_pIColumnsInfo->GetColumnInfo(NULL, &m_rgInfo, &m_pStringsBuffer), E_INVALIDARG)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr); CLEANUP: FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(2) //*----------------------------------------------------------------------- // @mfunc E_INVALIDARG: rgInfo is NULL // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_ExecuteRowset::Variation_2() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; IID iid = IID_IRowset; // Initialize the variation INIT; // SetText on command if (FAILED(SetCommandText(m_pIMalloc, m_pICommand, m_pTable, NULL, eSELECT, SELECT_COLLISTFROMTBL, NULL))) goto CLEANUP; if (!CHECK(hr=m_pICommand->Execute(NULL, iid, NULL, &m_cRowsAffected, (IUnknown **) &m_pIRowset),S_OK)) goto CLEANUP; if (!m_pIRowset) goto CLEANUP; // Release the ColumnsInfo Pointer SAFE_RELEASE(m_pIColumnsInfo); if (FAILED(m_pIRowset->QueryInterface(IID_IColumnsInfo, (void **)&m_pIColumnsInfo))) goto CLEANUP; // Dirty the output params m_cColumns = 99; m_pStringsBuffer= INVALID(WCHAR*); // Run testing interface, validate params if (CHECK(hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, NULL, &m_pStringsBuffer),E_INVALIDARG)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr); CLEANUP: FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(3) //*----------------------------------------------------------------------- // @mfunc E_INVALIDARG: pStringsBuffer is NULL // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_ExecuteRowset::Variation_3() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; IID iid = IID_IRowset; // Initialize the variation INIT; // SetText on command if (FAILED(SetCommandText(m_pIMalloc, m_pICommand, m_pTable, NULL, eSELECT, SELECT_COLLISTFROMTBL, NULL))) goto CLEANUP; if (!CHECK(hr=m_pICommand->Execute(NULL, iid, NULL, &m_cRowsAffected, (IUnknown **) &m_pIRowset),S_OK)) goto CLEANUP; if (!m_pIRowset) goto CLEANUP; // Release the ColumnsInfo Pointer SAFE_RELEASE(m_pIColumnsInfo); if (FAILED(m_pIRowset->QueryInterface(IID_IColumnsInfo, (void **)&m_pIColumnsInfo))) goto CLEANUP; // Dirty the output params m_cColumns = 99; m_rgInfo = INVALID(DBCOLUMNINFO*); // run testing interface, validate params if (CHECK(hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, NULL),E_INVALIDARG)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr); CLEANUP: FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(4) //*----------------------------------------------------------------------- // @mfunc S_OK: CommandText is Set and Executed // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_ExecuteRowset::Variation_4() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; // Initialize the variation INIT; if (CHECK(hr=ExecuteMethod_row(FALSE, FALSE, FALSE, eSELECT, SELECT_ALLFROMTBL, NULL, NEITHER, 0),S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr); FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(5) //*----------------------------------------------------------------------- // @mfunc S_OK: CommandText is Set, Prepared, Unprepared, and Executed // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_ExecuteRowset::Variation_5() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; // Initialize the variation INIT; if (CHECK(hr=ExecuteMethod_row(FALSE, FALSE, FALSE, eSELECT, SELECT_ALLFROMTBL, NULL, BOTH, 0),S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr); FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(6) //*----------------------------------------------------------------------- // @mfunc S_OK: CommandText is Set, Prepared, and Executed // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_ExecuteRowset::Variation_6() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; // Initialize the variation INIT; if (CHECK(hr=ExecuteMethod_row(FALSE, FALSE, FALSE, eSELECT, SELECT_ALLFROMTBL, NULL, PREPARE, 1),S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr); FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(7) //*----------------------------------------------------------------------- // @mfunc S_OK: CommandText that includes duplicate columns // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_ExecuteRowset::Variation_7() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; // Initialize the variation INIT; if (CHECK(hr=ExecuteMethod_row(FALSE, FALSE, FALSE, eSELECT, SELECT_DUPLICATECOLUMNS, NULL, NEITHER, 1),S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr); FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(8) //*----------------------------------------------------------------------- // @mfunc S_OK: CommandText is Set, then change the Text // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_ExecuteRowset::Variation_8() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; // Initialize the variation INIT; if (!CHECK(hr=ExecuteMethod_row(FALSE, FALSE, FALSE, eSELECT, SELECT_DUPLICATECOLUMNS, NULL, NEITHER, 1),S_OK)) goto CLEANUP; SAFE_RELEASE(m_pIRowset); SAFE_RELEASE(m_pIColumnsInfo); FreeColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer); PROVIDER_FREE(m_prgOrdTbl1); m_cOrdTbl1 = 0; // SetText on Command if (CHECK(hr=ExecuteMethod_row(FALSE, FALSE, FALSE, eSELECT, SELECT_REVCOLLIST, NULL, PREPARE, 1),S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr); if (CHECK(hr,S_OK)) fResult = TEST_PASS; CLEANUP: FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(9) //*----------------------------------------------------------------------- // @mfunc S_OK: CommandText contains a count(*) // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_ExecuteRowset::Variation_9() { BOOL fResult = TEST_FAIL; // Initialize the variation INIT; TEST2C_(m_hr=ExecuteMethod_row(FALSE, FALSE, FALSE, eSELECT, SELECT_COUNT, NULL, NEITHER, 1),S_OK,DB_E_NOTSUPPORTED); //Skip variation if query is not supported. if(m_hr == DB_E_NOTSUPPORTED) { fResult = TEST_SKIPPED; goto CLEANUP; } // Validate the columns CheckEachColumn(m_hr,0,SELECT_COUNT); fResult = TEST_PASS; CLEANUP: FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(10) //*----------------------------------------------------------------------- // @mfunc S_OK: CommandText contains different column names // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_ExecuteRowset::Variation_10() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; // Initialize the variation INIT; if (CHECK(hr=ExecuteMethod_row(FALSE, FALSE, FALSE, eSELECT, SELECT_CHANGECOLNAME, NULL, NEITHER, 1),S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr,0,SELECT_CHANGECOLNAME); FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(11) //*----------------------------------------------------------------------- // @mfunc S_OK: CommandText contains a select from an Empty Rowset // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_ExecuteRowset::Variation_11() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; // Initialize the variation INIT; TEST2C_(hr=ExecuteMethod_row(FALSE, FALSE, FALSE, eSELECT, SELECT_EMPTYROWSET, NULL, NEITHER, 1),S_OK,DB_E_NOTSUPPORTED); //Skip variation if query is not supported. if (hr == DB_E_NOTSUPPORTED) { odtLog<GetSQLSupport() != DBPROPVAL_SQL_NONE) { // Delete all rows in the table. if(!CHECK(m_pTable->Delete(),S_OK)) goto CLEANUP; } else { // Drop the table and create an empty one if(!CHECK(m_pTable->DropTable(),S_OK)) goto CLEANUP; if(!SUCCEEDED(m_pTable->CreateTable(0,1,NULL,PRIMARY,TRUE))) goto CLEANUP; } if(CHECK(hr=ExecuteMethod_row(FALSE, FALSE, FALSE, eSELECT, SELECT_COLLISTFROMTBL, NULL, NEITHER),S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr); for(count=0;count<10;count++) m_pTable->Insert(); CLEANUP: FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(13) //*----------------------------------------------------------------------- // @mfunc S_OK: Ask for DBPROP_IRowsetLocate on a Select Statement // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_ExecuteRowset::Variation_13() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; if (!SupportedProperty(DBPROP_IRowsetLocate, DBPROPSET_ROWSET, m_pIDBInitialize)) { odtLog << L"IRowsetLocate is not supported.\n"; return TEST_SKIPPED; } // Initialize the variation INIT; if (CHECK(hr=ExecuteMethod_row(FALSE, FALSE, FALSE, eSELECT, SELECT_COLLISTFROMTBL, NULL, NEITHER, 1, DBPROP_IRowsetLocate),S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr, DBPROP_IRowsetLocate); FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(14) //*----------------------------------------------------------------------- // @mfunc S_OK: Ask for DBPROP_BOOKMARKS on a Select Statement // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_ExecuteRowset::Variation_14() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; if (!SupportedProperty(DBPROP_BOOKMARKS, DBPROPSET_ROWSET, m_pIDBInitialize)) { odtLog << L"Bookmarks are not supported.\n"; return TEST_SKIPPED; } // Initialize the variation INIT; if (CHECK(hr=ExecuteMethod_row(FALSE, FALSE, FALSE, eSELECT, SELECT_COLLISTFROMTBL, NULL, NEITHER, 1, DBPROP_BOOKMARKS),S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr, DBPROP_BOOKMARKS); FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(15) //*----------------------------------------------------------------------- // @mfunc S_OK: Ask for DBPROP_DEFERRED on a Select Statement // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_ExecuteRowset::Variation_15() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; if (!SupportedProperty(DBPROP_DEFERRED, DBPROPSET_ROWSET, m_pIDBInitialize)) { odtLog << L"Deferred is not supported.\n"; return TEST_SKIPPED; } // Initialize the variation INIT; if (CHECK(hr=ExecuteMethod_row(FALSE, FALSE, FALSE, eSELECT, SELECT_COLLISTFROMTBL, NULL, NEITHER, 1, DBPROP_DEFERRED),S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr, DBPROP_DEFERRED); FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(16) //*----------------------------------------------------------------------- // @mfunc S_OK: Ask for DBPROP_CACHEDEFERRED on a Select Statement // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_ExecuteRowset::Variation_16() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; if (!SupportedProperty(DBPROP_CACHEDEFERRED, DBPROPSET_ROWSET, m_pIDBInitialize)) { odtLog << L"Cache Deferred is not supported.\n"; return TEST_SKIPPED; } // Initialize the variation INIT; if (CHECK(hr=ExecuteMethod_row(FALSE, FALSE, FALSE, eSELECT, SELECT_COLLISTFROMTBL, NULL, NEITHER, 1, DBPROP_CACHEDEFERRED),S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr, DBPROP_CACHEDEFERRED); FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(17) //*----------------------------------------------------------------------- // @mfunc S_OK: Ask for DBPROP_MAYWRITECOLUMN on a Select Statement // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_ExecuteRowset::Variation_17() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; if (!SupportedProperty(DBPROP_MAYWRITECOLUMN, DBPROPSET_ROWSET, m_pIDBInitialize)) { odtLog << L"May Write Column is not supported.\n"; return TEST_SKIPPED; } // Initialize the variation INIT; if(CHECK(hr=ExecuteMethod_row(FALSE, FALSE, FALSE, eSELECT, SELECT_COLLISTFROMTBL, NULL, NEITHER, 1, DBPROP_MAYWRITECOLUMN),S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr, DBPROP_MAYWRITECOLUMN); FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(18) //*----------------------------------------------------------------------- // @mfunc S_OK: CommandText contains a select from view // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_ExecuteRowset::Variation_18() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; //If the provider is read only, skip the variation. if(g_fReadOnlyProvider || m_pTable->GetSQLSupport() == DBPROPVAL_SQL_NONE) { odtLog << L"Provider is ReadOnly." << ENDL; return TEST_SKIPPED; } // Initialize the variation INIT; hr=ExecuteMethod_row(FALSE, FALSE, FALSE, eSELECT, SELECT_REVCOLLISTFROMVIEW, NULL, NEITHER, 1); // Check to see if the create view failed if (FAILED(hr)) { odtLog<OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset))) goto CLEANUP; if (!m_pIRowset) goto CLEANUP; if (FAILED(m_pIRowset->QueryInterface(IID_IColumnsInfo, (void **)&m_pIColumnsInfo))) goto CLEANUP; // Dirty the output params m_rgInfo = INVALID(DBCOLUMNINFO*); m_pStringsBuffer= INVALID(WCHAR*); // Run testing interface, validate params if (CHECK(hr=m_pIColumnsInfo->GetColumnInfo(NULL, &m_rgInfo, &m_pStringsBuffer), E_INVALIDARG)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr); CLEANUP: FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(2) //*----------------------------------------------------------------------- // @mfunc E_INVALIDARG: rgInfo is NULL // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_OpenRowset::Variation_2() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; IID iid = IID_IRowset; // Initialize the variation INIT; if (FAILED(hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset))) goto CLEANUP; if (!m_pIRowset) goto CLEANUP; if (FAILED(m_pIRowset->QueryInterface(IID_IColumnsInfo, (void **)&m_pIColumnsInfo))) goto CLEANUP; // Dirty the output params m_cColumns = 99; m_pStringsBuffer= INVALID(WCHAR*); // Run testing interface, validate params if (CHECK(hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, NULL, &m_pStringsBuffer),E_INVALIDARG)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr); CLEANUP: FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(3) //*----------------------------------------------------------------------- // @mfunc E_INVALIDARG: pStringsBuffer is NULL // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_OpenRowset::Variation_3() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; IID iid = IID_IRowset; // Initialize the variation INIT; if (FAILED(hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset))) goto CLEANUP; if (!m_pIRowset) goto CLEANUP; if (FAILED(m_pIRowset->QueryInterface(IID_IColumnsInfo, (void **)&m_pIColumnsInfo))) goto CLEANUP; // Dirty the output params m_cColumns = 99; m_rgInfo = INVALID(DBCOLUMNINFO*); // run testing interface, validate params if (CHECK(hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, NULL),E_INVALIDARG)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr); CLEANUP: FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(4) //*----------------------------------------------------------------------- // @mfunc S_OK: Basic OpenRowset // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_OpenRowset::Variation_4() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; IID iid = IID_IRowset; // Initialize the variation INIT; if (FAILED(hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset))) goto CLEANUP; if (!m_pIRowset) goto CLEANUP; if (FAILED(m_pIRowset->QueryInterface(IID_IColumnsInfo, (void **)&m_pIColumnsInfo))) goto CLEANUP; // run testing interface, validate params if (CHECK(hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer),S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr); CLEANUP: FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(5) //*----------------------------------------------------------------------- // @mfunc S_OK: Base table contains no rows // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_OpenRowset::Variation_5() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; ULONG count = 0; IID iid = IID_IRowset; // Initialize the variation INIT; // Check to see if the DSO is ReadOnly if(!g_fReadOnlyProvider && m_pTable->GetSQLSupport() != DBPROPVAL_SQL_NONE) { // Delete all rows in the table. if(!CHECK(m_pTable->Delete(),S_OK)) goto CLEANUP; } else { // Drop the table and create an empty one if(!CHECK(m_pTable->DropTable(),S_OK)) goto CLEANUP; if(!SUCCEEDED(m_pTable->CreateTable(0,1,NULL,PRIMARY,TRUE))) goto CLEANUP; } if (FAILED(hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset))) goto CLEANUP; if (!m_pIRowset) goto CLEANUP; if (FAILED(m_pIRowset->QueryInterface(IID_IColumnsInfo, (void **)&m_pIColumnsInfo))) goto CLEANUP; // run testing interface, validate params if (CHECK(hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer),S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr); for(count=0;count<10;count++) m_pTable->Insert(); CLEANUP: FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(6) //*----------------------------------------------------------------------- // @mfunc S_OK: Ask for DBPROP_IRowsetLocate on a Select Statement // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_OpenRowset::Variation_6() { HRESULT hr = E_FAIL; HRESULT Exphr = S_OK; BOOL fResult = TEST_FAIL; IID iid = IID_IRowset; if (!SupportedProperty(DBPROP_IRowsetLocate, DBPROPSET_ROWSET, m_pIDBInitialize)) { odtLog << L"IRowsetLocate is not supported.\n"; return TEST_SKIPPED; } // Initialize the variation INIT; // Set Property SetRowsetProperties(DBPROPSET_ROWSET,DBPROP_IRowsetLocate); if (FAILED(hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset))) { if(CHECK(DB_E_ERRORSOCCURRED, hr) && (!m_pIRowset) && (m_rgPropSets->rgProperties->dwStatus == DBPROPSTATUS_NOTSETTABLE)) fResult = TEST_PASS; goto CLEANUP; } if (!m_pIRowset) goto CLEANUP; if (FAILED(m_pIRowset->QueryInterface(IID_IColumnsInfo, (void **)&m_pIColumnsInfo))) goto CLEANUP; // run testing interface, validate params if (CHECK(hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer),S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr, DBPROP_IRowsetLocate); CLEANUP: FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(7) //*----------------------------------------------------------------------- // @mfunc S_OK: Ask for DBPROP_BOOKMARKS on a Select Statement // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_OpenRowset::Variation_7() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; IID iid = IID_IRowset; if (!SupportedProperty(DBPROP_BOOKMARKS, DBPROPSET_ROWSET, m_pIDBInitialize)) { odtLog << L"Bookmarks are not supported.\n"; return TEST_SKIPPED; } // Initialize the variation INIT; // Set Property SetRowsetProperties(DBPROPSET_ROWSET,DBPROP_BOOKMARKS); if (FAILED(hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset))) { if(CHECK(DB_E_ERRORSOCCURRED, hr) && (!m_pIRowset) && (m_rgPropSets->rgProperties->dwStatus == DBPROPSTATUS_NOTSETTABLE)) fResult = TEST_PASS; goto CLEANUP; } if (!m_pIRowset) goto CLEANUP; if (FAILED(m_pIRowset->QueryInterface(IID_IColumnsInfo, (void **)&m_pIColumnsInfo))) goto CLEANUP; // run testing interface, validate params if (CHECK(hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer),S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr, DBPROP_BOOKMARKS); CLEANUP: FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(8) //*----------------------------------------------------------------------- // @mfunc S_OK: Ask for DBPROP_DEFERRED on a Select Statement // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_OpenRowset::Variation_8() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; IID iid = IID_IRowset; if (!SupportedProperty(DBPROP_DEFERRED, DBPROPSET_ROWSET, m_pIDBInitialize)) { odtLog << L"Deferred is not supported.\n"; return TEST_SKIPPED; } // Initialize the variation INIT; // Set Property SetRowsetProperties(DBPROPSET_ROWSET,DBPROP_DEFERRED); if (FAILED(hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset))) { if(CHECK(DB_E_ERRORSOCCURRED, hr) && (!m_pIRowset) && (m_rgPropSets->rgProperties->dwStatus == DBPROPSTATUS_NOTSETTABLE)) fResult = TEST_PASS; goto CLEANUP; } if (!m_pIRowset) goto CLEANUP; if (FAILED(m_pIRowset->QueryInterface(IID_IColumnsInfo, (void **)&m_pIColumnsInfo))) goto CLEANUP; // run testing interface, validate params if (CHECK(hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer),S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr, DBPROP_DEFERRED); CLEANUP: FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(9) //*----------------------------------------------------------------------- // @mfunc S_OK: Ask for DBPROP_CACHEDEFERRED on a Select Statement // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_OpenRowset::Variation_9() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; IID iid = IID_IRowset; if (!SupportedProperty(DBPROP_CACHEDEFERRED, DBPROPSET_ROWSET, m_pIDBInitialize)) { odtLog << L"Cache Deferred is not supported.\n"; return TEST_SKIPPED; } // Initialize the variation INIT; // Set Property SetRowsetProperties(DBPROPSET_ROWSET,DBPROP_CACHEDEFERRED); if (FAILED(hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset))) { if(CHECK(DB_E_ERRORSOCCURRED, hr) && (!m_pIRowset) && (m_rgPropSets->rgProperties->dwStatus == DBPROPSTATUS_NOTSETTABLE)) fResult = TEST_PASS; goto CLEANUP; } if (!m_pIRowset) goto CLEANUP; if (FAILED(m_pIRowset->QueryInterface(IID_IColumnsInfo, (void **)&m_pIColumnsInfo))) goto CLEANUP; // run testing interface, validate params if (CHECK(hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer),S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr, DBPROP_DEFERRED); CLEANUP: FREE; return fResult; } // }} // {{ TCW_VAR_PROTOTYPE(10) //*----------------------------------------------------------------------- // @mfunc S_OK: Ask for DBPROP_MAYWRITECOLUMN on a Select Statement // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfo_OpenRowset::Variation_10() { HRESULT hr = E_FAIL; BOOL fResult = TEST_FAIL; IID iid = IID_IRowset; if (!SupportedProperty(DBPROP_MAYWRITECOLUMN, DBPROPSET_ROWSET, m_pIDBInitialize)) { odtLog << L"May Write Column is not supported.\n"; return TEST_SKIPPED; } // Initialize the variation INIT; // Set Property SetRowsetProperties(DBPROPSET_ROWSET,DBPROP_MAYWRITECOLUMN); if (FAILED(hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset))) { if(CHECK(DB_E_ERRORSOCCURRED, hr) && (!m_pIRowset) && (m_rgPropSets->rgProperties->dwStatus == DBPROPSTATUS_NOTSETTABLE)) fResult = TEST_PASS; goto CLEANUP; } if (!m_pIRowset) goto CLEANUP; if (FAILED(m_pIRowset->QueryInterface(IID_IColumnsInfo, (void **)&m_pIColumnsInfo))) goto CLEANUP; // run testing interface, validate params if (CHECK(hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer),S_OK)) fResult = TEST_PASS; // Validate the columns CheckEachColumn(hr, DBPROP_MAYWRITECOLUMN); CLEANUP: FREE; return fResult; } // }} // {{ TCW_TERMINATE_METHOD //-------------------------------------------------------------------- // @mfunc TestCase Termination Routine // // @rdesc TRUE or FALSE // BOOL GetColInfo_OpenRowset::Terminate() { // {{ TCW_TERM_BASECLASS_CHECK2 return(IColInfo::Terminate()); } // }} // }} // }} // {{ TCW_TC_PROTOTYPE(GetColInfoRow_Rowset) //*----------------------------------------------------------------------- //| Test Case: GetColInfoRow_Rowset - GetColumnInfo on a Row object //| Created: 10/12/98 //*----------------------------------------------------------------------- //*----------------------------------------------------------------------- // @mfunc TestCase Initialization Routine // // @rdesc TRUE or FALSE // BOOL GetColInfoRow_Rowset::Init() { EINTERFACE eIntf = ROWSET_INTERFACE; if(m_eTestCase == TC_Cmd) eIntf = COMMAND_INTERFACE; // {{ TCW_INIT_BASECLASS_CHECK if(IColInfo::Init(eIntf)) // }} { m_Method = GETCOLINFO; switch(m_eTestCase) { case TC_Rowset: return GetRowFromRowset(FALSE); case TC_Cmd: return GetRowFromCommand(FALSE); case TC_OpenRW: return GetRowFromOpenRW(FALSE); case TC_Bind: return GetRowFromBind(FALSE); case TC_IColInfo2: return GetRowFromRowset(TRUE); default: ASSERT(!L"Unhandled Type..."); } } return FALSE; } // {{ TCW_VAR_PROTOTYPE(1) //*----------------------------------------------------------------------- // @mfunc S_OK: Basic // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfoRow_Rowset::Variation_1() { TBEGIN TESTC_(m_hr=CallMethodOnRowObj(FALSE), S_OK) m_cColumns = m_cOrdTbl1 + !(m_rgInfo2[0].iOrdinal) ; m_rgInfo = m_rgInfo2; CheckEachColumn(m_hr); TESTC(m_cColumns2 >= m_cColumns) TESTC(CheckRowSpecificColumns(m_cColumns2-m_cColumns, &(m_rgInfo2[m_cColumns]), m_rgInfo2[m_cColumns-1].iOrdinal+1)) CLEANUP: CLEAR Free(FALSE); TRETURN } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_VAR_PROTOTYPE(2) //*----------------------------------------------------------------------- // @mfunc E_INVALIDARG: pcColumns is NULL // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfoRow_Rowset::Variation_2() { TBEGIN if(m_pIColumnsInfo) TESTC_(m_pIColumnsInfo->GetColumnInfo(NULL,&m_rgInfo2,&m_pStringsBuffer), E_INVALIDARG) else TESTC_(m_pIColumnsInfo2->GetColumnInfo(NULL,&m_rgInfo2,&m_pStringsBuffer), E_INVALIDARG) CLEANUP: TRETURN } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_VAR_PROTOTYPE(3) //*----------------------------------------------------------------------- // @mfunc E_INVALIDARG: prgInfo is NULL // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfoRow_Rowset::Variation_3() { TBEGIN if(m_pIColumnsInfo) TESTC_(m_pIColumnsInfo->GetColumnInfo(&m_cColumns2,NULL,&m_pStringsBuffer), E_INVALIDARG) else TESTC_(m_pIColumnsInfo2->GetColumnInfo(&m_cColumns2,NULL,&m_pStringsBuffer), E_INVALIDARG) CLEANUP: TRETURN } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_VAR_PROTOTYPE(4) //*----------------------------------------------------------------------- // @mfunc E_INVALIDARG: ppStringsBuffer is NULL // // @rdesc TEST_PASS or TEST_FAIL // int GetColInfoRow_Rowset::Variation_4() { TBEGIN if(m_pIColumnsInfo) TESTC_(m_pIColumnsInfo->GetColumnInfo(&m_cColumns2,&m_rgInfo2,NULL), E_INVALIDARG) else TESTC_(m_pIColumnsInfo2->GetColumnInfo(&m_cColumns2,&m_rgInfo2,NULL), E_INVALIDARG) CLEANUP: TRETURN } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_TERMINATE_METHOD //*----------------------------------------------------------------------- // @mfunc TestCase Termination Routine // // @rdesc TEST_PASS or TEST_FAIL // BOOL GetColInfoRow_Rowset::Terminate() { SAFE_RELEASE(m_pIUnknown); FREE; // {{ TCW_TERM_BASECLASS_CHECK2 return(IColInfo::Terminate()); } // }} // }} TCW_TERMINATE_METHOD_END // }} TCW_TC_PROTOTYPE_END // {{ TCW_TC_PROTOTYPE(GetResColInfoRow_Rowset) //*----------------------------------------------------------------------- //| Test Case: GetResColInfoRow_Rowset - GetRestrictedColumnInfo on a Row object //| Created: 10/12/98 //*----------------------------------------------------------------------- //*----------------------------------------------------------------------- // @mfunc TestCase Initialization Routine // // @rdesc TRUE or FALSE // BOOL GetResColInfoRow_Rowset::Init() { EINTERFACE eIntf = ROWSET_INTERFACE; if(m_eTestCase == TC_Cmd) eIntf = COMMAND_INTERFACE; // {{ TCW_INIT_BASECLASS_CHECK if(IColInfo::Init(eIntf)) // }} { m_Method = GETRESCOLINFO; switch(m_eTestCase) { case TC_Rowset: return GetRowFromRowset(TRUE); case TC_Cmd: return GetRowFromCommand(TRUE); case TC_OpenRW: return GetRowFromOpenRW(TRUE); case TC_Bind: return GetRowFromBind(TRUE); default: ASSERT(!L"Unhandled Type..."); } } return FALSE; } // {{ TCW_VAR_PROTOTYPE(1) //*----------------------------------------------------------------------- // @mfunc S_OK: No Masks // // @rdesc TEST_PASS or TEST_FAIL // int GetResColInfoRow_Rowset::Variation_1() { TBEGIN //NO MASKS. m_cMasks = 0; m_rgMasks = NULL; TESTC_(m_hr=CallMethodOnRowObj(TRUE), S_OK) m_cColumns = m_cOrdTbl1 + !(m_rgInfo2[0].iOrdinal) ; m_rgInfo = m_rgInfo2; CheckEachColumn(m_hr); TESTC(m_cColumns2 >= m_cColumns) TESTC(CheckRowSpecificColumns(m_cColumns2-m_cColumns, &(m_rgInfo2[m_cColumns]), m_rgInfo2[m_cColumns-1].iOrdinal+1)) CLEANUP: CLEAR Free(FALSE); TRETURN } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_VAR_PROTOTYPE(2) //*----------------------------------------------------------------------- // @mfunc S_OK: 1 name mask // // @rdesc TEST_PASS or TEST_FAIL // int GetResColInfoRow_Rowset::Variation_2() { TBEGIN //ONE NAME MASK m_cMasks = 1; SAFE_ALLOC(m_rgMasks, DBID, 1); m_rgMasks[0].eKind = DBKIND_NAME; m_rgMasks[0].uName.pwszName = L"C"; TEST2C_(m_hr=CallMethodOnRowObj(TRUE), S_OK, DB_E_NOCOLUMN) if(S_OK == m_hr) TESTC(VerifyRestrictions()); CLEANUP: Free(FALSE); TRETURN } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_VAR_PROTOTYPE(3) //*----------------------------------------------------------------------- // @mfunc S_OK: Multiple name masks // // @rdesc TEST_PASS or TEST_FAIL // int GetResColInfoRow_Rowset::Variation_3() { TBEGIN DBORDINAL iMask; DBORDINAL cMasks = 8; //6 NAME MASKS m_cMasks = cMasks; SAFE_ALLOC(m_rgMasks, DBID, cMasks); for(iMask=0; iMask0 && m_rgInfo2) if(m_cColumns2>1) cCol = 1; //ONE NAME MASK m_cMasks = 1; SAFE_ALLOC(m_rgMasks, DBID, 1); TESTC_(DuplicateDBID(m_rgInfo2[cCol].columnid, m_rgMasks), S_OK) FreeColumnInfo(&m_cColumns2,&m_rgInfo2,&m_pStringsBuffer); TESTC_(m_hr=CallMethodOnRowObj(TRUE), S_OK) TESTC(VerifyRestrictions()); CLEANUP: ReleaseDBID(m_rgMasks, FALSE); Free(FALSE); TRETURN } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_VAR_PROTOTYPE(5) //*----------------------------------------------------------------------- // @mfunc S_OK: GUID_PROPID mask // // @rdesc TEST_PASS or TEST_FAIL // int GetResColInfoRow_Rowset::Variation_5() { TBEGIN ULONG_PTR ulDocSrc=0; BOOL bDocSrc=FALSE; //Get the value of DBPROP_DATASOURCE_TYPE property. if(GetProperty(DBPROP_DATASOURCE_TYPE, DBPROPSET_DATASOURCEINFO, m_pIDBInitialize, &ulDocSrc)) { if((ulDocSrc & DBPROPVAL_DST_DOCSOURCE) == DBPROPVAL_DST_DOCSOURCE) bDocSrc = TRUE; } //6 GUID MASKS m_cMasks = 6; SAFE_ALLOC(m_rgMasks, DBID, 6); m_rgMasks[0] = DBROWCOL_PARSENAME; m_rgMasks[1] = DBROWCOL_PARENTNAME; m_rgMasks[2] = DBROWCOL_ABSOLUTEPARSENAME; m_rgMasks[3] = DBROWCOL_ISHIDDEN; m_rgMasks[4] = DBROWCOL_ISREADONLY; m_rgMasks[5] = DBROWCOL_CONTENTTYPE; TEST2C_(m_hr=CallMethodOnRowObj(TRUE), S_OK, DB_E_NOCOLUMN) if(S_OK == m_hr) { TESTC(VerifyRestrictions()); //Since the resource rowset columns were returned, //verify the value of DBPROP_DATASOURCE_TYPE property. TESTC(bDocSrc); odtLog<0 && m_rgInfo2) if(m_cColumns2>1) cCol = 1; //ONE NAME MASK m_cMasks = 1; SAFE_ALLOC(m_rgMasks, DBID, 1); TESTC_(DuplicateDBID(m_rgInfo2[cCol].columnid, m_rgMasks), S_OK) FreeColumnInfo(&m_cColumns2,&m_rgInfo2,&m_pStringsBuffer); TESTC_(m_hr = m_pIColumnsInfo2->GetRestrictedColumnInfo(m_cMasks, m_rgMasks, 0, &m_cColumns2,NULL,&m_rgInfo2,&m_pStringsBuffer), S_OK) TESTC(CheckParams(m_hr, GETRESCOLINFO)) TESTC(VerifyRestrictions()); CLEANUP: ReleaseDBID(m_rgMasks, FALSE); Free(FALSE); TRETURN } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_VAR_PROTOTYPE(12) //*----------------------------------------------------------------------- // @mfunc S_OK: prgColumnInfo=NULL but prgColumnIDs != NULL // // @rdesc TEST_PASS or TEST_FAIL // int GetResColInfoRow_Rowset::Variation_12() { TBEGIN DBORDINAL cCol = 0; TESTC_(m_hr=CallMethodOnRowObj(TRUE, GETCOLINFO), S_OK) TESTC(m_cColumns2>0 && m_rgInfo2) if(m_cColumns2>1) cCol = 1; //ONE NAME MASK m_cMasks = 1; SAFE_ALLOC(m_rgMasks, DBID, 1); TESTC_(DuplicateDBID(m_rgInfo2[cCol].columnid, m_rgMasks), S_OK) FreeColumnInfo(&m_cColumns2,&m_rgInfo2,&m_pStringsBuffer); TESTC_(m_hr = m_pIColumnsInfo2->GetRestrictedColumnInfo(m_cMasks, m_rgMasks, 0, &m_cColumns2,&m_rgColumnIDs2,NULL,&m_pStringsBuffer), S_OK) TESTC(CheckParams(m_hr, GETRESCOLINFO)) TESTC(VerifyRestrictions()); CLEANUP: ReleaseDBID(m_rgMasks, FALSE); Free(FALSE); TRETURN } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_VAR_PROTOTYPE(13) //*----------------------------------------------------------------------- // @mfunc DB_E_BADCOLUMNID: invalid DBID for rgColumnIDMasks // // @rdesc TEST_PASS or TEST_FAIL // int GetResColInfoRow_Rowset::Variation_13() { TBEGIN //ONE NAME MASK m_cMasks = 1; SAFE_ALLOC(m_rgMasks, DBID, 1); m_rgMasks[0].eKind = DBKIND_GUID + 100; //Some large number. m_rgMasks[0].uName.pwszName = L"n"; TESTC_(m_hr=CallMethodOnRowObj(TRUE), DB_E_BADCOLUMNID) CLEANUP: Free(FALSE); TRETURN } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_VAR_PROTOTYPE(14) //*----------------------------------------------------------------------- // @mfunc DB_E_NOCOLUMN: Non-existent name for mask // // @rdesc TEST_PASS or TEST_FAIL // int GetResColInfoRow_Rowset::Variation_14() { TBEGIN DBORDINAL iMask; //6 NAME MASKS m_cMasks = 6; SAFE_ALLOC(m_rgMasks, DBID, 6); for(iMask=0; iMask<6; iMask++) m_rgMasks[iMask].eKind = DBKIND_NAME; m_rgMasks[0].uName.pwszName = L"NonExistentColumn1"; m_rgMasks[1].uName.pwszName = L"NonExistentColumn2"; m_rgMasks[2].uName.pwszName = L"NonExistentColumn3"; m_rgMasks[3].uName.pwszName = L"NonExistentColumn4"; m_rgMasks[4].uName.pwszName = L"NonExistentColumn5"; m_rgMasks[5].uName.pwszName = L"NonExistentColumn6"; TESTC_(m_hr=CallMethodOnRowObj(TRUE), DB_E_NOCOLUMN) CLEANUP: Free(FALSE); TRETURN } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_VAR_PROTOTYPE(15) //*----------------------------------------------------------------------- // @mfunc E_INVALIDARG: cColumnIDMasks=1 and rgColumnIDMasks=NULL // // @rdesc TEST_PASS or TEST_FAIL // int GetResColInfoRow_Rowset::Variation_15() { TBEGIN TESTC_(m_pIColumnsInfo2->GetRestrictedColumnInfo(1, NULL, 0, &m_cColumns2,&m_rgColumnIDs2,&m_rgInfo2,&m_pStringsBuffer), E_INVALIDARG) CLEANUP: Free(FALSE); TRETURN } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_VAR_PROTOTYPE(16) //*----------------------------------------------------------------------- // @mfunc E_INVALIDARG: pcColumns=NULL // // @rdesc TEST_PASS or TEST_FAIL // int GetResColInfoRow_Rowset::Variation_16() { TBEGIN //ONE NAME MASK m_cMasks = 1; SAFE_ALLOC(m_rgMasks, DBID, 1); m_rgMasks[0].eKind = DBKIND_NAME; m_rgMasks[0].uName.pwszName = L"n"; TESTC_(m_pIColumnsInfo2->GetRestrictedColumnInfo(m_cMasks, m_rgMasks, 0, NULL,&m_rgColumnIDs2,&m_rgInfo2,&m_pStringsBuffer), E_INVALIDARG) CLEANUP: Free(FALSE); TRETURN } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_VAR_PROTOTYPE(17) //*----------------------------------------------------------------------- // @mfunc E_INVALIDARG: ppStringsBuffer=NULL // // @rdesc TEST_PASS or TEST_FAIL // int GetResColInfoRow_Rowset::Variation_17() { TBEGIN //ONE NAME MASK m_cMasks = 1; SAFE_ALLOC(m_rgMasks, DBID, 1); m_rgMasks[0].eKind = DBKIND_NAME; m_rgMasks[0].uName.pwszName = L"n"; TESTC_(m_pIColumnsInfo2->GetRestrictedColumnInfo(m_cMasks, m_rgMasks, 0, &m_cColumns2,&m_rgColumnIDs2,&m_rgInfo2,NULL), E_INVALIDARG) CLEANUP: Free(FALSE); TRETURN } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_VAR_PROTOTYPE(18) //*----------------------------------------------------------------------- // @mfunc E_INVALIDARG: prgColumnIDs=NULL and prgColumnInfo=NULL // // @rdesc TEST_PASS or TEST_FAIL // int GetResColInfoRow_Rowset::Variation_18() { TBEGIN //ONE NAME MASK m_cMasks = 1; SAFE_ALLOC(m_rgMasks, DBID, 1); m_rgMasks[0].eKind = DBKIND_NAME; m_rgMasks[0].uName.pwszName = L"n"; TESTC_(m_pIColumnsInfo2->GetRestrictedColumnInfo(m_cMasks, m_rgMasks, 0, &m_cColumns2,NULL,NULL,&m_pStringsBuffer), E_INVALIDARG) TESTC_(m_pIColumnsInfo2->GetRestrictedColumnInfo(0, m_rgMasks, 0, &m_cColumns2,NULL,NULL,NULL), E_INVALIDARG) CLEANUP: Free(FALSE); TRETURN } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_VAR_PROTOTYPE(19) //*----------------------------------------------------------------------- // @mfunc E_INVALIDARG: ppStringsBuffer=NULL & either prgColumnIDs or prgColumnInfo = NULL // // @rdesc TEST_PASS or TEST_FAIL // int GetResColInfoRow_Rowset::Variation_19() { TBEGIN //ONE NAME MASK m_cMasks = 1; SAFE_ALLOC(m_rgMasks, DBID, 1); m_rgMasks[0].eKind = DBKIND_NAME; m_rgMasks[0].uName.pwszName = L"n"; CHECK(m_pIColumnsInfo2->GetRestrictedColumnInfo(m_cMasks, m_rgMasks, 0, &m_cColumns2,NULL, &m_rgInfo2, NULL), E_INVALIDARG); CHECK(m_pIColumnsInfo2->GetRestrictedColumnInfo(m_cMasks, m_rgMasks, 0, &m_cColumns2,&m_rgColumnIDs2,NULL,NULL), E_INVALIDARG); CHECK(m_pIColumnsInfo2->GetRestrictedColumnInfo(0, m_rgMasks, 0, &m_cColumns2,NULL,&m_rgInfo2,NULL), E_INVALIDARG); CHECK(m_pIColumnsInfo2->GetRestrictedColumnInfo(0, m_rgMasks, 0, &m_cColumns2,&m_rgColumnIDs2,NULL,NULL), E_INVALIDARG); CLEANUP: Free(FALSE); TRETURN } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_TERMINATE_METHOD //*----------------------------------------------------------------------- // @mfunc TestCase Termination Routine // // @rdesc TEST_PASS or TEST_FAIL // BOOL GetResColInfoRow_Rowset::Terminate() { SAFE_RELEASE(m_pIUnknown); FREE; // {{ TCW_TERM_BASECLASS_CHECK2 return(IColInfo::Terminate()); } // }} // }} TCW_TERMINATE_METHOD_END // }} TCW_TC_PROTOTYPE_END // {{ TCW_TC_PROTOTYPE(MapColID_Command) //*----------------------------------------------------------------------- //| Test Case: MapColID_Command - MapColumnIDs on a command object //| Created: 09/20/96 //| Updated: 04/25/98 //*----------------------------------------------------------------------- //-------------------------------------------------------------------- // @mfunc TestCase Initialization Routine // // @rdesc TRUE or FALSE // BOOL MapColID_Command::Init() { // Initialize for IColumnsInfo::MapColumnIDs m_Method = MAPCOLID; ULONG_PTR ulOleObj = 0; if(!GetProperty(DBPROP_OLEOBJECTS, DBPROPSET_DATASOURCEINFO, GetModInfo()->GetThisTestModule()->m_pIUnknown, &ulOleObj) || !(ulOleObj & DBPROPVAL_OO_SINGLETON)) { if(m_eTestCase == TC_SingSel) { odtLog<MapColumnIDs(m_cColumnIDs,m_rgColumnIDs, m_rgColumns), DB_E_NOCOMMAND); // Validate the columns QTESTC(CheckOrdinal(m_hr)); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(4) //*----------------------------------------------------------------------- // @mfunc DB_E_NOCOMMAND: CommandText is Set to Empty // // @rdesc TEST_PASS or TEST_FAIL // int MapColID_Command::Variation_4() { TBEGIN; DBORDINAL ulIndex = 0; WCHAR * pSQLSet = NULL; if(m_eTestCase==TC_SingSel) goto CLEANUP; // Initialize the variation INIT; // Fillout the Columns TESTC_(m_hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_COLLISTFROMTBL, NULL, PREPARE),S_OK); // SetText on command TESTC_(SetCommandText(m_pIMalloc, m_pICommand, m_pTable, NULL, eSQL, SELECT_COLLISTFROMTBL, pSQLSet),S_OK); // Reset the rgColumns array for(ulIndex=0; ulIndex < m_cColumnIDs; ulIndex++) m_rgColumns[ulIndex] = INVALID(DBORDINAL); TESTC_(m_hr=m_pIColumnsInfo->MapColumnIDs(m_cColumnIDs,m_rgColumnIDs, m_rgColumns), DB_E_NOCOMMAND); // Validate the columns QTESTC(CheckOrdinal(m_hr)); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(5) //*----------------------------------------------------------------------- // @mfunc DB_E_NOCOMMAND: CommandText is Set to NULL // // @rdesc TEST_PASS or TEST_FAIL // int MapColID_Command::Variation_5() { TBEGIN; DBORDINAL ulIndex = 0; if(m_eTestCase==TC_SingSel) goto CLEANUP; // Initialize the variation INIT; // Fillout the Columns TESTC_(m_hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_COLLISTFROMTBL, NULL, PREPARE),S_OK); // SetText on command TESTC_(SetCommandText(m_pIMalloc, m_pICommand, m_pTable, NULL, eSQL, SELECT_COLLISTFROMTBL, NULL),S_OK); // Reset the rgColumns array for(ulIndex=0; ulIndex < m_cColumnIDs; ulIndex++) m_rgColumns[ulIndex] = INVALID(DBORDINAL); TESTC_(m_hr=m_pIColumnsInfo->MapColumnIDs(m_cColumnIDs,m_rgColumnIDs, m_rgColumns), DB_E_NOCOMMAND); // Validate the columns QTESTC(CheckOrdinal(m_hr)); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(6) //*----------------------------------------------------------------------- // @mfunc DB_E_NOTPREPARED/S_OK: CommandText is Set, but not Prepared // // @rdesc TEST_PASS or TEST_FAIL // int MapColID_Command::Variation_6() { TBEGIN; HRESULT Exphr = S_OK; if(m_eTestCase==TC_SingSel) goto CLEANUP; // Initialize the variation INIT; // Check to see if the Provider supports ICommandPrepare if( m_ePreparation == SUPPORTED ) Exphr = DB_E_NOTPREPARED; TESTC_(m_hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_REVCOLLIST, NULL, NEITHER, 1), Exphr); // Validate the columns QTESTC(CheckOrdinal(m_hr)); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(7) //*----------------------------------------------------------------------- // @mfunc DB_E_NOTPREPARED/S_OK: CommandText is Set, Prepared, and Unprepared // // @rdesc TEST_PASS or TEST_FAIL // int MapColID_Command::Variation_7() { TBEGIN; HRESULT Exphr = S_OK; if(m_eTestCase==TC_SingSel) goto CLEANUP; // Initialize the variation INIT; // Check to see if the Provider supports ICommandPrepare if( m_ePreparation == SUPPORTED ) Exphr = DB_E_NOTPREPARED; TESTC_(m_hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_COLLISTFROMTBL, NULL, BOTH, 1), Exphr); // Validate the columns QTESTC(CheckOrdinal(m_hr)); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(8) //*----------------------------------------------------------------------- // @mfunc DB_E_ERRORSOCCURRED: All ColumnIDs are invalid // // @rdesc TEST_PASS or TEST_FAIL // int MapColID_Command::Variation_8() { TBEGIN; DBORDINAL ulIndex = 0; // Initialize the variation INIT; // Initialize to Params m_cColumnIDs = 5; m_rgColumnIDs = (DBID *) PROVIDER_ALLOC(sizeof(DBID) * m_cColumnIDs); m_rgColumns = (DBORDINAL *) PROVIDER_ALLOC(sizeof(DBORDINAL) * m_cColumnIDs); TESTC(m_rgColumnIDs != NULL); TESTC(m_rgColumns != NULL); for(ulIndex=0; ulIndex < m_cColumnIDs; ulIndex++) m_rgColumns[ulIndex] = INVALID(DBORDINAL); // Copy values into members for(ulIndex=0; ulIndexGetSQLSupport() == DBPROPVAL_SQL_NONE ) { odtLog << L"Provider is ReadOnly." << ENDL; return TEST_SKIPPED; } // Initialize the variation INIT; m_hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_REVCOLLISTFROMVIEW, NULL, PREPARE); // Check to see if the create view failed if( FAILED(m_hr) ) odtLog<GetSQLSupport() == DBPROPVAL_SQL_NONE ) { odtLog << L"Provider is ReadOnly." << ENDL; return TEST_SKIPPED; } // Initialize the variation INIT; m_hr=ExecuteMethod_row(TRUE, TRUE, TRUE, eSELECT, SELECT_REVCOLLISTFROMVIEW, NULL, PREPARE); // Check to see if the create view failed if( FAILED(m_hr) ) odtLog<Execute(NULL,IID_IRowset,NULL, NULL,(IUnknown **)&m_pIRowset),S_OK); // Check to see if IColumnsRowset is supported TESTC_PROVIDER(VerifyInterface(m_pIRowset, IID_IColumnsRowset, ROWSET_INTERFACE, (IUnknown **)&pIColumnsRowset)); TESTC_(pIColumnsRowset->GetAvailableColumns(&cOptColumns, &rgOptColumns),S_OK); // Check for an optional column TESTC_PROVIDER(cOptColumns && rgOptColumns); // Pass first optional column TESTC_(pIColumnsRowset->GetColumnsRowset(NULL, 1, rgOptColumns, IID_IRowset, 0, NULL, (IUnknown**)&pIRowsetColumns),S_OK); // Get a IID_IColumnsInfo pointer TESTC(VerifyInterface(pIRowsetColumns, IID_IColumnsInfo, ROWSET_INTERFACE, (IUnknown **)&m_pIColumnsInfo)); TESTC_(m_hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer), S_OK); TESTC_(m_pIColumnsInfo->MapColumnIDs(1, rgOptColumns, &ulOptColOrd),S_OK); TESTC(m_rgInfo[m_cColumns-1].iOrdinal == ulOptColOrd); CLEANUP: PROVIDER_FREE(rgOptColumns); SAFE_RELEASE(pIColumnsRowset); SAFE_RELEASE(pIRowsetColumns); FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(12) //*----------------------------------------------------------------------- // @mfunc S_OK: ColumnIDs from a count(*) // // @rdesc TEST_PASS or TEST_FAIL // int MapColID_ExecuteRowset::Variation_12() { TBEGIN; // Initialize the variation INIT; TEST2C_(m_hr=ExecuteMethod_row(TRUE, TRUE, TRUE, eSELECT, SELECT_COUNT, NULL, NEITHER),S_OK,DB_E_NOTSUPPORTED); //Skip variation if query is not supported. TESTC_PROVIDER(m_hr != DB_E_NOTSUPPORTED) // Validate the columns QTESTC(CheckOrdinal(m_hr)); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(13) //*----------------------------------------------------------------------- // @mfunc DB_E_ERRORSOCCURRED: Change the DBKIND in the ColumnIDs // // @rdesc TEST_PASS or TEST_FAIL // int MapColID_ExecuteRowset::Variation_13() { TBEGIN; DBORDINAL ulIndex = 0; // Initialize the variation INIT; TESTC_(m_hr=ExecuteMethod_row(TRUE, TRUE, TRUE, eSELECT, SELECT_COLLISTFROMTBL, NULL, PREPARE),S_OK); // Release the Rowset created SAFE_RELEASE(m_pIRowset); // Copy values into members for(ulIndex=0; ulIndexOpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset),S_OK); TESTC(m_pIRowset != NULL); TESTC(VerifyInterface(m_pIRowset, IID_IColumnsInfo, ROWSET_INTERFACE, (IUnknown **)&m_pIColumnsInfo)); // Get the Column DBIDs TESTC_(m_hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer),S_OK); // Make array of DBIDs TESTC_(m_hr=MakeDBIDArrays(TRUE,FALSE,TRUE),S_OK); // run testing interface, validate params TESTC_(m_hr=m_pIColumnsInfo->MapColumnIDs(m_cColumnIDs, m_rgColumnIDs, m_rgColumns),E_INVALIDARG); // Validate the columns QTESTC(CheckOrdinal(m_hr)); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(2) //*----------------------------------------------------------------------- // @mfunc E_INVALIDARG: rgColumns is NULL // // @rdesc TEST_PASS or TEST_FAIL // int MapColID_OpenRowset::Variation_2() { TBEGIN; IID iid = IID_IRowset; // Initialize the variation INIT; TESTC_(m_hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset),S_OK); TESTC(m_pIRowset != NULL); TESTC(VerifyInterface(m_pIRowset, IID_IColumnsInfo, ROWSET_INTERFACE, (IUnknown **)&m_pIColumnsInfo)); // Get the Column DBIDs TESTC_(m_hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer),S_OK); // Make array of DBIDs TESTC_(m_hr=MakeDBIDArrays(TRUE,TRUE,FALSE),S_OK); // run testing interface, validate params TESTC_(m_hr=m_pIColumnsInfo->MapColumnIDs(m_cColumnIDs, m_rgColumnIDs, m_rgColumns),E_INVALIDARG); // Validate the columns QTESTC(CheckOrdinal(m_hr)); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(3) //*----------------------------------------------------------------------- // @mfunc DB_E_ERRORSOCCURRED: All ColumnIDs are invalid // // @rdesc TEST_PASS or TEST_FAIL // int MapColID_OpenRowset::Variation_3() { TBEGIN; IID iid = IID_IRowset; DBORDINAL ulIndex = 0; // Initialize the variation INIT; // Initialize to Params m_cColumnIDs = 5; m_rgColumnIDs = (DBID *) PROVIDER_ALLOC(sizeof(DBID) * m_cColumnIDs); m_rgColumns = (DBORDINAL *) PROVIDER_ALLOC(sizeof(DBORDINAL) * m_cColumnIDs); TESTC(m_rgColumnIDs != NULL); TESTC(m_rgColumns != NULL); for(ulIndex=0; ulIndex < m_cColumnIDs; ulIndex++) m_rgColumns[ulIndex] = INVALID(DBORDINAL); // Copy values into members for(ulIndex=0; ulIndexOpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset),S_OK); TESTC(m_pIRowset != NULL); TESTC(VerifyInterface(m_pIRowset, IID_IColumnsInfo, ROWSET_INTERFACE, (IUnknown **)&m_pIColumnsInfo)); // Get the Column DBIDs TESTC_(m_hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer),S_OK); // run testing interface, validate params TESTC_(m_hr=m_pIColumnsInfo->MapColumnIDs(m_cColumnIDs, m_rgColumnIDs, m_rgColumns),DB_E_ERRORSOCCURRED); // Validate the columns QTESTC(CheckOrdinal(m_hr)); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(4) //*----------------------------------------------------------------------- // @mfunc DB_S_ERRORSOCCURRED: One ColumnID is invalid // // @rdesc TEST_PASS or TEST_FAIL // int MapColID_OpenRowset::Variation_4() { TBEGIN; HRESULT Exphr = S_OK; IID iid = IID_IRowset; DBORDINAL ulIndex = 0; // Initialize the variation INIT; TESTC_(m_hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset),S_OK); TESTC(m_pIRowset != NULL); TESTC(VerifyInterface(m_pIRowset, IID_IColumnsInfo, ROWSET_INTERFACE, (IUnknown **)&m_pIColumnsInfo)); // Get the Column DBIDs TESTC_(m_hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer),S_OK); // Make array of DBIDs TESTC_(m_hr=MakeDBIDArrays(TRUE,TRUE,TRUE),S_OK); // Copy values into members for(ulIndex=0; ulIndexMapColumnIDs(m_cColumnIDs, m_rgColumnIDs, m_rgColumns),Exphr); // Validate the columns QTESTC(CheckOrdinal(m_hr)); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(5) //*----------------------------------------------------------------------- // @mfunc S_OK: Count of ColumnIDs is 0 // // @rdesc TEST_PASS or TEST_FAIL // int MapColID_OpenRowset::Variation_5() { TBEGIN; IID iid = IID_IRowset; // Initialize the variation INIT; TESTC_(m_hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset),S_OK); TESTC(m_pIRowset != NULL); TESTC(VerifyInterface(m_pIRowset, IID_IColumnsInfo, ROWSET_INTERFACE, (IUnknown **)&m_pIColumnsInfo)); // Get the Column DBIDs TESTC_(m_hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer),S_OK); // Make array of DBIDs TESTC_(m_hr=MakeDBIDArrays(FALSE,TRUE,TRUE),S_OK); // run testing interface, validate params TESTC_(m_hr=m_pIColumnsInfo->MapColumnIDs(m_cColumnIDs, m_rgColumnIDs, m_rgColumns),S_OK); // Validate the columns QTESTC(CheckOrdinal(m_hr)); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(6) //*----------------------------------------------------------------------- // @mfunc S_OK: Valid count and valid range of ColumnIDs // // @rdesc TEST_PASS or TEST_FAIL // int MapColID_OpenRowset::Variation_6() { TBEGIN; IID iid = IID_IRowset; // Initialize the variation INIT; TESTC_(m_hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset),S_OK); TESTC(m_pIRowset != NULL); TESTC(VerifyInterface(m_pIRowset, IID_IColumnsInfo, ROWSET_INTERFACE, (IUnknown **)&m_pIColumnsInfo)); // Get the Column DBIDs TESTC_(m_hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer),S_OK); // Make array of DBIDs TESTC_(m_hr=MakeDBIDArrays(TRUE,TRUE,TRUE),S_OK); // run testing interface, validate params TESTC_(m_hr=m_pIColumnsInfo->MapColumnIDs(m_cColumnIDs, m_rgColumnIDs, m_rgColumns),S_OK); // Validate the columns QTESTC(CheckOrdinal(m_hr)); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(7) //*----------------------------------------------------------------------- // @mfunc S_OK: Ask for DBPROP_BOOKMARKS // // @rdesc TEST_PASS or TEST_FAIL // int MapColID_OpenRowset::Variation_7() { TBEGIN; IID iid = IID_IRowset; if( !SupportedProperty(DBPROP_BOOKMARKS, DBPROPSET_ROWSET, m_pIDBInitialize) ) { odtLog << L"Bookmarks are not supported.\n"; return TEST_SKIPPED; } // Initialize the variation INIT; // Set Property SetRowsetProperties(DBPROPSET_ROWSET,DBPROP_BOOKMARKS); if( FAILED(m_hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset)) ) { TESTC_(DB_E_ERRORSOCCURRED, m_hr); TESTC(!m_pIRowset); TESTC(m_rgPropSets->rgProperties->dwStatus == DBPROPSTATUS_NOTSETTABLE); goto CLEANUP; } TESTC(m_pIRowset != NULL); TESTC(VerifyInterface(m_pIRowset, IID_IColumnsInfo, ROWSET_INTERFACE, (IUnknown **)&m_pIColumnsInfo)); // Get the Column DBIDs TESTC_(m_hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer),S_OK); // Make array of DBIDs TESTC_(m_hr=MakeDBIDArrays(FALSE,TRUE,TRUE),S_OK); // run testing interface, validate params TESTC_(m_hr=m_pIColumnsInfo->MapColumnIDs(m_cColumnIDs, m_rgColumnIDs, m_rgColumns),S_OK); // Validate the columns QTESTC(CheckOrdinal(m_hr)); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(8) //*----------------------------------------------------------------------- // @mfunc S_OK: MapColumnIDs on optional columns in IColumnsRowset // // @rdesc TEST_PASS or TEST_FAIL // int MapColID_OpenRowset::Variation_8() { TBEGIN; DBORDINAL ulOptColOrd = 99; DBORDINAL cOptColumns = 0; DBID* rgOptColumns = NULL; IColumnsRowset* pIColumnsRowset = NULL; IRowset* pIRowsetColumns = NULL; IID iid = IID_IRowset; // Initialize the variation INIT; TESTC_(m_hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset),S_OK); TESTC(m_pIRowset != NULL); // Check to see if IColumnsRowset is supported TESTC_PROVIDER(VerifyInterface(m_pIRowset, IID_IColumnsRowset, ROWSET_INTERFACE, (IUnknown **)&pIColumnsRowset)); TESTC_(pIColumnsRowset->GetAvailableColumns(&cOptColumns, &rgOptColumns),S_OK); // Check for an optional column TESTC_PROVIDER(cOptColumns && rgOptColumns); // Pass first optional column TESTC_(pIColumnsRowset->GetColumnsRowset(NULL, 1, rgOptColumns, IID_IRowset, 0, NULL, (IUnknown**)&pIRowsetColumns),S_OK); // Get a IID_IColumnsInfo pointer TESTC(VerifyInterface(pIRowsetColumns, IID_IColumnsInfo, ROWSET_INTERFACE, (IUnknown **)&m_pIColumnsInfo)); TESTC_(m_hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer), S_OK); TESTC_(m_pIColumnsInfo->MapColumnIDs(1, rgOptColumns, &ulOptColOrd),S_OK); TESTC(m_rgInfo[m_cColumns-1].iOrdinal == ulOptColOrd); CLEANUP: PROVIDER_FREE(rgOptColumns); SAFE_RELEASE(pIColumnsRowset); SAFE_RELEASE(pIRowsetColumns); FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(9) //*----------------------------------------------------------------------- // @mfunc DB_E_ERRORSOCCURRED: Change the DBKIND in the ColumnIDs // // @rdesc TEST_PASS or TEST_FAIL // int MapColID_OpenRowset::Variation_9() { TBEGIN; IID iid = IID_IRowset; DBORDINAL ulIndex = 0; // Initialize the variation INIT; TESTC_(m_hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset),S_OK); TESTC(m_pIRowset != NULL); TESTC(VerifyInterface(m_pIRowset, IID_IColumnsInfo, ROWSET_INTERFACE, (IUnknown **)&m_pIColumnsInfo)); // Get the Column DBIDs TESTC_(m_hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer),S_OK); // Make array of DBIDs TESTC_(m_hr=MakeDBIDArrays(TRUE,TRUE,TRUE),S_OK); // Copy values into members for(ulIndex=0; ulIndexMapColumnIDs(m_cColumnIDs, m_rgColumnIDs, m_rgColumns), DB_E_ERRORSOCCURRED); // Validate the columns QTESTC(CheckOrdinal(m_hr)); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(10) //*----------------------------------------------------------------------- // @mfunc DB_E_ERRORSOCCURRED: Ask for Column 0 with DBKIND_PROPID // // @rdesc TEST_PASS or TEST_FAIL // int MapColID_OpenRowset::Variation_10() { TBEGIN; IID iid = IID_IRowset; DBORDINAL ulIndex = 0; // Initialize the variation INIT; TESTC_(m_hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset),S_OK); TESTC(m_pIRowset != NULL); TESTC(VerifyInterface(m_pIRowset, IID_IColumnsInfo, ROWSET_INTERFACE, (IUnknown **)&m_pIColumnsInfo)); // Get the Column DBIDs TESTC_(m_hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer),S_OK); // Make array of DBIDs TESTC_(m_hr=MakeDBIDArrays(TRUE,TRUE,TRUE),S_OK); // Copy values into members for(ulIndex=0; ulIndexMapColumnIDs(m_cColumnIDs, m_rgColumnIDs, m_rgColumns), DB_E_ERRORSOCCURRED); // Validate the columns QTESTC(CheckOrdinal(m_hr)); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(11) //*----------------------------------------------------------------------- // @mfunc DB_E_ERRORSOCCURRED: Switch the DBKIND in the ColumnIDs // // @rdesc TEST_PASS or TEST_FAIL // int MapColID_OpenRowset::Variation_11() { TBEGIN; IID iid = IID_IRowset; DBORDINAL ulIndex = 0; // Initialize the variation INIT; TESTC_(m_hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset),S_OK); TESTC(m_pIRowset != NULL); TESTC(VerifyInterface(m_pIRowset, IID_IColumnsInfo, ROWSET_INTERFACE, (IUnknown **)&m_pIColumnsInfo)); // Get the Column DBIDs TESTC_(m_hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer),S_OK); // Make array of DBIDs TESTC_(m_hr=MakeDBIDArrays(TRUE,TRUE,TRUE),S_OK); // Copy values into members for(ulIndex=0; ulIndexMapColumnIDs(m_cColumnIDs, m_rgColumnIDs, m_rgColumns), DB_E_ERRORSOCCURRED); // Validate the columns QTESTC(CheckOrdinal(m_hr, FALSE)); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(12) //*----------------------------------------------------------------------- // @mfunc DB_E_ERRORSOCCURRED: Change the GUID in the DBID // // @rdesc TEST_PASS or TEST_FAIL // int MapColID_OpenRowset::Variation_12() { TBEGIN; IID iid = IID_IRowset; DBORDINAL ulIndex = 0; // Initialize the variation INIT; TESTC_(m_hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset),S_OK); TESTC(m_pIRowset != NULL); TESTC(VerifyInterface(m_pIRowset, IID_IColumnsInfo, ROWSET_INTERFACE, (IUnknown **)&m_pIColumnsInfo)); // Get the Column DBIDs TESTC_(m_hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer),S_OK); // Make array of DBIDs TESTC_(m_hr=MakeDBIDArrays(TRUE,TRUE,TRUE),S_OK); // Copy values into members for(ulIndex=0; ulIndexMapColumnIDs(m_cColumnIDs, m_rgColumnIDs, m_rgColumns), DB_E_ERRORSOCCURRED); // Validate the columns QTESTC(CheckOrdinal(m_hr)); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(13) //*----------------------------------------------------------------------- // @mfunc DB_E_ERRORSOCCURRED: Switch the DBKIND in the ColumnIDs with Bookmarks // // @rdesc TEST_PASS or TEST_FAIL // int MapColID_OpenRowset::Variation_13() { TBEGIN; IID iid = IID_IRowset; DBORDINAL ulIndex = 0; // Set Property if( !SettableProperty(DBPROP_BOOKMARKS, DBPROPSET_ROWSET, m_pIDBInitialize) ) { odtLog << L"Bookmarks are not settable.\n"; return TEST_SKIPPED; } // Initialize the variation INIT; // Set Property SetRowsetProperties(DBPROPSET_ROWSET,DBPROP_BOOKMARKS); TESTC_(m_hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset),S_OK); TESTC(m_pIRowset != NULL); TESTC(VerifyInterface(m_pIRowset, IID_IColumnsInfo, ROWSET_INTERFACE, (IUnknown **)&m_pIColumnsInfo)); // Get the Column DBIDs TESTC_(m_hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer),S_OK); // Make array of DBIDs TESTC_(m_hr=MakeDBIDArrays(TRUE,TRUE,TRUE),S_OK); // Copy values into members for(ulIndex=0; ulIndexMapColumnIDs(m_cColumnIDs, m_rgColumnIDs, m_rgColumns), DB_E_ERRORSOCCURRED); // Validate the columns QTESTC(CheckOrdinal(m_hr, FALSE)); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(14) //*----------------------------------------------------------------------- // @mfunc DB_S_ERRORSOCCURRED: ColumnID one greater than the last ordinal // // @rdesc TEST_PASS or TEST_FAIL // int MapColID_OpenRowset::Variation_14() { TBEGIN; HRESULT Exphr = S_OK; IID iid = IID_IRowset; DBORDINAL ulIndex = 0; // Initialize the variation INIT; TESTC_(m_hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset),S_OK); TESTC(m_pIRowset != NULL); TESTC(VerifyInterface(m_pIRowset, IID_IColumnsInfo, ROWSET_INTERFACE, (IUnknown **)&m_pIColumnsInfo)); // Get the Column DBIDs TESTC_(m_hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer),S_OK); // Make array of DBIDs TESTC_(m_hr=MakeDBIDArrays(TRUE,TRUE,TRUE),S_OK); // Copy values into members for(ulIndex=0; ulIndexMapColumnIDs(m_cColumnIDs, m_rgColumnIDs, m_rgColumns), Exphr); // Validate the columns QTESTC(CheckOrdinal(m_hr)); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_VAR_PROTOTYPE(15) //*----------------------------------------------------------------------- // @mfunc DB_E_ERRORSOCCURRED: Ask for Column 0 // // @rdesc TEST_PASS or TEST_FAIL // int MapColID_OpenRowset::Variation_15() { TBEGIN; IID iid = IID_IRowset; DBORDINAL ulIndex = 0; // Initialize the variation INIT; TESTC_(m_hr=m_pIOpenRowset->OpenRowset(NULL, &m_pTable->GetTableID(), NULL, iid, m_cPropSets, m_rgPropSets, (IUnknown **)&m_pIRowset),S_OK); TESTC(m_pIRowset != NULL); TESTC(VerifyInterface(m_pIRowset, IID_IColumnsInfo, ROWSET_INTERFACE, (IUnknown **)&m_pIColumnsInfo)); // Get the Column DBIDs TESTC_(m_hr=m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer),S_OK); // Make array of DBIDs TESTC_(m_hr=MakeDBIDArrays(TRUE,TRUE,TRUE),S_OK); // Copy values into members for(ulIndex=0; ulIndexMapColumnIDs(m_cColumnIDs, m_rgColumnIDs, m_rgColumns); // May or may not find the bookmark column if( GetProperty(DBPROP_BOOKMARKS, DBPROPSET_ROWSET, m_pIRowset) ) { TEST2C_(m_hr, DB_E_ERRORSOCCURRED, DB_S_ERRORSOCCURRED); } else { TESTC_(m_hr, DB_E_ERRORSOCCURRED); } // Validate the columns QTESTC(CheckOrdinal(m_hr)); CLEANUP: FREE; TRETURN; } // }} // {{ TCW_TERMINATE_METHOD //-------------------------------------------------------------------- // @mfunc TestCase Termination Routine // // @rdesc TRUE or FALSE // BOOL MapColID_OpenRowset::Terminate() { // {{ TCW_TERM_BASECLASS_CHECK2 return(IColInfo::Terminate()); } // }} // }} // }} // {{ TCW_TC_PROTOTYPE(MapColIDRow_Rowset) //*----------------------------------------------------------------------- //| Test Case: MapColIDRow_Rowset - MapColumnIDs on a Row object //| Created: 10/12/98 //*----------------------------------------------------------------------- //*----------------------------------------------------------------------- // @mfunc TestCase Initialization Routine // // @rdesc TRUE or FALSE // BOOL MapColIDRow_Rowset::Init() { EINTERFACE eIntf = ROWSET_INTERFACE; if(m_eTestCase == TC_Cmd) eIntf = COMMAND_INTERFACE; // {{ TCW_INIT_BASECLASS_CHECK if(IColInfo::Init(eIntf)) // }} { m_Method = MAPCOLID; switch(m_eTestCase) { case TC_Rowset: return GetRowFromRowset(FALSE); case TC_Cmd: return GetRowFromCommand(FALSE); case TC_OpenRW: return GetRowFromOpenRW(FALSE); case TC_Bind: return GetRowFromBind(FALSE); case TC_IColInfo2: return GetRowFromRowset(TRUE); default: ASSERT(!L"Unhandled Type..."); } } return FALSE; } // {{ TCW_VAR_PROTOTYPE(1) //*----------------------------------------------------------------------- // @mfunc S_OK: cColumnIDs = 0 // // @rdesc TEST_PASS or TEST_FAIL // int MapColIDRow_Rowset::Variation_1() { TBEGIN m_cColumnIDs = 0; SAFE_ALLOC(m_rgColumnIDs, DBID, 1); SAFE_ALLOC(m_rgColumns, DBORDINAL, 1); TESTC_(m_hr=CallMethodOnRowObj(FALSE), S_OK) TESTC(m_rgColumnIDs != NULL) TESTC(m_rgColumns != NULL) CLEANUP: Free(FALSE); TRETURN } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_VAR_PROTOTYPE(2) //*----------------------------------------------------------------------- // @mfunc S_OK: All columns returned by GetColInfo // // @rdesc TEST_PASS or TEST_FAIL // int MapColIDRow_Rowset::Variation_2() { TBEGIN TESTC_(m_hr=CallMethodOnRowObj(FALSE, GETCOLINFO), S_OK) m_cColumns = m_cColumns2; m_rgInfo = m_rgInfo2; TESTC_(MakeDBIDArrays(TRUE,TRUE,TRUE), S_OK) TESTC_(m_hr=CallMethodOnRowObj(FALSE), S_OK) QTESTC(CheckOrdinal(m_hr)) CLEANUP: CLEAR Free(FALSE); TRETURN } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_VAR_PROTOTYPE(3) //*----------------------------------------------------------------------- // @mfunc S_OK: Subset of columns returned by GetColInfo // // @rdesc TEST_PASS or TEST_FAIL // int MapColIDRow_Rowset::Variation_3() { TBEGIN TESTC_(m_hr=CallMethodOnRowObj(FALSE, GETCOLINFO), S_OK) TESTC_PROVIDER(m_cColumns2>2) m_cColumns = m_cColumns2 - 2; m_rgInfo = &(m_rgInfo2[2]); TESTC_(MakeDBIDArrays(TRUE,TRUE,TRUE), S_OK) TESTC_(m_hr=CallMethodOnRowObj(FALSE), S_OK) QTESTC(CheckOrdinal(m_hr)) TESTC(m_rgColumns[0] == m_rgInfo2[2].iOrdinal) CLEANUP: CLEAR Free(FALSE); TRETURN } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_VAR_PROTOTYPE(4) //*----------------------------------------------------------------------- // @mfunc S_OK: Columns out of order // // @rdesc TEST_PASS or TEST_FAIL // int MapColIDRow_Rowset::Variation_4() { TBEGIN DBORDINAL ulIndex = 0; TESTC_(m_hr=CallMethodOnRowObj(FALSE, GETCOLINFO), S_OK) TESTC_PROVIDER(m_cColumns2>2) m_cColumns = m_cColumns2; m_rgInfo = m_rgInfo2; m_cColumnIDs = 2; // Allocate memory for the array of DBID's SAFE_ALLOC(m_rgColumnIDs, DBID, sizeof(DBID) * m_cColumnIDs); // Copy DBIDs using DuplicateDBID, not memcpy DuplicateDBID(m_rgInfo2[2].columnid, &(m_rgColumnIDs[0])); DuplicateDBID(m_rgInfo2[0].columnid, &(m_rgColumnIDs[1])); // Allocate memory for the array of DBID's SAFE_ALLOC(m_rgColumns, DBORDINAL, sizeof(DBORDINAL) * m_cColumnIDs); // Copy values into members for(ulIndex=0; ulIndexMapColumnIDs(1,NULL,m_rgColumns), E_INVALIDARG) else TESTC_(m_pIColumnsInfo2->MapColumnIDs(1,NULL,m_rgColumns), E_INVALIDARG) CLEANUP: CLEAR Free(FALSE); TRETURN } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_VAR_PROTOTYPE(8) //*----------------------------------------------------------------------- // @mfunc E_INVALIDARG: rgColumns is NULL // // @rdesc TEST_PASS or TEST_FAIL // int MapColIDRow_Rowset::Variation_8() { TBEGIN TESTC_(m_hr=CallMethodOnRowObj(FALSE, GETCOLINFO), S_OK) m_cColumns = m_cColumns2; m_rgInfo = m_rgInfo2; TESTC_(MakeDBIDArrays(TRUE,TRUE,TRUE), S_OK) if(m_pIColumnsInfo) TESTC_(m_pIColumnsInfo->MapColumnIDs(m_cColumnIDs,m_rgColumnIDs,NULL), E_INVALIDARG) else TESTC_(m_pIColumnsInfo->MapColumnIDs(m_cColumnIDs,m_rgColumnIDs,NULL), E_INVALIDARG) CLEANUP: CLEAR Free(FALSE); TRETURN } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_TERMINATE_METHOD //*----------------------------------------------------------------------- // @mfunc TestCase Termination Routine // // @rdesc TEST_PASS or TEST_FAIL // BOOL MapColIDRow_Rowset::Terminate() { SAFE_RELEASE(m_pIUnknown); FREE; // {{ TCW_TERM_BASECLASS_CHECK2 return(IColInfo::Terminate()); } // }} // }} TCW_TERMINATE_METHOD_END // }} TCW_TC_PROTOTYPE_END // {{ TCW_TC_PROTOTYPE(ZombieClassCmd) //*----------------------------------------------------------------------- //| Test Case: ZombieClassCmd - zombie on command //| Created: 09/20/96 //| Updated: 04/25/98 //*----------------------------------------------------------------------- //-------------------------------------------------------------------- // @mfunc TestCase Initialization Routine // // @rdesc TRUE or FALSE // BOOL ZombieClassCmd::Init() { BOOL fReturn = FALSE; // Check to see if Transactions are usable if(!IsUsableInterface(SESSION_INTERFACE, IID_ITransactionLocal)) return TEST_SKIPPED; // Initialize to a invalid pointer m_pITransactionLocal = INVALID(ITransactionLocal*); m_pIDBCreateCommand = INVALID(IDBCreateCommand*); // {{ TCW_INIT_BASECLASS_CHECK if(Zombie::Init()) // }} { //This is a mandatory interface, it should always succeed if(RegisterInterface(COMMAND_INTERFACE, IID_IColumnsInfo, 0, NULL)) return TRUE; } // Check to see if ITransaction or Commands are supported if( (!m_pITransactionLocal) || (!m_pIDBCreateCommand) ) fReturn = TEST_SKIPPED; // Clear the bad pointer value if(m_pIDBCreateCommand == INVALID(IDBCreateCommand*)) m_pIDBCreateCommand = NULL; if(m_pITransactionLocal == INVALID(ITransactionLocal*)) m_pITransactionLocal = NULL; return fReturn; } // {{ TCW_VAR_PROTOTYPE(1) //*----------------------------------------------------------------------- // @mfunc Abort with fRetaining set to TRUE // // @rdesc TEST_PASS or TEST_FAIL // int ZombieClassCmd::Variation_1() { return TestTxnCmd(ETXN_ABORT, TRUE); } // }} // {{ TCW_VAR_PROTOTYPE(2) //*----------------------------------------------------------------------- // @mfunc Abort with fRetaining set to FALSE // // @rdesc TEST_PASS or TEST_FAIL // int ZombieClassCmd::Variation_2() { return TestTxnCmd(ETXN_ABORT, FALSE); } // }} // {{ TCW_VAR_PROTOTYPE(3) //*----------------------------------------------------------------------- // @mfunc Commit with fRetaining set to TRUE // // @rdesc TEST_PASS or TEST_FAIL // int ZombieClassCmd::Variation_3() { return TestTxnCmd(ETXN_COMMIT, TRUE); } // }} // {{ TCW_VAR_PROTOTYPE(4) //*----------------------------------------------------------------------- // @mfunc Commit with fRetaining set to FALSE // // @rdesc TEST_PASS or TEST_FAIL // int ZombieClassCmd::Variation_4() { return TestTxnCmd(ETXN_COMMIT, FALSE); } // }} // {{ TCW_TERMINATE_METHOD //-------------------------------------------------------------------- // @mfunc TestCase Termination Routine // // @rdesc TRUE or FALSE // BOOL ZombieClassCmd::Terminate() { // {{ TCW_TERM_BASECLASS_CHECK2 return(Zombie::Terminate()); } // }} // }} // }} // {{ TCW_TC_PROTOTYPE(ZombieClassRowset) //*----------------------------------------------------------------------- //| Test Case: ZombieClassRowset - zombie on a rowset //| Created: 09/20/96 //| Updated: 04/25/98 //*----------------------------------------------------------------------- //-------------------------------------------------------------------- // @mfunc TestCase Initialization Routine // // @rdesc TRUE or FALSE // BOOL ZombieClassRowset::Init() { // Check to see if Transactions are usable if(!IsUsableInterface(SESSION_INTERFACE, IID_ITransactionLocal)) return TEST_SKIPPED; // Initialize to a invalid pointer m_pITransactionLocal = INVALID(ITransactionLocal*); // {{ TCW_INIT_BASECLASS_CHECK if(Zombie::Init()) // }} { //This is a mandatory interface, it should always succeed if(RegisterInterface(ROWSET_INTERFACE, IID_IColumnsInfo, 0, NULL)) return TRUE; } // Check to see if ITransaction is supported if(!m_pITransactionLocal) return TEST_SKIPPED; // Clear the bad pointer value if(m_pITransactionLocal == INVALID(ITransactionLocal*)) m_pITransactionLocal = NULL; return FALSE; } // {{ TCW_VAR_PROTOTYPE(1) //*----------------------------------------------------------------------- // @mfunc Abort with fRetaining set to TRUE // // @rdesc TEST_PASS or TEST_FAIL // int ZombieClassRowset::Variation_1() { return TestTxnRowset(ETXN_ABORT, TRUE); } // }} // {{ TCW_VAR_PROTOTYPE(2) //*----------------------------------------------------------------------- // @mfunc Abort with fRetaining set to FALSE // // @rdesc TEST_PASS or TEST_FAIL // int ZombieClassRowset::Variation_2() { return TestTxnRowset(ETXN_ABORT, FALSE); } // }} // {{ TCW_VAR_PROTOTYPE(3) //*----------------------------------------------------------------------- // @mfunc Commit with fRetaining set to TRUE // // @rdesc TEST_PASS or TEST_FAIL // int ZombieClassRowset::Variation_3() { return TestTxnRowset(ETXN_COMMIT, TRUE); } // }} // {{ TCW_VAR_PROTOTYPE(4) //*----------------------------------------------------------------------- // @mfunc Commit with fRetaining set to FALSE // // @rdesc TEST_PASS or TEST_FAIL // int ZombieClassRowset::Variation_4() { return TestTxnRowset(ETXN_COMMIT, FALSE); } // }} // {{ TCW_VAR_PROTOTYPE(5) //*----------------------------------------------------------------------- // @mfunc Abort with fRetaining set to TRUE for Multiple Rowsets // // @rdesc TEST_PASS or TEST_FAIL // int ZombieClassRowset::Variation_5() { return TestTxnRowset(ETXN_ABORT, TRUE, TRUE); } // }} // {{ TCW_VAR_PROTOTYPE(6) //*----------------------------------------------------------------------- // @mfunc Abort with fRetaining set to FALSE for Multiple Rowsets // // @rdesc TEST_PASS or TEST_FAIL // int ZombieClassRowset::Variation_6() { return TestTxnRowset(ETXN_ABORT, FALSE, TRUE); } // }} // {{ TCW_VAR_PROTOTYPE(7) //*----------------------------------------------------------------------- // @mfunc Commit with fRetaining set to TRUE for Multiple Rowsets // // @rdesc TEST_PASS or TEST_FAIL // int ZombieClassRowset::Variation_7() { return TestTxnRowset(ETXN_COMMIT, TRUE, TRUE); } // }} // {{ TCW_VAR_PROTOTYPE(8) //*----------------------------------------------------------------------- // @mfunc Commit with fRetaining set to FALSE for Multiple Rowsets // // @rdesc TEST_PASS or TEST_FAIL // int ZombieClassRowset::Variation_8() { return TestTxnRowset(ETXN_COMMIT, FALSE, TRUE); } // }} // {{ TCW_TERMINATE_METHOD //-------------------------------------------------------------------- // @mfunc TestCase Termination Routine // // @rdesc TRUE or FALSE // BOOL ZombieClassRowset::Terminate() { // {{ TCW_TERM_BASECLASS_CHECK2 return(Zombie::Terminate()); } // }} // }} // }} // {{ TCW_TC_PROTOTYPE(ZombieClassRow) //*----------------------------------------------------------------------- //| Test Case: ZombieClassRow - zombie on a row //| Created: 1/28/99 //*----------------------------------------------------------------------- //*----------------------------------------------------------------------- // @mfunc TestCase Initialization Routine // // @rdesc TRUE or FALSE // BOOL ZombieClassRow::Init() { // Check to see if Transactions are usable if(!IsUsableInterface(SESSION_INTERFACE, IID_ITransactionLocal)) return TEST_SKIPPED; // Initialize to a invalid pointer m_pITransactionLocal = INVALID(ITransactionLocal*); // {{ TCW_INIT_BASECLASS_CHECK if(Zombie::Init()) // }} { //This is a mandatory interface, it should always succeed if(RegisterInterface(ROW_INTERFACE, IID_IColumnsInfo, 0, NULL)) return TRUE; //Check to see if the interface is supported (IGetRow off the Rowset) if( m_hr == E_NOINTERFACE ) return TEST_SKIPPED; } // Check to see if ITransaction is supported if(!m_pITransactionLocal) return TEST_SKIPPED; // Clear the bad pointer value if(m_pITransactionLocal == INVALID(ITransactionLocal*)) m_pITransactionLocal = NULL; return FALSE; } // {{ TCW_VAR_PROTOTYPE(1) //*----------------------------------------------------------------------- // @mfunc Abort with fRetaining set to TRUE // // @rdesc TEST_PASS or TEST_FAIL // int ZombieClassRow::Variation_1() { return TestTxnRow(ETXN_ABORT, TRUE); } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_VAR_PROTOTYPE(2) //*----------------------------------------------------------------------- // @mfunc Abort with fRetaining set to FALSE // // @rdesc TEST_PASS or TEST_FAIL // int ZombieClassRow::Variation_2() { return TestTxnRow(ETXN_ABORT, FALSE); } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_VAR_PROTOTYPE(3) //*----------------------------------------------------------------------- // @mfunc Commit with fRetaining set to TRUE // // @rdesc TEST_PASS or TEST_FAIL // int ZombieClassRow::Variation_3() { return TestTxnRow(ETXN_COMMIT, TRUE); } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_VAR_PROTOTYPE(4) //*----------------------------------------------------------------------- // @mfunc Commit with fRetaining set to FALSE // // @rdesc TEST_PASS or TEST_FAIL // int ZombieClassRow::Variation_4() { return TestTxnRow(ETXN_COMMIT, FALSE); } // }} TCW_VAR_PROTOTYPE_END // {{ TCW_TERMINATE_METHOD //*----------------------------------------------------------------------- // @mfunc TestCase Termination Routine // // @rdesc TEST_PASS or TEST_FAIL // BOOL ZombieClassRow::Terminate() { // TO DO: Add your own code here // {{ TCW_TERM_BASECLASS_CHECK2 return(Zombie::Terminate()); } // }} // }} TCW_TERMINATE_METHOD_END // }} TCW_TC_PROTOTYPE_END // {{ TCW_TC_PROTOTYPE(ExtendedErrors) //*----------------------------------------------------------------------- //| Test Case: ExtendedErrors - extended error tests //| Created: 09/20/96 //| Updated: 04/25/98 //*----------------------------------------------------------------------- //-------------------------------------------------------------------- // @mfunc TestCase Initialization Routine // // @rdesc TRUE or FALSE // BOOL ExtendedErrors::Init() { BOOL fResult = TEST_SKIPPED; ISupportErrorInfo *pISupportErrorInfo = NULL; // {{ TCW_INIT_BASECLASS_CHECK if(IColInfo::Init(COMMAND_INTERFACE)) // }} { INIT; if(!m_pICommand) goto CLEANUP; if((m_pICommand->QueryInterface(IID_ISupportErrorInfo, (void **)&pISupportErrorInfo))== E_NOINTERFACE) { odtLog<CauseError(); // Do extended check following GetColumnInfo if(CHECK(hr = m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer), S_OK)) fResult = XCHECK(m_pIColumnsInfo, IID_IColumnsInfo, hr); // Validate the columns CheckEachColumn(hr); FREE; // Initialize the variation INIT; m_Method = MAPCOLID; if (!CHECK(hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_COLLISTFROMTBL, NULL, PREPARE),S_OK)) goto CLEANUP; // Cause an error m_pExtError->CauseError(); // Do extended check following MapColumnIDs if(CHECK(hr = m_pIColumnsInfo->MapColumnIDs(m_cColumnIDs, m_rgColumnIDs, m_rgColumns), S_OK)) fResult &= XCHECK(m_pIColumnsInfo, IID_IColumnsInfo, hr); // Validate the columns QTESTC(CheckOrdinal(hr)); CLEANUP: FREE; if (fResult) return TEST_PASS; else return TEST_FAIL; } // }} // {{ TCW_VAR_PROTOTYPE(2) //*----------------------------------------------------------------------- // @mfunc Invalid IColumnsInfo calls on the Command with previous eror object existing // // @rdesc TEST_PASS or TEST_FAIL // int ExtendedErrors::Variation_2() { BOOL fResult = TEST_FAIL; HRESULT hr = E_FAIL; DBORDINAL ulIndex = 0; // Initialize the variation INIT; m_Method = GETCOLINFO; if (!CHECK(hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_COLLISTFROMTBL, NULL, PREPARE, 1), S_OK)) goto CLEANUP; // Free the memory FreeColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer); // Cause an error m_pExtError->CauseError(); // Do extended check following GetColumnInfo if(CHECK(hr = m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, NULL), E_INVALIDARG)) fResult = XCHECK(m_pIColumnsInfo, IID_IColumnsInfo, hr); // Validate the columns CheckEachColumn(hr); FREE; // Initialize the variation INIT; m_Method = MAPCOLID; if (!CHECK(hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_COLLISTFROMTBL, NULL, PREPARE),S_OK)) goto CLEANUP; // Cause an error m_pExtError->CauseError(); // Reset the rgColumns array for(ulIndex=0; ulIndex < m_cColumnIDs; ulIndex++) m_rgColumns[ulIndex] = INVALID(DBORDINAL); // Do extended check following MapColumnIDs if(CHECK(hr = m_pIColumnsInfo->MapColumnIDs(m_cColumnIDs, m_rgColumnIDs, NULL), E_INVALIDARG)) fResult &= XCHECK(m_pIColumnsInfo, IID_IColumnsInfo, hr); // Validate the columns QTESTC(CheckOrdinal(hr)); CLEANUP: FREE; if (fResult) return TEST_PASS; else return TEST_FAIL; } // }} // {{ TCW_VAR_PROTOTYPE(3) //*----------------------------------------------------------------------- // @mfunc Invalid IColumnsInfo calls on the Command with no previous error object existing // // @rdesc TEST_PASS or TEST_FAIL // int ExtendedErrors::Variation_3() { BOOL fResult = TEST_FAIL; HRESULT hr = E_FAIL; DBORDINAL ulIndex = 0; // Initialize the variation INIT; m_Method = GETCOLINFO; if (!CHECK(hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_COLLISTFROMTBL, NULL, PREPARE, 1), S_OK)) goto CLEANUP; // Free the memory FreeColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer); // Do extended check following GetColumnInfo if(CHECK(hr = m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, NULL), E_INVALIDARG)) fResult = XCHECK(m_pIColumnsInfo, IID_IColumnsInfo, hr); // Validate the columns CheckEachColumn(hr); FREE; // Initialize the variation INIT; m_Method = MAPCOLID; if (!CHECK(hr=ExecuteMethod_cmd(TRUE, TRUE, TRUE, eSELECT, SELECT_COLLISTFROMTBL, NULL, PREPARE),S_OK)) goto CLEANUP; // Reset the rgColumns array for(ulIndex=0; ulIndex < m_cColumnIDs; ulIndex++) m_rgColumns[ulIndex] = INVALID(DBORDINAL); // Do extended check following MapColumnIDs if(CHECK(hr = m_pIColumnsInfo->MapColumnIDs(m_cColumnIDs, m_rgColumnIDs, NULL), E_INVALIDARG)) fResult &= XCHECK(m_pIColumnsInfo, IID_IColumnsInfo, hr); // Validate the columns QTESTC(CheckOrdinal(hr)); CLEANUP: FREE; if (fResult) return TEST_PASS; else return TEST_FAIL; } // }} // {{ TCW_VAR_PROTOTYPE(4) //*----------------------------------------------------------------------- // @mfunc Valid IColumnsInfo calls on the Rowset with previous error object existing // // @rdesc TEST_PASS or TEST_FAIL // int ExtendedErrors::Variation_4() { BOOL fResult = TEST_FAIL; HRESULT hr = E_FAIL; // Initialize the variation INIT; m_Method = GETCOLINFO; if (!CHECK(hr=ExecuteMethod_row(TRUE, TRUE, TRUE, eSELECT, SELECT_COLLISTFROMTBL, NULL, PREPARE, 1), S_OK)) goto CLEANUP; // Free the memory FreeColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer); // Cause an error m_pExtError->CauseError(); // Do extended check following GetColumnInfo if(CHECK(hr = m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer), S_OK)) fResult = XCHECK(m_pIColumnsInfo, IID_IColumnsInfo, hr); // Validate the columns CheckEachColumn(hr); FREE; // Initialize the variation INIT; m_Method = MAPCOLID; if (!CHECK(hr=ExecuteMethod_row(TRUE, TRUE, TRUE, eSELECT, SELECT_COLLISTFROMTBL, NULL, PREPARE),S_OK)) goto CLEANUP; // Cause an error m_pExtError->CauseError(); // Do extended check following MapColumnIDs if(CHECK(hr = m_pIColumnsInfo->MapColumnIDs(m_cColumnIDs, m_rgColumnIDs, m_rgColumns), S_OK)) fResult &= XCHECK(m_pIColumnsInfo, IID_IColumnsInfo, hr); // Validate the columns QTESTC(CheckOrdinal(hr)); CLEANUP: FREE; if (fResult) return TEST_PASS; else return TEST_FAIL; } // }} // {{ TCW_VAR_PROTOTYPE(5) //*----------------------------------------------------------------------- // @mfunc Invalid IColumnsInfo calls on the Rowset with previous error object exisiting // // @rdesc TEST_PASS or TEST_FAIL // int ExtendedErrors::Variation_5() { BOOL fResult = TEST_FAIL; HRESULT hr = E_FAIL; DBORDINAL ulIndex = 0; // Initialize the variation INIT; m_Method = GETCOLINFO; if (!CHECK(hr=ExecuteMethod_row(TRUE, TRUE, TRUE, eSELECT, SELECT_COLLISTFROMTBL, NULL, PREPARE, 1), S_OK)) goto CLEANUP; // Free the memory FreeColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer); // Cause an error m_pExtError->CauseError(); // Reset the rgColumns array for(ulIndex=0; ulIndex < m_cColumnIDs; ulIndex++) m_rgColumns[ulIndex] = INVALID(DBORDINAL); // Do extended check following GetColumnInfo if(CHECK(hr = m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, NULL), E_INVALIDARG)) fResult = XCHECK(m_pIColumnsInfo, IID_IColumnsInfo, hr); // Validate the columns CheckEachColumn(hr); FREE; // Initialize the variation INIT; m_Method = MAPCOLID; if (!CHECK(hr=ExecuteMethod_row(TRUE, TRUE, TRUE, eSELECT, SELECT_COLLISTFROMTBL, NULL, PREPARE),S_OK)) goto CLEANUP; // Cause an error m_pExtError->CauseError(); // Reset the rgColumns array for(ulIndex=0; ulIndex < m_cColumnIDs; ulIndex++) m_rgColumns[ulIndex] = INVALID(DBORDINAL); // Do extended check following MapColumnIDs if(CHECK(hr = m_pIColumnsInfo->MapColumnIDs(m_cColumnIDs, m_rgColumnIDs, NULL), E_INVALIDARG)) fResult &= XCHECK(m_pIColumnsInfo, IID_IColumnsInfo, hr); // Validate the columns QTESTC(CheckOrdinal(hr)); CLEANUP: FREE; if (fResult) return TEST_PASS; else return TEST_FAIL; } // }} // {{ TCW_VAR_PROTOTYPE(6) //*----------------------------------------------------------------------- // @mfunc Invalid IColumnsInfo calls on the Rowset with no previous error object exisiting // // @rdesc TEST_PASS or TEST_FAIL // int ExtendedErrors::Variation_6() { BOOL fResult = TEST_FAIL; HRESULT hr = E_FAIL; DBORDINAL ulIndex = 0; // Initialize the variation INIT; m_Method = GETCOLINFO; if (!CHECK(hr=ExecuteMethod_row(TRUE, TRUE, TRUE, eSELECT, SELECT_COLLISTFROMTBL, NULL, PREPARE, 1), S_OK)) goto CLEANUP; // Free the memory FreeColumnInfo(&m_cColumns, &m_rgInfo, &m_pStringsBuffer); // Do extended check following GetColumnInfo if(CHECK(hr = m_pIColumnsInfo->GetColumnInfo(&m_cColumns, &m_rgInfo, NULL), E_INVALIDARG)) fResult = XCHECK(m_pIColumnsInfo, IID_IColumnsInfo, hr); // Validate the columns CheckEachColumn(hr); FREE; // Initialize the variation INIT; m_Method = MAPCOLID; if (!CHECK(hr=ExecuteMethod_row(TRUE, TRUE, TRUE, eSELECT, SELECT_COLLISTFROMTBL, NULL, PREPARE),S_OK)) goto CLEANUP; // Reset the rgColumns array for(ulIndex=0; ulIndex < m_cColumnIDs; ulIndex++) m_rgColumns[ulIndex] = INVALID(DBORDINAL); // Do extended check following MapColumnIDs if(CHECK(hr = m_pIColumnsInfo->MapColumnIDs(m_cColumnIDs, m_rgColumnIDs, NULL), E_INVALIDARG)) fResult &= XCHECK(m_pIColumnsInfo, IID_IColumnsInfo, hr); // Validate the columns QTESTC(CheckOrdinal(hr)); CLEANUP: FREE; if (fResult) return TEST_PASS; else return TEST_FAIL; } // }} // {{ TCW_TERMINATE_METHOD //-------------------------------------------------------------------- // @mfunc TestCase Termination Routine // // @rdesc TRUE or FALSE // BOOL ExtendedErrors::Terminate() { // {{ TCW_TERM_BASECLASS_CHECK2 return(IColInfo::Terminate()); } // }} // }} // }}