1*cdf0e10cSrcweir %{
2*cdf0e10cSrcweir //--------------------------------------------------------------------------
3*cdf0e10cSrcweir //
4*cdf0e10cSrcweir // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5*cdf0e10cSrcweir //
6*cdf0e10cSrcweir // Copyright 2000, 2010 Oracle and/or its affiliates.
7*cdf0e10cSrcweir //
8*cdf0e10cSrcweir // OpenOffice.org - a multi-platform office productivity suite
9*cdf0e10cSrcweir //
10*cdf0e10cSrcweir // This file is part of OpenOffice.org.
11*cdf0e10cSrcweir //
12*cdf0e10cSrcweir // OpenOffice.org is free software: you can redistribute it and/or modify
13*cdf0e10cSrcweir // it under the terms of the GNU Lesser General Public License version 3
14*cdf0e10cSrcweir // only, as published by the Free Software Foundation.
15*cdf0e10cSrcweir //
16*cdf0e10cSrcweir // OpenOffice.org is distributed in the hope that it will be useful,
17*cdf0e10cSrcweir // but WITHOUT ANY WARRANTY; without even the implied warranty of
18*cdf0e10cSrcweir // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19*cdf0e10cSrcweir // GNU Lesser General Public License version 3 for more details
20*cdf0e10cSrcweir // (a copy is included in the LICENSE file that accompanied this code).
21*cdf0e10cSrcweir //
22*cdf0e10cSrcweir // You should have received a copy of the GNU Lesser General Public License
23*cdf0e10cSrcweir // version 3 along with OpenOffice.org.  If not, see
24*cdf0e10cSrcweir // <http://www.openoffice.org/license.html>
25*cdf0e10cSrcweir // for a copy of the LGPLv3 License.
26*cdf0e10cSrcweir //
27*cdf0e10cSrcweir //--------------------------------------------------------------------------
28*cdf0e10cSrcweir 
29*cdf0e10cSrcweir #include <vector>
30*cdf0e10cSrcweir #include <string.h>
31*cdf0e10cSrcweir 
32*cdf0e10cSrcweir #ifndef _CONNECTIVITY_SQLNODE_HXX
33*cdf0e10cSrcweir #include <connectivity/sqlnode.hxx>
34*cdf0e10cSrcweir #endif
35*cdf0e10cSrcweir #ifndef _CONNECTIVITY_SQLPARSE_HXX
36*cdf0e10cSrcweir #include <connectivity/sqlparse.hxx>
37*cdf0e10cSrcweir #endif
38*cdf0e10cSrcweir #ifndef _CONNECTIVITY_SQLINTERNALNODE_HXX
39*cdf0e10cSrcweir #include <internalnode.hxx>
40*cdf0e10cSrcweir #endif
41*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_LANG_LOCALE_HPP_
42*cdf0e10cSrcweir #include <com/sun/star/lang/Locale.hpp>
43*cdf0e10cSrcweir #endif
44*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_SDBC_DATATYPE_HPP_
45*cdf0e10cSrcweir #include <com/sun/star/sdbc/DataType.hpp>
46*cdf0e10cSrcweir #endif
47*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_DATE_HPP_
48*cdf0e10cSrcweir #include <com/sun/star/util/Date.hpp>
49*cdf0e10cSrcweir #endif
50*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_DATETIME_HPP_
51*cdf0e10cSrcweir #include <com/sun/star/util/DateTime.hpp>
52*cdf0e10cSrcweir #endif
53*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_TIME_HPP_
54*cdf0e10cSrcweir #include <com/sun/star/util/Time.hpp>
55*cdf0e10cSrcweir #endif
56*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTER_HPP_
57*cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatter.hpp>
58*cdf0e10cSrcweir #endif
59*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATSSUPPLIER_HPP_
60*cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
61*cdf0e10cSrcweir #endif
62*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATS_HPP_
63*cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormats.hpp>
64*cdf0e10cSrcweir #endif
65*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_NUMBERFORMAT_HPP_
66*cdf0e10cSrcweir #include <com/sun/star/util/NumberFormat.hpp>
67*cdf0e10cSrcweir #endif
68*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_UTIL_XNUMBERFORMATTYPES_HPP_
69*cdf0e10cSrcweir #include <com/sun/star/util/XNumberFormatTypes.hpp>
70*cdf0e10cSrcweir #endif
71*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_BEANS_XPROPERTYSET_HPP_
72*cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp>
73*cdf0e10cSrcweir #endif
74*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_I18N_KPARSETYPE_HPP_
75*cdf0e10cSrcweir #include <com/sun/star/i18n/KParseType.hpp>
76*cdf0e10cSrcweir #endif
77*cdf0e10cSrcweir #ifndef _COM_SUN_STAR_I18N_KPARSETOKENS_HPP_
78*cdf0e10cSrcweir #include <com/sun/star/i18n/KParseTokens.hpp>
79*cdf0e10cSrcweir #endif
80*cdf0e10cSrcweir #ifndef _CONNECTIVITY_SQLSCAN_HXX
81*cdf0e10cSrcweir #include "sqlscan.hxx"
82*cdf0e10cSrcweir #endif
83*cdf0e10cSrcweir #ifndef _OSL_DIAGNOSE_H_
84*cdf0e10cSrcweir #include <osl/diagnose.h>
85*cdf0e10cSrcweir #endif
86*cdf0e10cSrcweir #ifndef _DBHELPER_DBCONVERSION_HXX_
87*cdf0e10cSrcweir #include "connectivity/dbconversion.hxx"
88*cdf0e10cSrcweir #endif
89*cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
90*cdf0e10cSrcweir 
91*cdf0e10cSrcweir #if defined __GNUC__
92*cdf0e10cSrcweir     #pragma GCC system_header
93*cdf0e10cSrcweir #elif defined __SUNPRO_CC
94*cdf0e10cSrcweir #pragma disable_warn
95*cdf0e10cSrcweir #elif defined _MSC_VER
96*cdf0e10cSrcweir #pragma warning(push, 1)
97*cdf0e10cSrcweir #pragma warning(disable:4273 4701 4706)
98*cdf0e10cSrcweir #endif
99*cdf0e10cSrcweir 
100*cdf0e10cSrcweir static ::rtl::OUString aEmptyString;
101*cdf0e10cSrcweir 
102*cdf0e10cSrcweir static connectivity::OSQLInternalNode* newNode(const sal_Char* pNewValue,
103*cdf0e10cSrcweir 							     const connectivity::SQLNodeType eNodeType,
104*cdf0e10cSrcweir 								 const sal_uInt32 nNodeID = 0)
105*cdf0e10cSrcweir {
106*cdf0e10cSrcweir 	return new connectivity::OSQLInternalNode(pNewValue, eNodeType, nNodeID);
107*cdf0e10cSrcweir }
108*cdf0e10cSrcweir 
109*cdf0e10cSrcweir static connectivity::OSQLInternalNode* newNode(const ::rtl::OString& _NewValue,
110*cdf0e10cSrcweir 							    const connectivity::SQLNodeType eNodeType,
111*cdf0e10cSrcweir 								const sal_uInt32 nNodeID = 0)
112*cdf0e10cSrcweir {
113*cdf0e10cSrcweir 	return new connectivity::OSQLInternalNode(_NewValue, eNodeType, nNodeID);
114*cdf0e10cSrcweir }
115*cdf0e10cSrcweir 
116*cdf0e10cSrcweir static connectivity::OSQLInternalNode* newNode(const ::rtl::OUString& _NewValue,
117*cdf0e10cSrcweir 							    const connectivity::SQLNodeType eNodeType,
118*cdf0e10cSrcweir 								const sal_uInt32 nNodeID = 0)
119*cdf0e10cSrcweir {
120*cdf0e10cSrcweir 	return new connectivity::OSQLInternalNode(_NewValue, eNodeType, nNodeID);
121*cdf0e10cSrcweir }
122*cdf0e10cSrcweir 
123*cdf0e10cSrcweir 
124*cdf0e10cSrcweir // yyi ist die interne Nr. der Regel, die gerade reduziert wird.
125*cdf0e10cSrcweir // Ueber die Mapping-Tabelle yyrmap wird daraus eine externe Regel-Nr.
126*cdf0e10cSrcweir #define SQL_NEW_RULE 			newNode(aEmptyString, SQL_NODE_RULE, yyr1[yyn])
127*cdf0e10cSrcweir #define SQL_NEW_LISTRULE 		newNode(aEmptyString, SQL_NODE_LISTRULE, yyr1[yyn])
128*cdf0e10cSrcweir #define SQL_NEW_COMMALISTRULE   newNode(aEmptyString, SQL_NODE_COMMALISTRULE, yyr1[yyn])
129*cdf0e10cSrcweir 
130*cdf0e10cSrcweir 
131*cdf0e10cSrcweir connectivity::OSQLParser* xxx_pGLOBAL_SQLPARSER;
132*cdf0e10cSrcweir 
133*cdf0e10cSrcweir #define YYERROR_VERBOSE
134*cdf0e10cSrcweir 
135*cdf0e10cSrcweir #define SQLyyerror(s)						\
136*cdf0e10cSrcweir {											\
137*cdf0e10cSrcweir 	xxx_pGLOBAL_SQLPARSER->error(s);		\
138*cdf0e10cSrcweir }
139*cdf0e10cSrcweir 
140*cdf0e10cSrcweir using namespace connectivity;
141*cdf0e10cSrcweir #define SQLyylex xxx_pGLOBAL_SQLPARSER->SQLlex
142*cdf0e10cSrcweir %}
143*cdf0e10cSrcweir 	/* symbolic tokens */
144*cdf0e10cSrcweir 
145*cdf0e10cSrcweir %union {
146*cdf0e10cSrcweir 	connectivity::OSQLParseNode * pParseNode;
147*cdf0e10cSrcweir }
148*cdf0e10cSrcweir %type <pParseNode> '(' ')' ',' ':' ';' '?' '[' ']' '{' '}' '.' 'K' 'M' 'G' 'T' 'P'
149*cdf0e10cSrcweir 
150*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_STRING SQL_TOKEN_ACCESS_DATE SQL_TOKEN_INT SQL_TOKEN_REAL_NUM
151*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_INTNUM SQL_TOKEN_APPROXNUM SQL_TOKEN_NOT SQL_TOKEN_NAME
152*cdf0e10cSrcweir 
153*cdf0e10cSrcweir 
154*cdf0e10cSrcweir %nonassoc <pParseNode> SQL_TOKEN_UMINUS
155*cdf0e10cSrcweir 
156*cdf0e10cSrcweir 
157*cdf0e10cSrcweir 
158*cdf0e10cSrcweir 	/* literal keyword tokens */
159*cdf0e10cSrcweir 
160*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_ALL SQL_TOKEN_ALTER SQL_TOKEN_AMMSC SQL_TOKEN_ANY SQL_TOKEN_AS SQL_TOKEN_ASC SQL_TOKEN_AT SQL_TOKEN_AUTHORIZATION SQL_TOKEN_AVG
161*cdf0e10cSrcweir 
162*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_BETWEEN SQL_TOKEN_BIT SQL_TOKEN_BOTH SQL_TOKEN_BY
163*cdf0e10cSrcweir 
164*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_CAST SQL_TOKEN_CHARACTER SQL_TOKEN_CHECK SQL_TOKEN_COLLATE SQL_TOKEN_COMMIT SQL_TOKEN_CONTINUE SQL_TOKEN_CONVERT SQL_TOKEN_COUNT SQL_TOKEN_CREATE SQL_TOKEN_CROSS
165*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_CURRENT SQL_TOKEN_CURSOR
166*cdf0e10cSrcweir 
167*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_DATE SQL_TOKEN_DATEVALUE SQL_TOKEN_DAY SQL_TOKEN_DEC SQL_TOKEN_DECIMAL SQL_TOKEN_DECLARE SQL_TOKEN_DEFAULT SQL_TOKEN_DELETE SQL_TOKEN_DESC
168*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_DISTINCT SQL_TOKEN_DOUBLE SQL_TOKEN_DROP
169*cdf0e10cSrcweir 
170*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_ESCAPE SQL_TOKEN_EXCEPT SQL_TOKEN_EXISTS SQL_TOKEN_FALSE SQL_TOKEN_FETCH SQL_TOKEN_FLOAT SQL_TOKEN_FOR SQL_TOKEN_FOREIGN SQL_TOKEN_FOUND SQL_TOKEN_FROM SQL_TOKEN_FULL
171*cdf0e10cSrcweir 
172*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_GRANT SQL_TOKEN_GROUP SQL_TOKEN_HAVING SQL_TOKEN_IN SQL_TOKEN_INDICATOR SQL_TOKEN_INNER SQL_TOKEN_INTEGER SQL_TOKEN_INTO SQL_TOKEN_IS SQL_TOKEN_INTERSECT
173*cdf0e10cSrcweir 
174*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_JOIN SQL_TOKEN_KEY SQL_TOKEN_LEADING SQL_TOKEN_LIKE SQL_TOKEN_LOCAL SQL_TOKEN_LOWER
175*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_MAX SQL_TOKEN_MIN SQL_TOKEN_NATURAL SQL_TOKEN_NCHAR SQL_TOKEN_NULL SQL_TOKEN_NUMERIC
176*cdf0e10cSrcweir 
177*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_OCTET_LENGTH SQL_TOKEN_OF SQL_TOKEN_ON SQL_TOKEN_OPTION SQL_TOKEN_ORDER SQL_TOKEN_OUTER
178*cdf0e10cSrcweir 
179*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_PRECISION SQL_TOKEN_PRIMARY SQL_TOKEN_PRIVILEGES SQL_TOKEN_PROCEDURE SQL_TOKEN_PUBLIC
180*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_REAL SQL_TOKEN_REFERENCES SQL_TOKEN_ROLLBACK
181*cdf0e10cSrcweir 
182*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_SCHEMA SQL_TOKEN_SELECT SQL_TOKEN_SET SQL_TOKEN_SIZE SQL_TOKEN_SMALLINT SQL_TOKEN_SOME SQL_TOKEN_SQLCODE SQL_TOKEN_SQLERROR SQL_TOKEN_SUM
183*cdf0e10cSrcweir 
184*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_TABLE SQL_TOKEN_TIME SQL_TOKEN_TIMESTAMP SQL_TOKEN_TIMEZONE_HOUR SQL_TOKEN_TIMEZONE_MINUTE SQL_TOKEN_TO SQL_TOKEN_TRAILING SQL_TOKEN_TRANSLATE SQL_TOKEN_TRIM SQL_TOKEN_TRUE SQL_TOKEN_UNION
185*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_UNIQUE SQL_TOKEN_UNKNOWN SQL_TOKEN_UPDATE SQL_TOKEN_UPPER SQL_TOKEN_USAGE SQL_TOKEN_USER SQL_TOKEN_USING SQL_TOKEN_VALUES SQL_TOKEN_VIEW
186*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_WHERE SQL_TOKEN_WITH SQL_TOKEN_WORK SQL_TOKEN_ZONE
187*cdf0e10cSrcweir 
188*cdf0e10cSrcweir /* ODBC KEYWORDS */
189*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_CALL SQL_TOKEN_D SQL_TOKEN_FN SQL_TOKEN_T SQL_TOKEN_TS SQL_TOKEN_OJ
190*cdf0e10cSrcweir /* string functions */
191*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_ASCII SQL_TOKEN_BIT_LENGTH  SQL_TOKEN_CHAR  SQL_TOKEN_CHAR_LENGTH  SQL_TOKEN_SQL_TOKEN_INTNUM
192*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_CONCAT
193*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_DIFFERENCE  SQL_TOKEN_INSERT SQL_TOKEN_LCASE  SQL_TOKEN_LEFT SQL_TOKEN_LENGTH  SQL_TOKEN_LOCATE
194*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_LOCATE_2 SQL_TOKEN_LTRIM SQL_TOKEN_POSITION SQL_TOKEN_REPEAT SQL_TOKEN_REPLACE
195*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_RIGHT SQL_TOKEN_RTRIM SQL_TOKEN_SOUNDEX SQL_TOKEN_SPACE  SQL_TOKEN_SUBSTRING SQL_TOKEN_UCASE
196*cdf0e10cSrcweir 
197*cdf0e10cSrcweir /* time and date functions */
198*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_CURRENT_DATE SQL_TOKEN_CURRENT_TIME SQL_TOKEN_CURRENT_TIMESTAMP SQL_TOKEN_CURDATE SQL_TOKEN_CURTIME
199*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_DAYNAME  SQL_TOKEN_DAYOFMONTH  SQL_TOKEN_DAYOFWEEK  SQL_TOKEN_DAYOFYEAR SQL_TOKEN_EXTRACT
200*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_HOUR SQL_TOKEN_MINUTE  SQL_TOKEN_MONTH  SQL_TOKEN_MONTHNAME SQL_TOKEN_NOW SQL_TOKEN_QUARTER SQL_TOKEN_DATEDIFF
201*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_SECOND SQL_TOKEN_TIMESTAMPADD SQL_TOKEN_TIMESTAMPDIFF SQL_TOKEN_TIMEVALUE SQL_TOKEN_WEEK SQL_TOKEN_YEAR
202*cdf0e10cSrcweir 
203*cdf0e10cSrcweir /* numeric functions */
204*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_ABS SQL_TOKEN_ACOS SQL_TOKEN_ASIN SQL_TOKEN_ATAN SQL_TOKEN_ATAN2 SQL_TOKEN_CEILING
205*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_COS SQL_TOKEN_COT SQL_TOKEN_DEGREES SQL_TOKEN_EXP SQL_TOKEN_FLOOR SQL_TOKEN_LOGF  SQL_TOKEN_LOG SQL_TOKEN_LN
206*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_LOG10 SQL_TOKEN_MOD SQL_TOKEN_PI SQL_TOKEN_POWER SQL_TOKEN_RADIANS SQL_TOKEN_RAND SQL_TOKEN_ROUNDMAGIC
207*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_ROUND   SQL_TOKEN_SIGN    SQL_TOKEN_SIN     SQL_TOKEN_SQRT    SQL_TOKEN_TAN SQL_TOKEN_TRUNCATE
208*cdf0e10cSrcweir 
209*cdf0e10cSrcweir // computational operation
210*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_EVERY SQL_TOKEN_INTERSECTION SQL_TOKEN_FUSION SQL_TOKEN_COLLECT SQL_TOKEN_VAR_POP SQL_TOKEN_VAR_SAMP
211*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_STDDEV_SAMP SQL_TOKEN_STDDEV_POP
212*cdf0e10cSrcweir 
213*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_RANK SQL_TOKEN_DENSE_RANK	SQL_TOKEN_PERCENT_RANK	SQL_TOKEN_CUME_DIST SQL_TOKEN_PERCENTILE_CONT SQL_TOKEN_PERCENTILE_DISC SQL_TOKEN_WITHIN SQL_TOKEN_ARRAY_AGG
214*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_CASE SQL_TOKEN_THEN SQL_TOKEN_END SQL_TOKEN_NULLIF SQL_TOKEN_COALESCE SQL_TOKEN_WHEN SQL_TOKEN_ELSE
215*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_BEFORE SQL_TOKEN_AFTER SQL_TOKEN_INSTEAD SQL_TOKEN_EACH SQL_TOKEN_REFERENCING SQL_TOKEN_BEGIN SQL_TOKEN_ATOMIC SQL_TOKEN_TRIGGER SQL_TOKEN_ROW SQL_TOKEN_STATEMENT
216*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_NEW SQL_TOKEN_OLD
217*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_VALUE SQL_TOKEN_CURRENT_CATALOG SQL_TOKEN_CURRENT_DEFAULT_TRANSFORM_GROUP SQL_TOKEN_CURRENT_PATH SQL_TOKEN_CURRENT_ROLE SQL_TOKEN_CURRENT_SCHEMA SQL_TOKEN_CURRENT_USER
218*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_SESSION_USER SQL_TOKEN_SYSTEM_USER SQL_TOKEN_VARCHAR SQL_TOKEN_VARBINARY SQL_TOKEN_VARYING SQL_TOKEN_OBJECT SQL_TOKEN_NCLOB SQL_TOKEN_NATIONAL
219*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_LARGE SQL_TOKEN_CLOB SQL_TOKEN_BLOB SQL_TOKEN_BIGINT SQL_TOKEN_BINARY SQL_TOKEN_WITHOUT SQL_TOKEN_BOOLEAN SQL_TOKEN_INTERVAL
220*cdf0e10cSrcweir // window function
221*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_OVER SQL_TOKEN_ROW_NUMBER SQL_TOKEN_NTILE SQL_TOKEN_LEAD SQL_TOKEN_LAG SQL_TOKEN_RESPECT SQL_TOKEN_IGNORE SQL_TOKEN_NULLS
222*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_FIRST_VALUE SQL_TOKEN_LAST_VALUE SQL_TOKEN_NTH_VALUE SQL_TOKEN_FIRST SQL_TOKEN_LAST
223*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_EXCLUDE SQL_TOKEN_OTHERS SQL_TOKEN_TIES SQL_TOKEN_FOLLOWING SQL_TOKEN_UNBOUNDED SQL_TOKEN_PRECEDING SQL_TOKEN_RANGE SQL_TOKEN_ROWS
224*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_PARTITION SQL_TOKEN_WINDOW SQL_TOKEN_NO
225*cdf0e10cSrcweir // LIMIT and OFFSEt
226*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_LIMIT SQL_TOKEN_OFFSET SQL_TOKEN_NEXT SQL_TOKEN_ONLY
227*cdf0e10cSrcweir 
228*cdf0e10cSrcweir 	/* operators */
229*cdf0e10cSrcweir %left SQL_TOKEN_NAME
230*cdf0e10cSrcweir %left <pParseNode> SQL_TOKEN_OR
231*cdf0e10cSrcweir %left <pParseNode> SQL_TOKEN_AND
232*cdf0e10cSrcweir 
233*cdf0e10cSrcweir %left <pParseNode> SQL_LESSEQ SQL_GREATEQ SQL_NOTEQUAL SQL_LESS SQL_GREAT SQL_EQUAL /* '<' '>' = <> < > <= >= != */
234*cdf0e10cSrcweir %left <pParseNode> '+' '-' SQL_CONCAT
235*cdf0e10cSrcweir %left <pParseNode> '*' '/'
236*cdf0e10cSrcweir %left SQL_TOKEN_NATURAL SQL_TOKEN_CROSS SQL_TOKEN_FULL SQL_TOKEN_LEFT SQL_TOKEN_RIGHT
237*cdf0e10cSrcweir %left ')'
238*cdf0e10cSrcweir %right '='
239*cdf0e10cSrcweir %right '.'
240*cdf0e10cSrcweir %right '('
241*cdf0e10cSrcweir 
242*cdf0e10cSrcweir 
243*cdf0e10cSrcweir %token <pParseNode> SQL_TOKEN_INVALIDSYMBOL
244*cdf0e10cSrcweir 
245*cdf0e10cSrcweir /*%type <pParseNode> sql_single_statement */
246*cdf0e10cSrcweir 
247*cdf0e10cSrcweir %type <pParseNode> sql /*schema */
248*cdf0e10cSrcweir %type <pParseNode> column_def_opt_list column_def_opt table_constraint_def column_commalist
249*cdf0e10cSrcweir %type <pParseNode> view_def opt_with_check_option opt_column_commalist privilege_def
250*cdf0e10cSrcweir %type <pParseNode> opt_with_grant_option privileges operation_commalist operation
251*cdf0e10cSrcweir %type <pParseNode> grantee_commalist grantee opt_order_by_clause ordering_spec_commalist
252*cdf0e10cSrcweir %type <pParseNode> ordering_spec opt_asc_desc manipulative_statement commit_statement
253*cdf0e10cSrcweir %type <pParseNode> /*delete_statement_positioned*/ delete_statement_searched fetch_statement
254*cdf0e10cSrcweir %type <pParseNode> insert_statement values_or_query_spec
255*cdf0e10cSrcweir %type <pParseNode> rollback_statement select_statement_into opt_all_distinct
256*cdf0e10cSrcweir %type <pParseNode> /*update_statement_positioned*/ assignment_commalist assignment
257*cdf0e10cSrcweir %type <pParseNode> update_statement_searched target_commalist target opt_where_clause
258*cdf0e10cSrcweir %type <pParseNode> select_statement selection table_exp from_clause table_ref_commalist table_ref
259*cdf0e10cSrcweir %type <pParseNode> where_clause opt_group_by_clause column_ref_commalist opt_having_clause
260*cdf0e10cSrcweir %type <pParseNode> search_condition predicate comparison_predicate comparison_predicate_part_2 between_predicate between_predicate_part_2
261*cdf0e10cSrcweir %type <pParseNode> like_predicate opt_escape test_for_null null_predicate_part_2 in_predicate in_predicate_part_2 character_like_predicate_part_2 other_like_predicate_part_2
262*cdf0e10cSrcweir %type <pParseNode> all_or_any_predicate any_all_some existence_test subquery quantified_comparison_predicate_part_2
263*cdf0e10cSrcweir %type <pParseNode> scalar_exp_commalist parameter_ref literal parenthesized_boolean_value_expression
264*cdf0e10cSrcweir %type <pParseNode> column_ref data_type column cursor parameter range_variable user /*like_check*/
265*cdf0e10cSrcweir /* neue Regeln bei OJ */
266*cdf0e10cSrcweir %type <pParseNode> derived_column as_clause table_name num_primary term num_value_exp
267*cdf0e10cSrcweir %type <pParseNode> value_exp_primary num_value_fct unsigned_value_spec cast_spec set_fct_spec  scalar_subquery
268*cdf0e10cSrcweir %type <pParseNode> position_exp extract_exp length_exp general_value_spec
269*cdf0e10cSrcweir %type <pParseNode> general_set_fct set_fct_type query_exp non_join_query_exp joined_table
270*cdf0e10cSrcweir %type <pParseNode> non_join_query_term non_join_query_primary simple_table
271*cdf0e10cSrcweir %type <pParseNode> table_value_const_list row_value_constructor row_value_const_list row_value_constructor_elem
272*cdf0e10cSrcweir %type <pParseNode> qualified_join value_exp query_term join_type outer_join_type join_condition boolean_term
273*cdf0e10cSrcweir %type <pParseNode> boolean_factor truth_value boolean_test boolean_primary named_columns_join join_spec
274*cdf0e10cSrcweir %type <pParseNode> cast_operand cast_target factor datetime_value_exp /*interval_value_exp*/ datetime_term datetime_factor
275*cdf0e10cSrcweir %type <pParseNode> datetime_primary datetime_value_fct time_zone time_zone_specifier /*interval_term*/ interval_qualifier
276*cdf0e10cSrcweir %type <pParseNode> start_field non_second_datetime_field end_field single_datetime_field extract_field datetime_field time_zone_field
277*cdf0e10cSrcweir %type <pParseNode> extract_source char_length_exp octet_length_exp bit_length_exp select_sublist string_value_exp
278*cdf0e10cSrcweir %type <pParseNode> char_value_exp concatenation char_factor char_primary string_value_fct char_substring_fct fold
279*cdf0e10cSrcweir %type <pParseNode> form_conversion char_translation trim_fct trim_operands trim_spec bit_value_fct bit_substring_fct op_column_commalist
280*cdf0e10cSrcweir %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
281*cdf0e10cSrcweir %type <pParseNode> function_arg_commalist3 string_function_3Argument function_arg_commalist4 string_function_4Argument function_arg_commalist2 string_function_1Argument string_function_2Argument
282*cdf0e10cSrcweir %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
283*cdf0e10cSrcweir %type <pParseNode> all query_primary sql_not for_length upper_lower comparison column_val  cross_union /*opt_schema_element_list*/
284*cdf0e10cSrcweir %type <pParseNode> /*op_authorization op_schema*/ nil_fkt schema_element base_table_def base_table_element base_table_element_commalist
285*cdf0e10cSrcweir %type <pParseNode> column_def odbc_fct_spec	odbc_call_spec odbc_fct_type op_parameter union_statement
286*cdf0e10cSrcweir %type <pParseNode> op_odbc_call_parameter odbc_parameter_commalist odbc_parameter function_args_commalist function_arg
287*cdf0e10cSrcweir %type <pParseNode> catalog_name schema_name table_node numeric_function string_function function_name date_function table_primary_as_range_column opt_as
288*cdf0e10cSrcweir %type <pParseNode> ordered_set_function inverse_distribution_function hypothetical_set_function hypothetical_set_function_value_expression_list rank_function_type within_group_specification inverse_distribution_function_type array_aggregate_function inverse_distribution_function_argument
289*cdf0e10cSrcweir %type <pParseNode> case_expression else_clause result_expression result case_abbreviation case_specification searched_when_clause simple_when_clause searched_case simple_case
290*cdf0e10cSrcweir %type <pParseNode> when_operand_list when_operand case_operand
291*cdf0e10cSrcweir %type <pParseNode> trigger_definition trigger_name trigger_action_time trigger_event transition_table_or_variable_list triggered_action trigger_column_list triggered_when_clause triggered_SQL_statement SQL_procedure_statement old_transition_variable_name new_transition_variable_name
292*cdf0e10cSrcweir %type <pParseNode> op_referencing op_trigger_columnlist op_triggered_action_for opt_row trigger_for SQL_procedure_statement_list transition_table_or_variable old_transition_table_name new_transition_table_name transition_table_name
293*cdf0e10cSrcweir %type <pParseNode> searched_when_clause_list simple_when_clause_list predefined_type opt_char_set_spec opt_collate_clause character_string_type national_character_string_type
294*cdf0e10cSrcweir %type <pParseNode> binary_string_type numeric_type boolean_type datetime_type interval_type opt_paren_precision paren_char_length opt_paren_char_large_length paren_character_large_object_length
295*cdf0e10cSrcweir %type <pParseNode> large_object_length opt_multiplier character_large_object_type national_character_large_object_type binary_large_object_string_type opt_with_or_without_time_zone
296*cdf0e10cSrcweir %type <pParseNode> approximate_numeric_type exact_numeric_type opt_paren_precision_scale
297*cdf0e10cSrcweir /* window function rules */
298*cdf0e10cSrcweir %type <pParseNode> window_function window_function_type ntile_function number_of_tiles lead_or_lag_function lead_or_lag lead_or_lag_extent offset default_expression null_treatment
299*cdf0e10cSrcweir %type <pParseNode> first_or_last_value_function first_or_last_value nth_value_function nth_row from_first_or_last window_name_or_specification in_line_window_specification opt_lead_or_lag_function
300*cdf0e10cSrcweir %type <pParseNode> opt_null_treatment opt_from_first_or_last simple_value_specification dynamic_parameter_specification window_name window_clause window_definition_list window_definition
301*cdf0e10cSrcweir %type <pParseNode> new_window_name window_specification_details existing_window_name window_partition_clause window_partition_column_reference_list window_partition_column_reference window_frame_clause
302*cdf0e10cSrcweir %type <pParseNode> window_frame_units window_frame_extent window_frame_start window_frame_preceding window_frame_between window_frame_bound_1 window_frame_bound_2 window_frame_bound window_frame_following window_frame_exclusion
303*cdf0e10cSrcweir %type <pParseNode> opt_window_frame_clause opt_window_partition_clause opt_existing_window_name window_specification opt_window_frame_exclusion opt_window_clause opt_offset
304*cdf0e10cSrcweir %type <pParseNode> opt_fetch_first_row_count fetch_first_clause offset_row_count fetch_first_row_count first_or_next row_or_rows opt_result_offset_clause result_offset_clause
305*cdf0e10cSrcweir /* LIMIT and OFFSET */
306*cdf0e10cSrcweir %type <pParseNode> opt_limit_offset_clause limit_offset_clause opt_fetch_first_clause
307*cdf0e10cSrcweir %%
308*cdf0e10cSrcweir 
309*cdf0e10cSrcweir /* Parse Tree an OSQLParser zurueckliefern
310*cdf0e10cSrcweir  * (der Zugriff ueber yyval nach Aufruf des Parsers scheitert,
311*cdf0e10cSrcweir  *
312*cdf0e10cSrcweir  */
313*cdf0e10cSrcweir sql_single_statement:
314*cdf0e10cSrcweir 		sql
315*cdf0e10cSrcweir 		{ xxx_pGLOBAL_SQLPARSER->setParseTree( $1 ); }
316*cdf0e10cSrcweir 	|	sql ';'
317*cdf0e10cSrcweir 		{ xxx_pGLOBAL_SQLPARSER->setParseTree( $1 ); }
318*cdf0e10cSrcweir 	;
319*cdf0e10cSrcweir 
320*cdf0e10cSrcweir 	/* schema definition language */
321*cdf0e10cSrcweir 	/* Note: other ``sql:sal_Unicode() rules appear later in the grammar */
322*cdf0e10cSrcweir 
323*cdf0e10cSrcweir sql:
324*cdf0e10cSrcweir 		manipulative_statement
325*cdf0e10cSrcweir 	|	schema_element
326*cdf0e10cSrcweir            {
327*cdf0e10cSrcweir                 $$ = SQL_NEW_RULE;
328*cdf0e10cSrcweir 		$$->append($1);
329*cdf0e10cSrcweir 	   }
330*cdf0e10cSrcweir 	;
331*cdf0e10cSrcweir 
332*cdf0e10cSrcweir /***
333*cdf0e10cSrcweir 
334*cdf0e10cSrcweir op_authorization:
335*cdf0e10cSrcweir 		{$$ = SQL_NEW_RULE;}
336*cdf0e10cSrcweir 	|	SQL_TOKEN_AUTHORIZATION user
337*cdf0e10cSrcweir 		{
338*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
339*cdf0e10cSrcweir 			$$->append($1);
340*cdf0e10cSrcweir 			$$->append($2);
341*cdf0e10cSrcweir 		}
342*cdf0e10cSrcweir 	;
343*cdf0e10cSrcweir op_schema:
344*cdf0e10cSrcweir 		{$$ = SQL_NEW_RULE;}
345*cdf0e10cSrcweir 	|	SQL_TOKEN_NAME
346*cdf0e10cSrcweir 	|	SQL_TOKEN_NAME '.' SQL_TOKEN_NAME
347*cdf0e10cSrcweir 		{
348*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
349*cdf0e10cSrcweir 			$$->append($1);
350*cdf0e10cSrcweir 			$$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
351*cdf0e10cSrcweir 			$$->append($3);
352*cdf0e10cSrcweir 		}
353*cdf0e10cSrcweir 	;
354*cdf0e10cSrcweir 
355*cdf0e10cSrcweir schema:
356*cdf0e10cSrcweir 		SQL_TOKEN_CREATE SQL_TOKEN_SCHEMA op_schema op_authorization opt_schema_element_list
357*cdf0e10cSrcweir 		{
358*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
359*cdf0e10cSrcweir 			$$->append($1);
360*cdf0e10cSrcweir 			$$->append($2);
361*cdf0e10cSrcweir 			$$->append($3);
362*cdf0e10cSrcweir 			$$->append($4);
363*cdf0e10cSrcweir 			$$->append($5);
364*cdf0e10cSrcweir 		}
365*cdf0e10cSrcweir 	;
366*cdf0e10cSrcweir 
367*cdf0e10cSrcweir opt_schema_element_list:
368*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;}
369*cdf0e10cSrcweir 	|       schema_glement_list
370*cdf0e10cSrcweir 	;
371*cdf0e10cSrcweir 
372*cdf0e10cSrcweir schema_element_list:
373*cdf0e10cSrcweir 		schema_element
374*cdf0e10cSrcweir 			{$$ = SQL_NEW_LISTRULE;
375*cdf0e10cSrcweir 			$$->append($1);}
376*cdf0e10cSrcweir 	|       schema_element_list schema_element
377*cdf0e10cSrcweir 			{$1->append($2);
378*cdf0e10cSrcweir 			$$ = $1;}
379*cdf0e10cSrcweir 	;
380*cdf0e10cSrcweir */
381*cdf0e10cSrcweir 
382*cdf0e10cSrcweir schema_element:
383*cdf0e10cSrcweir 			base_table_def
384*cdf0e10cSrcweir 	|       view_def
385*cdf0e10cSrcweir 	|       privilege_def
386*cdf0e10cSrcweir 	|		trigger_definition
387*cdf0e10cSrcweir 	;
388*cdf0e10cSrcweir 
389*cdf0e10cSrcweir base_table_def:
390*cdf0e10cSrcweir 		SQL_TOKEN_CREATE SQL_TOKEN_TABLE table_node '(' base_table_element_commalist ')'
391*cdf0e10cSrcweir 		{$$ = SQL_NEW_RULE;
392*cdf0e10cSrcweir 		$$->append($1);
393*cdf0e10cSrcweir 		$$->append($2);
394*cdf0e10cSrcweir 		$$->append($3);
395*cdf0e10cSrcweir 		$$->append($4 = newNode("(", SQL_NODE_PUNCTUATION));
396*cdf0e10cSrcweir 		$$->append($5);
397*cdf0e10cSrcweir 		$$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));}
398*cdf0e10cSrcweir 	;
399*cdf0e10cSrcweir 
400*cdf0e10cSrcweir base_table_element_commalist:
401*cdf0e10cSrcweir 		base_table_element
402*cdf0e10cSrcweir 		{$$ = SQL_NEW_COMMALISTRULE;
403*cdf0e10cSrcweir 		$$->append($1);}
404*cdf0e10cSrcweir 	|   base_table_element_commalist ',' base_table_element
405*cdf0e10cSrcweir 		{$1->append($3);
406*cdf0e10cSrcweir 		$$ = $1;}
407*cdf0e10cSrcweir 	;
408*cdf0e10cSrcweir 
409*cdf0e10cSrcweir base_table_element:
410*cdf0e10cSrcweir 		column_def
411*cdf0e10cSrcweir 	|	table_constraint_def
412*cdf0e10cSrcweir 	;
413*cdf0e10cSrcweir 
414*cdf0e10cSrcweir column_def:
415*cdf0e10cSrcweir 		column data_type column_def_opt_list
416*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
417*cdf0e10cSrcweir 			$$->append($1);
418*cdf0e10cSrcweir 			$$->append($2);
419*cdf0e10cSrcweir 			$$->append($3);
420*cdf0e10cSrcweir 			}
421*cdf0e10cSrcweir 	;
422*cdf0e10cSrcweir 
423*cdf0e10cSrcweir column_def_opt_list:
424*cdf0e10cSrcweir 		/* empty */                 {$$ = SQL_NEW_LISTRULE;}
425*cdf0e10cSrcweir 	|       column_def_opt_list column_def_opt
426*cdf0e10cSrcweir 			{$1->append($2);
427*cdf0e10cSrcweir 			$$ = $1;}
428*cdf0e10cSrcweir 	;
429*cdf0e10cSrcweir 
430*cdf0e10cSrcweir nil_fkt:
431*cdf0e10cSrcweir 	datetime_value_fct
432*cdf0e10cSrcweir 	;
433*cdf0e10cSrcweir unique_spec:
434*cdf0e10cSrcweir 		SQL_TOKEN_UNIQUE
435*cdf0e10cSrcweir 	|	SQL_TOKEN_PRIMARY SQL_TOKEN_KEY
436*cdf0e10cSrcweir 		{
437*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
438*cdf0e10cSrcweir 			$$->append($1);
439*cdf0e10cSrcweir 			$$->append($2);
440*cdf0e10cSrcweir 		}
441*cdf0e10cSrcweir 	;
442*cdf0e10cSrcweir column_def_opt:
443*cdf0e10cSrcweir 		SQL_TOKEN_NOT SQL_TOKEN_NULL
444*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
445*cdf0e10cSrcweir 			$$->append($1);
446*cdf0e10cSrcweir 			$$->append($2);}
447*cdf0e10cSrcweir 	|       unique_spec
448*cdf0e10cSrcweir 	|       SQL_TOKEN_DEFAULT literal
449*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
450*cdf0e10cSrcweir 			$$->append($1);
451*cdf0e10cSrcweir 			$$->append($2);}
452*cdf0e10cSrcweir 	|       SQL_TOKEN_DEFAULT SQL_TOKEN_NULL
453*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
454*cdf0e10cSrcweir 			$$->append($1);
455*cdf0e10cSrcweir 			$$->append($2);}
456*cdf0e10cSrcweir 	|       SQL_TOKEN_DEFAULT SQL_TOKEN_USER
457*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
458*cdf0e10cSrcweir 			$$->append($1);
459*cdf0e10cSrcweir 			$$->append($2);}
460*cdf0e10cSrcweir 	|		SQL_TOKEN_DEFAULT nil_fkt
461*cdf0e10cSrcweir 			{
462*cdf0e10cSrcweir 				$$ = SQL_NEW_RULE;
463*cdf0e10cSrcweir 				$$->append($1);
464*cdf0e10cSrcweir 				$$->append($2);
465*cdf0e10cSrcweir 			}
466*cdf0e10cSrcweir 	|       SQL_TOKEN_CHECK
467*cdf0e10cSrcweir 	|       SQL_TOKEN_CHECK '(' search_condition ')'
468*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
469*cdf0e10cSrcweir 			$$->append($1);
470*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
471*cdf0e10cSrcweir 			$$->append($3);
472*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));}
473*cdf0e10cSrcweir 	|       SQL_TOKEN_REFERENCES table_node
474*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
475*cdf0e10cSrcweir 			$$->append($1);
476*cdf0e10cSrcweir 			$$->append($2);}
477*cdf0e10cSrcweir 	|       SQL_TOKEN_REFERENCES table_node '(' column_commalist ')'
478*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
479*cdf0e10cSrcweir 			$$->append($1);
480*cdf0e10cSrcweir 			$$->append($2);
481*cdf0e10cSrcweir 			$$->append($3 = newNode("(", SQL_NODE_PUNCTUATION));
482*cdf0e10cSrcweir 			$$->append($4);
483*cdf0e10cSrcweir 			$$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));}
484*cdf0e10cSrcweir 	;
485*cdf0e10cSrcweir 
486*cdf0e10cSrcweir table_constraint_def:
487*cdf0e10cSrcweir 		unique_spec '(' column_commalist ')'
488*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
489*cdf0e10cSrcweir 			$$->append($1);
490*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
491*cdf0e10cSrcweir 			$$->append($3);
492*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));}
493*cdf0e10cSrcweir 	|       SQL_TOKEN_FOREIGN SQL_TOKEN_KEY '(' column_commalist ')' SQL_TOKEN_REFERENCES table_node
494*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
495*cdf0e10cSrcweir 			$$->append($1);
496*cdf0e10cSrcweir 			$$->append($2);
497*cdf0e10cSrcweir 			$$->append($3 = newNode("(", SQL_NODE_PUNCTUATION));
498*cdf0e10cSrcweir 			$$->append($4);
499*cdf0e10cSrcweir 			$$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
500*cdf0e10cSrcweir 			$$->append($6);
501*cdf0e10cSrcweir 			$$->append($7);}
502*cdf0e10cSrcweir 	|       SQL_TOKEN_FOREIGN SQL_TOKEN_KEY '(' column_commalist ')' SQL_TOKEN_REFERENCES table_node '(' column_commalist ')'
503*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
504*cdf0e10cSrcweir 			$$->append($1);
505*cdf0e10cSrcweir 			$$->append($2);
506*cdf0e10cSrcweir 			$$->append($3 = newNode("(", SQL_NODE_PUNCTUATION));
507*cdf0e10cSrcweir 			$$->append($4);
508*cdf0e10cSrcweir 			$$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
509*cdf0e10cSrcweir 			$$->append($6);
510*cdf0e10cSrcweir 			$$->append($7);
511*cdf0e10cSrcweir 			$$->append($8 = newNode("(", SQL_NODE_PUNCTUATION));
512*cdf0e10cSrcweir 			$$->append($9);
513*cdf0e10cSrcweir 			$$->append($10 = newNode(")", SQL_NODE_PUNCTUATION));}
514*cdf0e10cSrcweir 	|       SQL_TOKEN_CHECK '(' search_condition ')'
515*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
516*cdf0e10cSrcweir 			$$->append($1);
517*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
518*cdf0e10cSrcweir 			$$->append($3);
519*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));}
520*cdf0e10cSrcweir 	;
521*cdf0e10cSrcweir op_column_commalist:
522*cdf0e10cSrcweir 	/* empty */ {$$ = SQL_NEW_RULE;}
523*cdf0e10cSrcweir 	| '(' column_commalist ')'
524*cdf0e10cSrcweir 		{$$ = SQL_NEW_RULE;
525*cdf0e10cSrcweir 			$$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
526*cdf0e10cSrcweir 			$$->append($2);
527*cdf0e10cSrcweir 			$$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
528*cdf0e10cSrcweir 		}
529*cdf0e10cSrcweir 	;
530*cdf0e10cSrcweir column_commalist:
531*cdf0e10cSrcweir 		column_commalist ',' column
532*cdf0e10cSrcweir 			{$1->append($3);
533*cdf0e10cSrcweir 			$$ = $1;}
534*cdf0e10cSrcweir 	|	column
535*cdf0e10cSrcweir 			{$$ = SQL_NEW_COMMALISTRULE;
536*cdf0e10cSrcweir 			$$->append($1);}
537*cdf0e10cSrcweir 	;
538*cdf0e10cSrcweir 
539*cdf0e10cSrcweir view_def:
540*cdf0e10cSrcweir 		SQL_TOKEN_CREATE SQL_TOKEN_VIEW table_node opt_column_commalist SQL_TOKEN_AS select_statement opt_with_check_option
541*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
542*cdf0e10cSrcweir 			$$->append($1);
543*cdf0e10cSrcweir 			$$->append($2);
544*cdf0e10cSrcweir 			$$->append($3);
545*cdf0e10cSrcweir 			$$->append($4);
546*cdf0e10cSrcweir 			$$->append($5);
547*cdf0e10cSrcweir 			$$->append($6);
548*cdf0e10cSrcweir 			$$->append($7);}
549*cdf0e10cSrcweir 	;
550*cdf0e10cSrcweir 
551*cdf0e10cSrcweir opt_with_check_option:
552*cdf0e10cSrcweir 		/* empty */         {$$ = SQL_NEW_RULE;}
553*cdf0e10cSrcweir 	|       SQL_TOKEN_WITH SQL_TOKEN_CHECK SQL_TOKEN_OPTION
554*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
555*cdf0e10cSrcweir 			$$->append($1);
556*cdf0e10cSrcweir 			$$->append($2);
557*cdf0e10cSrcweir 			$$->append($3);}
558*cdf0e10cSrcweir 	;
559*cdf0e10cSrcweir 
560*cdf0e10cSrcweir opt_column_commalist:
561*cdf0e10cSrcweir 		/* empty */         {$$ = SQL_NEW_RULE;}
562*cdf0e10cSrcweir 	|       '(' column_commalist ')'
563*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
564*cdf0e10cSrcweir 			$$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
565*cdf0e10cSrcweir 			$$->append($2);
566*cdf0e10cSrcweir 			$$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));}
567*cdf0e10cSrcweir 	;
568*cdf0e10cSrcweir 
569*cdf0e10cSrcweir privilege_def:
570*cdf0e10cSrcweir 		SQL_TOKEN_GRANT privileges SQL_TOKEN_ON table_node SQL_TOKEN_TO grantee_commalist
571*cdf0e10cSrcweir 		opt_with_grant_option
572*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
573*cdf0e10cSrcweir 			$$->append($1);
574*cdf0e10cSrcweir 			$$->append($2);
575*cdf0e10cSrcweir 			$$->append($3);
576*cdf0e10cSrcweir 			$$->append($4);
577*cdf0e10cSrcweir 			$$->append($5);
578*cdf0e10cSrcweir 			$$->append($6);
579*cdf0e10cSrcweir 			$$->append($7);}
580*cdf0e10cSrcweir 	;
581*cdf0e10cSrcweir 
582*cdf0e10cSrcweir opt_with_grant_option:
583*cdf0e10cSrcweir 		/* empty */         {$$ = SQL_NEW_RULE;}
584*cdf0e10cSrcweir 	|       SQL_TOKEN_WITH SQL_TOKEN_GRANT SQL_TOKEN_OPTION
585*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
586*cdf0e10cSrcweir 			$$->append($1);
587*cdf0e10cSrcweir 			$$->append($2);
588*cdf0e10cSrcweir 			$$->append($3);}
589*cdf0e10cSrcweir 	;
590*cdf0e10cSrcweir 
591*cdf0e10cSrcweir privileges:
592*cdf0e10cSrcweir 		SQL_TOKEN_ALL SQL_TOKEN_PRIVILEGES
593*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
594*cdf0e10cSrcweir 			$$->append($1);
595*cdf0e10cSrcweir 			$$->append($2);}
596*cdf0e10cSrcweir 	|       operation_commalist
597*cdf0e10cSrcweir 	;
598*cdf0e10cSrcweir 
599*cdf0e10cSrcweir operation_commalist:
600*cdf0e10cSrcweir 		operation
601*cdf0e10cSrcweir 			{$$ = SQL_NEW_COMMALISTRULE;
602*cdf0e10cSrcweir 			$$->append($1);}
603*cdf0e10cSrcweir 	|       operation_commalist ',' operation
604*cdf0e10cSrcweir 			{$1->append($3);
605*cdf0e10cSrcweir 			$$ = $1;}
606*cdf0e10cSrcweir 	;
607*cdf0e10cSrcweir 
608*cdf0e10cSrcweir operation:
609*cdf0e10cSrcweir 			SQL_TOKEN_SELECT
610*cdf0e10cSrcweir 	|       SQL_TOKEN_INSERT opt_column_commalist
611*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
612*cdf0e10cSrcweir 			$$->append($1);
613*cdf0e10cSrcweir 			$$->append($2);}
614*cdf0e10cSrcweir 	|       SQL_TOKEN_DELETE
615*cdf0e10cSrcweir 	|       SQL_TOKEN_UPDATE opt_column_commalist
616*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
617*cdf0e10cSrcweir 			$$->append($1);
618*cdf0e10cSrcweir 			$$->append($2);}
619*cdf0e10cSrcweir 	|       SQL_TOKEN_REFERENCES opt_column_commalist
620*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
621*cdf0e10cSrcweir 			$$->append($1);
622*cdf0e10cSrcweir 			$$->append($2);}
623*cdf0e10cSrcweir 	|		SQL_TOKEN_USAGE
624*cdf0e10cSrcweir 	;
625*cdf0e10cSrcweir 
626*cdf0e10cSrcweir 
627*cdf0e10cSrcweir grantee_commalist:
628*cdf0e10cSrcweir 		grantee
629*cdf0e10cSrcweir 			{$$ = SQL_NEW_COMMALISTRULE;
630*cdf0e10cSrcweir 			$$->append($1);}
631*cdf0e10cSrcweir 	|       grantee_commalist ',' grantee
632*cdf0e10cSrcweir 			{$1->append($3);
633*cdf0e10cSrcweir 			$$ = $1;}
634*cdf0e10cSrcweir 	;
635*cdf0e10cSrcweir 
636*cdf0e10cSrcweir grantee:
637*cdf0e10cSrcweir 			SQL_TOKEN_PUBLIC
638*cdf0e10cSrcweir 	|       user
639*cdf0e10cSrcweir 	;
640*cdf0e10cSrcweir 
641*cdf0e10cSrcweir 	/* module language */
642*cdf0e10cSrcweir 
643*cdf0e10cSrcweir opt_order_by_clause:
644*cdf0e10cSrcweir 		/* empty */         {$$ = SQL_NEW_RULE;}
645*cdf0e10cSrcweir 	|       SQL_TOKEN_ORDER SQL_TOKEN_BY ordering_spec_commalist
646*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
647*cdf0e10cSrcweir 			$$->append($1);
648*cdf0e10cSrcweir 			$$->append($2);
649*cdf0e10cSrcweir 			$$->append($3);}
650*cdf0e10cSrcweir 	;
651*cdf0e10cSrcweir 
652*cdf0e10cSrcweir ordering_spec_commalist:
653*cdf0e10cSrcweir 		ordering_spec
654*cdf0e10cSrcweir 			{$$ = SQL_NEW_COMMALISTRULE;
655*cdf0e10cSrcweir 			$$->append($1);}
656*cdf0e10cSrcweir 	|       ordering_spec_commalist ',' ordering_spec
657*cdf0e10cSrcweir 			{$1->append($3);
658*cdf0e10cSrcweir 			$$ = $1;}
659*cdf0e10cSrcweir 	;
660*cdf0e10cSrcweir 
661*cdf0e10cSrcweir ordering_spec:
662*cdf0e10cSrcweir /*		SQL_TOKEN_INTNUM opt_asc_desc
663*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
664*cdf0e10cSrcweir 			$$->append($1);
665*cdf0e10cSrcweir 			$$->append($2);}
666*cdf0e10cSrcweir */
667*cdf0e10cSrcweir 		predicate opt_asc_desc
668*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
669*cdf0e10cSrcweir 			$$->append($1);
670*cdf0e10cSrcweir 			$$->append($2);}
671*cdf0e10cSrcweir 
672*cdf0e10cSrcweir 	|	row_value_constructor_elem opt_asc_desc
673*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
674*cdf0e10cSrcweir 			$$->append($1);
675*cdf0e10cSrcweir 			$$->append($2);}
676*cdf0e10cSrcweir 	;
677*cdf0e10cSrcweir 
678*cdf0e10cSrcweir opt_asc_desc:
679*cdf0e10cSrcweir 		{$$ = SQL_NEW_RULE;}
680*cdf0e10cSrcweir 	|	SQL_TOKEN_ASC
681*cdf0e10cSrcweir 	|	SQL_TOKEN_DESC
682*cdf0e10cSrcweir 	;
683*cdf0e10cSrcweir 
684*cdf0e10cSrcweir 
685*cdf0e10cSrcweir /***
686*cdf0e10cSrcweir manipulative_statement_list:
687*cdf0e10cSrcweir 		manipulative_statement
688*cdf0e10cSrcweir 			{$$ = SQL_NEW_LISTRULE;
689*cdf0e10cSrcweir 			$$->append($1);}
690*cdf0e10cSrcweir 	|       manipulative_statement_list manipulative_statement
691*cdf0e10cSrcweir 			{$1->append($2);
692*cdf0e10cSrcweir 			$$ = $1;}
693*cdf0e10cSrcweir 	;
694*cdf0e10cSrcweir ***/
695*cdf0e10cSrcweir 
696*cdf0e10cSrcweir sql_not:
697*cdf0e10cSrcweir 	{$$ = SQL_NEW_RULE;}
698*cdf0e10cSrcweir 	|	SQL_TOKEN_NOT
699*cdf0e10cSrcweir 	;
700*cdf0e10cSrcweir 
701*cdf0e10cSrcweir /* manipulative statements */
702*cdf0e10cSrcweir 
703*cdf0e10cSrcweir manipulative_statement:
704*cdf0e10cSrcweir 			commit_statement
705*cdf0e10cSrcweir /*	|       delete_statement_positioned*/
706*cdf0e10cSrcweir 	|       delete_statement_searched
707*cdf0e10cSrcweir 	|       fetch_statement
708*cdf0e10cSrcweir 	|       insert_statement
709*cdf0e10cSrcweir 	|       rollback_statement
710*cdf0e10cSrcweir 	|       select_statement_into
711*cdf0e10cSrcweir /*	|       update_statement_positioned*/
712*cdf0e10cSrcweir 	|       update_statement_searched
713*cdf0e10cSrcweir 	|		union_statement
714*cdf0e10cSrcweir 	|		'{' odbc_call_spec '}'
715*cdf0e10cSrcweir 		{
716*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
717*cdf0e10cSrcweir 			$$->append($1 = newNode("{", SQL_NODE_PUNCTUATION));
718*cdf0e10cSrcweir 			$$->append($2);
719*cdf0e10cSrcweir 			$$->append($3 = newNode("}", SQL_NODE_PUNCTUATION));
720*cdf0e10cSrcweir 		}
721*cdf0e10cSrcweir 	;
722*cdf0e10cSrcweir 
723*cdf0e10cSrcweir union_statement:
724*cdf0e10cSrcweir 			select_statement
725*cdf0e10cSrcweir 	|		union_statement SQL_TOKEN_UNION all select_statement
726*cdf0e10cSrcweir 		{
727*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
728*cdf0e10cSrcweir 			$$->append($1);
729*cdf0e10cSrcweir 			$$->append($2);
730*cdf0e10cSrcweir 			$$->append($3);
731*cdf0e10cSrcweir 			$$->append($4);
732*cdf0e10cSrcweir 		}
733*cdf0e10cSrcweir 	;
734*cdf0e10cSrcweir commit_statement:
735*cdf0e10cSrcweir 		SQL_TOKEN_COMMIT SQL_TOKEN_WORK
736*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
737*cdf0e10cSrcweir 			$$->append($1);
738*cdf0e10cSrcweir 			$$->append($2);}
739*cdf0e10cSrcweir 	;
740*cdf0e10cSrcweir /*
741*cdf0e10cSrcweir delete_statement_positioned:
742*cdf0e10cSrcweir 		SQL_TOKEN_DELETE SQL_TOKEN_FROM table_node SQL_TOKEN_WHERE SQL_TOKEN_CURRENT SQL_TOKEN_OF cursor
743*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
744*cdf0e10cSrcweir 			$$->append($1);
745*cdf0e10cSrcweir 			$$->append($2);
746*cdf0e10cSrcweir 			$$->append($3);
747*cdf0e10cSrcweir 			$$->append($4);
748*cdf0e10cSrcweir 			$$->append($5);
749*cdf0e10cSrcweir 			$$->append($6);
750*cdf0e10cSrcweir 			$$->append($7);}
751*cdf0e10cSrcweir 	;
752*cdf0e10cSrcweir */
753*cdf0e10cSrcweir delete_statement_searched:
754*cdf0e10cSrcweir 		SQL_TOKEN_DELETE SQL_TOKEN_FROM table_node opt_where_clause
755*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
756*cdf0e10cSrcweir 			$$->append($1);
757*cdf0e10cSrcweir 			$$->append($2);
758*cdf0e10cSrcweir 			$$->append($3);
759*cdf0e10cSrcweir 			$$->append($4);}
760*cdf0e10cSrcweir 	;
761*cdf0e10cSrcweir 
762*cdf0e10cSrcweir fetch_statement:
763*cdf0e10cSrcweir 		SQL_TOKEN_FETCH cursor SQL_TOKEN_INTO target_commalist
764*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
765*cdf0e10cSrcweir 			$$->append($1);
766*cdf0e10cSrcweir 			$$->append($2);
767*cdf0e10cSrcweir 			$$->append($3);
768*cdf0e10cSrcweir 			$$->append($4);}
769*cdf0e10cSrcweir 	;
770*cdf0e10cSrcweir 
771*cdf0e10cSrcweir insert_statement:
772*cdf0e10cSrcweir 		SQL_TOKEN_INSERT SQL_TOKEN_INTO table_node opt_column_commalist values_or_query_spec
773*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
774*cdf0e10cSrcweir 			$$->append($1);
775*cdf0e10cSrcweir 			$$->append($2);
776*cdf0e10cSrcweir 			$$->append($3);
777*cdf0e10cSrcweir 			$$->append($4);
778*cdf0e10cSrcweir 			$$->append($5);}
779*cdf0e10cSrcweir 	;
780*cdf0e10cSrcweir values_or_query_spec:
781*cdf0e10cSrcweir 		SQL_TOKEN_VALUES '(' table_value_const_list ')'
782*cdf0e10cSrcweir 		{$$ = SQL_NEW_RULE;
783*cdf0e10cSrcweir 			$$->append($1);
784*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
785*cdf0e10cSrcweir 			$$->append($3);
786*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
787*cdf0e10cSrcweir 		}
788*cdf0e10cSrcweir 	;
789*cdf0e10cSrcweir 
790*cdf0e10cSrcweir table_value_const_list:
791*cdf0e10cSrcweir 			row_value_constructor
792*cdf0e10cSrcweir 			{$$ = SQL_NEW_COMMALISTRULE;
793*cdf0e10cSrcweir 			$$->append($1);}
794*cdf0e10cSrcweir 	|       table_value_const_list ',' row_value_constructor
795*cdf0e10cSrcweir 			{$1->append($3);
796*cdf0e10cSrcweir 			$$ = $1;}
797*cdf0e10cSrcweir 	;
798*cdf0e10cSrcweir row_value_const_list:
799*cdf0e10cSrcweir 			row_value_constructor_elem
800*cdf0e10cSrcweir 			{$$ = SQL_NEW_COMMALISTRULE;
801*cdf0e10cSrcweir 			$$->append($1);}
802*cdf0e10cSrcweir 	|       row_value_const_list ',' row_value_constructor_elem
803*cdf0e10cSrcweir 			{$1->append($3);
804*cdf0e10cSrcweir 			$$ = $1;}
805*cdf0e10cSrcweir 	;
806*cdf0e10cSrcweir row_value_constructor:
807*cdf0e10cSrcweir 			row_value_constructor_elem
808*cdf0e10cSrcweir /*	  |		'(' row_value_const_list ')'
809*cdf0e10cSrcweir 			{
810*cdf0e10cSrcweir 				$$ = SQL_NEW_RULE;
811*cdf0e10cSrcweir 				$$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
812*cdf0e10cSrcweir 				$$->append($2);
813*cdf0e10cSrcweir 				$$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
814*cdf0e10cSrcweir 			}
815*cdf0e10cSrcweir 			*/
816*cdf0e10cSrcweir 	;
817*cdf0e10cSrcweir row_value_constructor_elem:
818*cdf0e10cSrcweir 			value_exp /*[^')']*/
819*cdf0e10cSrcweir 	|		SQL_TOKEN_DEFAULT
820*cdf0e10cSrcweir 	;
821*cdf0e10cSrcweir 
822*cdf0e10cSrcweir 
823*cdf0e10cSrcweir rollback_statement:
824*cdf0e10cSrcweir 		SQL_TOKEN_ROLLBACK SQL_TOKEN_WORK
825*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
826*cdf0e10cSrcweir 			$$->append($1);
827*cdf0e10cSrcweir 			$$->append($2);}
828*cdf0e10cSrcweir 	;
829*cdf0e10cSrcweir 
830*cdf0e10cSrcweir 
831*cdf0e10cSrcweir 		/* INTO target_commalist herausgenommen */
832*cdf0e10cSrcweir select_statement_into:
833*cdf0e10cSrcweir 		SQL_TOKEN_SELECT opt_all_distinct selection SQL_TOKEN_INTO target_commalist table_exp
834*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
835*cdf0e10cSrcweir 			$$->append($1);
836*cdf0e10cSrcweir 			$$->append($2);
837*cdf0e10cSrcweir 			$$->append($3);
838*cdf0e10cSrcweir 			$$->append($4);
839*cdf0e10cSrcweir 			$$->append($5);
840*cdf0e10cSrcweir 			$$->append($6); }
841*cdf0e10cSrcweir 	;
842*cdf0e10cSrcweir 
843*cdf0e10cSrcweir opt_all_distinct:
844*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;}
845*cdf0e10cSrcweir 		|	SQL_TOKEN_ALL
846*cdf0e10cSrcweir 		|	SQL_TOKEN_DISTINCT
847*cdf0e10cSrcweir 
848*cdf0e10cSrcweir 	;
849*cdf0e10cSrcweir /*
850*cdf0e10cSrcweir update_statement_positioned:
851*cdf0e10cSrcweir 		SQL_TOKEN_UPDATE table_node SQL_TOKEN_SET assignment_commalist
852*cdf0e10cSrcweir 		SQL_TOKEN_WHERE SQL_TOKEN_CURRENT SQL_TOKEN_OF cursor
853*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
854*cdf0e10cSrcweir 			$$->append($1);
855*cdf0e10cSrcweir 			$$->append($2);
856*cdf0e10cSrcweir 			$$->append($3);
857*cdf0e10cSrcweir 			$$->append($4);
858*cdf0e10cSrcweir 			$$->append($5);
859*cdf0e10cSrcweir 			$$->append($6);
860*cdf0e10cSrcweir 			$$->append($7);
861*cdf0e10cSrcweir 			$$->append($8);}
862*cdf0e10cSrcweir 	;
863*cdf0e10cSrcweir */
864*cdf0e10cSrcweir assignment_commalist:
865*cdf0e10cSrcweir 			assignment
866*cdf0e10cSrcweir 			{$$ = SQL_NEW_COMMALISTRULE;
867*cdf0e10cSrcweir 			$$->append($1);}
868*cdf0e10cSrcweir 	|       assignment_commalist ',' assignment
869*cdf0e10cSrcweir 			{$1->append($3);
870*cdf0e10cSrcweir 			$$ = $1;}
871*cdf0e10cSrcweir 	;
872*cdf0e10cSrcweir 
873*cdf0e10cSrcweir assignment:
874*cdf0e10cSrcweir 		column SQL_EQUAL update_source
875*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
876*cdf0e10cSrcweir 			$$->append($1);
877*cdf0e10cSrcweir 			$$->append($2);
878*cdf0e10cSrcweir 			$$->append($3);}
879*cdf0e10cSrcweir 	;
880*cdf0e10cSrcweir update_source:
881*cdf0e10cSrcweir 		value_exp
882*cdf0e10cSrcweir 	  | SQL_TOKEN_DEFAULT
883*cdf0e10cSrcweir 	;
884*cdf0e10cSrcweir update_statement_searched:
885*cdf0e10cSrcweir 		SQL_TOKEN_UPDATE table_node SQL_TOKEN_SET assignment_commalist opt_where_clause
886*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
887*cdf0e10cSrcweir 			$$->append($1);
888*cdf0e10cSrcweir 			$$->append($2);
889*cdf0e10cSrcweir 			$$->append($3);
890*cdf0e10cSrcweir 			$$->append($4);
891*cdf0e10cSrcweir 			$$->append($5);}
892*cdf0e10cSrcweir 	;
893*cdf0e10cSrcweir 
894*cdf0e10cSrcweir target_commalist:
895*cdf0e10cSrcweir 		target
896*cdf0e10cSrcweir 			{$$ = SQL_NEW_COMMALISTRULE;
897*cdf0e10cSrcweir 			$$->append($1);}
898*cdf0e10cSrcweir 	|       target_commalist ',' target
899*cdf0e10cSrcweir 			{$1->append($3);
900*cdf0e10cSrcweir 			$$ = $1;}
901*cdf0e10cSrcweir 	;
902*cdf0e10cSrcweir 
903*cdf0e10cSrcweir target:
904*cdf0e10cSrcweir 		parameter_ref
905*cdf0e10cSrcweir 	;
906*cdf0e10cSrcweir 
907*cdf0e10cSrcweir opt_where_clause:
908*cdf0e10cSrcweir 		/* empty */             {$$ = SQL_NEW_RULE;}
909*cdf0e10cSrcweir 	|       where_clause
910*cdf0e10cSrcweir 	;
911*cdf0e10cSrcweir 
912*cdf0e10cSrcweir 	/* query expressions */
913*cdf0e10cSrcweir 
914*cdf0e10cSrcweir query_term:
915*cdf0e10cSrcweir 		non_join_query_term
916*cdf0e10cSrcweir 		{
917*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
918*cdf0e10cSrcweir 			$$->append($1);
919*cdf0e10cSrcweir 		}
920*cdf0e10cSrcweir     ;
921*cdf0e10cSrcweir /* SELECT STATEMENT */
922*cdf0e10cSrcweir select_statement:
923*cdf0e10cSrcweir 		SQL_TOKEN_SELECT opt_all_distinct selection table_exp
924*cdf0e10cSrcweir 		{
925*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
926*cdf0e10cSrcweir 			$$->append($1);
927*cdf0e10cSrcweir 			$$->append($2);
928*cdf0e10cSrcweir 			$$->append($3);
929*cdf0e10cSrcweir 			$$->append($4);
930*cdf0e10cSrcweir 		}
931*cdf0e10cSrcweir 	;
932*cdf0e10cSrcweir 
933*cdf0e10cSrcweir selection:
934*cdf0e10cSrcweir 		'*'
935*cdf0e10cSrcweir 		{
936*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
937*cdf0e10cSrcweir 			$$->append($1 = newNode("*", SQL_NODE_PUNCTUATION));
938*cdf0e10cSrcweir 		}
939*cdf0e10cSrcweir 	|	scalar_exp_commalist
940*cdf0e10cSrcweir 	;
941*cdf0e10cSrcweir opt_result_offset_clause:
942*cdf0e10cSrcweir 		/* empty */ {$$ = SQL_NEW_RULE;}
943*cdf0e10cSrcweir 	|	result_offset_clause
944*cdf0e10cSrcweir 	;
945*cdf0e10cSrcweir result_offset_clause:
946*cdf0e10cSrcweir 	SQL_TOKEN_OFFSET offset_row_count row_or_rows
947*cdf0e10cSrcweir 	{
948*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
949*cdf0e10cSrcweir 		$$->append($1);
950*cdf0e10cSrcweir 		$$->append($2);
951*cdf0e10cSrcweir 		$$->append($3);
952*cdf0e10cSrcweir 	}
953*cdf0e10cSrcweir 	;
954*cdf0e10cSrcweir opt_fetch_first_row_count:
955*cdf0e10cSrcweir 		/* empty */ {$$ = SQL_NEW_RULE;}
956*cdf0e10cSrcweir 	|	fetch_first_row_count
957*cdf0e10cSrcweir 	;
958*cdf0e10cSrcweir first_or_next:
959*cdf0e10cSrcweir 		SQL_TOKEN_FIRST
960*cdf0e10cSrcweir 	|	SQL_TOKEN_NEXT
961*cdf0e10cSrcweir 	;
962*cdf0e10cSrcweir row_or_rows:
963*cdf0e10cSrcweir 		SQL_TOKEN_ROW
964*cdf0e10cSrcweir 	|	SQL_TOKEN_ROWS
965*cdf0e10cSrcweir 	;
966*cdf0e10cSrcweir opt_fetch_first_clause:
967*cdf0e10cSrcweir 		/* empty */ {$$ = SQL_NEW_RULE;}
968*cdf0e10cSrcweir 	|	fetch_first_clause
969*cdf0e10cSrcweir 	;
970*cdf0e10cSrcweir fetch_first_clause:
971*cdf0e10cSrcweir 	SQL_TOKEN_FETCH first_or_next opt_fetch_first_row_count row_or_rows SQL_TOKEN_ONLY
972*cdf0e10cSrcweir 	{
973*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
974*cdf0e10cSrcweir 		$$->append($1);
975*cdf0e10cSrcweir 		$$->append($2);
976*cdf0e10cSrcweir 		$$->append($3);
977*cdf0e10cSrcweir 		$$->append($4);
978*cdf0e10cSrcweir 		$$->append($5);
979*cdf0e10cSrcweir 	}
980*cdf0e10cSrcweir 	;
981*cdf0e10cSrcweir offset_row_count:
982*cdf0e10cSrcweir 	literal
983*cdf0e10cSrcweir 	;
984*cdf0e10cSrcweir fetch_first_row_count:
985*cdf0e10cSrcweir 	literal
986*cdf0e10cSrcweir 	;
987*cdf0e10cSrcweir 
988*cdf0e10cSrcweir opt_limit_offset_clause:
989*cdf0e10cSrcweir 		/* empty */ {$$ = SQL_NEW_RULE;}
990*cdf0e10cSrcweir 	|	limit_offset_clause
991*cdf0e10cSrcweir 	;
992*cdf0e10cSrcweir opt_offset:
993*cdf0e10cSrcweir 		/* empty */ {$$ = SQL_NEW_RULE;}
994*cdf0e10cSrcweir 	|	SQL_TOKEN_OFFSET SQL_TOKEN_INTNUM
995*cdf0e10cSrcweir 	{
996*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
997*cdf0e10cSrcweir 		$$->append($1);
998*cdf0e10cSrcweir 		$$->append($2);
999*cdf0e10cSrcweir 	}
1000*cdf0e10cSrcweir 	;
1001*cdf0e10cSrcweir limit_offset_clause:
1002*cdf0e10cSrcweir 	SQL_TOKEN_LIMIT SQL_TOKEN_INTNUM opt_offset
1003*cdf0e10cSrcweir 	{
1004*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
1005*cdf0e10cSrcweir 		$$->append($1);
1006*cdf0e10cSrcweir 		$$->append($2);
1007*cdf0e10cSrcweir 		$$->append($3);
1008*cdf0e10cSrcweir 	}
1009*cdf0e10cSrcweir 	;
1010*cdf0e10cSrcweir table_exp:
1011*cdf0e10cSrcweir 		from_clause opt_where_clause opt_group_by_clause opt_having_clause opt_window_clause opt_order_by_clause opt_limit_offset_clause opt_result_offset_clause opt_fetch_first_clause
1012*cdf0e10cSrcweir 		{
1013*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1014*cdf0e10cSrcweir 			$$->append($1);
1015*cdf0e10cSrcweir 			$$->append($2);
1016*cdf0e10cSrcweir 			$$->append($3);
1017*cdf0e10cSrcweir 			$$->append($4);
1018*cdf0e10cSrcweir 			$$->append($5);
1019*cdf0e10cSrcweir 			$$->append($6);
1020*cdf0e10cSrcweir 			$$->append($7);
1021*cdf0e10cSrcweir 			$$->append($8);
1022*cdf0e10cSrcweir 			$$->append($9);
1023*cdf0e10cSrcweir 		}
1024*cdf0e10cSrcweir 	;
1025*cdf0e10cSrcweir 
1026*cdf0e10cSrcweir from_clause:
1027*cdf0e10cSrcweir 		SQL_TOKEN_FROM table_ref_commalist
1028*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
1029*cdf0e10cSrcweir 			$$->append($1);
1030*cdf0e10cSrcweir 			$$->append($2);}
1031*cdf0e10cSrcweir 	;
1032*cdf0e10cSrcweir 
1033*cdf0e10cSrcweir table_ref_commalist:
1034*cdf0e10cSrcweir 
1035*cdf0e10cSrcweir 		table_ref
1036*cdf0e10cSrcweir 			{$$ = SQL_NEW_COMMALISTRULE;
1037*cdf0e10cSrcweir 			$$->append($1);}
1038*cdf0e10cSrcweir 	|       table_ref_commalist ',' table_ref
1039*cdf0e10cSrcweir 			{$1->append($3);
1040*cdf0e10cSrcweir 			$$ = $1;}
1041*cdf0e10cSrcweir 	;
1042*cdf0e10cSrcweir 
1043*cdf0e10cSrcweir opt_as:
1044*cdf0e10cSrcweir 		/* empty */ {$$ = SQL_NEW_RULE;}
1045*cdf0e10cSrcweir 	|	SQL_TOKEN_AS
1046*cdf0e10cSrcweir 	;
1047*cdf0e10cSrcweir opt_row:
1048*cdf0e10cSrcweir 		/* empty */ {$$ = SQL_NEW_RULE;}
1049*cdf0e10cSrcweir 	|	SQL_TOKEN_ROW
1050*cdf0e10cSrcweir 	;
1051*cdf0e10cSrcweir table_primary_as_range_column:
1052*cdf0e10cSrcweir         {$$ = SQL_NEW_RULE;}
1053*cdf0e10cSrcweir 	|   opt_as SQL_TOKEN_NAME op_column_commalist
1054*cdf0e10cSrcweir 		{$$ = SQL_NEW_RULE;
1055*cdf0e10cSrcweir 		    $$->append($1);
1056*cdf0e10cSrcweir 		    $$->append($2);
1057*cdf0e10cSrcweir 			$$->append($3);
1058*cdf0e10cSrcweir 		}
1059*cdf0e10cSrcweir     ;
1060*cdf0e10cSrcweir table_ref:
1061*cdf0e10cSrcweir         table_node table_primary_as_range_column
1062*cdf0e10cSrcweir 		{
1063*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1064*cdf0e10cSrcweir 			$$->append($1);
1065*cdf0e10cSrcweir 			$$->append($2);
1066*cdf0e10cSrcweir 		}
1067*cdf0e10cSrcweir 	|   subquery range_variable op_column_commalist
1068*cdf0e10cSrcweir 		{
1069*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1070*cdf0e10cSrcweir 			$$->append($1);
1071*cdf0e10cSrcweir 			$$->append($2);
1072*cdf0e10cSrcweir 		    $$->append($3);
1073*cdf0e10cSrcweir 		}
1074*cdf0e10cSrcweir 	|	joined_table
1075*cdf0e10cSrcweir 	|	'{' SQL_TOKEN_OJ joined_table '}'
1076*cdf0e10cSrcweir 		{
1077*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1078*cdf0e10cSrcweir 			$$->append($1 = newNode("{", SQL_NODE_PUNCTUATION));
1079*cdf0e10cSrcweir 			$$->append($2);
1080*cdf0e10cSrcweir 			$$->append($3);
1081*cdf0e10cSrcweir 			$$->append($4 = newNode("}", SQL_NODE_PUNCTUATION));
1082*cdf0e10cSrcweir 		}
1083*cdf0e10cSrcweir 	|	'(' joined_table ')'
1084*cdf0e10cSrcweir 		{
1085*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1086*cdf0e10cSrcweir 			$$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
1087*cdf0e10cSrcweir 			$$->append($2);
1088*cdf0e10cSrcweir 			$$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
1089*cdf0e10cSrcweir 		}
1090*cdf0e10cSrcweir 	;
1091*cdf0e10cSrcweir where_clause:
1092*cdf0e10cSrcweir 		SQL_TOKEN_WHERE search_condition
1093*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
1094*cdf0e10cSrcweir 			$$->append($1);
1095*cdf0e10cSrcweir 			$$->append($2);}
1096*cdf0e10cSrcweir 	;
1097*cdf0e10cSrcweir 
1098*cdf0e10cSrcweir opt_group_by_clause:
1099*cdf0e10cSrcweir 		/* empty */      {$$ = SQL_NEW_RULE;}
1100*cdf0e10cSrcweir 	|   SQL_TOKEN_GROUP SQL_TOKEN_BY column_ref_commalist
1101*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
1102*cdf0e10cSrcweir 			$$->append($1);
1103*cdf0e10cSrcweir 			$$->append($2);
1104*cdf0e10cSrcweir 			$$->append($3);}
1105*cdf0e10cSrcweir 	;
1106*cdf0e10cSrcweir 
1107*cdf0e10cSrcweir column_ref_commalist:
1108*cdf0e10cSrcweir 		column_ref
1109*cdf0e10cSrcweir 			{$$ = SQL_NEW_COMMALISTRULE;
1110*cdf0e10cSrcweir 			$$->append($1);}
1111*cdf0e10cSrcweir 	|	set_fct_spec
1112*cdf0e10cSrcweir 		{$$ = SQL_NEW_COMMALISTRULE;
1113*cdf0e10cSrcweir 			$$->append($1);}
1114*cdf0e10cSrcweir 	|   column_ref_commalist ',' column_ref
1115*cdf0e10cSrcweir 			{$1->append($3);
1116*cdf0e10cSrcweir 			$$ = $1;}
1117*cdf0e10cSrcweir 	|   column_ref_commalist ',' set_fct_spec
1118*cdf0e10cSrcweir 			{$1->append($3);
1119*cdf0e10cSrcweir 			$$ = $1;}
1120*cdf0e10cSrcweir 	;
1121*cdf0e10cSrcweir 
1122*cdf0e10cSrcweir opt_having_clause:
1123*cdf0e10cSrcweir 		/* empty */                 {$$ = SQL_NEW_RULE;}
1124*cdf0e10cSrcweir 	|       SQL_TOKEN_HAVING search_condition
1125*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
1126*cdf0e10cSrcweir 			$$->append($1);
1127*cdf0e10cSrcweir 			$$->append($2);}
1128*cdf0e10cSrcweir 	;
1129*cdf0e10cSrcweir 
1130*cdf0e10cSrcweir 	/* search conditions */
1131*cdf0e10cSrcweir truth_value:
1132*cdf0e10cSrcweir 		SQL_TOKEN_TRUE
1133*cdf0e10cSrcweir 	  | SQL_TOKEN_FALSE
1134*cdf0e10cSrcweir 	  | SQL_TOKEN_UNKNOWN
1135*cdf0e10cSrcweir 	  | SQL_TOKEN_NULL
1136*cdf0e10cSrcweir 	  ;
1137*cdf0e10cSrcweir boolean_primary:
1138*cdf0e10cSrcweir 		predicate
1139*cdf0e10cSrcweir 	|   '(' search_condition ')'
1140*cdf0e10cSrcweir 		{ // boolean_primary: rule 2
1141*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1142*cdf0e10cSrcweir 			$$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
1143*cdf0e10cSrcweir 			$$->append($2);
1144*cdf0e10cSrcweir 			$$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
1145*cdf0e10cSrcweir 		}
1146*cdf0e10cSrcweir 	|	row_value_constructor_elem  /*[^')' ',']*/
1147*cdf0e10cSrcweir 		{
1148*cdf0e10cSrcweir     		if(xxx_pGLOBAL_SQLPARSER->inPredicateCheck())// boolean_primary: rule 3
1149*cdf0e10cSrcweir 			{
1150*cdf0e10cSrcweir 			    $$ = SQL_NEW_RULE;
1151*cdf0e10cSrcweir 			    sal_Int16 nErg = xxx_pGLOBAL_SQLPARSER->buildComparsionRule($$,$1);
1152*cdf0e10cSrcweir 			    if(nErg == 1)
1153*cdf0e10cSrcweir 			    {
1154*cdf0e10cSrcweir 				    OSQLParseNode* pTemp = $$;
1155*cdf0e10cSrcweir 				    $$ = pTemp->removeAt((sal_uInt32)0);
1156*cdf0e10cSrcweir 				    delete pTemp;
1157*cdf0e10cSrcweir 			    }
1158*cdf0e10cSrcweir 			    else
1159*cdf0e10cSrcweir 			    {
1160*cdf0e10cSrcweir 				    delete $$;
1161*cdf0e10cSrcweir 				    if(nErg)
1162*cdf0e10cSrcweir 					    YYERROR;
1163*cdf0e10cSrcweir 				    else
1164*cdf0e10cSrcweir 					    YYABORT;
1165*cdf0e10cSrcweir 			    }
1166*cdf0e10cSrcweir 			}
1167*cdf0e10cSrcweir 			else
1168*cdf0e10cSrcweir 				YYERROR;
1169*cdf0e10cSrcweir 		}
1170*cdf0e10cSrcweir 	;
1171*cdf0e10cSrcweir parenthesized_boolean_value_expression:
1172*cdf0e10cSrcweir    '(' search_condition ')'
1173*cdf0e10cSrcweir 	{ // boolean_primary: rule 2
1174*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
1175*cdf0e10cSrcweir 		$$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
1176*cdf0e10cSrcweir 		$$->append($2);
1177*cdf0e10cSrcweir 		$$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
1178*cdf0e10cSrcweir 	}
1179*cdf0e10cSrcweir 	;
1180*cdf0e10cSrcweir boolean_test:
1181*cdf0e10cSrcweir 		boolean_primary
1182*cdf0e10cSrcweir 	|	boolean_primary SQL_TOKEN_IS sql_not truth_value
1183*cdf0e10cSrcweir 		{
1184*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1185*cdf0e10cSrcweir 			$$->append($1);
1186*cdf0e10cSrcweir 			$$->append($2);
1187*cdf0e10cSrcweir 			$$->append($3);
1188*cdf0e10cSrcweir 			$$->append($4);
1189*cdf0e10cSrcweir 		}
1190*cdf0e10cSrcweir 	;
1191*cdf0e10cSrcweir boolean_factor:
1192*cdf0e10cSrcweir         boolean_test
1193*cdf0e10cSrcweir 	|   SQL_TOKEN_NOT boolean_test
1194*cdf0e10cSrcweir 		{ // boolean_factor: rule 1
1195*cdf0e10cSrcweir 		    $$ = SQL_NEW_RULE;
1196*cdf0e10cSrcweir 		    $$->append($1);
1197*cdf0e10cSrcweir 		    $$->append($2);
1198*cdf0e10cSrcweir 		}
1199*cdf0e10cSrcweir 	;
1200*cdf0e10cSrcweir boolean_term:
1201*cdf0e10cSrcweir 		boolean_factor
1202*cdf0e10cSrcweir 	|	boolean_term SQL_TOKEN_AND boolean_factor
1203*cdf0e10cSrcweir 		{
1204*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE; // boolean_term: rule 1
1205*cdf0e10cSrcweir 			$$->append($1);
1206*cdf0e10cSrcweir 			$$->append($2);
1207*cdf0e10cSrcweir 			$$->append($3);
1208*cdf0e10cSrcweir 		}
1209*cdf0e10cSrcweir 	;
1210*cdf0e10cSrcweir search_condition:
1211*cdf0e10cSrcweir 		boolean_term
1212*cdf0e10cSrcweir 	|	search_condition SQL_TOKEN_OR boolean_term
1213*cdf0e10cSrcweir 		{
1214*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE; // search_condition
1215*cdf0e10cSrcweir 			$$->append($1);
1216*cdf0e10cSrcweir 			$$->append($2);
1217*cdf0e10cSrcweir 			$$->append($3);
1218*cdf0e10cSrcweir 		}
1219*cdf0e10cSrcweir 	;
1220*cdf0e10cSrcweir predicate:
1221*cdf0e10cSrcweir 		comparison_predicate
1222*cdf0e10cSrcweir 	|       between_predicate
1223*cdf0e10cSrcweir 	|       all_or_any_predicate
1224*cdf0e10cSrcweir 	|       existence_test
1225*cdf0e10cSrcweir 	|		unique_test
1226*cdf0e10cSrcweir 	|		test_for_null
1227*cdf0e10cSrcweir 	|       in_predicate
1228*cdf0e10cSrcweir 	|       like_predicate
1229*cdf0e10cSrcweir 	;
1230*cdf0e10cSrcweir comparison_predicate_part_2:
1231*cdf0e10cSrcweir 		comparison row_value_constructor
1232*cdf0e10cSrcweir 		{
1233*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE; // comparison_predicate: rule 1
1234*cdf0e10cSrcweir 			$$->append($1);
1235*cdf0e10cSrcweir 			$$->append($2);
1236*cdf0e10cSrcweir 		}
1237*cdf0e10cSrcweir comparison_predicate:
1238*cdf0e10cSrcweir 		row_value_constructor comparison row_value_constructor
1239*cdf0e10cSrcweir 		{
1240*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE; // comparison_predicate: rule 1
1241*cdf0e10cSrcweir 			$$->append($1);
1242*cdf0e10cSrcweir 			$$->append($2);
1243*cdf0e10cSrcweir 			$$->append($3);
1244*cdf0e10cSrcweir 		}
1245*cdf0e10cSrcweir 	|	comparison row_value_constructor
1246*cdf0e10cSrcweir 		{
1247*cdf0e10cSrcweir 			if(xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) // comparison_predicate: rule 2
1248*cdf0e10cSrcweir 			{
1249*cdf0e10cSrcweir 				$$ = SQL_NEW_RULE;
1250*cdf0e10cSrcweir 				sal_Int16 nErg = xxx_pGLOBAL_SQLPARSER->buildPredicateRule($$,$2,$1);
1251*cdf0e10cSrcweir 				if(nErg == 1)
1252*cdf0e10cSrcweir 				{
1253*cdf0e10cSrcweir 					OSQLParseNode* pTemp = $$;
1254*cdf0e10cSrcweir 					$$ = pTemp->removeAt((sal_uInt32)0);
1255*cdf0e10cSrcweir 					delete pTemp;
1256*cdf0e10cSrcweir 				}
1257*cdf0e10cSrcweir 				else
1258*cdf0e10cSrcweir 				{
1259*cdf0e10cSrcweir 					delete $$;
1260*cdf0e10cSrcweir 					YYABORT;
1261*cdf0e10cSrcweir 				}
1262*cdf0e10cSrcweir 			}
1263*cdf0e10cSrcweir 			else
1264*cdf0e10cSrcweir 			{
1265*cdf0e10cSrcweir 				YYERROR;
1266*cdf0e10cSrcweir 			}
1267*cdf0e10cSrcweir 		}
1268*cdf0e10cSrcweir 	;
1269*cdf0e10cSrcweir comparison:
1270*cdf0e10cSrcweir 		SQL_LESS
1271*cdf0e10cSrcweir 	  | SQL_NOTEQUAL
1272*cdf0e10cSrcweir 	  | SQL_EQUAL
1273*cdf0e10cSrcweir 	  | SQL_GREAT
1274*cdf0e10cSrcweir 	  | SQL_LESSEQ
1275*cdf0e10cSrcweir 	  | SQL_GREATEQ
1276*cdf0e10cSrcweir 	;
1277*cdf0e10cSrcweir between_predicate_part_2:
1278*cdf0e10cSrcweir 	sql_not SQL_TOKEN_BETWEEN row_value_constructor SQL_TOKEN_AND row_value_constructor
1279*cdf0e10cSrcweir 		{
1280*cdf0e10cSrcweir 			if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) // between_predicate: rule 2
1281*cdf0e10cSrcweir 			{
1282*cdf0e10cSrcweir 				$$ = SQL_NEW_RULE;
1283*cdf0e10cSrcweir 
1284*cdf0e10cSrcweir 				sal_Int16 nErg = xxx_pGLOBAL_SQLPARSER->buildPredicateRule($$,$3,$2,$5);
1285*cdf0e10cSrcweir 				if(nErg == 1)
1286*cdf0e10cSrcweir 				{
1287*cdf0e10cSrcweir 					OSQLParseNode* pTemp = $$;
1288*cdf0e10cSrcweir 					$$ = pTemp->removeAt((sal_uInt32)0);
1289*cdf0e10cSrcweir 					OSQLParseNode* pColumnRef = $$->removeAt((sal_uInt32)0);
1290*cdf0e10cSrcweir 					$$->insert(0,$1);
1291*cdf0e10cSrcweir 					OSQLParseNode* pBetween_predicate = new OSQLInternalNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::between_predicate));
1292*cdf0e10cSrcweir 					pBetween_predicate->append(pColumnRef);
1293*cdf0e10cSrcweir 					pBetween_predicate->append($$);
1294*cdf0e10cSrcweir 					$$ = pBetween_predicate;
1295*cdf0e10cSrcweir 
1296*cdf0e10cSrcweir 					delete pTemp;
1297*cdf0e10cSrcweir 					delete $4;
1298*cdf0e10cSrcweir 				}
1299*cdf0e10cSrcweir 				else
1300*cdf0e10cSrcweir 				{
1301*cdf0e10cSrcweir 					delete $$;
1302*cdf0e10cSrcweir 					YYABORT;
1303*cdf0e10cSrcweir 				}
1304*cdf0e10cSrcweir 			}
1305*cdf0e10cSrcweir 			else
1306*cdf0e10cSrcweir 			{
1307*cdf0e10cSrcweir 				$$ = SQL_NEW_RULE; // between_predicate: rule 1
1308*cdf0e10cSrcweir 				$$->append($1);
1309*cdf0e10cSrcweir 				$$->append($2);
1310*cdf0e10cSrcweir 				$$->append($3);
1311*cdf0e10cSrcweir 				$$->append($4);
1312*cdf0e10cSrcweir 				$$->append($5);
1313*cdf0e10cSrcweir 			}
1314*cdf0e10cSrcweir 		}
1315*cdf0e10cSrcweir between_predicate:
1316*cdf0e10cSrcweir 		row_value_constructor between_predicate_part_2
1317*cdf0e10cSrcweir 		{
1318*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE; // between_predicate: rule 1
1319*cdf0e10cSrcweir 			$$->append($1);
1320*cdf0e10cSrcweir 			$$->append($2);
1321*cdf0e10cSrcweir 		}
1322*cdf0e10cSrcweir 	|	between_predicate_part_2
1323*cdf0e10cSrcweir 	;
1324*cdf0e10cSrcweir character_like_predicate_part_2:
1325*cdf0e10cSrcweir 	sql_not SQL_TOKEN_LIKE string_value_exp opt_escape
1326*cdf0e10cSrcweir 		{
1327*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE; // like_predicate: rule 1
1328*cdf0e10cSrcweir 			$$->append($1);
1329*cdf0e10cSrcweir 			$$->append($2);
1330*cdf0e10cSrcweir 			$$->append($3);
1331*cdf0e10cSrcweir 			$$->append($4);
1332*cdf0e10cSrcweir 		}
1333*cdf0e10cSrcweir 	;
1334*cdf0e10cSrcweir other_like_predicate_part_2:
1335*cdf0e10cSrcweir 	sql_not SQL_TOKEN_LIKE value_exp_primary opt_escape
1336*cdf0e10cSrcweir 		{
1337*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE; // like_predicate: rule 1
1338*cdf0e10cSrcweir 			$$->append($1);
1339*cdf0e10cSrcweir 			$$->append($2);
1340*cdf0e10cSrcweir 			$$->append($3);
1341*cdf0e10cSrcweir 			$$->append($4);
1342*cdf0e10cSrcweir 		}
1343*cdf0e10cSrcweir 	;
1344*cdf0e10cSrcweir like_predicate:
1345*cdf0e10cSrcweir 		row_value_constructor character_like_predicate_part_2
1346*cdf0e10cSrcweir 		{
1347*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE; // like_predicate: rule 1
1348*cdf0e10cSrcweir 			$$->append($1);
1349*cdf0e10cSrcweir 			$$->append($2);
1350*cdf0e10cSrcweir 		}
1351*cdf0e10cSrcweir 	|	row_value_constructor other_like_predicate_part_2
1352*cdf0e10cSrcweir 		{
1353*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;  // like_predicate: rule 3
1354*cdf0e10cSrcweir 			$$->append($1);
1355*cdf0e10cSrcweir 			$$->append($2);
1356*cdf0e10cSrcweir 		}
1357*cdf0e10cSrcweir 	|	character_like_predicate_part_2
1358*cdf0e10cSrcweir 		{
1359*cdf0e10cSrcweir 			if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())  // like_predicate: rule 5
1360*cdf0e10cSrcweir 			{
1361*cdf0e10cSrcweir 				OSQLParseNode* pColumnRef = newNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref));
1362*cdf0e10cSrcweir 				pColumnRef->append(newNode(xxx_pGLOBAL_SQLPARSER->getFieldName(),SQL_NODE_NAME));
1363*cdf0e10cSrcweir 
1364*cdf0e10cSrcweir 				$$ = SQL_NEW_RULE;
1365*cdf0e10cSrcweir 				$$->append(pColumnRef);
1366*cdf0e10cSrcweir 				$$->append($1);
1367*cdf0e10cSrcweir 				OSQLParseNode* p2nd = $1->removeAt(2);
1368*cdf0e10cSrcweir 				OSQLParseNode* p3rd = $1->removeAt(2);
1369*cdf0e10cSrcweir 				if ( !xxx_pGLOBAL_SQLPARSER->buildLikeRule($1,p2nd,p3rd) )
1370*cdf0e10cSrcweir 				{
1371*cdf0e10cSrcweir 					delete $$;
1372*cdf0e10cSrcweir 					YYABORT;
1373*cdf0e10cSrcweir 				}
1374*cdf0e10cSrcweir 				$1->append(p3rd);
1375*cdf0e10cSrcweir 			}
1376*cdf0e10cSrcweir 			else
1377*cdf0e10cSrcweir 				YYERROR;
1378*cdf0e10cSrcweir 		}
1379*cdf0e10cSrcweir 	|	other_like_predicate_part_2
1380*cdf0e10cSrcweir 		{
1381*cdf0e10cSrcweir 			if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) // like_predicate: rule 6
1382*cdf0e10cSrcweir 			{
1383*cdf0e10cSrcweir 				OSQLParseNode* pColumnRef = newNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref));
1384*cdf0e10cSrcweir 				pColumnRef->append(newNode(xxx_pGLOBAL_SQLPARSER->getFieldName(),SQL_NODE_NAME));
1385*cdf0e10cSrcweir 
1386*cdf0e10cSrcweir 				$$ = SQL_NEW_RULE;
1387*cdf0e10cSrcweir 				$$->append(pColumnRef);
1388*cdf0e10cSrcweir 				$$->append($1);
1389*cdf0e10cSrcweir 				OSQLParseNode* p2nd = $1->removeAt(2);
1390*cdf0e10cSrcweir 				OSQLParseNode* p3rd = $1->removeAt(2);
1391*cdf0e10cSrcweir 				if ( !xxx_pGLOBAL_SQLPARSER->buildLikeRule($1,p2nd,p3rd) )
1392*cdf0e10cSrcweir 				{
1393*cdf0e10cSrcweir 					delete $$;
1394*cdf0e10cSrcweir 					YYABORT;
1395*cdf0e10cSrcweir 				}
1396*cdf0e10cSrcweir 				$1->append(p3rd);
1397*cdf0e10cSrcweir 			}
1398*cdf0e10cSrcweir 			else
1399*cdf0e10cSrcweir 				YYERROR;
1400*cdf0e10cSrcweir 		}
1401*cdf0e10cSrcweir 	;
1402*cdf0e10cSrcweir 
1403*cdf0e10cSrcweir opt_escape:
1404*cdf0e10cSrcweir 		/* empty */                 {$$ = SQL_NEW_RULE;}
1405*cdf0e10cSrcweir 	|   SQL_TOKEN_ESCAPE string_value_exp
1406*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
1407*cdf0e10cSrcweir 			$$->append($1);
1408*cdf0e10cSrcweir 			$$->append($2);}
1409*cdf0e10cSrcweir 	|	'{' SQL_TOKEN_ESCAPE SQL_TOKEN_STRING '}'
1410*cdf0e10cSrcweir 		{
1411*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1412*cdf0e10cSrcweir 			$$->append($1 = newNode("{", SQL_NODE_PUNCTUATION));
1413*cdf0e10cSrcweir 			$$->append($2);
1414*cdf0e10cSrcweir 			$$->append($3);
1415*cdf0e10cSrcweir 			$$->append($4 = newNode("}", SQL_NODE_PUNCTUATION));
1416*cdf0e10cSrcweir 		}
1417*cdf0e10cSrcweir 	;
1418*cdf0e10cSrcweir 
1419*cdf0e10cSrcweir null_predicate_part_2:
1420*cdf0e10cSrcweir 	SQL_TOKEN_IS sql_not SQL_TOKEN_NULL
1421*cdf0e10cSrcweir 	{
1422*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE; // test_for_null: rule 1
1423*cdf0e10cSrcweir 		$$->append($1);
1424*cdf0e10cSrcweir 		$$->append($2);
1425*cdf0e10cSrcweir 		$$->append($3);
1426*cdf0e10cSrcweir 	}
1427*cdf0e10cSrcweir 	;
1428*cdf0e10cSrcweir test_for_null:
1429*cdf0e10cSrcweir 		row_value_constructor null_predicate_part_2
1430*cdf0e10cSrcweir 		{
1431*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE; // test_for_null: rule 1
1432*cdf0e10cSrcweir 			$$->append($1);
1433*cdf0e10cSrcweir 			$$->append($2);
1434*cdf0e10cSrcweir 		}
1435*cdf0e10cSrcweir 	|	null_predicate_part_2
1436*cdf0e10cSrcweir 		{
1437*cdf0e10cSrcweir 			if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())// test_for_null: rule 2
1438*cdf0e10cSrcweir 			{
1439*cdf0e10cSrcweir 				OSQLParseNode* pColumnRef = newNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref));
1440*cdf0e10cSrcweir 				pColumnRef->append(newNode(xxx_pGLOBAL_SQLPARSER->getFieldName(),SQL_NODE_NAME));
1441*cdf0e10cSrcweir 
1442*cdf0e10cSrcweir 				$$ = SQL_NEW_RULE;
1443*cdf0e10cSrcweir 				$$->append(pColumnRef);
1444*cdf0e10cSrcweir 				$$->append($1);
1445*cdf0e10cSrcweir 			}
1446*cdf0e10cSrcweir 			else
1447*cdf0e10cSrcweir 				YYERROR;
1448*cdf0e10cSrcweir 		}
1449*cdf0e10cSrcweir 	;
1450*cdf0e10cSrcweir in_predicate_value:
1451*cdf0e10cSrcweir 		subquery
1452*cdf0e10cSrcweir 		{$$ = SQL_NEW_RULE;
1453*cdf0e10cSrcweir 			$$->append($1);
1454*cdf0e10cSrcweir 		}
1455*cdf0e10cSrcweir 	  | '(' value_exp_commalist ')'
1456*cdf0e10cSrcweir 		{$$ = SQL_NEW_RULE;
1457*cdf0e10cSrcweir 			$$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
1458*cdf0e10cSrcweir 			$$->append($2);
1459*cdf0e10cSrcweir 			$$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
1460*cdf0e10cSrcweir 		}
1461*cdf0e10cSrcweir 	;
1462*cdf0e10cSrcweir in_predicate_part_2:
1463*cdf0e10cSrcweir 	sql_not SQL_TOKEN_IN in_predicate_value
1464*cdf0e10cSrcweir 	{
1465*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;// in_predicate: rule 1
1466*cdf0e10cSrcweir 		$$->append($1);
1467*cdf0e10cSrcweir 		$$->append($2);
1468*cdf0e10cSrcweir 		$$->append($3);
1469*cdf0e10cSrcweir 	}
1470*cdf0e10cSrcweir 	;
1471*cdf0e10cSrcweir in_predicate:
1472*cdf0e10cSrcweir 		row_value_constructor in_predicate_part_2
1473*cdf0e10cSrcweir 		{
1474*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;// in_predicate: rule 1
1475*cdf0e10cSrcweir 			$$->append($1);
1476*cdf0e10cSrcweir 			$$->append($2);
1477*cdf0e10cSrcweir 		}
1478*cdf0e10cSrcweir 	|	in_predicate_part_2
1479*cdf0e10cSrcweir 		{
1480*cdf0e10cSrcweir 			if ( xxx_pGLOBAL_SQLPARSER->inPredicateCheck() )// in_predicate: rule 2
1481*cdf0e10cSrcweir 			{
1482*cdf0e10cSrcweir 				OSQLParseNode* pColumnRef = newNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref));
1483*cdf0e10cSrcweir 				pColumnRef->append(newNode(xxx_pGLOBAL_SQLPARSER->getFieldName(),SQL_NODE_NAME));
1484*cdf0e10cSrcweir 
1485*cdf0e10cSrcweir 				$$ = SQL_NEW_RULE;
1486*cdf0e10cSrcweir 				$$->append(pColumnRef);
1487*cdf0e10cSrcweir 				$$->append($1);
1488*cdf0e10cSrcweir 			}
1489*cdf0e10cSrcweir 			else
1490*cdf0e10cSrcweir 				YYERROR;
1491*cdf0e10cSrcweir 		}
1492*cdf0e10cSrcweir 	;
1493*cdf0e10cSrcweir quantified_comparison_predicate_part_2:
1494*cdf0e10cSrcweir 	comparison any_all_some subquery
1495*cdf0e10cSrcweir 	{
1496*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
1497*cdf0e10cSrcweir 		$$->append($1);
1498*cdf0e10cSrcweir 		$$->append($2);
1499*cdf0e10cSrcweir 		$$->append($3);
1500*cdf0e10cSrcweir 	}
1501*cdf0e10cSrcweir 	;
1502*cdf0e10cSrcweir all_or_any_predicate:
1503*cdf0e10cSrcweir 		row_value_constructor quantified_comparison_predicate_part_2
1504*cdf0e10cSrcweir 		{
1505*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1506*cdf0e10cSrcweir 			$$->append($1);
1507*cdf0e10cSrcweir 			$$->append($2);
1508*cdf0e10cSrcweir 		}
1509*cdf0e10cSrcweir 	|	quantified_comparison_predicate_part_2
1510*cdf0e10cSrcweir 		{
1511*cdf0e10cSrcweir 			if(xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
1512*cdf0e10cSrcweir 			{
1513*cdf0e10cSrcweir 				OSQLParseNode* pColumnRef = newNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref));
1514*cdf0e10cSrcweir 				pColumnRef->append(newNode(xxx_pGLOBAL_SQLPARSER->getFieldName(),SQL_NODE_NAME));
1515*cdf0e10cSrcweir 
1516*cdf0e10cSrcweir 				$$ = SQL_NEW_RULE;
1517*cdf0e10cSrcweir 				$$->append(pColumnRef);
1518*cdf0e10cSrcweir 				$$->append($1);
1519*cdf0e10cSrcweir 			}
1520*cdf0e10cSrcweir 			else
1521*cdf0e10cSrcweir 				YYERROR;
1522*cdf0e10cSrcweir 		}
1523*cdf0e10cSrcweir 	;
1524*cdf0e10cSrcweir 
1525*cdf0e10cSrcweir any_all_some:
1526*cdf0e10cSrcweir 			SQL_TOKEN_ANY
1527*cdf0e10cSrcweir 	|       SQL_TOKEN_ALL
1528*cdf0e10cSrcweir 	|       SQL_TOKEN_SOME
1529*cdf0e10cSrcweir 	;
1530*cdf0e10cSrcweir 
1531*cdf0e10cSrcweir existence_test:
1532*cdf0e10cSrcweir 		SQL_TOKEN_EXISTS subquery
1533*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
1534*cdf0e10cSrcweir 			$$->append($1);
1535*cdf0e10cSrcweir 			$$->append($2);}
1536*cdf0e10cSrcweir 	;
1537*cdf0e10cSrcweir unique_test:
1538*cdf0e10cSrcweir 		SQL_TOKEN_UNIQUE subquery
1539*cdf0e10cSrcweir 		{$$ = SQL_NEW_RULE;
1540*cdf0e10cSrcweir 			$$->append($1);
1541*cdf0e10cSrcweir 			$$->append($2);}
1542*cdf0e10cSrcweir 	;
1543*cdf0e10cSrcweir subquery:
1544*cdf0e10cSrcweir 		'(' query_exp ')'
1545*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
1546*cdf0e10cSrcweir 			$$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
1547*cdf0e10cSrcweir 			$$->append($2);
1548*cdf0e10cSrcweir 			$$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));}
1549*cdf0e10cSrcweir 	;
1550*cdf0e10cSrcweir 
1551*cdf0e10cSrcweir 	/* scalar expressions */
1552*cdf0e10cSrcweir scalar_exp_commalist:
1553*cdf0e10cSrcweir 		select_sublist
1554*cdf0e10cSrcweir 		{
1555*cdf0e10cSrcweir 			$$ = SQL_NEW_COMMALISTRULE;
1556*cdf0e10cSrcweir 			$$->append($1);
1557*cdf0e10cSrcweir 		}
1558*cdf0e10cSrcweir 	|   scalar_exp_commalist ',' select_sublist
1559*cdf0e10cSrcweir 		{
1560*cdf0e10cSrcweir 			$1->append($3);
1561*cdf0e10cSrcweir 			$$ = $1;
1562*cdf0e10cSrcweir 		}
1563*cdf0e10cSrcweir 	;
1564*cdf0e10cSrcweir select_sublist:
1565*cdf0e10cSrcweir /*		table_node '.' '*'
1566*cdf0e10cSrcweir 		{
1567*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1568*cdf0e10cSrcweir 			$$->append($1);
1569*cdf0e10cSrcweir 			$$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
1570*cdf0e10cSrcweir 			$$->append($3 = newNode("*", SQL_NODE_PUNCTUATION));
1571*cdf0e10cSrcweir 		}
1572*cdf0e10cSrcweir */
1573*cdf0e10cSrcweir 		derived_column
1574*cdf0e10cSrcweir 
1575*cdf0e10cSrcweir 	;
1576*cdf0e10cSrcweir 
1577*cdf0e10cSrcweir parameter_ref:
1578*cdf0e10cSrcweir 		parameter
1579*cdf0e10cSrcweir 	;
1580*cdf0e10cSrcweir 
1581*cdf0e10cSrcweir /*
1582*cdf0e10cSrcweir op_like:
1583*cdf0e10cSrcweir 		'*'
1584*cdf0e10cSrcweir 		{
1585*cdf0e10cSrcweir 			$$ = newNode("*", SQL_NODE_PUNCTUATION);
1586*cdf0e10cSrcweir 		}
1587*cdf0e10cSrcweir 	|	'?'
1588*cdf0e10cSrcweir 		{
1589*cdf0e10cSrcweir 			$$ = newNode("?", SQL_NODE_PUNCTUATION);
1590*cdf0e10cSrcweir 		}
1591*cdf0e10cSrcweir 	|   op_like	'*'
1592*cdf0e10cSrcweir 		{
1593*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1594*cdf0e10cSrcweir 			$$->append($1);
1595*cdf0e10cSrcweir 			$$->append($2 = newNode("*", SQL_NODE_PUNCTUATION));
1596*cdf0e10cSrcweir 			xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_False);
1597*cdf0e10cSrcweir 		}
1598*cdf0e10cSrcweir 	|	op_like '?'
1599*cdf0e10cSrcweir 		{
1600*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1601*cdf0e10cSrcweir 			$$->append($1);
1602*cdf0e10cSrcweir 			$$->append($2 = newNode("?", SQL_NODE_PUNCTUATION));
1603*cdf0e10cSrcweir 			xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_False);
1604*cdf0e10cSrcweir 		}
1605*cdf0e10cSrcweir 	;
1606*cdf0e10cSrcweir */
1607*cdf0e10cSrcweir 
1608*cdf0e10cSrcweir literal:
1609*cdf0e10cSrcweir /*		SQL_TOKEN_STRING
1610*cdf0e10cSrcweir 	|   */SQL_TOKEN_INT
1611*cdf0e10cSrcweir 	|   SQL_TOKEN_REAL_NUM
1612*cdf0e10cSrcweir 	|   SQL_TOKEN_INTNUM
1613*cdf0e10cSrcweir 	|   SQL_TOKEN_APPROXNUM
1614*cdf0e10cSrcweir 	|	SQL_TOKEN_ACCESS_DATE
1615*cdf0e10cSrcweir /*	rules for predicate check */
1616*cdf0e10cSrcweir 	|	literal SQL_TOKEN_STRING
1617*cdf0e10cSrcweir 		{
1618*cdf0e10cSrcweir 			if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
1619*cdf0e10cSrcweir 			{
1620*cdf0e10cSrcweir 				$$ = SQL_NEW_RULE;
1621*cdf0e10cSrcweir 				$$->append($1);
1622*cdf0e10cSrcweir 				$$->append($2);
1623*cdf0e10cSrcweir 				xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_True);
1624*cdf0e10cSrcweir 			}
1625*cdf0e10cSrcweir 			else
1626*cdf0e10cSrcweir 				YYERROR;
1627*cdf0e10cSrcweir 		}
1628*cdf0e10cSrcweir 	|	literal SQL_TOKEN_INT
1629*cdf0e10cSrcweir 		{
1630*cdf0e10cSrcweir 			if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
1631*cdf0e10cSrcweir 			{
1632*cdf0e10cSrcweir 				$$ = SQL_NEW_RULE;
1633*cdf0e10cSrcweir 				$$->append($1);
1634*cdf0e10cSrcweir 				$$->append($2);
1635*cdf0e10cSrcweir 				xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_True);
1636*cdf0e10cSrcweir 			}
1637*cdf0e10cSrcweir 			else
1638*cdf0e10cSrcweir 				YYERROR;
1639*cdf0e10cSrcweir 		}
1640*cdf0e10cSrcweir 	|	literal SQL_TOKEN_REAL_NUM
1641*cdf0e10cSrcweir 		{
1642*cdf0e10cSrcweir 			if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
1643*cdf0e10cSrcweir 			{
1644*cdf0e10cSrcweir 				$$ = SQL_NEW_RULE;
1645*cdf0e10cSrcweir 				$$->append($1);
1646*cdf0e10cSrcweir 				$$->append($2);
1647*cdf0e10cSrcweir 				xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_True);
1648*cdf0e10cSrcweir 			}
1649*cdf0e10cSrcweir 			else
1650*cdf0e10cSrcweir 				YYERROR;
1651*cdf0e10cSrcweir 		}
1652*cdf0e10cSrcweir 	|	literal SQL_TOKEN_APPROXNUM
1653*cdf0e10cSrcweir 		{
1654*cdf0e10cSrcweir 			if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
1655*cdf0e10cSrcweir 			{
1656*cdf0e10cSrcweir 				$$ = SQL_NEW_RULE;
1657*cdf0e10cSrcweir 				$$->append($1);
1658*cdf0e10cSrcweir 				$$->append($2);
1659*cdf0e10cSrcweir 				xxx_pGLOBAL_SQLPARSER->reduceLiteral($$, sal_True);
1660*cdf0e10cSrcweir 			}
1661*cdf0e10cSrcweir 			else
1662*cdf0e10cSrcweir 				YYERROR;
1663*cdf0e10cSrcweir 		}
1664*cdf0e10cSrcweir 	;
1665*cdf0e10cSrcweir 
1666*cdf0e10cSrcweir 	/* miscellaneous */
1667*cdf0e10cSrcweir as_clause:
1668*cdf0e10cSrcweir 		/* empty */ {$$ = SQL_NEW_RULE;}
1669*cdf0e10cSrcweir 	|	SQL_TOKEN_AS column
1670*cdf0e10cSrcweir 		{
1671*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1672*cdf0e10cSrcweir 			$$->append($1);
1673*cdf0e10cSrcweir 			$$->append($2);
1674*cdf0e10cSrcweir 		}
1675*cdf0e10cSrcweir 	|	column
1676*cdf0e10cSrcweir 	;
1677*cdf0e10cSrcweir position_exp:
1678*cdf0e10cSrcweir 		SQL_TOKEN_POSITION '(' value_exp SQL_TOKEN_IN value_exp ')'
1679*cdf0e10cSrcweir 		{
1680*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1681*cdf0e10cSrcweir 			$$->append($1);
1682*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1683*cdf0e10cSrcweir 			$$->append($3);
1684*cdf0e10cSrcweir 			$$->append($4);
1685*cdf0e10cSrcweir 			$$->append($5);
1686*cdf0e10cSrcweir 			$$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
1687*cdf0e10cSrcweir 		}
1688*cdf0e10cSrcweir 	|	SQL_TOKEN_POSITION '(' value_exp_commalist ')'
1689*cdf0e10cSrcweir 		{
1690*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1691*cdf0e10cSrcweir 			$$->append($1);
1692*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1693*cdf0e10cSrcweir 			$$->append($3);
1694*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1695*cdf0e10cSrcweir 		}
1696*cdf0e10cSrcweir 	;
1697*cdf0e10cSrcweir num_value_fct:
1698*cdf0e10cSrcweir 		position_exp
1699*cdf0e10cSrcweir 	|	extract_exp
1700*cdf0e10cSrcweir 	|	length_exp
1701*cdf0e10cSrcweir 	;
1702*cdf0e10cSrcweir char_length_exp:
1703*cdf0e10cSrcweir 		SQL_TOKEN_CHAR_LENGTH '(' value_exp ')'
1704*cdf0e10cSrcweir 		{
1705*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1706*cdf0e10cSrcweir 			$$->append($1);
1707*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1708*cdf0e10cSrcweir 			$$->append($3);
1709*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1710*cdf0e10cSrcweir 		}
1711*cdf0e10cSrcweir 	|	SQL_TOKEN_SQL_TOKEN_INTNUM '(' value_exp ')'
1712*cdf0e10cSrcweir 		{
1713*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1714*cdf0e10cSrcweir 			$$->append($1);
1715*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1716*cdf0e10cSrcweir 			$$->append($3);
1717*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1718*cdf0e10cSrcweir 		}
1719*cdf0e10cSrcweir 
1720*cdf0e10cSrcweir 	;
1721*cdf0e10cSrcweir octet_length_exp:
1722*cdf0e10cSrcweir 		SQL_TOKEN_OCTET_LENGTH '(' value_exp ')'
1723*cdf0e10cSrcweir 		{
1724*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1725*cdf0e10cSrcweir 			$$->append($1);
1726*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1727*cdf0e10cSrcweir 			$$->append($3);
1728*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1729*cdf0e10cSrcweir 		}
1730*cdf0e10cSrcweir 	;
1731*cdf0e10cSrcweir bit_length_exp:
1732*cdf0e10cSrcweir 		SQL_TOKEN_BIT_LENGTH '(' value_exp ')'
1733*cdf0e10cSrcweir 		{
1734*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1735*cdf0e10cSrcweir 			$$->append($1);
1736*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1737*cdf0e10cSrcweir 			$$->append($3);
1738*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1739*cdf0e10cSrcweir 		}
1740*cdf0e10cSrcweir 	;
1741*cdf0e10cSrcweir length_exp:
1742*cdf0e10cSrcweir 		char_length_exp
1743*cdf0e10cSrcweir 		{
1744*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1745*cdf0e10cSrcweir 			$$->append($1);
1746*cdf0e10cSrcweir 		}
1747*cdf0e10cSrcweir 	  | octet_length_exp
1748*cdf0e10cSrcweir 		{
1749*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1750*cdf0e10cSrcweir 			$$->append($1);
1751*cdf0e10cSrcweir 		}
1752*cdf0e10cSrcweir 	  | bit_length_exp
1753*cdf0e10cSrcweir 		{
1754*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1755*cdf0e10cSrcweir 			$$->append($1);
1756*cdf0e10cSrcweir 		}
1757*cdf0e10cSrcweir 	;
1758*cdf0e10cSrcweir datetime_field:
1759*cdf0e10cSrcweir 		non_second_datetime_field
1760*cdf0e10cSrcweir 		{
1761*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1762*cdf0e10cSrcweir 			$$->append($1);
1763*cdf0e10cSrcweir 		}
1764*cdf0e10cSrcweir 	  | SQL_TOKEN_SECOND
1765*cdf0e10cSrcweir 		{
1766*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1767*cdf0e10cSrcweir 			$$->append($1);
1768*cdf0e10cSrcweir 		}
1769*cdf0e10cSrcweir 	;
1770*cdf0e10cSrcweir extract_field:
1771*cdf0e10cSrcweir 	   time_zone_field
1772*cdf0e10cSrcweir 	  | datetime_field
1773*cdf0e10cSrcweir 	  |	value_exp
1774*cdf0e10cSrcweir 	;
1775*cdf0e10cSrcweir time_zone_field:
1776*cdf0e10cSrcweir 		SQL_TOKEN_TIMEZONE_HOUR
1777*cdf0e10cSrcweir 		{
1778*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1779*cdf0e10cSrcweir 			$$->append($1);
1780*cdf0e10cSrcweir 		}
1781*cdf0e10cSrcweir 	  | SQL_TOKEN_TIMEZONE_MINUTE
1782*cdf0e10cSrcweir 		{
1783*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1784*cdf0e10cSrcweir 			$$->append($1);
1785*cdf0e10cSrcweir 		}
1786*cdf0e10cSrcweir 	;
1787*cdf0e10cSrcweir extract_source:
1788*cdf0e10cSrcweir 		datetime_value_exp
1789*cdf0e10cSrcweir 		{
1790*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1791*cdf0e10cSrcweir 			$$->append($1);
1792*cdf0e10cSrcweir 		}
1793*cdf0e10cSrcweir /*      | interval_value_exp
1794*cdf0e10cSrcweir 		{
1795*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1796*cdf0e10cSrcweir 			$$->append($1);
1797*cdf0e10cSrcweir 		} */
1798*cdf0e10cSrcweir 	;
1799*cdf0e10cSrcweir extract_exp:
1800*cdf0e10cSrcweir 		SQL_TOKEN_EXTRACT '(' extract_field SQL_TOKEN_FROM value_exp ')'
1801*cdf0e10cSrcweir 		{
1802*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1803*cdf0e10cSrcweir 			$$->append($1);
1804*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1805*cdf0e10cSrcweir 			$$->append($3);
1806*cdf0e10cSrcweir 			$$->append($4);
1807*cdf0e10cSrcweir 			$$->append($5);
1808*cdf0e10cSrcweir 			$$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
1809*cdf0e10cSrcweir 		}
1810*cdf0e10cSrcweir 	;
1811*cdf0e10cSrcweir unsigned_value_spec:
1812*cdf0e10cSrcweir 		general_value_spec
1813*cdf0e10cSrcweir 	|	literal
1814*cdf0e10cSrcweir 	;
1815*cdf0e10cSrcweir general_value_spec:
1816*cdf0e10cSrcweir 		parameter
1817*cdf0e10cSrcweir 	| SQL_TOKEN_USER
1818*cdf0e10cSrcweir 	/*	  | SQL_TOKEN_NULL*/
1819*cdf0e10cSrcweir 	| SQL_TOKEN_FALSE
1820*cdf0e10cSrcweir 	| SQL_TOKEN_TRUE
1821*cdf0e10cSrcweir 	| SQL_TOKEN_VALUE
1822*cdf0e10cSrcweir 	| SQL_TOKEN_CURRENT_CATALOG
1823*cdf0e10cSrcweir 	| SQL_TOKEN_CURRENT_DEFAULT_TRANSFORM_GROUP
1824*cdf0e10cSrcweir 	| SQL_TOKEN_CURRENT_PATH
1825*cdf0e10cSrcweir 	| SQL_TOKEN_CURRENT_ROLE
1826*cdf0e10cSrcweir 	| SQL_TOKEN_CURRENT_SCHEMA
1827*cdf0e10cSrcweir 	| SQL_TOKEN_CURRENT_USER
1828*cdf0e10cSrcweir 	| SQL_TOKEN_SESSION_USER
1829*cdf0e10cSrcweir 	| SQL_TOKEN_SYSTEM_USER
1830*cdf0e10cSrcweir 	;
1831*cdf0e10cSrcweir set_fct_spec:
1832*cdf0e10cSrcweir 		general_set_fct
1833*cdf0e10cSrcweir 	|	'{' odbc_fct_spec '}'
1834*cdf0e10cSrcweir 		{
1835*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1836*cdf0e10cSrcweir 			$$->append($1 = newNode("{", SQL_NODE_PUNCTUATION));
1837*cdf0e10cSrcweir 			$$->append($2);
1838*cdf0e10cSrcweir 			$$->append($3 = newNode("}", SQL_NODE_PUNCTUATION));
1839*cdf0e10cSrcweir 		}
1840*cdf0e10cSrcweir 	|	function_name '(' ')'
1841*cdf0e10cSrcweir 		{
1842*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1843*cdf0e10cSrcweir 			$$->append($1);
1844*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1845*cdf0e10cSrcweir 			$$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
1846*cdf0e10cSrcweir 		}
1847*cdf0e10cSrcweir 	|	function_name0 '(' ')'
1848*cdf0e10cSrcweir 		{
1849*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1850*cdf0e10cSrcweir 			$$->append($1);
1851*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1852*cdf0e10cSrcweir 			$$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
1853*cdf0e10cSrcweir 		}
1854*cdf0e10cSrcweir 	|	function_name1 '(' function_arg ')'
1855*cdf0e10cSrcweir 		{
1856*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1857*cdf0e10cSrcweir 			$$->append($1);
1858*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1859*cdf0e10cSrcweir 			$$->append($3);
1860*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1861*cdf0e10cSrcweir 		}
1862*cdf0e10cSrcweir 	|	function_name2 '(' function_arg_commalist2 ')'
1863*cdf0e10cSrcweir 		{
1864*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1865*cdf0e10cSrcweir 			$$->append($1);
1866*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1867*cdf0e10cSrcweir 			$$->append($3);
1868*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1869*cdf0e10cSrcweir 		}
1870*cdf0e10cSrcweir 	|	function_name3 '(' function_arg_commalist3 ')'
1871*cdf0e10cSrcweir 		{
1872*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1873*cdf0e10cSrcweir 			$$->append($1);
1874*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1875*cdf0e10cSrcweir 			$$->append($3);
1876*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1877*cdf0e10cSrcweir 		}
1878*cdf0e10cSrcweir 	|	string_function_4Argument '(' function_arg_commalist4 ')'
1879*cdf0e10cSrcweir 		{
1880*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1881*cdf0e10cSrcweir 			$$->append($1);
1882*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1883*cdf0e10cSrcweir 			$$->append($3);
1884*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1885*cdf0e10cSrcweir 		}
1886*cdf0e10cSrcweir 	|	function_name '(' function_args_commalist ')'
1887*cdf0e10cSrcweir 		{
1888*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
1889*cdf0e10cSrcweir 			$$->append($1);
1890*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1891*cdf0e10cSrcweir 			$$->append($3);
1892*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1893*cdf0e10cSrcweir 		}
1894*cdf0e10cSrcweir 	|	function_name12 '(' function_args_commalist ')'
1895*cdf0e10cSrcweir 		{
1896*cdf0e10cSrcweir 			if ( $3->count() == 1 || $3->count() == 2 )
1897*cdf0e10cSrcweir 			{
1898*cdf0e10cSrcweir 				$$ = SQL_NEW_RULE;
1899*cdf0e10cSrcweir 				$$->append($1);
1900*cdf0e10cSrcweir 				$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1901*cdf0e10cSrcweir 				$$->append($3);
1902*cdf0e10cSrcweir 				$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1903*cdf0e10cSrcweir 			}
1904*cdf0e10cSrcweir 			else
1905*cdf0e10cSrcweir 				YYERROR;
1906*cdf0e10cSrcweir 		}
1907*cdf0e10cSrcweir 	|	function_name23 '(' function_args_commalist ')'
1908*cdf0e10cSrcweir 		{
1909*cdf0e10cSrcweir 			if ( $3->count() == 2 || $3->count() == 3)
1910*cdf0e10cSrcweir 			{
1911*cdf0e10cSrcweir 				$$ = SQL_NEW_RULE;
1912*cdf0e10cSrcweir 				$$->append($1);
1913*cdf0e10cSrcweir 				$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
1914*cdf0e10cSrcweir 				$$->append($3);
1915*cdf0e10cSrcweir 				$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
1916*cdf0e10cSrcweir 			}
1917*cdf0e10cSrcweir 			else
1918*cdf0e10cSrcweir 				YYERROR;
1919*cdf0e10cSrcweir 		}
1920*cdf0e10cSrcweir 	;
1921*cdf0e10cSrcweir function_name0:
1922*cdf0e10cSrcweir 		date_function_0Argument
1923*cdf0e10cSrcweir 	|	numeric_function_0Argument
1924*cdf0e10cSrcweir 	;
1925*cdf0e10cSrcweir function_name1:
1926*cdf0e10cSrcweir 		string_function_1Argument
1927*cdf0e10cSrcweir 	|	date_function_1Argument
1928*cdf0e10cSrcweir 	|	numeric_function_1Argument
1929*cdf0e10cSrcweir 	;
1930*cdf0e10cSrcweir function_name2:
1931*cdf0e10cSrcweir 		string_function_2Argument
1932*cdf0e10cSrcweir 	|	numeric_function_2Argument
1933*cdf0e10cSrcweir 	;
1934*cdf0e10cSrcweir function_name12:
1935*cdf0e10cSrcweir 		SQL_TOKEN_ROUND
1936*cdf0e10cSrcweir 	|	SQL_TOKEN_WEEK
1937*cdf0e10cSrcweir 	|	SQL_TOKEN_LOGF
1938*cdf0e10cSrcweir 	|	SQL_TOKEN_LOG
1939*cdf0e10cSrcweir 	;
1940*cdf0e10cSrcweir function_name23:
1941*cdf0e10cSrcweir 		SQL_TOKEN_LOCATE
1942*cdf0e10cSrcweir 	|	SQL_TOKEN_DATEDIFF
1943*cdf0e10cSrcweir 	;
1944*cdf0e10cSrcweir function_name3:
1945*cdf0e10cSrcweir 		string_function_3Argument
1946*cdf0e10cSrcweir 	;
1947*cdf0e10cSrcweir function_name:
1948*cdf0e10cSrcweir 		string_function
1949*cdf0e10cSrcweir 	|	date_function
1950*cdf0e10cSrcweir 	|	numeric_function
1951*cdf0e10cSrcweir 	|	SQL_TOKEN_NAME
1952*cdf0e10cSrcweir 	;
1953*cdf0e10cSrcweir string_function_1Argument:
1954*cdf0e10cSrcweir 		SQL_TOKEN_LENGTH
1955*cdf0e10cSrcweir 	|	SQL_TOKEN_ASCII
1956*cdf0e10cSrcweir 	|	SQL_TOKEN_LCASE
1957*cdf0e10cSrcweir 	|	SQL_TOKEN_LTRIM
1958*cdf0e10cSrcweir 	|	SQL_TOKEN_RTRIM
1959*cdf0e10cSrcweir 	|	SQL_TOKEN_SPACE
1960*cdf0e10cSrcweir 	|	SQL_TOKEN_UCASE
1961*cdf0e10cSrcweir 	;
1962*cdf0e10cSrcweir 
1963*cdf0e10cSrcweir string_function_2Argument:
1964*cdf0e10cSrcweir 		SQL_TOKEN_REPEAT
1965*cdf0e10cSrcweir 	|	SQL_TOKEN_LEFT
1966*cdf0e10cSrcweir 	|	SQL_TOKEN_RIGHT
1967*cdf0e10cSrcweir 	;
1968*cdf0e10cSrcweir string_function_3Argument:
1969*cdf0e10cSrcweir 		SQL_TOKEN_REPLACE
1970*cdf0e10cSrcweir 	;
1971*cdf0e10cSrcweir string_function_4Argument:
1972*cdf0e10cSrcweir 		SQL_TOKEN_INSERT
1973*cdf0e10cSrcweir 	;
1974*cdf0e10cSrcweir 
1975*cdf0e10cSrcweir string_function:
1976*cdf0e10cSrcweir 		SQL_TOKEN_CHAR
1977*cdf0e10cSrcweir 	|	SQL_TOKEN_CONCAT
1978*cdf0e10cSrcweir 	|	SQL_TOKEN_DIFFERENCE
1979*cdf0e10cSrcweir 	|	SQL_TOKEN_LOCATE_2
1980*cdf0e10cSrcweir 	|	SQL_TOKEN_SOUNDEX
1981*cdf0e10cSrcweir 	;
1982*cdf0e10cSrcweir date_function_0Argument:
1983*cdf0e10cSrcweir 		SQL_TOKEN_CURDATE
1984*cdf0e10cSrcweir 	|	SQL_TOKEN_CURTIME
1985*cdf0e10cSrcweir 	|	SQL_TOKEN_NOW
1986*cdf0e10cSrcweir 	;
1987*cdf0e10cSrcweir date_function_1Argument:
1988*cdf0e10cSrcweir 		SQL_TOKEN_DAYOFWEEK
1989*cdf0e10cSrcweir 	|	SQL_TOKEN_DAYOFMONTH
1990*cdf0e10cSrcweir 	|	SQL_TOKEN_DAYOFYEAR
1991*cdf0e10cSrcweir 	|	SQL_TOKEN_MONTH
1992*cdf0e10cSrcweir 	|	SQL_TOKEN_DAYNAME
1993*cdf0e10cSrcweir 	|	SQL_TOKEN_MONTHNAME
1994*cdf0e10cSrcweir 	|	SQL_TOKEN_QUARTER
1995*cdf0e10cSrcweir 	|	SQL_TOKEN_HOUR
1996*cdf0e10cSrcweir 	|	SQL_TOKEN_MINUTE
1997*cdf0e10cSrcweir 	|	SQL_TOKEN_SECOND
1998*cdf0e10cSrcweir 	|	SQL_TOKEN_YEAR
1999*cdf0e10cSrcweir 	|	SQL_TOKEN_DAY
2000*cdf0e10cSrcweir 	|	SQL_TOKEN_TIMEVALUE
2001*cdf0e10cSrcweir 	|	SQL_TOKEN_DATEVALUE
2002*cdf0e10cSrcweir 	;
2003*cdf0e10cSrcweir 
2004*cdf0e10cSrcweir date_function:
2005*cdf0e10cSrcweir 		SQL_TOKEN_TIMESTAMPADD
2006*cdf0e10cSrcweir 	|	SQL_TOKEN_TIMESTAMPDIFF
2007*cdf0e10cSrcweir 	;
2008*cdf0e10cSrcweir numeric_function_0Argument:
2009*cdf0e10cSrcweir 		SQL_TOKEN_PI
2010*cdf0e10cSrcweir 	;
2011*cdf0e10cSrcweir numeric_function_1Argument:
2012*cdf0e10cSrcweir 		SQL_TOKEN_ABS
2013*cdf0e10cSrcweir 	|	SQL_TOKEN_ACOS
2014*cdf0e10cSrcweir 	|	SQL_TOKEN_ASIN
2015*cdf0e10cSrcweir 	|	SQL_TOKEN_ATAN
2016*cdf0e10cSrcweir 	|	SQL_TOKEN_CEILING
2017*cdf0e10cSrcweir 	|	SQL_TOKEN_COS
2018*cdf0e10cSrcweir 	|	SQL_TOKEN_COT
2019*cdf0e10cSrcweir 	|	SQL_TOKEN_DEGREES
2020*cdf0e10cSrcweir 	|	SQL_TOKEN_FLOOR
2021*cdf0e10cSrcweir 	|	SQL_TOKEN_SIGN
2022*cdf0e10cSrcweir 	|	SQL_TOKEN_SIN
2023*cdf0e10cSrcweir 	|	SQL_TOKEN_SQRT
2024*cdf0e10cSrcweir 	|	SQL_TOKEN_TAN
2025*cdf0e10cSrcweir 	|	SQL_TOKEN_EXP
2026*cdf0e10cSrcweir 	|	SQL_TOKEN_LOG10
2027*cdf0e10cSrcweir 	|	SQL_TOKEN_LN
2028*cdf0e10cSrcweir 	|	SQL_TOKEN_RADIANS
2029*cdf0e10cSrcweir 	|	SQL_TOKEN_ROUNDMAGIC
2030*cdf0e10cSrcweir 	;
2031*cdf0e10cSrcweir numeric_function_2Argument:
2032*cdf0e10cSrcweir 		SQL_TOKEN_ATAN2
2033*cdf0e10cSrcweir 	|	SQL_TOKEN_MOD
2034*cdf0e10cSrcweir 	|	SQL_TOKEN_POWER
2035*cdf0e10cSrcweir 	;
2036*cdf0e10cSrcweir numeric_function:
2037*cdf0e10cSrcweir 		SQL_TOKEN_RAND
2038*cdf0e10cSrcweir 	|	SQL_TOKEN_TRUNCATE
2039*cdf0e10cSrcweir 	;
2040*cdf0e10cSrcweir 
2041*cdf0e10cSrcweir window_function:
2042*cdf0e10cSrcweir 	window_function_type SQL_TOKEN_OVER window_name_or_specification
2043*cdf0e10cSrcweir 	{
2044*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2045*cdf0e10cSrcweir 			$$->append($1);
2046*cdf0e10cSrcweir 			$$->append($2);
2047*cdf0e10cSrcweir 			$$->append($3);
2048*cdf0e10cSrcweir 	}
2049*cdf0e10cSrcweir 	;
2050*cdf0e10cSrcweir window_function_type :
2051*cdf0e10cSrcweir 		rank_function_type '(' ')'
2052*cdf0e10cSrcweir 		{
2053*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2054*cdf0e10cSrcweir 			$$->append($1);
2055*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2056*cdf0e10cSrcweir 			$$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
2057*cdf0e10cSrcweir 		}
2058*cdf0e10cSrcweir 	|	SQL_TOKEN_ROW_NUMBER '(' ')'
2059*cdf0e10cSrcweir 		{
2060*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2061*cdf0e10cSrcweir 			$$->append($1);
2062*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2063*cdf0e10cSrcweir 			$$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
2064*cdf0e10cSrcweir 		}
2065*cdf0e10cSrcweir 	| general_set_fct
2066*cdf0e10cSrcweir 	| ntile_function
2067*cdf0e10cSrcweir 	| lead_or_lag_function
2068*cdf0e10cSrcweir 	| first_or_last_value_function
2069*cdf0e10cSrcweir 	| nth_value_function
2070*cdf0e10cSrcweir ;
2071*cdf0e10cSrcweir ntile_function :
2072*cdf0e10cSrcweir 	SQL_TOKEN_NTILE '(' number_of_tiles ')'
2073*cdf0e10cSrcweir 	{
2074*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2075*cdf0e10cSrcweir 			$$->append($1);
2076*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2077*cdf0e10cSrcweir 			$$->append($3);
2078*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
2079*cdf0e10cSrcweir 	}
2080*cdf0e10cSrcweir 	;
2081*cdf0e10cSrcweir dynamic_parameter_specification:
2082*cdf0e10cSrcweir 	parameter
2083*cdf0e10cSrcweir 	;
2084*cdf0e10cSrcweir simple_value_specification:
2085*cdf0e10cSrcweir 	literal
2086*cdf0e10cSrcweir 	;
2087*cdf0e10cSrcweir number_of_tiles :
2088*cdf0e10cSrcweir 		simple_value_specification
2089*cdf0e10cSrcweir 	|	dynamic_parameter_specification
2090*cdf0e10cSrcweir 	;
2091*cdf0e10cSrcweir opt_lead_or_lag_function:
2092*cdf0e10cSrcweir 	/* empty */      {$$ = SQL_NEW_RULE;}
2093*cdf0e10cSrcweir 	| ',' offset
2094*cdf0e10cSrcweir 		{
2095*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2096*cdf0e10cSrcweir 			$$->append($1 = newNode(",", SQL_NODE_PUNCTUATION));
2097*cdf0e10cSrcweir 			$$->append($2);
2098*cdf0e10cSrcweir 		}
2099*cdf0e10cSrcweir 	| ',' offset ',' default_expression
2100*cdf0e10cSrcweir 		{
2101*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2102*cdf0e10cSrcweir 			$$->append($1 = newNode(",", SQL_NODE_PUNCTUATION));
2103*cdf0e10cSrcweir 			$$->append($2);
2104*cdf0e10cSrcweir 			$$->append($3 = newNode(",", SQL_NODE_PUNCTUATION));
2105*cdf0e10cSrcweir 			$$->append($4);
2106*cdf0e10cSrcweir 		}
2107*cdf0e10cSrcweir 	;
2108*cdf0e10cSrcweir opt_null_treatment:
2109*cdf0e10cSrcweir 		/* empty */      {$$ = SQL_NEW_RULE;}
2110*cdf0e10cSrcweir 	|	null_treatment
2111*cdf0e10cSrcweir 	;
2112*cdf0e10cSrcweir 
2113*cdf0e10cSrcweir lead_or_lag_function:
2114*cdf0e10cSrcweir 	lead_or_lag '(' lead_or_lag_extent opt_lead_or_lag_function ')'	opt_null_treatment
2115*cdf0e10cSrcweir 	{
2116*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2117*cdf0e10cSrcweir 			$$->append($1);
2118*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2119*cdf0e10cSrcweir 			$$->append($3);
2120*cdf0e10cSrcweir 			$$->append($4);
2121*cdf0e10cSrcweir 			$$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
2122*cdf0e10cSrcweir 			$$->append($6);
2123*cdf0e10cSrcweir 	}
2124*cdf0e10cSrcweir 	;
2125*cdf0e10cSrcweir lead_or_lag:
2126*cdf0e10cSrcweir 		SQL_TOKEN_LEAD
2127*cdf0e10cSrcweir 	|	SQL_TOKEN_LAG
2128*cdf0e10cSrcweir 	;
2129*cdf0e10cSrcweir lead_or_lag_extent:
2130*cdf0e10cSrcweir 	value_exp
2131*cdf0e10cSrcweir 	;
2132*cdf0e10cSrcweir offset:
2133*cdf0e10cSrcweir 	SQL_TOKEN_INTNUM
2134*cdf0e10cSrcweir 	;
2135*cdf0e10cSrcweir default_expression:
2136*cdf0e10cSrcweir 	value_exp
2137*cdf0e10cSrcweir 	;
2138*cdf0e10cSrcweir null_treatment:
2139*cdf0e10cSrcweir 		SQL_TOKEN_RESPECT SQL_TOKEN_NULLS
2140*cdf0e10cSrcweir 	|	SQL_TOKEN_IGNORE SQL_TOKEN_NULLS
2141*cdf0e10cSrcweir 	;
2142*cdf0e10cSrcweir first_or_last_value_function:
2143*cdf0e10cSrcweir 	first_or_last_value '(' value_exp ')' opt_null_treatment
2144*cdf0e10cSrcweir 	{
2145*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2146*cdf0e10cSrcweir 			$$->append($1);
2147*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2148*cdf0e10cSrcweir 			$$->append($3);
2149*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
2150*cdf0e10cSrcweir 			$$->append($5);
2151*cdf0e10cSrcweir 	}
2152*cdf0e10cSrcweir 	;
2153*cdf0e10cSrcweir first_or_last_value :
2154*cdf0e10cSrcweir 		SQL_TOKEN_FIRST_VALUE
2155*cdf0e10cSrcweir 	|	SQL_TOKEN_LAST_VALUE
2156*cdf0e10cSrcweir 	;
2157*cdf0e10cSrcweir opt_from_first_or_last:
2158*cdf0e10cSrcweir 		/* empty */      {$$ = SQL_NEW_RULE;}
2159*cdf0e10cSrcweir 	|	from_first_or_last
2160*cdf0e10cSrcweir 	;
2161*cdf0e10cSrcweir nth_value_function:
2162*cdf0e10cSrcweir 	SQL_TOKEN_NTH_VALUE '(' value_exp ',' nth_row ')' opt_from_first_or_last opt_null_treatment
2163*cdf0e10cSrcweir 	{
2164*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2165*cdf0e10cSrcweir 			$$->append($1);
2166*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2167*cdf0e10cSrcweir 			$$->append($3);
2168*cdf0e10cSrcweir 			$$->append($4 = newNode(",", SQL_NODE_PUNCTUATION));
2169*cdf0e10cSrcweir 			$$->append($5);
2170*cdf0e10cSrcweir 			$$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
2171*cdf0e10cSrcweir 			$$->append($7);
2172*cdf0e10cSrcweir 			$$->append($8);
2173*cdf0e10cSrcweir 	}
2174*cdf0e10cSrcweir 	;
2175*cdf0e10cSrcweir nth_row:
2176*cdf0e10cSrcweir 		simple_value_specification
2177*cdf0e10cSrcweir 	|	dynamic_parameter_specification
2178*cdf0e10cSrcweir 	;
2179*cdf0e10cSrcweir from_first_or_last:
2180*cdf0e10cSrcweir 		SQL_TOKEN_FROM SQL_TOKEN_FIRST
2181*cdf0e10cSrcweir 		{
2182*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2183*cdf0e10cSrcweir 			$$->append($1);
2184*cdf0e10cSrcweir 			$$->append($2);
2185*cdf0e10cSrcweir 		}
2186*cdf0e10cSrcweir 	|	SQL_TOKEN_FROM SQL_TOKEN_LAST
2187*cdf0e10cSrcweir 		{
2188*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2189*cdf0e10cSrcweir 			$$->append($1);
2190*cdf0e10cSrcweir 			$$->append($2);
2191*cdf0e10cSrcweir 		}
2192*cdf0e10cSrcweir 	;
2193*cdf0e10cSrcweir window_name:
2194*cdf0e10cSrcweir 	SQL_TOKEN_NAME
2195*cdf0e10cSrcweir 	;
2196*cdf0e10cSrcweir window_name_or_specification:
2197*cdf0e10cSrcweir 		window_name
2198*cdf0e10cSrcweir 	|	in_line_window_specification
2199*cdf0e10cSrcweir 	;
2200*cdf0e10cSrcweir in_line_window_specification:
2201*cdf0e10cSrcweir 	window_specification
2202*cdf0e10cSrcweir 	;
2203*cdf0e10cSrcweir opt_window_clause:
2204*cdf0e10cSrcweir 		/* empty */      {$$ = SQL_NEW_RULE;}
2205*cdf0e10cSrcweir 	|	window_clause
2206*cdf0e10cSrcweir 	;
2207*cdf0e10cSrcweir window_clause:
2208*cdf0e10cSrcweir 	SQL_TOKEN_WINDOW window_definition_list
2209*cdf0e10cSrcweir 	{
2210*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
2211*cdf0e10cSrcweir 		$$->append($1);
2212*cdf0e10cSrcweir 		$$->append($2);
2213*cdf0e10cSrcweir 	}
2214*cdf0e10cSrcweir 	;
2215*cdf0e10cSrcweir window_definition_list:
2216*cdf0e10cSrcweir 		window_definition_list ',' window_definition
2217*cdf0e10cSrcweir 			{$1->append($3);
2218*cdf0e10cSrcweir 			$$ = $1;}
2219*cdf0e10cSrcweir 	|	window_definition
2220*cdf0e10cSrcweir 			{$$ = SQL_NEW_COMMALISTRULE;
2221*cdf0e10cSrcweir 			$$->append($1);}
2222*cdf0e10cSrcweir 	;
2223*cdf0e10cSrcweir window_definition:
2224*cdf0e10cSrcweir 	new_window_name SQL_TOKEN_AS window_specification
2225*cdf0e10cSrcweir 	{
2226*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
2227*cdf0e10cSrcweir 		$$->append($1);
2228*cdf0e10cSrcweir 		$$->append($2);
2229*cdf0e10cSrcweir 		$$->append($3);
2230*cdf0e10cSrcweir 	}
2231*cdf0e10cSrcweir 	;
2232*cdf0e10cSrcweir new_window_name:
2233*cdf0e10cSrcweir 	window_name
2234*cdf0e10cSrcweir 	;
2235*cdf0e10cSrcweir window_specification:
2236*cdf0e10cSrcweir 	'(' window_specification_details ')'
2237*cdf0e10cSrcweir 	{
2238*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
2239*cdf0e10cSrcweir 		$$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
2240*cdf0e10cSrcweir 		$$->append($2);
2241*cdf0e10cSrcweir 		$$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
2242*cdf0e10cSrcweir 	}
2243*cdf0e10cSrcweir 	;
2244*cdf0e10cSrcweir opt_existing_window_name:
2245*cdf0e10cSrcweir 		/* empty */      {$$ = SQL_NEW_RULE;}
2246*cdf0e10cSrcweir 	|	existing_window_name
2247*cdf0e10cSrcweir 	;
2248*cdf0e10cSrcweir opt_window_partition_clause:
2249*cdf0e10cSrcweir 	/* empty */      {$$ = SQL_NEW_RULE;}
2250*cdf0e10cSrcweir 	|	window_partition_clause
2251*cdf0e10cSrcweir 	;
2252*cdf0e10cSrcweir opt_window_frame_clause:
2253*cdf0e10cSrcweir 	/* empty */      {$$ = SQL_NEW_RULE;}
2254*cdf0e10cSrcweir 	|	window_frame_clause
2255*cdf0e10cSrcweir 	;
2256*cdf0e10cSrcweir window_specification_details:
2257*cdf0e10cSrcweir 	opt_existing_window_name
2258*cdf0e10cSrcweir 	opt_window_partition_clause
2259*cdf0e10cSrcweir 	opt_order_by_clause
2260*cdf0e10cSrcweir 	opt_window_frame_clause
2261*cdf0e10cSrcweir 	;
2262*cdf0e10cSrcweir existing_window_name:
2263*cdf0e10cSrcweir 	window_name
2264*cdf0e10cSrcweir 	;
2265*cdf0e10cSrcweir window_partition_clause:
2266*cdf0e10cSrcweir 	SQL_TOKEN_PARTITION SQL_TOKEN_BY window_partition_column_reference_list
2267*cdf0e10cSrcweir 	{
2268*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
2269*cdf0e10cSrcweir 		$$->append($1);
2270*cdf0e10cSrcweir 		$$->append($2);
2271*cdf0e10cSrcweir 		$$->append($3);
2272*cdf0e10cSrcweir 	}
2273*cdf0e10cSrcweir 	;
2274*cdf0e10cSrcweir window_partition_column_reference_list:
2275*cdf0e10cSrcweir 	window_partition_column_reference_list ',' window_partition_column_reference
2276*cdf0e10cSrcweir 			{$1->append($3);
2277*cdf0e10cSrcweir 			$$ = $1;}
2278*cdf0e10cSrcweir 	|	window_partition_column_reference
2279*cdf0e10cSrcweir 			{$$ = SQL_NEW_COMMALISTRULE;
2280*cdf0e10cSrcweir 			$$->append($1);}
2281*cdf0e10cSrcweir 	;
2282*cdf0e10cSrcweir window_partition_column_reference:
2283*cdf0e10cSrcweir 	column_ref opt_collate_clause
2284*cdf0e10cSrcweir 	{
2285*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
2286*cdf0e10cSrcweir 		$$->append($1);
2287*cdf0e10cSrcweir 		$$->append($2);
2288*cdf0e10cSrcweir 	}
2289*cdf0e10cSrcweir 	;
2290*cdf0e10cSrcweir opt_window_frame_exclusion:
2291*cdf0e10cSrcweir 	/* empty */      {$$ = SQL_NEW_RULE;}
2292*cdf0e10cSrcweir 	|	window_frame_exclusion
2293*cdf0e10cSrcweir 	;
2294*cdf0e10cSrcweir window_frame_clause:
2295*cdf0e10cSrcweir 	window_frame_units window_frame_extent opt_window_frame_exclusion
2296*cdf0e10cSrcweir 	{
2297*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
2298*cdf0e10cSrcweir 		$$->append($1);
2299*cdf0e10cSrcweir 		$$->append($2);
2300*cdf0e10cSrcweir 		$$->append($3);
2301*cdf0e10cSrcweir 	}
2302*cdf0e10cSrcweir 	;
2303*cdf0e10cSrcweir window_frame_units:
2304*cdf0e10cSrcweir 		SQL_TOKEN_ROWS
2305*cdf0e10cSrcweir 	|	SQL_TOKEN_RANGE
2306*cdf0e10cSrcweir 	;
2307*cdf0e10cSrcweir window_frame_extent:
2308*cdf0e10cSrcweir 		window_frame_start
2309*cdf0e10cSrcweir 	|	window_frame_between
2310*cdf0e10cSrcweir 	;
2311*cdf0e10cSrcweir window_frame_start:
2312*cdf0e10cSrcweir 		SQL_TOKEN_UNBOUNDED SQL_TOKEN_PRECEDING
2313*cdf0e10cSrcweir 		{
2314*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2315*cdf0e10cSrcweir 			$$->append($1);
2316*cdf0e10cSrcweir 			$$->append($2);
2317*cdf0e10cSrcweir 		}
2318*cdf0e10cSrcweir 	|	window_frame_preceding
2319*cdf0e10cSrcweir 	|	SQL_TOKEN_CURRENT SQL_TOKEN_ROW
2320*cdf0e10cSrcweir 		{
2321*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2322*cdf0e10cSrcweir 			$$->append($1);
2323*cdf0e10cSrcweir 			$$->append($2);
2324*cdf0e10cSrcweir 		}
2325*cdf0e10cSrcweir 	;
2326*cdf0e10cSrcweir window_frame_preceding:
2327*cdf0e10cSrcweir 	unsigned_value_spec SQL_TOKEN_PRECEDING
2328*cdf0e10cSrcweir 	{
2329*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
2330*cdf0e10cSrcweir 		$$->append($1);
2331*cdf0e10cSrcweir 		$$->append($2);
2332*cdf0e10cSrcweir 	}
2333*cdf0e10cSrcweir 	;
2334*cdf0e10cSrcweir window_frame_between:
2335*cdf0e10cSrcweir 	SQL_TOKEN_BETWEEN window_frame_bound_1 SQL_TOKEN_AND window_frame_bound_2
2336*cdf0e10cSrcweir 	{
2337*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
2338*cdf0e10cSrcweir 		$$->append($1);
2339*cdf0e10cSrcweir 		$$->append($2);
2340*cdf0e10cSrcweir 		$$->append($3);
2341*cdf0e10cSrcweir 		$$->append($4);
2342*cdf0e10cSrcweir 	}
2343*cdf0e10cSrcweir 	;
2344*cdf0e10cSrcweir window_frame_bound_1:
2345*cdf0e10cSrcweir 	window_frame_bound
2346*cdf0e10cSrcweir 	;
2347*cdf0e10cSrcweir window_frame_bound_2:
2348*cdf0e10cSrcweir 	window_frame_bound
2349*cdf0e10cSrcweir 	;
2350*cdf0e10cSrcweir window_frame_bound:
2351*cdf0e10cSrcweir 	window_frame_start
2352*cdf0e10cSrcweir 	| SQL_TOKEN_UNBOUNDED SQL_TOKEN_FOLLOWING
2353*cdf0e10cSrcweir 	{
2354*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
2355*cdf0e10cSrcweir 		$$->append($1);
2356*cdf0e10cSrcweir 		$$->append($2);
2357*cdf0e10cSrcweir 	}
2358*cdf0e10cSrcweir 	| window_frame_following
2359*cdf0e10cSrcweir 	;
2360*cdf0e10cSrcweir window_frame_following:
2361*cdf0e10cSrcweir 	unsigned_value_spec SQL_TOKEN_FOLLOWING
2362*cdf0e10cSrcweir 	{
2363*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
2364*cdf0e10cSrcweir 		$$->append($1);
2365*cdf0e10cSrcweir 		$$->append($2);
2366*cdf0e10cSrcweir 	}
2367*cdf0e10cSrcweir 	;
2368*cdf0e10cSrcweir window_frame_exclusion:
2369*cdf0e10cSrcweir 		SQL_TOKEN_EXCLUDE SQL_TOKEN_CURRENT SQL_TOKEN_ROW
2370*cdf0e10cSrcweir 		{
2371*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2372*cdf0e10cSrcweir 			$$->append($1);
2373*cdf0e10cSrcweir 			$$->append($2);
2374*cdf0e10cSrcweir 			$$->append($3);
2375*cdf0e10cSrcweir 		}
2376*cdf0e10cSrcweir 	|	SQL_TOKEN_EXCLUDE SQL_TOKEN_GROUP
2377*cdf0e10cSrcweir 		{
2378*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2379*cdf0e10cSrcweir 			$$->append($1);
2380*cdf0e10cSrcweir 			$$->append($2);
2381*cdf0e10cSrcweir 		}
2382*cdf0e10cSrcweir 	|	SQL_TOKEN_EXCLUDE SQL_TOKEN_TIES
2383*cdf0e10cSrcweir 		{
2384*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2385*cdf0e10cSrcweir 			$$->append($1);
2386*cdf0e10cSrcweir 			$$->append($2);
2387*cdf0e10cSrcweir 		}
2388*cdf0e10cSrcweir 	|	SQL_TOKEN_EXCLUDE SQL_TOKEN_NO SQL_TOKEN_OTHERS
2389*cdf0e10cSrcweir 		{
2390*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2391*cdf0e10cSrcweir 			$$->append($1);
2392*cdf0e10cSrcweir 			$$->append($2);
2393*cdf0e10cSrcweir 			$$->append($3);
2394*cdf0e10cSrcweir 		}
2395*cdf0e10cSrcweir 	;
2396*cdf0e10cSrcweir op_parameter:
2397*cdf0e10cSrcweir 		{$$ = SQL_NEW_RULE;}
2398*cdf0e10cSrcweir 	|	'?' SQL_EQUAL
2399*cdf0e10cSrcweir 		{
2400*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2401*cdf0e10cSrcweir 			$$->append($1 = newNode("?", SQL_NODE_PUNCTUATION));
2402*cdf0e10cSrcweir 			$$->append($2);
2403*cdf0e10cSrcweir 		}
2404*cdf0e10cSrcweir 	;
2405*cdf0e10cSrcweir odbc_call_spec:
2406*cdf0e10cSrcweir 		op_parameter SQL_TOKEN_CALL table_node op_odbc_call_parameter
2407*cdf0e10cSrcweir 		{
2408*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2409*cdf0e10cSrcweir 			$$->append($1);
2410*cdf0e10cSrcweir 			$$->append($2);
2411*cdf0e10cSrcweir 			$$->append($3);
2412*cdf0e10cSrcweir 			$$->append($4);
2413*cdf0e10cSrcweir 		}
2414*cdf0e10cSrcweir 	;
2415*cdf0e10cSrcweir 
2416*cdf0e10cSrcweir op_odbc_call_parameter:
2417*cdf0e10cSrcweir 		{$$ = SQL_NEW_RULE;}
2418*cdf0e10cSrcweir 	|	'(' odbc_parameter_commalist ')'
2419*cdf0e10cSrcweir 		{
2420*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2421*cdf0e10cSrcweir 			$$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
2422*cdf0e10cSrcweir 			$$->append($2);
2423*cdf0e10cSrcweir 			$$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
2424*cdf0e10cSrcweir 		}
2425*cdf0e10cSrcweir 	;
2426*cdf0e10cSrcweir 
2427*cdf0e10cSrcweir odbc_parameter_commalist:
2428*cdf0e10cSrcweir 		odbc_parameter
2429*cdf0e10cSrcweir 		{$$ = SQL_NEW_COMMALISTRULE;
2430*cdf0e10cSrcweir 			$$->append($1);}
2431*cdf0e10cSrcweir 	|	odbc_parameter_commalist ',' odbc_parameter
2432*cdf0e10cSrcweir 		{
2433*cdf0e10cSrcweir 			$1->append($3);
2434*cdf0e10cSrcweir 			$$ = $1;
2435*cdf0e10cSrcweir 		}
2436*cdf0e10cSrcweir 	;
2437*cdf0e10cSrcweir odbc_parameter:
2438*cdf0e10cSrcweir 	/* empty */ 	{$$ = SQL_NEW_RULE;}
2439*cdf0e10cSrcweir 	|	literal
2440*cdf0e10cSrcweir 	|	parameter
2441*cdf0e10cSrcweir 	;
2442*cdf0e10cSrcweir 
2443*cdf0e10cSrcweir odbc_fct_spec:
2444*cdf0e10cSrcweir 		odbc_fct_type SQL_TOKEN_STRING
2445*cdf0e10cSrcweir 		{
2446*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2447*cdf0e10cSrcweir 			$$->append($1);
2448*cdf0e10cSrcweir 			$$->append($2);
2449*cdf0e10cSrcweir 		}
2450*cdf0e10cSrcweir 	|	SQL_TOKEN_FN set_fct_spec
2451*cdf0e10cSrcweir 		{
2452*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2453*cdf0e10cSrcweir 			$$->append($1);
2454*cdf0e10cSrcweir 			$$->append($2);
2455*cdf0e10cSrcweir 		}
2456*cdf0e10cSrcweir 	;
2457*cdf0e10cSrcweir 
2458*cdf0e10cSrcweir odbc_fct_type:
2459*cdf0e10cSrcweir 		SQL_TOKEN_D
2460*cdf0e10cSrcweir 	| 	SQL_TOKEN_T
2461*cdf0e10cSrcweir 	| 	SQL_TOKEN_TS
2462*cdf0e10cSrcweir 	;
2463*cdf0e10cSrcweir 
2464*cdf0e10cSrcweir general_set_fct:
2465*cdf0e10cSrcweir 		set_fct_type '(' opt_all_distinct function_arg ')'
2466*cdf0e10cSrcweir 		{
2467*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2468*cdf0e10cSrcweir 			$$->append($1);
2469*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2470*cdf0e10cSrcweir 			$$->append($3);
2471*cdf0e10cSrcweir 			$$->append($4);
2472*cdf0e10cSrcweir 			$$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
2473*cdf0e10cSrcweir 		}
2474*cdf0e10cSrcweir 	|	SQL_TOKEN_COUNT '(' '*' ')'
2475*cdf0e10cSrcweir 		{
2476*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2477*cdf0e10cSrcweir 			$$->append($1);
2478*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2479*cdf0e10cSrcweir 			$$->append($3 = newNode("*", SQL_NODE_PUNCTUATION));
2480*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
2481*cdf0e10cSrcweir 		}
2482*cdf0e10cSrcweir 	|	SQL_TOKEN_COUNT '(' opt_all_distinct function_arg ')'
2483*cdf0e10cSrcweir 		{
2484*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2485*cdf0e10cSrcweir 			$$->append($1);
2486*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2487*cdf0e10cSrcweir 			$$->append($3);
2488*cdf0e10cSrcweir 			$$->append($4);
2489*cdf0e10cSrcweir 			$$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
2490*cdf0e10cSrcweir 		}
2491*cdf0e10cSrcweir 	|	ordered_set_function
2492*cdf0e10cSrcweir 	|	array_aggregate_function
2493*cdf0e10cSrcweir 	;
2494*cdf0e10cSrcweir set_fct_type:
2495*cdf0e10cSrcweir 		SQL_TOKEN_AVG
2496*cdf0e10cSrcweir 	|   SQL_TOKEN_MAX
2497*cdf0e10cSrcweir 	|   SQL_TOKEN_MIN
2498*cdf0e10cSrcweir 	|   SQL_TOKEN_SUM
2499*cdf0e10cSrcweir 	|   SQL_TOKEN_EVERY
2500*cdf0e10cSrcweir 	|   SQL_TOKEN_ANY
2501*cdf0e10cSrcweir 	|   SQL_TOKEN_SOME
2502*cdf0e10cSrcweir 	|   SQL_TOKEN_STDDEV_POP
2503*cdf0e10cSrcweir 	|   SQL_TOKEN_STDDEV_SAMP
2504*cdf0e10cSrcweir 	|   SQL_TOKEN_VAR_SAMP
2505*cdf0e10cSrcweir 	|   SQL_TOKEN_VAR_POP
2506*cdf0e10cSrcweir 	|   SQL_TOKEN_COLLECT
2507*cdf0e10cSrcweir 	|   SQL_TOKEN_FUSION
2508*cdf0e10cSrcweir 	|   SQL_TOKEN_INTERSECTION
2509*cdf0e10cSrcweir 	;
2510*cdf0e10cSrcweir 
2511*cdf0e10cSrcweir ordered_set_function:
2512*cdf0e10cSrcweir 		hypothetical_set_function
2513*cdf0e10cSrcweir 	|	inverse_distribution_function
2514*cdf0e10cSrcweir 	;
2515*cdf0e10cSrcweir hypothetical_set_function:
2516*cdf0e10cSrcweir 		rank_function_type '('	hypothetical_set_function_value_expression_list ')'	within_group_specification
2517*cdf0e10cSrcweir 		{
2518*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2519*cdf0e10cSrcweir 			$$->append($1);
2520*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2521*cdf0e10cSrcweir 			$$->append($3);
2522*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
2523*cdf0e10cSrcweir 			$$->append($5);
2524*cdf0e10cSrcweir 		}
2525*cdf0e10cSrcweir 	|	rank_function_type '('	hypothetical_set_function_value_expression_list SQL_TOKEN_BY value_exp_commalist ')'	within_group_specification
2526*cdf0e10cSrcweir 	{
2527*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
2528*cdf0e10cSrcweir 		$$->append($1);
2529*cdf0e10cSrcweir 		$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2530*cdf0e10cSrcweir 		$$->append($3);
2531*cdf0e10cSrcweir 		$$->append($4);
2532*cdf0e10cSrcweir 		$$->append($5);
2533*cdf0e10cSrcweir 		$$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
2534*cdf0e10cSrcweir 		$$->append($7);
2535*cdf0e10cSrcweir 	}
2536*cdf0e10cSrcweir 	;
2537*cdf0e10cSrcweir 
2538*cdf0e10cSrcweir within_group_specification:
2539*cdf0e10cSrcweir 	{
2540*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
2541*cdf0e10cSrcweir 	}
2542*cdf0e10cSrcweir 	|	SQL_TOKEN_WITHIN SQL_TOKEN_GROUP '(' opt_order_by_clause ')'
2543*cdf0e10cSrcweir 	{
2544*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
2545*cdf0e10cSrcweir 		$$->append($1);
2546*cdf0e10cSrcweir 		$$->append($2);
2547*cdf0e10cSrcweir 		$$->append($3 = newNode("(", SQL_NODE_PUNCTUATION));
2548*cdf0e10cSrcweir 		$$->append($4);
2549*cdf0e10cSrcweir 		$$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
2550*cdf0e10cSrcweir 	}
2551*cdf0e10cSrcweir 	;
2552*cdf0e10cSrcweir hypothetical_set_function_value_expression_list:
2553*cdf0e10cSrcweir 	value_exp_commalist
2554*cdf0e10cSrcweir 	;
2555*cdf0e10cSrcweir 
2556*cdf0e10cSrcweir inverse_distribution_function:
2557*cdf0e10cSrcweir 	inverse_distribution_function_type '('inverse_distribution_function_argument ')' within_group_specification
2558*cdf0e10cSrcweir 	{
2559*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
2560*cdf0e10cSrcweir 		$$->append($1);
2561*cdf0e10cSrcweir 		$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2562*cdf0e10cSrcweir 		$$->append($3);
2563*cdf0e10cSrcweir 		$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
2564*cdf0e10cSrcweir 	}
2565*cdf0e10cSrcweir 	;
2566*cdf0e10cSrcweir inverse_distribution_function_argument:
2567*cdf0e10cSrcweir 		num_value_exp
2568*cdf0e10cSrcweir 	;
2569*cdf0e10cSrcweir inverse_distribution_function_type:
2570*cdf0e10cSrcweir 		SQL_TOKEN_PERCENTILE_CONT
2571*cdf0e10cSrcweir 	|	SQL_TOKEN_PERCENTILE_DISC
2572*cdf0e10cSrcweir 	;
2573*cdf0e10cSrcweir 
2574*cdf0e10cSrcweir array_aggregate_function:
2575*cdf0e10cSrcweir 	SQL_TOKEN_ARRAY_AGG '(' value_exp opt_order_by_clause ')'
2576*cdf0e10cSrcweir 	{
2577*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
2578*cdf0e10cSrcweir 		$$->append($1);
2579*cdf0e10cSrcweir 		$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2580*cdf0e10cSrcweir 		$$->append($3);
2581*cdf0e10cSrcweir 		$$->append($4);
2582*cdf0e10cSrcweir 		$$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
2583*cdf0e10cSrcweir 	}
2584*cdf0e10cSrcweir 	;
2585*cdf0e10cSrcweir 
2586*cdf0e10cSrcweir rank_function_type:
2587*cdf0e10cSrcweir 		SQL_TOKEN_RANK
2588*cdf0e10cSrcweir 	|	SQL_TOKEN_DENSE_RANK
2589*cdf0e10cSrcweir 	|	SQL_TOKEN_PERCENT_RANK
2590*cdf0e10cSrcweir 	|	SQL_TOKEN_CUME_DIST
2591*cdf0e10cSrcweir 	;
2592*cdf0e10cSrcweir outer_join_type:
2593*cdf0e10cSrcweir 		SQL_TOKEN_LEFT %prec SQL_TOKEN_LEFT
2594*cdf0e10cSrcweir 		{
2595*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2596*cdf0e10cSrcweir 			$$->append($1);
2597*cdf0e10cSrcweir 		}
2598*cdf0e10cSrcweir 	  | SQL_TOKEN_RIGHT %prec SQL_TOKEN_RIGHT
2599*cdf0e10cSrcweir 		{
2600*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2601*cdf0e10cSrcweir 			$$->append($1);
2602*cdf0e10cSrcweir 		}
2603*cdf0e10cSrcweir 	  | SQL_TOKEN_FULL %prec SQL_TOKEN_FULL
2604*cdf0e10cSrcweir 		{
2605*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2606*cdf0e10cSrcweir 			$$->append($1);
2607*cdf0e10cSrcweir 		}
2608*cdf0e10cSrcweir 	  ;
2609*cdf0e10cSrcweir join_condition:
2610*cdf0e10cSrcweir 		SQL_TOKEN_ON search_condition
2611*cdf0e10cSrcweir 		{
2612*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2613*cdf0e10cSrcweir 			$$->append($1);
2614*cdf0e10cSrcweir 			$$->append($2);
2615*cdf0e10cSrcweir 		}
2616*cdf0e10cSrcweir 		;
2617*cdf0e10cSrcweir join_spec:
2618*cdf0e10cSrcweir 		join_condition
2619*cdf0e10cSrcweir 	  | named_columns_join
2620*cdf0e10cSrcweir 	  ;
2621*cdf0e10cSrcweir join_type:
2622*cdf0e10cSrcweir 		/* empty */ 	{$$ = SQL_NEW_RULE;}
2623*cdf0e10cSrcweir 	  | SQL_TOKEN_INNER
2624*cdf0e10cSrcweir 		{
2625*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2626*cdf0e10cSrcweir 			$$->append($1);
2627*cdf0e10cSrcweir 		}
2628*cdf0e10cSrcweir 	  | outer_join_type
2629*cdf0e10cSrcweir 	  | outer_join_type SQL_TOKEN_OUTER
2630*cdf0e10cSrcweir 		{
2631*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2632*cdf0e10cSrcweir 			$$->append($1);
2633*cdf0e10cSrcweir 			$$->append($2);
2634*cdf0e10cSrcweir 		}
2635*cdf0e10cSrcweir 	;
2636*cdf0e10cSrcweir cross_union:
2637*cdf0e10cSrcweir 		table_ref SQL_TOKEN_CROSS SQL_TOKEN_JOIN table_ref
2638*cdf0e10cSrcweir 		{
2639*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2640*cdf0e10cSrcweir 			$$->append($1);
2641*cdf0e10cSrcweir 			$$->append($2);
2642*cdf0e10cSrcweir 			$$->append($3);
2643*cdf0e10cSrcweir 			$$->append($4);
2644*cdf0e10cSrcweir 		}
2645*cdf0e10cSrcweir 	;
2646*cdf0e10cSrcweir 
2647*cdf0e10cSrcweir qualified_join:
2648*cdf0e10cSrcweir 		/* wenn SQL_TOKEN_NATURAL, dann keine join_spec */
2649*cdf0e10cSrcweir 		table_ref SQL_TOKEN_NATURAL join_type SQL_TOKEN_JOIN table_ref
2650*cdf0e10cSrcweir 		{
2651*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2652*cdf0e10cSrcweir 			$$->append($1);
2653*cdf0e10cSrcweir 			$$->append($2);
2654*cdf0e10cSrcweir 			$$->append($3);
2655*cdf0e10cSrcweir 			$$->append($4);
2656*cdf0e10cSrcweir 			$$->append($5);
2657*cdf0e10cSrcweir 		}
2658*cdf0e10cSrcweir 	|	table_ref join_type SQL_TOKEN_JOIN table_ref join_spec
2659*cdf0e10cSrcweir 		{
2660*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2661*cdf0e10cSrcweir 			$$->append($1);
2662*cdf0e10cSrcweir 			$$->append($2);
2663*cdf0e10cSrcweir 			$$->append($3);
2664*cdf0e10cSrcweir 			$$->append($4);
2665*cdf0e10cSrcweir 			$$->append($5);
2666*cdf0e10cSrcweir 		}
2667*cdf0e10cSrcweir 	|	cross_union
2668*cdf0e10cSrcweir 	;
2669*cdf0e10cSrcweir joined_table:
2670*cdf0e10cSrcweir 		qualified_join
2671*cdf0e10cSrcweir 	;
2672*cdf0e10cSrcweir named_columns_join:
2673*cdf0e10cSrcweir 		SQL_TOKEN_USING '(' column_commalist ')'
2674*cdf0e10cSrcweir 		{
2675*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2676*cdf0e10cSrcweir 			$$->append($1);
2677*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2678*cdf0e10cSrcweir 			$$->append($3);
2679*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
2680*cdf0e10cSrcweir 		}
2681*cdf0e10cSrcweir 	;
2682*cdf0e10cSrcweir simple_table:
2683*cdf0e10cSrcweir 		select_statement
2684*cdf0e10cSrcweir 	  | values_or_query_spec
2685*cdf0e10cSrcweir 	  ;
2686*cdf0e10cSrcweir 
2687*cdf0e10cSrcweir non_join_query_primary:
2688*cdf0e10cSrcweir 		simple_table
2689*cdf0e10cSrcweir 	  | '(' non_join_query_exp ')'
2690*cdf0e10cSrcweir 		{
2691*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2692*cdf0e10cSrcweir 			$$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
2693*cdf0e10cSrcweir 			$$->append($2);
2694*cdf0e10cSrcweir 			$$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
2695*cdf0e10cSrcweir 		}
2696*cdf0e10cSrcweir 	  ;
2697*cdf0e10cSrcweir non_join_query_term:
2698*cdf0e10cSrcweir 		non_join_query_primary
2699*cdf0e10cSrcweir 	|	query_term SQL_TOKEN_INTERSECT all query_primary
2700*cdf0e10cSrcweir 		{
2701*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2702*cdf0e10cSrcweir 			$$->append($1);
2703*cdf0e10cSrcweir 			$$->append($2);
2704*cdf0e10cSrcweir 			$$->append($3);
2705*cdf0e10cSrcweir 			$$->append($4);
2706*cdf0e10cSrcweir 		}
2707*cdf0e10cSrcweir 	;
2708*cdf0e10cSrcweir query_primary:
2709*cdf0e10cSrcweir 		non_join_query_primary
2710*cdf0e10cSrcweir 	;
2711*cdf0e10cSrcweir non_join_query_exp:
2712*cdf0e10cSrcweir 		non_join_query_term
2713*cdf0e10cSrcweir 	  | query_exp SQL_TOKEN_UNION all query_term
2714*cdf0e10cSrcweir 		{
2715*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2716*cdf0e10cSrcweir 			$$->append($1);
2717*cdf0e10cSrcweir 			$$->append($2);
2718*cdf0e10cSrcweir 			$$->append($3);
2719*cdf0e10cSrcweir 			$$->append($4);
2720*cdf0e10cSrcweir 		}
2721*cdf0e10cSrcweir 	  | query_exp SQL_TOKEN_EXCEPT all query_term
2722*cdf0e10cSrcweir 		{
2723*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2724*cdf0e10cSrcweir 			$$->append($1);
2725*cdf0e10cSrcweir 			$$->append($2);
2726*cdf0e10cSrcweir 			$$->append($3);
2727*cdf0e10cSrcweir 			$$->append($4);
2728*cdf0e10cSrcweir 		}
2729*cdf0e10cSrcweir 	;
2730*cdf0e10cSrcweir all:
2731*cdf0e10cSrcweir 	/* empty*/ {$$ = SQL_NEW_RULE;}
2732*cdf0e10cSrcweir 	|	SQL_TOKEN_ALL
2733*cdf0e10cSrcweir 	;
2734*cdf0e10cSrcweir query_exp:
2735*cdf0e10cSrcweir 		non_join_query_exp /*[^')']*/
2736*cdf0e10cSrcweir 	;
2737*cdf0e10cSrcweir scalar_subquery:
2738*cdf0e10cSrcweir 		subquery
2739*cdf0e10cSrcweir 	;
2740*cdf0e10cSrcweir cast_operand:
2741*cdf0e10cSrcweir 		value_exp
2742*cdf0e10cSrcweir 	;
2743*cdf0e10cSrcweir cast_target:
2744*cdf0e10cSrcweir 		table_node
2745*cdf0e10cSrcweir 	  | data_type
2746*cdf0e10cSrcweir 	;
2747*cdf0e10cSrcweir cast_spec:
2748*cdf0e10cSrcweir 	  SQL_TOKEN_CAST '(' cast_operand SQL_TOKEN_AS cast_target ')'
2749*cdf0e10cSrcweir 	  {
2750*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2751*cdf0e10cSrcweir 			$$->append($1);
2752*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
2753*cdf0e10cSrcweir 			$$->append($3);
2754*cdf0e10cSrcweir 			$$->append($4);
2755*cdf0e10cSrcweir 			$$->append($5);
2756*cdf0e10cSrcweir 			$$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
2757*cdf0e10cSrcweir 		}
2758*cdf0e10cSrcweir 	;
2759*cdf0e10cSrcweir value_exp_primary:
2760*cdf0e10cSrcweir 		unsigned_value_spec
2761*cdf0e10cSrcweir 	  | column_ref
2762*cdf0e10cSrcweir 	  | set_fct_spec
2763*cdf0e10cSrcweir 	  | scalar_subquery
2764*cdf0e10cSrcweir 	  | case_expression
2765*cdf0e10cSrcweir 	  | window_function
2766*cdf0e10cSrcweir 	  | '(' value_exp ')'
2767*cdf0e10cSrcweir 		{
2768*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2769*cdf0e10cSrcweir 			$$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
2770*cdf0e10cSrcweir 			$$->append($2);
2771*cdf0e10cSrcweir 			$$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
2772*cdf0e10cSrcweir 		}
2773*cdf0e10cSrcweir 	  | cast_spec
2774*cdf0e10cSrcweir 	;
2775*cdf0e10cSrcweir 
2776*cdf0e10cSrcweir num_primary:
2777*cdf0e10cSrcweir 		value_exp_primary
2778*cdf0e10cSrcweir 	  | num_value_fct
2779*cdf0e10cSrcweir 	;
2780*cdf0e10cSrcweir factor:
2781*cdf0e10cSrcweir 		num_primary
2782*cdf0e10cSrcweir 	|	'-' num_primary  %prec SQL_TOKEN_UMINUS
2783*cdf0e10cSrcweir 		{
2784*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2785*cdf0e10cSrcweir 			$$->append($1 = newNode("-", SQL_NODE_PUNCTUATION));
2786*cdf0e10cSrcweir 			$$->append($2);
2787*cdf0e10cSrcweir 		}
2788*cdf0e10cSrcweir 	|	'+' num_primary  %prec SQL_TOKEN_UMINUS
2789*cdf0e10cSrcweir 		{
2790*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2791*cdf0e10cSrcweir 			$$->append($1 = newNode("+", SQL_NODE_PUNCTUATION));
2792*cdf0e10cSrcweir 			$$->append($2);
2793*cdf0e10cSrcweir 		}
2794*cdf0e10cSrcweir 	;
2795*cdf0e10cSrcweir 
2796*cdf0e10cSrcweir term:
2797*cdf0e10cSrcweir 		factor
2798*cdf0e10cSrcweir 	  | term '*' factor
2799*cdf0e10cSrcweir 		{
2800*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2801*cdf0e10cSrcweir 			$$->append($1);
2802*cdf0e10cSrcweir 			$$->append($2 = newNode("*", SQL_NODE_PUNCTUATION));
2803*cdf0e10cSrcweir 			$$->append($3);
2804*cdf0e10cSrcweir 		}
2805*cdf0e10cSrcweir 	  | term '/' factor
2806*cdf0e10cSrcweir 		{
2807*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2808*cdf0e10cSrcweir 			$$->append($1);
2809*cdf0e10cSrcweir 			$$->append($2 = newNode("/", SQL_NODE_PUNCTUATION));
2810*cdf0e10cSrcweir 			$$->append($3);
2811*cdf0e10cSrcweir 		}
2812*cdf0e10cSrcweir 	  ;
2813*cdf0e10cSrcweir 
2814*cdf0e10cSrcweir num_value_exp:
2815*cdf0e10cSrcweir 		term
2816*cdf0e10cSrcweir 	  | num_value_exp '+' term
2817*cdf0e10cSrcweir 		{
2818*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2819*cdf0e10cSrcweir 			$$->append($1);
2820*cdf0e10cSrcweir 			$$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
2821*cdf0e10cSrcweir 			$$->append($3);
2822*cdf0e10cSrcweir 		}
2823*cdf0e10cSrcweir 	  | num_value_exp '-' term
2824*cdf0e10cSrcweir 		{
2825*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2826*cdf0e10cSrcweir 			$$->append($1);
2827*cdf0e10cSrcweir 			$$->append($2 = newNode("-", SQL_NODE_PUNCTUATION));
2828*cdf0e10cSrcweir 			$$->append($3);
2829*cdf0e10cSrcweir 		}
2830*cdf0e10cSrcweir 	  ;
2831*cdf0e10cSrcweir datetime_primary:
2832*cdf0e10cSrcweir /*		value_exp_primary
2833*cdf0e10cSrcweir 		{
2834*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2835*cdf0e10cSrcweir 			$$->append($1);
2836*cdf0e10cSrcweir 		}
2837*cdf0e10cSrcweir 	  |*/ datetime_value_fct
2838*cdf0e10cSrcweir 		{
2839*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2840*cdf0e10cSrcweir 			$$->append($1);
2841*cdf0e10cSrcweir 		}
2842*cdf0e10cSrcweir 	;
2843*cdf0e10cSrcweir datetime_value_fct:
2844*cdf0e10cSrcweir 		SQL_TOKEN_CURRENT_DATE
2845*cdf0e10cSrcweir 		{
2846*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2847*cdf0e10cSrcweir 			$$->append($1);
2848*cdf0e10cSrcweir 		}
2849*cdf0e10cSrcweir 	  | SQL_TOKEN_CURRENT_TIME
2850*cdf0e10cSrcweir 		{
2851*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2852*cdf0e10cSrcweir 			$$->append($1);
2853*cdf0e10cSrcweir 		}
2854*cdf0e10cSrcweir 	  | SQL_TOKEN_CURRENT_TIMESTAMP
2855*cdf0e10cSrcweir 		{
2856*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2857*cdf0e10cSrcweir 			$$->append($1);
2858*cdf0e10cSrcweir 		}
2859*cdf0e10cSrcweir 	;
2860*cdf0e10cSrcweir time_zone:
2861*cdf0e10cSrcweir 		SQL_TOKEN_AT time_zone_specifier
2862*cdf0e10cSrcweir 		{
2863*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2864*cdf0e10cSrcweir 			$$->append($1);
2865*cdf0e10cSrcweir 			$$->append($2);
2866*cdf0e10cSrcweir 		}
2867*cdf0e10cSrcweir 	;
2868*cdf0e10cSrcweir time_zone_specifier:
2869*cdf0e10cSrcweir 		SQL_TOKEN_LOCAL
2870*cdf0e10cSrcweir 		{
2871*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2872*cdf0e10cSrcweir 			$$->append($1);
2873*cdf0e10cSrcweir 		}
2874*cdf0e10cSrcweir /*      | SQL_TOKEN_TIME SQL_TOKEN_ZONE interval_value_exp
2875*cdf0e10cSrcweir 		{
2876*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2877*cdf0e10cSrcweir 			$$->append($1);
2878*cdf0e10cSrcweir 			$$->append($2);
2879*cdf0e10cSrcweir 			$$->append($3);
2880*cdf0e10cSrcweir 		}*/
2881*cdf0e10cSrcweir 	  ;
2882*cdf0e10cSrcweir datetime_factor:
2883*cdf0e10cSrcweir 		datetime_primary
2884*cdf0e10cSrcweir 		{
2885*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2886*cdf0e10cSrcweir 			$$->append($1);
2887*cdf0e10cSrcweir 		}
2888*cdf0e10cSrcweir 	|	datetime_primary time_zone
2889*cdf0e10cSrcweir 		{
2890*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2891*cdf0e10cSrcweir 			$$->append($1);
2892*cdf0e10cSrcweir 			$$->append($2);
2893*cdf0e10cSrcweir 		}
2894*cdf0e10cSrcweir 	;
2895*cdf0e10cSrcweir datetime_term:
2896*cdf0e10cSrcweir 		datetime_factor
2897*cdf0e10cSrcweir 		{
2898*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2899*cdf0e10cSrcweir 			$$->append($1);
2900*cdf0e10cSrcweir 		}
2901*cdf0e10cSrcweir 	;
2902*cdf0e10cSrcweir /*
2903*cdf0e10cSrcweir interval_term:
2904*cdf0e10cSrcweir 		literal
2905*cdf0e10cSrcweir 	  | interval_term '*' factor
2906*cdf0e10cSrcweir 		{
2907*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2908*cdf0e10cSrcweir 			$$->append($1);
2909*cdf0e10cSrcweir 			$$->append($2 = newNode("*", SQL_NODE_PUNCTUATION));
2910*cdf0e10cSrcweir 			$$->append($3);
2911*cdf0e10cSrcweir 		}
2912*cdf0e10cSrcweir 	  | interval_term '/' factor
2913*cdf0e10cSrcweir 		{
2914*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2915*cdf0e10cSrcweir 			$$->append($1);
2916*cdf0e10cSrcweir 			$$->append($2 = newNode("/", SQL_NODE_PUNCTUATION));
2917*cdf0e10cSrcweir 			$$->append($3);
2918*cdf0e10cSrcweir 		}
2919*cdf0e10cSrcweir 	;
2920*cdf0e10cSrcweir */
2921*cdf0e10cSrcweir datetime_value_exp:
2922*cdf0e10cSrcweir 		datetime_term
2923*cdf0e10cSrcweir 		{
2924*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2925*cdf0e10cSrcweir 			$$->append($1);
2926*cdf0e10cSrcweir 		}
2927*cdf0e10cSrcweir /*      | interval_value_exp '+' datetime_term
2928*cdf0e10cSrcweir 		{
2929*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2930*cdf0e10cSrcweir 			$$->append($1);
2931*cdf0e10cSrcweir 			$$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
2932*cdf0e10cSrcweir 			$$->append($3);
2933*cdf0e10cSrcweir 		}
2934*cdf0e10cSrcweir 	  | datetime_value_exp '+' interval_term
2935*cdf0e10cSrcweir 		{
2936*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2937*cdf0e10cSrcweir 			$$->append($1);
2938*cdf0e10cSrcweir 			$$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
2939*cdf0e10cSrcweir 			$$->append($3);
2940*cdf0e10cSrcweir 		}
2941*cdf0e10cSrcweir 	  | datetime_value_exp '-' interval_term
2942*cdf0e10cSrcweir 		{
2943*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2944*cdf0e10cSrcweir 			$$->append($1);
2945*cdf0e10cSrcweir 			$$->append($2 = newNode("-", SQL_NODE_PUNCTUATION));
2946*cdf0e10cSrcweir 			$$->append($3);
2947*cdf0e10cSrcweir 		}
2948*cdf0e10cSrcweir */	;
2949*cdf0e10cSrcweir /*
2950*cdf0e10cSrcweir interval_value_exp:
2951*cdf0e10cSrcweir 		interval_term
2952*cdf0e10cSrcweir 		{
2953*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2954*cdf0e10cSrcweir 			$$->append($1);
2955*cdf0e10cSrcweir 		}
2956*cdf0e10cSrcweir 	  | interval_value_exp '+' interval_term
2957*cdf0e10cSrcweir 		{
2958*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2959*cdf0e10cSrcweir 			$$->append($1);
2960*cdf0e10cSrcweir 			$$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
2961*cdf0e10cSrcweir 			$$->append($3);
2962*cdf0e10cSrcweir 		}
2963*cdf0e10cSrcweir 	  | interval_value_exp '-' interval_term
2964*cdf0e10cSrcweir 		{
2965*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2966*cdf0e10cSrcweir 			$$->append($1);
2967*cdf0e10cSrcweir 			$$->append($2 = newNode("-", SQL_NODE_PUNCTUATION));
2968*cdf0e10cSrcweir 			$$->append($3);
2969*cdf0e10cSrcweir 		}
2970*cdf0e10cSrcweir 	  | '(' datetime_value_exp '-' datetime_term ')' interval_qualifier
2971*cdf0e10cSrcweir 		{
2972*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2973*cdf0e10cSrcweir 			$$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
2974*cdf0e10cSrcweir 			$$->append($2);
2975*cdf0e10cSrcweir 			$$->append($3 = newNode("-", SQL_NODE_PUNCTUATION));
2976*cdf0e10cSrcweir 			$$->append($4);
2977*cdf0e10cSrcweir 			$$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
2978*cdf0e10cSrcweir 			$$->append($6);
2979*cdf0e10cSrcweir 		}
2980*cdf0e10cSrcweir 	;
2981*cdf0e10cSrcweir */
2982*cdf0e10cSrcweir non_second_datetime_field:
2983*cdf0e10cSrcweir 		SQL_TOKEN_YEAR
2984*cdf0e10cSrcweir 	|	SQL_TOKEN_MONTH
2985*cdf0e10cSrcweir 	|	SQL_TOKEN_DAY
2986*cdf0e10cSrcweir 	|	SQL_TOKEN_HOUR
2987*cdf0e10cSrcweir 	|	SQL_TOKEN_MINUTE
2988*cdf0e10cSrcweir 	;
2989*cdf0e10cSrcweir start_field:
2990*cdf0e10cSrcweir 		non_second_datetime_field opt_paren_precision
2991*cdf0e10cSrcweir 		{
2992*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
2993*cdf0e10cSrcweir 			$$->append($1);
2994*cdf0e10cSrcweir 			$$->append($2);
2995*cdf0e10cSrcweir 		}
2996*cdf0e10cSrcweir 	;
2997*cdf0e10cSrcweir end_field:
2998*cdf0e10cSrcweir 		non_second_datetime_field
2999*cdf0e10cSrcweir 	|	SQL_TOKEN_SECOND opt_paren_precision
3000*cdf0e10cSrcweir 		{
3001*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3002*cdf0e10cSrcweir 			$$->append($1);
3003*cdf0e10cSrcweir 			$$->append($2);
3004*cdf0e10cSrcweir 		}
3005*cdf0e10cSrcweir 	;
3006*cdf0e10cSrcweir 
3007*cdf0e10cSrcweir single_datetime_field:
3008*cdf0e10cSrcweir 		non_second_datetime_field opt_paren_precision
3009*cdf0e10cSrcweir 		{
3010*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3011*cdf0e10cSrcweir 			$$->append($1);
3012*cdf0e10cSrcweir 			$$->append($2);
3013*cdf0e10cSrcweir 		}
3014*cdf0e10cSrcweir 	|	SQL_TOKEN_SECOND opt_paren_precision_scale
3015*cdf0e10cSrcweir 		{
3016*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3017*cdf0e10cSrcweir 			$$->append($1);
3018*cdf0e10cSrcweir 			$$->append($2);
3019*cdf0e10cSrcweir 		}
3020*cdf0e10cSrcweir 	;
3021*cdf0e10cSrcweir 
3022*cdf0e10cSrcweir interval_qualifier:
3023*cdf0e10cSrcweir 		start_field SQL_TOKEN_TO end_field
3024*cdf0e10cSrcweir 		{
3025*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3026*cdf0e10cSrcweir 			$$->append($1);
3027*cdf0e10cSrcweir 			$$->append($2);
3028*cdf0e10cSrcweir 			$$->append($3);
3029*cdf0e10cSrcweir 		}
3030*cdf0e10cSrcweir 	|	single_datetime_field
3031*cdf0e10cSrcweir 	;
3032*cdf0e10cSrcweir 
3033*cdf0e10cSrcweir function_arg_commalist2:
3034*cdf0e10cSrcweir 	    function_arg ',' function_arg
3035*cdf0e10cSrcweir 			{$$ = SQL_NEW_COMMALISTRULE;
3036*cdf0e10cSrcweir 			$$->append($1);
3037*cdf0e10cSrcweir 			$$->append($3);}
3038*cdf0e10cSrcweir 	;
3039*cdf0e10cSrcweir function_arg_commalist3:
3040*cdf0e10cSrcweir 	    function_arg ',' function_arg ',' function_arg
3041*cdf0e10cSrcweir 		{
3042*cdf0e10cSrcweir 			$$ = SQL_NEW_COMMALISTRULE;
3043*cdf0e10cSrcweir 			$$->append($1);
3044*cdf0e10cSrcweir 			$$->append($3);
3045*cdf0e10cSrcweir 			$$->append($5);
3046*cdf0e10cSrcweir 		}
3047*cdf0e10cSrcweir 	;
3048*cdf0e10cSrcweir function_arg_commalist4:
3049*cdf0e10cSrcweir 	    function_arg ',' function_arg ',' function_arg ',' function_arg
3050*cdf0e10cSrcweir 		{
3051*cdf0e10cSrcweir 			$$ = SQL_NEW_COMMALISTRULE;
3052*cdf0e10cSrcweir 			$$->append($1);
3053*cdf0e10cSrcweir 			$$->append($3);
3054*cdf0e10cSrcweir 			$$->append($5);
3055*cdf0e10cSrcweir 			$$->append($7);
3056*cdf0e10cSrcweir 		}
3057*cdf0e10cSrcweir 	;
3058*cdf0e10cSrcweir value_exp_commalist:
3059*cdf0e10cSrcweir 		value_exp
3060*cdf0e10cSrcweir 			{$$ = SQL_NEW_COMMALISTRULE;
3061*cdf0e10cSrcweir 			$$->append($1);}
3062*cdf0e10cSrcweir 	|   value_exp_commalist ',' value_exp
3063*cdf0e10cSrcweir 			{$1->append($3);
3064*cdf0e10cSrcweir 			$$ = $1;}
3065*cdf0e10cSrcweir 	/*	this rule is only valid if we check predicates */
3066*cdf0e10cSrcweir 	|   value_exp_commalist ';' value_exp
3067*cdf0e10cSrcweir 		{
3068*cdf0e10cSrcweir 			if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
3069*cdf0e10cSrcweir 			{
3070*cdf0e10cSrcweir 				$1->append($3);
3071*cdf0e10cSrcweir 				$$ = $1;
3072*cdf0e10cSrcweir 			}
3073*cdf0e10cSrcweir 			else
3074*cdf0e10cSrcweir 				YYERROR;
3075*cdf0e10cSrcweir 		}
3076*cdf0e10cSrcweir 	;
3077*cdf0e10cSrcweir function_arg:
3078*cdf0e10cSrcweir 		result
3079*cdf0e10cSrcweir 	|	value_exp comparison value_exp
3080*cdf0e10cSrcweir 		{
3081*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3082*cdf0e10cSrcweir 			$$->append($1);
3083*cdf0e10cSrcweir 			$$->append($2);
3084*cdf0e10cSrcweir 			$$->append($3);
3085*cdf0e10cSrcweir 		}
3086*cdf0e10cSrcweir 	|	value_exp SQL_TOKEN_USING value_exp comparison value_exp
3087*cdf0e10cSrcweir 		{
3088*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3089*cdf0e10cSrcweir 			$$->append($1);
3090*cdf0e10cSrcweir 			$$->append($2);
3091*cdf0e10cSrcweir 			$$->append($3);
3092*cdf0e10cSrcweir 			$$->append($4);
3093*cdf0e10cSrcweir 		}
3094*cdf0e10cSrcweir 	|	value_exp SQL_TOKEN_BY value_exp_commalist
3095*cdf0e10cSrcweir 		{
3096*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3097*cdf0e10cSrcweir 			$$->append($1);
3098*cdf0e10cSrcweir 			$$->append($2);
3099*cdf0e10cSrcweir 			$$->append($3);
3100*cdf0e10cSrcweir 		}
3101*cdf0e10cSrcweir 	;
3102*cdf0e10cSrcweir function_args_commalist:
3103*cdf0e10cSrcweir 		function_arg
3104*cdf0e10cSrcweir 			{$$ = SQL_NEW_COMMALISTRULE;
3105*cdf0e10cSrcweir 			$$->append($1);}
3106*cdf0e10cSrcweir 	|   function_args_commalist ',' function_arg
3107*cdf0e10cSrcweir 			{$1->append($3);
3108*cdf0e10cSrcweir 			$$ = $1;}
3109*cdf0e10cSrcweir 	/*	this rule is only valid if we check predicates */
3110*cdf0e10cSrcweir 	|   function_args_commalist ';' function_arg
3111*cdf0e10cSrcweir 		{
3112*cdf0e10cSrcweir 			if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck())
3113*cdf0e10cSrcweir 			{
3114*cdf0e10cSrcweir 				$1->append($3);
3115*cdf0e10cSrcweir 				$$ = $1;
3116*cdf0e10cSrcweir 			}
3117*cdf0e10cSrcweir 			else
3118*cdf0e10cSrcweir 				YYERROR;
3119*cdf0e10cSrcweir 		}
3120*cdf0e10cSrcweir 	;
3121*cdf0e10cSrcweir 
3122*cdf0e10cSrcweir value_exp:
3123*cdf0e10cSrcweir 		num_value_exp /*[^')']*/
3124*cdf0e10cSrcweir 	  | string_value_exp
3125*cdf0e10cSrcweir 	  | datetime_value_exp
3126*cdf0e10cSrcweir 		{
3127*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3128*cdf0e10cSrcweir 			$$->append($1);
3129*cdf0e10cSrcweir 		}
3130*cdf0e10cSrcweir 	;
3131*cdf0e10cSrcweir string_value_exp:
3132*cdf0e10cSrcweir 		char_value_exp
3133*cdf0e10cSrcweir /*      | bit_value_exp
3134*cdf0e10cSrcweir 		{
3135*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3136*cdf0e10cSrcweir 			$$->append($1);
3137*cdf0e10cSrcweir 		}
3138*cdf0e10cSrcweir */	;
3139*cdf0e10cSrcweir char_value_exp:
3140*cdf0e10cSrcweir 		char_factor
3141*cdf0e10cSrcweir 	|	concatenation
3142*cdf0e10cSrcweir 	;
3143*cdf0e10cSrcweir concatenation:
3144*cdf0e10cSrcweir 		char_value_exp '+' char_factor
3145*cdf0e10cSrcweir 		{
3146*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3147*cdf0e10cSrcweir 			$$->append($1);
3148*cdf0e10cSrcweir 			$$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
3149*cdf0e10cSrcweir 			$$->append($3);
3150*cdf0e10cSrcweir 		}
3151*cdf0e10cSrcweir 	|	value_exp SQL_CONCAT value_exp
3152*cdf0e10cSrcweir 		{
3153*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3154*cdf0e10cSrcweir 			$$->append($1);
3155*cdf0e10cSrcweir 			$$->append($2);
3156*cdf0e10cSrcweir 			$$->append($3);
3157*cdf0e10cSrcweir 		}
3158*cdf0e10cSrcweir 	;
3159*cdf0e10cSrcweir 
3160*cdf0e10cSrcweir char_primary:
3161*cdf0e10cSrcweir 			SQL_TOKEN_STRING
3162*cdf0e10cSrcweir 	  |		string_value_fct
3163*cdf0e10cSrcweir 	;
3164*cdf0e10cSrcweir collate_clause:
3165*cdf0e10cSrcweir 		SQL_TOKEN_COLLATE table_node
3166*cdf0e10cSrcweir 		{
3167*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3168*cdf0e10cSrcweir 			$$->append($1);
3169*cdf0e10cSrcweir 			$$->append($2);
3170*cdf0e10cSrcweir 		}
3171*cdf0e10cSrcweir 	;
3172*cdf0e10cSrcweir char_factor:
3173*cdf0e10cSrcweir 		char_primary
3174*cdf0e10cSrcweir 	|	char_primary collate_clause
3175*cdf0e10cSrcweir 		{
3176*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3177*cdf0e10cSrcweir 			$$->append($1);
3178*cdf0e10cSrcweir 			$$->append($2);
3179*cdf0e10cSrcweir 		}
3180*cdf0e10cSrcweir 	;
3181*cdf0e10cSrcweir string_value_fct:
3182*cdf0e10cSrcweir 		char_value_fct
3183*cdf0e10cSrcweir 	  | bit_value_fct
3184*cdf0e10cSrcweir 	;
3185*cdf0e10cSrcweir bit_value_fct:
3186*cdf0e10cSrcweir 		bit_substring_fct
3187*cdf0e10cSrcweir 		{
3188*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3189*cdf0e10cSrcweir 			$$->append($1);
3190*cdf0e10cSrcweir 		}
3191*cdf0e10cSrcweir 	;
3192*cdf0e10cSrcweir bit_substring_fct:
3193*cdf0e10cSrcweir 		SQL_TOKEN_SUBSTRING '(' bit_value_exp SQL_TOKEN_FROM string_value_exp for_length ')'
3194*cdf0e10cSrcweir 		{
3195*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3196*cdf0e10cSrcweir 			$$->append($1);
3197*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3198*cdf0e10cSrcweir 			$$->append($3);
3199*cdf0e10cSrcweir 			$$->append($4);
3200*cdf0e10cSrcweir 			$$->append($5);
3201*cdf0e10cSrcweir 			$$->append($6);
3202*cdf0e10cSrcweir 			$$->append($7 = newNode(")", SQL_NODE_PUNCTUATION));
3203*cdf0e10cSrcweir 		}
3204*cdf0e10cSrcweir 	;
3205*cdf0e10cSrcweir bit_value_exp:
3206*cdf0e10cSrcweir 		bit_factor
3207*cdf0e10cSrcweir 		{
3208*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3209*cdf0e10cSrcweir 			$$->append($1);
3210*cdf0e10cSrcweir 		}
3211*cdf0e10cSrcweir 	;
3212*cdf0e10cSrcweir /*
3213*cdf0e10cSrcweir 			bit_concatenation
3214*cdf0e10cSrcweir 		{
3215*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3216*cdf0e10cSrcweir 			$$->append($1);
3217*cdf0e10cSrcweir 		}
3218*cdf0e10cSrcweir 	  |
3219*cdf0e10cSrcweir bit_concatenation:
3220*cdf0e10cSrcweir 		bit_value_exp '+' bit_factor
3221*cdf0e10cSrcweir 		{
3222*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3223*cdf0e10cSrcweir 			$$->append($1);
3224*cdf0e10cSrcweir 			$$->append($2 = newNode("+", SQL_NODE_PUNCTUATION));
3225*cdf0e10cSrcweir 			$$->append($3);
3226*cdf0e10cSrcweir 		}
3227*cdf0e10cSrcweir 	;
3228*cdf0e10cSrcweir */
3229*cdf0e10cSrcweir bit_factor:
3230*cdf0e10cSrcweir 		bit_primary
3231*cdf0e10cSrcweir 		{
3232*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3233*cdf0e10cSrcweir 			$$->append($1);
3234*cdf0e10cSrcweir 		}
3235*cdf0e10cSrcweir 	;
3236*cdf0e10cSrcweir bit_primary:
3237*cdf0e10cSrcweir 	{$$ = SQL_NEW_RULE;}
3238*cdf0e10cSrcweir /*		value_exp_primary
3239*cdf0e10cSrcweir 		{
3240*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3241*cdf0e10cSrcweir 			$$->append($1);
3242*cdf0e10cSrcweir 		}
3243*cdf0e10cSrcweir 	  | string_value_fct
3244*cdf0e10cSrcweir 		{
3245*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3246*cdf0e10cSrcweir 			$$->append($1);
3247*cdf0e10cSrcweir 		}*/
3248*cdf0e10cSrcweir 	;
3249*cdf0e10cSrcweir char_value_fct:
3250*cdf0e10cSrcweir 		char_substring_fct
3251*cdf0e10cSrcweir 	  | fold
3252*cdf0e10cSrcweir 	  | form_conversion
3253*cdf0e10cSrcweir 		{
3254*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3255*cdf0e10cSrcweir 			$$->append($1);
3256*cdf0e10cSrcweir 		}
3257*cdf0e10cSrcweir 	  | char_translation
3258*cdf0e10cSrcweir 		{
3259*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3260*cdf0e10cSrcweir 			$$->append($1);
3261*cdf0e10cSrcweir 		}
3262*cdf0e10cSrcweir 	  | trim_fct
3263*cdf0e10cSrcweir 		{
3264*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3265*cdf0e10cSrcweir 			$$->append($1);
3266*cdf0e10cSrcweir 		}
3267*cdf0e10cSrcweir 	;
3268*cdf0e10cSrcweir for_length:
3269*cdf0e10cSrcweir 		{$$ = SQL_NEW_RULE;}
3270*cdf0e10cSrcweir 	|	SQL_TOKEN_FOR value_exp
3271*cdf0e10cSrcweir 		{
3272*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3273*cdf0e10cSrcweir 			$$->append($1);
3274*cdf0e10cSrcweir 			$$->append($2);
3275*cdf0e10cSrcweir 		}
3276*cdf0e10cSrcweir 	;
3277*cdf0e10cSrcweir char_substring_fct:
3278*cdf0e10cSrcweir 		SQL_TOKEN_SUBSTRING '(' value_exp SQL_TOKEN_FROM value_exp for_length ')'
3279*cdf0e10cSrcweir 		{
3280*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3281*cdf0e10cSrcweir 			$$->append($1);
3282*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3283*cdf0e10cSrcweir 			$$->append($3);
3284*cdf0e10cSrcweir 			$$->append($4);
3285*cdf0e10cSrcweir 			$$->append($5);
3286*cdf0e10cSrcweir 			$$->append($6);
3287*cdf0e10cSrcweir 			$$->append($7 = newNode(")", SQL_NODE_PUNCTUATION));
3288*cdf0e10cSrcweir 		}
3289*cdf0e10cSrcweir 	|	SQL_TOKEN_SUBSTRING '(' value_exp_commalist ')'
3290*cdf0e10cSrcweir 		{
3291*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3292*cdf0e10cSrcweir 			$$->append($1);
3293*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3294*cdf0e10cSrcweir 			$$->append($3);
3295*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
3296*cdf0e10cSrcweir 		}
3297*cdf0e10cSrcweir 	;
3298*cdf0e10cSrcweir upper_lower:
3299*cdf0e10cSrcweir 		SQL_TOKEN_UPPER
3300*cdf0e10cSrcweir 	|	SQL_TOKEN_LOWER
3301*cdf0e10cSrcweir 	;
3302*cdf0e10cSrcweir fold:
3303*cdf0e10cSrcweir 		upper_lower '(' value_exp ')'
3304*cdf0e10cSrcweir 		{
3305*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3306*cdf0e10cSrcweir 			$$->append($1);
3307*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3308*cdf0e10cSrcweir 			$$->append($3);
3309*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
3310*cdf0e10cSrcweir 		}
3311*cdf0e10cSrcweir 	;
3312*cdf0e10cSrcweir form_conversion:
3313*cdf0e10cSrcweir 		SQL_TOKEN_CONVERT '(' string_value_exp SQL_TOKEN_USING table_node ')'
3314*cdf0e10cSrcweir 		{
3315*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3316*cdf0e10cSrcweir 			$$->append($1);
3317*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3318*cdf0e10cSrcweir 			$$->append($3);
3319*cdf0e10cSrcweir 			$$->append($4);
3320*cdf0e10cSrcweir 			$$->append($5);
3321*cdf0e10cSrcweir 			$$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
3322*cdf0e10cSrcweir 		}
3323*cdf0e10cSrcweir 	|	SQL_TOKEN_CONVERT '(' cast_operand ',' cast_target ')'
3324*cdf0e10cSrcweir 		{
3325*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3326*cdf0e10cSrcweir 			$$->append($1);
3327*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3328*cdf0e10cSrcweir 			$$->append($3);
3329*cdf0e10cSrcweir 			$$->append($2 = newNode(",", SQL_NODE_PUNCTUATION));
3330*cdf0e10cSrcweir 			$$->append($5);
3331*cdf0e10cSrcweir 			$$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
3332*cdf0e10cSrcweir 		}
3333*cdf0e10cSrcweir 	;
3334*cdf0e10cSrcweir char_translation:
3335*cdf0e10cSrcweir 		SQL_TOKEN_TRANSLATE '(' string_value_exp SQL_TOKEN_USING table_node ')'
3336*cdf0e10cSrcweir 		{
3337*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3338*cdf0e10cSrcweir 			$$->append($1);
3339*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3340*cdf0e10cSrcweir 			$$->append($3);
3341*cdf0e10cSrcweir 			$$->append($4);
3342*cdf0e10cSrcweir 			$$->append($5);
3343*cdf0e10cSrcweir 			$$->append($6 = newNode(")", SQL_NODE_PUNCTUATION));
3344*cdf0e10cSrcweir 		}
3345*cdf0e10cSrcweir 	;
3346*cdf0e10cSrcweir trim_fct:
3347*cdf0e10cSrcweir 		SQL_TOKEN_TRIM  '(' trim_operands ')'
3348*cdf0e10cSrcweir 		{
3349*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3350*cdf0e10cSrcweir 			$$->append($1);
3351*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3352*cdf0e10cSrcweir 			$$->append($3);
3353*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
3354*cdf0e10cSrcweir 		}
3355*cdf0e10cSrcweir 	;
3356*cdf0e10cSrcweir trim_operands:
3357*cdf0e10cSrcweir     trim_spec value_exp SQL_TOKEN_FROM value_exp
3358*cdf0e10cSrcweir         {
3359*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3360*cdf0e10cSrcweir 			$$->append($1);
3361*cdf0e10cSrcweir 			$$->append($2);
3362*cdf0e10cSrcweir 			$$->append($3);
3363*cdf0e10cSrcweir 			$$->append($4);
3364*cdf0e10cSrcweir 		}
3365*cdf0e10cSrcweir 	| trim_spec SQL_TOKEN_FROM value_exp
3366*cdf0e10cSrcweir         {
3367*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3368*cdf0e10cSrcweir 			$$->append($1);
3369*cdf0e10cSrcweir 			$$->append($2);
3370*cdf0e10cSrcweir 			$$->append($3);
3371*cdf0e10cSrcweir 		}
3372*cdf0e10cSrcweir 	| value_exp SQL_TOKEN_FROM value_exp
3373*cdf0e10cSrcweir         {
3374*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3375*cdf0e10cSrcweir 			$$->append($1);
3376*cdf0e10cSrcweir 			$$->append($2);
3377*cdf0e10cSrcweir 			$$->append($3);
3378*cdf0e10cSrcweir 		}
3379*cdf0e10cSrcweir 	| SQL_TOKEN_FROM value_exp
3380*cdf0e10cSrcweir 	    {
3381*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3382*cdf0e10cSrcweir 			$$->append($1);
3383*cdf0e10cSrcweir 			$$->append($2);
3384*cdf0e10cSrcweir 		}
3385*cdf0e10cSrcweir 	| value_exp
3386*cdf0e10cSrcweir 	;
3387*cdf0e10cSrcweir 
3388*cdf0e10cSrcweir trim_spec:
3389*cdf0e10cSrcweir         SQL_TOKEN_BOTH
3390*cdf0e10cSrcweir 	|	SQL_TOKEN_LEADING
3391*cdf0e10cSrcweir 	|	SQL_TOKEN_TRAILING
3392*cdf0e10cSrcweir 	;
3393*cdf0e10cSrcweir 
3394*cdf0e10cSrcweir derived_column:
3395*cdf0e10cSrcweir 		value_exp as_clause
3396*cdf0e10cSrcweir 		{
3397*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3398*cdf0e10cSrcweir 			$$->append($1);
3399*cdf0e10cSrcweir 			$$->append($2);
3400*cdf0e10cSrcweir 		}
3401*cdf0e10cSrcweir 	;
3402*cdf0e10cSrcweir /* Tabellenname */
3403*cdf0e10cSrcweir table_node:
3404*cdf0e10cSrcweir 		table_name
3405*cdf0e10cSrcweir 	|	schema_name
3406*cdf0e10cSrcweir 	|	catalog_name
3407*cdf0e10cSrcweir ;
3408*cdf0e10cSrcweir catalog_name:
3409*cdf0e10cSrcweir 		SQL_TOKEN_NAME '.' schema_name
3410*cdf0e10cSrcweir 		{
3411*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3412*cdf0e10cSrcweir 			$$->append($1);
3413*cdf0e10cSrcweir 			$$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
3414*cdf0e10cSrcweir 			$$->append($3);
3415*cdf0e10cSrcweir 		}
3416*cdf0e10cSrcweir 	|	SQL_TOKEN_NAME ':' schema_name
3417*cdf0e10cSrcweir 		{
3418*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3419*cdf0e10cSrcweir 			$$->append($1);
3420*cdf0e10cSrcweir 			$$->append($2 = newNode(":", SQL_NODE_PUNCTUATION));
3421*cdf0e10cSrcweir 			$$->append($3);
3422*cdf0e10cSrcweir 		}
3423*cdf0e10cSrcweir ;
3424*cdf0e10cSrcweir schema_name:
3425*cdf0e10cSrcweir 		SQL_TOKEN_NAME '.' table_name
3426*cdf0e10cSrcweir 		{
3427*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3428*cdf0e10cSrcweir 			$$->append($1);
3429*cdf0e10cSrcweir 			$$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
3430*cdf0e10cSrcweir 			$$->append($3);
3431*cdf0e10cSrcweir 		}
3432*cdf0e10cSrcweir ;
3433*cdf0e10cSrcweir 
3434*cdf0e10cSrcweir table_name:
3435*cdf0e10cSrcweir 			SQL_TOKEN_NAME
3436*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
3437*cdf0e10cSrcweir 			$$->append($1);}
3438*cdf0e10cSrcweir ;
3439*cdf0e10cSrcweir /* Columns */
3440*cdf0e10cSrcweir column_ref:
3441*cdf0e10cSrcweir 			column
3442*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
3443*cdf0e10cSrcweir 			$$->append($1);}
3444*cdf0e10cSrcweir /*	|       table_node '.' column_val %prec '.'
3445*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
3446*cdf0e10cSrcweir 			$$->append($1);
3447*cdf0e10cSrcweir 			$$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
3448*cdf0e10cSrcweir 			$$->append($3);}
3449*cdf0e10cSrcweir */
3450*cdf0e10cSrcweir 	|       SQL_TOKEN_NAME '.' column_val %prec '.'
3451*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
3452*cdf0e10cSrcweir 			$$->append($1);
3453*cdf0e10cSrcweir 			$$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
3454*cdf0e10cSrcweir 			$$->append($3);
3455*cdf0e10cSrcweir 			}
3456*cdf0e10cSrcweir 	|       SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val %prec '.'
3457*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
3458*cdf0e10cSrcweir 			$$->append($1);
3459*cdf0e10cSrcweir 			$$->append($2 = newNode(".", SQL_NODE_PUNCTUATION));
3460*cdf0e10cSrcweir 			$$->append($3);
3461*cdf0e10cSrcweir 			$$->append($4 = newNode(".", SQL_NODE_PUNCTUATION));
3462*cdf0e10cSrcweir 			$$->append($5);}
3463*cdf0e10cSrcweir 	|       SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val %prec '.'
3464*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
3465*cdf0e10cSrcweir 			$$->append($1);
3466*cdf0e10cSrcweir 			$$->append($2= newNode(".", SQL_NODE_PUNCTUATION));
3467*cdf0e10cSrcweir 			$$->append($3);
3468*cdf0e10cSrcweir 			$$->append($4 = newNode(".", SQL_NODE_PUNCTUATION));
3469*cdf0e10cSrcweir 			$$->append($5);
3470*cdf0e10cSrcweir 			$$->append($6 = newNode(".", SQL_NODE_PUNCTUATION));
3471*cdf0e10cSrcweir 			$$->append($7);
3472*cdf0e10cSrcweir 			}
3473*cdf0e10cSrcweir 	|       SQL_TOKEN_NAME ':' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val %prec '.'
3474*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
3475*cdf0e10cSrcweir 			$$->append($1);
3476*cdf0e10cSrcweir 			$$->append($2= newNode(":", SQL_NODE_PUNCTUATION));
3477*cdf0e10cSrcweir 			$$->append($3);
3478*cdf0e10cSrcweir 			$$->append($4 = newNode(".", SQL_NODE_PUNCTUATION));
3479*cdf0e10cSrcweir 			$$->append($5);
3480*cdf0e10cSrcweir 			$$->append($6 = newNode(".", SQL_NODE_PUNCTUATION));
3481*cdf0e10cSrcweir 			$$->append($7);
3482*cdf0e10cSrcweir 			}
3483*cdf0e10cSrcweir /*	|       SQL_TOKEN_NAME ';' SQL_TOKEN_NAME '.' SQL_TOKEN_NAME '.' column_val
3484*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
3485*cdf0e10cSrcweir 			$$->append($1);
3486*cdf0e10cSrcweir 			$$->append($2= newNode(";", SQL_NODE_PUNCTUATION));
3487*cdf0e10cSrcweir 			$$->append($3);
3488*cdf0e10cSrcweir 			$$->append($4 = newNode(".", SQL_NODE_PUNCTUATION));
3489*cdf0e10cSrcweir 			$$->append($5);
3490*cdf0e10cSrcweir 			$$->append($6 = newNode(".", SQL_NODE_PUNCTUATION));
3491*cdf0e10cSrcweir 			$$->append($7);
3492*cdf0e10cSrcweir 			}
3493*cdf0e10cSrcweir */	;
3494*cdf0e10cSrcweir 
3495*cdf0e10cSrcweir 		/* data types */
3496*cdf0e10cSrcweir column_val:
3497*cdf0e10cSrcweir 		column
3498*cdf0e10cSrcweir 		{$$ = SQL_NEW_RULE;
3499*cdf0e10cSrcweir 			$$->append($1);}
3500*cdf0e10cSrcweir 	|	'*'
3501*cdf0e10cSrcweir 		{
3502*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3503*cdf0e10cSrcweir 			$$->append($1 = newNode("*", SQL_NODE_PUNCTUATION));
3504*cdf0e10cSrcweir 		}
3505*cdf0e10cSrcweir 	;
3506*cdf0e10cSrcweir data_type:
3507*cdf0e10cSrcweir 	predefined_type
3508*cdf0e10cSrcweir 	;
3509*cdf0e10cSrcweir opt_char_set_spec:
3510*cdf0e10cSrcweir 	{$$ = SQL_NEW_RULE;}
3511*cdf0e10cSrcweir 	|	SQL_TOKEN_CHARACTER SQL_TOKEN_SET SQL_TOKEN_NAME
3512*cdf0e10cSrcweir 		{
3513*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3514*cdf0e10cSrcweir 			$$->append($1);
3515*cdf0e10cSrcweir 			$$->append($2);
3516*cdf0e10cSrcweir 			$$->append($3);
3517*cdf0e10cSrcweir 		}
3518*cdf0e10cSrcweir 	;
3519*cdf0e10cSrcweir opt_collate_clause:
3520*cdf0e10cSrcweir 	{$$ = SQL_NEW_RULE;}
3521*cdf0e10cSrcweir 	| collate_clause
3522*cdf0e10cSrcweir 	;
3523*cdf0e10cSrcweir predefined_type:
3524*cdf0e10cSrcweir 		character_string_type opt_char_set_spec	opt_collate_clause
3525*cdf0e10cSrcweir 		{
3526*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3527*cdf0e10cSrcweir 			$$->append($1);
3528*cdf0e10cSrcweir 			$$->append($2);
3529*cdf0e10cSrcweir 			$$->append($3);
3530*cdf0e10cSrcweir 		}
3531*cdf0e10cSrcweir 	|	national_character_string_type opt_collate_clause
3532*cdf0e10cSrcweir 		{
3533*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3534*cdf0e10cSrcweir 			$$->append($1);
3535*cdf0e10cSrcweir 			$$->append($2);
3536*cdf0e10cSrcweir 		}
3537*cdf0e10cSrcweir 	|	binary_string_type
3538*cdf0e10cSrcweir 	|	numeric_type
3539*cdf0e10cSrcweir 	|	boolean_type
3540*cdf0e10cSrcweir 	|	datetime_type
3541*cdf0e10cSrcweir 	|	interval_type
3542*cdf0e10cSrcweir 	;
3543*cdf0e10cSrcweir character_string_type:
3544*cdf0e10cSrcweir 		SQL_TOKEN_CHARACTER opt_paren_precision
3545*cdf0e10cSrcweir 		{
3546*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3547*cdf0e10cSrcweir 			$$->append($1);
3548*cdf0e10cSrcweir 			$$->append($2);
3549*cdf0e10cSrcweir 		}
3550*cdf0e10cSrcweir 	|	SQL_TOKEN_CHAR opt_paren_precision
3551*cdf0e10cSrcweir 		{
3552*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3553*cdf0e10cSrcweir 			$$->append($1);
3554*cdf0e10cSrcweir 			$$->append($2);
3555*cdf0e10cSrcweir 		}
3556*cdf0e10cSrcweir 	|	SQL_TOKEN_CHARACTER SQL_TOKEN_VARYING paren_char_length
3557*cdf0e10cSrcweir 		{
3558*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3559*cdf0e10cSrcweir 			$$->append($1);
3560*cdf0e10cSrcweir 			$$->append($2);
3561*cdf0e10cSrcweir 			$$->append($3);
3562*cdf0e10cSrcweir 		}
3563*cdf0e10cSrcweir 	|	SQL_TOKEN_CHAR SQL_TOKEN_VARYING paren_char_length
3564*cdf0e10cSrcweir 		{
3565*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3566*cdf0e10cSrcweir 			$$->append($1);
3567*cdf0e10cSrcweir 			$$->append($2);
3568*cdf0e10cSrcweir 			$$->append($3);
3569*cdf0e10cSrcweir 		}
3570*cdf0e10cSrcweir 	|	SQL_TOKEN_VARCHAR paren_char_length
3571*cdf0e10cSrcweir 		{
3572*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3573*cdf0e10cSrcweir 			$$->append($1);
3574*cdf0e10cSrcweir 			$$->append($2);
3575*cdf0e10cSrcweir 		}
3576*cdf0e10cSrcweir 	| character_large_object_type
3577*cdf0e10cSrcweir 	;
3578*cdf0e10cSrcweir opt_paren_precision:
3579*cdf0e10cSrcweir 		{$$ = SQL_NEW_RULE;}
3580*cdf0e10cSrcweir 	|	paren_char_length
3581*cdf0e10cSrcweir 	;
3582*cdf0e10cSrcweir paren_char_length:
3583*cdf0e10cSrcweir 	'(' SQL_TOKEN_INTNUM ')'
3584*cdf0e10cSrcweir 	{
3585*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
3586*cdf0e10cSrcweir 		$$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
3587*cdf0e10cSrcweir 		$$->append($2);
3588*cdf0e10cSrcweir 		$$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
3589*cdf0e10cSrcweir 	}
3590*cdf0e10cSrcweir 	;
3591*cdf0e10cSrcweir opt_paren_char_large_length:
3592*cdf0e10cSrcweir 		{$$ = SQL_NEW_RULE;}
3593*cdf0e10cSrcweir 	|	paren_character_large_object_length
3594*cdf0e10cSrcweir 	;
3595*cdf0e10cSrcweir paren_character_large_object_length:
3596*cdf0e10cSrcweir 	'(' large_object_length ')'
3597*cdf0e10cSrcweir 	{
3598*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
3599*cdf0e10cSrcweir 		$$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
3600*cdf0e10cSrcweir 		$$->append($2);
3601*cdf0e10cSrcweir 		$$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
3602*cdf0e10cSrcweir 	}
3603*cdf0e10cSrcweir 	;
3604*cdf0e10cSrcweir 
3605*cdf0e10cSrcweir large_object_length:
3606*cdf0e10cSrcweir 	SQL_TOKEN_INTNUM opt_multiplier
3607*cdf0e10cSrcweir 	{
3608*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
3609*cdf0e10cSrcweir 		$$->append($1);
3610*cdf0e10cSrcweir 		$$->append($2);
3611*cdf0e10cSrcweir 	}
3612*cdf0e10cSrcweir 	;
3613*cdf0e10cSrcweir opt_multiplier:
3614*cdf0e10cSrcweir 	{$$ = SQL_NEW_RULE;}
3615*cdf0e10cSrcweir 	|	'K'
3616*cdf0e10cSrcweir 		{
3617*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3618*cdf0e10cSrcweir 			$$->append($1 = newNode("K", SQL_NODE_PUNCTUATION));
3619*cdf0e10cSrcweir 		}
3620*cdf0e10cSrcweir 	|	'M'
3621*cdf0e10cSrcweir 		{
3622*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3623*cdf0e10cSrcweir 			$$->append($1 = newNode("M", SQL_NODE_PUNCTUATION));
3624*cdf0e10cSrcweir 		}
3625*cdf0e10cSrcweir 	|	'G'
3626*cdf0e10cSrcweir 		{
3627*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3628*cdf0e10cSrcweir 			$$->append($1 = newNode("G", SQL_NODE_PUNCTUATION));
3629*cdf0e10cSrcweir 		}
3630*cdf0e10cSrcweir 	|	'T'
3631*cdf0e10cSrcweir 		{
3632*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3633*cdf0e10cSrcweir 			$$->append($1 = newNode("T", SQL_NODE_PUNCTUATION));
3634*cdf0e10cSrcweir 		}
3635*cdf0e10cSrcweir 	|	'P'
3636*cdf0e10cSrcweir 		{
3637*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3638*cdf0e10cSrcweir 			$$->append($1 = newNode("P", SQL_NODE_PUNCTUATION));
3639*cdf0e10cSrcweir 		}
3640*cdf0e10cSrcweir 	;
3641*cdf0e10cSrcweir character_large_object_type:
3642*cdf0e10cSrcweir 		SQL_TOKEN_CHARACTER SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3643*cdf0e10cSrcweir 	{
3644*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3645*cdf0e10cSrcweir 			$$->append($1);
3646*cdf0e10cSrcweir 			$$->append($2);
3647*cdf0e10cSrcweir 			$$->append($3);
3648*cdf0e10cSrcweir 			$$->append($4);
3649*cdf0e10cSrcweir 		}
3650*cdf0e10cSrcweir 	|	SQL_TOKEN_CHAR SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3651*cdf0e10cSrcweir 		{
3652*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3653*cdf0e10cSrcweir 			$$->append($1);
3654*cdf0e10cSrcweir 			$$->append($2);
3655*cdf0e10cSrcweir 			$$->append($3);
3656*cdf0e10cSrcweir 			$$->append($4);
3657*cdf0e10cSrcweir 		}
3658*cdf0e10cSrcweir 	|	SQL_TOKEN_CLOB opt_paren_char_large_length
3659*cdf0e10cSrcweir 		{
3660*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3661*cdf0e10cSrcweir 			$$->append($1);
3662*cdf0e10cSrcweir 			$$->append($2);
3663*cdf0e10cSrcweir 		}
3664*cdf0e10cSrcweir 	;
3665*cdf0e10cSrcweir national_character_string_type:
3666*cdf0e10cSrcweir 		SQL_TOKEN_NATIONAL SQL_TOKEN_CHARACTER opt_paren_precision
3667*cdf0e10cSrcweir 		{
3668*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3669*cdf0e10cSrcweir 			$$->append($1);
3670*cdf0e10cSrcweir 			$$->append($2);
3671*cdf0e10cSrcweir 			$$->append($3);
3672*cdf0e10cSrcweir 		}
3673*cdf0e10cSrcweir 	|	SQL_TOKEN_NATIONAL SQL_TOKEN_CHAR opt_paren_precision
3674*cdf0e10cSrcweir 		{
3675*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3676*cdf0e10cSrcweir 			$$->append($1);
3677*cdf0e10cSrcweir 			$$->append($2);
3678*cdf0e10cSrcweir 			$$->append($3);
3679*cdf0e10cSrcweir 		}
3680*cdf0e10cSrcweir 	|	SQL_TOKEN_NCHAR opt_paren_precision
3681*cdf0e10cSrcweir 		{
3682*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3683*cdf0e10cSrcweir 			$$->append($1);
3684*cdf0e10cSrcweir 			$$->append($2);
3685*cdf0e10cSrcweir 		}
3686*cdf0e10cSrcweir 	|	SQL_TOKEN_NATIONAL SQL_TOKEN_CHARACTER SQL_TOKEN_VARYING paren_char_length
3687*cdf0e10cSrcweir 		{
3688*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3689*cdf0e10cSrcweir 			$$->append($1);
3690*cdf0e10cSrcweir 			$$->append($2);
3691*cdf0e10cSrcweir 			$$->append($3);
3692*cdf0e10cSrcweir 			$$->append($4);
3693*cdf0e10cSrcweir 		}
3694*cdf0e10cSrcweir 	|	SQL_TOKEN_NATIONAL SQL_TOKEN_CHAR SQL_TOKEN_VARYING paren_char_length
3695*cdf0e10cSrcweir 		{
3696*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3697*cdf0e10cSrcweir 			$$->append($1);
3698*cdf0e10cSrcweir 			$$->append($2);
3699*cdf0e10cSrcweir 			$$->append($3);
3700*cdf0e10cSrcweir 			$$->append($4);
3701*cdf0e10cSrcweir 		}
3702*cdf0e10cSrcweir 	|	SQL_TOKEN_NCHAR SQL_TOKEN_VARYING paren_char_length
3703*cdf0e10cSrcweir 		{
3704*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3705*cdf0e10cSrcweir 			$$->append($1);
3706*cdf0e10cSrcweir 			$$->append($2);
3707*cdf0e10cSrcweir 			$$->append($3);
3708*cdf0e10cSrcweir 		}
3709*cdf0e10cSrcweir 	|	national_character_large_object_type
3710*cdf0e10cSrcweir 	;
3711*cdf0e10cSrcweir national_character_large_object_type:
3712*cdf0e10cSrcweir 		SQL_TOKEN_NATIONAL SQL_TOKEN_CHARACTER SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3713*cdf0e10cSrcweir 		{
3714*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3715*cdf0e10cSrcweir 			$$->append($1);
3716*cdf0e10cSrcweir 			$$->append($2);
3717*cdf0e10cSrcweir 			$$->append($3);
3718*cdf0e10cSrcweir 			$$->append($4);
3719*cdf0e10cSrcweir 			$$->append($5);
3720*cdf0e10cSrcweir 		}
3721*cdf0e10cSrcweir 	|	SQL_TOKEN_NCHAR SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3722*cdf0e10cSrcweir 		{
3723*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3724*cdf0e10cSrcweir 			$$->append($1);
3725*cdf0e10cSrcweir 			$$->append($2);
3726*cdf0e10cSrcweir 			$$->append($3);
3727*cdf0e10cSrcweir 			$$->append($4);
3728*cdf0e10cSrcweir 		}
3729*cdf0e10cSrcweir 	|	SQL_TOKEN_NCLOB opt_paren_char_large_length
3730*cdf0e10cSrcweir 		{
3731*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3732*cdf0e10cSrcweir 			$$->append($1);
3733*cdf0e10cSrcweir 			$$->append($2);
3734*cdf0e10cSrcweir 		}
3735*cdf0e10cSrcweir 	;
3736*cdf0e10cSrcweir binary_string_type:
3737*cdf0e10cSrcweir 		SQL_TOKEN_BINARY opt_paren_precision
3738*cdf0e10cSrcweir 		{
3739*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3740*cdf0e10cSrcweir 			$$->append($1);
3741*cdf0e10cSrcweir 			$$->append($2);
3742*cdf0e10cSrcweir 		}
3743*cdf0e10cSrcweir 	|	SQL_TOKEN_BINARY SQL_TOKEN_VARYING paren_char_length
3744*cdf0e10cSrcweir 		{
3745*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3746*cdf0e10cSrcweir 			$$->append($1);
3747*cdf0e10cSrcweir 			$$->append($2);
3748*cdf0e10cSrcweir 			$$->append($3);
3749*cdf0e10cSrcweir 		}
3750*cdf0e10cSrcweir 	|	SQL_TOKEN_VARBINARY paren_char_length
3751*cdf0e10cSrcweir 		{
3752*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3753*cdf0e10cSrcweir 			$$->append($1);
3754*cdf0e10cSrcweir 			$$->append($2);
3755*cdf0e10cSrcweir 		}
3756*cdf0e10cSrcweir 	|	binary_large_object_string_type
3757*cdf0e10cSrcweir 	;
3758*cdf0e10cSrcweir binary_large_object_string_type:
3759*cdf0e10cSrcweir 		SQL_TOKEN_BINARY SQL_TOKEN_LARGE SQL_TOKEN_OBJECT opt_paren_char_large_length
3760*cdf0e10cSrcweir 		{
3761*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3762*cdf0e10cSrcweir 			$$->append($1);
3763*cdf0e10cSrcweir 			$$->append($2);
3764*cdf0e10cSrcweir 			$$->append($3);
3765*cdf0e10cSrcweir 			$$->append($4);
3766*cdf0e10cSrcweir 		}
3767*cdf0e10cSrcweir 	|	SQL_TOKEN_BLOB opt_paren_char_large_length
3768*cdf0e10cSrcweir 		{
3769*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3770*cdf0e10cSrcweir 			$$->append($1);
3771*cdf0e10cSrcweir 			$$->append($2);
3772*cdf0e10cSrcweir 		}
3773*cdf0e10cSrcweir 	;
3774*cdf0e10cSrcweir numeric_type:
3775*cdf0e10cSrcweir 		exact_numeric_type
3776*cdf0e10cSrcweir 	|	approximate_numeric_type
3777*cdf0e10cSrcweir 	;
3778*cdf0e10cSrcweir opt_paren_precision_scale:
3779*cdf0e10cSrcweir 	{$$ = SQL_NEW_RULE;}
3780*cdf0e10cSrcweir 	|	'(' SQL_TOKEN_INTNUM ')'
3781*cdf0e10cSrcweir 		{
3782*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3783*cdf0e10cSrcweir 			$$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
3784*cdf0e10cSrcweir 			$$->append($2);
3785*cdf0e10cSrcweir 			$$->append($3 = newNode(")", SQL_NODE_PUNCTUATION));
3786*cdf0e10cSrcweir 		}
3787*cdf0e10cSrcweir 	|	'(' SQL_TOKEN_INTNUM ',' SQL_TOKEN_INTNUM ')'
3788*cdf0e10cSrcweir 		{
3789*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3790*cdf0e10cSrcweir 			$$->append($1 = newNode("(", SQL_NODE_PUNCTUATION));
3791*cdf0e10cSrcweir 			$$->append($2);
3792*cdf0e10cSrcweir 			$$->append($3 = newNode(",", SQL_NODE_PUNCTUATION));
3793*cdf0e10cSrcweir 			$$->append($4);
3794*cdf0e10cSrcweir 			$$->append($5 = newNode(")", SQL_NODE_PUNCTUATION));
3795*cdf0e10cSrcweir 		}
3796*cdf0e10cSrcweir 	;
3797*cdf0e10cSrcweir exact_numeric_type:
3798*cdf0e10cSrcweir 		SQL_TOKEN_NUMERIC opt_paren_precision_scale
3799*cdf0e10cSrcweir 		{
3800*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3801*cdf0e10cSrcweir 			$$->append($1);
3802*cdf0e10cSrcweir 			$$->append($2);
3803*cdf0e10cSrcweir 		}
3804*cdf0e10cSrcweir 	|	SQL_TOKEN_DECIMAL opt_paren_precision_scale
3805*cdf0e10cSrcweir 		{
3806*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3807*cdf0e10cSrcweir 			$$->append($1);
3808*cdf0e10cSrcweir 			$$->append($2);
3809*cdf0e10cSrcweir 		}
3810*cdf0e10cSrcweir 	|	SQL_TOKEN_DEC opt_paren_precision_scale
3811*cdf0e10cSrcweir 		{
3812*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3813*cdf0e10cSrcweir 			$$->append($1);
3814*cdf0e10cSrcweir 			$$->append($2);
3815*cdf0e10cSrcweir 		}
3816*cdf0e10cSrcweir 	|	SQL_TOKEN_SMALLINT
3817*cdf0e10cSrcweir 	|	SQL_TOKEN_INTEGER
3818*cdf0e10cSrcweir 	|	SQL_TOKEN_INT
3819*cdf0e10cSrcweir 	|	SQL_TOKEN_BIGINT
3820*cdf0e10cSrcweir 	;
3821*cdf0e10cSrcweir approximate_numeric_type:
3822*cdf0e10cSrcweir 		SQL_TOKEN_FLOAT '(' SQL_TOKEN_INTNUM ')'
3823*cdf0e10cSrcweir 		{
3824*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3825*cdf0e10cSrcweir 			$$->append($1);
3826*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3827*cdf0e10cSrcweir 			$$->append($3);
3828*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
3829*cdf0e10cSrcweir 		}
3830*cdf0e10cSrcweir 	|	SQL_TOKEN_FLOAT
3831*cdf0e10cSrcweir 	|	SQL_TOKEN_REAL
3832*cdf0e10cSrcweir 	|	SQL_TOKEN_DOUBLE
3833*cdf0e10cSrcweir 	|	SQL_TOKEN_DOUBLE SQL_TOKEN_PRECISION
3834*cdf0e10cSrcweir 		{
3835*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3836*cdf0e10cSrcweir 			$$->append($1);
3837*cdf0e10cSrcweir 			$$->append($2);
3838*cdf0e10cSrcweir 		}
3839*cdf0e10cSrcweir 	;
3840*cdf0e10cSrcweir boolean_type:
3841*cdf0e10cSrcweir 	SQL_TOKEN_BOOLEAN
3842*cdf0e10cSrcweir ;
3843*cdf0e10cSrcweir datetime_type:
3844*cdf0e10cSrcweir 		SQL_TOKEN_DATE
3845*cdf0e10cSrcweir 	|	SQL_TOKEN_TIME opt_paren_precision opt_with_or_without_time_zone
3846*cdf0e10cSrcweir 		{
3847*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3848*cdf0e10cSrcweir 			$$->append($1);
3849*cdf0e10cSrcweir 			$$->append($2);
3850*cdf0e10cSrcweir 			$$->append($3);
3851*cdf0e10cSrcweir 		}
3852*cdf0e10cSrcweir 	|	SQL_TOKEN_TIMESTAMP opt_paren_precision opt_with_or_without_time_zone
3853*cdf0e10cSrcweir 		{
3854*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3855*cdf0e10cSrcweir 			$$->append($1);
3856*cdf0e10cSrcweir 			$$->append($2);
3857*cdf0e10cSrcweir 			$$->append($3);
3858*cdf0e10cSrcweir 		}
3859*cdf0e10cSrcweir 	;
3860*cdf0e10cSrcweir opt_with_or_without_time_zone:
3861*cdf0e10cSrcweir 		{$$ = SQL_NEW_RULE;}
3862*cdf0e10cSrcweir 	|	SQL_TOKEN_WITH SQL_TOKEN_TIME SQL_TOKEN_ZONE
3863*cdf0e10cSrcweir 		{
3864*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3865*cdf0e10cSrcweir 			$$->append($1);
3866*cdf0e10cSrcweir 			$$->append($2);
3867*cdf0e10cSrcweir 			$$->append($3);
3868*cdf0e10cSrcweir 		}
3869*cdf0e10cSrcweir 	|	SQL_TOKEN_WITHOUT SQL_TOKEN_TIME SQL_TOKEN_ZONE
3870*cdf0e10cSrcweir 		{
3871*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3872*cdf0e10cSrcweir 			$$->append($1);
3873*cdf0e10cSrcweir 			$$->append($2);
3874*cdf0e10cSrcweir 			$$->append($3);
3875*cdf0e10cSrcweir 		}
3876*cdf0e10cSrcweir 	;
3877*cdf0e10cSrcweir interval_type:
3878*cdf0e10cSrcweir 	SQL_TOKEN_INTERVAL interval_qualifier
3879*cdf0e10cSrcweir 	{
3880*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
3881*cdf0e10cSrcweir 		$$->append($1);
3882*cdf0e10cSrcweir 		$$->append($2);
3883*cdf0e10cSrcweir 	}
3884*cdf0e10cSrcweir 	;
3885*cdf0e10cSrcweir 	/* the various things you can name */
3886*cdf0e10cSrcweir 
3887*cdf0e10cSrcweir column:
3888*cdf0e10cSrcweir 		SQL_TOKEN_NAME
3889*cdf0e10cSrcweir 	|	SQL_TOKEN_POSITION
3890*cdf0e10cSrcweir 		{
3891*cdf0e10cSrcweir 			sal_uInt32 nNod = $$->getRuleID();
3892*cdf0e10cSrcweir 			delete $$;
3893*cdf0e10cSrcweir 			$$ = newNode(xxx_pGLOBAL_SQLPARSER->TokenIDToStr(nNod), SQL_NODE_NAME);
3894*cdf0e10cSrcweir 		}
3895*cdf0e10cSrcweir 	|	SQL_TOKEN_CHAR_LENGTH
3896*cdf0e10cSrcweir 		{
3897*cdf0e10cSrcweir 			sal_uInt32 nNod = $$->getRuleID();
3898*cdf0e10cSrcweir 			delete $$;
3899*cdf0e10cSrcweir 			$$ = newNode(xxx_pGLOBAL_SQLPARSER->TokenIDToStr(nNod), SQL_NODE_NAME);
3900*cdf0e10cSrcweir 		}
3901*cdf0e10cSrcweir 	|	SQL_TOKEN_EXTRACT
3902*cdf0e10cSrcweir 		{
3903*cdf0e10cSrcweir 			sal_uInt32 nNod = $$->getRuleID();
3904*cdf0e10cSrcweir 			delete $$;
3905*cdf0e10cSrcweir 			$$ = newNode(xxx_pGLOBAL_SQLPARSER->TokenIDToStr(nNod), SQL_NODE_NAME);
3906*cdf0e10cSrcweir 		}
3907*cdf0e10cSrcweir 	;
3908*cdf0e10cSrcweir case_expression:
3909*cdf0e10cSrcweir 		case_abbreviation
3910*cdf0e10cSrcweir 	|	case_specification
3911*cdf0e10cSrcweir 	;
3912*cdf0e10cSrcweir case_abbreviation:
3913*cdf0e10cSrcweir 		SQL_TOKEN_NULLIF '(' value_exp_commalist ')'
3914*cdf0e10cSrcweir 		{
3915*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3916*cdf0e10cSrcweir 			$$->append($1);
3917*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3918*cdf0e10cSrcweir 			$$->append($3);
3919*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
3920*cdf0e10cSrcweir 		}
3921*cdf0e10cSrcweir 	|	SQL_TOKEN_COALESCE '(' value_exp ')'
3922*cdf0e10cSrcweir 		{
3923*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3924*cdf0e10cSrcweir 			$$->append($1);
3925*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3926*cdf0e10cSrcweir 			$$->append($3);
3927*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
3928*cdf0e10cSrcweir 		}
3929*cdf0e10cSrcweir 	|	SQL_TOKEN_COALESCE '(' value_exp_commalist ')'
3930*cdf0e10cSrcweir 		{
3931*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3932*cdf0e10cSrcweir 			$$->append($1);
3933*cdf0e10cSrcweir 			$$->append($2 = newNode("(", SQL_NODE_PUNCTUATION));
3934*cdf0e10cSrcweir 			$$->append($3);
3935*cdf0e10cSrcweir 			$$->append($4 = newNode(")", SQL_NODE_PUNCTUATION));
3936*cdf0e10cSrcweir 		}
3937*cdf0e10cSrcweir 	;
3938*cdf0e10cSrcweir case_specification:
3939*cdf0e10cSrcweir 		simple_case
3940*cdf0e10cSrcweir 	|	searched_case
3941*cdf0e10cSrcweir 	;
3942*cdf0e10cSrcweir simple_case:
3943*cdf0e10cSrcweir 	SQL_TOKEN_CASE case_operand simple_when_clause_list else_clause SQL_TOKEN_END
3944*cdf0e10cSrcweir 		{
3945*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3946*cdf0e10cSrcweir 			$$->append($1);
3947*cdf0e10cSrcweir 			$$->append($2);
3948*cdf0e10cSrcweir 			$$->append($3);
3949*cdf0e10cSrcweir 			$$->append($4);
3950*cdf0e10cSrcweir 			$$->append($5);
3951*cdf0e10cSrcweir 		}
3952*cdf0e10cSrcweir 	;
3953*cdf0e10cSrcweir searched_case:
3954*cdf0e10cSrcweir 	SQL_TOKEN_CASE searched_when_clause_list else_clause SQL_TOKEN_END
3955*cdf0e10cSrcweir 		{
3956*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3957*cdf0e10cSrcweir 			$$->append($1);
3958*cdf0e10cSrcweir 			$$->append($2);
3959*cdf0e10cSrcweir 			$$->append($3);
3960*cdf0e10cSrcweir 			$$->append($4);
3961*cdf0e10cSrcweir 		}
3962*cdf0e10cSrcweir 	;
3963*cdf0e10cSrcweir simple_when_clause_list:
3964*cdf0e10cSrcweir 		simple_when_clause
3965*cdf0e10cSrcweir 		{
3966*cdf0e10cSrcweir 			$$ = SQL_NEW_LISTRULE;
3967*cdf0e10cSrcweir 			$$->append($1);
3968*cdf0e10cSrcweir 		}
3969*cdf0e10cSrcweir 	|   searched_when_clause_list simple_when_clause
3970*cdf0e10cSrcweir 		{
3971*cdf0e10cSrcweir 			$1->append($2);
3972*cdf0e10cSrcweir 			$$ = $1;
3973*cdf0e10cSrcweir 		}
3974*cdf0e10cSrcweir 	;
3975*cdf0e10cSrcweir simple_when_clause:
3976*cdf0e10cSrcweir 	SQL_TOKEN_WHEN when_operand_list SQL_TOKEN_THEN result
3977*cdf0e10cSrcweir 	{
3978*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
3979*cdf0e10cSrcweir 			$$->append($1);
3980*cdf0e10cSrcweir 			$$->append($2);
3981*cdf0e10cSrcweir 			$$->append($3);
3982*cdf0e10cSrcweir 			$$->append($4);
3983*cdf0e10cSrcweir 		}
3984*cdf0e10cSrcweir 	;
3985*cdf0e10cSrcweir when_operand_list:
3986*cdf0e10cSrcweir 		when_operand
3987*cdf0e10cSrcweir 		{$$ = SQL_NEW_COMMALISTRULE;
3988*cdf0e10cSrcweir 		$$->append($1);}
3989*cdf0e10cSrcweir 	|   when_operand_list ',' when_operand
3990*cdf0e10cSrcweir 		{$1->append($3);
3991*cdf0e10cSrcweir 		$$ = $1;}
3992*cdf0e10cSrcweir 	;
3993*cdf0e10cSrcweir when_operand:
3994*cdf0e10cSrcweir 		row_value_constructor_elem
3995*cdf0e10cSrcweir 	|	comparison_predicate_part_2
3996*cdf0e10cSrcweir 	|	between_predicate_part_2
3997*cdf0e10cSrcweir 	|	in_predicate_part_2
3998*cdf0e10cSrcweir 	|	character_like_predicate_part_2
3999*cdf0e10cSrcweir 	|	null_predicate_part_2
4000*cdf0e10cSrcweir ;
4001*cdf0e10cSrcweir searched_when_clause_list:
4002*cdf0e10cSrcweir 		searched_when_clause
4003*cdf0e10cSrcweir 		{
4004*cdf0e10cSrcweir 			$$ = SQL_NEW_LISTRULE;
4005*cdf0e10cSrcweir 			$$->append($1);
4006*cdf0e10cSrcweir 		}
4007*cdf0e10cSrcweir 	|   searched_when_clause_list searched_when_clause
4008*cdf0e10cSrcweir 		{
4009*cdf0e10cSrcweir 			$1->append($2);
4010*cdf0e10cSrcweir 			$$ = $1;
4011*cdf0e10cSrcweir 		}
4012*cdf0e10cSrcweir 	;
4013*cdf0e10cSrcweir searched_when_clause:
4014*cdf0e10cSrcweir 	SQL_TOKEN_WHEN search_condition SQL_TOKEN_THEN result
4015*cdf0e10cSrcweir 	{
4016*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
4017*cdf0e10cSrcweir 			$$->append($1);
4018*cdf0e10cSrcweir 			$$->append($2);
4019*cdf0e10cSrcweir 			$$->append($3);
4020*cdf0e10cSrcweir 			$$->append($4);
4021*cdf0e10cSrcweir 		}
4022*cdf0e10cSrcweir 	;
4023*cdf0e10cSrcweir else_clause:
4024*cdf0e10cSrcweir 		{$$ = SQL_NEW_RULE;}
4025*cdf0e10cSrcweir 	|	SQL_TOKEN_ELSE result
4026*cdf0e10cSrcweir 		{
4027*cdf0e10cSrcweir 			$$ = SQL_NEW_RULE;
4028*cdf0e10cSrcweir 			$$->append($1);
4029*cdf0e10cSrcweir 			$$->append($2);
4030*cdf0e10cSrcweir 		}
4031*cdf0e10cSrcweir 	;
4032*cdf0e10cSrcweir result:
4033*cdf0e10cSrcweir 		result_expression
4034*cdf0e10cSrcweir 	|	SQL_TOKEN_NULL
4035*cdf0e10cSrcweir 	;
4036*cdf0e10cSrcweir result_expression:
4037*cdf0e10cSrcweir 	value_exp
4038*cdf0e10cSrcweir 	;
4039*cdf0e10cSrcweir case_operand:
4040*cdf0e10cSrcweir 	row_value_constructor_elem
4041*cdf0e10cSrcweir 	;
4042*cdf0e10cSrcweir 
4043*cdf0e10cSrcweir cursor:	SQL_TOKEN_NAME
4044*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
4045*cdf0e10cSrcweir 			$$->append($1);}
4046*cdf0e10cSrcweir 	;
4047*cdf0e10cSrcweir 
4048*cdf0e10cSrcweir /***
4049*cdf0e10cSrcweir module:	SQL_TOKEN_NAME
4050*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
4051*cdf0e10cSrcweir 			$$->append($1);}
4052*cdf0e10cSrcweir 	;
4053*cdf0e10cSrcweir ***/
4054*cdf0e10cSrcweir 
4055*cdf0e10cSrcweir parameter:
4056*cdf0e10cSrcweir 		':' SQL_TOKEN_NAME
4057*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
4058*cdf0e10cSrcweir 			$$->append($1 = newNode(":", SQL_NODE_PUNCTUATION));
4059*cdf0e10cSrcweir 			$$->append($2);}
4060*cdf0e10cSrcweir 	|	'?'
4061*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE; // test
4062*cdf0e10cSrcweir 			$$->append($1 = newNode("?", SQL_NODE_PUNCTUATION));}
4063*cdf0e10cSrcweir 	|	'['	SQL_TOKEN_NAME ']'
4064*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
4065*cdf0e10cSrcweir 			$$->append($1 = newNode("[", SQL_NODE_PUNCTUATION));
4066*cdf0e10cSrcweir 			$$->append($2);
4067*cdf0e10cSrcweir 			$$->append($3 = newNode("]", SQL_NODE_PUNCTUATION));}
4068*cdf0e10cSrcweir 	;
4069*cdf0e10cSrcweir 
4070*cdf0e10cSrcweir /***
4071*cdf0e10cSrcweir procedure:      SQL_TOKEN_NAME
4072*cdf0e10cSrcweir 			{$$ = SQL_NEW_RULE;
4073*cdf0e10cSrcweir 			$$->append($1);}
4074*cdf0e10cSrcweir 	;
4075*cdf0e10cSrcweir ***/
4076*cdf0e10cSrcweir 
4077*cdf0e10cSrcweir range_variable:
4078*cdf0e10cSrcweir         {$$ = SQL_NEW_RULE;}
4079*cdf0e10cSrcweir     |   opt_as SQL_TOKEN_NAME
4080*cdf0e10cSrcweir         {$$ = SQL_NEW_RULE;
4081*cdf0e10cSrcweir         $$->append($1);
4082*cdf0e10cSrcweir         $$->append($2);
4083*cdf0e10cSrcweir         }
4084*cdf0e10cSrcweir 	;
4085*cdf0e10cSrcweir 
4086*cdf0e10cSrcweir user:	SQL_TOKEN_NAME
4087*cdf0e10cSrcweir 	;
4088*cdf0e10cSrcweir 
4089*cdf0e10cSrcweir /* PREDICATECHECK RULES */
4090*cdf0e10cSrcweir sql:
4091*cdf0e10cSrcweir 		search_condition /* checking predicats */
4092*cdf0e10cSrcweir 		{
4093*cdf0e10cSrcweir 			if (xxx_pGLOBAL_SQLPARSER->inPredicateCheck()) // sql: rule 1
4094*cdf0e10cSrcweir 			{
4095*cdf0e10cSrcweir 				$$ = $1;
4096*cdf0e10cSrcweir 				if ( SQL_ISRULE($$,search_condition) )
4097*cdf0e10cSrcweir 				{
4098*cdf0e10cSrcweir 					$$->insert(0,newNode("(", SQL_NODE_PUNCTUATION));
4099*cdf0e10cSrcweir 					$$->append(newNode(")", SQL_NODE_PUNCTUATION));
4100*cdf0e10cSrcweir 				}
4101*cdf0e10cSrcweir 			}
4102*cdf0e10cSrcweir 			else
4103*cdf0e10cSrcweir 				YYERROR;
4104*cdf0e10cSrcweir 		}
4105*cdf0e10cSrcweir 	|   '(' sql ')' /* checking predicats */
4106*cdf0e10cSrcweir     ;
4107*cdf0e10cSrcweir trigger_definition:
4108*cdf0e10cSrcweir 	SQL_TOKEN_CREATE SQL_TOKEN_TRIGGER trigger_name trigger_action_time trigger_event SQL_TOKEN_ON table_name op_referencing triggered_action
4109*cdf0e10cSrcweir 	{
4110*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
4111*cdf0e10cSrcweir         $$->append($1);
4112*cdf0e10cSrcweir         $$->append($2);
4113*cdf0e10cSrcweir         $$->append($3);
4114*cdf0e10cSrcweir         $$->append($4);
4115*cdf0e10cSrcweir         $$->append($5);
4116*cdf0e10cSrcweir         $$->append($6);
4117*cdf0e10cSrcweir         $$->append($7);
4118*cdf0e10cSrcweir         $$->append($8);
4119*cdf0e10cSrcweir         $$->append($9);
4120*cdf0e10cSrcweir     }
4121*cdf0e10cSrcweir 	;
4122*cdf0e10cSrcweir op_referencing:
4123*cdf0e10cSrcweir 	{
4124*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
4125*cdf0e10cSrcweir 	}
4126*cdf0e10cSrcweir 	|	SQL_TOKEN_REFERENCING transition_table_or_variable_list
4127*cdf0e10cSrcweir 	{
4128*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
4129*cdf0e10cSrcweir         $$->append($1);
4130*cdf0e10cSrcweir         $$->append($2);
4131*cdf0e10cSrcweir     }
4132*cdf0e10cSrcweir 	;
4133*cdf0e10cSrcweir trigger_action_time:
4134*cdf0e10cSrcweir 		SQL_TOKEN_BEFORE
4135*cdf0e10cSrcweir 	|	SQL_TOKEN_AFTER
4136*cdf0e10cSrcweir 	|	SQL_TOKEN_INSTEAD SQL_TOKEN_OF
4137*cdf0e10cSrcweir 	{
4138*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
4139*cdf0e10cSrcweir         $$->append($1);
4140*cdf0e10cSrcweir         $$->append($2);
4141*cdf0e10cSrcweir     }
4142*cdf0e10cSrcweir ;
4143*cdf0e10cSrcweir trigger_event:
4144*cdf0e10cSrcweir 		SQL_TOKEN_INSERT
4145*cdf0e10cSrcweir 	|	SQL_TOKEN_DELETE
4146*cdf0e10cSrcweir 	|	SQL_TOKEN_UPDATE op_trigger_columnlist
4147*cdf0e10cSrcweir 	{
4148*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
4149*cdf0e10cSrcweir         $$->append($1);
4150*cdf0e10cSrcweir         $$->append($2);
4151*cdf0e10cSrcweir     }
4152*cdf0e10cSrcweir 	;
4153*cdf0e10cSrcweir op_trigger_columnlist:
4154*cdf0e10cSrcweir 	{
4155*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
4156*cdf0e10cSrcweir 	}
4157*cdf0e10cSrcweir 	|	SQL_TOKEN_OF trigger_column_list
4158*cdf0e10cSrcweir 	{
4159*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
4160*cdf0e10cSrcweir         $$->append($1);
4161*cdf0e10cSrcweir         $$->append($2);
4162*cdf0e10cSrcweir     }
4163*cdf0e10cSrcweir 	;
4164*cdf0e10cSrcweir trigger_column_list:
4165*cdf0e10cSrcweir 	column_commalist
4166*cdf0e10cSrcweir 	;
4167*cdf0e10cSrcweir triggered_action:
4168*cdf0e10cSrcweir 	op_triggered_action_for triggered_when_clause triggered_SQL_statement
4169*cdf0e10cSrcweir 	{
4170*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
4171*cdf0e10cSrcweir         $$->append($1);
4172*cdf0e10cSrcweir         $$->append($2);
4173*cdf0e10cSrcweir         $$->append($3);
4174*cdf0e10cSrcweir     }
4175*cdf0e10cSrcweir 	;
4176*cdf0e10cSrcweir op_triggered_action_for:
4177*cdf0e10cSrcweir 		{
4178*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
4179*cdf0e10cSrcweir 		}
4180*cdf0e10cSrcweir 	|	SQL_TOKEN_FOR SQL_TOKEN_EACH trigger_for
4181*cdf0e10cSrcweir 	{
4182*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
4183*cdf0e10cSrcweir         $$->append($1);
4184*cdf0e10cSrcweir         $$->append($2);
4185*cdf0e10cSrcweir         $$->append($3);
4186*cdf0e10cSrcweir     }
4187*cdf0e10cSrcweir 	;
4188*cdf0e10cSrcweir trigger_for:
4189*cdf0e10cSrcweir 		SQL_TOKEN_ROW
4190*cdf0e10cSrcweir 	|	SQL_TOKEN_STATEMENT
4191*cdf0e10cSrcweir 	;
4192*cdf0e10cSrcweir triggered_when_clause:
4193*cdf0e10cSrcweir 	{
4194*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
4195*cdf0e10cSrcweir 	}
4196*cdf0e10cSrcweir 	|	SQL_TOKEN_WHEN parenthesized_boolean_value_expression
4197*cdf0e10cSrcweir 	{
4198*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
4199*cdf0e10cSrcweir         $$->append($1);
4200*cdf0e10cSrcweir         $$->append($2);
4201*cdf0e10cSrcweir     }
4202*cdf0e10cSrcweir 	;
4203*cdf0e10cSrcweir triggered_SQL_statement:
4204*cdf0e10cSrcweir 		SQL_procedure_statement
4205*cdf0e10cSrcweir 	|	SQL_TOKEN_BEGIN SQL_TOKEN_ATOMIC SQL_procedure_statement_list ';' SQL_TOKEN_END
4206*cdf0e10cSrcweir 	{
4207*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
4208*cdf0e10cSrcweir         $$->append($1);
4209*cdf0e10cSrcweir         $$->append($2);
4210*cdf0e10cSrcweir         $$->append($3);
4211*cdf0e10cSrcweir         $$->append($4 = newNode(";", SQL_NODE_PUNCTUATION));
4212*cdf0e10cSrcweir         $$->append($5);
4213*cdf0e10cSrcweir     }
4214*cdf0e10cSrcweir 	;
4215*cdf0e10cSrcweir SQL_procedure_statement_list:
4216*cdf0e10cSrcweir 		SQL_procedure_statement
4217*cdf0e10cSrcweir 		{
4218*cdf0e10cSrcweir 			$$ = SQL_NEW_LISTRULE;
4219*cdf0e10cSrcweir 			$$->append($1);
4220*cdf0e10cSrcweir 		}
4221*cdf0e10cSrcweir 	|	SQL_procedure_statement_list ';' SQL_procedure_statement
4222*cdf0e10cSrcweir 		{
4223*cdf0e10cSrcweir 			$1->append($3);
4224*cdf0e10cSrcweir 			$$ = $1;
4225*cdf0e10cSrcweir 		}
4226*cdf0e10cSrcweir 	;
4227*cdf0e10cSrcweir SQL_procedure_statement:
4228*cdf0e10cSrcweir 	sql
4229*cdf0e10cSrcweir 	;
4230*cdf0e10cSrcweir 
4231*cdf0e10cSrcweir transition_table_or_variable_list:
4232*cdf0e10cSrcweir 		transition_table_or_variable
4233*cdf0e10cSrcweir 		{
4234*cdf0e10cSrcweir 			$$ = SQL_NEW_LISTRULE;
4235*cdf0e10cSrcweir 			$$->append($1);
4236*cdf0e10cSrcweir 		}
4237*cdf0e10cSrcweir 	|   transition_table_or_variable_list transition_table_or_variable
4238*cdf0e10cSrcweir 		{
4239*cdf0e10cSrcweir 			$1->append($2);
4240*cdf0e10cSrcweir 			$$ = $1;
4241*cdf0e10cSrcweir 		}
4242*cdf0e10cSrcweir 	;
4243*cdf0e10cSrcweir 
4244*cdf0e10cSrcweir transition_table_or_variable:
4245*cdf0e10cSrcweir 		SQL_TOKEN_OLD opt_row opt_as old_transition_variable_name
4246*cdf0e10cSrcweir 	{
4247*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
4248*cdf0e10cSrcweir         $$->append($1);
4249*cdf0e10cSrcweir         $$->append($2);
4250*cdf0e10cSrcweir         $$->append($3);
4251*cdf0e10cSrcweir         $$->append($4);
4252*cdf0e10cSrcweir     }
4253*cdf0e10cSrcweir 	|	SQL_TOKEN_NEW opt_row opt_as new_transition_variable_name
4254*cdf0e10cSrcweir 	{
4255*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
4256*cdf0e10cSrcweir         $$->append($1);
4257*cdf0e10cSrcweir         $$->append($2);
4258*cdf0e10cSrcweir         $$->append($3);
4259*cdf0e10cSrcweir         $$->append($4);
4260*cdf0e10cSrcweir     }
4261*cdf0e10cSrcweir 	|	SQL_TOKEN_OLD SQL_TOKEN_TABLE opt_as old_transition_table_name
4262*cdf0e10cSrcweir 	{
4263*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
4264*cdf0e10cSrcweir         $$->append($1);
4265*cdf0e10cSrcweir         $$->append($2);
4266*cdf0e10cSrcweir         $$->append($3);
4267*cdf0e10cSrcweir         $$->append($4);
4268*cdf0e10cSrcweir     }
4269*cdf0e10cSrcweir 	|	SQL_TOKEN_NEW SQL_TOKEN_TABLE opt_as new_transition_table_name
4270*cdf0e10cSrcweir 	{
4271*cdf0e10cSrcweir 		$$ = SQL_NEW_RULE;
4272*cdf0e10cSrcweir         $$->append($1);
4273*cdf0e10cSrcweir         $$->append($2);
4274*cdf0e10cSrcweir         $$->append($3);
4275*cdf0e10cSrcweir         $$->append($4);
4276*cdf0e10cSrcweir     }
4277*cdf0e10cSrcweir ;
4278*cdf0e10cSrcweir old_transition_table_name:
4279*cdf0e10cSrcweir 	transition_table_name
4280*cdf0e10cSrcweir ;
4281*cdf0e10cSrcweir new_transition_table_name:
4282*cdf0e10cSrcweir 	transition_table_name
4283*cdf0e10cSrcweir ;
4284*cdf0e10cSrcweir transition_table_name:
4285*cdf0e10cSrcweir 	SQL_TOKEN_NAME
4286*cdf0e10cSrcweir ;
4287*cdf0e10cSrcweir old_transition_variable_name:
4288*cdf0e10cSrcweir 	SQL_TOKEN_NAME
4289*cdf0e10cSrcweir ;
4290*cdf0e10cSrcweir new_transition_variable_name:
4291*cdf0e10cSrcweir 	SQL_TOKEN_NAME
4292*cdf0e10cSrcweir ;
4293*cdf0e10cSrcweir trigger_name:
4294*cdf0e10cSrcweir 	SQL_TOKEN_NAME
4295*cdf0e10cSrcweir ;
4296*cdf0e10cSrcweir %%
4297*cdf0e10cSrcweir 
4298*cdf0e10cSrcweir 
4299*cdf0e10cSrcweir using namespace ::com::sun::star::sdbc;
4300*cdf0e10cSrcweir using namespace ::com::sun::star::beans;
4301*cdf0e10cSrcweir using namespace ::com::sun::star::uno;
4302*cdf0e10cSrcweir using namespace ::com::sun::star::i18n;
4303*cdf0e10cSrcweir using namespace ::com::sun::star::lang;
4304*cdf0e10cSrcweir using namespace ::com::sun::star::util;
4305*cdf0e10cSrcweir using namespace ::osl;
4306*cdf0e10cSrcweir using namespace ::dbtools;
4307*cdf0e10cSrcweir //	using namespace connectivity;
4308*cdf0e10cSrcweir 
4309*cdf0e10cSrcweir //============================================================
4310*cdf0e10cSrcweir //= a helper for static ascii pseudo-unicode strings
4311*cdf0e10cSrcweir //============================================================
4312*cdf0e10cSrcweir // string constants
4313*cdf0e10cSrcweir struct _ConstAsciiString_
4314*cdf0e10cSrcweir {
4315*cdf0e10cSrcweir 	sal_Int32 length;
4316*cdf0e10cSrcweir 	sal_Char  const* str;
4317*cdf0e10cSrcweir 
4318*cdf0e10cSrcweir 	operator rtl::OUString () const { return rtl::OUString(str, length, RTL_TEXTENCODING_ASCII_US); }
4319*cdf0e10cSrcweir //	operator ::rtl::OUString () const { return ::rtl::OUString(str, length, RTL_TEXTENCODING_ASCII_US); }
4320*cdf0e10cSrcweir 	operator const sal_Char * () const { return str; }
4321*cdf0e10cSrcweir 	operator ::rtl::OString() const { return str; }
4322*cdf0e10cSrcweir };
4323*cdf0e10cSrcweir 
4324*cdf0e10cSrcweir #define IMPLEMENT_CONSTASCII_STRING( name, string ) \
4325*cdf0e10cSrcweir 	_ConstAsciiString_ const name = { sizeof(string)-1, string }
4326*cdf0e10cSrcweir 
4327*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(ERROR_STR_GENERAL, "Syntax error in SQL expression");
4328*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(ERROR_STR_VALUE_NO_LIKE, "The value #1 can not be used with LIKE.");
4329*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(ERROR_STR_FIELD_NO_LIKE, "LIKE can not be used with this field.");
4330*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_COMPARE, "The entered criterion can not be compared with this field.");
4331*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_DATE_COMPARE, "The field can not be compared with a date.");
4332*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_REAL_COMPARE,	"The field can not be compared with a floating point number.");
4333*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_INT_COMPARE,	"The field can not be compared with a number.");
4334*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_TABLE,	"The database does not contain a table named \"#\".");
4335*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_TABLE_OR_QUERY,   "The database does contain neither a table nor a query named \"#\".");
4336*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_COLUMN,	"The column \"#1\" is unknown in the table \"#2\".");
4337*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_TABLE_EXIST,	"The database already contains a table or view with name \"#\".");
4338*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(ERROR_STR_INVALID_QUERY_EXIST,	"The database already contains a query with name \"#\".");
4339*cdf0e10cSrcweir 
4340*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_LIKE, "LIKE");
4341*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_NOT, "NOT");
4342*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_NULL, "NULL");
4343*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_TRUE, "True");
4344*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_FALSE, "False");
4345*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_IS, "IS");
4346*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_BETWEEN, "BETWEEN");
4347*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_OR, "OR");
4348*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_AND, "AND");
4349*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_AVG, "AVG");
4350*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_COUNT, "COUNT");
4351*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_MAX, "MAX");
4352*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_MIN, "MIN");
4353*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_SUM, "SUM");
4354*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_EVERY, "EVERY");
4355*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_ANY, "ANY");
4356*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_SOME, "SOME");
4357*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_STDDEV_POP, "STDDEV_POP");
4358*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_STDDEV_SAMP, "STDDEV_SAMP");
4359*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_VAR_SAMP, "VAR_SAMP");
4360*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_VAR_POP, "VAR_POP");
4361*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_COLLECT, "COLLECT");
4362*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_FUSION, "FUSION");
4363*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(KEY_STR_INTERSECTION, "INTERSECTION");
4364*cdf0e10cSrcweir 
4365*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(FIELD_STR_NULLDATE, "NullDate");
4366*cdf0e10cSrcweir 
4367*cdf0e10cSrcweir IMPLEMENT_CONSTASCII_STRING(STR_SQL_TOKEN, "SQL_TOKEN_");
4368*cdf0e10cSrcweir 
4369*cdf0e10cSrcweir //==========================================================================
4370*cdf0e10cSrcweir //= OParseContext
4371*cdf0e10cSrcweir //==========================================================================
4372*cdf0e10cSrcweir //-----------------------------------------------------------------------------
4373*cdf0e10cSrcweir OParseContext::OParseContext()
4374*cdf0e10cSrcweir {
4375*cdf0e10cSrcweir }
4376*cdf0e10cSrcweir 
4377*cdf0e10cSrcweir //-----------------------------------------------------------------------------
4378*cdf0e10cSrcweir OParseContext::~OParseContext()
4379*cdf0e10cSrcweir {
4380*cdf0e10cSrcweir }
4381*cdf0e10cSrcweir 
4382*cdf0e10cSrcweir //-----------------------------------------------------------------------------
4383*cdf0e10cSrcweir ::rtl::OUString OParseContext::getErrorMessage(ErrorCode _eCode) const
4384*cdf0e10cSrcweir {
4385*cdf0e10cSrcweir 	::rtl::OUString aMsg;
4386*cdf0e10cSrcweir 	switch (_eCode)
4387*cdf0e10cSrcweir 	{
4388*cdf0e10cSrcweir 		case ERROR_GENERAL:					aMsg = ERROR_STR_GENERAL; break;
4389*cdf0e10cSrcweir 		case ERROR_VALUE_NO_LIKE:			aMsg = ERROR_STR_VALUE_NO_LIKE; break;
4390*cdf0e10cSrcweir 		case ERROR_FIELD_NO_LIKE:			aMsg = ERROR_STR_FIELD_NO_LIKE; break;
4391*cdf0e10cSrcweir 		case ERROR_INVALID_COMPARE:			aMsg = ERROR_STR_INVALID_COMPARE; break;
4392*cdf0e10cSrcweir 		case ERROR_INVALID_INT_COMPARE:		aMsg = ERROR_STR_INVALID_INT_COMPARE; break;
4393*cdf0e10cSrcweir 		case ERROR_INVALID_DATE_COMPARE:	aMsg = ERROR_STR_INVALID_DATE_COMPARE; break;
4394*cdf0e10cSrcweir 		case ERROR_INVALID_REAL_COMPARE:	aMsg = ERROR_STR_INVALID_REAL_COMPARE; break;
4395*cdf0e10cSrcweir 		case ERROR_INVALID_TABLE:			aMsg = ERROR_STR_INVALID_TABLE; break;
4396*cdf0e10cSrcweir 		case ERROR_INVALID_TABLE_OR_QUERY:  aMsg = ERROR_STR_INVALID_TABLE_OR_QUERY; break;
4397*cdf0e10cSrcweir 		case ERROR_INVALID_COLUMN:			aMsg = ERROR_STR_INVALID_COLUMN; break;
4398*cdf0e10cSrcweir 		case ERROR_INVALID_TABLE_EXIST:		aMsg = ERROR_STR_INVALID_TABLE_EXIST; break;
4399*cdf0e10cSrcweir 		case ERROR_INVALID_QUERY_EXIST:		aMsg = ERROR_STR_INVALID_QUERY_EXIST; break;
4400*cdf0e10cSrcweir         default:
4401*cdf0e10cSrcweir             OSL_ENSURE( false, "OParseContext::getErrorMessage: unknown error code!" );
4402*cdf0e10cSrcweir             break;
4403*cdf0e10cSrcweir 	}
4404*cdf0e10cSrcweir 	return aMsg;
4405*cdf0e10cSrcweir }
4406*cdf0e10cSrcweir 
4407*cdf0e10cSrcweir //-----------------------------------------------------------------------------
4408*cdf0e10cSrcweir ::rtl::OString OParseContext::getIntlKeywordAscii(InternationalKeyCode _eKey) const
4409*cdf0e10cSrcweir {
4410*cdf0e10cSrcweir 	::rtl::OString aKeyword;
4411*cdf0e10cSrcweir 	switch (_eKey)
4412*cdf0e10cSrcweir 	{
4413*cdf0e10cSrcweir 		case KEY_LIKE:		aKeyword = KEY_STR_LIKE; break;
4414*cdf0e10cSrcweir 		case KEY_NOT:		aKeyword = KEY_STR_NOT; break;
4415*cdf0e10cSrcweir 		case KEY_NULL:		aKeyword = KEY_STR_NULL; break;
4416*cdf0e10cSrcweir 		case KEY_TRUE:		aKeyword = KEY_STR_TRUE; break;
4417*cdf0e10cSrcweir 		case KEY_FALSE:		aKeyword = KEY_STR_FALSE; break;
4418*cdf0e10cSrcweir 		case KEY_IS:		aKeyword = KEY_STR_IS; break;
4419*cdf0e10cSrcweir 		case KEY_BETWEEN:	aKeyword = KEY_STR_BETWEEN; break;
4420*cdf0e10cSrcweir 		case KEY_OR:		aKeyword = KEY_STR_OR; break;
4421*cdf0e10cSrcweir 		case KEY_AND:		aKeyword = KEY_STR_AND; break;
4422*cdf0e10cSrcweir 		case KEY_AVG:		aKeyword = KEY_STR_AVG; break;
4423*cdf0e10cSrcweir 		case KEY_COUNT:		aKeyword = KEY_STR_COUNT; break;
4424*cdf0e10cSrcweir 		case KEY_MAX:		aKeyword = KEY_STR_MAX; break;
4425*cdf0e10cSrcweir 		case KEY_MIN:		aKeyword = KEY_STR_MIN; break;
4426*cdf0e10cSrcweir 		case KEY_SUM:		aKeyword = KEY_STR_SUM; break;
4427*cdf0e10cSrcweir         case KEY_EVERY:     aKeyword = KEY_STR_EVERY; break;
4428*cdf0e10cSrcweir         case KEY_ANY:       aKeyword = KEY_STR_ANY; break;
4429*cdf0e10cSrcweir         case KEY_SOME:      aKeyword = KEY_STR_SOME; break;
4430*cdf0e10cSrcweir         case KEY_STDDEV_POP: aKeyword = KEY_STR_STDDEV_POP; break;
4431*cdf0e10cSrcweir         case KEY_STDDEV_SAMP: aKeyword = KEY_STR_STDDEV_SAMP; break;
4432*cdf0e10cSrcweir         case KEY_VAR_SAMP:  aKeyword = KEY_STR_VAR_SAMP; break;
4433*cdf0e10cSrcweir         case KEY_VAR_POP:   aKeyword = KEY_STR_VAR_POP; break;
4434*cdf0e10cSrcweir         case KEY_COLLECT:   aKeyword = KEY_STR_COLLECT; break;
4435*cdf0e10cSrcweir         case KEY_FUSION:    aKeyword = KEY_STR_FUSION; break;
4436*cdf0e10cSrcweir         case KEY_INTERSECTION:aKeyword = KEY_STR_INTERSECTION; break;
4437*cdf0e10cSrcweir         case KEY_NONE:      break;
4438*cdf0e10cSrcweir         default:
4439*cdf0e10cSrcweir             OSL_ENSURE( false, "OParseContext::getIntlKeywordAscii: unknown key!" );
4440*cdf0e10cSrcweir             break;
4441*cdf0e10cSrcweir 	}
4442*cdf0e10cSrcweir 	return aKeyword;
4443*cdf0e10cSrcweir }
4444*cdf0e10cSrcweir 
4445*cdf0e10cSrcweir //-----------------------------------------------------------------------------
4446*cdf0e10cSrcweir IParseContext::InternationalKeyCode OParseContext::getIntlKeyCode(const ::rtl::OString& rToken) const
4447*cdf0e10cSrcweir {
4448*cdf0e10cSrcweir 	static IParseContext::InternationalKeyCode Intl_TokenID[] =
4449*cdf0e10cSrcweir 	{
4450*cdf0e10cSrcweir 		KEY_LIKE, KEY_NOT, KEY_NULL, KEY_TRUE,
4451*cdf0e10cSrcweir 		KEY_FALSE, KEY_IS, KEY_BETWEEN, KEY_OR,
4452*cdf0e10cSrcweir 		KEY_AND, KEY_AVG, KEY_COUNT, KEY_MAX,
4453*cdf0e10cSrcweir 		KEY_MIN, KEY_SUM, KEY_EVERY,KEY_ANY,KEY_SOME,
4454*cdf0e10cSrcweir         KEY_STDDEV_POP,KEY_STDDEV_SAMP,KEY_VAR_SAMP,
4455*cdf0e10cSrcweir         KEY_VAR_POP,KEY_COLLECT,KEY_FUSION,KEY_INTERSECTION
4456*cdf0e10cSrcweir 	};
4457*cdf0e10cSrcweir 
4458*cdf0e10cSrcweir 	sal_uInt32 nCount = sizeof Intl_TokenID / sizeof Intl_TokenID[0];
4459*cdf0e10cSrcweir 	for (sal_uInt32 i = 0; i < nCount; i++)
4460*cdf0e10cSrcweir 	{
4461*cdf0e10cSrcweir 		::rtl::OString aKey = getIntlKeywordAscii(Intl_TokenID[i]);
4462*cdf0e10cSrcweir 		if (rToken.equalsIgnoreAsciiCase(aKey))
4463*cdf0e10cSrcweir 			return Intl_TokenID[i];
4464*cdf0e10cSrcweir 	}
4465*cdf0e10cSrcweir 
4466*cdf0e10cSrcweir 	return KEY_NONE;
4467*cdf0e10cSrcweir }
4468*cdf0e10cSrcweir 
4469*cdf0e10cSrcweir //------------------------------------------------------------------------------
4470*cdf0e10cSrcweir static Locale& impl_getLocaleInstance( )
4471*cdf0e10cSrcweir {
4472*cdf0e10cSrcweir 	static Locale s_aLocale(
4473*cdf0e10cSrcweir 		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "en" ) ),
4474*cdf0e10cSrcweir 		::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM( "US" ) ),
4475*cdf0e10cSrcweir 		::rtl::OUString( )
4476*cdf0e10cSrcweir 	);
4477*cdf0e10cSrcweir 	return s_aLocale;
4478*cdf0e10cSrcweir }
4479*cdf0e10cSrcweir 
4480*cdf0e10cSrcweir //------------------------------------------------------------------------------
4481*cdf0e10cSrcweir void OParseContext::setDefaultLocale( const ::com::sun::star::lang::Locale& _rLocale )
4482*cdf0e10cSrcweir {
4483*cdf0e10cSrcweir 	impl_getLocaleInstance() = _rLocale;
4484*cdf0e10cSrcweir }
4485*cdf0e10cSrcweir 
4486*cdf0e10cSrcweir //------------------------------------------------------------------------------
4487*cdf0e10cSrcweir Locale OParseContext::getPreferredLocale( ) const
4488*cdf0e10cSrcweir {
4489*cdf0e10cSrcweir 	return getDefaultLocale();
4490*cdf0e10cSrcweir }
4491*cdf0e10cSrcweir 
4492*cdf0e10cSrcweir //------------------------------------------------------------------------------
4493*cdf0e10cSrcweir const Locale& OParseContext::getDefaultLocale()
4494*cdf0e10cSrcweir {
4495*cdf0e10cSrcweir 	return impl_getLocaleInstance();
4496*cdf0e10cSrcweir }
4497*cdf0e10cSrcweir 
4498*cdf0e10cSrcweir //==========================================================================
4499*cdf0e10cSrcweir //= misc
4500*cdf0e10cSrcweir //==========================================================================
4501*cdf0e10cSrcweir // Der (leider globale) yylval fuer die Uebergabe von
4502*cdf0e10cSrcweir // Werten vom Scanner an den Parser. Die globale Variable
4503*cdf0e10cSrcweir // wird nur kurzzeitig verwendet, der Parser liest die Variable
4504*cdf0e10cSrcweir // sofort nach dem Scanner-Aufruf in eine gleichnamige eigene
4505*cdf0e10cSrcweir // Member-Variable.
4506*cdf0e10cSrcweir 
4507*cdf0e10cSrcweir const double fMilliSecondsPerDay = 86400000.0;
4508*cdf0e10cSrcweir 
4509*cdf0e10cSrcweir //------------------------------------------------------------------------------
4510*cdf0e10cSrcweir 
4511*cdf0e10cSrcweir 
4512*cdf0e10cSrcweir //------------------------------------------------------------------
4513*cdf0e10cSrcweir ::rtl::OUString ConvertLikeToken(const OSQLParseNode* pTokenNode, const OSQLParseNode* pEscapeNode, sal_Bool bInternational)
4514*cdf0e10cSrcweir {
4515*cdf0e10cSrcweir 	::rtl::OUStringBuffer aMatchStr;
4516*cdf0e10cSrcweir 	if (pTokenNode->isToken())
4517*cdf0e10cSrcweir 	{
4518*cdf0e10cSrcweir 		sal_Unicode cEscape = 0;
4519*cdf0e10cSrcweir 		if (pEscapeNode->count())
4520*cdf0e10cSrcweir 			cEscape = pEscapeNode->getChild(1)->getTokenValue().toChar();
4521*cdf0e10cSrcweir 
4522*cdf0e10cSrcweir 		// Platzhalter austauschen
4523*cdf0e10cSrcweir 		aMatchStr = pTokenNode->getTokenValue();
4524*cdf0e10cSrcweir 		const sal_Int32 nLen = aMatchStr.getLength();
4525*cdf0e10cSrcweir 		::rtl::OUStringBuffer sSearch,sReplace;
4526*cdf0e10cSrcweir 		if ( bInternational )
4527*cdf0e10cSrcweir 		{
4528*cdf0e10cSrcweir 		    sSearch.appendAscii("%_",2);
4529*cdf0e10cSrcweir 		    sReplace.appendAscii("*?",2);
4530*cdf0e10cSrcweir 		}
4531*cdf0e10cSrcweir 		else
4532*cdf0e10cSrcweir 		{
4533*cdf0e10cSrcweir 		    sSearch.appendAscii("*?",2);
4534*cdf0e10cSrcweir 		    sReplace.appendAscii("%_",2);
4535*cdf0e10cSrcweir 		}
4536*cdf0e10cSrcweir 
4537*cdf0e10cSrcweir 		for (sal_Int32 i = 0; i < nLen; i++)
4538*cdf0e10cSrcweir 		{
4539*cdf0e10cSrcweir 			const sal_Unicode c = aMatchStr.charAt(i);
4540*cdf0e10cSrcweir 			if (c == sSearch.charAt(0) || c == sSearch.charAt(1))
4541*cdf0e10cSrcweir 			{
4542*cdf0e10cSrcweir 				if (i > 0 && aMatchStr.charAt(i-1) == cEscape)
4543*cdf0e10cSrcweir 					continue;
4544*cdf0e10cSrcweir 				else
4545*cdf0e10cSrcweir 				{
4546*cdf0e10cSrcweir 					const sal_Unicode cCharacter = sReplace.charAt( (c == sSearch.charAt(0)) ? 0 : 1);
4547*cdf0e10cSrcweir 					aMatchStr.setCharAt(i , cCharacter);
4548*cdf0e10cSrcweir 				}
4549*cdf0e10cSrcweir 			}
4550*cdf0e10cSrcweir 		}
4551*cdf0e10cSrcweir 	}
4552*cdf0e10cSrcweir 	return aMatchStr.makeStringAndClear();
4553*cdf0e10cSrcweir }
4554*cdf0e10cSrcweir 
4555*cdf0e10cSrcweir //==========================================================================
4556*cdf0e10cSrcweir //= OSQLParser
4557*cdf0e10cSrcweir //==========================================================================
4558*cdf0e10cSrcweir 
4559*cdf0e10cSrcweir sal_uInt32			    OSQLParser::s_nRuleIDs[OSQLParseNode::rule_count + 1];
4560*cdf0e10cSrcweir OSQLParser::RuleIDMap   OSQLParser::s_aReverseRuleIDLookup;
4561*cdf0e10cSrcweir OParseContext		    OSQLParser::s_aDefaultContext;
4562*cdf0e10cSrcweir 
4563*cdf0e10cSrcweir sal_Int32			OSQLParser::s_nRefCount	= 0;
4564*cdf0e10cSrcweir //	::osl::Mutex		OSQLParser::s_aMutex;
4565*cdf0e10cSrcweir OSQLScanner*		OSQLParser::s_pScanner = 0;
4566*cdf0e10cSrcweir OSQLParseNodesGarbageCollector*		OSQLParser::s_pGarbageCollector = 0;
4567*cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XLocaleData>		OSQLParser::s_xLocaleData = NULL;
4568*cdf0e10cSrcweir //-----------------------------------------------------------------------------
4569*cdf0e10cSrcweir void setParser(OSQLParser* _pParser)
4570*cdf0e10cSrcweir {
4571*cdf0e10cSrcweir 	xxx_pGLOBAL_SQLPARSER = _pParser;
4572*cdf0e10cSrcweir }
4573*cdf0e10cSrcweir // -------------------------------------------------------------------------
4574*cdf0e10cSrcweir void OSQLParser::setParseTree(OSQLParseNode * pNewParseTree)
4575*cdf0e10cSrcweir {
4576*cdf0e10cSrcweir 	::osl::MutexGuard aGuard(getMutex());
4577*cdf0e10cSrcweir 	m_pParseTree = pNewParseTree;
4578*cdf0e10cSrcweir }
4579*cdf0e10cSrcweir //-----------------------------------------------------------------------------
4580*cdf0e10cSrcweir OSQLParseNode* OSQLParser::parseTree(::rtl::OUString& rErrorMessage,
4581*cdf0e10cSrcweir 									 const ::rtl::OUString& rStatement,
4582*cdf0e10cSrcweir 								     sal_Bool bInternational)
4583*cdf0e10cSrcweir {
4584*cdf0e10cSrcweir 
4585*cdf0e10cSrcweir 
4586*cdf0e10cSrcweir 	// Guard the parsing
4587*cdf0e10cSrcweir 	::osl::MutexGuard aGuard(getMutex());
4588*cdf0e10cSrcweir 	// must be reset
4589*cdf0e10cSrcweir 	setParser(this);
4590*cdf0e10cSrcweir 
4591*cdf0e10cSrcweir 	// defines how to scan
4592*cdf0e10cSrcweir 	s_pScanner->SetRule(s_pScanner->GetSQLRule()); // initial
4593*cdf0e10cSrcweir 	s_pScanner->prepareScan(rStatement, m_pContext, bInternational);
4594*cdf0e10cSrcweir 
4595*cdf0e10cSrcweir 	SQLyylval.pParseNode = NULL;
4596*cdf0e10cSrcweir 	//	SQLyypvt = NULL;
4597*cdf0e10cSrcweir 	m_pParseTree = NULL;
4598*cdf0e10cSrcweir 	m_sErrorMessage = ::rtl::OUString();
4599*cdf0e10cSrcweir 
4600*cdf0e10cSrcweir 	// ... und den Parser anwerfen ...
4601*cdf0e10cSrcweir 	if (SQLyyparse() != 0)
4602*cdf0e10cSrcweir 	{
4603*cdf0e10cSrcweir 		// only set the error message, if it's not already set
4604*cdf0e10cSrcweir 		if (!m_sErrorMessage.getLength())
4605*cdf0e10cSrcweir 			m_sErrorMessage = s_pScanner->getErrorMessage();
4606*cdf0e10cSrcweir 		if (!m_sErrorMessage.getLength())
4607*cdf0e10cSrcweir 			m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_GENERAL);
4608*cdf0e10cSrcweir 
4609*cdf0e10cSrcweir 		rErrorMessage = m_sErrorMessage;
4610*cdf0e10cSrcweir 
4611*cdf0e10cSrcweir 		// clear the garbage collector
4612*cdf0e10cSrcweir 		(*s_pGarbageCollector)->clearAndDelete();
4613*cdf0e10cSrcweir 		return NULL;
4614*cdf0e10cSrcweir 	}
4615*cdf0e10cSrcweir 	else
4616*cdf0e10cSrcweir 	{
4617*cdf0e10cSrcweir 		(*s_pGarbageCollector)->clear();
4618*cdf0e10cSrcweir 
4619*cdf0e10cSrcweir 		// Das Ergebnis liefern (den Root Parse Node):
4620*cdf0e10cSrcweir 
4621*cdf0e10cSrcweir 		//	OSL_ENSURE(Sdbyyval.pParseNode != NULL,"OSQLParser: Parser hat keinen ParseNode geliefert");
4622*cdf0e10cSrcweir 		//	return Sdbyyval.pParseNode;
4623*cdf0e10cSrcweir 		// geht nicht wegen Bug in MKS YACC-erzeugtem Code (es wird ein falscher ParseNode
4624*cdf0e10cSrcweir 		// geliefert).
4625*cdf0e10cSrcweir 
4626*cdf0e10cSrcweir 		// Stattdessen setzt die Parse-Routine jetzt den Member pParseTree
4627*cdf0e10cSrcweir 		// - einfach diesen zurueckliefern:
4628*cdf0e10cSrcweir 		OSL_ENSURE(m_pParseTree != NULL,"OSQLParser: Parser hat keinen ParseTree geliefert");
4629*cdf0e10cSrcweir 		return m_pParseTree;
4630*cdf0e10cSrcweir 	}
4631*cdf0e10cSrcweir }
4632*cdf0e10cSrcweir //-----------------------------------------------------------------------------
4633*cdf0e10cSrcweir ::rtl::OString OSQLParser::TokenIDToStr(sal_uInt32 nTokenID, const IParseContext* pContext)
4634*cdf0e10cSrcweir {
4635*cdf0e10cSrcweir 	::rtl::OString aStr;
4636*cdf0e10cSrcweir 	if (pContext)
4637*cdf0e10cSrcweir 	{
4638*cdf0e10cSrcweir 		IParseContext::InternationalKeyCode eKeyCode = IParseContext::KEY_NONE;
4639*cdf0e10cSrcweir 		switch( nTokenID )
4640*cdf0e10cSrcweir 		{
4641*cdf0e10cSrcweir 			case SQL_TOKEN_LIKE: eKeyCode = IParseContext::KEY_LIKE; break;
4642*cdf0e10cSrcweir 			case SQL_TOKEN_NOT: eKeyCode = IParseContext::KEY_NOT; break;
4643*cdf0e10cSrcweir 			case SQL_TOKEN_NULL: eKeyCode = IParseContext::KEY_NULL; break;
4644*cdf0e10cSrcweir 			case SQL_TOKEN_TRUE: eKeyCode = IParseContext::KEY_TRUE; break;
4645*cdf0e10cSrcweir 			case SQL_TOKEN_FALSE: eKeyCode = IParseContext::KEY_FALSE; break;
4646*cdf0e10cSrcweir 			case SQL_TOKEN_IS: eKeyCode = IParseContext::KEY_IS; break;
4647*cdf0e10cSrcweir 			case SQL_TOKEN_BETWEEN: eKeyCode = IParseContext::KEY_BETWEEN; break;
4648*cdf0e10cSrcweir 			case SQL_TOKEN_OR: eKeyCode = IParseContext::KEY_OR; break;
4649*cdf0e10cSrcweir 			case SQL_TOKEN_AND: eKeyCode = IParseContext::KEY_AND; break;
4650*cdf0e10cSrcweir 			case SQL_TOKEN_AVG: eKeyCode = IParseContext::KEY_AVG; break;
4651*cdf0e10cSrcweir 			case SQL_TOKEN_COUNT: eKeyCode = IParseContext::KEY_COUNT; break;
4652*cdf0e10cSrcweir 			case SQL_TOKEN_MAX: eKeyCode = IParseContext::KEY_MAX; break;
4653*cdf0e10cSrcweir 			case SQL_TOKEN_MIN: eKeyCode = IParseContext::KEY_MIN; break;
4654*cdf0e10cSrcweir 			case SQL_TOKEN_SUM: eKeyCode = IParseContext::KEY_SUM; break;
4655*cdf0e10cSrcweir 		}
4656*cdf0e10cSrcweir 		if ( eKeyCode != IParseContext::KEY_NONE )
4657*cdf0e10cSrcweir 		    aStr = pContext->getIntlKeywordAscii(eKeyCode);
4658*cdf0e10cSrcweir 	}
4659*cdf0e10cSrcweir 
4660*cdf0e10cSrcweir 	if (!aStr.getLength())
4661*cdf0e10cSrcweir 	{
4662*cdf0e10cSrcweir 		aStr = yytname[YYTRANSLATE(nTokenID)];
4663*cdf0e10cSrcweir 		if(!aStr.compareTo("SQL_TOKEN_",10))
4664*cdf0e10cSrcweir 			aStr = aStr.copy(10);
4665*cdf0e10cSrcweir 	}
4666*cdf0e10cSrcweir 	return aStr;
4667*cdf0e10cSrcweir }
4668*cdf0e10cSrcweir 
4669*cdf0e10cSrcweir //-----------------------------------------------------------------------------
4670*cdf0e10cSrcweir ::rtl::OUString OSQLParser::RuleIDToStr(sal_uInt32 nRuleID)
4671*cdf0e10cSrcweir {
4672*cdf0e10cSrcweir 	OSL_ENSURE(nRuleID < (sizeof yytname/sizeof yytname[0]), "OSQLParser::RuleIDToStr: Invalid nRuleId!");
4673*cdf0e10cSrcweir 	return ::rtl::OUString::createFromAscii(yytname[nRuleID]);
4674*cdf0e10cSrcweir }
4675*cdf0e10cSrcweir 
4676*cdf0e10cSrcweir //-----------------------------------------------------------------------------
4677*cdf0e10cSrcweir sal_uInt32 OSQLParser::StrToRuleID(const ::rtl::OString & rValue)
4678*cdf0e10cSrcweir {
4679*cdf0e10cSrcweir 	// In yysvar nach dem angegebenen Namen suchen, den Index zurueckliefern
4680*cdf0e10cSrcweir 	// (oder 0, wenn nicht gefunden)
4681*cdf0e10cSrcweir 	static sal_uInt32 nLen = sizeof(yytname)/sizeof(yytname[0]);
4682*cdf0e10cSrcweir 	for (sal_uInt32 i = YYTRANSLATE(SQL_TOKEN_INVALIDSYMBOL); i < (nLen-1); i++)
4683*cdf0e10cSrcweir 	{
4684*cdf0e10cSrcweir 		if (yytname && rValue == yytname[i])
4685*cdf0e10cSrcweir 			return i;
4686*cdf0e10cSrcweir 	}
4687*cdf0e10cSrcweir 
4688*cdf0e10cSrcweir 	// Nicht gefunden
4689*cdf0e10cSrcweir 	return 0;
4690*cdf0e10cSrcweir }
4691*cdf0e10cSrcweir 
4692*cdf0e10cSrcweir //-----------------------------------------------------------------------------
4693*cdf0e10cSrcweir OSQLParseNode::Rule OSQLParser::RuleIDToRule( sal_uInt32 _nRule )
4694*cdf0e10cSrcweir {
4695*cdf0e10cSrcweir     return s_aReverseRuleIDLookup[ _nRule ];
4696*cdf0e10cSrcweir }
4697*cdf0e10cSrcweir 
4698*cdf0e10cSrcweir //-----------------------------------------------------------------------------
4699*cdf0e10cSrcweir sal_uInt32 OSQLParser::RuleID(OSQLParseNode::Rule eRule)
4700*cdf0e10cSrcweir {
4701*cdf0e10cSrcweir 	return s_nRuleIDs[(sal_uInt16)eRule];
4702*cdf0e10cSrcweir }
4703*cdf0e10cSrcweir // -------------------------------------------------------------------------
4704*cdf0e10cSrcweir sal_Int16 OSQLParser::buildNode(OSQLParseNode*& pAppend,OSQLParseNode* pCompare,OSQLParseNode* pLiteral,OSQLParseNode* pLiteral2)
4705*cdf0e10cSrcweir {
4706*cdf0e10cSrcweir 	OSQLParseNode* pColumnRef = new OSQLInternalNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::column_ref));
4707*cdf0e10cSrcweir 	pColumnRef->append(new OSQLInternalNode(m_sFieldName,SQL_NODE_NAME));
4708*cdf0e10cSrcweir 	OSQLParseNode* pComp = NULL;
4709*cdf0e10cSrcweir 	if ( SQL_ISTOKEN( pCompare, BETWEEN) && pLiteral2 )
4710*cdf0e10cSrcweir 		pComp = new OSQLInternalNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::between_predicate_part_2));
4711*cdf0e10cSrcweir 	else
4712*cdf0e10cSrcweir 		pComp = new OSQLInternalNode(aEmptyString, SQL_NODE_RULE,OSQLParser::RuleID(OSQLParseNode::comparison_predicate));
4713*cdf0e10cSrcweir 
4714*cdf0e10cSrcweir 	pComp->append(pColumnRef);
4715*cdf0e10cSrcweir 	pComp->append(pCompare);
4716*cdf0e10cSrcweir 	pComp->append(pLiteral);
4717*cdf0e10cSrcweir 	if ( pLiteral2 )
4718*cdf0e10cSrcweir 	{
4719*cdf0e10cSrcweir 		pComp->append(new OSQLInternalNode(aEmptyString, SQL_NODE_KEYWORD,SQL_TOKEN_AND));
4720*cdf0e10cSrcweir 		pComp->append(pLiteral2);
4721*cdf0e10cSrcweir 	}
4722*cdf0e10cSrcweir 	pAppend->append(pComp);
4723*cdf0e10cSrcweir 	return 1;
4724*cdf0e10cSrcweir }
4725*cdf0e10cSrcweir //-----------------------------------------------------------------------------
4726*cdf0e10cSrcweir sal_Int16 OSQLParser::buildStringNodes(OSQLParseNode*& pLiteral)
4727*cdf0e10cSrcweir {
4728*cdf0e10cSrcweir 	if(!pLiteral)
4729*cdf0e10cSrcweir 		return 1;
4730*cdf0e10cSrcweir 
4731*cdf0e10cSrcweir 	if(SQL_ISRULE(pLiteral,set_fct_spec) || SQL_ISRULE(pLiteral,general_set_fct) || SQL_ISRULE(pLiteral,column_ref)
4732*cdf0e10cSrcweir 		|| SQL_ISRULE(pLiteral,subquery))
4733*cdf0e10cSrcweir 		return 1; // here I have a function that I can't transform into a string
4734*cdf0e10cSrcweir 
4735*cdf0e10cSrcweir 	if(pLiteral->getNodeType() == SQL_NODE_INTNUM || pLiteral->getNodeType() == SQL_NODE_APPROXNUM || pLiteral->getNodeType() == SQL_NODE_ACCESS_DATE)
4736*cdf0e10cSrcweir 	{
4737*cdf0e10cSrcweir 		OSQLParseNode* pParent = pLiteral->getParent();
4738*cdf0e10cSrcweir 
4739*cdf0e10cSrcweir 		OSQLParseNode* pNewNode = new OSQLInternalNode(pLiteral->getTokenValue(), SQL_NODE_STRING);
4740*cdf0e10cSrcweir 		pParent->replace(pLiteral, pNewNode);
4741*cdf0e10cSrcweir 		delete pLiteral;
4742*cdf0e10cSrcweir 		pLiteral = NULL;
4743*cdf0e10cSrcweir 		return 1;
4744*cdf0e10cSrcweir 	}
4745*cdf0e10cSrcweir 
4746*cdf0e10cSrcweir 	for(sal_uInt32 i=0;i<pLiteral->count();++i)
4747*cdf0e10cSrcweir 	{
4748*cdf0e10cSrcweir 		OSQLParseNode* pChild = pLiteral->getChild(i);
4749*cdf0e10cSrcweir 		buildStringNodes(pChild);
4750*cdf0e10cSrcweir 	}
4751*cdf0e10cSrcweir 	if(SQL_ISRULE(pLiteral,term) || SQL_ISRULE(pLiteral,value_exp_primary))
4752*cdf0e10cSrcweir 	{
4753*cdf0e10cSrcweir 		m_sErrorMessage = m_pContext->getErrorMessage(IParseContext::ERROR_INVALID_COMPARE);
4754*cdf0e10cSrcweir 		return 0;
4755*cdf0e10cSrcweir 	}
4756*cdf0e10cSrcweir 	return 1;
4757*cdf0e10cSrcweir }
4758*cdf0e10cSrcweir //-----------------------------------------------------------------------------
4759*cdf0e10cSrcweir sal_Int16 OSQLParser::buildComparsionRule(OSQLParseNode*& pAppend,OSQLParseNode* pLiteral)
4760*cdf0e10cSrcweir {
4761*cdf0e10cSrcweir 	OSQLParseNode* pComp = new OSQLInternalNode(::rtl::OUString::createFromAscii("="), SQL_NODE_EQUAL);
4762*cdf0e10cSrcweir 	return buildPredicateRule(pAppend,pLiteral,pComp);
4763*cdf0e10cSrcweir }
4764*cdf0e10cSrcweir 
4765*cdf0e10cSrcweir 
4766*cdf0e10cSrcweir //-----------------------------------------------------------------------------
4767*cdf0e10cSrcweir void OSQLParser::reduceLiteral(OSQLParseNode*& pLiteral, sal_Bool bAppendBlank)
4768*cdf0e10cSrcweir {
4769*cdf0e10cSrcweir 	OSL_ENSURE(pLiteral->isRule(), "This is no ::com::sun::star::chaos::Rule");
4770*cdf0e10cSrcweir 	OSL_ENSURE(pLiteral->count() == 2, "OSQLParser::ReduceLiteral() Invalid count");
4771*cdf0e10cSrcweir 	OSQLParseNode* pTemp = pLiteral;
4772*cdf0e10cSrcweir 	::rtl::OUStringBuffer aValue(pLiteral->getChild(0)->getTokenValue());
4773*cdf0e10cSrcweir 	if (bAppendBlank)
4774*cdf0e10cSrcweir 	{
4775*cdf0e10cSrcweir 		aValue.appendAscii(" ");
4776*cdf0e10cSrcweir 	}
4777*cdf0e10cSrcweir 
4778*cdf0e10cSrcweir 	aValue.append(pLiteral->getChild(1)->getTokenValue());
4779*cdf0e10cSrcweir 
4780*cdf0e10cSrcweir 	pLiteral = new OSQLInternalNode(aValue.makeStringAndClear(),SQL_NODE_STRING);
4781*cdf0e10cSrcweir 	delete pTemp;
4782*cdf0e10cSrcweir }
4783*cdf0e10cSrcweir 
4784*cdf0e10cSrcweir // -------------------------------------------------------------------------
4785*cdf0e10cSrcweir void OSQLParser::error(sal_Char *fmt)
4786*cdf0e10cSrcweir {
4787*cdf0e10cSrcweir 	if(!m_sErrorMessage.getLength())
4788*cdf0e10cSrcweir 	{
4789*cdf0e10cSrcweir 		::rtl::OUString sStr(fmt,strlen(fmt),RTL_TEXTENCODING_UTF8);
4790*cdf0e10cSrcweir 		::rtl::OUString sSQL_TOKEN(::rtl::OUString::createFromAscii("SQL_TOKEN_"));
4791*cdf0e10cSrcweir 
4792*cdf0e10cSrcweir 		sal_Int32 nPos1 = sStr.indexOf(sSQL_TOKEN);
4793*cdf0e10cSrcweir 		if(nPos1 != -1)
4794*cdf0e10cSrcweir 		{
4795*cdf0e10cSrcweir 			::rtl::OUString sFirst  = sStr.copy(0,nPos1);
4796*cdf0e10cSrcweir 			sal_Int32 nPos2 = sStr.indexOf(sSQL_TOKEN,nPos1+1);
4797*cdf0e10cSrcweir 			if(nPos2 != -1)
4798*cdf0e10cSrcweir 			{
4799*cdf0e10cSrcweir 				::rtl::OUString sSecond = sStr.copy(nPos1+sSQL_TOKEN.getLength(),nPos2-nPos1-sSQL_TOKEN.getLength());
4800*cdf0e10cSrcweir 				sFirst  += sSecond;
4801*cdf0e10cSrcweir 				sFirst  += sStr.copy(nPos2+sSQL_TOKEN.getLength());
4802*cdf0e10cSrcweir 			}
4803*cdf0e10cSrcweir 			else
4804*cdf0e10cSrcweir 				sFirst += sStr.copy(nPos1+sSQL_TOKEN.getLength());
4805*cdf0e10cSrcweir 
4806*cdf0e10cSrcweir 			m_sErrorMessage = sFirst;
4807*cdf0e10cSrcweir 		}
4808*cdf0e10cSrcweir 		else
4809*cdf0e10cSrcweir 			m_sErrorMessage = sStr;
4810*cdf0e10cSrcweir 
4811*cdf0e10cSrcweir 		::rtl::OUString aError = s_pScanner->getErrorMessage();
4812*cdf0e10cSrcweir 		if(aError.getLength())
4813*cdf0e10cSrcweir 		{
4814*cdf0e10cSrcweir 			m_sErrorMessage += ::rtl::OUString::createFromAscii(", ");
4815*cdf0e10cSrcweir 			m_sErrorMessage += aError;
4816*cdf0e10cSrcweir 		}
4817*cdf0e10cSrcweir 	}
4818*cdf0e10cSrcweir }
4819*cdf0e10cSrcweir // -------------------------------------------------------------------------
4820*cdf0e10cSrcweir int OSQLParser::SQLlex()
4821*cdf0e10cSrcweir {
4822*cdf0e10cSrcweir 	return s_pScanner->SQLlex();
4823*cdf0e10cSrcweir }
4824*cdf0e10cSrcweir 
4825*cdf0e10cSrcweir #if defined __SUNPRO_CC
4826*cdf0e10cSrcweir #pragma enable_warn
4827*cdf0e10cSrcweir #elif defined _MSC_VER
4828*cdf0e10cSrcweir #pragma warning(pop)
4829*cdf0e10cSrcweir #endif
4830