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