Free SQLVAR as appropriate. (firebird-sdbc)
Change-Id: I5742e178baa85f3faf80d95f57fed248f7984793
This commit is contained in:
@@ -77,7 +77,7 @@ void OPreparedStatement::ensurePrepared()
|
|||||||
m_pInSqlda = (XSQLDA*) malloc(XSQLDA_LENGTH(10));
|
m_pInSqlda = (XSQLDA*) malloc(XSQLDA_LENGTH(10));
|
||||||
m_pInSqlda->version = SQLDA_VERSION1;
|
m_pInSqlda->version = SQLDA_VERSION1;
|
||||||
m_pInSqlda->sqln = 10;
|
m_pInSqlda->sqln = 10;
|
||||||
} // TODO: free this on closing
|
}
|
||||||
|
|
||||||
prepareAndDescribeStatement(m_sSqlStatement,
|
prepareAndDescribeStatement(m_sSqlStatement,
|
||||||
m_pOutSqlda,
|
m_pOutSqlda,
|
||||||
@@ -172,7 +172,22 @@ Reference< XResultSetMetaData > SAL_CALL OPreparedStatement::getMetaData()
|
|||||||
|
|
||||||
void SAL_CALL OPreparedStatement::close() throw(SQLException, RuntimeException)
|
void SAL_CALL OPreparedStatement::close() throw(SQLException, RuntimeException)
|
||||||
{
|
{
|
||||||
|
MutexGuard aGuard( m_pConnection->getMutex() );
|
||||||
|
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
|
||||||
|
|
||||||
OStatementCommonBase::close();
|
OStatementCommonBase::close();
|
||||||
|
if (m_pInSqlda)
|
||||||
|
{
|
||||||
|
freeSQLVAR(m_pInSqlda);
|
||||||
|
free(m_pInSqlda);
|
||||||
|
m_pInSqlda = 0;
|
||||||
|
}
|
||||||
|
if (m_pOutSqlda)
|
||||||
|
{
|
||||||
|
freeSQLVAR(m_pOutSqlda);
|
||||||
|
free(m_pOutSqlda);
|
||||||
|
m_pOutSqlda = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SAL_CALL OPreparedStatement::disposing()
|
void SAL_CALL OPreparedStatement::disposing()
|
||||||
|
@@ -265,8 +265,6 @@ void OResultSet::disposing(void)
|
|||||||
|
|
||||||
MutexGuard aGuard(m_pConnection->getMutex());
|
MutexGuard aGuard(m_pConnection->getMutex());
|
||||||
|
|
||||||
// TODO: free the sqlda
|
|
||||||
|
|
||||||
m_xMetaData = NULL;
|
m_xMetaData = NULL;
|
||||||
}
|
}
|
||||||
// -------------------------------------------------------------------------
|
// -------------------------------------------------------------------------
|
||||||
|
@@ -60,6 +60,12 @@ namespace connectivity
|
|||||||
::com::sun::star::sdbc::XColumnLocate,
|
::com::sun::star::sdbc::XColumnLocate,
|
||||||
::com::sun::star::lang::XServiceInfo> OResultSet_BASE;
|
::com::sun::star::lang::XServiceInfo> OResultSet_BASE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This ResultSet does not deal with the management of the SQLDA
|
||||||
|
* it is supplied with. The owner must mange its SQLDA appropriately
|
||||||
|
* and ensure that the ResultSet is destroyed before disposing of the
|
||||||
|
* SQLDA.
|
||||||
|
*/
|
||||||
class OResultSet : public OResultSet_BASE,
|
class OResultSet : public OResultSet_BASE,
|
||||||
public ::cppu::OPropertySetHelper,
|
public ::cppu::OPropertySetHelper,
|
||||||
public OPropertyArrayUsageHelper<OResultSet>
|
public OPropertyArrayUsageHelper<OResultSet>
|
||||||
|
@@ -78,6 +78,21 @@ void SAL_CALL OStatement::release() throw()
|
|||||||
OStatementCommonBase::release();
|
OStatementCommonBase::release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OStatement::disposeResultSet()
|
||||||
|
{
|
||||||
|
MutexGuard aGuard(m_pConnection->getMutex());
|
||||||
|
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
|
||||||
|
|
||||||
|
OStatementCommonBase::disposeResultSet();
|
||||||
|
|
||||||
|
if (m_pSqlda)
|
||||||
|
{
|
||||||
|
freeSQLVAR(m_pSqlda);
|
||||||
|
free(m_pSqlda);
|
||||||
|
m_pSqlda = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ---- XStatement -----------------------------------------------------------
|
// ---- XStatement -----------------------------------------------------------
|
||||||
sal_Int32 SAL_CALL OStatement::executeUpdate(const OUString& sql)
|
sal_Int32 SAL_CALL OStatement::executeUpdate(const OUString& sql)
|
||||||
throw(SQLException, RuntimeException)
|
throw(SQLException, RuntimeException)
|
||||||
@@ -109,11 +124,12 @@ uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& s
|
|||||||
MutexGuard aGuard(m_pConnection->getMutex());
|
MutexGuard aGuard(m_pConnection->getMutex());
|
||||||
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
|
checkDisposed(OStatementCommonBase_Base::rBHelper.bDisposed);
|
||||||
|
|
||||||
XSQLDA* pOutSqlda = 0;
|
|
||||||
ISC_STATUS aErr = 0;
|
ISC_STATUS aErr = 0;
|
||||||
|
|
||||||
|
disposeResultSet();
|
||||||
|
|
||||||
prepareAndDescribeStatement(sql,
|
prepareAndDescribeStatement(sql,
|
||||||
pOutSqlda);
|
m_pSqlda);
|
||||||
|
|
||||||
aErr = isc_dsql_execute(m_statusVector,
|
aErr = isc_dsql_execute(m_statusVector,
|
||||||
&m_pConnection->getTransaction(),
|
&m_pConnection->getTransaction(),
|
||||||
@@ -126,7 +142,7 @@ uno::Reference< XResultSet > SAL_CALL OStatement::executeQuery(const OUString& s
|
|||||||
m_xResultSet = new OResultSet(m_pConnection,
|
m_xResultSet = new OResultSet(m_pConnection,
|
||||||
uno::Reference< XInterface >(*this),
|
uno::Reference< XInterface >(*this),
|
||||||
m_aStatementHandle,
|
m_aStatementHandle,
|
||||||
pOutSqlda);
|
m_pSqlda);
|
||||||
|
|
||||||
// TODO: deal with cleanup
|
// TODO: deal with cleanup
|
||||||
|
|
||||||
@@ -179,6 +195,7 @@ void SAL_CALL OStatement::close() throw(SQLException, RuntimeException)
|
|||||||
|
|
||||||
void SAL_CALL OStatement::disposing()
|
void SAL_CALL OStatement::disposing()
|
||||||
{
|
{
|
||||||
|
disposeResultSet();
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||||
|
@@ -39,12 +39,18 @@ namespace connectivity
|
|||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
virtual ~OStatement(){}
|
virtual ~OStatement(){}
|
||||||
|
|
||||||
|
XSQLDA* m_pSqlda;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
// a constructor, which is required for returning objects:
|
// a constructor, which is required for returning objects:
|
||||||
OStatement( OConnection* _pConnection)
|
OStatement( OConnection* _pConnection)
|
||||||
: OStatementCommonBase( _pConnection)
|
: OStatementCommonBase( _pConnection),
|
||||||
|
m_pSqlda(0)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
virtual void disposeResultSet();
|
||||||
|
|
||||||
DECLARE_SERVICE_INFO();
|
DECLARE_SERVICE_INFO();
|
||||||
|
|
||||||
virtual void SAL_CALL acquire() throw();
|
virtual void SAL_CALL acquire() throw();
|
||||||
|
@@ -64,7 +64,7 @@ namespace connectivity
|
|||||||
isc_stmt_handle m_aStatementHandle;
|
isc_stmt_handle m_aStatementHandle;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void disposeResultSet();
|
virtual void disposeResultSet();
|
||||||
void freeStatementHandle()
|
void freeStatementHandle()
|
||||||
throw (::com::sun::star::sdbc::SQLException);
|
throw (::com::sun::star::sdbc::SQLException);
|
||||||
|
|
||||||
@@ -102,7 +102,10 @@ namespace connectivity
|
|||||||
using OStatementCommonBase_Base::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
|
using OStatementCommonBase_Base::operator ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface >;
|
||||||
|
|
||||||
// OComponentHelper
|
// OComponentHelper
|
||||||
virtual void SAL_CALL disposing(void){OStatementCommonBase_Base::disposing();}
|
virtual void SAL_CALL disposing(void){
|
||||||
|
disposeResultSet();
|
||||||
|
OStatementCommonBase_Base::disposing();
|
||||||
|
}
|
||||||
// XInterface
|
// XInterface
|
||||||
virtual void SAL_CALL release() throw();
|
virtual void SAL_CALL release() throw();
|
||||||
virtual void SAL_CALL acquire() throw();
|
virtual void SAL_CALL acquire() throw();
|
||||||
|
@@ -251,4 +251,51 @@ void firebird::mallocSQLVAR(XSQLDA* pSqlda)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void firebird::freeSQLVAR(XSQLDA* pSqlda)
|
||||||
|
{
|
||||||
|
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:
|
||||||
|
case SQL_VARYING:
|
||||||
|
case SQL_SHORT:
|
||||||
|
case SQL_LONG:
|
||||||
|
case SQL_FLOAT:
|
||||||
|
case SQL_DOUBLE:
|
||||||
|
case SQL_D_FLOAT:
|
||||||
|
case SQL_TIMESTAMP:
|
||||||
|
case SQL_BLOB:
|
||||||
|
case SQL_INT64:
|
||||||
|
free(pVar->sqldata);
|
||||||
|
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_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)
|
||||||
|
{
|
||||||
|
free(pVar->sqlind);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
@@ -55,7 +55,7 @@ namespace connectivity
|
|||||||
|
|
||||||
void mallocSQLVAR(XSQLDA* pSqlda);
|
void mallocSQLVAR(XSQLDA* pSqlda);
|
||||||
|
|
||||||
// void freeSQLVAR(XSQLDA* pSqlda);
|
void freeSQLVAR(XSQLDA* pSqlda);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif //CONNECTIVITY_FIREBIRD_UTIL_HXX
|
#endif //CONNECTIVITY_FIREBIRD_UTIL_HXX
|
||||||
|
Reference in New Issue
Block a user