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