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