summaryrefslogtreecommitdiff
path: root/connectivity
diff options
context:
space:
mode:
authorAndrzej J.R. Hunt <andrzej@ahunt.org>2013-07-22 13:29:02 +0200
committerAndrzej J.R. Hunt <andrzej@ahunt.org>2013-07-22 18:03:27 +0200
commit291b87962dbbd6859ec5156f69fbdf5a6e74be75 (patch)
tree5ea60b8e2a0b0801ff2bb33b6b8001cef06fc9a8 /connectivity
parentdc3202517d2f48cea27e712a30be79acfdabb5f3 (diff)
Move allocation of SQLVAR memory to Util (firebird-sdbc).
(Is also needed for allocating sqlin data in prepared statement.) Change-Id: Id572ddbc582c709c8d361ca6e9a670fb8f2d2165
Diffstat (limited to 'connectivity')
-rw-r--r--connectivity/source/drivers/firebird/FStatement.cxx74
-rw-r--r--connectivity/source/drivers/firebird/FStatement.hxx3
-rw-r--r--connectivity/source/drivers/firebird/Util.cxx69
-rw-r--r--connectivity/source/drivers/firebird/Util.hxx6
4 files changed, 82 insertions, 70 deletions
diff --git a/connectivity/source/drivers/firebird/FStatement.cxx b/connectivity/source/drivers/firebird/FStatement.cxx
index 9eac4032c867..7085b67e9787 100644
--- a/connectivity/source/drivers/firebird/FStatement.cxx
+++ b/connectivity/source/drivers/firebird/FStatement.cxx
@@ -36,8 +36,7 @@
#include "FStatement.hxx"
#include "FConnection.hxx"
#include "FResultSet.hxx"
-#include <propertyids.hxx>
-#include <TConnection.hxx>
+#include "Util.hxx"
#include <ibase.h>
@@ -45,7 +44,9 @@
#include <cppuhelper/typeprovider.hxx>
#include <osl/diagnose.h>
#include <osl/thread.h>
+#include <propertyids.hxx>
#include <rtl/ustrbuf.hxx>
+#include <TConnection.hxx>
#include <com/sun/star/sdbc/ResultSetConcurrency.hpp>
#include <com/sun/star/sdbc/ResultSetType.hpp>
@@ -215,7 +216,8 @@ OUString OStatement_Base::sanitizeSqlString(const OUString& sqlIn)
int OStatement_Base::prepareAndDescribeStatement(const OUString& sqlIn,
isc_stmt_handle& aStatementHandle,
- XSQLDA*& pOutSqlda)
+ XSQLDA*& pOutSqlda,
+ XSQLDA* pInSqlda)
{
MutexGuard aGuard(m_pConnection->getMutex());
@@ -247,7 +249,7 @@ int OStatement_Base::prepareAndDescribeStatement(const OUString& sqlIn,
0,
OUStringToOString(sql, RTL_TEXTENCODING_UTF8).getStr(),
1,
- NULL);
+ pInSqlda);
}
if (aErr)
@@ -280,7 +282,6 @@ int OStatement_Base::prepareAndDescribeStatement(const OUString& sqlIn,
1,
pOutSqlda);
}
- XSQLVAR* pVar = pOutSqlda->sqlvar;
// Process each XSQLVAR parameter structure in the output XSQLDA
if (aErr)
@@ -290,68 +291,7 @@ int OStatement_Base::prepareAndDescribeStatement(const OUString& sqlIn,
}
else
{
- // TODO: confirm the sizings below.
- for (int i=0; i < pOutSqlda->sqld; i++, pVar++)
- {
- int dtype = (pVar->sqltype & ~1); /* drop flag bit for now */
- switch(dtype) {
- case SQL_TEXT:
- pVar->sqldata = (char *)malloc(sizeof(char)*pVar->sqllen);
- break;
- case SQL_VARYING:
- pVar->sqltype = SQL_TEXT;
- pVar->sqldata = (char *)malloc(sizeof(char)*pVar->sqllen);
- break;
- case SQL_SHORT:
- pVar->sqldata = (char *)malloc(sizeof(char)*pVar->sqllen);
- break;
- case SQL_LONG:
- pVar->sqldata = (char *)malloc(sizeof(long));
- break;
- case SQL_FLOAT:
- pVar->sqldata = (char *)malloc(sizeof(double));
- break;
- case SQL_DOUBLE:
- pVar->sqldata = (char *)malloc(sizeof(double));
- break;
- case SQL_D_FLOAT:
- pVar->sqldata = (char *)malloc(sizeof(double));
- break;
- case SQL_TIMESTAMP:
- pVar->sqldata = (char *)malloc(sizeof(time_t));
- break;
- case SQL_BLOB:
- pVar->sqldata = (char*) malloc(sizeof(ISC_QUAD));
- break;
- case SQL_ARRAY:
- assert(false); // TODO: implement
- break;
- case SQL_TYPE_TIME:
- assert(false); // TODO: implement
- break;
- case SQL_TYPE_DATE:
- assert(false); // TODO: implement
- break;
- case SQL_INT64:
- pVar->sqldata = (char *)malloc(sizeof(int));
- break;
- case SQL_NULL:
- assert(false); // TODO: implement
- break;
- case SQL_QUAD:
- assert(false); // TODO: implement
- break;
- default:
- SAL_WARN("connectivity.firebird", "Unknown type: " << dtype);
- assert(false);
- break;
- }
- if (pVar->sqltype & 1)
- {
- /* allocate variable to hold NULL status */
- pVar->sqlind = (short *)malloc(sizeof(short));
- }
- }
+ mallocSQLVAR(pOutSqlda);
}
return aErr;
diff --git a/connectivity/source/drivers/firebird/FStatement.hxx b/connectivity/source/drivers/firebird/FStatement.hxx
index 514f109acbef..8113f576a64b 100644
--- a/connectivity/source/drivers/firebird/FStatement.hxx
+++ b/connectivity/source/drivers/firebird/FStatement.hxx
@@ -103,7 +103,8 @@ namespace connectivity
virtual ~OStatement_Base();
int prepareAndDescribeStatement(const OUString& sqlIn,
isc_stmt_handle& aStatementHandle,
- XSQLDA*& pOutSqlda);
+ XSQLDA*& pOutSqlda,
+ XSQLDA* pInSqlda=0);
::rtl::OUString sanitizeSqlString(const OUString& sqlIn);
public:
diff --git a/connectivity/source/drivers/firebird/Util.cxx b/connectivity/source/drivers/firebird/Util.cxx
index 0c23495c9cda..bc77775e4d90 100644
--- a/connectivity/source/drivers/firebird/Util.cxx
+++ b/connectivity/source/drivers/firebird/Util.cxx
@@ -9,8 +9,6 @@
#include "Util.hxx"
-#include <ibase.h>
-
using namespace ::connectivity;
using namespace ::rtl;
@@ -148,4 +146,71 @@ short firebird::getFBTypeFromBlrType(short blrType)
return 0;
}
}
+
+void firebird::mallocSQLVAR(XSQLDA* pSqlda)
+{
+ // TODO: confirm the sizings below.
+ XSQLVAR* pVar = pSqlda->sqlvar;
+ for (int i=0; i < pSqlda->sqld; i++, pVar++)
+ {
+ int dtype = (pVar->sqltype & ~1); /* drop flag bit for now */
+ switch(dtype) {
+ case SQL_TEXT:
+ pVar->sqldata = (char *)malloc(sizeof(char)*pVar->sqllen);
+ break;
+ case SQL_VARYING:
+ pVar->sqltype = SQL_TEXT;
+ pVar->sqldata = (char *)malloc(sizeof(char)*pVar->sqllen);
+ break;
+ case SQL_SHORT:
+ pVar->sqldata = (char *)malloc(sizeof(short));
+ break;
+ case SQL_LONG:
+ pVar->sqldata = (char *)malloc(sizeof(long));
+ break;
+ case SQL_FLOAT:
+ pVar->sqldata = (char *)malloc(sizeof(double));
+ break;
+ case SQL_DOUBLE:
+ pVar->sqldata = (char *)malloc(sizeof(double));
+ break;
+ case SQL_D_FLOAT:
+ pVar->sqldata = (char *)malloc(sizeof(double));
+ break;
+ case SQL_TIMESTAMP:
+ pVar->sqldata = (char *)malloc(sizeof(time_t));
+ break;
+ case SQL_BLOB:
+ pVar->sqldata = (char*) malloc(sizeof(ISC_QUAD));
+ break;
+ case SQL_ARRAY:
+ assert(false); // TODO: implement
+ break;
+ case SQL_TYPE_TIME:
+ assert(false); // TODO: implement
+ break;
+ case SQL_TYPE_DATE:
+ assert(false); // TODO: implement
+ break;
+ case SQL_INT64:
+ pVar->sqldata = (char *)malloc(sizeof(int));
+ break;
+ case SQL_NULL:
+ assert(false); // TODO: implement
+ break;
+ case SQL_QUAD:
+ assert(false); // TODO: implement
+ break;
+ default:
+ SAL_WARN("connectivity.firebird", "Unknown type: " << dtype);
+ assert(false);
+ break;
+ }
+ if (pVar->sqltype & 1)
+ {
+ /* allocate variable to hold NULL status */
+ pVar->sqlind = (short *)malloc(sizeof(short));
+ }
+ }
+}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file
diff --git a/connectivity/source/drivers/firebird/Util.hxx b/connectivity/source/drivers/firebird/Util.hxx
index 0d68099b78df..f3039dbcdc51 100644
--- a/connectivity/source/drivers/firebird/Util.hxx
+++ b/connectivity/source/drivers/firebird/Util.hxx
@@ -10,6 +10,8 @@
#ifndef CONNECTIVITY_FIREBIRD_UTIL_HXX
#define CONNECTIVITY_FIREBIRD_UTIL_HXX
+#include <ibase.h>
+
#include <rtl/ustring.hxx>
#include <com/sun/star/sdbc/DataType.hpp>
@@ -28,6 +30,10 @@ namespace connectivity
* between the two when retrieving column metadata.
*/
short getFBTypeFromBlrType(short blrType);
+
+ void mallocSQLVAR(XSQLDA* pSqlda);
+
+// void freeSQLVAR(XSQLDA* pSqlda);
}
}
#endif //CONNECTIVITY_FIREBIRD_UTIL_HXX