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
This commit is contained in:
Andrzej J.R. Hunt
2013-08-07 18:18:09 +01:00
parent 89b37927c0
commit 54a138db91
4 changed files with 41 additions and 3 deletions

View File

@@ -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()

View File

@@ -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;
}

View File

@@ -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: */

View File

@@ -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;