summaryrefslogtreecommitdiff
path: root/connectivity/source/drivers/file/FStatement.cxx
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2005-03-18 08:57:10 +0000
committerOliver Bolte <obo@openoffice.org>2005-03-18 08:57:10 +0000
commitd3a6b7f2a2250592dcfc4beb03d810f8c9994ed9 (patch)
treebfe45ed17e09aab78edc4ca766169339c785211c /connectivity/source/drivers/file/FStatement.cxx
parent6bb1fec4b0bcc95c09257a94d6be66d83b8aaeeb (diff)
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
Diffstat (limited to 'connectivity/source/drivers/file/FStatement.cxx')
-rw-r--r--connectivity/source/drivers/file/FStatement.cxx27
1 files changed, 22 insertions, 5 deletions
diff --git a/connectivity/source/drivers/file/FStatement.cxx b/connectivity/source/drivers/file/FStatement.cxx
index f3368f4d344c..62b175059c69 100644
--- a/connectivity/source/drivers/file/FStatement.cxx
+++ b/connectivity/source/drivers/file/FStatement.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: FStatement.cxx,v $
*
- * $Revision: 1.35 $
+ * $Revision: 1.36 $
*
- * last change: $Author: obo $ $Date: 2005-01-05 11:59:50 $
+ * last change: $Author: obo $ $Date: 2005-03-18 09:57:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -373,11 +373,13 @@ Reference< XResultSet > SAL_CALL OStatement::executeQuery( const ::rtl::OUString
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 @@ void OStatement_Base::construct(const ::rtl::OUString& sql) throw(SQLException,
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,7 +560,8 @@ void OStatement_Base::construct(const ::rtl::OUString& sql) throw(SQLException,
m_pTable->acquire();
}
OSL_ENSURE(m_pTable,"No table!");
- m_xColNames = m_pTable->getColumns();
+ if ( m_pTable )
+ m_xColNames = m_pTable->getColumns();
Reference<XIndexAccess> xNames(m_xColNames,UNO_QUERY);
// set the binding of the resultrow
m_aRow = new OValueRefVector(xNames->getCount());
@@ -565,7 +583,6 @@ void OStatement_Base::construct(const ::rtl::OUString& sql) throw(SQLException,
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());