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