Tag: cws_dev300_rptchart02
User: oj      
Date: 2008-05-23 08:26:46+0000
Modified:
   dba/connectivity/inc/connectivity/sqliterator.hxx
   dba/connectivity/inc/connectivity/sqlnode.hxx
   dba/connectivity/source/drivers/evoab2/NStatement.cxx
   dba/connectivity/source/parse/sqlbison.y
   dba/connectivity/source/parse/sqliterator.cxx
   dba/connectivity/source/parse/sqlnode.cxx

Log:
 #i84290# change sql rule table_ref

File Changes:

Directory: /dba/connectivity/inc/connectivity/
==============================================

File [changed]: sqliterator.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/inc/connectivity/sqliterator.hxx?r1=1.24&r2=1.24.18.1
Delta lines:  +2 -3
-------------------
--- sqliterator.hxx     2008-04-10 07:39:53+0000        1.24
+++ sqliterator.hxx     2008-05-23 08:26:42+0000        1.24.18.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: sqliterator.hxx,v $
- * $Revision: 1.24 $
+ * $Revision: 1.24.18.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -277,7 +277,6 @@
 
                // return true when the tableNode is a rule like catalog_name, 
schema_name or table_name
                sal_Bool isTableNode(const OSQLParseNode* _pTableNode) const;
-
     private:
         /** traverses the list of table names, and filles _rTables
         */

File [changed]: sqlnode.hxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/inc/connectivity/sqlnode.hxx?r1=1.22&r2=1.22.18.1
Delta lines:  +7 -3
-------------------
--- sqlnode.hxx 2008-04-10 07:40:40+0000        1.22
+++ sqlnode.hxx 2008-05-23 08:26:42+0000        1.22.18.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: sqlnode.hxx,v $
- * $Revision: 1.22 $
+ * $Revision: 1.22.18.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -192,7 +192,6 @@
                        all_or_any_predicate,
                        named_columns_join,
                        join_condition,
-                       joined_table,
                        boolean_factor,
                        sql_not,
                        boolean_test,
@@ -217,6 +216,7 @@
             table_node,
             as,
             op_column_commalist,
+            table_primary_as_range_column,
             rule_count,             // letzter_wert
             UNKNOWN_RULE            // ID indicating that a node is no rule 
with a matching Rule-enum value (see getKnownRuleID)
                };
@@ -401,6 +401,10 @@
                // _pNode will be modified if parameters exists
                static void substituteParameterNames(OSQLParseNode* _pNode);
 
+        /** return a table range when it exists.
+        */
+        static ::rtl::OUString getTableRange(const OSQLParseNode* _pTableRef);
+
        protected:
                // ParseNodeToStr konkateniert alle Token (Blaetter) des 
ParseNodes
                void parseNodeToStr(::rtl::OUString& rString,

Directory: /dba/connectivity/source/drivers/evoab2/
===================================================

File [changed]: NStatement.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/drivers/evoab2/NStatement.cxx?r1=1.10&r2=1.10.18.1
Delta lines:  +4 -5
-------------------
--- NStatement.cxx      2008-04-10 08:54:38+0000        1.10
+++ NStatement.cxx      2008-05-23 08:26:42+0000        1.10.18.1
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: NStatement.cxx,v $
- * $Revision: 1.10 $
+ * $Revision: 1.10.18.1 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -403,9 +403,8 @@
                        OSQLParseNode *pNodeForTableName = 
pAllTableNames->getChild( 0 )->getChild( 0 );
                        if( m_aSQLIterator.isTableNode( pNodeForTableName ) )
                        {
-                               if( pAllTableNames->getChild( 0 )->count() == 4 
)
-                                       aTableName = pAllTableNames->getChild( 
0 )->getChild( 2 )->getTokenValue();
-                               else
+                aTableName = getTableRange(pAllTableNames->getChild( 0 ));
+                               if( !aTableName.getLength() )
                                OSQLParseNode::getTableComponents( 
pNodeForTableName, aCatalog, aSchema, aTableName);
                        }
                        else

Directory: /dba/connectivity/source/parse/
==========================================

File [changed]: sqlbison.y
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/parse/sqlbison.y?r1=1.63.18.1&r2=1.63.18.2
Delta lines:  +32 -44
---------------------
--- sqlbison.y  2008-05-20 08:29:11+0000        1.63.18.1
+++ sqlbison.y  2008-05-23 08:26:43+0000        1.63.18.2
@@ -9,7 +9,7 @@
 //
 // $RCSfile: sqlbison.y,v $
 //
-// $Revision: 1.63.18.1 $
+// $Revision: 1.63.18.2 $
 //
 // This file is part of OpenOffice.org.
 //
@@ -268,11 +268,11 @@
 %type <pParseNode> /*bit_concatenation*/ bit_value_exp bit_factor bit_primary 
collate_clause char_value_fct unique_spec value_exp_commalist 
in_predicate_value unique_test update_source 
 %type <pParseNode> function_arg_commalist3 string_function_3Argument 
function_arg_commalist4 string_function_4Argument function_arg_commalist2 
string_function_1Argument string_function_2Argument
 %type <pParseNode> date_function_0Argument date_function_1Argument 
function_name12 function_name23 function_name1 function_name2 function_name3 
function_name0 numeric_function_0Argument numeric_function_1Argument 
numeric_function_2Argument date_function_3Argument
-%type <pParseNode> all query_primary as sql_not for_length upper_lower 
comparison column_val  cross_union /*opt_schema_element_list*/
+%type <pParseNode> all query_primary sql_not for_length upper_lower comparison 
column_val  cross_union /*opt_schema_element_list*/
 %type <pParseNode> /*op_authorization op_schema*/ nil_fkt schema_element 
base_table_def base_table_element base_table_element_commalist
 %type <pParseNode> column_def odbc_fct_spec    odbc_call_spec odbc_fct_type 
op_parameter union_statement
 %type <pParseNode> op_odbc_call_parameter odbc_parameter_commalist 
odbc_parameter function_args_commalist function_arg
-%type <pParseNode> catalog_name schema_name table_node numeric_function 
string_function function_name date_function
+%type <pParseNode> catalog_name schema_name table_node numeric_function 
string_function function_name date_function table_primary_as_range_column opt_as
 %%
 
 /* Parse Tree an OSQLParser zurueckliefern
@@ -904,12 +904,7 @@
                        $$ = SQL_NEW_RULE;
                        $$->append($1);
                }
-/*      | joined_table
-               {
-                       $$ = SQL_NEW_RULE;
-                       $$->append($1);
-               }
-*/     ;
+    ;
 /* SELECT STATEMENT */
 select_statement:
                SQL_TOKEN_SELECT opt_all_distinct selection table_exp
@@ -953,6 +948,7 @@
        ;
 
 table_ref_commalist:
+
                table_ref
                        {$$ = SQL_NEW_COMMALISTRULE;
                        $$->append($1);}
@@ -960,38 +956,34 @@
                        {$1->append($3);
                        $$ = $1;}
        ;
-as:
-               {$$ = SQL_NEW_RULE;}
+
+opt_as:
+               /* empty */ {$$ = SQL_NEW_RULE;}
        |       SQL_TOKEN_AS
-               {
-                       $$ = SQL_NEW_RULE;
+       ;
+table_primary_as_range_column:
+        {$$ = SQL_NEW_RULE;}
+       |   opt_as SQL_TOKEN_NAME op_column_commalist
+               {$$ = SQL_NEW_RULE;
+                   $$->append($1);
+                   $$->append($2);
+                       $$->append($3);
                }
        ;
 table_ref:
-               table_node
+        table_node table_primary_as_range_column
                {
                        $$ = SQL_NEW_RULE;
                        $$->append($1);
+                       $$->append($2);
                }
-       |       table_node as range_variable op_column_commalist
+       |   subquery range_variable op_column_commalist
                {
                        $$ = SQL_NEW_RULE;
                        $$->append($1);
                        $$->append($2);
                        $$->append($3);
-                       $$->append($4);
-               }
-       |       '(' joined_table ')' as range_variable op_column_commalist
-               {
-                       $$ = SQL_NEW_RULE;
-                       $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
-                       $$->append($2);
-                       $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
-                       $$->append($4);
-                       $$->append($5);
-                       $$->append($6);
                }
-       |       joined_table
        |       '{' SQL_TOKEN_OJ joined_table '}'
                {
                        $$ = SQL_NEW_RULE;
@@ -1000,12 +992,14 @@
                        $$->append($3);
                        $$->append($4 = newNode("}", SQL_NODE_PUNCTUATION));
                }
-       |   subquery as range_variable
+    |  '(' joined_table ')' range_variable op_column_commalist
                {
                        $$ = SQL_NEW_RULE;
-                       $$->append($1);
+                       $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
                        $$->append($2);
-                       $$->append($3);
+                       $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
+                       $$->append($4);
+                       $$->append($5);
                }
        ;
 where_clause:
@@ -2116,15 +2110,6 @@
        ;
 joined_table:
                qualified_join
-/*     |       query_exp*/
-       |       '(' joined_table ')'
-               {
-                       $$ = SQL_NEW_RULE;
-                       $$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
-                       $$->append($2);
-                       $$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
-               }
-
        ;
 named_columns_join:
                SQL_TOKEN_USING '(' column_commalist ')'
@@ -2164,7 +2149,6 @@
        ;
 query_primary:
                non_join_query_primary
-        /*|    joined_table*/
        ;
 non_join_query_exp:
                non_join_query_term
@@ -3092,7 +3076,11 @@
 
 range_variable: 
         {$$ = SQL_NEW_RULE;}
-    |   SQL_TOKEN_NAME
+    |   opt_as SQL_TOKEN_NAME
+        {$$ = SQL_NEW_RULE;
+        $$->append($1);
+        $$->append($2);
+        }
        ;
 
 user:  SQL_TOKEN_NAME

File [changed]: sqliterator.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/parse/sqliterator.cxx?r1=1.57.18.1&r2=1.57.18.2
Delta lines:  +11 -42
---------------------
--- sqliterator.cxx     2008-05-20 08:29:11+0000        1.57.18.1
+++ sqliterator.cxx     2008-05-23 08:26:43+0000        1.57.18.2
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: sqliterator.cxx,v $
- * $Revision: 1.57.18.1 $
+ * $Revision: 1.57.18.2 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -477,7 +477,7 @@
 //-----------------------------------------------------------------------------
 void OSQLParseTreeIterator::getQualified_join( OSQLTables& _rTables, const 
OSQLParseNode *pTableRef, ::rtl::OUString& aTableRange )
 {
-    OSL_PRECOND( SQL_ISRULE( pTableRef, joined_table ) || SQL_ISRULE( 
pTableRef, cross_union ) || SQL_ISRULE( pTableRef, qualified_join ) ,
+    OSL_PRECOND( SQL_ISRULE( pTableRef, cross_union ) || SQL_ISRULE( 
pTableRef, qualified_join ) ,
         "OSQLParseTreeIterator::getQualified_join: illegal node!" );
 
        aTableRange = ::rtl::OUString();
@@ -497,35 +497,23 @@
 //-----------------------------------------------------------------------------
 const OSQLParseNode* OSQLParseTreeIterator::getTableNode( OSQLTables& 
_rTables, const OSQLParseNode *pTableRef,::rtl::OUString& rTableRange )
 {
-    OSL_PRECOND( SQL_ISRULE( pTableRef, table_ref ) || SQL_ISRULE( pTableRef, 
joined_table )
+    OSL_PRECOND( SQL_ISRULE( pTableRef, table_ref )
               || SQL_ISRULE( pTableRef, qualified_join ) || SQL_ISRULE( 
pTableRef, cross_union )
               || SQL_ISRULE( pTableRef, subquery ),
         "OSQLParseTreeIterator::getTableNode: only to be called for table_ref 
nodes!" );
        
        const OSQLParseNode* pTableNameNode = NULL;
 
-    if ( SQL_ISRULE( pTableRef, joined_table ) )
-    {
-        getQualified_join( _rTables, pTableRef->getChild(1), rTableRange );
-    }
-    else if ( SQL_ISRULE( pTableRef, qualified_join ) || SQL_ISRULE( 
pTableRef, cross_union ) )
+    if ( SQL_ISRULE( pTableRef, qualified_join ) || SQL_ISRULE( pTableRef, 
cross_union ) )
     {
         getQualified_join( _rTables, pTableRef, rTableRange );
     }
     else
     {
-        sal_uInt32 nTableRangePos = 0;
-        if ( pTableRef->count() == 4 )
+        rTableRange = OSQLParseNode::getTableRange(pTableRef);
+        if ( pTableRef->count() == 4 || pTableRef->count() == 5 ) // '{' 
SQL_TOKEN_OJ joined_table '}' || '(' joined_table ')' range_variable 
op_column_commalist
         {
-            if ( SQL_ISPUNCTUATION( pTableRef->getChild(0), "{" ) )
-            {   // { OJ joined_table }
-                getQualified_join( _rTables, pTableRef->getChild(2), 
rTableRange );
-            }
-            else
-            {   // table_node as range_variable op_column_commalist
-                pTableNameNode = pTableRef->getChild(0);
-                nTableRangePos = 2;
-            }
+            getQualified_join( _rTables, pTableRef->getChild(6 - 
pTableRef->count()), rTableRange );
         }
         else if ( pTableRef->count() == 3 )
         {   // subquery as range_variable
@@ -535,29 +523,19 @@
             if ( SQL_ISRULE( pQueryExpression, select_statement ) )
             {
                 getSelect_statement( *m_pImpl->m_pSubTables, pQueryExpression 
);
-                nTableRangePos = 2;
             }
             else
             {
                 OSL_ENSURE( false, "OSQLParseTreeIterator::getTableNode: 
subquery which is no select_statement: not yet implemented!" );
             }
         }
-        else if ( pTableRef->count() == 6 )
-        {
-            // '(' joined_table ')' as range_variable op_column_commalist
-            getQualified_join( _rTables, pTableRef->getChild(1), rTableRange );
-            nTableRangePos = 4;
-        }
-        else if ( pTableRef->count() == 1 )
+        else if ( pTableRef->count() == 2 )
         {
             // table_node
             pTableNameNode = pTableRef->getChild(0);
         }
         else
             OSL_ENSURE( false, "OSQLParseTreeIterator::getTableNode: unhandled 
case!" );
-
-        if ( nTableRangePos != 0 && 
pTableRef->getChild(nTableRangePos)->isToken() )
-            rTableRange = pTableRef->getChild(nTableRangePos)->getTokenValue();
     }
 
        return pTableNameNode;
@@ -593,13 +571,7 @@
                        pTableName = pTableListElement->getChild(0);
                        if( isTableNode( pTableName ) )
                        {       // Tabellennamen gefunden
-                               if ( pTableListElement->count() == 4 )
-                {   // table_node as range_variable op_column_commalist
-                    OSL_ENSURE( 
pTableListElement->getChild(1)->getKnownRuleID() == OSQLParseNode::as,
-                        "OSQLParseTreeIterator::getSelect_statement: table_ref 
rules changed?" );
-                    if ( pTableListElement->getChild(2)->isToken() )
-                                           aTableRange = 
pTableListElement->getChild(2)->getTokenValue();
-                }
+                aTableRange = OSQLParseNode::getTableRange(pTableListElement);
                                traverseOneTableName( _rTables, pTableName, 
aTableRange );
                        }
                        else if(SQL_ISPUNCTUATION(pTableName,"{"))
@@ -607,7 +579,7 @@
                 getQualified_join( _rTables, pTableListElement->getChild(2), 
aTableRange );
             }
                        else
-            {   // '(' joined_table ')' as range_variable op_column_commalist
+            {   // '(' joined_table ')' range_variable op_column_commalist
                                getTableNode( _rTables, pTableListElement, 
aTableRange );
             }
                }
@@ -615,10 +587,6 @@
                {
                        getQualified_join( _rTables, pTableListElement, 
aTableRange );
                }
-               else if ( SQL_ISRULE( pTableListElement, joined_table ) )
-               {
-                       getQualified_join( _rTables, 
pTableListElement->getChild(1), aTableRange );
-               }
 
                //      if (! aIteratorStatus.IsSuccessful()) break;
        }
@@ -1996,3 +1964,4 @@
        else
                m_aErrors = _rError;
 }
+// 
-----------------------------------------------------------------------------

File [changed]: sqlnode.cxx
Url: 
http://dba.openoffice.org/source/browse/dba/connectivity/source/parse/sqlnode.cxx?r1=1.54.18.1&r2=1.54.18.2
Delta lines:  +31 -73
---------------------
--- sqlnode.cxx 2008-05-20 08:29:11+0000        1.54.18.1
+++ sqlnode.cxx 2008-05-23 08:26:43+0000        1.54.18.2
@@ -7,7 +7,7 @@
  * OpenOffice.org - a multi-platform office productivity suite
  *
  * $RCSfile: sqlnode.cxx,v $
- * $Revision: 1.54.18.1 $
+ * $Revision: 1.54.18.2 $
  *
  * This file is part of OpenOffice.org.
  *
@@ -72,7 +72,9 @@
 #include "connectivity/sqlerror.hxx"
 #include <tools/diagnose_ex.h>
 #include <string.h>
-
+#include <boost/bind.hpp>
+#include <algorithm>
+#include <functional>
 
 using namespace ::com::sun::star::sdbc;
 using namespace ::com::sun::star::util;
@@ -349,47 +351,7 @@
 {
     bool lcl_isAliasNamePresent( const OSQLParseNode& _rTableNameNode )
     {
-        OSL_ENSURE( _rTableNameNode.getKnownRuleID() == 
OSQLParseNode::table_name, "lcl_isAliasNamePresent: Must be a 'table_name' 
rule!" );
-        OSL_ENSURE( _rTableNameNode.getParent()->getKnownRuleID() == 
OSQLParseNode::table_ref, "lcl_isAliasNamePresent: parent must be a 
'table_ref'!" );
-
-        const OSQLParseNode* pTableRef = _rTableNameNode.getParent();
-        if ( pTableRef->count() == 4 )
-        {
-            // table_ref := table_node as range_variable op_column_commalist
-            // table_node := table_name | ...
-            if ( pTableRef->getChild(1)->getKnownRuleID() == OSQLParseNode::as 
)
-                return true;
-
-            // table_ref := '{' SQL_TOKEN_OJ joined_table '}'
-            OSL_ENSURE( SQL_ISPUNCTUATION( pTableRef->getChild(0), "(" ), 
"lcl_isAliasNamePresent: grammar changed(1)!" );
-            return false;
-        }
-
-        if ( pTableRef->count() == 6 )
-        {   // '(' joined_table ')' as range_variable op_column_commalist
-            OSL_ENSURE( SQL_ISPUNCTUATION( pTableRef->getChild(2), "(" )
-                    &&  SQL_ISRULE( pTableRef->getChild(3), as ),
-                    "lcl_isAliasNamePresent: grammar changed(3)!" );
-            return true;
-        }
-
-        if ( pTableRef->count() == 3 )
-            // subquery as range_variable
-            return true;
-
-        if ( pTableRef->count() == 1 )
-            return false;
-
-#if OSL_DEBUG_LEVEL > 0
-        for ( size_t i=0; i<pTableRef->count(); ++i )
-        {
-            const OSQLParseNode* pChildNode = pTableRef->getChild( i );
-            OSQLParseNode::Rule eRuleID = pChildNode->getKnownRuleID();
-            OSL_UNUSED( eRuleID );
-        }
-#endif
-        OSL_ENSURE( false, "lcl_isAliasNamePresent: unreachable code - except 
you extended the production rules for table_ref!" );
-        return false;
+        return 
OSQLParseNode::getTableRange(_rTableNameNode.getParent()).getLength() != 0;
     }
 }
 
@@ -432,9 +394,7 @@
 
     // table refs
     case table_ref:
-        if  (   ( nCount == 4 ) || ( nCount == 3 )
-            ||  ( ( nCount == 6 ) &&  SQL_ISPUNCTUATION( m_aChilds[0], "(" ) )
-            )
+        if (  ( nCount == 2 ) || ( nCount == 3 ) || ( nCount == 5 ) )
         {
                    impl_parseTableRangeNodeToString_throw( rString, rParam );
             bHandled = true;
@@ -693,32 +653,12 @@
 //-----------------------------------------------------------------------------
 void OSQLParseNode::impl_parseTableRangeNodeToString_throw(::rtl::OUString& 
rString, const SQLParseNodeParameter& rParam) const
 {
-       sal_uInt32 nCount(count());
-       rString += ::rtl::OUString::createFromAscii(" ");
+    const sal_uInt32 nCount(count());
+    OSL_PRECOND(  ( nCount == 2 ) || ( nCount == 3 ) || ( nCount == 5 ) 
,"Illegal count");
 
-       if ( nCount == 3 || nCount == 4 )
-       {
-               m_aChilds[0]->impl_parseNodeToString_throw( rString, rParam );
-        if ( m_aChilds[2]->isToken() )
-        {
-                   m_aChilds[1]->impl_parseNodeToString_throw( rString, rParam 
);
-                   m_aChilds[2]->impl_parseNodeToString_throw( rString, rParam 
);
-        } // if ( m_aChilds[2]->isToken() )
-        if ( nCount == 4 )
-                   m_aChilds[3]->impl_parseNodeToString_throw( rString, rParam 
);
-       }
-       else if(nCount == 6 && SQL_ISPUNCTUATION(m_aChilds[0],"("))
-       {
-               m_aChilds[0]->impl_parseNodeToString_throw( rString, rParam );
-               m_aChilds[1]->impl_parseNodeToString_throw( rString, rParam );
-               m_aChilds[2]->impl_parseNodeToString_throw( rString, rParam );
-        if ( m_aChilds[4]->isToken() )
-        {
-                   m_aChilds[3]->impl_parseNodeToString_throw( rString, rParam 
);
-                   m_aChilds[4]->impl_parseNodeToString_throw( rString, rParam 
);
-        }
-               m_aChilds[5]->impl_parseNodeToString_throw( rString, rParam );
-       }
+       rString += ::rtl::OUString::createFromAscii(" ");
+    ::std::for_each(m_aChilds.begin(),m_aChilds.end(),
+        boost::bind( &OSQLParseNode::impl_parseNodeToString_throw, _1, 
boost::ref( rString ), boost::cref( rParam ) ));
 }
 
 //-----------------------------------------------------------------------------
@@ -1433,7 +1373,6 @@
             { OSQLParseNode::all_or_any_predicate, "all_or_any_predicate" },
             { OSQLParseNode::named_columns_join, "named_columns_join" },
             { OSQLParseNode::join_condition, "join_condition" },
-            { OSQLParseNode::joined_table, "joined_table" },
             { OSQLParseNode::boolean_factor, "boolean_factor" },
             { OSQLParseNode::sql_not, "sql_not" },
             { OSQLParseNode::boolean_test, "boolean_test" },
@@ -1457,7 +1396,8 @@
             { OSQLParseNode::column_def, "column_def" },
             { OSQLParseNode::table_node, "table_node" },
             { OSQLParseNode::as, "as" },
-            { OSQLParseNode::op_column_commalist, "op_column_commalist" }
+            { OSQLParseNode::op_column_commalist, "op_column_commalist" },
+            { OSQLParseNode::table_primary_as_range_column, 
"table_primary_as_range_column" }
         };
         size_t nRuleMapCount = sizeof( aRuleDescriptions ) / sizeof( 
aRuleDescriptions[0] );
         OSL_ENSURE( nRuleMapCount == size_t( OSQLParseNode::rule_count ), 
"OSQLParser::OSQLParser: added a new rule? Adjust this map!" );
@@ -2613,5 +2553,23 @@
         return UNKNOWN_RULE;
     return OSQLParser::RuleIDToRule( getRuleID() );
 }
+// 
-----------------------------------------------------------------------------
+::rtl::OUString OSQLParseNode::getTableRange(const OSQLParseNode* _pTableRef)
+{
+    OSL_ENSURE(_pTableRef && _pTableRef->count() > 1 && 
_pTableRef->getKnownRuleID() == OSQLParseNode::table_ref,"Invalid node give, 
only table ref is allowed!");
+    const sal_uInt32 nCount = _pTableRef->count();
+    ::rtl::OUString sTableRange;
+    if ( nCount == 2 || nCount == 3 || nCount == 5)
+    {
+        const OSQLParseNode* pNode = _pTableRef->getChild(nCount - (nCount == 
2 ? 1 : 2));
+        OSL_ENSURE(pNode && (pNode->getKnownRuleID() == 
OSQLParseNode::table_primary_as_range_column
+                          || pNode->getKnownRuleID() == 
OSQLParseNode::range_variable) 
+                         ,"SQL grammar changed!");
+        if ( !pNode->isLeaf() )
+            sTableRange = pNode->getChild(pNode->count() - 1)->getTokenValue();
+    } // if ( nCount == 2 || nCount == 3 || nCount == 5)
+
+    return sTableRange;
+}
 
 }   // namespace connectivity




---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to