User: obo Date: 05/03/18 01:57:12 Modified: /dba/connectivity/source/drivers/file/ FStatement.cxx
Log: INTEGRATION: CWS dba25 (1.35.32); FILE MERGED 2005/03/15 17:06:39 fs 1.35.32.2: #i45104# properly defer CREATE TABLE statements (in all cases), and again allow INSERT and SELECT statements 2005/03/02 12:48:15 oj 1.35.32.1: #i43858# check for create table File Changes: Directory: /dba/connectivity/source/drivers/file/ ================================================= File [changed]: FStatement.cxx Url: http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/file/FStatement.cxx?r1=1.35&r2=1.36 Delta lines: +23 -6 -------------------- --- FStatement.cxx 5 Jan 2005 11:59:50 -0000 1.35 +++ FStatement.cxx 18 Mar 2005 09:57:10 -0000 1.36 @@ -373,11 +373,13 @@ checkDisposed(OStatement_BASE::rBHelper.bDisposed); construct(sql); + Reference< XResultSet > xRS; OResultSet* pResult = createResultSet(); - Reference< XResultSet > xRS = pResult; + xRS = pResult; initializeResultSet(pResult); pResult->OpenImpl(); + return xRS; } // ------------------------------------------------------------------------- @@ -518,20 +520,35 @@ m_aSQLIterator.traverseAll(); const OSQLTables& xTabs = m_aSQLIterator.getTables(); + // sanity checks if ( xTabs.empty() ) + // no tables -> nothing to operate on -> error throwGenericSQLException( ::rtl::OUString::createFromAscii("The statement is invalid. It contains no valid table."), static_cast<XWeak*>(this), makeAny(m_aSQLIterator.getWarning())); + if ( xTabs.size() > 1 || m_aSQLIterator.getWarning().Message.getLength() ) + // more than one table -> can't operate on them -> error throwGenericSQLException( ::rtl::OUString::createFromAscii("The statement is invalid. It contains more than one table."), static_cast<XWeak*>(this), makeAny(m_aSQLIterator.getWarning())); if ( (m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT || m_aSQLIterator.getStatementType() == SQL_STATEMENT_SELECT_COUNT) && m_aSQLIterator.getSelectColumns()->empty() ) + // SELECT statement without columns -> error throwGenericSQLException( ::rtl::OUString::createFromAscii("The statement is invalid. It contains no valid column names."), static_cast<XWeak*>(this), makeAny(m_aSQLIterator.getWarning())); + if ( m_aSQLIterator.getStatementType() == SQL_STATEMENT_CREATE_TABLE ) + // CREATE TABLE is not supported at all + throwGenericSQLException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("The \"CREATE TABLE\" of statement is not supported.")), + static_cast<XWeak*>(this)); + + if ( ( m_aSQLIterator.getStatementType() == SQL_STATEMENT_ODBC_CALL ) || ( m_aSQLIterator.getStatementType() == SQL_STATEMENT_UNKNOWN ) ) + // ODBC call or unknown statement type -> error + throwGenericSQLException( ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("This kind of statement is not supported.")), + static_cast<XWeak*>(this)); + // at this moment we support only one table per select statement Reference< ::com::sun::star::lang::XUnoTunnel> xTunnel(xTabs.begin()->second,UNO_QUERY); if(xTunnel.is()) @@ -543,6 +560,7 @@ m_pTable->acquire(); } OSL_ENSURE(m_pTable,"No table!"); + if ( m_pTable ) m_xColNames = m_pTable->getColumns(); Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY); // set the binding of the resultrow @@ -565,7 +583,6 @@ m_pSQLAnalyzer = createAnalyzer(); - OSL_ENSURE(m_pTable,"We need a table object!"); Reference<XIndexesSupplier> xIndexSup(xTunnel,UNO_QUERY); if(xIndexSup.is()) m_pSQLAnalyzer->setIndexes(xIndexSup->getIndexes()); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
