summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorAndrzej J.R. Hunt <andrzej@ahunt.org>2013-08-07 18:18:09 +0100
committerAndrzej J.R. Hunt <andrzej@ahunt.org>2013-08-07 18:23:37 +0100
commit54a138db910554e8bf2868facc85e47b1776bac2 (patch)
tree19d93929b3a6859a9bac176f62d23ffa7db50c61 /connectivity
parent89b37927c0cd62cd648dd7d085c761545451e659 (diff)
Commit after DDL statement. (firebird-sdbc)
Changes made in a DDL statement are only usable after a commit in firebird, e.g. a created table won't appear etc. Change-Id: I3b537f495b6bc96fa48ebc1a3e46205da60bb2d4
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/firebird/DatabaseMetaData.cxx6
-rw-r--r--connectivity/source/drivers/firebird/Statement.cxx7
-rw-r--r--connectivity/source/drivers/firebird/StatementCommonBase.cxx28
-rw-r--r--connectivity/source/drivers/firebird/StatementCommonBase.hxx3
4 files changed, 41 insertions, 3 deletions
diff --git a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
index cc19be6e4d42..177d041111d7 100644
--- a/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
+++ b/connectivity/source/drivers/firebird/DatabaseMetaData.cxx
@@ -393,20 +393,20 @@ sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionIgnoredInTransactions()
sal_Bool SAL_CALL ODatabaseMetaData::dataDefinitionCausesTransactionCommit()
throw(SQLException, RuntimeException)
{
- return sal_False;
+ return sal_True;
}
sal_Bool SAL_CALL ODatabaseMetaData::supportsDataManipulationTransactionsOnly()
throw(SQLException, RuntimeException)
{
- return sal_False;
+ return sal_True;
}
sal_Bool SAL_CALL ODatabaseMetaData::
supportsDataDefinitionAndDataManipulationTransactions()
throw(SQLException, RuntimeException)
{
- return sal_True;
+ return sal_False;
}
//----- Transaction Support --------------------------------------------------
sal_Bool SAL_CALL ODatabaseMetaData::supportsTransactions()
diff --git a/connectivity/source/drivers/firebird/Statement.cxx b/connectivity/source/drivers/firebird/Statement.cxx
index 6f2ee586dd1e..5317c43e0033 100644
--- a/connectivity/source/drivers/firebird/Statement.cxx
+++ b/connectivity/source/drivers/firebird/Statement.cxx
@@ -139,7 +139,14 @@ uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& s
// TODO: deal with cleanup
// close();
+
evaluateStatusVector(m_statusVector, sql, *this);
+
+ if (isDDLStatement(aStatementHandle))
+ {
+ m_pConnection->commit();
+ }
+
return m_xResultSet;
}
diff --git a/connectivity/source/drivers/firebird/StatementCommonBase.cxx b/connectivity/source/drivers/firebird/StatementCommonBase.cxx
index d3ee72caa536..baf53ca95676 100644
--- a/connectivity/source/drivers/firebird/StatementCommonBase.cxx
+++ b/connectivity/source/drivers/firebird/StatementCommonBase.cxx
@@ -321,4 +321,32 @@ uno::Reference< ::com::sun::star::beans::XPropertySetInfo > SAL_CALL OStatementC
return ::cppu::OPropertySetHelper::createPropertySetInfo(getInfoHelper());
}
+bool OStatementCommonBase::isDDLStatement(isc_stmt_handle& aStatementHandle)
+ throw (SQLException)
+{
+ ISC_STATUS_ARRAY aStatusVector;
+ ISC_STATUS aErr;
+
+ char aInfoItems[] = {isc_info_sql_stmt_type};
+ char aResultsBuffer[8];
+
+ aErr = isc_dsql_sql_info(aStatusVector,
+ &aStatementHandle,
+ sizeof(aInfoItems),
+ aInfoItems,
+ sizeof(aResultsBuffer),
+ aResultsBuffer);
+
+ if (!aErr && aResultsBuffer[0] == isc_info_sql_stmt_type)
+ {
+ const short aBytes = (short) isc_vax_integer(aResultsBuffer+1, 2);
+ const short aStatementType = (short) isc_vax_integer(aResultsBuffer+3, aBytes);
+ if (aStatementType == isc_info_sql_stmt_ddl)
+ return true;
+ }
+ evaluateStatusVector(aStatusVector,
+ "isc_dsq_sql_info",
+ *this);
+ return false;
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/connectivity/source/drivers/firebird/StatementCommonBase.hxx b/connectivity/source/drivers/firebird/StatementCommonBase.hxx
index 12483a6d3faf..0496b11c2457 100644
--- a/connectivity/source/drivers/firebird/StatementCommonBase.hxx
+++ b/connectivity/source/drivers/firebird/StatementCommonBase.hxx
@@ -87,6 +87,9 @@ namespace connectivity
isc_stmt_handle& aStatementHandle,
XSQLDA*& pOutSqlda,
XSQLDA* pInSqlda=0);
+ bool isDDLStatement(isc_stmt_handle& aStatementHandle)
+ throw (::com::sun::star::sdbc::SQLException);
+
public:
::cppu::OBroadcastHelper& rBHelper;