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