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