f4cfd6bbef2cd7d7b60e4c97e96fcd29fdcbe6b8
[reactos.git] / dll / win32 / msi / sql.tab.c
1 /* A Bison parser, made by GNU Bison 3.0.2. */
2
3 /* Bison implementation for Yacc-like parsers in C
4
5 Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
6
7 This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19
20 /* As a special exception, you may create a larger work that contains
21 part or all of the Bison parser skeleton and distribute that work
22 under terms of your choice, so long as that work isn't itself a
23 parser generator using the skeleton or a modified version thereof
24 as a parser skeleton. Alternatively, if you modify or redistribute
25 the parser skeleton itself, you may (at your option) remove this
26 special exception, which will cause the skeleton and the resulting
27 Bison output files to be licensed under the GNU General Public
28 License without this special exception.
29
30 This special exception was added by the Free Software Foundation in
31 version 2.2 of Bison. */
32
33 /* C LALR(1) parser skeleton written by Richard Stallman, by
34 simplifying the original so-called "semantic" parser. */
35
36 /* All symbols defined below should begin with yy or YY, to avoid
37 infringing on user name space. This should be done even for local
38 variables, as they might otherwise be expanded by user macros.
39 There are some unavoidable exceptions within include files to
40 define necessary library symbols; they are noted "INFRINGES ON
41 USER NAME SPACE" below. */
42
43 /* Identify Bison output. */
44 #define YYBISON 1
45
46 /* Bison version. */
47 #define YYBISON_VERSION "3.0.2"
48
49 /* Skeleton name. */
50 #define YYSKELETON_NAME "yacc.c"
51
52 /* Pure parsers. */
53 #define YYPURE 1
54
55 /* Push parsers. */
56 #define YYPUSH 0
57
58 /* Pull parsers. */
59 #define YYPULL 1
60
61
62 /* Substitute the variable and function names. */
63 #define yyparse sql_parse
64 #define yylex sql_lex
65 #define yyerror sql_error
66 #define yydebug sql_debug
67 #define yynerrs sql_nerrs
68
69
70 /* Copy the first part of user declarations. */
71 #line 1 "sql.y" /* yacc.c:339 */
72
73
74 /*
75 * Implementation of the Microsoft Installer (msi.dll)
76 *
77 * Copyright 2002-2004 Mike McCormack for CodeWeavers
78 *
79 * This library is free software; you can redistribute it and/or
80 * modify it under the terms of the GNU Lesser General Public
81 * License as published by the Free Software Foundation; either
82 * version 2.1 of the License, or (at your option) any later version.
83 *
84 * This library is distributed in the hope that it will be useful,
85 * but WITHOUT ANY WARRANTY; without even the implied warranty of
86 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
87 * Lesser General Public License for more details.
88 *
89 * You should have received a copy of the GNU Lesser General Public
90 * License along with this library; if not, write to the Free Software
91 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
92 */
93
94 #include "msipriv.h"
95
96 WINE_DEFAULT_DEBUG_CHANNEL(msi);
97
98 static UINT SQL_getstring( void *info, const struct sql_str *strdata, LPWSTR *str );
99 static INT SQL_getint( void *info );
100 static int sql_lex( void *SQL_lval, SQL_input *info );
101 static int sql_error( SQL_input *info, const char *str);
102
103 static LPWSTR parser_add_table( void *info, LPCWSTR list, LPCWSTR table );
104 static void *parser_alloc( void *info, unsigned int sz );
105 static column_info *parser_alloc_column( void *info, LPCWSTR table, LPCWSTR column );
106
107 static BOOL SQL_MarkPrimaryKeys( column_info **cols, column_info *keys);
108
109 static struct expr * EXPR_complex( void *info, struct expr *l, UINT op, struct expr *r );
110 static struct expr * EXPR_unary( void *info, struct expr *l, UINT op );
111 static struct expr * EXPR_column( void *info, const column_info *column );
112 static struct expr * EXPR_ival( void *info, int val );
113 static struct expr * EXPR_sval( void *info, const struct sql_str *str );
114 static struct expr * EXPR_wildcard( void *info );
115
116 #define PARSER_BUBBLE_UP_VIEW( sql, result, current_view ) \
117 *sql->view = current_view; \
118 result = current_view
119
120
121 #line 134 "sql.tab.c" /* yacc.c:339 */
122
123 # ifndef YY_NULLPTR
124 # if defined __cplusplus && 201103L <= __cplusplus
125 # define YY_NULLPTR nullptr
126 # else
127 # define YY_NULLPTR 0
128 # endif
129 # endif
130
131 /* Enabling verbose error messages. */
132 #ifdef YYERROR_VERBOSE
133 # undef YYERROR_VERBOSE
134 # define YYERROR_VERBOSE 1
135 #else
136 # define YYERROR_VERBOSE 0
137 #endif
138
139 /* In a future release of Bison, this section will be replaced
140 by #include "sql.tab.h". */
141 #ifndef YY_SQL_SQL_TAB_H_INCLUDED
142 # define YY_SQL_SQL_TAB_H_INCLUDED
143 /* Debug traces. */
144 #ifndef YYDEBUG
145 # define YYDEBUG 0
146 #endif
147 #if YYDEBUG
148 extern int sql_debug;
149 #endif
150
151 /* Token type. */
152 #ifndef YYTOKENTYPE
153 # define YYTOKENTYPE
154 enum yytokentype
155 {
156 TK_ALTER = 258,
157 TK_AND = 259,
158 TK_BY = 260,
159 TK_CHAR = 261,
160 TK_COMMA = 262,
161 TK_CREATE = 263,
162 TK_DELETE = 264,
163 TK_DROP = 265,
164 TK_DISTINCT = 266,
165 TK_DOT = 267,
166 TK_EQ = 268,
167 TK_FREE = 269,
168 TK_FROM = 270,
169 TK_GE = 271,
170 TK_GT = 272,
171 TK_HOLD = 273,
172 TK_ADD = 274,
173 TK_ID = 275,
174 TK_ILLEGAL = 276,
175 TK_INSERT = 277,
176 TK_INT = 278,
177 TK_INTEGER = 279,
178 TK_INTO = 280,
179 TK_IS = 281,
180 TK_KEY = 282,
181 TK_LE = 283,
182 TK_LONG = 284,
183 TK_LONGCHAR = 285,
184 TK_LP = 286,
185 TK_LT = 287,
186 TK_LOCALIZABLE = 288,
187 TK_MINUS = 289,
188 TK_NE = 290,
189 TK_NOT = 291,
190 TK_NULL = 292,
191 TK_OBJECT = 293,
192 TK_OR = 294,
193 TK_ORDER = 295,
194 TK_PRIMARY = 296,
195 TK_RP = 297,
196 TK_SELECT = 298,
197 TK_SET = 299,
198 TK_SHORT = 300,
199 TK_SPACE = 301,
200 TK_STAR = 302,
201 TK_STRING = 303,
202 TK_TABLE = 304,
203 TK_TEMPORARY = 305,
204 TK_UPDATE = 306,
205 TK_VALUES = 307,
206 TK_WHERE = 308,
207 TK_WILDCARD = 309,
208 END_OF_FILE = 310,
209 ILLEGAL = 311,
210 SPACE = 312,
211 UNCLOSED_STRING = 313,
212 COMMENT = 314,
213 FUNCTION = 315,
214 COLUMN = 316,
215 TK_LIKE = 318,
216 TK_NEGATION = 319
217 };
218 #endif
219
220 /* Value type. */
221 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
222 typedef union YYSTYPE YYSTYPE;
223 union YYSTYPE
224 {
225 #line 68 "sql.y" /* yacc.c:355 */
226
227 struct sql_str str;
228 LPWSTR string;
229 column_info *column_list;
230 MSIVIEW *query;
231 struct expr *expr;
232 USHORT column_type;
233 int integer;
234
235 #line 248 "sql.tab.c" /* yacc.c:355 */
236 };
237 # define YYSTYPE_IS_TRIVIAL 1
238 # define YYSTYPE_IS_DECLARED 1
239 #endif
240
241
242
243 int sql_parse (SQL_input *info);
244
245 #endif /* !YY_SQL_SQL_TAB_H_INCLUDED */
246
247 /* Copy the second part of user declarations. */
248
249 #line 262 "sql.tab.c" /* yacc.c:358 */
250
251 #ifdef short
252 # undef short
253 #endif
254
255 #ifdef YYTYPE_UINT8
256 typedef YYTYPE_UINT8 yytype_uint8;
257 #else
258 typedef unsigned char yytype_uint8;
259 #endif
260
261 #ifdef YYTYPE_INT8
262 typedef YYTYPE_INT8 yytype_int8;
263 #else
264 typedef signed char yytype_int8;
265 #endif
266
267 #ifdef YYTYPE_UINT16
268 typedef YYTYPE_UINT16 yytype_uint16;
269 #else
270 typedef unsigned short int yytype_uint16;
271 #endif
272
273 #ifdef YYTYPE_INT16
274 typedef YYTYPE_INT16 yytype_int16;
275 #else
276 typedef short int yytype_int16;
277 #endif
278
279 #ifndef YYSIZE_T
280 # ifdef __SIZE_TYPE__
281 # define YYSIZE_T __SIZE_TYPE__
282 # elif defined size_t
283 # define YYSIZE_T size_t
284 # elif ! defined YYSIZE_T
285 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
286 # define YYSIZE_T size_t
287 # else
288 # define YYSIZE_T unsigned int
289 # endif
290 #endif
291
292 #define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
293
294 #ifndef YY_
295 # if defined YYENABLE_NLS && YYENABLE_NLS
296 # if ENABLE_NLS
297 # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
298 # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
299 # endif
300 # endif
301 # ifndef YY_
302 # define YY_(Msgid) Msgid
303 # endif
304 #endif
305
306 #ifndef YY_ATTRIBUTE
307 # if (defined __GNUC__ \
308 && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \
309 || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
310 # define YY_ATTRIBUTE(Spec) __attribute__(Spec)
311 # else
312 # define YY_ATTRIBUTE(Spec) /* empty */
313 # endif
314 #endif
315
316 #ifndef YY_ATTRIBUTE_PURE
317 # define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__))
318 #endif
319
320 #ifndef YY_ATTRIBUTE_UNUSED
321 # define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
322 #endif
323
324 #if !defined _Noreturn \
325 && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
326 # if defined _MSC_VER && 1200 <= _MSC_VER
327 # define _Noreturn __declspec (noreturn)
328 # else
329 # define _Noreturn YY_ATTRIBUTE ((__noreturn__))
330 # endif
331 #endif
332
333 /* Suppress unused-variable warnings by "using" E. */
334 #if ! defined lint || defined __GNUC__
335 # define YYUSE(E) ((void) (E))
336 #else
337 # define YYUSE(E) /* empty */
338 #endif
339
340 #if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
341 /* Suppress an incorrect diagnostic about yylval being uninitialized. */
342 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
343 _Pragma ("GCC diagnostic push") \
344 _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
345 _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
346 # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
347 _Pragma ("GCC diagnostic pop")
348 #else
349 # define YY_INITIAL_VALUE(Value) Value
350 #endif
351 #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
352 # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
353 # define YY_IGNORE_MAYBE_UNINITIALIZED_END
354 #endif
355 #ifndef YY_INITIAL_VALUE
356 # define YY_INITIAL_VALUE(Value) /* Nothing. */
357 #endif
358
359
360 #if ! defined yyoverflow || YYERROR_VERBOSE
361
362 /* The parser invokes alloca or malloc; define the necessary symbols. */
363
364 # ifdef YYSTACK_USE_ALLOCA
365 # if YYSTACK_USE_ALLOCA
366 # ifdef __GNUC__
367 # define YYSTACK_ALLOC __builtin_alloca
368 # elif defined __BUILTIN_VA_ARG_INCR
369 # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
370 # elif defined _AIX
371 # define YYSTACK_ALLOC __alloca
372 # elif defined _MSC_VER
373 # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
374 # define alloca _alloca
375 # else
376 # define YYSTACK_ALLOC alloca
377 # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
378 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
379 /* Use EXIT_SUCCESS as a witness for stdlib.h. */
380 # ifndef EXIT_SUCCESS
381 # define EXIT_SUCCESS 0
382 # endif
383 # endif
384 # endif
385 # endif
386 # endif
387
388 # ifdef YYSTACK_ALLOC
389 /* Pacify GCC's 'empty if-body' warning. */
390 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
391 # ifndef YYSTACK_ALLOC_MAXIMUM
392 /* The OS might guarantee only one guard page at the bottom of the stack,
393 and a page size can be as small as 4096 bytes. So we cannot safely
394 invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
395 to allow for a few compiler-allocated temporary stack slots. */
396 # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
397 # endif
398 # else
399 # define YYSTACK_ALLOC YYMALLOC
400 # define YYSTACK_FREE YYFREE
401 # ifndef YYSTACK_ALLOC_MAXIMUM
402 # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
403 # endif
404 # if (defined __cplusplus && ! defined EXIT_SUCCESS \
405 && ! ((defined YYMALLOC || defined malloc) \
406 && (defined YYFREE || defined free)))
407 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
408 # ifndef EXIT_SUCCESS
409 # define EXIT_SUCCESS 0
410 # endif
411 # endif
412 # ifndef YYMALLOC
413 # define YYMALLOC malloc
414 # if ! defined malloc && ! defined EXIT_SUCCESS
415 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
416 # endif
417 # endif
418 # ifndef YYFREE
419 # define YYFREE free
420 # if ! defined free && ! defined EXIT_SUCCESS
421 void free (void *); /* INFRINGES ON USER NAME SPACE */
422 # endif
423 # endif
424 # endif
425 #endif /* ! defined yyoverflow || YYERROR_VERBOSE */
426
427
428 #if (! defined yyoverflow \
429 && (! defined __cplusplus \
430 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
431
432 /* A type that is properly aligned for any stack member. */
433 union yyalloc
434 {
435 yytype_int16 yyss_alloc;
436 YYSTYPE yyvs_alloc;
437 };
438
439 /* The size of the maximum gap between one aligned stack and the next. */
440 # define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
441
442 /* The size of an array large to enough to hold all stacks, each with
443 N elements. */
444 # define YYSTACK_BYTES(N) \
445 ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
446 + YYSTACK_GAP_MAXIMUM)
447
448 # define YYCOPY_NEEDED 1
449
450 /* Relocate STACK from its old location to the new one. The
451 local variables YYSIZE and YYSTACKSIZE give the old and new number of
452 elements in the stack, and YYPTR gives the new location of the
453 stack. Advance YYPTR to a properly aligned location for the next
454 stack. */
455 # define YYSTACK_RELOCATE(Stack_alloc, Stack) \
456 do \
457 { \
458 YYSIZE_T yynewbytes; \
459 YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
460 Stack = &yyptr->Stack_alloc; \
461 yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
462 yyptr += yynewbytes / sizeof (*yyptr); \
463 } \
464 while (0)
465
466 #endif
467
468 #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
469 /* Copy COUNT objects from SRC to DST. The source and destination do
470 not overlap. */
471 # ifndef YYCOPY
472 # if defined __GNUC__ && 1 < __GNUC__
473 # define YYCOPY(Dst, Src, Count) \
474 __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
475 # else
476 # define YYCOPY(Dst, Src, Count) \
477 do \
478 { \
479 YYSIZE_T yyi; \
480 for (yyi = 0; yyi < (Count); yyi++) \
481 (Dst)[yyi] = (Src)[yyi]; \
482 } \
483 while (0)
484 # endif
485 # endif
486 #endif /* !YYCOPY_NEEDED */
487
488 /* YYFINAL -- State number of the termination state. */
489 #define YYFINAL 36
490 /* YYLAST -- Last index in YYTABLE. */
491 #define YYLAST 156
492
493 /* YYNTOKENS -- Number of terminals. */
494 #define YYNTOKENS 65
495 /* YYNNTS -- Number of nonterminals. */
496 #define YYNNTS 37
497 /* YYNRULES -- Number of rules. */
498 #define YYNRULES 87
499 /* YYNSTATES -- Number of states. */
500 #define YYNSTATES 154
501
502 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
503 by yylex, with out-of-bounds checking. */
504 #define YYUNDEFTOK 2
505 #define YYMAXUTOK 319
506
507 #define YYTRANSLATE(YYX) \
508 ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
509
510 /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
511 as returned by yylex, without out-of-bounds checking. */
512 static const yytype_uint8 yytranslate[] =
513 {
514 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
515 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
516 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
517 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
518 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
519 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
520 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
521 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
522 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
523 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
524 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
525 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
526 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
527 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
528 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
529 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
530 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
531 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
532 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
533 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
534 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
535 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
536 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
537 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
538 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
539 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
540 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
541 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
542 25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
543 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
544 45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
545 55, 56, 57, 58, 59, 60, 61, 62, 63, 64
546 };
547
548 #if YYDEBUG
549 /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
550 static const yytype_uint16 yyrline[] =
551 {
552 0, 117, 117, 125, 126, 127, 128, 129, 130, 131,
553 135, 146, 160, 177, 193, 204, 218, 232, 243, 254,
554 268, 272, 279, 294, 304, 314, 321, 330, 334, 338,
555 345, 349, 356, 360, 364, 368, 372, 376, 380, 387,
556 396, 400, 415, 435, 436, 440, 447, 448, 452, 459,
557 471, 484, 488, 500, 515, 519, 528, 534, 540, 546,
558 552, 558, 564, 570, 576, 582, 588, 597, 598, 602,
559 609, 620, 621, 629, 637, 643, 649, 655, 664, 673,
560 679, 688, 694, 700, 709, 716, 724, 732
561 };
562 #endif
563
564 #if YYDEBUG || YYERROR_VERBOSE || 0
565 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
566 First, the terminals, then, starting at YYNTOKENS, nonterminals. */
567 static const char *const yytname[] =
568 {
569 "$end", "error", "$undefined", "TK_ALTER", "TK_AND", "TK_BY", "TK_CHAR",
570 "TK_COMMA", "TK_CREATE", "TK_DELETE", "TK_DROP", "TK_DISTINCT", "TK_DOT",
571 "TK_EQ", "TK_FREE", "TK_FROM", "TK_GE", "TK_GT", "TK_HOLD", "TK_ADD",
572 "TK_ID", "TK_ILLEGAL", "TK_INSERT", "TK_INT", "TK_INTEGER", "TK_INTO",
573 "TK_IS", "TK_KEY", "TK_LE", "TK_LONG", "TK_LONGCHAR", "TK_LP", "TK_LT",
574 "TK_LOCALIZABLE", "TK_MINUS", "TK_NE", "TK_NOT", "TK_NULL", "TK_OBJECT",
575 "TK_OR", "TK_ORDER", "TK_PRIMARY", "TK_RP", "TK_SELECT", "TK_SET",
576 "TK_SHORT", "TK_SPACE", "TK_STAR", "TK_STRING", "TK_TABLE",
577 "TK_TEMPORARY", "TK_UPDATE", "TK_VALUES", "TK_WHERE", "TK_WILDCARD",
578 "END_OF_FILE", "ILLEGAL", "SPACE", "UNCLOSED_STRING", "COMMENT",
579 "FUNCTION", "COLUMN", "AGG_FUNCTION.", "TK_LIKE", "TK_NEGATION",
580 "$accept", "query", "onequery", "oneinsert", "onecreate", "oneupdate",
581 "onedelete", "onealter", "alterop", "onedrop", "table_def", "column_def",
582 "column_and_type", "column_type", "data_type_l", "data_type",
583 "data_count", "oneselect", "selectfrom", "selcollist", "collist", "from",
584 "unorderdfrom", "tablelist", "expr", "val", "constlist",
585 "update_assign_list", "column_assignment", "const_val", "column_val",
586 "column", "selcolumn", "table", "id", "string", "number", YY_NULLPTR
587 };
588 #endif
589
590 # ifdef YYPRINT
591 /* YYTOKNUM[NUM] -- (External) token number corresponding to the
592 (internal) symbol number NUM (which must be that of a token). */
593 static const yytype_uint16 yytoknum[] =
594 {
595 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
596 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
597 275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
598 285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
599 295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
600 305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
601 315, 316, 317, 318, 319
602 };
603 # endif
604
605 #define YYPACT_NINF -80
606
607 #define yypact_value_is_default(Yystate) \
608 (!!((Yystate) == (-80)))
609
610 #define YYTABLE_NINF -85
611
612 #define yytable_value_is_error(Yytable_value) \
613 0
614
615 /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
616 STATE-NUM. */
617 static const yytype_int16 yypact[] =
618 {
619 36, -44, -39, -1, -26, 9, 50, 37, 56, -80,
620 -80, -80, -80, -80, -80, -80, -80, 37, 37, 37,
621 -80, 25, 37, 37, -18, -80, -80, -80, -80, -1,
622 78, 47, 76, -80, 57, -80, -80, 105, 72, 51,
623 55, 100, -80, 81, -80, -80, -18, 37, 37, -80,
624 -80, 37, -80, 37, 62, 37, -12, -12, -80, -80,
625 63, 102, 108, 101, 76, 97, 45, 83, 2, -80,
626 62, 3, 94, -80, -80, 126, -80, -80, 127, 93,
627 62, 37, 52, 37, -80, 106, -80, -80, -80, -80,
628 -80, -80, 31, 103, 118, 37, 111, 11, 62, 62,
629 60, 60, 60, -11, 60, 60, 60, -12, 88, 3,
630 -80, -80, 117, -80, -80, -80, -80, -80, 117, -80,
631 -80, 107, -80, -80, -12, -80, -80, 138, -80, -80,
632 -80, -80, -80, 109, -80, -80, -80, -80, -80, 112,
633 -80, 110, -80, -80, -80, -80, 52, -80, 113, 140,
634 95, 52, -80, -80
635 };
636
637 /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
638 Performed when YYTABLE does not specify something else to do. Zero
639 means the default is an error. */
640 static const yytype_uint8 yydefact[] =
641 {
642 0, 0, 0, 0, 0, 0, 0, 0, 0, 2,
643 5, 4, 6, 7, 8, 9, 3, 0, 0, 0,
644 16, 51, 0, 0, 0, 85, 45, 86, 40, 0,
645 43, 0, 82, 83, 0, 84, 1, 0, 0, 52,
646 54, 0, 22, 0, 41, 42, 0, 0, 0, 21,
647 20, 0, 17, 0, 0, 0, 0, 0, 44, 81,
648 15, 71, 0, 0, 80, 18, 0, 0, 0, 25,
649 0, 53, 0, 78, 55, 54, 48, 50, 46, 0,
650 0, 0, 0, 0, 19, 32, 36, 37, 34, 38,
651 35, 26, 27, 30, 12, 0, 0, 0, 0, 0,
652 0, 0, 0, 0, 0, 0, 0, 0, 0, 14,
653 72, 87, 0, 76, 77, 73, 74, 79, 0, 28,
654 29, 0, 13, 24, 0, 56, 57, 58, 59, 68,
655 67, 63, 60, 0, 65, 62, 61, 64, 47, 0,
656 75, 0, 39, 31, 23, 66, 0, 33, 0, 69,
657 10, 0, 11, 70
658 };
659
660 /* YYPGOTO[NTERM-NUM]. */
661 static const yytype_int8 yypgoto[] =
662 {
663 -80, -80, -80, -80, -80, -80, -80, -80, -80, -80,
664 -80, -80, -47, -80, -80, -80, -80, -80, 124, 104,
665 -53, 120, -80, 96, 19, 26, 5, 73, -80, -79,
666 -7, -29, -80, 14, -6, -80, -16
667 };
668
669 /* YYDEFGOTO[NTERM-NUM]. */
670 static const yytype_int16 yydefgoto[] =
671 {
672 -1, 8, 9, 10, 11, 12, 13, 14, 52, 15,
673 67, 68, 65, 91, 92, 93, 141, 16, 28, 29,
674 77, 20, 21, 39, 71, 128, 148, 60, 61, 129,
675 130, 73, 30, 63, 64, 33, 116
676 };
677
678 /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
679 positive, shift that token. If negative, reduce the rule whose
680 number is the opposite. If YYTABLE_NINF, syntax error. */
681 static const yytype_int16 yytable[] =
682 {
683 32, 35, 25, 115, 79, 17, 69, 98, 25, 95,
684 18, 35, 35, 35, 19, 98, 35, 35, 32, 62,
685 31, 34, 66, 22, 66, 133, 134, 78, 78, 26,
686 27, 37, 38, 40, 23, 76, 42, 43, 31, 1,
687 32, 59, 99, 96, 2, 3, 4, 72, 123, 35,
688 99, 85, 62, 125, 138, -49, 36, 25, 5, 47,
689 31, 24, 55, 72, 119, 41, 66, 149, 86, 75,
690 25, 144, 149, 72, 87, 88, 111, 117, 78, 6,
691 25, 120, 25, 89, 111, 46, 112, 7, -84, 97,
692 90, 72, 72, 70, 112, 78, 140, 26, 27, 109,
693 113, 48, 142, 53, 54, 56, 114, 100, 113, 81,
694 101, 102, 57, 83, 114, 84, 80, 126, 127, 49,
695 103, 82, 104, 50, 51, 94, 105, 131, 132, 106,
696 135, 136, 137, 55, 107, 108, 122, 118, 124, 121,
697 139, 111, 98, 146, 143, 152, 145, 151, 44, 45,
698 58, 74, 147, 0, 110, 150, 153
699 };
700
701 static const yytype_int16 yycheck[] =
702 {
703 6, 7, 20, 82, 57, 49, 53, 4, 20, 7,
704 49, 17, 18, 19, 15, 4, 22, 23, 24, 48,
705 6, 7, 51, 49, 53, 36, 37, 56, 57, 47,
706 48, 17, 18, 19, 25, 47, 22, 23, 24, 3,
707 46, 47, 39, 41, 8, 9, 10, 54, 95, 55,
708 39, 6, 81, 42, 107, 0, 0, 20, 22, 12,
709 46, 11, 7, 70, 33, 40, 95, 146, 23, 55,
710 20, 124, 151, 80, 29, 30, 24, 83, 107, 43,
711 20, 50, 20, 38, 24, 7, 34, 51, 12, 70,
712 45, 98, 99, 31, 34, 124, 112, 47, 48, 80,
713 48, 44, 118, 31, 53, 5, 54, 13, 48, 7,
714 16, 17, 31, 12, 54, 18, 53, 98, 99, 14,
715 26, 13, 28, 18, 19, 42, 32, 101, 102, 35,
716 104, 105, 106, 7, 7, 42, 18, 31, 27, 36,
717 52, 24, 4, 31, 37, 50, 37, 7, 24, 29,
718 46, 55, 42, -1, 81, 42, 151
719 };
720
721 /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
722 symbol of state STATE-NUM. */
723 static const yytype_uint8 yystos[] =
724 {
725 0, 3, 8, 9, 10, 22, 43, 51, 66, 67,
726 68, 69, 70, 71, 72, 74, 82, 49, 49, 15,
727 86, 87, 49, 25, 11, 20, 47, 48, 83, 84,
728 97, 98, 99, 100, 98, 99, 0, 98, 98, 88,
729 98, 40, 98, 98, 83, 86, 7, 12, 44, 14,
730 18, 19, 73, 31, 53, 7, 5, 31, 84, 99,
731 92, 93, 96, 98, 99, 77, 96, 75, 76, 77,
732 31, 89, 95, 96, 88, 98, 47, 85, 96, 85,
733 53, 7, 13, 12, 18, 6, 23, 29, 30, 38,
734 45, 78, 79, 80, 42, 7, 41, 89, 4, 39,
735 13, 16, 17, 26, 28, 32, 35, 7, 42, 89,
736 92, 24, 34, 48, 54, 94, 101, 99, 31, 33,
737 50, 36, 18, 77, 27, 42, 89, 89, 90, 94,
738 95, 90, 90, 36, 37, 90, 90, 90, 85, 52,
739 101, 81, 101, 37, 85, 37, 31, 42, 91, 94,
740 42, 7, 50, 91
741 };
742
743 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
744 static const yytype_uint8 yyr1[] =
745 {
746 0, 65, 66, 67, 67, 67, 67, 67, 67, 67,
747 68, 68, 69, 69, 70, 70, 71, 72, 72, 72,
748 73, 73, 74, 75, 76, 76, 77, 78, 78, 78,
749 79, 79, 80, 80, 80, 80, 80, 80, 80, 81,
750 82, 82, 83, 84, 84, 84, 85, 85, 85, 86,
751 86, 86, 87, 87, 88, 88, 89, 89, 89, 89,
752 89, 89, 89, 89, 89, 89, 89, 90, 90, 91,
753 91, 92, 92, 93, 94, 94, 94, 94, 95, 96,
754 96, 97, 97, 97, 98, 99, 100, 101
755 };
756
757 /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
758 static const yytype_uint8 yyr2[] =
759 {
760 0, 2, 1, 1, 1, 1, 1, 1, 1, 1,
761 10, 11, 6, 7, 6, 4, 2, 4, 5, 6,
762 1, 1, 3, 4, 3, 1, 2, 1, 2, 2,
763 1, 3, 1, 4, 1, 1, 1, 1, 1, 1,
764 2, 3, 2, 1, 3, 1, 1, 3, 1, 2,
765 4, 1, 2, 4, 1, 3, 3, 3, 3, 3,
766 3, 3, 3, 3, 3, 3, 4, 1, 1, 1,
767 3, 1, 3, 3, 1, 2, 1, 1, 1, 3,
768 1, 3, 1, 1, 1, 1, 1, 1
769 };
770
771
772 #define yyerrok (yyerrstatus = 0)
773 #define yyclearin (yychar = YYEMPTY)
774 #define YYEMPTY (-2)
775 #define YYEOF 0
776
777 #define YYACCEPT goto yyacceptlab
778 #define YYABORT goto yyabortlab
779 #define YYERROR goto yyerrorlab
780
781
782 #define YYRECOVERING() (!!yyerrstatus)
783
784 #define YYBACKUP(Token, Value) \
785 do \
786 if (yychar == YYEMPTY) \
787 { \
788 yychar = (Token); \
789 yylval = (Value); \
790 YYPOPSTACK (yylen); \
791 yystate = *yyssp; \
792 goto yybackup; \
793 } \
794 else \
795 { \
796 yyerror (info, YY_("syntax error: cannot back up")); \
797 YYERROR; \
798 } \
799 while (0)
800
801 /* Error token number */
802 #define YYTERROR 1
803 #define YYERRCODE 256
804
805
806
807 /* Enable debugging if requested. */
808 #if YYDEBUG
809
810 # ifndef YYFPRINTF
811 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
812 # define YYFPRINTF fprintf
813 # endif
814
815 # define YYDPRINTF(Args) \
816 do { \
817 if (yydebug) \
818 YYFPRINTF Args; \
819 } while (0)
820
821 /* This macro is provided for backward compatibility. */
822 #ifndef YY_LOCATION_PRINT
823 # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
824 #endif
825
826
827 # define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
828 do { \
829 if (yydebug) \
830 { \
831 YYFPRINTF (stderr, "%s ", Title); \
832 yy_symbol_print (stderr, \
833 Type, Value, info); \
834 YYFPRINTF (stderr, "\n"); \
835 } \
836 } while (0)
837
838
839 /*----------------------------------------.
840 | Print this symbol's value on YYOUTPUT. |
841 `----------------------------------------*/
842
843 static void
844 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, SQL_input *info)
845 {
846 FILE *yyo = yyoutput;
847 YYUSE (yyo);
848 YYUSE (info);
849 if (!yyvaluep)
850 return;
851 # ifdef YYPRINT
852 if (yytype < YYNTOKENS)
853 YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
854 # endif
855 YYUSE (yytype);
856 }
857
858
859 /*--------------------------------.
860 | Print this symbol on YYOUTPUT. |
861 `--------------------------------*/
862
863 static void
864 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, SQL_input *info)
865 {
866 YYFPRINTF (yyoutput, "%s %s (",
867 yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
868
869 yy_symbol_value_print (yyoutput, yytype, yyvaluep, info);
870 YYFPRINTF (yyoutput, ")");
871 }
872
873 /*------------------------------------------------------------------.
874 | yy_stack_print -- Print the state stack from its BOTTOM up to its |
875 | TOP (included). |
876 `------------------------------------------------------------------*/
877
878 static void
879 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
880 {
881 YYFPRINTF (stderr, "Stack now");
882 for (; yybottom <= yytop; yybottom++)
883 {
884 int yybot = *yybottom;
885 YYFPRINTF (stderr, " %d", yybot);
886 }
887 YYFPRINTF (stderr, "\n");
888 }
889
890 # define YY_STACK_PRINT(Bottom, Top) \
891 do { \
892 if (yydebug) \
893 yy_stack_print ((Bottom), (Top)); \
894 } while (0)
895
896
897 /*------------------------------------------------.
898 | Report that the YYRULE is going to be reduced. |
899 `------------------------------------------------*/
900
901 static void
902 yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, SQL_input *info)
903 {
904 unsigned long int yylno = yyrline[yyrule];
905 int yynrhs = yyr2[yyrule];
906 int yyi;
907 YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
908 yyrule - 1, yylno);
909 /* The symbols being reduced. */
910 for (yyi = 0; yyi < yynrhs; yyi++)
911 {
912 YYFPRINTF (stderr, " $%d = ", yyi + 1);
913 yy_symbol_print (stderr,
914 yystos[yyssp[yyi + 1 - yynrhs]],
915 &(yyvsp[(yyi + 1) - (yynrhs)])
916 , info);
917 YYFPRINTF (stderr, "\n");
918 }
919 }
920
921 # define YY_REDUCE_PRINT(Rule) \
922 do { \
923 if (yydebug) \
924 yy_reduce_print (yyssp, yyvsp, Rule, info); \
925 } while (0)
926
927 /* Nonzero means print parse trace. It is left uninitialized so that
928 multiple parsers can coexist. */
929 int yydebug;
930 #else /* !YYDEBUG */
931 # define YYDPRINTF(Args)
932 # define YY_SYMBOL_PRINT(Title, Type, Value, Location)
933 # define YY_STACK_PRINT(Bottom, Top)
934 # define YY_REDUCE_PRINT(Rule)
935 #endif /* !YYDEBUG */
936
937
938 /* YYINITDEPTH -- initial size of the parser's stacks. */
939 #ifndef YYINITDEPTH
940 # define YYINITDEPTH 200
941 #endif
942
943 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
944 if the built-in stack extension method is used).
945
946 Do not make this value too large; the results are undefined if
947 YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
948 evaluated with infinite-precision integer arithmetic. */
949
950 #ifndef YYMAXDEPTH
951 # define YYMAXDEPTH 10000
952 #endif
953
954
955 #if YYERROR_VERBOSE
956
957 # ifndef yystrlen
958 # if defined __GLIBC__ && defined _STRING_H
959 # define yystrlen strlen
960 # else
961 /* Return the length of YYSTR. */
962 static YYSIZE_T
963 yystrlen (const char *yystr)
964 {
965 YYSIZE_T yylen;
966 for (yylen = 0; yystr[yylen]; yylen++)
967 continue;
968 return yylen;
969 }
970 # endif
971 # endif
972
973 # ifndef yystpcpy
974 # if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
975 # define yystpcpy stpcpy
976 # else
977 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
978 YYDEST. */
979 static char *
980 yystpcpy (char *yydest, const char *yysrc)
981 {
982 char *yyd = yydest;
983 const char *yys = yysrc;
984
985 while ((*yyd++ = *yys++) != '\0')
986 continue;
987
988 return yyd - 1;
989 }
990 # endif
991 # endif
992
993 # ifndef yytnamerr
994 /* Copy to YYRES the contents of YYSTR after stripping away unnecessary
995 quotes and backslashes, so that it's suitable for yyerror. The
996 heuristic is that double-quoting is unnecessary unless the string
997 contains an apostrophe, a comma, or backslash (other than
998 backslash-backslash). YYSTR is taken from yytname. If YYRES is
999 null, do not copy; instead, return the length of what the result
1000 would have been. */
1001 static YYSIZE_T
1002 yytnamerr (char *yyres, const char *yystr)
1003 {
1004 if (*yystr == '"')
1005 {
1006 YYSIZE_T yyn = 0;
1007 char const *yyp = yystr;
1008
1009 for (;;)
1010 switch (*++yyp)
1011 {
1012 case '\'':
1013 case ',':
1014 goto do_not_strip_quotes;
1015
1016 case '\\':
1017 if (*++yyp != '\\')
1018 goto do_not_strip_quotes;
1019 /* Fall through. */
1020 default:
1021 if (yyres)
1022 yyres[yyn] = *yyp;
1023 yyn++;
1024 break;
1025
1026 case '"':
1027 if (yyres)
1028 yyres[yyn] = '\0';
1029 return yyn;
1030 }
1031 do_not_strip_quotes: ;
1032 }
1033
1034 if (! yyres)
1035 return yystrlen (yystr);
1036
1037 return yystpcpy (yyres, yystr) - yyres;
1038 }
1039 # endif
1040
1041 /* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message
1042 about the unexpected token YYTOKEN for the state stack whose top is
1043 YYSSP.
1044
1045 Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is
1046 not large enough to hold the message. In that case, also set
1047 *YYMSG_ALLOC to the required number of bytes. Return 2 if the
1048 required number of bytes is too large to store. */
1049 static int
1050 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
1051 yytype_int16 *yyssp, int yytoken)
1052 {
1053 YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
1054 YYSIZE_T yysize = yysize0;
1055 enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1056 /* Internationalized format string. */
1057 const char *yyformat = YY_NULLPTR;
1058 /* Arguments of yyformat. */
1059 char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1060 /* Number of reported tokens (one for the "unexpected", one per
1061 "expected"). */
1062 int yycount = 0;
1063
1064 /* There are many possibilities here to consider:
1065 - If this state is a consistent state with a default action, then
1066 the only way this function was invoked is if the default action
1067 is an error action. In that case, don't check for expected
1068 tokens because there are none.
1069 - The only way there can be no lookahead present (in yychar) is if
1070 this state is a consistent state with a default action. Thus,
1071 detecting the absence of a lookahead is sufficient to determine
1072 that there is no unexpected or expected token to report. In that
1073 case, just report a simple "syntax error".
1074 - Don't assume there isn't a lookahead just because this state is a
1075 consistent state with a default action. There might have been a
1076 previous inconsistent state, consistent state with a non-default
1077 action, or user semantic action that manipulated yychar.
1078 - Of course, the expected token list depends on states to have
1079 correct lookahead information, and it depends on the parser not
1080 to perform extra reductions after fetching a lookahead from the
1081 scanner and before detecting a syntax error. Thus, state merging
1082 (from LALR or IELR) and default reductions corrupt the expected
1083 token list. However, the list is correct for canonical LR with
1084 one exception: it will still contain any token that will not be
1085 accepted due to an error action in a later state.
1086 */
1087 if (yytoken != YYEMPTY)
1088 {
1089 int yyn = yypact[*yyssp];
1090 yyarg[yycount++] = yytname[yytoken];
1091 if (!yypact_value_is_default (yyn))
1092 {
1093 /* Start YYX at -YYN if negative to avoid negative indexes in
1094 YYCHECK. In other words, skip the first -YYN actions for
1095 this state because they are default actions. */
1096 int yyxbegin = yyn < 0 ? -yyn : 0;
1097 /* Stay within bounds of both yycheck and yytname. */
1098 int yychecklim = YYLAST - yyn + 1;
1099 int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1100 int yyx;
1101
1102 for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1103 if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR
1104 && !yytable_value_is_error (yytable[yyx + yyn]))
1105 {
1106 if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1107 {
1108 yycount = 1;
1109 yysize = yysize0;
1110 break;
1111 }
1112 yyarg[yycount++] = yytname[yyx];
1113 {
1114 YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
1115 if (! (yysize <= yysize1
1116 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1117 return 2;
1118 yysize = yysize1;
1119 }
1120 }
1121 }
1122 }
1123
1124 switch (yycount)
1125 {
1126 # define YYCASE_(N, S) \
1127 case N: \
1128 yyformat = S; \
1129 break
1130 YYCASE_(0, YY_("syntax error"));
1131 YYCASE_(1, YY_("syntax error, unexpected %s"));
1132 YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s"));
1133 YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s"));
1134 YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
1135 YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
1136 # undef YYCASE_
1137 }
1138
1139 {
1140 YYSIZE_T yysize1 = yysize + yystrlen (yyformat);
1141 if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
1142 return 2;
1143 yysize = yysize1;
1144 }
1145
1146 if (*yymsg_alloc < yysize)
1147 {
1148 *yymsg_alloc = 2 * yysize;
1149 if (! (yysize <= *yymsg_alloc
1150 && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM))
1151 *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM;
1152 return 1;
1153 }
1154
1155 /* Avoid sprintf, as that infringes on the user's name space.
1156 Don't have undefined behavior even if the translation
1157 produced a string with the wrong number of "%s"s. */
1158 {
1159 char *yyp = *yymsg;
1160 int yyi = 0;
1161 while ((*yyp = *yyformat) != '\0')
1162 if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount)
1163 {
1164 yyp += yytnamerr (yyp, yyarg[yyi++]);
1165 yyformat += 2;
1166 }
1167 else
1168 {
1169 yyp++;
1170 yyformat++;
1171 }
1172 }
1173 return 0;
1174 }
1175 #endif /* YYERROR_VERBOSE */
1176
1177 /*-----------------------------------------------.
1178 | Release the memory associated to this symbol. |
1179 `-----------------------------------------------*/
1180
1181 static void
1182 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, SQL_input *info)
1183 {
1184 YYUSE (yyvaluep);
1185 YYUSE (info);
1186 if (!yymsg)
1187 yymsg = "Deleting";
1188 YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1189
1190 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1191 YYUSE (yytype);
1192 YY_IGNORE_MAYBE_UNINITIALIZED_END
1193 }
1194
1195
1196
1197
1198 /*----------.
1199 | yyparse. |
1200 `----------*/
1201
1202 int
1203 yyparse (SQL_input *info)
1204 {
1205 /* The lookahead symbol. */
1206 int yychar;
1207
1208
1209 /* The semantic value of the lookahead symbol. */
1210 /* Default value used for initialization, for pacifying older GCCs
1211 or non-GCC compilers. */
1212 YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1213 YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1214
1215 /* Number of syntax errors so far. */
1216 int yynerrs;
1217
1218 int yystate;
1219 /* Number of tokens to shift before error messages enabled. */
1220 int yyerrstatus;
1221
1222 /* The stacks and their tools:
1223 'yyss': related to states.
1224 'yyvs': related to semantic values.
1225
1226 Refer to the stacks through separate pointers, to allow yyoverflow
1227 to reallocate them elsewhere. */
1228
1229 /* The state stack. */
1230 yytype_int16 yyssa[YYINITDEPTH];
1231 yytype_int16 *yyss;
1232 yytype_int16 *yyssp;
1233
1234 /* The semantic value stack. */
1235 YYSTYPE yyvsa[YYINITDEPTH];
1236 YYSTYPE *yyvs;
1237 YYSTYPE *yyvsp;
1238
1239 YYSIZE_T yystacksize;
1240
1241 int yyn;
1242 int yyresult;
1243 /* Lookahead token as an internal (translated) token number. */
1244 int yytoken = 0;
1245 /* The variables used to return semantic value and location from the
1246 action routines. */
1247 YYSTYPE yyval;
1248
1249 #if YYERROR_VERBOSE
1250 /* Buffer for error messages, and its allocated size. */
1251 char yymsgbuf[128];
1252 char *yymsg = yymsgbuf;
1253 YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1254 #endif
1255
1256 #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1257
1258 /* The number of symbols on the RHS of the reduced rule.
1259 Keep to zero when no symbol should be popped. */
1260 int yylen = 0;
1261
1262 yyssp = yyss = yyssa;
1263 yyvsp = yyvs = yyvsa;
1264 yystacksize = YYINITDEPTH;
1265
1266 YYDPRINTF ((stderr, "Starting parse\n"));
1267
1268 yystate = 0;
1269 yyerrstatus = 0;
1270 yynerrs = 0;
1271 yychar = YYEMPTY; /* Cause a token to be read. */
1272 goto yysetstate;
1273
1274 /*------------------------------------------------------------.
1275 | yynewstate -- Push a new state, which is found in yystate. |
1276 `------------------------------------------------------------*/
1277 yynewstate:
1278 /* In all cases, when you get here, the value and location stacks
1279 have just been pushed. So pushing a state here evens the stacks. */
1280 yyssp++;
1281
1282 yysetstate:
1283 *yyssp = yystate;
1284
1285 if (yyss + yystacksize - 1 <= yyssp)
1286 {
1287 /* Get the current used size of the three stacks, in elements. */
1288 YYSIZE_T yysize = yyssp - yyss + 1;
1289
1290 #ifdef yyoverflow
1291 {
1292 /* Give user a chance to reallocate the stack. Use copies of
1293 these so that the &'s don't force the real ones into
1294 memory. */
1295 YYSTYPE *yyvs1 = yyvs;
1296 yytype_int16 *yyss1 = yyss;
1297
1298 /* Each stack pointer address is followed by the size of the
1299 data in use in that stack, in bytes. This used to be a
1300 conditional around just the two extra args, but that might
1301 be undefined if yyoverflow is a macro. */
1302 yyoverflow (YY_("memory exhausted"),
1303 &yyss1, yysize * sizeof (*yyssp),
1304 &yyvs1, yysize * sizeof (*yyvsp),
1305 &yystacksize);
1306
1307 yyss = yyss1;
1308 yyvs = yyvs1;
1309 }
1310 #else /* no yyoverflow */
1311 # ifndef YYSTACK_RELOCATE
1312 goto yyexhaustedlab;
1313 # else
1314 /* Extend the stack our own way. */
1315 if (YYMAXDEPTH <= yystacksize)
1316 goto yyexhaustedlab;
1317 yystacksize *= 2;
1318 if (YYMAXDEPTH < yystacksize)
1319 yystacksize = YYMAXDEPTH;
1320
1321 {
1322 yytype_int16 *yyss1 = yyss;
1323 union yyalloc *yyptr =
1324 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1325 if (! yyptr)
1326 goto yyexhaustedlab;
1327 YYSTACK_RELOCATE (yyss_alloc, yyss);
1328 YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1329 # undef YYSTACK_RELOCATE
1330 if (yyss1 != yyssa)
1331 YYSTACK_FREE (yyss1);
1332 }
1333 # endif
1334 #endif /* no yyoverflow */
1335
1336 yyssp = yyss + yysize - 1;
1337 yyvsp = yyvs + yysize - 1;
1338
1339 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1340 (unsigned long int) yystacksize));
1341
1342 if (yyss + yystacksize - 1 <= yyssp)
1343 YYABORT;
1344 }
1345
1346 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1347
1348 if (yystate == YYFINAL)
1349 YYACCEPT;
1350
1351 goto yybackup;
1352
1353 /*-----------.
1354 | yybackup. |
1355 `-----------*/
1356 yybackup:
1357
1358 /* Do appropriate processing given the current state. Read a
1359 lookahead token if we need one and don't already have one. */
1360
1361 /* First try to decide what to do without reference to lookahead token. */
1362 yyn = yypact[yystate];
1363 if (yypact_value_is_default (yyn))
1364 goto yydefault;
1365
1366 /* Not known => get a lookahead token if don't already have one. */
1367
1368 /* YYCHAR is either YYEMPTY or YYEOF or a valid lookahead symbol. */
1369 if (yychar == YYEMPTY)
1370 {
1371 YYDPRINTF ((stderr, "Reading a token: "));
1372 yychar = yylex (&yylval, info);
1373 }
1374
1375 if (yychar <= YYEOF)
1376 {
1377 yychar = yytoken = YYEOF;
1378 YYDPRINTF ((stderr, "Now at end of input.\n"));
1379 }
1380 else
1381 {
1382 yytoken = YYTRANSLATE (yychar);
1383 YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1384 }
1385
1386 /* If the proper action on seeing token YYTOKEN is to reduce or to
1387 detect an error, take that action. */
1388 yyn += yytoken;
1389 if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1390 goto yydefault;
1391 yyn = yytable[yyn];
1392 if (yyn <= 0)
1393 {
1394 if (yytable_value_is_error (yyn))
1395 goto yyerrlab;
1396 yyn = -yyn;
1397 goto yyreduce;
1398 }
1399
1400 /* Count tokens shifted since error; after three, turn off error
1401 status. */
1402 if (yyerrstatus)
1403 yyerrstatus--;
1404
1405 /* Shift the lookahead token. */
1406 YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1407
1408 /* Discard the shifted token. */
1409 yychar = YYEMPTY;
1410
1411 yystate = yyn;
1412 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1413 *++yyvsp = yylval;
1414 YY_IGNORE_MAYBE_UNINITIALIZED_END
1415
1416 goto yynewstate;
1417
1418
1419 /*-----------------------------------------------------------.
1420 | yydefault -- do the default action for the current state. |
1421 `-----------------------------------------------------------*/
1422 yydefault:
1423 yyn = yydefact[yystate];
1424 if (yyn == 0)
1425 goto yyerrlab;
1426 goto yyreduce;
1427
1428
1429 /*-----------------------------.
1430 | yyreduce -- Do a reduction. |
1431 `-----------------------------*/
1432 yyreduce:
1433 /* yyn is the number of a rule to reduce with. */
1434 yylen = yyr2[yyn];
1435
1436 /* If YYLEN is nonzero, implement the default value of the action:
1437 '$$ = $1'.
1438
1439 Otherwise, the following line sets YYVAL to garbage.
1440 This behavior is undocumented and Bison
1441 users should not rely upon it. Assigning to YYVAL
1442 unconditionally makes the parser a bit smaller, and it avoids a
1443 GCC warning that YYVAL may be used uninitialized. */
1444 yyval = yyvsp[1-yylen];
1445
1446
1447 YY_REDUCE_PRINT (yyn);
1448 switch (yyn)
1449 {
1450 case 2:
1451 #line 118 "sql.y" /* yacc.c:1646 */
1452 {
1453 SQL_input* sql = (SQL_input*) info;
1454 *sql->view = (yyvsp[0].query);
1455 }
1456 #line 1469 "sql.tab.c" /* yacc.c:1646 */
1457 break;
1458
1459 case 10:
1460 #line 136 "sql.y" /* yacc.c:1646 */
1461 {
1462 SQL_input *sql = (SQL_input*) info;
1463 MSIVIEW *insert = NULL;
1464
1465 INSERT_CreateView( sql->db, &insert, (yyvsp[-7].string), (yyvsp[-5].column_list), (yyvsp[-1].column_list), FALSE );
1466 if( !insert )
1467 YYABORT;
1468
1469 PARSER_BUBBLE_UP_VIEW( sql, (yyval.query), insert );
1470 }
1471 #line 1484 "sql.tab.c" /* yacc.c:1646 */
1472 break;
1473
1474 case 11:
1475 #line 147 "sql.y" /* yacc.c:1646 */
1476 {
1477 SQL_input *sql = (SQL_input*) info;
1478 MSIVIEW *insert = NULL;
1479
1480 INSERT_CreateView( sql->db, &insert, (yyvsp[-8].string), (yyvsp[-6].column_list), (yyvsp[-2].column_list), TRUE );
1481 if( !insert )
1482 YYABORT;
1483
1484 PARSER_BUBBLE_UP_VIEW( sql, (yyval.query), insert );
1485 }
1486 #line 1499 "sql.tab.c" /* yacc.c:1646 */
1487 break;
1488
1489 case 12:
1490 #line 161 "sql.y" /* yacc.c:1646 */
1491 {
1492 SQL_input* sql = (SQL_input*) info;
1493 MSIVIEW *create = NULL;
1494 UINT r;
1495
1496 if( !(yyvsp[-1].column_list) )
1497 YYABORT;
1498 r = CREATE_CreateView( sql->db, &create, (yyvsp[-3].string), (yyvsp[-1].column_list), FALSE );
1499 if( !create )
1500 {
1501 sql->r = r;
1502 YYABORT;
1503 }
1504
1505 PARSER_BUBBLE_UP_VIEW( sql, (yyval.query), create );
1506 }
1507 #line 1520 "sql.tab.c" /* yacc.c:1646 */
1508 break;
1509
1510 case 13:
1511 #line 178 "sql.y" /* yacc.c:1646 */
1512 {
1513 SQL_input* sql = (SQL_input*) info;
1514 MSIVIEW *create = NULL;
1515
1516 if( !(yyvsp[-2].column_list) )
1517 YYABORT;
1518 CREATE_CreateView( sql->db, &create, (yyvsp[-4].string), (yyvsp[-2].column_list), TRUE );
1519 if( !create )
1520 YYABORT;
1521
1522 PARSER_BUBBLE_UP_VIEW( sql, (yyval.query), create );
1523 }
1524 #line 1537 "sql.tab.c" /* yacc.c:1646 */
1525 break;
1526
1527 case 14:
1528 #line 194 "sql.y" /* yacc.c:1646 */
1529 {
1530 SQL_input* sql = (SQL_input*) info;
1531 MSIVIEW *update = NULL;
1532
1533 UPDATE_CreateView( sql->db, &update, (yyvsp[-4].string), (yyvsp[-2].column_list), (yyvsp[0].expr) );
1534 if( !update )
1535 YYABORT;
1536
1537 PARSER_BUBBLE_UP_VIEW( sql, (yyval.query), update );
1538 }
1539 #line 1552 "sql.tab.c" /* yacc.c:1646 */
1540 break;
1541
1542 case 15:
1543 #line 205 "sql.y" /* yacc.c:1646 */
1544 {
1545 SQL_input* sql = (SQL_input*) info;
1546 MSIVIEW *update = NULL;
1547
1548 UPDATE_CreateView( sql->db, &update, (yyvsp[-2].string), (yyvsp[0].column_list), NULL );
1549 if( !update )
1550 YYABORT;
1551
1552 PARSER_BUBBLE_UP_VIEW( sql, (yyval.query), update );
1553 }
1554 #line 1567 "sql.tab.c" /* yacc.c:1646 */
1555 break;
1556
1557 case 16:
1558 #line 219 "sql.y" /* yacc.c:1646 */
1559 {
1560 SQL_input* sql = (SQL_input*) info;
1561 MSIVIEW *delete = NULL;
1562
1563 DELETE_CreateView( sql->db, &delete, (yyvsp[0].query) );
1564 if( !delete )
1565 YYABORT;
1566
1567 PARSER_BUBBLE_UP_VIEW( sql, (yyval.query), delete );
1568 }
1569 #line 1582 "sql.tab.c" /* yacc.c:1646 */
1570 break;
1571
1572 case 17:
1573 #line 233 "sql.y" /* yacc.c:1646 */
1574 {
1575 SQL_input* sql = (SQL_input*) info;
1576 MSIVIEW *alter = NULL;
1577
1578 ALTER_CreateView( sql->db, &alter, (yyvsp[-1].string), NULL, (yyvsp[0].integer) );
1579 if( !alter )
1580 YYABORT;
1581
1582 PARSER_BUBBLE_UP_VIEW( sql, (yyval.query), alter );
1583 }
1584 #line 1597 "sql.tab.c" /* yacc.c:1646 */
1585 break;
1586
1587 case 18:
1588 #line 244 "sql.y" /* yacc.c:1646 */
1589 {
1590 SQL_input *sql = (SQL_input *)info;
1591 MSIVIEW *alter = NULL;
1592
1593 ALTER_CreateView( sql->db, &alter, (yyvsp[-2].string), (yyvsp[0].column_list), 0 );
1594 if (!alter)
1595 YYABORT;
1596
1597 PARSER_BUBBLE_UP_VIEW( sql, (yyval.query), alter );
1598 }
1599 #line 1612 "sql.tab.c" /* yacc.c:1646 */
1600 break;
1601
1602 case 19:
1603 #line 255 "sql.y" /* yacc.c:1646 */
1604 {
1605 SQL_input *sql = (SQL_input *)info;
1606 MSIVIEW *alter = NULL;
1607
1608 ALTER_CreateView( sql->db, &alter, (yyvsp[-3].string), (yyvsp[-1].column_list), 1 );
1609 if (!alter)
1610 YYABORT;
1611
1612 PARSER_BUBBLE_UP_VIEW( sql, (yyval.query), alter );
1613 }
1614 #line 1627 "sql.tab.c" /* yacc.c:1646 */
1615 break;
1616
1617 case 20:
1618 #line 269 "sql.y" /* yacc.c:1646 */
1619 {
1620 (yyval.integer) = 1;
1621 }
1622 #line 1635 "sql.tab.c" /* yacc.c:1646 */
1623 break;
1624
1625 case 21:
1626 #line 273 "sql.y" /* yacc.c:1646 */
1627 {
1628 (yyval.integer) = -1;
1629 }
1630 #line 1643 "sql.tab.c" /* yacc.c:1646 */
1631 break;
1632
1633 case 22:
1634 #line 280 "sql.y" /* yacc.c:1646 */
1635 {
1636 SQL_input* sql = (SQL_input*) info;
1637 MSIVIEW* drop = NULL;
1638 UINT r;
1639
1640 r = DROP_CreateView( sql->db, &drop, (yyvsp[0].string) );
1641 if( r != ERROR_SUCCESS || !(yyval.query) )
1642 YYABORT;
1643
1644 PARSER_BUBBLE_UP_VIEW( sql, (yyval.query), drop );
1645 }
1646 #line 1659 "sql.tab.c" /* yacc.c:1646 */
1647 break;
1648
1649 case 23:
1650 #line 295 "sql.y" /* yacc.c:1646 */
1651 {
1652 if( SQL_MarkPrimaryKeys( &(yyvsp[-3].column_list), (yyvsp[0].column_list) ) )
1653 (yyval.column_list) = (yyvsp[-3].column_list);
1654 else
1655 (yyval.column_list) = NULL;
1656 }
1657 #line 1670 "sql.tab.c" /* yacc.c:1646 */
1658 break;
1659
1660 case 24:
1661 #line 305 "sql.y" /* yacc.c:1646 */
1662 {
1663 column_info *ci;
1664
1665 for( ci = (yyvsp[-2].column_list); ci->next; ci = ci->next )
1666 ;
1667
1668 ci->next = (yyvsp[0].column_list);
1669 (yyval.column_list) = (yyvsp[-2].column_list);
1670 }
1671 #line 1684 "sql.tab.c" /* yacc.c:1646 */
1672 break;
1673
1674 case 25:
1675 #line 315 "sql.y" /* yacc.c:1646 */
1676 {
1677 (yyval.column_list) = (yyvsp[0].column_list);
1678 }
1679 #line 1692 "sql.tab.c" /* yacc.c:1646 */
1680 break;
1681
1682 case 26:
1683 #line 322 "sql.y" /* yacc.c:1646 */
1684 {
1685 (yyval.column_list) = (yyvsp[-1].column_list);
1686 (yyval.column_list)->type = ((yyvsp[0].column_type) | MSITYPE_VALID);
1687 (yyval.column_list)->temporary = (yyvsp[0].column_type) & MSITYPE_TEMPORARY ? TRUE : FALSE;
1688 }
1689 #line 1702 "sql.tab.c" /* yacc.c:1646 */
1690 break;
1691
1692 case 27:
1693 #line 331 "sql.y" /* yacc.c:1646 */
1694 {
1695 (yyval.column_type) = (yyvsp[0].column_type);
1696 }
1697 #line 1710 "sql.tab.c" /* yacc.c:1646 */
1698 break;
1699
1700 case 28:
1701 #line 335 "sql.y" /* yacc.c:1646 */
1702 {
1703 (yyval.column_type) = (yyvsp[-1].column_type) | MSITYPE_LOCALIZABLE;
1704 }
1705 #line 1718 "sql.tab.c" /* yacc.c:1646 */
1706 break;
1707
1708 case 29:
1709 #line 339 "sql.y" /* yacc.c:1646 */
1710 {
1711 (yyval.column_type) = (yyvsp[-1].column_type) | MSITYPE_TEMPORARY;
1712 }
1713 #line 1726 "sql.tab.c" /* yacc.c:1646 */
1714 break;
1715
1716 case 30:
1717 #line 346 "sql.y" /* yacc.c:1646 */
1718 {
1719 (yyval.column_type) |= MSITYPE_NULLABLE;
1720 }
1721 #line 1734 "sql.tab.c" /* yacc.c:1646 */
1722 break;
1723
1724 case 31:
1725 #line 350 "sql.y" /* yacc.c:1646 */
1726 {
1727 (yyval.column_type) = (yyvsp[-2].column_type);
1728 }
1729 #line 1742 "sql.tab.c" /* yacc.c:1646 */
1730 break;
1731
1732 case 32:
1733 #line 357 "sql.y" /* yacc.c:1646 */
1734 {
1735 (yyval.column_type) = MSITYPE_STRING | 1;
1736 }
1737 #line 1750 "sql.tab.c" /* yacc.c:1646 */
1738 break;
1739
1740 case 33:
1741 #line 361 "sql.y" /* yacc.c:1646 */
1742 {
1743 (yyval.column_type) = MSITYPE_STRING | 0x400 | (yyvsp[-1].column_type);
1744 }
1745 #line 1758 "sql.tab.c" /* yacc.c:1646 */
1746 break;
1747
1748 case 34:
1749 #line 365 "sql.y" /* yacc.c:1646 */
1750 {
1751 (yyval.column_type) = MSITYPE_STRING | 0x400;
1752 }
1753 #line 1766 "sql.tab.c" /* yacc.c:1646 */
1754 break;
1755
1756 case 35:
1757 #line 369 "sql.y" /* yacc.c:1646 */
1758 {
1759 (yyval.column_type) = 2 | 0x400;
1760 }
1761 #line 1774 "sql.tab.c" /* yacc.c:1646 */
1762 break;
1763
1764 case 36:
1765 #line 373 "sql.y" /* yacc.c:1646 */
1766 {
1767 (yyval.column_type) = 2 | 0x400;
1768 }
1769 #line 1782 "sql.tab.c" /* yacc.c:1646 */
1770 break;
1771
1772 case 37:
1773 #line 377 "sql.y" /* yacc.c:1646 */
1774 {
1775 (yyval.column_type) = 4;
1776 }
1777 #line 1790 "sql.tab.c" /* yacc.c:1646 */
1778 break;
1779
1780 case 38:
1781 #line 381 "sql.y" /* yacc.c:1646 */
1782 {
1783 (yyval.column_type) = MSITYPE_STRING | MSITYPE_VALID;
1784 }
1785 #line 1798 "sql.tab.c" /* yacc.c:1646 */
1786 break;
1787
1788 case 39:
1789 #line 388 "sql.y" /* yacc.c:1646 */
1790 {
1791 if( ( (yyvsp[0].integer) > 255 ) || ( (yyvsp[0].integer) < 0 ) )
1792 YYABORT;
1793 (yyval.column_type) = (yyvsp[0].integer);
1794 }
1795 #line 1808 "sql.tab.c" /* yacc.c:1646 */
1796 break;
1797
1798 case 40:
1799 #line 397 "sql.y" /* yacc.c:1646 */
1800 {
1801 (yyval.query) = (yyvsp[0].query);
1802 }
1803 #line 1816 "sql.tab.c" /* yacc.c:1646 */
1804 break;
1805
1806 case 41:
1807 #line 401 "sql.y" /* yacc.c:1646 */
1808 {
1809 SQL_input* sql = (SQL_input*) info;
1810 MSIVIEW* distinct = NULL;
1811 UINT r;
1812
1813 r = DISTINCT_CreateView( sql->db, &distinct, (yyvsp[0].query) );
1814 if (r != ERROR_SUCCESS)
1815 YYABORT;
1816
1817 PARSER_BUBBLE_UP_VIEW( sql, (yyval.query), distinct );
1818 }
1819 #line 1832 "sql.tab.c" /* yacc.c:1646 */
1820 break;
1821
1822 case 42:
1823 #line 416 "sql.y" /* yacc.c:1646 */
1824 {
1825 SQL_input* sql = (SQL_input*) info;
1826 MSIVIEW* select = NULL;
1827 UINT r;
1828
1829 if( (yyvsp[-1].column_list) )
1830 {
1831 r = SELECT_CreateView( sql->db, &select, (yyvsp[0].query), (yyvsp[-1].column_list) );
1832 if (r != ERROR_SUCCESS)
1833 YYABORT;
1834
1835 PARSER_BUBBLE_UP_VIEW( sql, (yyval.query), select );
1836 }
1837 else
1838 (yyval.query) = (yyvsp[0].query);
1839 }
1840 #line 1853 "sql.tab.c" /* yacc.c:1646 */
1841 break;
1842
1843 case 44:
1844 #line 437 "sql.y" /* yacc.c:1646 */
1845 {
1846 (yyvsp[-2].column_list)->next = (yyvsp[0].column_list);
1847 }
1848 #line 1861 "sql.tab.c" /* yacc.c:1646 */
1849 break;
1850
1851 case 45:
1852 #line 441 "sql.y" /* yacc.c:1646 */
1853 {
1854 (yyval.column_list) = NULL;
1855 }
1856 #line 1869 "sql.tab.c" /* yacc.c:1646 */
1857 break;
1858
1859 case 47:
1860 #line 449 "sql.y" /* yacc.c:1646 */
1861 {
1862 (yyvsp[-2].column_list)->next = (yyvsp[0].column_list);
1863 }
1864 #line 1877 "sql.tab.c" /* yacc.c:1646 */
1865 break;
1866
1867 case 48:
1868 #line 453 "sql.y" /* yacc.c:1646 */
1869 {
1870 (yyval.column_list) = NULL;
1871 }
1872 #line 1885 "sql.tab.c" /* yacc.c:1646 */
1873 break;
1874
1875 case 49:
1876 #line 460 "sql.y" /* yacc.c:1646 */
1877 {
1878 SQL_input* sql = (SQL_input*) info;
1879 MSIVIEW* table = NULL;
1880 UINT r;
1881
1882 r = TABLE_CreateView( sql->db, (yyvsp[0].string), &table );
1883 if( r != ERROR_SUCCESS || !(yyval.query) )
1884 YYABORT;
1885
1886 PARSER_BUBBLE_UP_VIEW( sql, (yyval.query), table );
1887 }
1888 #line 1901 "sql.tab.c" /* yacc.c:1646 */
1889 break;
1890
1891 case 50:
1892 #line 472 "sql.y" /* yacc.c:1646 */
1893 {
1894 UINT r;
1895
1896 if( (yyvsp[0].column_list) )
1897 {
1898 r = (yyvsp[-3].query)->ops->sort( (yyvsp[-3].query), (yyvsp[0].column_list) );
1899 if ( r != ERROR_SUCCESS)
1900 YYABORT;
1901 }
1902
1903 (yyval.query) = (yyvsp[-3].query);
1904 }
1905 #line 1918 "sql.tab.c" /* yacc.c:1646 */
1906 break;
1907
1908 case 52:
1909 #line 489 "sql.y" /* yacc.c:1646 */
1910 {
1911 SQL_input* sql = (SQL_input*) info;
1912 MSIVIEW* where = NULL;
1913 UINT r;
1914
1915 r = WHERE_CreateView( sql->db, &where, (yyvsp[0].string), NULL );
1916 if( r != ERROR_SUCCESS )
1917 YYABORT;
1918
1919 PARSER_BUBBLE_UP_VIEW( sql, (yyval.query), where );
1920 }
1921 #line 1934 "sql.tab.c" /* yacc.c:1646 */
1922 break;
1923
1924 case 53:
1925 #line 501 "sql.y" /* yacc.c:1646 */
1926 {
1927 SQL_input* sql = (SQL_input*) info;
1928 MSIVIEW* where = NULL;
1929 UINT r;
1930
1931 r = WHERE_CreateView( sql->db, &where, (yyvsp[-2].string), (yyvsp[0].expr) );
1932 if( r != ERROR_SUCCESS )
1933 YYABORT;
1934
1935 PARSER_BUBBLE_UP_VIEW( sql, (yyval.query), where );
1936 }
1937 #line 1950 "sql.tab.c" /* yacc.c:1646 */
1938 break;
1939
1940 case 54:
1941 #line 516 "sql.y" /* yacc.c:1646 */
1942 {
1943 (yyval.string) = (yyvsp[0].string);
1944 }
1945 #line 1958 "sql.tab.c" /* yacc.c:1646 */
1946 break;
1947
1948 case 55:
1949 #line 520 "sql.y" /* yacc.c:1646 */
1950 {
1951 (yyval.string) = parser_add_table( info, (yyvsp[0].string), (yyvsp[-2].string) );
1952 if (!(yyval.string))
1953 YYABORT;
1954 }
1955 #line 1968 "sql.tab.c" /* yacc.c:1646 */
1956 break;
1957
1958 case 56:
1959 #line 529 "sql.y" /* yacc.c:1646 */
1960 {
1961 (yyval.expr) = (yyvsp[-1].expr);
1962 if( !(yyval.expr) )
1963 YYABORT;
1964 }
1965 #line 1978 "sql.tab.c" /* yacc.c:1646 */
1966 break;
1967
1968 case 57:
1969 #line 535 "sql.y" /* yacc.c:1646 */
1970 {
1971 (yyval.expr) = EXPR_complex( info, (yyvsp[-2].expr), OP_AND, (yyvsp[0].expr) );
1972 if( !(yyval.expr) )
1973 YYABORT;
1974 }
1975 #line 1988 "sql.tab.c" /* yacc.c:1646 */
1976 break;
1977
1978 case 58:
1979 #line 541 "sql.y" /* yacc.c:1646 */
1980 {
1981 (yyval.expr) = EXPR_complex( info, (yyvsp[-2].expr), OP_OR, (yyvsp[0].expr) );
1982 if( !(yyval.expr) )
1983 YYABORT;
1984 }
1985 #line 1998 "sql.tab.c" /* yacc.c:1646 */
1986 break;
1987
1988 case 59:
1989 #line 547 "sql.y" /* yacc.c:1646 */
1990 {
1991 (yyval.expr) = EXPR_complex( info, (yyvsp[-2].expr), OP_EQ, (yyvsp[0].expr) );
1992 if( !(yyval.expr) )
1993 YYABORT;
1994 }
1995 #line 2008 "sql.tab.c" /* yacc.c:1646 */
1996 break;
1997
1998 case 60:
1999 #line 553 "sql.y" /* yacc.c:1646 */
2000 {
2001 (yyval.expr) = EXPR_complex( info, (yyvsp[-2].expr), OP_GT, (yyvsp[0].expr) );
2002 if( !(yyval.expr) )
2003 YYABORT;
2004 }
2005 #line 2018 "sql.tab.c" /* yacc.c:1646 */
2006 break;
2007
2008 case 61:
2009 #line 559 "sql.y" /* yacc.c:1646 */
2010 {
2011 (yyval.expr) = EXPR_complex( info, (yyvsp[-2].expr), OP_LT, (yyvsp[0].expr) );
2012 if( !(yyval.expr) )
2013 YYABORT;
2014 }
2015 #line 2028 "sql.tab.c" /* yacc.c:1646 */
2016 break;
2017
2018 case 62:
2019 #line 565 "sql.y" /* yacc.c:1646 */
2020 {
2021 (yyval.expr) = EXPR_complex( info, (yyvsp[-2].expr), OP_LE, (yyvsp[0].expr) );
2022 if( !(yyval.expr) )
2023 YYABORT;
2024 }
2025 #line 2038 "sql.tab.c" /* yacc.c:1646 */
2026 break;
2027
2028 case 63:
2029 #line 571 "sql.y" /* yacc.c:1646 */
2030 {
2031 (yyval.expr) = EXPR_complex( info, (yyvsp[-2].expr), OP_GE, (yyvsp[0].expr) );
2032 if( !(yyval.expr) )
2033 YYABORT;
2034 }
2035 #line 2048 "sql.tab.c" /* yacc.c:1646 */
2036 break;
2037
2038 case 64:
2039 #line 577 "sql.y" /* yacc.c:1646 */
2040 {
2041 (yyval.expr) = EXPR_complex( info, (yyvsp[-2].expr), OP_NE, (yyvsp[0].expr) );
2042 if( !(yyval.expr) )
2043 YYABORT;
2044 }
2045 #line 2058 "sql.tab.c" /* yacc.c:1646 */
2046 break;
2047
2048 case 65:
2049 #line 583 "sql.y" /* yacc.c:1646 */
2050 {
2051 (yyval.expr) = EXPR_unary( info, (yyvsp[-2].expr), OP_ISNULL );
2052 if( !(yyval.expr) )
2053 YYABORT;
2054 }
2055 #line 2068 "sql.tab.c" /* yacc.c:1646 */
2056 break;
2057
2058 case 66:
2059 #line 589 "sql.y" /* yacc.c:1646 */
2060 {
2061 (yyval.expr) = EXPR_unary( info, (yyvsp[-3].expr), OP_NOTNULL );
2062 if( !(yyval.expr) )
2063 YYABORT;
2064 }
2065 #line 2078 "sql.tab.c" /* yacc.c:1646 */
2066 break;
2067
2068 case 69:
2069 #line 603 "sql.y" /* yacc.c:1646 */
2070 {
2071 (yyval.column_list) = parser_alloc_column( info, NULL, NULL );
2072 if( !(yyval.column_list) )
2073 YYABORT;
2074 (yyval.column_list)->val = (yyvsp[0].expr);
2075 }
2076 #line 2089 "sql.tab.c" /* yacc.c:1646 */
2077 break;
2078
2079 case 70:
2080 #line 610 "sql.y" /* yacc.c:1646 */
2081 {
2082 (yyval.column_list) = parser_alloc_column( info, NULL, NULL );
2083 if( !(yyval.column_list) )
2084 YYABORT;
2085 (yyval.column_list)->val = (yyvsp[-2].expr);
2086 (yyval.column_list)->next = (yyvsp[0].column_list);
2087 }
2088 #line 2101 "sql.tab.c" /* yacc.c:1646 */
2089 break;
2090
2091 case 72:
2092 #line 622 "sql.y" /* yacc.c:1646 */
2093 {
2094 (yyval.column_list) = (yyvsp[-2].column_list);
2095 (yyval.column_list)->next = (yyvsp[0].column_list);
2096 }
2097 #line 2110 "sql.tab.c" /* yacc.c:1646 */
2098 break;
2099
2100 case 73:
2101 #line 630 "sql.y" /* yacc.c:1646 */
2102 {
2103 (yyval.column_list) = (yyvsp[-2].column_list);
2104 (yyval.column_list)->val = (yyvsp[0].expr);
2105 }
2106 #line 2119 "sql.tab.c" /* yacc.c:1646 */
2107 break;
2108
2109 case 74:
2110 #line 638 "sql.y" /* yacc.c:1646 */
2111 {
2112 (yyval.expr) = EXPR_ival( info, (yyvsp[0].integer) );
2113 if( !(yyval.expr) )
2114 YYABORT;
2115 }
2116 #line 2129 "sql.tab.c" /* yacc.c:1646 */
2117 break;
2118
2119 case 75:
2120 #line 644 "sql.y" /* yacc.c:1646 */
2121 {
2122 (yyval.expr) = EXPR_ival( info, -(yyvsp[0].integer) );
2123 if( !(yyval.expr) )
2124 YYABORT;
2125 }
2126 #line 2139 "sql.tab.c" /* yacc.c:1646 */
2127 break;
2128
2129 case 76:
2130 #line 650 "sql.y" /* yacc.c:1646 */
2131 {
2132 (yyval.expr) = EXPR_sval( info, &(yyvsp[0].str) );
2133 if( !(yyval.expr) )
2134 YYABORT;
2135 }
2136 #line 2149 "sql.tab.c" /* yacc.c:1646 */
2137 break;
2138
2139 case 77:
2140 #line 656 "sql.y" /* yacc.c:1646 */
2141 {
2142 (yyval.expr) = EXPR_wildcard( info );
2143 if( !(yyval.expr) )
2144 YYABORT;
2145 }
2146 #line 2159 "sql.tab.c" /* yacc.c:1646 */
2147 break;
2148
2149 case 78:
2150 #line 665 "sql.y" /* yacc.c:1646 */
2151 {
2152 (yyval.expr) = EXPR_column( info, (yyvsp[0].column_list) );
2153 if( !(yyval.expr) )
2154 YYABORT;
2155 }
2156 #line 2169 "sql.tab.c" /* yacc.c:1646 */
2157 break;
2158
2159 case 79:
2160 #line 674 "sql.y" /* yacc.c:1646 */
2161 {
2162 (yyval.column_list) = parser_alloc_column( info, (yyvsp[-2].string), (yyvsp[0].string) );
2163 if( !(yyval.column_list) )
2164 YYABORT;
2165 }
2166 #line 2179 "sql.tab.c" /* yacc.c:1646 */
2167 break;
2168
2169 case 80:
2170 #line 680 "sql.y" /* yacc.c:1646 */
2171 {
2172 (yyval.column_list) = parser_alloc_column( info, NULL, (yyvsp[0].string) );
2173 if( !(yyval.column_list) )
2174 YYABORT;
2175 }
2176 #line 2189 "sql.tab.c" /* yacc.c:1646 */
2177 break;
2178
2179 case 81:
2180 #line 689 "sql.y" /* yacc.c:1646 */
2181 {
2182 (yyval.column_list) = parser_alloc_column( info, (yyvsp[-2].string), (yyvsp[0].string) );
2183 if( !(yyval.column_list) )
2184 YYABORT;
2185 }
2186 #line 2199 "sql.tab.c" /* yacc.c:1646 */
2187 break;
2188
2189 case 82:
2190 #line 695 "sql.y" /* yacc.c:1646 */
2191 {
2192 (yyval.column_list) = parser_alloc_column( info, NULL, (yyvsp[0].string) );
2193 if( !(yyval.column_list) )
2194 YYABORT;
2195 }
2196 #line 2209 "sql.tab.c" /* yacc.c:1646 */
2197 break;
2198
2199 case 83:
2200 #line 701 "sql.y" /* yacc.c:1646 */
2201 {
2202 (yyval.column_list) = parser_alloc_column( info, NULL, (yyvsp[0].string) );
2203 if( !(yyval.column_list) )
2204 YYABORT;
2205 }
2206 #line 2219 "sql.tab.c" /* yacc.c:1646 */
2207 break;
2208
2209 case 84:
2210 #line 710 "sql.y" /* yacc.c:1646 */
2211 {
2212 (yyval.string) = (yyvsp[0].string);
2213 }
2214 #line 2227 "sql.tab.c" /* yacc.c:1646 */
2215 break;
2216
2217 case 85:
2218 #line 717 "sql.y" /* yacc.c:1646 */
2219 {
2220 if ( SQL_getstring( info, &(yyvsp[0].str), &(yyval.string) ) != ERROR_SUCCESS || !(yyval.string) )
2221 YYABORT;
2222 }
2223 #line 2236 "sql.tab.c" /* yacc.c:1646 */
2224 break;
2225
2226 case 86:
2227 #line 725 "sql.y" /* yacc.c:1646 */
2228 {
2229 if ( SQL_getstring( info, &(yyvsp[0].str), &(yyval.string) ) != ERROR_SUCCESS || !(yyval.string) )
2230 YYABORT;
2231 }
2232 #line 2245 "sql.tab.c" /* yacc.c:1646 */
2233 break;
2234
2235 case 87:
2236 #line 733 "sql.y" /* yacc.c:1646 */
2237 {
2238 (yyval.integer) = SQL_getint( info );
2239 }
2240 #line 2253 "sql.tab.c" /* yacc.c:1646 */
2241 break;
2242
2243
2244 #line 2257 "sql.tab.c" /* yacc.c:1646 */
2245 default: break;
2246 }
2247 /* User semantic actions sometimes alter yychar, and that requires
2248 that yytoken be updated with the new translation. We take the
2249 approach of translating immediately before every use of yytoken.
2250 One alternative is translating here after every semantic action,
2251 but that translation would be missed if the semantic action invokes
2252 YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
2253 if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
2254 incorrect destructor might then be invoked immediately. In the
2255 case of YYERROR or YYBACKUP, subsequent parser actions might lead
2256 to an incorrect destructor call or verbose syntax error message
2257 before the lookahead is translated. */
2258 YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
2259
2260 YYPOPSTACK (yylen);
2261 yylen = 0;
2262 YY_STACK_PRINT (yyss, yyssp);
2263
2264 *++yyvsp = yyval;
2265
2266 /* Now 'shift' the result of the reduction. Determine what state
2267 that goes to, based on the state we popped back to and the rule
2268 number reduced by. */
2269
2270 yyn = yyr1[yyn];
2271
2272 yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
2273 if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
2274 yystate = yytable[yystate];
2275 else
2276 yystate = yydefgoto[yyn - YYNTOKENS];
2277
2278 goto yynewstate;
2279
2280
2281 /*--------------------------------------.
2282 | yyerrlab -- here on detecting error. |
2283 `--------------------------------------*/
2284 yyerrlab:
2285 /* Make sure we have latest lookahead translation. See comments at
2286 user semantic actions for why this is necessary. */
2287 yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
2288
2289 /* If not already recovering from an error, report this error. */
2290 if (!yyerrstatus)
2291 {
2292 ++yynerrs;
2293 #if ! YYERROR_VERBOSE
2294 yyerror (info, YY_("syntax error"));
2295 #else
2296 # define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \
2297 yyssp, yytoken)
2298 {
2299 char const *yymsgp = YY_("syntax error");
2300 int yysyntax_error_status;
2301 yysyntax_error_status = YYSYNTAX_ERROR;
2302 if (yysyntax_error_status == 0)
2303 yymsgp = yymsg;
2304 else if (yysyntax_error_status == 1)
2305 {
2306 if (yymsg != yymsgbuf)
2307 YYSTACK_FREE (yymsg);
2308 yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc);
2309 if (!yymsg)
2310 {
2311 yymsg = yymsgbuf;
2312 yymsg_alloc = sizeof yymsgbuf;
2313 yysyntax_error_status = 2;
2314 }
2315 else
2316 {
2317 yysyntax_error_status = YYSYNTAX_ERROR;
2318 yymsgp = yymsg;
2319 }
2320 }
2321 yyerror (info, yymsgp);
2322 if (yysyntax_error_status == 2)
2323 goto yyexhaustedlab;
2324 }
2325 # undef YYSYNTAX_ERROR
2326 #endif
2327 }
2328
2329
2330
2331 if (yyerrstatus == 3)
2332 {
2333 /* If just tried and failed to reuse lookahead token after an
2334 error, discard it. */
2335
2336 if (yychar <= YYEOF)
2337 {
2338 /* Return failure if at end of input. */
2339 if (yychar == YYEOF)
2340 YYABORT;
2341 }
2342 else
2343 {
2344 yydestruct ("Error: discarding",
2345 yytoken, &yylval, info);
2346 yychar = YYEMPTY;
2347 }
2348 }
2349
2350 /* Else will try to reuse lookahead token after shifting the error
2351 token. */
2352 goto yyerrlab1;
2353
2354
2355 /*---------------------------------------------------.
2356 | yyerrorlab -- error raised explicitly by YYERROR. |
2357 `---------------------------------------------------*/
2358 yyerrorlab:
2359
2360 /* Pacify compilers like GCC when the user code never invokes
2361 YYERROR and the label yyerrorlab therefore never appears in user
2362 code. */
2363 if (/*CONSTCOND*/ 0)
2364 goto yyerrorlab;
2365
2366 /* Do not reclaim the symbols of the rule whose action triggered
2367 this YYERROR. */
2368 YYPOPSTACK (yylen);
2369 yylen = 0;
2370 YY_STACK_PRINT (yyss, yyssp);
2371 yystate = *yyssp;
2372 goto yyerrlab1;
2373
2374
2375 /*-------------------------------------------------------------.
2376 | yyerrlab1 -- common code for both syntax error and YYERROR. |
2377 `-------------------------------------------------------------*/
2378 yyerrlab1:
2379 yyerrstatus = 3; /* Each real token shifted decrements this. */
2380
2381 for (;;)
2382 {
2383 yyn = yypact[yystate];
2384 if (!yypact_value_is_default (yyn))
2385 {
2386 yyn += YYTERROR;
2387 if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
2388 {
2389 yyn = yytable[yyn];
2390 if (0 < yyn)
2391 break;
2392 }
2393 }
2394
2395 /* Pop the current state because it cannot handle the error token. */
2396 if (yyssp == yyss)
2397 YYABORT;
2398
2399
2400 yydestruct ("Error: popping",
2401 yystos[yystate], yyvsp, info);
2402 YYPOPSTACK (1);
2403 yystate = *yyssp;
2404 YY_STACK_PRINT (yyss, yyssp);
2405 }
2406
2407 YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
2408 *++yyvsp = yylval;
2409 YY_IGNORE_MAYBE_UNINITIALIZED_END
2410
2411
2412 /* Shift the error token. */
2413 YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
2414
2415 yystate = yyn;
2416 goto yynewstate;
2417
2418
2419 /*-------------------------------------.
2420 | yyacceptlab -- YYACCEPT comes here. |
2421 `-------------------------------------*/
2422 yyacceptlab:
2423 yyresult = 0;
2424 goto yyreturn;
2425
2426 /*-----------------------------------.
2427 | yyabortlab -- YYABORT comes here. |
2428 `-----------------------------------*/
2429 yyabortlab:
2430 yyresult = 1;
2431 goto yyreturn;
2432
2433 #if !defined yyoverflow || YYERROR_VERBOSE
2434 /*-------------------------------------------------.
2435 | yyexhaustedlab -- memory exhaustion comes here. |
2436 `-------------------------------------------------*/
2437 yyexhaustedlab:
2438 yyerror (info, YY_("memory exhausted"));
2439 yyresult = 2;
2440 /* Fall through. */
2441 #endif
2442
2443 yyreturn:
2444 if (yychar != YYEMPTY)
2445 {
2446 /* Make sure we have latest lookahead translation. See comments at
2447 user semantic actions for why this is necessary. */
2448 yytoken = YYTRANSLATE (yychar);
2449 yydestruct ("Cleanup: discarding lookahead",
2450 yytoken, &yylval, info);
2451 }
2452 /* Do not reclaim the symbols of the rule whose action triggered
2453 this YYABORT or YYACCEPT. */
2454 YYPOPSTACK (yylen);
2455 YY_STACK_PRINT (yyss, yyssp);
2456 while (yyssp != yyss)
2457 {
2458 yydestruct ("Cleanup: popping",
2459 yystos[*yyssp], yyvsp, info);
2460 YYPOPSTACK (1);
2461 }
2462 #ifndef yyoverflow
2463 if (yyss != yyssa)
2464 YYSTACK_FREE (yyss);
2465 #endif
2466 #if YYERROR_VERBOSE
2467 if (yymsg != yymsgbuf)
2468 YYSTACK_FREE (yymsg);
2469 #endif
2470 return yyresult;
2471 }
2472 #line 738 "sql.y" /* yacc.c:1906 */
2473
2474
2475 static LPWSTR parser_add_table( void *info, LPCWSTR list, LPCWSTR table )
2476 {
2477 static const WCHAR space[] = {' ',0};
2478 DWORD len = strlenW( list ) + strlenW( table ) + 2;
2479 LPWSTR ret;
2480
2481 ret = parser_alloc( info, len * sizeof(WCHAR) );
2482 if( ret )
2483 {
2484 strcpyW( ret, list );
2485 strcatW( ret, space );
2486 strcatW( ret, table );
2487 }
2488 return ret;
2489 }
2490
2491 static void *parser_alloc( void *info, unsigned int sz )
2492 {
2493 SQL_input* sql = (SQL_input*) info;
2494 struct list *mem;
2495
2496 mem = msi_alloc( sizeof (struct list) + sz );
2497 list_add_tail( sql->mem, mem );
2498 return &mem[1];
2499 }
2500
2501 static column_info *parser_alloc_column( void *info, LPCWSTR table, LPCWSTR column )
2502 {
2503 column_info *col;
2504
2505 col = parser_alloc( info, sizeof (*col) );
2506 if( col )
2507 {
2508 col->table = table;
2509 col->column = column;
2510 col->val = NULL;
2511 col->type = 0;
2512 col->next = NULL;
2513 }
2514
2515 return col;
2516 }
2517
2518 static int sql_lex( void *SQL_lval, SQL_input *sql )
2519 {
2520 int token, skip;
2521 struct sql_str * str = SQL_lval;
2522
2523 do
2524 {
2525 sql->n += sql->len;
2526 if( ! sql->command[sql->n] )
2527 return 0; /* end of input */
2528
2529 /* TRACE("string : %s\n", debugstr_w(&sql->command[sql->n])); */
2530 sql->len = sqliteGetToken( &sql->command[sql->n], &token, &skip );
2531 if( sql->len==0 )
2532 break;
2533 str->data = &sql->command[sql->n];
2534 str->len = sql->len;
2535 sql->n += skip;
2536 }
2537 while( token == TK_SPACE );
2538
2539 /* TRACE("token : %d (%s)\n", token, debugstr_wn(&sql->command[sql->n], sql->len)); */
2540
2541 return token;
2542 }
2543
2544 UINT SQL_getstring( void *info, const struct sql_str *strdata, LPWSTR *str )
2545 {
2546 LPCWSTR p = strdata->data;
2547 UINT len = strdata->len;
2548
2549 /* match quotes */
2550 if( ( (p[0]=='`') && (p[len-1]!='`') ) ||
2551 ( (p[0]=='\'') && (p[len-1]!='\'') ) )
2552 return ERROR_FUNCTION_FAILED;
2553
2554 /* if there are quotes, remove them */
2555 if( ( (p[0]=='`') && (p[len-1]=='`') ) ||
2556 ( (p[0]=='\'') && (p[len-1]=='\'') ) )
2557 {
2558 p++;
2559 len -= 2;
2560 }
2561 *str = parser_alloc( info, (len + 1)*sizeof(WCHAR) );
2562 if( !*str )
2563 return ERROR_OUTOFMEMORY;
2564 memcpy( *str, p, len*sizeof(WCHAR) );
2565 (*str)[len]=0;
2566
2567 return ERROR_SUCCESS;
2568 }
2569
2570 INT SQL_getint( void *info )
2571 {
2572 SQL_input* sql = (SQL_input*) info;
2573 LPCWSTR p = &sql->command[sql->n];
2574 INT i, r = 0;
2575
2576 for( i=0; i<sql->len; i++ )
2577 {
2578 if( '0' > p[i] || '9' < p[i] )
2579 {
2580 ERR("should only be numbers here!\n");
2581 break;
2582 }
2583 r = (p[i]-'0') + r*10;
2584 }
2585
2586 return r;
2587 }
2588
2589 static int sql_error( SQL_input *info, const char *str )
2590 {
2591 return 0;
2592 }
2593
2594 static struct expr * EXPR_wildcard( void *info )
2595 {
2596 struct expr *e = parser_alloc( info, sizeof *e );
2597 if( e )
2598 {
2599 e->type = EXPR_WILDCARD;
2600 }
2601 return e;
2602 }
2603
2604 static struct expr * EXPR_complex( void *info, struct expr *l, UINT op, struct expr *r )
2605 {
2606 struct expr *e = parser_alloc( info, sizeof *e );
2607 if( e )
2608 {
2609 e->type = EXPR_COMPLEX;
2610 e->u.expr.left = l;
2611 e->u.expr.op = op;
2612 e->u.expr.right = r;
2613 }
2614 return e;
2615 }
2616
2617 static struct expr * EXPR_unary( void *info, struct expr *l, UINT op )
2618 {
2619 struct expr *e = parser_alloc( info, sizeof *e );
2620 if( e )
2621 {
2622 e->type = EXPR_UNARY;
2623 e->u.expr.left = l;
2624 e->u.expr.op = op;
2625 e->u.expr.right = NULL;
2626 }
2627 return e;
2628 }
2629
2630 static struct expr * EXPR_column( void *info, const column_info *column )
2631 {
2632 struct expr *e = parser_alloc( info, sizeof *e );
2633 if( e )
2634 {
2635 e->type = EXPR_COLUMN;
2636 e->u.column.unparsed.column = column->column;
2637 e->u.column.unparsed.table = column->table;
2638 }
2639 return e;
2640 }
2641
2642 static struct expr * EXPR_ival( void *info, int val )
2643 {
2644 struct expr *e = parser_alloc( info, sizeof *e );
2645 if( e )
2646 {
2647 e->type = EXPR_IVAL;
2648 e->u.ival = val;
2649 }
2650 return e;
2651 }
2652
2653 static struct expr * EXPR_sval( void *info, const struct sql_str *str )
2654 {
2655 struct expr *e = parser_alloc( info, sizeof *e );
2656 if( e )
2657 {
2658 e->type = EXPR_SVAL;
2659 if( SQL_getstring( info, str, (LPWSTR *)&e->u.sval ) != ERROR_SUCCESS )
2660 return NULL; /* e will be freed by query destructor */
2661 }
2662 return e;
2663 }
2664
2665 static void swap_columns( column_info **cols, column_info *A, int idx )
2666 {
2667 column_info *preA = NULL, *preB = NULL, *B, *ptr;
2668 int i = 0;
2669
2670 B = NULL;
2671 ptr = *cols;
2672 while( ptr )
2673 {
2674 if( i++ == idx )
2675 B = ptr;
2676 else if( !B )
2677 preB = ptr;
2678
2679 if( ptr->next == A )
2680 preA = ptr;
2681
2682 ptr = ptr->next;
2683 }
2684
2685 if( preB ) preB->next = A;
2686 if( preA ) preA->next = B;
2687 ptr = A->next;
2688 A->next = B->next;
2689 B->next = ptr;
2690 if( idx == 0 )
2691 *cols = A;
2692 }
2693
2694 static BOOL SQL_MarkPrimaryKeys( column_info **cols,
2695 column_info *keys )
2696 {
2697 column_info *k;
2698 BOOL found = TRUE;
2699 int count;
2700
2701 for( k = keys, count = 0; k && found; k = k->next, count++ )
2702 {
2703 column_info *c;
2704 int idx;
2705
2706 found = FALSE;
2707 for( c = *cols, idx = 0; c && !found; c = c->next, idx++ )
2708 {
2709 if( strcmpW( k->column, c->column ) )
2710 continue;
2711 c->type |= MSITYPE_KEY;
2712 found = TRUE;
2713 if (idx != count)
2714 swap_columns( cols, c, count );
2715 }
2716 }
2717
2718 return found;
2719 }
2720
2721 UINT MSI_ParseSQL( MSIDATABASE *db, LPCWSTR command, MSIVIEW **phview,
2722 struct list *mem )
2723 {
2724 SQL_input sql;
2725 int r;
2726
2727 *phview = NULL;
2728
2729 sql.db = db;
2730 sql.command = command;
2731 sql.n = 0;
2732 sql.len = 0;
2733 sql.r = ERROR_BAD_QUERY_SYNTAX;
2734 sql.view = phview;
2735 sql.mem = mem;
2736
2737 r = sql_parse(&sql);
2738
2739 TRACE("Parse returned %d\n", r);
2740 if( r )
2741 {
2742 if (*sql.view)
2743 {
2744 (*sql.view)->ops->delete(*sql.view);
2745 *sql.view = NULL;
2746 }
2747 return sql.r;
2748 }
2749
2750 return ERROR_SUCCESS;
2751 }