Fix memory leak
Change-Id: Ia9176826b89b947408230bf65db26a83f269c845
This commit is contained in:
@@ -97,16 +97,6 @@ void MQueryHelper::setAddressbook(OUString &ab)
|
|||||||
OSL_TRACE("\tOUT MQuery::setAddressbook()");
|
OSL_TRACE("\tOUT MQuery::setAddressbook()");
|
||||||
}
|
}
|
||||||
|
|
||||||
void MQueryHelper::setExpression( MQueryExpression &_expr )
|
|
||||||
{
|
|
||||||
OSL_TRACE("IN MQueryHelper::setExpression()");
|
|
||||||
::osl::MutexGuard aGuard(m_aMutex);
|
|
||||||
|
|
||||||
m_aExpr = _expr;
|
|
||||||
|
|
||||||
OSL_TRACE("\tOUT MQuery::setExpression()");
|
|
||||||
}
|
|
||||||
|
|
||||||
void MQueryHelper::append(MQueryHelperResultEntry* resEnt)
|
void MQueryHelper::append(MQueryHelperResultEntry* resEnt)
|
||||||
{
|
{
|
||||||
if ( resEnt != NULL ) {
|
if ( resEnt != NULL ) {
|
||||||
@@ -198,7 +188,7 @@ bool MQueryHelper::getRowValue( ORowSetValue& rValue, sal_Int32 nDBRow,const OUS
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
sal_Int32 MQueryHelper::executeQuery(OConnection* xConnection)
|
sal_Int32 MQueryHelper::executeQuery(OConnection* xConnection, MQueryExpression & expr)
|
||||||
{
|
{
|
||||||
reset();
|
reset();
|
||||||
|
|
||||||
@@ -256,7 +246,7 @@ sal_Int32 MQueryHelper::executeQuery(OConnection* xConnection)
|
|||||||
OUString valueOUString = OStringToOUString( valueOString, RTL_TEXTENCODING_UTF8 );
|
OUString valueOUString = OStringToOUString( valueOString, RTL_TEXTENCODING_UTF8 );
|
||||||
entry->setValue(key, valueOUString);
|
entry->setValue(key, valueOUString);
|
||||||
}
|
}
|
||||||
::std::vector< sal_Bool > vector = entryMatchedByExpression(this, &m_aExpr, entry);
|
::std::vector< sal_Bool > vector = entryMatchedByExpression(this, &expr, entry);
|
||||||
bool result = true;
|
bool result = true;
|
||||||
for (::std::vector<sal_Bool>::iterator iter = vector.begin(); iter != vector.end(); ++iter)
|
for (::std::vector<sal_Bool>::iterator iter = vector.begin(); iter != vector.end(); ++iter)
|
||||||
{
|
{
|
||||||
@@ -279,7 +269,7 @@ sal_Int32 MQueryHelper::executeQuery(OConnection* xConnection)
|
|||||||
::std::vector< sal_Bool > entryMatchedByExpression(MQueryHelper* _aQuery, MQueryExpression* _aExpr, MQueryHelperResultEntry* entry)
|
::std::vector< sal_Bool > entryMatchedByExpression(MQueryHelper* _aQuery, MQueryExpression* _aExpr, MQueryHelperResultEntry* entry)
|
||||||
{
|
{
|
||||||
::std::vector< sal_Bool > resultVector;
|
::std::vector< sal_Bool > resultVector;
|
||||||
MQueryExpression::ExprVector::iterator evIter;
|
MQueryExpression::ExprVector::const_iterator evIter;
|
||||||
for( evIter = _aExpr->getExpressions().begin();
|
for( evIter = _aExpr->getExpressions().begin();
|
||||||
evIter != _aExpr->getExpressions().end();
|
evIter != _aExpr->getExpressions().end();
|
||||||
++evIter )
|
++evIter )
|
||||||
|
@@ -27,6 +27,7 @@
|
|||||||
#include <osl/thread.hxx>
|
#include <osl/thread.hxx>
|
||||||
#include <connectivity/FValue.hxx>
|
#include <connectivity/FValue.hxx>
|
||||||
|
|
||||||
|
#include <boost/noncopyable.hpp>
|
||||||
#include <boost/unordered_map.hpp>
|
#include <boost/unordered_map.hpp>
|
||||||
|
|
||||||
#include "MErrorResource.hxx"
|
#include "MErrorResource.hxx"
|
||||||
@@ -68,6 +69,8 @@ namespace connectivity
|
|||||||
MQueryExpressionBase( node_type _eNodeType ) : m_eNodeType( _eNodeType ) {}
|
MQueryExpressionBase( node_type _eNodeType ) : m_eNodeType( _eNodeType ) {}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual ~MQueryExpressionBase() {}
|
||||||
|
|
||||||
bool isUnknown( ) const { return m_eNodeType == Unknown; }
|
bool isUnknown( ) const { return m_eNodeType == Unknown; }
|
||||||
bool isStringExpr( ) const { return m_eNodeType == StringExpr; }
|
bool isStringExpr( ) const { return m_eNodeType == StringExpr; }
|
||||||
bool isExpr( ) const { return m_eNodeType == Expr; }
|
bool isExpr( ) const { return m_eNodeType == Expr; }
|
||||||
@@ -105,7 +108,7 @@ namespace connectivity
|
|||||||
const OUString& getValue() const { return m_aValue; }
|
const OUString& getValue() const { return m_aValue; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class MQueryExpression : public MQueryExpressionBase
|
class MQueryExpression : public MQueryExpressionBase, private boost::noncopyable
|
||||||
{
|
{
|
||||||
friend class MQueryHelper;
|
friend class MQueryHelper;
|
||||||
|
|
||||||
@@ -117,14 +120,14 @@ namespace connectivity
|
|||||||
OR
|
OR
|
||||||
} bool_cond;
|
} bool_cond;
|
||||||
|
|
||||||
void setExpressions( ExprVector& _exprVector )
|
|
||||||
{ m_aExprVector = _exprVector; }
|
|
||||||
|
|
||||||
// All expressions on a peer level use same condition operator
|
// All expressions on a peer level use same condition operator
|
||||||
void setExpressionCondition( bool_cond _cond )
|
void setExpressionCondition( bool_cond _cond )
|
||||||
{ m_aExprCondType = _cond; }
|
{ m_aExprCondType = _cond; }
|
||||||
|
|
||||||
ExprVector& getExpressions( )
|
void addExpression(MQueryExpressionBase * expr)
|
||||||
|
{ m_aExprVector.push_back(expr); }
|
||||||
|
|
||||||
|
ExprVector const & getExpressions( ) const
|
||||||
{ return m_aExprVector; }
|
{ return m_aExprVector; }
|
||||||
|
|
||||||
// All expressions on a peer level use same condition operator
|
// All expressions on a peer level use same condition operator
|
||||||
@@ -133,8 +136,15 @@ namespace connectivity
|
|||||||
|
|
||||||
MQueryExpression() : MQueryExpressionBase( MQueryExpressionBase::Expr ),
|
MQueryExpression() : MQueryExpressionBase( MQueryExpressionBase::Expr ),
|
||||||
m_aExprCondType( OR )
|
m_aExprCondType( OR )
|
||||||
{ m_aExprVector.clear(); }
|
{}
|
||||||
|
|
||||||
|
virtual ~MQueryExpression() {
|
||||||
|
for (ExprVector::iterator i(m_aExprVector.begin());
|
||||||
|
i != m_aExprVector.end(); ++i)
|
||||||
|
{
|
||||||
|
delete *i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
ExprVector m_aExprVector;
|
ExprVector m_aExprVector;
|
||||||
@@ -174,7 +184,6 @@ namespace connectivity
|
|||||||
OColumnAlias m_rColumnAlias;
|
OColumnAlias m_rColumnAlias;
|
||||||
ErrorDescriptor m_aError;
|
ErrorDescriptor m_aError;
|
||||||
OUString m_aAddressbook;
|
OUString m_aAddressbook;
|
||||||
MQueryExpression m_aExpr;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void clearResultOrComplete();
|
void clearResultOrComplete();
|
||||||
@@ -197,14 +206,12 @@ namespace connectivity
|
|||||||
sal_Int32 getResultCount() const;
|
sal_Int32 getResultCount() const;
|
||||||
bool checkRowAvailable( sal_Int32 nDBRow );
|
bool checkRowAvailable( sal_Int32 nDBRow );
|
||||||
bool getRowValue( ORowSetValue& rValue, sal_Int32 nDBRow,const OUString& aDBColumnName, sal_Int32 nType );
|
bool getRowValue( ORowSetValue& rValue, sal_Int32 nDBRow,const OUString& aDBColumnName, sal_Int32 nType );
|
||||||
sal_Int32 executeQuery(OConnection* xConnection);
|
sal_Int32 executeQuery(OConnection* xConnection, MQueryExpression & expr);
|
||||||
const OColumnAlias& getColumnAlias() const { return m_rColumnAlias; }
|
const OColumnAlias& getColumnAlias() const { return m_rColumnAlias; }
|
||||||
bool hadError() const { return m_aError.is(); }
|
bool hadError() const { return m_aError.is(); }
|
||||||
inline ErrorDescriptor& getError() { return m_aError; }
|
inline ErrorDescriptor& getError() { return m_aError; }
|
||||||
|
|
||||||
void setAddressbook( OUString&);
|
void setAddressbook( OUString&);
|
||||||
void setExpression( MQueryExpression &_expr );
|
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -823,7 +823,7 @@ void OResultSet::analyseWhereClause( const OSQLParseNode* parseT
|
|||||||
OSL_TRACE("analyseSQL : Got Punctuation ()");
|
OSL_TRACE("analyseSQL : Got Punctuation ()");
|
||||||
MQueryExpression *subExpression = new MQueryExpression();
|
MQueryExpression *subExpression = new MQueryExpression();
|
||||||
analyseWhereClause( parseTree->getChild( 1 ), *subExpression );
|
analyseWhereClause( parseTree->getChild( 1 ), *subExpression );
|
||||||
queryExpression.getExpressions().push_back( subExpression );
|
queryExpression.addExpression( subExpression );
|
||||||
}
|
}
|
||||||
else if ((SQL_ISRULE(parseTree,search_condition) || (SQL_ISRULE(parseTree,boolean_term)))
|
else if ((SQL_ISRULE(parseTree,search_condition) || (SQL_ISRULE(parseTree,boolean_term)))
|
||||||
&& parseTree->count() == 3) // Handle AND/OR
|
&& parseTree->count() == 3) // Handle AND/OR
|
||||||
@@ -885,7 +885,7 @@ void OResultSet::analyseWhereClause( const OSQLParseNode* parseT
|
|||||||
OSL_TRACE("Query always evaluates to FALSE");
|
OSL_TRACE("Query always evaluates to FALSE");
|
||||||
m_bIsAlwaysFalseQuery = true;
|
m_bIsAlwaysFalseQuery = true;
|
||||||
}
|
}
|
||||||
queryExpression.getExpressions().push_back( new MQueryExpressionString( columnName, op, matchString ));
|
queryExpression.addExpression( new MQueryExpressionString( columnName, op, matchString ));
|
||||||
}
|
}
|
||||||
else if (SQL_ISRULE(parseTree,like_predicate))
|
else if (SQL_ISRULE(parseTree,like_predicate))
|
||||||
{
|
{
|
||||||
@@ -1021,7 +1021,7 @@ void OResultSet::analyseWhereClause( const OSQLParseNode* parseT
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
queryExpression.getExpressions().push_back( new MQueryExpressionString( columnName, op, matchString ));
|
queryExpression.addExpression( new MQueryExpressionString( columnName, op, matchString ));
|
||||||
}
|
}
|
||||||
else if (SQL_ISRULE(parseTree,test_for_null))
|
else if (SQL_ISRULE(parseTree,test_for_null))
|
||||||
{
|
{
|
||||||
@@ -1046,7 +1046,7 @@ void OResultSet::analyseWhereClause( const OSQLParseNode* parseT
|
|||||||
OUString sTableRange;
|
OUString sTableRange;
|
||||||
m_pSQLIterator->getColumnRange(parseTree->getChild(0),columnName,sTableRange);
|
m_pSQLIterator->getColumnRange(parseTree->getChild(0),columnName,sTableRange);
|
||||||
|
|
||||||
queryExpression.getExpressions().push_back( new MQueryExpressionString( columnName, op ));
|
queryExpression.addExpression( new MQueryExpressionString( columnName, op ));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1103,12 +1103,10 @@ void OResultSet::fillRowData()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_aQueryHelper.setExpression( queryExpression );
|
|
||||||
|
|
||||||
OUString aStr( m_pTable->getName() );
|
OUString aStr( m_pTable->getName() );
|
||||||
m_aQueryHelper.setAddressbook( aStr );
|
m_aQueryHelper.setAddressbook( aStr );
|
||||||
|
|
||||||
sal_Int32 rv = m_aQueryHelper.executeQuery(xConnection);
|
sal_Int32 rv = m_aQueryHelper.executeQuery(xConnection, queryExpression);
|
||||||
if ( rv == -1 ) {
|
if ( rv == -1 ) {
|
||||||
m_pStatement->getOwnConnection()->throwSQLException( STR_ERR_EXECUTING_QUERY, *this );
|
m_pStatement->getOwnConnection()->throwSQLException( STR_ERR_EXECUTING_QUERY, *this );
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user