summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej J.R. Hunt <andrzej@ahunt.org>2013-09-09 08:48:56 +0100
committerAndrzej J.R. Hunt <andrzej@ahunt.org>2013-09-09 10:04:45 +0000
commit8c204276a438c718bd2eed6c59189dcfb24032be (patch)
tree894706ddaa419e280cbf123821b57522d9fb7da3
parenta2e73b061f8e17fac7bdc8362231b3afd1e92d46 (diff)
Cleanup findColumn. (firebird-sdbc)
Change-Id: I0458892d9688a8618789652caf67251a61cc63aa Reviewed-on: https://gerrit.libreoffice.org/5884 Reviewed-by: Andrzej J.R. Hunt <andrzej@ahunt.org> Tested-by: Andrzej J.R. Hunt <andrzej@ahunt.org>
-rw-r--r--connectivity/source/drivers/firebird/ResultSet.cxx20
1 files changed, 12 insertions, 8 deletions
diff --git a/connectivity/source/drivers/firebird/ResultSet.cxx b/connectivity/source/drivers/firebird/ResultSet.cxx
index a33460ba23a4..113ba5f5b0e9 100644
--- a/connectivity/source/drivers/firebird/ResultSet.cxx
+++ b/connectivity/source/drivers/firebird/ResultSet.cxx
@@ -311,7 +311,7 @@ Any SAL_CALL OResultSet::queryInterface( const Type & rType ) throw(RuntimeExcep
return concatSequences(OPropertySetHelper::getTypes(), OResultSet_BASE::getTypes());
}
// ---- XColumnLocate ---------------------------------------------------------
-sal_Int32 SAL_CALL OResultSet::findColumn(const OUString& columnName)
+sal_Int32 SAL_CALL OResultSet::findColumn(const OUString& rColumnName)
throw(SQLException, RuntimeException)
{
MutexGuard aGuard(m_pConnection->getMutex());
@@ -325,15 +325,19 @@ sal_Int32 SAL_CALL OResultSet::findColumn(const OUString& columnName)
{
// We assume case sensitive, otherwise you'd have to test
// xMeta->isCaseSensitive and use qualsIgnoreAsciiCase as needed.
- if (columnName == xMeta->getColumnName(i))
- break;
+ if (rColumnName == xMeta->getColumnName(i))
+ return i;
}
- // TODO: add appropriate error
- if (i > nLen)
- throw SQLException();
-
- return i;
+ // The API documentation (XRowLocate) doesn't specify what should happen
+ // if the column name isn't found. The JDBC api specifies that an SQLException
+ // should be thrown. Most drivers return either -1 (some don't check for this
+ // case and just return nLen), however the JDBC specification seems more
+ // correct (in the case of the JDBC/HSQLDB drivers the SQLException is
+ // just propagated from the JDBC call, hence should be expected by any
+ // SDBC user too).
+ ::dbtools::throwSQLException("Invalid column name", SQL_COLUMN_NOT_FOUND, *this);
+ return -1; // Never reached
}
// -------------------------------------------------------------------------
uno::Reference< XInputStream > SAL_CALL OResultSet::getBinaryStream( sal_Int32 columnIndex ) throw(SQLException, RuntimeException)