xref: /trunk/main/connectivity/inc/connectivity/sqliterator.hxx (revision cdf0e10c4e3984b49a9502b011690b615761d4a3)
1*cdf0e10cSrcweir /*************************************************************************
2*cdf0e10cSrcweir  *
3*cdf0e10cSrcweir  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4*cdf0e10cSrcweir  *
5*cdf0e10cSrcweir  * Copyright 2000, 2010 Oracle and/or its affiliates.
6*cdf0e10cSrcweir  *
7*cdf0e10cSrcweir  * OpenOffice.org - a multi-platform office productivity suite
8*cdf0e10cSrcweir  *
9*cdf0e10cSrcweir  * This file is part of OpenOffice.org.
10*cdf0e10cSrcweir  *
11*cdf0e10cSrcweir  * OpenOffice.org is free software: you can redistribute it and/or modify
12*cdf0e10cSrcweir  * it under the terms of the GNU Lesser General Public License version 3
13*cdf0e10cSrcweir  * only, as published by the Free Software Foundation.
14*cdf0e10cSrcweir  *
15*cdf0e10cSrcweir  * OpenOffice.org is distributed in the hope that it will be useful,
16*cdf0e10cSrcweir  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17*cdf0e10cSrcweir  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18*cdf0e10cSrcweir  * GNU Lesser General Public License version 3 for more details
19*cdf0e10cSrcweir  * (a copy is included in the LICENSE file that accompanied this code).
20*cdf0e10cSrcweir  *
21*cdf0e10cSrcweir  * You should have received a copy of the GNU Lesser General Public License
22*cdf0e10cSrcweir  * version 3 along with OpenOffice.org.  If not, see
23*cdf0e10cSrcweir  * <http://www.openoffice.org/license.html>
24*cdf0e10cSrcweir  * for a copy of the LGPLv3 License.
25*cdf0e10cSrcweir  *
26*cdf0e10cSrcweir  ************************************************************************/
27*cdf0e10cSrcweir #ifndef _CONNECTIVITY_PARSE_SQLITERATOR_HXX_
28*cdf0e10cSrcweir #define _CONNECTIVITY_PARSE_SQLITERATOR_HXX_
29*cdf0e10cSrcweir 
30*cdf0e10cSrcweir #include "connectivity/dbtoolsdllapi.hxx"
31*cdf0e10cSrcweir #include "connectivity/sqlnode.hxx"
32*cdf0e10cSrcweir #include <connectivity/IParseContext.hxx>
33*cdf0e10cSrcweir #include <com/sun/star/sdbcx/XColumnsSupplier.hpp>
34*cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp>
35*cdf0e10cSrcweir #include <com/sun/star/sdbc/SQLWarning.hpp>
36*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
37*cdf0e10cSrcweir #include "connectivity/CommonTools.hxx"
38*cdf0e10cSrcweir #include <vos/ref.hxx>
39*cdf0e10cSrcweir #include <cppuhelper/weak.hxx>
40*cdf0e10cSrcweir 
41*cdf0e10cSrcweir #include <map>
42*cdf0e10cSrcweir #include <memory>
43*cdf0e10cSrcweir #include <vector>
44*cdf0e10cSrcweir 
45*cdf0e10cSrcweir namespace connectivity
46*cdf0e10cSrcweir {
47*cdf0e10cSrcweir 
48*cdf0e10cSrcweir     class OSQLParseNode;
49*cdf0e10cSrcweir     class OSQLParser;
50*cdf0e10cSrcweir 
51*cdf0e10cSrcweir     typedef ::std::pair<const OSQLParseNode*,const OSQLParseNode* > TNodePair;
52*cdf0e10cSrcweir 
53*cdf0e10cSrcweir     enum OSQLStatementType {
54*cdf0e10cSrcweir         SQL_STATEMENT_UNKNOWN,
55*cdf0e10cSrcweir         SQL_STATEMENT_SELECT,
56*cdf0e10cSrcweir         SQL_STATEMENT_INSERT,
57*cdf0e10cSrcweir         SQL_STATEMENT_UPDATE,
58*cdf0e10cSrcweir         SQL_STATEMENT_DELETE,
59*cdf0e10cSrcweir         SQL_STATEMENT_ODBC_CALL,
60*cdf0e10cSrcweir         SQL_STATEMENT_CREATE_TABLE
61*cdf0e10cSrcweir     };
62*cdf0e10cSrcweir 
63*cdf0e10cSrcweir     struct OSQLParseTreeIteratorImpl;
64*cdf0e10cSrcweir 
65*cdf0e10cSrcweir     class OOO_DLLPUBLIC_DBTOOLS OSQLParseTreeIterator
66*cdf0e10cSrcweir     {
67*cdf0e10cSrcweir     private:
68*cdf0e10cSrcweir         ::com::sun::star::sdbc::SQLException            m_aErrors;          // conatins the error while iterating through the statement
69*cdf0e10cSrcweir         const OSQLParseNode*                            m_pParseTree;       // aktueller ParseTree
70*cdf0e10cSrcweir         const OSQLParser&                               m_rParser;          // if set used for general error messages from the context
71*cdf0e10cSrcweir         OSQLStatementType                               m_eStatementType;   // Art des Statements
72*cdf0e10cSrcweir         ::vos::ORef<OSQLColumns>                        m_aSelectColumns;   // alle Spalten aus dem Select-Clause
73*cdf0e10cSrcweir         ::vos::ORef<OSQLColumns>                        m_aParameters;      // all parameters
74*cdf0e10cSrcweir         ::vos::ORef<OSQLColumns>                        m_aGroupColumns;    // the group by columns
75*cdf0e10cSrcweir         ::vos::ORef<OSQLColumns>                        m_aOrderColumns;    // the order by columns
76*cdf0e10cSrcweir         ::vos::ORef<OSQLColumns>                        m_aCreateColumns;   // the columns for Create table clause
77*cdf0e10cSrcweir 
78*cdf0e10cSrcweir         ::std::auto_ptr< OSQLParseTreeIteratorImpl >    m_pImpl;
79*cdf0e10cSrcweir 
80*cdf0e10cSrcweir         void                traverseParameter(const OSQLParseNode* _pParseNode,const OSQLParseNode* _pColumnRef,const ::rtl::OUString& _aColumnName,const ::rtl::OUString& _aTableRange, const ::rtl::OUString& _rColumnAlias);
81*cdf0e10cSrcweir         // F"ugt eine Tabelle in die Map ein
82*cdf0e10cSrcweir         void                traverseOneTableName( OSQLTables& _rTables,const OSQLParseNode * pTableName, const ::rtl::OUString & rTableRange );
83*cdf0e10cSrcweir         void                traverseORCriteria(OSQLParseNode * pSearchCondition);
84*cdf0e10cSrcweir         void                traverseANDCriteria(OSQLParseNode * pSearchCondition);
85*cdf0e10cSrcweir         void                traverseOnePredicate(
86*cdf0e10cSrcweir                                                 OSQLParseNode * pColumnRef,
87*cdf0e10cSrcweir                                                 ::rtl::OUString& aValue,
88*cdf0e10cSrcweir                                                 OSQLParseNode * pParameter);
89*cdf0e10cSrcweir         void traverseByColumnNames(const OSQLParseNode* pSelectNode,sal_Bool _bOrder);
90*cdf0e10cSrcweir         void                traverseParameters(const OSQLParseNode* pSelectNode);
91*cdf0e10cSrcweir 
92*cdf0e10cSrcweir         const OSQLParseNode*    getTableNode( OSQLTables& _rTables, const OSQLParseNode* pTableRef, ::rtl::OUString& aTableRange );
93*cdf0e10cSrcweir         void                    getQualified_join( OSQLTables& _rTables, const OSQLParseNode *pTableRef, ::rtl::OUString& aTableRange );
94*cdf0e10cSrcweir         void                    getSelect_statement(OSQLTables& _rTables,const OSQLParseNode* pSelect);
95*cdf0e10cSrcweir         ::rtl::OUString         getUniqueColumnName(const ::rtl::OUString & rColumnName)    const;
96*cdf0e10cSrcweir 
97*cdf0e10cSrcweir         /** finds the column with a given name, belonging to a given table, in a given tables collection
98*cdf0e10cSrcweir             @param  _rTables
99*cdf0e10cSrcweir                 the tables collection to look in
100*cdf0e10cSrcweir             @param  rColumnName
101*cdf0e10cSrcweir                 the column name to look for
102*cdf0e10cSrcweir             @param  rTableRange
103*cdf0e10cSrcweir                 the table alias name
104*cdf0e10cSrcweir             @return
105*cdf0e10cSrcweir                 the desired column object, or <NULL/> if no such column could be found
106*cdf0e10cSrcweir         */
107*cdf0e10cSrcweir         static ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > findColumn(
108*cdf0e10cSrcweir             const OSQLTables& _rTables, const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange );
109*cdf0e10cSrcweir 
110*cdf0e10cSrcweir         /** finds a column with a given name, belonging to a given table
111*cdf0e10cSrcweir             @param  rColumnName
112*cdf0e10cSrcweir                 the column name to look for
113*cdf0e10cSrcweir             @param  rTableRange
114*cdf0e10cSrcweir                     the table alias name
115*cdf0e10cSrcweir             @param  _bLookInSubTables
116*cdf0e10cSrcweir                 <TRUE/> if and only if not only our direct tables, but also our sub tables (from sub selects)
117*cdf0e10cSrcweir                 should be searched
118*cdf0e10cSrcweir             @return
119*cdf0e10cSrcweir         */
120*cdf0e10cSrcweir         ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > findColumn(
121*cdf0e10cSrcweir             const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange, bool _bLookInSubTables );
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir       protected:
124*cdf0e10cSrcweir         void setSelectColumnName(::vos::ORef<OSQLColumns>& _rColumns,const ::rtl::OUString & rColumnName,const ::rtl::OUString & rColumnAlias, const ::rtl::OUString & rTableRange,sal_Bool bFkt=sal_False,sal_Int32 _nType = com::sun::star::sdbc::DataType::VARCHAR,sal_Bool bAggFkt=sal_False);
125*cdf0e10cSrcweir         void appendColumns(::vos::ORef<OSQLColumns>& _rColumns,const ::rtl::OUString& _rTableAlias,const OSQLTable& _rTable);
126*cdf0e10cSrcweir         // Weitere Member-Variable, die in den "set"-Funktionen zur
127*cdf0e10cSrcweir         // Verfuegung stehen sollen, koennen in der abgeleiteten Klasse
128*cdf0e10cSrcweir         // definiert werden und z. B. in deren Konstruktor initialisiert
129*cdf0e10cSrcweir         // bzw. nach Benutzung der "traverse"-Routinen mit Hilfe weiterer
130*cdf0e10cSrcweir         // Funktionen abgefragt werden.
131*cdf0e10cSrcweir 
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir       private:
134*cdf0e10cSrcweir         OSQLParseTreeIterator();                                        // never implemented
135*cdf0e10cSrcweir         OSQLParseTreeIterator(const OSQLParseTreeIterator & rIter);     // never implemented
136*cdf0e10cSrcweir 
137*cdf0e10cSrcweir       public:
138*cdf0e10cSrcweir         OSQLParseTreeIterator(
139*cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
140*cdf0e10cSrcweir             const ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess >& _rxTables,
141*cdf0e10cSrcweir             const OSQLParser& _rParser,
142*cdf0e10cSrcweir             const OSQLParseNode* pRoot = NULL );
143*cdf0e10cSrcweir         ~OSQLParseTreeIterator();
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir         inline static void * SAL_CALL operator new( size_t nSize ) SAL_THROW( () )
146*cdf0e10cSrcweir             { return ::rtl_allocateMemory( nSize ); }
147*cdf0e10cSrcweir         inline static void * SAL_CALL operator new( size_t,void* _pHint ) SAL_THROW( () )
148*cdf0e10cSrcweir             { return _pHint; }
149*cdf0e10cSrcweir         inline static void SAL_CALL operator delete( void * pMem ) SAL_THROW( () )
150*cdf0e10cSrcweir             { ::rtl_freeMemory( pMem ); }
151*cdf0e10cSrcweir         inline static void SAL_CALL operator delete( void *,void* ) SAL_THROW( () )
152*cdf0e10cSrcweir             {  }
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir         void dispose();
155*cdf0e10cSrcweir         bool isCaseSensitive() const;
156*cdf0e10cSrcweir         // Der zu analysierende/zu traversierende Parse Tree:
157*cdf0e10cSrcweir         // bei "Ubergabe von NULL wird der aktuelle Parsetree gel"oscht und der Fehlerstatus gecleared
158*cdf0e10cSrcweir         void setParseTree(const OSQLParseNode * pNewParseTree);
159*cdf0e10cSrcweir //      void setParser(const OSQLParser* _pParser) { m_pParser = _pParser; }
160*cdf0e10cSrcweir         const OSQLParseNode * getParseTree() const { return m_pParseTree; };
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir         // Teilbaueme bei einem select statement
163*cdf0e10cSrcweir         const OSQLParseNode* getWhereTree() const;
164*cdf0e10cSrcweir         const OSQLParseNode* getOrderTree() const;
165*cdf0e10cSrcweir         const OSQLParseNode* getGroupByTree() const;
166*cdf0e10cSrcweir         const OSQLParseNode* getHavingTree() const;
167*cdf0e10cSrcweir 
168*cdf0e10cSrcweir         const OSQLParseNode* getSimpleWhereTree() const;
169*cdf0e10cSrcweir         const OSQLParseNode* getSimpleOrderTree() const;
170*cdf0e10cSrcweir         const OSQLParseNode* getSimpleGroupByTree() const;
171*cdf0e10cSrcweir         const OSQLParseNode* getSimpleHavingTree() const;
172*cdf0e10cSrcweir 
173*cdf0e10cSrcweir         /** returns the errors which occured during parsing.
174*cdf0e10cSrcweir 
175*cdf0e10cSrcweir             The returned object contains a chain (via SQLException::NextException) of SQLExceptions.
176*cdf0e10cSrcweir         */
177*cdf0e10cSrcweir         inline const ::com::sun::star::sdbc::SQLException&   getErrors() const { return m_aErrors; }
178*cdf0e10cSrcweir         inline bool hasErrors() const { return m_aErrors.Message.getLength() > 0; }
179*cdf0e10cSrcweir 
180*cdf0e10cSrcweir         // Statement-Typ (wird bereits in setParseTree gesetzt):
181*cdf0e10cSrcweir         OSQLStatementType getStatementType() const { return m_eStatementType; }
182*cdf0e10cSrcweir 
183*cdf0e10cSrcweir         /** traverses the complete statement tree, and fills all our data with
184*cdf0e10cSrcweir             the information obatined during traversal.
185*cdf0e10cSrcweir 
186*cdf0e10cSrcweir             Implemented by calling the single traverse* methods in the proper
187*cdf0e10cSrcweir             order (depending on the statement type).
188*cdf0e10cSrcweir         */
189*cdf0e10cSrcweir         void traverseAll();
190*cdf0e10cSrcweir 
191*cdf0e10cSrcweir         enum TraversalParts
192*cdf0e10cSrcweir         {
193*cdf0e10cSrcweir             Parameters      = 0x0001,
194*cdf0e10cSrcweir             TableNames      = 0x0002,
195*cdf0e10cSrcweir             SelectColumns   = 0x0006,   // note that this includes TableNames. No SelectColumns without TableNames
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir             // Those are not implemented currently
198*cdf0e10cSrcweir             // GroupColumns    = 0x0008,
199*cdf0e10cSrcweir             // OrderColumns    = 0x0010,
200*cdf0e10cSrcweir             // SelectColumns   = 0x0020,
201*cdf0e10cSrcweir             // CreateColumns   = 0x0040,
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir             All             = 0xFFFF
204*cdf0e10cSrcweir         };
205*cdf0e10cSrcweir         /** traverses selected parts of the statement tree, and fills our data with
206*cdf0e10cSrcweir             the information obtained during traversal
207*cdf0e10cSrcweir 
208*cdf0e10cSrcweir             @param _nIncludeMask
209*cdf0e10cSrcweir                 set of TraversalParts bits, specifying which information is to be collected.
210*cdf0e10cSrcweir                 Note TraversalParts is currently not
211*cdf0e10cSrcweir         */
212*cdf0e10cSrcweir         void traverseSome( sal_uInt32 _nIncludeMask );
213*cdf0e10cSrcweir 
214*cdf0e10cSrcweir         // Die TableRangeMap enth"alt alle Tabellen unter dem zugeh"origen Rangenamen der zuerst gefunden wird
215*cdf0e10cSrcweir         const OSQLTables& getTables() const;
216*cdf0e10cSrcweir 
217*cdf0e10cSrcweir         ::vos::ORef<OSQLColumns> getSelectColumns() const { return m_aSelectColumns;}
218*cdf0e10cSrcweir         ::vos::ORef<OSQLColumns> getGroupColumns() const { return m_aGroupColumns;}
219*cdf0e10cSrcweir         ::vos::ORef<OSQLColumns> getOrderColumns() const { return m_aOrderColumns;}
220*cdf0e10cSrcweir         ::vos::ORef<OSQLColumns> getParameters()    const { return m_aParameters; }
221*cdf0e10cSrcweir         ::vos::ORef<OSQLColumns> getCreateColumns() const { return m_aCreateColumns;}
222*cdf0e10cSrcweir 
223*cdf0e10cSrcweir         /** return the columname and the table range
224*cdf0e10cSrcweir             @param  _pColumnRef
225*cdf0e10cSrcweir                 The column ref parse node.
226*cdf0e10cSrcweir             @param  _rColumnName
227*cdf0e10cSrcweir                 The column name to be set.
228*cdf0e10cSrcweir             @param  _rTableRange
229*cdf0e10cSrcweir                 The table range to be set.
230*cdf0e10cSrcweir         */
231*cdf0e10cSrcweir         void getColumnRange(    const OSQLParseNode* _pColumnRef,
232*cdf0e10cSrcweir                                 ::rtl::OUString &_rColumnName,
233*cdf0e10cSrcweir                                 ::rtl::OUString& _rTableRange) const;
234*cdf0e10cSrcweir 
235*cdf0e10cSrcweir         /** retrieves a column's name, table range, and alias
236*cdf0e10cSrcweir 
237*cdf0e10cSrcweir             @param  _pColumnRef
238*cdf0e10cSrcweir                 The column_ref parse node.
239*cdf0e10cSrcweir             @param  _out_rColumnName
240*cdf0e10cSrcweir                 The column name to be set.
241*cdf0e10cSrcweir             @param  _out_rTableRange
242*cdf0e10cSrcweir                 The table range to be set.
243*cdf0e10cSrcweir             @param _out_rColumnAliasIfPresent
244*cdf0e10cSrcweir                 If the column specified by _pColumnRef is part of the select columns, and contains a column alias there,
245*cdf0e10cSrcweir                 this alias is returned here.
246*cdf0e10cSrcweir         */
247*cdf0e10cSrcweir         void getColumnRange(    const OSQLParseNode* _pColumnRef,
248*cdf0e10cSrcweir                                 ::rtl::OUString& _out_rColumnName,
249*cdf0e10cSrcweir                                 ::rtl::OUString& _out_rTableRange,
250*cdf0e10cSrcweir                                 ::rtl::OUString& _out_rColumnAliasIfPresent
251*cdf0e10cSrcweir                                 ) const;
252*cdf0e10cSrcweir 
253*cdf0e10cSrcweir         /** return the alias name of a column
254*cdf0e10cSrcweir             @param  _pDerivedColumn
255*cdf0e10cSrcweir                 The parse node where SQL_ISRULE(_pDerivedColumn,derived_column) must be true
256*cdf0e10cSrcweir             @return
257*cdf0e10cSrcweir                 The alias name of the column or an empty string.
258*cdf0e10cSrcweir         */
259*cdf0e10cSrcweir         static ::rtl::OUString getColumnAlias(const OSQLParseNode* _pDerivedColumn);
260*cdf0e10cSrcweir 
261*cdf0e10cSrcweir         /** return the columname and the table range
262*cdf0e10cSrcweir             @param  _pColumnRef
263*cdf0e10cSrcweir                 The column ref parse node.
264*cdf0e10cSrcweir             @param  _xMetaData
265*cdf0e10cSrcweir                 The database meta data.
266*cdf0e10cSrcweir             @param  _rColumnName
267*cdf0e10cSrcweir                 The column name to be set.
268*cdf0e10cSrcweir             @param  _rTableRange
269*cdf0e10cSrcweir                 The table range to be set.
270*cdf0e10cSrcweir         */
271*cdf0e10cSrcweir         static void getColumnRange( const OSQLParseNode* _pColumnRef,
272*cdf0e10cSrcweir                                     const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XConnection >& _rxConnection,
273*cdf0e10cSrcweir                                     ::rtl::OUString &_rColumnName,
274*cdf0e10cSrcweir                                     ::rtl::OUString& _rTableRange);
275*cdf0e10cSrcweir 
276*cdf0e10cSrcweir         // Ermittelt fuer eine Funktion, Spalten den zugehoeren TableRange,
277*cdf0e10cSrcweir         // wenn nicht eindeutig, dann leer
278*cdf0e10cSrcweir         sal_Bool getColumnTableRange(const OSQLParseNode* pNode, ::rtl::OUString &rTableRange) const;
279*cdf0e10cSrcweir 
280*cdf0e10cSrcweir         // return true when the tableNode is a rule like catalog_name, schema_name or table_name
281*cdf0e10cSrcweir         sal_Bool isTableNode(const OSQLParseNode* _pTableNode) const;
282*cdf0e10cSrcweir 
283*cdf0e10cSrcweir         // tries to find the correct type of the function
284*cdf0e10cSrcweir         sal_Int32 getFunctionReturnType(const OSQLParseNode* _pNode );
285*cdf0e10cSrcweir 
286*cdf0e10cSrcweir         // returns a lis of all joined columns
287*cdf0e10cSrcweir         ::std::vector< TNodePair >& getJoinConditions() const;
288*cdf0e10cSrcweir 
289*cdf0e10cSrcweir     private:
290*cdf0e10cSrcweir         /** traverses the list of table names, and filles _rTables
291*cdf0e10cSrcweir         */
292*cdf0e10cSrcweir         bool traverseTableNames( OSQLTables& _rTables );
293*cdf0e10cSrcweir 
294*cdf0e10cSrcweir         /// traverses columns in a SELECT statement
295*cdf0e10cSrcweir         bool traverseSelectColumnNames(const OSQLParseNode* pSelectNode);
296*cdf0e10cSrcweir         /// traverses columns in a CREATE TABLE statement
297*cdf0e10cSrcweir         void traverseCreateColumns(const OSQLParseNode* pSelectNode);
298*cdf0e10cSrcweir 
299*cdf0e10cSrcweir         bool traverseOrderByColumnNames(const OSQLParseNode* pSelectNode);
300*cdf0e10cSrcweir         bool traverseGroupByColumnNames(const OSQLParseNode* pSelectNode);
301*cdf0e10cSrcweir 
302*cdf0e10cSrcweir         bool traverseSelectionCriteria(const OSQLParseNode* pSelectNode);
303*cdf0e10cSrcweir 
304*cdf0e10cSrcweir     private:
305*cdf0e10cSrcweir         /** constructs a new iterator, which inherits some of the settings from a parent iterator
306*cdf0e10cSrcweir         */
307*cdf0e10cSrcweir         OSQLParseTreeIterator(
308*cdf0e10cSrcweir             const OSQLParseTreeIterator& _rParentIterator,
309*cdf0e10cSrcweir             const OSQLParser& _rParser,
310*cdf0e10cSrcweir             const OSQLParseNode* pRoot );
311*cdf0e10cSrcweir 
312*cdf0e10cSrcweir         /** creates a table object and inserts it into our tables collection
313*cdf0e10cSrcweir 
314*cdf0e10cSrcweir             only used when we're iterating through a CREATE TABLE statement
315*cdf0e10cSrcweir         */
316*cdf0e10cSrcweir         OSQLTable   impl_createTableObject(
317*cdf0e10cSrcweir             const ::rtl::OUString& rTableName, const ::rtl::OUString& rCatalogName, const ::rtl::OUString& rSchemaName );
318*cdf0e10cSrcweir 
319*cdf0e10cSrcweir         /** locates a record source (a table or query) with the given name
320*cdf0e10cSrcweir         */
321*cdf0e10cSrcweir         OSQLTable   impl_locateRecordSource(
322*cdf0e10cSrcweir             const ::rtl::OUString& _rComposedName
323*cdf0e10cSrcweir         );
324*cdf0e10cSrcweir 
325*cdf0e10cSrcweir         /** implementation for both traverseAll and traverseSome
326*cdf0e10cSrcweir         */
327*cdf0e10cSrcweir         void    impl_traverse( sal_uInt32 _nIncludeMask );
328*cdf0e10cSrcweir 
329*cdf0e10cSrcweir         /** retrieves the parameter columns of the given query
330*cdf0e10cSrcweir         */
331*cdf0e10cSrcweir         void    impl_getQueryParameterColumns( const OSQLTable& _rQuery );
332*cdf0e10cSrcweir 
333*cdf0e10cSrcweir         void setOrderByColumnName(const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange, sal_Bool bAscending);
334*cdf0e10cSrcweir         void setGroupByColumnName(const ::rtl::OUString & rColumnName, const ::rtl::OUString & rTableRange);
335*cdf0e10cSrcweir 
336*cdf0e10cSrcweir     private:
337*cdf0e10cSrcweir         /** appends an SQLException corresponding to the given error code to our error collection
338*cdf0e10cSrcweir 
339*cdf0e10cSrcweir             @param  _eError
340*cdf0e10cSrcweir                 the code of the error which occured
341*cdf0e10cSrcweir             @param  _pReplaceToken1
342*cdf0e10cSrcweir                 if not <NULL/>, the first occurance of '#' in the error message will be replaced
343*cdf0e10cSrcweir                 with the given token
344*cdf0e10cSrcweir             @param  _pReplaceToken2
345*cdf0e10cSrcweir                 if not <NULL/>, and if _rReplaceToken1 is not <NULL/>, the second occurance of '#'
346*cdf0e10cSrcweir                 in the error message will be replaced with _rReplaceToken2
347*cdf0e10cSrcweir         */
348*cdf0e10cSrcweir         void impl_appendError( IParseContext::ErrorCode _eError,
349*cdf0e10cSrcweir             const ::rtl::OUString* _pReplaceToken1 = NULL, const ::rtl::OUString* _pReplaceToken2 = NULL );
350*cdf0e10cSrcweir 
351*cdf0e10cSrcweir         /** appends an SQLException corresponding to the given error code to our error collection
352*cdf0e10cSrcweir         */
353*cdf0e10cSrcweir         void impl_appendError( const ::com::sun::star::sdbc::SQLException& _rError );
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir         /** resets our errors
356*cdf0e10cSrcweir         */
357*cdf0e10cSrcweir         inline void impl_resetErrors()
358*cdf0e10cSrcweir         {
359*cdf0e10cSrcweir             m_aErrors = ::com::sun::star::sdbc::SQLException();
360*cdf0e10cSrcweir         }
361*cdf0e10cSrcweir         void impl_fillJoinConditions(const OSQLParseNode* i_pJoinCondition);
362*cdf0e10cSrcweir     };
363*cdf0e10cSrcweir }
364*cdf0e10cSrcweir 
365*cdf0e10cSrcweir #endif // _CONNECTIVITY_PARSE_SQLITERATOR_HXX_
366*cdf0e10cSrcweir 
367