Tag: cws_src680_dba30 User: oj Date: 05/12/29 22:20:24 Modified: /dba/dbaccess/source/core/api/ RowSetCache.cxx, RowSetCache.hxx
Log: #i53377# check if innerjoin was used File Changes: Directory: /dba/dbaccess/source/core/api/ ========================================= File [changed]: RowSetCache.cxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/api/RowSetCache.cxx?r1=1.78&r2=1.78.16.1 Delta lines: +51 -7 -------------------- --- RowSetCache.cxx 23 Sep 2005 12:03:25 -0000 1.78 +++ RowSetCache.cxx 30 Dec 2005 06:20:20 -0000 1.78.16.1 @@ -4,9 +4,9 @@ * * $RCSfile: RowSetCache.cxx,v $ * - * $Revision: 1.78 $ + * $Revision: 1.78.16.1 $ * - * last change: $Author: hr $ $Date: 2005/09/23 12:03:25 $ + * last change: $Author: oj $ $Date: 2005/12/30 06:20:20 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -99,6 +99,9 @@ #ifndef _CONNECTIVITY_SQLNODE_HXX #include <connectivity/sqlnode.hxx> #endif +#ifndef _CONNECTIVITY_PARSE_SQLITERATOR_HXX_ +#include <connectivity/sqliterator.hxx> +#endif #ifndef _COMPHELPER_PROPERTY_HXX_ #include <comphelper/property.hxx> #endif @@ -1624,6 +1627,43 @@ if(m_bAfterLast || columnIndex >= (sal_Int32)(*m_aInsertRow)->size()) throwFunctionSequenceException(m_xSet.get()); } +//------------------------------------------------------------------------------ +sal_Bool ORowSetCache::checkInnerJoin(const ::connectivity::OSQLParseNode *pNode,const Reference< XConnection>& _xConnection,const ::rtl::OUString& _sUpdateTableName) +{ + sal_Bool bOk = sal_False; + if (pNode->count() == 3 && // Ausdruck is geklammert + SQL_ISPUNCTUATION(pNode->getChild(0),"(") && + SQL_ISPUNCTUATION(pNode->getChild(2),")")) + { + bOk = checkInnerJoin(pNode->getChild(1),_xConnection,_sUpdateTableName); + } + else if ((SQL_ISRULE(pNode,search_condition) || SQL_ISRULE(pNode,boolean_term)) && // AND/OR-Verknuepfung: + pNode->count() == 3) + { + // nur AND Verknüpfung zulassen + if ( SQL_ISTOKEN(pNode->getChild(1),AND) && (bOk = checkInnerJoin(pNode->getChild(0),_xConnection,_sUpdateTableName)) ) + bOk = checkInnerJoin(pNode->getChild(2),_xConnection,_sUpdateTableName); + } + else if (SQL_ISRULE(pNode,comparison_predicate)) + { + // only the comparison of columns is allowed + DBG_ASSERT(pNode->count() == 3,"checkInnerJoin: Fehler im Parse Tree"); + if (!(SQL_ISRULE(pNode->getChild(0),column_ref) && + SQL_ISRULE(pNode->getChild(2),column_ref) && + pNode->getChild(1)->getNodeType() == SQL_NODE_EQUAL)) + { + bOk = sal_False; + } + ::rtl::OUString sColumnName,sTableRange; + OSQLParseTreeIterator::getColumnRange(pNode->getChild(0),_xConnection->getMetaData(),sColumnName,sTableRange); + if ( !(bOk = sTableRange == _sUpdateTableName) ) + { + OSQLParseTreeIterator::getColumnRange(pNode->getChild(2),_xConnection->getMetaData(),sColumnName,sTableRange); + bOk = sTableRange == _sUpdateTableName; + } + } + return bOk; +} // ----------------------------------------------------------------------------- sal_Bool ORowSetCache::checkJoin(const Reference< XConnection>& _xConnection, const Reference< XSingleSelectQueryAnalyzer >& _xAnalyzer, @@ -1633,8 +1673,8 @@ ::rtl::OUString sSql = _xAnalyzer->getQuery(); ::rtl::OUString sErrorMsg; ::connectivity::OSQLParser aSqlParser(m_xServiceFactory); - ::connectivity::OSQLParseNode* pSqlParseNode = aSqlParser.parseTree(sErrorMsg,sSql); - if(pSqlParseNode) + ::std::auto_ptr< ::connectivity::OSQLParseNode> pSqlParseNode( aSqlParser.parseTree(sErrorMsg,sSql)); + if ( pSqlParseNode.get() && SQL_ISRULE(pSqlParseNode, select_statement) ) { OSQLParseNode* pTableRefCommalist = pSqlParseNode->getByRule(::connectivity::OSQLParseNode::table_ref_commalist); OSL_ENSURE(pTableRefCommalist,"NO tables why!?"); @@ -1676,9 +1716,13 @@ bOk = sTableRange == _sUpdateTableName; } } - } - delete pSqlParseNode; + else + { + OSQLParseNode* pWhereOpt = pSqlParseNode->getChild(3)->getChild(1); + if ( pWhereOpt && !pWhereOpt->isLeaf() ) + bOk = checkInnerJoin(pWhereOpt->getChild(1),_xConnection,_sUpdateTableName); + } } return bOk; } File [changed]: RowSetCache.hxx Url: http://dba.openoffice.org/source/browse/dba/dbaccess/source/core/api/RowSetCache.hxx?r1=1.25&r2=1.25.14.1 Delta lines: +10 -3 -------------------- --- RowSetCache.hxx 8 Sep 2005 10:01:59 -0000 1.25 +++ RowSetCache.hxx 30 Dec 2005 06:20:21 -0000 1.25.14.1 @@ -4,9 +4,9 @@ * * $RCSfile: RowSetCache.hxx,v $ * - * $Revision: 1.25 $ + * $Revision: 1.25.14.1 $ * - * last change: $Author: rt $ $Date: 2005/09/08 10:01:59 $ + * last change: $Author: oj $ $Date: 2005/12/30 06:20:21 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -105,6 +105,10 @@ #include "RowSetCacheIterator.hxx" #endif +namespace connectivity +{ + class OSQLParseNode; +} namespace dbaccess { class OCacheSet; @@ -180,6 +184,9 @@ sal_Bool checkJoin( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection, const ::com::sun::star::uno::Reference< ::com::sun::star::sdb::XSingleSelectQueryAnalyzer >& _xComposer, const ::rtl::OUString& _sUpdateTableName); + sal_Bool checkInnerJoin(const ::connectivity::OSQLParseNode *pNode + ,const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection>& _xConnection + ,const ::rtl::OUString& _sUpdateTableName); // clears the insert row void clearInsertRow(); --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
