summaryrefslogtreecommitdiffstats
path: root/connectivity
diff options
context:
space:
mode:
authorLionel Elie Mamane <lionel@mamane.lu>2013-11-07 19:12:23 +0100
committerLionel Elie Mamane <lionel@mamane.lu>2013-11-07 19:17:22 +0100
commitc2ad6017e66909e9797bc728ac28a9575c84343e (patch)
treebbf9497826fb87ef27f33e6ecb3007bebc9ee9d1 /connectivity
parentOAuth2 application keys shouldn't be in the code. (diff)
downloadcore-c2ad6017e66909e9797bc728ac28a9575c84343e.tar.gz
core-c2ad6017e66909e9797bc728ac28a9575c84343e.zip
firebird-sdbc: replace named parameter by unnamed
Change-Id: Iad6023d9d16b10001bb8493dea483e655fc8519c
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/firebird/Connection.cxx31
-rw-r--r--connectivity/source/drivers/firebird/Connection.hxx8
-rw-r--r--connectivity/source/drivers/firebird/Driver.cxx6
-rw-r--r--connectivity/source/drivers/firebird/Driver.hxx4
4 files changed, 44 insertions, 5 deletions
diff --git a/connectivity/source/drivers/firebird/Connection.cxx b/connectivity/source/drivers/firebird/Connection.cxx
index 67e7a9d91fff..3d552d9b87b4 100644
--- a/connectivity/source/drivers/firebird/Connection.cxx
+++ b/connectivity/source/drivers/firebird/Connection.cxx
@@ -45,6 +45,7 @@
#include <com/sun/star/ucb/XSimpleFileAccess2.hpp>
#include "connectivity/dbexception.hxx"
+#include <connectivity/sqlparse.hxx>
#include "resource/common_res.hrc"
#include "resource/hsqldb_res.hrc"
#include "resource/sharedresources.hxx"
@@ -372,6 +373,30 @@ Reference< XStatement > SAL_CALL Connection::createStatement( )
return xReturn;
}
+OUString Connection::transformPreparedStatement(const OUString& _sSQL)
+{
+ OUString sSqlStatement (_sSQL);
+ try
+ {
+ OSQLParser aParser( m_pDriver->getContext() );
+ OUString sErrorMessage;
+ OUString sNewSql;
+ OSQLParseNode* pNode = aParser.parseTree(sErrorMessage,_sSQL);
+ if(pNode)
+ { // special handling for parameters
+ OSQLParseNode::substituteParameterNames(pNode);
+ pNode->parseNodeToStr( sNewSql, this );
+ delete pNode;
+ sSqlStatement = sNewSql;
+ }
+ }
+ catch(const Exception&)
+ {
+ SAL_WARN("connectivity.firebird", "failed to remove named parameters from '" << _sSQL << "'");
+ }
+ return sSqlStatement;
+}
+
Reference< XPreparedStatement > SAL_CALL Connection::prepareStatement(
const OUString& _sSql)
throw(SQLException, RuntimeException)
@@ -384,9 +409,11 @@ Reference< XPreparedStatement > SAL_CALL Connection::prepareStatement(
if(m_aTypeInfo.empty())
buildTypeInfo();
+ OUString sSqlStatement (transformPreparedStatement( _sSql ));
+
Reference< XPreparedStatement > xReturn = new OPreparedStatement(this,
m_aTypeInfo,
- _sSql);
+ sSqlStatement);
m_aStatements.push_back(WeakReferenceHelper(xReturn));
return xReturn;
@@ -401,6 +428,8 @@ Reference< XPreparedStatement > SAL_CALL Connection::prepareCall(
MutexGuard aGuard( m_aMutex );
checkDisposed(Connection_BASE::rBHelper.bDisposed);
+ OUString sSqlStatement (transformPreparedStatement( _sSql ));
+
// not implemented yet :-) a task to do
return NULL;
}
diff --git a/connectivity/source/drivers/firebird/Connection.hxx b/connectivity/source/drivers/firebird/Connection.hxx
index a2f7dfe80b4f..6c8dba4db75b 100644
--- a/connectivity/source/drivers/firebird/Connection.hxx
+++ b/connectivity/source/drivers/firebird/Connection.hxx
@@ -156,6 +156,14 @@ namespace connectivity
throw(::com::sun::star::sdbc::SQLException);
void disposeStatements();
+ /** transform named parameters into unnamed parameters
+ @param _sSQL
+ The SQL statement to transform.
+ @return
+ The new statement with unnamed parameters
+ */
+ OUString transformPreparedStatement(const OUString& _sSQL);
+
public:
Connection(FirebirdDriver* _pDriver);
virtual ~Connection();
diff --git a/connectivity/source/drivers/firebird/Driver.cxx b/connectivity/source/drivers/firebird/Driver.cxx
index ecbb39509f5b..b15514cccbbc 100644
--- a/connectivity/source/drivers/firebird/Driver.cxx
+++ b/connectivity/source/drivers/firebird/Driver.cxx
@@ -48,8 +48,7 @@ namespace connectivity
const Reference< XMultiServiceFactory >& _rxFactory) throw( Exception )
{
SAL_INFO("connectivity.firebird", "FirebirdDriver_CreateInstance()" );
- (void) _rxFactory;
- return *(new FirebirdDriver());
+ return *(new FirebirdDriver(comphelper::getComponentContext(_rxFactory)));
}
}
}
@@ -58,8 +57,9 @@ namespace connectivity
const OUString FirebirdDriver::our_sFirebirdTmpVar("FIREBIRD_TMP");
const OUString FirebirdDriver::our_sFirebirdLockVar("FIREBIRD_LOCK");
-FirebirdDriver::FirebirdDriver()
+FirebirdDriver::FirebirdDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext)
: ODriver_BASE(m_aMutex)
+ , m_aContext(_rxContext)
, m_firebirdTMPDirectory(NULL, true)
, m_firebirdLockDirectory(NULL, true)
{
diff --git a/connectivity/source/drivers/firebird/Driver.hxx b/connectivity/source/drivers/firebird/Driver.hxx
index 31c93c65142b..0c03bac5603e 100644
--- a/connectivity/source/drivers/firebird/Driver.hxx
+++ b/connectivity/source/drivers/firebird/Driver.hxx
@@ -49,6 +49,7 @@ namespace connectivity
static const ::rtl::OUString our_sFirebirdTmpVar;
static const ::rtl::OUString our_sFirebirdLockVar;
+ css::uno::Reference<css::uno::XComponentContext> m_aContext;
::utl::TempFile m_firebirdTMPDirectory;
::utl::TempFile m_firebirdLockDirectory;
@@ -60,7 +61,8 @@ namespace connectivity
public:
- FirebirdDriver();
+ FirebirdDriver(const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext >& _rxContext);
+ const css::uno::Reference<css::uno::XComponentContext>& getContext() const { return m_aContext; }
// OComponentHelper
virtual void SAL_CALL disposing(void);