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