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