Line data Source code
1 : /* A Bison parser, made by GNU Bison 3.7.5. */
2 :
3 : /* Bison implementation for Yacc-like parsers in C
4 :
5 : Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2021 Free Software Foundation,
6 : Inc.
7 :
8 : This program is free software: you can redistribute it and/or modify
9 : it under the terms of the GNU General Public License as published by
10 : the Free Software Foundation, either version 3 of the License, or
11 : (at your option) any later version.
12 :
13 : This program is distributed in the hope that it will be useful,
14 : but WITHOUT ANY WARRANTY; without even the implied warranty of
15 : MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 : GNU General Public License for more details.
17 :
18 : You should have received a copy of the GNU General Public License
19 : along with this program. If not, see <http://www.gnu.org/licenses/>. */
20 :
21 : /* As a special exception, you may create a larger work that contains
22 : part or all of the Bison parser skeleton and distribute that work
23 : under terms of your choice, so long as that work isn't itself a
24 : parser generator using the skeleton or a modified version thereof
25 : as a parser skeleton. Alternatively, if you modify or redistribute
26 : the parser skeleton itself, you may (at your option) remove this
27 : special exception, which will cause the skeleton and the resulting
28 : Bison output files to be licensed under the GNU General Public
29 : License without this special exception.
30 :
31 : This special exception was added by the Free Software Foundation in
32 : version 2.2 of Bison. */
33 :
34 : /* C LALR(1) parser skeleton written by Richard Stallman, by
35 : simplifying the original so-called "semantic" parser. */
36 :
37 : /* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
38 : especially those whose name start with YY_ or yy_. They are
39 : private implementation details that can be changed or removed. */
40 :
41 : /* All symbols defined below should begin with yy or YY, to avoid
42 : infringing on user name space. This should be done even for local
43 : variables, as they might otherwise be expanded by user macros.
44 : There are some unavoidable exceptions within include files to
45 : define necessary library symbols; they are noted "INFRINGES ON
46 : USER NAME SPACE" below. */
47 :
48 : /* Identify Bison output, and Bison version. */
49 : #define YYBISON 30705
50 :
51 : /* Bison version string. */
52 : #define YYBISON_VERSION "3.7.5"
53 :
54 : /* Skeleton name. */
55 : #define YYSKELETON_NAME "yacc.c"
56 :
57 : /* Pure parsers. */
58 : #define YYPURE 1
59 :
60 : /* Push parsers. */
61 : #define YYPUSH 0
62 :
63 : /* Pull parsers. */
64 : #define YYPULL 1
65 :
66 :
67 : /* Substitute the variable and function names. */
68 : #define yyparse expr_yyparse
69 : #define yylex expr_yylex
70 : #define yyerror expr_yyerror
71 : #define yydebug expr_yydebug
72 : #define yynerrs expr_yynerrs
73 :
74 : /* First part of user prologue. */
75 : #line 1 "exprparse.y"
76 :
77 : /*-------------------------------------------------------------------------
78 : *
79 : * exprparse.y
80 : * bison grammar for a simple expression syntax
81 : *
82 : * Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
83 : * Portions Copyright (c) 1994, Regents of the University of California
84 : *
85 : * src/bin/pgbench/exprparse.y
86 : *
87 : *-------------------------------------------------------------------------
88 : */
89 :
90 : #include "postgres_fe.h"
91 :
92 : #include "pgbench.h"
93 :
94 : #define PGBENCH_NARGS_VARIABLE (-1)
95 : #define PGBENCH_NARGS_CASE (-2)
96 : #define PGBENCH_NARGS_HASH (-3)
97 : #define PGBENCH_NARGS_PERMUTE (-4)
98 :
99 : static PgBenchExprList *make_elist(PgBenchExpr *expr, PgBenchExprList *list);
100 : static PgBenchExpr *make_null_constant(void);
101 : static PgBenchExpr *make_boolean_constant(bool bval);
102 : static PgBenchExpr *make_integer_constant(int64 ival);
103 : static PgBenchExpr *make_double_constant(double dval);
104 : static PgBenchExpr *make_variable(char *varname);
105 : static PgBenchExpr *make_op(yyscan_t yyscanner, const char *operator,
106 : PgBenchExpr *lexpr, PgBenchExpr *rexpr);
107 : static PgBenchExpr *make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr);
108 : static int find_func(yyscan_t yyscanner, const char *fname);
109 : static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args);
110 : static PgBenchExpr *make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part);
111 :
112 :
113 : #line 114 "exprparse.c"
114 :
115 : # ifndef YY_CAST
116 : # ifdef __cplusplus
117 : # define YY_CAST(Type, Val) static_cast<Type> (Val)
118 : # define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
119 : # else
120 : # define YY_CAST(Type, Val) ((Type) (Val))
121 : # define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
122 : # endif
123 : # endif
124 : # ifndef YY_NULLPTR
125 : # if defined __cplusplus
126 : # if 201103L <= __cplusplus
127 : # define YY_NULLPTR nullptr
128 : # else
129 : # define YY_NULLPTR 0
130 : # endif
131 : # else
132 : # define YY_NULLPTR ((void*)0)
133 : # endif
134 : # endif
135 :
136 : #include "exprparse.h"
137 : /* Symbol kind. */
138 : enum yysymbol_kind_t
139 : {
140 : YYSYMBOL_YYEMPTY = -2,
141 : YYSYMBOL_YYEOF = 0, /* "end of file" */
142 : YYSYMBOL_YYerror = 1, /* error */
143 : YYSYMBOL_YYUNDEF = 2, /* "invalid token" */
144 : YYSYMBOL_NULL_CONST = 3, /* NULL_CONST */
145 : YYSYMBOL_INTEGER_CONST = 4, /* INTEGER_CONST */
146 : YYSYMBOL_MAXINT_PLUS_ONE_CONST = 5, /* MAXINT_PLUS_ONE_CONST */
147 : YYSYMBOL_DOUBLE_CONST = 6, /* DOUBLE_CONST */
148 : YYSYMBOL_BOOLEAN_CONST = 7, /* BOOLEAN_CONST */
149 : YYSYMBOL_VARIABLE = 8, /* VARIABLE */
150 : YYSYMBOL_FUNCTION = 9, /* FUNCTION */
151 : YYSYMBOL_AND_OP = 10, /* AND_OP */
152 : YYSYMBOL_OR_OP = 11, /* OR_OP */
153 : YYSYMBOL_NOT_OP = 12, /* NOT_OP */
154 : YYSYMBOL_NE_OP = 13, /* NE_OP */
155 : YYSYMBOL_LE_OP = 14, /* LE_OP */
156 : YYSYMBOL_GE_OP = 15, /* GE_OP */
157 : YYSYMBOL_LS_OP = 16, /* LS_OP */
158 : YYSYMBOL_RS_OP = 17, /* RS_OP */
159 : YYSYMBOL_IS_OP = 18, /* IS_OP */
160 : YYSYMBOL_CASE_KW = 19, /* CASE_KW */
161 : YYSYMBOL_WHEN_KW = 20, /* WHEN_KW */
162 : YYSYMBOL_THEN_KW = 21, /* THEN_KW */
163 : YYSYMBOL_ELSE_KW = 22, /* ELSE_KW */
164 : YYSYMBOL_END_KW = 23, /* END_KW */
165 : YYSYMBOL_ISNULL_OP = 24, /* ISNULL_OP */
166 : YYSYMBOL_NOTNULL_OP = 25, /* NOTNULL_OP */
167 : YYSYMBOL_26_ = 26, /* '<' */
168 : YYSYMBOL_27_ = 27, /* '>' */
169 : YYSYMBOL_28_ = 28, /* '=' */
170 : YYSYMBOL_29_ = 29, /* '|' */
171 : YYSYMBOL_30_ = 30, /* '#' */
172 : YYSYMBOL_31_ = 31, /* '&' */
173 : YYSYMBOL_32_ = 32, /* '~' */
174 : YYSYMBOL_33_ = 33, /* '+' */
175 : YYSYMBOL_34_ = 34, /* '-' */
176 : YYSYMBOL_35_ = 35, /* '*' */
177 : YYSYMBOL_36_ = 36, /* '/' */
178 : YYSYMBOL_37_ = 37, /* '%' */
179 : YYSYMBOL_UNARY = 38, /* UNARY */
180 : YYSYMBOL_39_ = 39, /* ',' */
181 : YYSYMBOL_40_ = 40, /* '(' */
182 : YYSYMBOL_41_ = 41, /* ')' */
183 : YYSYMBOL_YYACCEPT = 42, /* $accept */
184 : YYSYMBOL_result = 43, /* result */
185 : YYSYMBOL_elist = 44, /* elist */
186 : YYSYMBOL_expr = 45, /* expr */
187 : YYSYMBOL_when_then_list = 46, /* when_then_list */
188 : YYSYMBOL_case_control = 47, /* case_control */
189 : YYSYMBOL_function = 48 /* function */
190 : };
191 : typedef enum yysymbol_kind_t yysymbol_kind_t;
192 :
193 :
194 :
195 :
196 : #ifdef short
197 : # undef short
198 : #endif
199 :
200 : /* On compilers that do not define __PTRDIFF_MAX__ etc., make sure
201 : <limits.h> and (if available) <stdint.h> are included
202 : so that the code can choose integer types of a good width. */
203 :
204 : #ifndef __PTRDIFF_MAX__
205 : # include <limits.h> /* INFRINGES ON USER NAME SPACE */
206 : # if defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
207 : # include <stdint.h> /* INFRINGES ON USER NAME SPACE */
208 : # define YY_STDINT_H
209 : # endif
210 : #endif
211 :
212 : /* Narrow types that promote to a signed type and that can represent a
213 : signed or unsigned integer of at least N bits. In tables they can
214 : save space and decrease cache pressure. Promoting to a signed type
215 : helps avoid bugs in integer arithmetic. */
216 :
217 : #ifdef __INT_LEAST8_MAX__
218 : typedef __INT_LEAST8_TYPE__ yytype_int8;
219 : #elif defined YY_STDINT_H
220 : typedef int_least8_t yytype_int8;
221 : #else
222 : typedef signed char yytype_int8;
223 : #endif
224 :
225 : #ifdef __INT_LEAST16_MAX__
226 : typedef __INT_LEAST16_TYPE__ yytype_int16;
227 : #elif defined YY_STDINT_H
228 : typedef int_least16_t yytype_int16;
229 : #else
230 : typedef short yytype_int16;
231 : #endif
232 :
233 : /* Work around bug in HP-UX 11.23, which defines these macros
234 : incorrectly for preprocessor constants. This workaround can likely
235 : be removed in 2023, as HPE has promised support for HP-UX 11.23
236 : (aka HP-UX 11i v2) only through the end of 2022; see Table 2 of
237 : <https://h20195.www2.hpe.com/V2/getpdf.aspx/4AA4-7673ENW.pdf>. */
238 : #ifdef __hpux
239 : # undef UINT_LEAST8_MAX
240 : # undef UINT_LEAST16_MAX
241 : # define UINT_LEAST8_MAX 255
242 : # define UINT_LEAST16_MAX 65535
243 : #endif
244 :
245 : #if defined __UINT_LEAST8_MAX__ && __UINT_LEAST8_MAX__ <= __INT_MAX__
246 : typedef __UINT_LEAST8_TYPE__ yytype_uint8;
247 : #elif (!defined __UINT_LEAST8_MAX__ && defined YY_STDINT_H \
248 : && UINT_LEAST8_MAX <= INT_MAX)
249 : typedef uint_least8_t yytype_uint8;
250 : #elif !defined __UINT_LEAST8_MAX__ && UCHAR_MAX <= INT_MAX
251 : typedef unsigned char yytype_uint8;
252 : #else
253 : typedef short yytype_uint8;
254 : #endif
255 :
256 : #if defined __UINT_LEAST16_MAX__ && __UINT_LEAST16_MAX__ <= __INT_MAX__
257 : typedef __UINT_LEAST16_TYPE__ yytype_uint16;
258 : #elif (!defined __UINT_LEAST16_MAX__ && defined YY_STDINT_H \
259 : && UINT_LEAST16_MAX <= INT_MAX)
260 : typedef uint_least16_t yytype_uint16;
261 : #elif !defined __UINT_LEAST16_MAX__ && USHRT_MAX <= INT_MAX
262 : typedef unsigned short yytype_uint16;
263 : #else
264 : typedef int yytype_uint16;
265 : #endif
266 :
267 : #ifndef YYPTRDIFF_T
268 : # if defined __PTRDIFF_TYPE__ && defined __PTRDIFF_MAX__
269 : # define YYPTRDIFF_T __PTRDIFF_TYPE__
270 : # define YYPTRDIFF_MAXIMUM __PTRDIFF_MAX__
271 : # elif defined PTRDIFF_MAX
272 : # ifndef ptrdiff_t
273 : # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
274 : # endif
275 : # define YYPTRDIFF_T ptrdiff_t
276 : # define YYPTRDIFF_MAXIMUM PTRDIFF_MAX
277 : # else
278 : # define YYPTRDIFF_T long
279 : # define YYPTRDIFF_MAXIMUM LONG_MAX
280 : # endif
281 : #endif
282 :
283 : #ifndef YYSIZE_T
284 : # ifdef __SIZE_TYPE__
285 : # define YYSIZE_T __SIZE_TYPE__
286 : # elif defined size_t
287 : # define YYSIZE_T size_t
288 : # elif defined __STDC_VERSION__ && 199901 <= __STDC_VERSION__
289 : # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
290 : # define YYSIZE_T size_t
291 : # else
292 : # define YYSIZE_T unsigned
293 : # endif
294 : #endif
295 :
296 : #define YYSIZE_MAXIMUM \
297 : YY_CAST (YYPTRDIFF_T, \
298 : (YYPTRDIFF_MAXIMUM < YY_CAST (YYSIZE_T, -1) \
299 : ? YYPTRDIFF_MAXIMUM \
300 : : YY_CAST (YYSIZE_T, -1)))
301 :
302 : #define YYSIZEOF(X) YY_CAST (YYPTRDIFF_T, sizeof (X))
303 :
304 :
305 : /* Stored state numbers (used for stacks). */
306 : typedef yytype_int8 yy_state_t;
307 :
308 : /* State numbers in computations. */
309 : typedef int yy_state_fast_t;
310 :
311 : #ifndef YY_
312 : # if defined YYENABLE_NLS && YYENABLE_NLS
313 : # if ENABLE_NLS
314 : # include <libintl.h> /* INFRINGES ON USER NAME SPACE */
315 : # define YY_(Msgid) dgettext ("bison-runtime", Msgid)
316 : # endif
317 : # endif
318 : # ifndef YY_
319 : # define YY_(Msgid) Msgid
320 : # endif
321 : #endif
322 :
323 :
324 : #ifndef YY_ATTRIBUTE_PURE
325 : # if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
326 : # define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
327 : # else
328 : # define YY_ATTRIBUTE_PURE
329 : # endif
330 : #endif
331 :
332 : #ifndef YY_ATTRIBUTE_UNUSED
333 : # if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
334 : # define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
335 : # else
336 : # define YY_ATTRIBUTE_UNUSED
337 : # endif
338 : #endif
339 :
340 : /* Suppress unused-variable warnings by "using" E. */
341 : #if ! defined lint || defined __GNUC__
342 : # define YY_USE(E) ((void) (E))
343 : #else
344 : # define YY_USE(E) /* empty */
345 : #endif
346 :
347 : #if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
348 : /* Suppress an incorrect diagnostic about yylval being uninitialized. */
349 : # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
350 : _Pragma ("GCC diagnostic push") \
351 : _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
352 : _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
353 : # define YY_IGNORE_MAYBE_UNINITIALIZED_END \
354 : _Pragma ("GCC diagnostic pop")
355 : #else
356 : # define YY_INITIAL_VALUE(Value) Value
357 : #endif
358 : #ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
359 : # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
360 : # define YY_IGNORE_MAYBE_UNINITIALIZED_END
361 : #endif
362 : #ifndef YY_INITIAL_VALUE
363 : # define YY_INITIAL_VALUE(Value) /* Nothing. */
364 : #endif
365 :
366 : #if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
367 : # define YY_IGNORE_USELESS_CAST_BEGIN \
368 : _Pragma ("GCC diagnostic push") \
369 : _Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
370 : # define YY_IGNORE_USELESS_CAST_END \
371 : _Pragma ("GCC diagnostic pop")
372 : #endif
373 : #ifndef YY_IGNORE_USELESS_CAST_BEGIN
374 : # define YY_IGNORE_USELESS_CAST_BEGIN
375 : # define YY_IGNORE_USELESS_CAST_END
376 : #endif
377 :
378 :
379 : #define YY_ASSERT(E) ((void) (0 && (E)))
380 :
381 : #if !defined yyoverflow
382 :
383 : /* The parser invokes alloca or malloc; define the necessary symbols. */
384 :
385 : # ifdef YYSTACK_USE_ALLOCA
386 : # if YYSTACK_USE_ALLOCA
387 : # ifdef __GNUC__
388 : # define YYSTACK_ALLOC __builtin_alloca
389 : # elif defined __BUILTIN_VA_ARG_INCR
390 : # include <alloca.h> /* INFRINGES ON USER NAME SPACE */
391 : # elif defined _AIX
392 : # define YYSTACK_ALLOC __alloca
393 : # elif defined _MSC_VER
394 : # include <malloc.h> /* INFRINGES ON USER NAME SPACE */
395 : # define alloca _alloca
396 : # else
397 : # define YYSTACK_ALLOC alloca
398 : # if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
399 : # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
400 : /* Use EXIT_SUCCESS as a witness for stdlib.h. */
401 : # ifndef EXIT_SUCCESS
402 : # define EXIT_SUCCESS 0
403 : # endif
404 : # endif
405 : # endif
406 : # endif
407 : # endif
408 :
409 : # ifdef YYSTACK_ALLOC
410 : /* Pacify GCC's 'empty if-body' warning. */
411 : # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
412 : # ifndef YYSTACK_ALLOC_MAXIMUM
413 : /* The OS might guarantee only one guard page at the bottom of the stack,
414 : and a page size can be as small as 4096 bytes. So we cannot safely
415 : invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
416 : to allow for a few compiler-allocated temporary stack slots. */
417 : # define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
418 : # endif
419 : # else
420 : # define YYSTACK_ALLOC YYMALLOC
421 : # define YYSTACK_FREE YYFREE
422 : # ifndef YYSTACK_ALLOC_MAXIMUM
423 : # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
424 : # endif
425 : # if (defined __cplusplus && ! defined EXIT_SUCCESS \
426 : && ! ((defined YYMALLOC || defined malloc) \
427 : && (defined YYFREE || defined free)))
428 : # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
429 : # ifndef EXIT_SUCCESS
430 : # define EXIT_SUCCESS 0
431 : # endif
432 : # endif
433 : # ifndef YYMALLOC
434 : # define YYMALLOC malloc
435 : # if ! defined malloc && ! defined EXIT_SUCCESS
436 : void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
437 : # endif
438 : # endif
439 : # ifndef YYFREE
440 : # define YYFREE free
441 : # if ! defined free && ! defined EXIT_SUCCESS
442 : void free (void *); /* INFRINGES ON USER NAME SPACE */
443 : # endif
444 : # endif
445 : # endif
446 : #endif /* !defined yyoverflow */
447 :
448 : #if (! defined yyoverflow \
449 : && (! defined __cplusplus \
450 : || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
451 :
452 : /* A type that is properly aligned for any stack member. */
453 : union yyalloc
454 : {
455 : yy_state_t yyss_alloc;
456 : YYSTYPE yyvs_alloc;
457 : };
458 :
459 : /* The size of the maximum gap between one aligned stack and the next. */
460 : # define YYSTACK_GAP_MAXIMUM (YYSIZEOF (union yyalloc) - 1)
461 :
462 : /* The size of an array large to enough to hold all stacks, each with
463 : N elements. */
464 : # define YYSTACK_BYTES(N) \
465 : ((N) * (YYSIZEOF (yy_state_t) + YYSIZEOF (YYSTYPE)) \
466 : + YYSTACK_GAP_MAXIMUM)
467 :
468 : # define YYCOPY_NEEDED 1
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 : YYPTRDIFF_T yynewbytes; \
479 : YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
480 : Stack = &yyptr->Stack_alloc; \
481 : yynewbytes = yystacksize * YYSIZEOF (*Stack) + YYSTACK_GAP_MAXIMUM; \
482 : yyptr += yynewbytes / YYSIZEOF (*yyptr); \
483 : } \
484 : while (0)
485 :
486 : #endif
487 :
488 : #if defined YYCOPY_NEEDED && YYCOPY_NEEDED
489 : /* Copy COUNT objects from SRC to DST. The source and destination do
490 : not overlap. */
491 : # ifndef YYCOPY
492 : # if defined __GNUC__ && 1 < __GNUC__
493 : # define YYCOPY(Dst, Src, Count) \
494 : __builtin_memcpy (Dst, Src, YY_CAST (YYSIZE_T, (Count)) * sizeof (*(Src)))
495 : # else
496 : # define YYCOPY(Dst, Src, Count) \
497 : do \
498 : { \
499 : YYPTRDIFF_T yyi; \
500 : for (yyi = 0; yyi < (Count); yyi++) \
501 : (Dst)[yyi] = (Src)[yyi]; \
502 : } \
503 : while (0)
504 : # endif
505 : # endif
506 : #endif /* !YYCOPY_NEEDED */
507 :
508 : /* YYFINAL -- State number of the termination state. */
509 : #define YYFINAL 25
510 : /* YYLAST -- Last index in YYTABLE. */
511 : #define YYLAST 320
512 :
513 : /* YYNTOKENS -- Number of terminals. */
514 : #define YYNTOKENS 42
515 : /* YYNNTS -- Number of nonterminals. */
516 : #define YYNNTS 7
517 : /* YYNRULES -- Number of rules. */
518 : #define YYNRULES 47
519 : /* YYNSTATES -- Number of states. */
520 : #define YYNSTATES 88
521 :
522 : /* YYMAXUTOK -- Last valid token kind. */
523 : #define YYMAXUTOK 281
524 :
525 :
526 : /* YYTRANSLATE(TOKEN-NUM) -- Symbol number corresponding to TOKEN-NUM
527 : as returned by yylex, with out-of-bounds checking. */
528 : #define YYTRANSLATE(YYX) \
529 : (0 <= (YYX) && (YYX) <= YYMAXUTOK \
530 : ? YY_CAST (yysymbol_kind_t, yytranslate[YYX]) \
531 : : YYSYMBOL_YYUNDEF)
532 :
533 : /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
534 : as returned by yylex. */
535 : static const yytype_int8 yytranslate[] =
536 : {
537 : 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
538 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
539 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
540 : 2, 2, 2, 2, 2, 30, 2, 37, 31, 2,
541 : 40, 41, 35, 33, 39, 34, 2, 36, 2, 2,
542 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
543 : 26, 28, 27, 2, 2, 2, 2, 2, 2, 2,
544 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
545 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
546 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
547 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
548 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
549 : 2, 2, 2, 2, 29, 2, 32, 2, 2, 2,
550 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
551 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
552 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
553 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
554 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
555 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
556 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
557 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
558 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
559 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
560 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
561 : 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
562 : 2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
563 : 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
564 : 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
565 : 25, 38
566 : };
567 :
568 : #if YYDEBUG
569 : /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */
570 : static const yytype_uint8 yyrline[] =
571 : {
572 : 0, 82, 82, 87, 88, 89, 92, 93, 95, 98,
573 : 101, 103, 104, 105, 106, 107, 108, 109, 110, 111,
574 : 112, 113, 114, 115, 116, 117, 118, 119, 120, 121,
575 : 123, 124, 128, 129, 134, 138, 144, 145, 146, 147,
576 : 149, 150, 151, 155, 156, 159, 160, 162
577 : };
578 : #endif
579 :
580 : /** Accessing symbol of state STATE. */
581 : #define YY_ACCESSING_SYMBOL(State) YY_CAST (yysymbol_kind_t, yystos[State])
582 :
583 : #if YYDEBUG || 0
584 : /* The user-facing name of the symbol whose (internal) number is
585 : YYSYMBOL. No bounds checking. */
586 : static const char *yysymbol_name (yysymbol_kind_t yysymbol) YY_ATTRIBUTE_UNUSED;
587 :
588 : /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
589 : First, the terminals, then, starting at YYNTOKENS, nonterminals. */
590 : static const char *const yytname[] =
591 : {
592 : "\"end of file\"", "error", "\"invalid token\"", "NULL_CONST",
593 : "INTEGER_CONST", "MAXINT_PLUS_ONE_CONST", "DOUBLE_CONST",
594 : "BOOLEAN_CONST", "VARIABLE", "FUNCTION", "AND_OP", "OR_OP", "NOT_OP",
595 : "NE_OP", "LE_OP", "GE_OP", "LS_OP", "RS_OP", "IS_OP", "CASE_KW",
596 : "WHEN_KW", "THEN_KW", "ELSE_KW", "END_KW", "ISNULL_OP", "NOTNULL_OP",
597 : "'<'", "'>'", "'='", "'|'", "'#'", "'&'", "'~'", "'+'", "'-'", "'*'",
598 : "'/'", "'%'", "UNARY", "','", "'('", "')'", "$accept", "result", "elist",
599 : "expr", "when_then_list", "case_control", "function", YY_NULLPTR
600 : };
601 :
602 : static const char *
603 : yysymbol_name (yysymbol_kind_t yysymbol)
604 : {
605 : return yytname[yysymbol];
606 : }
607 : #endif
608 :
609 : #ifdef YYPRINT
610 : /* YYTOKNUM[NUM] -- (External) token number corresponding to the
611 : (internal) symbol number NUM (which must be that of a token). */
612 : static const yytype_int16 yytoknum[] =
613 : {
614 : 0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
615 : 265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
616 : 275, 276, 277, 278, 279, 280, 60, 62, 61, 124,
617 : 35, 38, 126, 43, 45, 42, 47, 37, 281, 44,
618 : 40, 41
619 : };
620 : #endif
621 :
622 : #define YYPACT_NINF (-33)
623 :
624 : #define yypact_value_is_default(Yyn) \
625 : ((Yyn) == YYPACT_NINF)
626 :
627 : #define YYTABLE_NINF (-1)
628 :
629 : #define yytable_value_is_error(Yyn) \
630 : ((Yyn) == YYTABLE_NINF)
631 :
632 : /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
633 : STATE-NUM. */
634 : static const yytype_int16 yypact[] =
635 : {
636 : 64, -33, -33, -33, -33, -33, -33, 64, -19, 64,
637 : 64, 46, 64, 13, 205, -33, -22, 258, 64, -6,
638 : 11, -33, -33, -33, 92, -33, 64, 64, 64, 64,
639 : 64, 64, 64, 3, -33, -33, 64, 64, 64, 64,
640 : 64, 64, 64, 64, 64, 64, 64, 64, 121, 64,
641 : 64, -33, -33, 258, 233, 283, 283, 283, 11, 11,
642 : -33, -33, 5, 283, 283, 283, 11, 11, 11, -9,
643 : -9, -33, -33, -33, -32, 205, 64, 149, 177, -33,
644 : -33, 64, -33, 205, 64, -33, 205, 205
645 : };
646 :
647 : /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
648 : Performed when YYTABLE does not specify something else to do. Zero
649 : means the default is an error. */
650 : static const yytype_int8 yydefact[] =
651 : {
652 : 0, 36, 38, 39, 37, 40, 47, 0, 0, 0,
653 : 0, 0, 0, 0, 2, 42, 0, 11, 0, 0,
654 : 10, 7, 9, 8, 0, 1, 0, 0, 0, 0,
655 : 0, 0, 0, 0, 30, 31, 0, 0, 0, 0,
656 : 0, 0, 0, 0, 0, 0, 0, 3, 0, 0,
657 : 0, 45, 6, 28, 29, 22, 18, 20, 26, 27,
658 : 32, 34, 0, 17, 19, 21, 24, 25, 23, 12,
659 : 13, 14, 15, 16, 0, 4, 0, 0, 0, 33,
660 : 35, 0, 41, 44, 0, 46, 5, 43
661 : };
662 :
663 : /* YYPGOTO[NTERM-NUM]. */
664 : static const yytype_int8 yypgoto[] =
665 : {
666 : -33, -33, -33, -7, -33, -33, -33
667 : };
668 :
669 : /* YYDEFGOTO[NTERM-NUM]. */
670 : static const yytype_int8 yydefgoto[] =
671 : {
672 : 0, 13, 74, 14, 19, 15, 16
673 : };
674 :
675 : /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
676 : positive, shift that token. If negative, reduce the rule whose
677 : number is the opposite. If YYTABLE_NINF, syntax error. */
678 : static const yytype_int8 yytable[] =
679 : {
680 : 17, 18, 20, 21, 23, 24, 60, 81, 79, 82,
681 : 61, 48, 80, 25, 49, 62, 50, 51, 47, 53,
682 : 54, 55, 56, 57, 58, 59, 44, 45, 46, 63,
683 : 64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
684 : 75, 0, 77, 78, 42, 43, 44, 45, 46, 1,
685 : 2, 22, 3, 4, 5, 6, 0, 0, 7, 0,
686 : 0, 0, 0, 0, 0, 8, 0, 1, 2, 83,
687 : 3, 4, 5, 6, 86, 0, 7, 87, 9, 10,
688 : 11, 0, 0, 8, 0, 0, 12, 0, 0, 0,
689 : 0, 0, 0, 0, 0, 0, 9, 10, 11, 0,
690 : 0, 0, 26, 27, 12, 28, 29, 30, 31, 32,
691 : 33, 0, 0, 0, 0, 0, 34, 35, 36, 37,
692 : 38, 39, 40, 41, 0, 42, 43, 44, 45, 46,
693 : 0, 26, 27, 52, 28, 29, 30, 31, 32, 33,
694 : 0, 0, 76, 0, 0, 34, 35, 36, 37, 38,
695 : 39, 40, 41, 0, 42, 43, 44, 45, 46, 26,
696 : 27, 0, 28, 29, 30, 31, 32, 33, 0, 0,
697 : 84, 0, 0, 34, 35, 36, 37, 38, 39, 40,
698 : 41, 0, 42, 43, 44, 45, 46, 26, 27, 0,
699 : 28, 29, 30, 31, 32, 33, 0, 0, 0, 0,
700 : 85, 34, 35, 36, 37, 38, 39, 40, 41, 0,
701 : 42, 43, 44, 45, 46, 26, 27, 0, 28, 29,
702 : 30, 31, 32, 33, 0, 0, 0, 0, 0, 34,
703 : 35, 36, 37, 38, 39, 40, 41, 0, 42, 43,
704 : 44, 45, 46, 26, 0, 0, 28, 29, 30, 31,
705 : 32, 33, 0, 0, 0, 0, 0, 34, 35, 36,
706 : 37, 38, 39, 40, 41, 0, 42, 43, 44, 45,
707 : 46, 28, 29, 30, 31, 32, 33, 0, 0, 0,
708 : 0, 0, 34, 35, 36, 37, 38, 39, 40, 41,
709 : 0, 42, 43, 44, 45, 46, -1, -1, -1, 31,
710 : 32, 0, 0, 0, 0, 0, 0, 0, 0, -1,
711 : -1, -1, 39, 40, 41, 0, 42, 43, 44, 45,
712 : 46
713 : };
714 :
715 : static const yytype_int8 yycheck[] =
716 : {
717 : 7, 20, 9, 10, 11, 12, 3, 39, 3, 41,
718 : 7, 18, 7, 0, 20, 12, 22, 23, 40, 26,
719 : 27, 28, 29, 30, 31, 32, 35, 36, 37, 36,
720 : 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
721 : 47, -1, 49, 50, 33, 34, 35, 36, 37, 3,
722 : 4, 5, 6, 7, 8, 9, -1, -1, 12, -1,
723 : -1, -1, -1, -1, -1, 19, -1, 3, 4, 76,
724 : 6, 7, 8, 9, 81, -1, 12, 84, 32, 33,
725 : 34, -1, -1, 19, -1, -1, 40, -1, -1, -1,
726 : -1, -1, -1, -1, -1, -1, 32, 33, 34, -1,
727 : -1, -1, 10, 11, 40, 13, 14, 15, 16, 17,
728 : 18, -1, -1, -1, -1, -1, 24, 25, 26, 27,
729 : 28, 29, 30, 31, -1, 33, 34, 35, 36, 37,
730 : -1, 10, 11, 41, 13, 14, 15, 16, 17, 18,
731 : -1, -1, 21, -1, -1, 24, 25, 26, 27, 28,
732 : 29, 30, 31, -1, 33, 34, 35, 36, 37, 10,
733 : 11, -1, 13, 14, 15, 16, 17, 18, -1, -1,
734 : 21, -1, -1, 24, 25, 26, 27, 28, 29, 30,
735 : 31, -1, 33, 34, 35, 36, 37, 10, 11, -1,
736 : 13, 14, 15, 16, 17, 18, -1, -1, -1, -1,
737 : 23, 24, 25, 26, 27, 28, 29, 30, 31, -1,
738 : 33, 34, 35, 36, 37, 10, 11, -1, 13, 14,
739 : 15, 16, 17, 18, -1, -1, -1, -1, -1, 24,
740 : 25, 26, 27, 28, 29, 30, 31, -1, 33, 34,
741 : 35, 36, 37, 10, -1, -1, 13, 14, 15, 16,
742 : 17, 18, -1, -1, -1, -1, -1, 24, 25, 26,
743 : 27, 28, 29, 30, 31, -1, 33, 34, 35, 36,
744 : 37, 13, 14, 15, 16, 17, 18, -1, -1, -1,
745 : -1, -1, 24, 25, 26, 27, 28, 29, 30, 31,
746 : -1, 33, 34, 35, 36, 37, 13, 14, 15, 16,
747 : 17, -1, -1, -1, -1, -1, -1, -1, -1, 26,
748 : 27, 28, 29, 30, 31, -1, 33, 34, 35, 36,
749 : 37
750 : };
751 :
752 : /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
753 : symbol of state STATE-NUM. */
754 : static const yytype_int8 yystos[] =
755 : {
756 : 0, 3, 4, 6, 7, 8, 9, 12, 19, 32,
757 : 33, 34, 40, 43, 45, 47, 48, 45, 20, 46,
758 : 45, 45, 5, 45, 45, 0, 10, 11, 13, 14,
759 : 15, 16, 17, 18, 24, 25, 26, 27, 28, 29,
760 : 30, 31, 33, 34, 35, 36, 37, 40, 45, 20,
761 : 22, 23, 41, 45, 45, 45, 45, 45, 45, 45,
762 : 3, 7, 12, 45, 45, 45, 45, 45, 45, 45,
763 : 45, 45, 45, 45, 44, 45, 21, 45, 45, 3,
764 : 7, 39, 41, 45, 21, 23, 45, 45
765 : };
766 :
767 : /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
768 : static const yytype_int8 yyr1[] =
769 : {
770 : 0, 42, 43, 44, 44, 44, 45, 45, 45, 45,
771 : 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
772 : 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
773 : 45, 45, 45, 45, 45, 45, 45, 45, 45, 45,
774 : 45, 45, 45, 46, 46, 47, 47, 48
775 : };
776 :
777 : /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */
778 : static const yytype_int8 yyr2[] =
779 : {
780 : 0, 2, 1, 0, 1, 3, 3, 2, 2, 2,
781 : 2, 2, 3, 3, 3, 3, 3, 3, 3, 3,
782 : 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
783 : 2, 2, 3, 4, 3, 4, 1, 1, 1, 1,
784 : 1, 4, 1, 5, 4, 3, 5, 1
785 : };
786 :
787 :
788 : enum { YYENOMEM = -2 };
789 :
790 : #define yyerrok (yyerrstatus = 0)
791 : #define yyclearin (yychar = YYEMPTY)
792 :
793 : #define YYACCEPT goto yyacceptlab
794 : #define YYABORT goto yyabortlab
795 : #define YYERROR goto yyerrorlab
796 :
797 :
798 : #define YYRECOVERING() (!!yyerrstatus)
799 :
800 : #define YYBACKUP(Token, Value) \
801 : do \
802 : if (yychar == YYEMPTY) \
803 : { \
804 : yychar = (Token); \
805 : yylval = (Value); \
806 : YYPOPSTACK (yylen); \
807 : yystate = *yyssp; \
808 : goto yybackup; \
809 : } \
810 : else \
811 : { \
812 : yyerror (expr_parse_result_p, yyscanner, YY_("syntax error: cannot back up")); \
813 : YYERROR; \
814 : } \
815 : while (0)
816 :
817 : /* Backward compatibility with an undocumented macro.
818 : Use YYerror or YYUNDEF. */
819 : #define YYERRCODE YYUNDEF
820 :
821 :
822 : /* Enable debugging if requested. */
823 : #if YYDEBUG
824 :
825 : # ifndef YYFPRINTF
826 : # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
827 : # define YYFPRINTF fprintf
828 : # endif
829 :
830 : # define YYDPRINTF(Args) \
831 : do { \
832 : if (yydebug) \
833 : YYFPRINTF Args; \
834 : } while (0)
835 :
836 : /* This macro is provided for backward compatibility. */
837 : # ifndef YY_LOCATION_PRINT
838 : # define YY_LOCATION_PRINT(File, Loc) ((void) 0)
839 : # endif
840 :
841 :
842 : # define YY_SYMBOL_PRINT(Title, Kind, Value, Location) \
843 : do { \
844 : if (yydebug) \
845 : { \
846 : YYFPRINTF (stderr, "%s ", Title); \
847 : yy_symbol_print (stderr, \
848 : Kind, Value, expr_parse_result_p, yyscanner); \
849 : YYFPRINTF (stderr, "\n"); \
850 : } \
851 : } while (0)
852 :
853 :
854 : /*-----------------------------------.
855 : | Print this symbol's value on YYO. |
856 : `-----------------------------------*/
857 :
858 : static void
859 : yy_symbol_value_print (FILE *yyo,
860 : yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner)
861 : {
862 : FILE *yyoutput = yyo;
863 : YY_USE (yyoutput);
864 : YY_USE (expr_parse_result_p);
865 : YY_USE (yyscanner);
866 : if (!yyvaluep)
867 : return;
868 : # ifdef YYPRINT
869 : if (yykind < YYNTOKENS)
870 : YYPRINT (yyo, yytoknum[yykind], *yyvaluep);
871 : # endif
872 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
873 : YY_USE (yykind);
874 : YY_IGNORE_MAYBE_UNINITIALIZED_END
875 : }
876 :
877 :
878 : /*---------------------------.
879 : | Print this symbol on YYO. |
880 : `---------------------------*/
881 :
882 : static void
883 : yy_symbol_print (FILE *yyo,
884 : yysymbol_kind_t yykind, YYSTYPE const * const yyvaluep, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner)
885 : {
886 : YYFPRINTF (yyo, "%s %s (",
887 : yykind < YYNTOKENS ? "token" : "nterm", yysymbol_name (yykind));
888 :
889 : yy_symbol_value_print (yyo, yykind, yyvaluep, expr_parse_result_p, yyscanner);
890 : YYFPRINTF (yyo, ")");
891 : }
892 :
893 : /*------------------------------------------------------------------.
894 : | yy_stack_print -- Print the state stack from its BOTTOM up to its |
895 : | TOP (included). |
896 : `------------------------------------------------------------------*/
897 :
898 : static void
899 : yy_stack_print (yy_state_t *yybottom, yy_state_t *yytop)
900 : {
901 : YYFPRINTF (stderr, "Stack now");
902 : for (; yybottom <= yytop; yybottom++)
903 : {
904 : int yybot = *yybottom;
905 : YYFPRINTF (stderr, " %d", yybot);
906 : }
907 : YYFPRINTF (stderr, "\n");
908 : }
909 :
910 : # define YY_STACK_PRINT(Bottom, Top) \
911 : do { \
912 : if (yydebug) \
913 : yy_stack_print ((Bottom), (Top)); \
914 : } while (0)
915 :
916 :
917 : /*------------------------------------------------.
918 : | Report that the YYRULE is going to be reduced. |
919 : `------------------------------------------------*/
920 :
921 : static void
922 : yy_reduce_print (yy_state_t *yyssp, YYSTYPE *yyvsp,
923 : int yyrule, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner)
924 : {
925 : int yylno = yyrline[yyrule];
926 : int yynrhs = yyr2[yyrule];
927 : int yyi;
928 : YYFPRINTF (stderr, "Reducing stack by rule %d (line %d):\n",
929 : yyrule - 1, yylno);
930 : /* The symbols being reduced. */
931 : for (yyi = 0; yyi < yynrhs; yyi++)
932 : {
933 : YYFPRINTF (stderr, " $%d = ", yyi + 1);
934 : yy_symbol_print (stderr,
935 : YY_ACCESSING_SYMBOL (+yyssp[yyi + 1 - yynrhs]),
936 : &yyvsp[(yyi + 1) - (yynrhs)], expr_parse_result_p, yyscanner);
937 : YYFPRINTF (stderr, "\n");
938 : }
939 : }
940 :
941 : # define YY_REDUCE_PRINT(Rule) \
942 : do { \
943 : if (yydebug) \
944 : yy_reduce_print (yyssp, yyvsp, Rule, expr_parse_result_p, yyscanner); \
945 : } while (0)
946 :
947 : /* Nonzero means print parse trace. It is left uninitialized so that
948 : multiple parsers can coexist. */
949 : int yydebug;
950 : #else /* !YYDEBUG */
951 : # define YYDPRINTF(Args) ((void) 0)
952 : # define YY_SYMBOL_PRINT(Title, Kind, Value, Location)
953 : # define YY_STACK_PRINT(Bottom, Top)
954 : # define YY_REDUCE_PRINT(Rule)
955 : #endif /* !YYDEBUG */
956 :
957 :
958 : /* YYINITDEPTH -- initial size of the parser's stacks. */
959 : #ifndef YYINITDEPTH
960 : # define YYINITDEPTH 200
961 : #endif
962 :
963 : /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
964 : if the built-in stack extension method is used).
965 :
966 : Do not make this value too large; the results are undefined if
967 : YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
968 : evaluated with infinite-precision integer arithmetic. */
969 :
970 : #ifndef YYMAXDEPTH
971 : # define YYMAXDEPTH 10000
972 : #endif
973 :
974 :
975 :
976 :
977 :
978 :
979 : /*-----------------------------------------------.
980 : | Release the memory associated to this symbol. |
981 : `-----------------------------------------------*/
982 :
983 : static void
984 1512 : yydestruct (const char *yymsg,
985 : yysymbol_kind_t yykind, YYSTYPE *yyvaluep, PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner)
986 : {
987 : YY_USE (yyvaluep);
988 : YY_USE (expr_parse_result_p);
989 : YY_USE (yyscanner);
990 1512 : if (!yymsg)
991 0 : yymsg = "Deleting";
992 : YY_SYMBOL_PRINT (yymsg, yykind, yyvaluep, yylocationp);
993 :
994 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
995 : YY_USE (yykind);
996 : YY_IGNORE_MAYBE_UNINITIALIZED_END
997 1512 : }
998 :
999 :
1000 :
1001 :
1002 :
1003 :
1004 : /*----------.
1005 : | yyparse. |
1006 : `----------*/
1007 :
1008 : int
1009 794 : yyparse (PgBenchExpr **expr_parse_result_p, yyscan_t yyscanner)
1010 : {
1011 : /* Lookahead token kind. */
1012 : int yychar;
1013 :
1014 :
1015 : /* The semantic value of the lookahead symbol. */
1016 : /* Default value used for initialization, for pacifying older GCCs
1017 : or non-GCC compilers. */
1018 : YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
1019 : YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
1020 :
1021 : /* Number of syntax errors so far. */
1022 794 : int yynerrs = 0;
1023 :
1024 794 : yy_state_fast_t yystate = 0;
1025 : /* Number of tokens to shift before error messages enabled. */
1026 794 : int yyerrstatus = 0;
1027 :
1028 : /* Refer to the stacks through separate pointers, to allow yyoverflow
1029 : to reallocate them elsewhere. */
1030 :
1031 : /* Their size. */
1032 794 : YYPTRDIFF_T yystacksize = YYINITDEPTH;
1033 :
1034 : /* The state stack: array, bottom, top. */
1035 : yy_state_t yyssa[YYINITDEPTH];
1036 794 : yy_state_t *yyss = yyssa;
1037 794 : yy_state_t *yyssp = yyss;
1038 :
1039 : /* The semantic value stack: array, bottom, top. */
1040 : YYSTYPE yyvsa[YYINITDEPTH];
1041 794 : YYSTYPE *yyvs = yyvsa;
1042 794 : YYSTYPE *yyvsp = yyvs;
1043 :
1044 : int yyn;
1045 : /* The return value of yyparse. */
1046 : int yyresult;
1047 : /* Lookahead symbol kind. */
1048 794 : yysymbol_kind_t yytoken = YYSYMBOL_YYEMPTY;
1049 : /* The variables used to return semantic value and location from the
1050 : action routines. */
1051 : YYSTYPE yyval;
1052 :
1053 :
1054 :
1055 : #define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1056 :
1057 : /* The number of symbols on the RHS of the reduced rule.
1058 : Keep to zero when no symbol should be popped. */
1059 794 : int yylen = 0;
1060 :
1061 : YYDPRINTF ((stderr, "Starting parse\n"));
1062 :
1063 794 : yychar = YYEMPTY; /* Cause a token to be read. */
1064 794 : goto yysetstate;
1065 :
1066 :
1067 : /*------------------------------------------------------------.
1068 : | yynewstate -- push a new state, which is found in yystate. |
1069 : `------------------------------------------------------------*/
1070 14794 : yynewstate:
1071 : /* In all cases, when you get here, the value and location stacks
1072 : have just been pushed. So pushing a state here evens the stacks. */
1073 14794 : yyssp++;
1074 :
1075 :
1076 : /*--------------------------------------------------------------------.
1077 : | yysetstate -- set current state (the top of the stack) to yystate. |
1078 : `--------------------------------------------------------------------*/
1079 15588 : yysetstate:
1080 : YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1081 : YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
1082 : YY_IGNORE_USELESS_CAST_BEGIN
1083 15588 : *yyssp = YY_CAST (yy_state_t, yystate);
1084 : YY_IGNORE_USELESS_CAST_END
1085 : YY_STACK_PRINT (yyss, yyssp);
1086 :
1087 15588 : if (yyss + yystacksize - 1 <= yyssp)
1088 : #if !defined yyoverflow && !defined YYSTACK_RELOCATE
1089 : goto yyexhaustedlab;
1090 : #else
1091 : {
1092 : /* Get the current used size of the three stacks, in elements. */
1093 0 : YYPTRDIFF_T yysize = yyssp - yyss + 1;
1094 :
1095 : # if defined yyoverflow
1096 : {
1097 : /* Give user a chance to reallocate the stack. Use copies of
1098 : these so that the &'s don't force the real ones into
1099 : memory. */
1100 : yy_state_t *yyss1 = yyss;
1101 : YYSTYPE *yyvs1 = yyvs;
1102 :
1103 : /* Each stack pointer address is followed by the size of the
1104 : data in use in that stack, in bytes. This used to be a
1105 : conditional around just the two extra args, but that might
1106 : be undefined if yyoverflow is a macro. */
1107 : yyoverflow (YY_("memory exhausted"),
1108 : &yyss1, yysize * YYSIZEOF (*yyssp),
1109 : &yyvs1, yysize * YYSIZEOF (*yyvsp),
1110 : &yystacksize);
1111 : yyss = yyss1;
1112 : yyvs = yyvs1;
1113 : }
1114 : # else /* defined YYSTACK_RELOCATE */
1115 : /* Extend the stack our own way. */
1116 0 : if (YYMAXDEPTH <= yystacksize)
1117 0 : goto yyexhaustedlab;
1118 0 : yystacksize *= 2;
1119 0 : if (YYMAXDEPTH < yystacksize)
1120 0 : yystacksize = YYMAXDEPTH;
1121 :
1122 : {
1123 0 : yy_state_t *yyss1 = yyss;
1124 : union yyalloc *yyptr =
1125 0 : YY_CAST (union yyalloc *,
1126 : YYSTACK_ALLOC (YY_CAST (YYSIZE_T, YYSTACK_BYTES (yystacksize))));
1127 0 : if (! yyptr)
1128 0 : goto yyexhaustedlab;
1129 0 : YYSTACK_RELOCATE (yyss_alloc, yyss);
1130 0 : YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1131 : # undef YYSTACK_RELOCATE
1132 0 : if (yyss1 != yyssa)
1133 0 : YYSTACK_FREE (yyss1);
1134 : }
1135 : # endif
1136 :
1137 0 : yyssp = yyss + yysize - 1;
1138 0 : yyvsp = yyvs + yysize - 1;
1139 :
1140 : YY_IGNORE_USELESS_CAST_BEGIN
1141 : YYDPRINTF ((stderr, "Stack size increased to %ld\n",
1142 : YY_CAST (long, yystacksize)));
1143 : YY_IGNORE_USELESS_CAST_END
1144 :
1145 0 : if (yyss + yystacksize - 1 <= yyssp)
1146 0 : YYABORT;
1147 : }
1148 : #endif /* !defined yyoverflow && !defined YYSTACK_RELOCATE */
1149 :
1150 15588 : if (yystate == YYFINAL)
1151 756 : YYACCEPT;
1152 :
1153 14832 : goto yybackup;
1154 :
1155 :
1156 : /*-----------.
1157 : | yybackup. |
1158 : `-----------*/
1159 14832 : yybackup:
1160 : /* Do appropriate processing given the current state. Read a
1161 : lookahead token if we need one and don't already have one. */
1162 :
1163 : /* First try to decide what to do without reference to lookahead token. */
1164 14832 : yyn = yypact[yystate];
1165 14832 : if (yypact_value_is_default (yyn))
1166 4634 : goto yydefault;
1167 :
1168 : /* Not known => get a lookahead token if don't already have one. */
1169 :
1170 : /* YYCHAR is either empty, or end-of-input, or a valid lookahead. */
1171 10198 : if (yychar == YYEMPTY)
1172 : {
1173 : YYDPRINTF ((stderr, "Reading a token\n"));
1174 7520 : yychar = yylex (&yylval, yyscanner);
1175 : }
1176 :
1177 10190 : if (yychar <= YYEOF)
1178 : {
1179 1552 : yychar = YYEOF;
1180 1552 : yytoken = YYSYMBOL_YYEOF;
1181 : YYDPRINTF ((stderr, "Now at end of input.\n"));
1182 : }
1183 8638 : else if (yychar == YYerror)
1184 : {
1185 : /* The scanner already issued an error message, process directly
1186 : to error recovery. But do not keep the error token as
1187 : lookahead, it is too special and may lead us to an endless
1188 : loop in error recovery. */
1189 0 : yychar = YYUNDEF;
1190 0 : yytoken = YYSYMBOL_YYerror;
1191 0 : goto yyerrlab1;
1192 : }
1193 : else
1194 : {
1195 8638 : yytoken = YYTRANSLATE (yychar);
1196 : YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1197 : }
1198 :
1199 : /* If the proper action on seeing token YYTOKEN is to reduce or to
1200 : detect an error, take that action. */
1201 10190 : yyn += yytoken;
1202 10190 : if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
1203 2690 : goto yydefault;
1204 7500 : yyn = yytable[yyn];
1205 7500 : if (yyn <= 0)
1206 : {
1207 0 : if (yytable_value_is_error (yyn))
1208 0 : goto yyerrlab;
1209 0 : yyn = -yyn;
1210 0 : goto yyreduce;
1211 : }
1212 :
1213 : /* Count tokens shifted since error; after three, turn off error
1214 : status. */
1215 7500 : if (yyerrstatus)
1216 0 : yyerrstatus--;
1217 :
1218 : /* Shift the lookahead token. */
1219 : YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
1220 7500 : yystate = yyn;
1221 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1222 7500 : *++yyvsp = yylval;
1223 : YY_IGNORE_MAYBE_UNINITIALIZED_END
1224 :
1225 : /* Discard the shifted token. */
1226 7500 : yychar = YYEMPTY;
1227 7500 : goto yynewstate;
1228 :
1229 :
1230 : /*-----------------------------------------------------------.
1231 : | yydefault -- do the default action for the current state. |
1232 : `-----------------------------------------------------------*/
1233 7324 : yydefault:
1234 7324 : yyn = yydefact[yystate];
1235 7324 : if (yyn == 0)
1236 12 : goto yyerrlab;
1237 7312 : goto yyreduce;
1238 :
1239 :
1240 : /*-----------------------------.
1241 : | yyreduce -- do a reduction. |
1242 : `-----------------------------*/
1243 7312 : yyreduce:
1244 : /* yyn is the number of a rule to reduce with. */
1245 7312 : yylen = yyr2[yyn];
1246 :
1247 : /* If YYLEN is nonzero, implement the default value of the action:
1248 : '$$ = $1'.
1249 :
1250 : Otherwise, the following line sets YYVAL to garbage.
1251 : This behavior is undocumented and Bison
1252 : users should not rely upon it. Assigning to YYVAL
1253 : unconditionally makes the parser a bit smaller, and it avoids a
1254 : GCC warning that YYVAL may be used uninitialized. */
1255 7312 : yyval = yyvsp[1-yylen];
1256 :
1257 :
1258 : YY_REDUCE_PRINT (yyn);
1259 7312 : switch (yyn)
1260 : {
1261 756 : case 2: /* result: expr */
1262 : #line 82 "exprparse.y"
1263 : {
1264 : *expr_parse_result_p = (yyvsp[0].expr);
1265 : (void) yynerrs; /* suppress compiler warning */
1266 : }
1267 : #line 1268 "exprparse.c"
1268 756 : break;
1269 :
1270 10 : case 3: /* elist: %empty */
1271 : #line 87 "exprparse.y"
1272 : { (yyval.elist) = NULL; }
1273 : #line 1274 "exprparse.c"
1274 10 : break;
1275 :
1276 786 : case 4: /* elist: expr */
1277 : #line 88 "exprparse.y"
1278 : { (yyval.elist) = make_elist((yyvsp[0].expr), NULL); }
1279 : #line 1280 "exprparse.c"
1280 786 : break;
1281 :
1282 686 : case 5: /* elist: elist ',' expr */
1283 : #line 89 "exprparse.y"
1284 : { (yyval.elist) = make_elist((yyvsp[0].expr), (yyvsp[-2].elist)); }
1285 : #line 1286 "exprparse.c"
1286 686 : break;
1287 :
1288 104 : case 6: /* expr: '(' expr ')' */
1289 : #line 92 "exprparse.y"
1290 : { (yyval.expr) = (yyvsp[-1].expr); }
1291 : #line 1292 "exprparse.c"
1292 104 : break;
1293 :
1294 4 : case 7: /* expr: '+' expr */
1295 : #line 93 "exprparse.y"
1296 : { (yyval.expr) = (yyvsp[0].expr); }
1297 : #line 1298 "exprparse.c"
1298 4 : break;
1299 :
1300 92 : case 8: /* expr: '-' expr */
1301 : #line 95 "exprparse.y"
1302 : { (yyval.expr) = make_op(yyscanner, "-",
1303 : make_integer_constant(0), (yyvsp[0].expr)); }
1304 : #line 1305 "exprparse.c"
1305 92 : break;
1306 :
1307 2 : case 9: /* expr: '-' MAXINT_PLUS_ONE_CONST */
1308 : #line 99 "exprparse.y"
1309 : { (yyval.expr) = make_integer_constant(PG_INT64_MIN); }
1310 : #line 1311 "exprparse.c"
1311 2 : break;
1312 :
1313 4 : case 10: /* expr: '~' expr */
1314 : #line 101 "exprparse.y"
1315 : { (yyval.expr) = make_op(yyscanner, "#",
1316 : make_integer_constant(~INT64CONST(0)), (yyvsp[0].expr)); }
1317 : #line 1318 "exprparse.c"
1318 4 : break;
1319 :
1320 24 : case 11: /* expr: NOT_OP expr */
1321 : #line 103 "exprparse.y"
1322 : { (yyval.expr) = make_uop(yyscanner, "!not", (yyvsp[0].expr)); }
1323 : #line 1324 "exprparse.c"
1324 24 : break;
1325 :
1326 96 : case 12: /* expr: expr '+' expr */
1327 : #line 104 "exprparse.y"
1328 : { (yyval.expr) = make_op(yyscanner, "+", (yyvsp[-2].expr), (yyvsp[0].expr)); }
1329 : #line 1330 "exprparse.c"
1330 96 : break;
1331 :
1332 36 : case 13: /* expr: expr '-' expr */
1333 : #line 105 "exprparse.y"
1334 : { (yyval.expr) = make_op(yyscanner, "-", (yyvsp[-2].expr), (yyvsp[0].expr)); }
1335 : #line 1336 "exprparse.c"
1336 36 : break;
1337 :
1338 408 : case 14: /* expr: expr '*' expr */
1339 : #line 106 "exprparse.y"
1340 : { (yyval.expr) = make_op(yyscanner, "*", (yyvsp[-2].expr), (yyvsp[0].expr)); }
1341 : #line 1342 "exprparse.c"
1342 408 : break;
1343 :
1344 26 : case 15: /* expr: expr '/' expr */
1345 : #line 107 "exprparse.y"
1346 : { (yyval.expr) = make_op(yyscanner, "/", (yyvsp[-2].expr), (yyvsp[0].expr)); }
1347 : #line 1348 "exprparse.c"
1348 26 : break;
1349 :
1350 4 : case 16: /* expr: expr '%' expr */
1351 : #line 108 "exprparse.y"
1352 : { (yyval.expr) = make_op(yyscanner, "mod", (yyvsp[-2].expr), (yyvsp[0].expr)); }
1353 : #line 1354 "exprparse.c"
1354 4 : break;
1355 :
1356 20 : case 17: /* expr: expr '<' expr */
1357 : #line 109 "exprparse.y"
1358 : { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[-2].expr), (yyvsp[0].expr)); }
1359 : #line 1360 "exprparse.c"
1360 20 : break;
1361 :
1362 8 : case 18: /* expr: expr LE_OP expr */
1363 : #line 110 "exprparse.y"
1364 : { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[-2].expr), (yyvsp[0].expr)); }
1365 : #line 1366 "exprparse.c"
1366 8 : break;
1367 :
1368 12 : case 19: /* expr: expr '>' expr */
1369 : #line 111 "exprparse.y"
1370 : { (yyval.expr) = make_op(yyscanner, "<", (yyvsp[0].expr), (yyvsp[-2].expr)); }
1371 : #line 1372 "exprparse.c"
1372 12 : break;
1373 :
1374 6 : case 20: /* expr: expr GE_OP expr */
1375 : #line 112 "exprparse.y"
1376 : { (yyval.expr) = make_op(yyscanner, "<=", (yyvsp[0].expr), (yyvsp[-2].expr)); }
1377 : #line 1378 "exprparse.c"
1378 6 : break;
1379 :
1380 64 : case 21: /* expr: expr '=' expr */
1381 : #line 113 "exprparse.y"
1382 : { (yyval.expr) = make_op(yyscanner, "=", (yyvsp[-2].expr), (yyvsp[0].expr)); }
1383 : #line 1384 "exprparse.c"
1384 64 : break;
1385 :
1386 16 : case 22: /* expr: expr NE_OP expr */
1387 : #line 114 "exprparse.y"
1388 : { (yyval.expr) = make_op(yyscanner, "<>", (yyvsp[-2].expr), (yyvsp[0].expr)); }
1389 : #line 1390 "exprparse.c"
1390 16 : break;
1391 :
1392 2 : case 23: /* expr: expr '&' expr */
1393 : #line 115 "exprparse.y"
1394 : { (yyval.expr) = make_op(yyscanner, "&", (yyvsp[-2].expr), (yyvsp[0].expr)); }
1395 : #line 1396 "exprparse.c"
1396 2 : break;
1397 :
1398 4 : case 24: /* expr: expr '|' expr */
1399 : #line 116 "exprparse.y"
1400 : { (yyval.expr) = make_op(yyscanner, "|", (yyvsp[-2].expr), (yyvsp[0].expr)); }
1401 : #line 1402 "exprparse.c"
1402 4 : break;
1403 :
1404 2 : case 25: /* expr: expr '#' expr */
1405 : #line 117 "exprparse.y"
1406 : { (yyval.expr) = make_op(yyscanner, "#", (yyvsp[-2].expr), (yyvsp[0].expr)); }
1407 : #line 1408 "exprparse.c"
1408 2 : break;
1409 :
1410 14 : case 26: /* expr: expr LS_OP expr */
1411 : #line 118 "exprparse.y"
1412 : { (yyval.expr) = make_op(yyscanner, "<<", (yyvsp[-2].expr), (yyvsp[0].expr)); }
1413 : #line 1414 "exprparse.c"
1414 14 : break;
1415 :
1416 2 : case 27: /* expr: expr RS_OP expr */
1417 : #line 119 "exprparse.y"
1418 : { (yyval.expr) = make_op(yyscanner, ">>", (yyvsp[-2].expr), (yyvsp[0].expr)); }
1419 : #line 1420 "exprparse.c"
1420 2 : break;
1421 :
1422 88 : case 28: /* expr: expr AND_OP expr */
1423 : #line 120 "exprparse.y"
1424 : { (yyval.expr) = make_op(yyscanner, "!and", (yyvsp[-2].expr), (yyvsp[0].expr)); }
1425 : #line 1426 "exprparse.c"
1426 88 : break;
1427 :
1428 10 : case 29: /* expr: expr OR_OP expr */
1429 : #line 121 "exprparse.y"
1430 : { (yyval.expr) = make_op(yyscanner, "!or", (yyvsp[-2].expr), (yyvsp[0].expr)); }
1431 : #line 1432 "exprparse.c"
1432 10 : break;
1433 :
1434 2 : case 30: /* expr: expr ISNULL_OP */
1435 : #line 123 "exprparse.y"
1436 : { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[-1].expr), make_null_constant()); }
1437 : #line 1438 "exprparse.c"
1438 2 : break;
1439 :
1440 2 : case 31: /* expr: expr NOTNULL_OP */
1441 : #line 124 "exprparse.y"
1442 : {
1443 : (yyval.expr) = make_uop(yyscanner, "!not",
1444 : make_op(yyscanner, "!is", (yyvsp[-1].expr), make_null_constant()));
1445 : }
1446 : #line 1447 "exprparse.c"
1447 2 : break;
1448 :
1449 8 : case 32: /* expr: expr IS_OP NULL_CONST */
1450 : #line 128 "exprparse.y"
1451 : { (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[-2].expr), make_null_constant()); }
1452 : #line 1453 "exprparse.c"
1453 8 : break;
1454 :
1455 4 : case 33: /* expr: expr IS_OP NOT_OP NULL_CONST */
1456 : #line 130 "exprparse.y"
1457 : {
1458 : (yyval.expr) = make_uop(yyscanner, "!not",
1459 : make_op(yyscanner, "!is", (yyvsp[-3].expr), make_null_constant()));
1460 : }
1461 : #line 1462 "exprparse.c"
1462 4 : break;
1463 :
1464 2 : case 34: /* expr: expr IS_OP BOOLEAN_CONST */
1465 : #line 135 "exprparse.y"
1466 : {
1467 : (yyval.expr) = make_op(yyscanner, "!is", (yyvsp[-2].expr), make_boolean_constant((yyvsp[0].bval)));
1468 : }
1469 : #line 1470 "exprparse.c"
1470 2 : break;
1471 :
1472 2 : case 35: /* expr: expr IS_OP NOT_OP BOOLEAN_CONST */
1473 : #line 139 "exprparse.y"
1474 : {
1475 : (yyval.expr) = make_uop(yyscanner, "!not",
1476 : make_op(yyscanner, "!is", (yyvsp[-3].expr), make_boolean_constant((yyvsp[0].bval))));
1477 : }
1478 : #line 1479 "exprparse.c"
1479 2 : break;
1480 :
1481 12 : case 36: /* expr: NULL_CONST */
1482 : #line 144 "exprparse.y"
1483 : { (yyval.expr) = make_null_constant(); }
1484 : #line 1485 "exprparse.c"
1485 12 : break;
1486 :
1487 62 : case 37: /* expr: BOOLEAN_CONST */
1488 : #line 145 "exprparse.y"
1489 : { (yyval.expr) = make_boolean_constant((yyvsp[0].bval)); }
1490 : #line 1491 "exprparse.c"
1491 62 : break;
1492 :
1493 1588 : case 38: /* expr: INTEGER_CONST */
1494 : #line 146 "exprparse.y"
1495 : { (yyval.expr) = make_integer_constant((yyvsp[0].ival)); }
1496 : #line 1497 "exprparse.c"
1497 1588 : break;
1498 :
1499 122 : case 39: /* expr: DOUBLE_CONST */
1500 : #line 147 "exprparse.y"
1501 : { (yyval.expr) = make_double_constant((yyvsp[0].dval)); }
1502 : #line 1503 "exprparse.c"
1503 122 : break;
1504 :
1505 540 : case 40: /* expr: VARIABLE */
1506 : #line 149 "exprparse.y"
1507 : { (yyval.expr) = make_variable((yyvsp[0].str)); }
1508 : #line 1509 "exprparse.c"
1509 540 : break;
1510 :
1511 796 : case 41: /* expr: function '(' elist ')' */
1512 : #line 150 "exprparse.y"
1513 : { (yyval.expr) = make_func(yyscanner, (yyvsp[-3].ival), (yyvsp[-1].elist)); }
1514 : #line 1515 "exprparse.c"
1515 780 : break;
1516 :
1517 28 : case 42: /* expr: case_control */
1518 : #line 151 "exprparse.y"
1519 : { (yyval.expr) = (yyvsp[0].expr); }
1520 : #line 1521 "exprparse.c"
1521 28 : break;
1522 :
1523 4 : case 43: /* when_then_list: when_then_list WHEN_KW expr THEN_KW expr */
1524 : #line 155 "exprparse.y"
1525 : { (yyval.elist) = make_elist((yyvsp[0].expr), make_elist((yyvsp[-2].expr), (yyvsp[-4].elist))); }
1526 : #line 1527 "exprparse.c"
1527 4 : break;
1528 :
1529 28 : case 44: /* when_then_list: WHEN_KW expr THEN_KW expr */
1530 : #line 156 "exprparse.y"
1531 : { (yyval.elist) = make_elist((yyvsp[0].expr), make_elist((yyvsp[-2].expr), NULL)); }
1532 : #line 1533 "exprparse.c"
1533 28 : break;
1534 :
1535 8 : case 45: /* case_control: CASE_KW when_then_list END_KW */
1536 : #line 159 "exprparse.y"
1537 : { (yyval.expr) = make_case(yyscanner, (yyvsp[-1].elist), make_null_constant()); }
1538 : #line 1539 "exprparse.c"
1539 8 : break;
1540 :
1541 20 : case 46: /* case_control: CASE_KW when_then_list ELSE_KW expr END_KW */
1542 : #line 160 "exprparse.y"
1543 : { (yyval.expr) = make_case(yyscanner, (yyvsp[-3].elist), (yyvsp[-1].expr)); }
1544 : #line 1545 "exprparse.c"
1545 20 : break;
1546 :
1547 798 : case 47: /* function: FUNCTION */
1548 : #line 162 "exprparse.y"
1549 : { (yyval.ival) = find_func(yyscanner, (yyvsp[0].str)); pg_free((yyvsp[0].str)); }
1550 : #line 1551 "exprparse.c"
1551 796 : break;
1552 :
1553 :
1554 : #line 1555 "exprparse.c"
1555 :
1556 0 : default: break;
1557 : }
1558 : /* User semantic actions sometimes alter yychar, and that requires
1559 : that yytoken be updated with the new translation. We take the
1560 : approach of translating immediately before every use of yytoken.
1561 : One alternative is translating here after every semantic action,
1562 : but that translation would be missed if the semantic action invokes
1563 : YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or
1564 : if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an
1565 : incorrect destructor might then be invoked immediately. In the
1566 : case of YYERROR or YYBACKUP, subsequent parser actions might lead
1567 : to an incorrect destructor call or verbose syntax error message
1568 : before the lookahead is translated. */
1569 : YY_SYMBOL_PRINT ("-> $$ =", YY_CAST (yysymbol_kind_t, yyr1[yyn]), &yyval, &yyloc);
1570 :
1571 7294 : YYPOPSTACK (yylen);
1572 7294 : yylen = 0;
1573 :
1574 7294 : *++yyvsp = yyval;
1575 :
1576 : /* Now 'shift' the result of the reduction. Determine what state
1577 : that goes to, based on the state we popped back to and the rule
1578 : number reduced by. */
1579 : {
1580 7294 : const int yylhs = yyr1[yyn] - YYNTOKENS;
1581 7294 : const int yyi = yypgoto[yylhs] + *yyssp;
1582 5042 : yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
1583 3400 : ? yytable[yyi]
1584 12336 : : yydefgoto[yylhs]);
1585 : }
1586 :
1587 7294 : goto yynewstate;
1588 :
1589 :
1590 : /*--------------------------------------.
1591 : | yyerrlab -- here on detecting error. |
1592 : `--------------------------------------*/
1593 12 : yyerrlab:
1594 : /* Make sure we have latest lookahead translation. See comments at
1595 : user semantic actions for why this is necessary. */
1596 12 : yytoken = yychar == YYEMPTY ? YYSYMBOL_YYEMPTY : YYTRANSLATE (yychar);
1597 : /* If not already recovering from an error, report this error. */
1598 12 : if (!yyerrstatus)
1599 : {
1600 12 : ++yynerrs;
1601 12 : yyerror (expr_parse_result_p, yyscanner, YY_("syntax error"));
1602 : }
1603 :
1604 0 : if (yyerrstatus == 3)
1605 : {
1606 : /* If just tried and failed to reuse lookahead token after an
1607 : error, discard it. */
1608 :
1609 0 : if (yychar <= YYEOF)
1610 : {
1611 : /* Return failure if at end of input. */
1612 0 : if (yychar == YYEOF)
1613 0 : YYABORT;
1614 : }
1615 : else
1616 : {
1617 0 : yydestruct ("Error: discarding",
1618 : yytoken, &yylval, expr_parse_result_p, yyscanner);
1619 0 : yychar = YYEMPTY;
1620 : }
1621 : }
1622 :
1623 : /* Else will try to reuse lookahead token after shifting the error
1624 : token. */
1625 0 : goto yyerrlab1;
1626 :
1627 :
1628 : /*---------------------------------------------------.
1629 : | yyerrorlab -- error raised explicitly by YYERROR. |
1630 : `---------------------------------------------------*/
1631 : yyerrorlab:
1632 : /* Pacify compilers when the user code never invokes YYERROR and the
1633 : label yyerrorlab therefore never appears in user code. */
1634 : if (0)
1635 : YYERROR;
1636 :
1637 : /* Do not reclaim the symbols of the rule whose action triggered
1638 : this YYERROR. */
1639 : YYPOPSTACK (yylen);
1640 : yylen = 0;
1641 : YY_STACK_PRINT (yyss, yyssp);
1642 : yystate = *yyssp;
1643 : goto yyerrlab1;
1644 :
1645 :
1646 : /*-------------------------------------------------------------.
1647 : | yyerrlab1 -- common code for both syntax error and YYERROR. |
1648 : `-------------------------------------------------------------*/
1649 0 : yyerrlab1:
1650 0 : yyerrstatus = 3; /* Each real token shifted decrements this. */
1651 :
1652 : /* Pop stack until we find a state that shifts the error token. */
1653 : for (;;)
1654 : {
1655 0 : yyn = yypact[yystate];
1656 0 : if (!yypact_value_is_default (yyn))
1657 : {
1658 0 : yyn += YYSYMBOL_YYerror;
1659 0 : if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYSYMBOL_YYerror)
1660 : {
1661 0 : yyn = yytable[yyn];
1662 0 : if (0 < yyn)
1663 0 : break;
1664 : }
1665 : }
1666 :
1667 : /* Pop the current state because it cannot handle the error token. */
1668 0 : if (yyssp == yyss)
1669 0 : YYABORT;
1670 :
1671 :
1672 0 : yydestruct ("Error: popping",
1673 0 : YY_ACCESSING_SYMBOL (yystate), yyvsp, expr_parse_result_p, yyscanner);
1674 0 : YYPOPSTACK (1);
1675 0 : yystate = *yyssp;
1676 : YY_STACK_PRINT (yyss, yyssp);
1677 : }
1678 :
1679 : YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
1680 0 : *++yyvsp = yylval;
1681 : YY_IGNORE_MAYBE_UNINITIALIZED_END
1682 :
1683 :
1684 : /* Shift the error token. */
1685 : YY_SYMBOL_PRINT ("Shifting", YY_ACCESSING_SYMBOL (yyn), yyvsp, yylsp);
1686 :
1687 0 : yystate = yyn;
1688 0 : goto yynewstate;
1689 :
1690 :
1691 : /*-------------------------------------.
1692 : | yyacceptlab -- YYACCEPT comes here. |
1693 : `-------------------------------------*/
1694 756 : yyacceptlab:
1695 756 : yyresult = 0;
1696 756 : goto yyreturn;
1697 :
1698 :
1699 : /*-----------------------------------.
1700 : | yyabortlab -- YYABORT comes here. |
1701 : `-----------------------------------*/
1702 0 : yyabortlab:
1703 0 : yyresult = 1;
1704 0 : goto yyreturn;
1705 :
1706 :
1707 : #if !defined yyoverflow
1708 : /*-------------------------------------------------.
1709 : | yyexhaustedlab -- memory exhaustion comes here. |
1710 : `-------------------------------------------------*/
1711 0 : yyexhaustedlab:
1712 0 : yyerror (expr_parse_result_p, yyscanner, YY_("memory exhausted"));
1713 : yyresult = 2;
1714 : goto yyreturn;
1715 : #endif
1716 :
1717 :
1718 : /*-------------------------------------------------------.
1719 : | yyreturn -- parsing is finished, clean up and return. |
1720 : `-------------------------------------------------------*/
1721 756 : yyreturn:
1722 756 : if (yychar != YYEMPTY)
1723 : {
1724 : /* Make sure we have latest lookahead translation. See comments at
1725 : user semantic actions for why this is necessary. */
1726 0 : yytoken = YYTRANSLATE (yychar);
1727 0 : yydestruct ("Cleanup: discarding lookahead",
1728 : yytoken, &yylval, expr_parse_result_p, yyscanner);
1729 : }
1730 : /* Do not reclaim the symbols of the rule whose action triggered
1731 : this YYABORT or YYACCEPT. */
1732 756 : YYPOPSTACK (yylen);
1733 : YY_STACK_PRINT (yyss, yyssp);
1734 2268 : while (yyssp != yyss)
1735 : {
1736 1512 : yydestruct ("Cleanup: popping",
1737 1512 : YY_ACCESSING_SYMBOL (+*yyssp), yyvsp, expr_parse_result_p, yyscanner);
1738 1512 : YYPOPSTACK (1);
1739 : }
1740 : #ifndef yyoverflow
1741 756 : if (yyss != yyssa)
1742 0 : YYSTACK_FREE (yyss);
1743 : #endif
1744 :
1745 756 : return yyresult;
1746 : }
1747 :
1748 : #line 165 "exprparse.y"
1749 :
1750 :
1751 : static PgBenchExpr *
1752 : make_null_constant(void)
1753 : {
1754 : PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr));
1755 :
1756 : expr->etype = ENODE_CONSTANT;
1757 : expr->u.constant.type = PGBT_NULL;
1758 : expr->u.constant.u.ival = 0;
1759 : return expr;
1760 : }
1761 :
1762 : static PgBenchExpr *
1763 : make_integer_constant(int64 ival)
1764 : {
1765 : PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr));
1766 :
1767 : expr->etype = ENODE_CONSTANT;
1768 : expr->u.constant.type = PGBT_INT;
1769 : expr->u.constant.u.ival = ival;
1770 : return expr;
1771 : }
1772 :
1773 : static PgBenchExpr *
1774 : make_double_constant(double dval)
1775 : {
1776 : PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr));
1777 :
1778 : expr->etype = ENODE_CONSTANT;
1779 : expr->u.constant.type = PGBT_DOUBLE;
1780 : expr->u.constant.u.dval = dval;
1781 : return expr;
1782 : }
1783 :
1784 : static PgBenchExpr *
1785 : make_boolean_constant(bool bval)
1786 : {
1787 : PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr));
1788 :
1789 : expr->etype = ENODE_CONSTANT;
1790 : expr->u.constant.type = PGBT_BOOLEAN;
1791 : expr->u.constant.u.bval = bval;
1792 : return expr;
1793 : }
1794 :
1795 : static PgBenchExpr *
1796 : make_variable(char *varname)
1797 : {
1798 : PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr));
1799 :
1800 : expr->etype = ENODE_VARIABLE;
1801 : expr->u.variable.varname = varname;
1802 : return expr;
1803 : }
1804 :
1805 : /* binary operators */
1806 : static PgBenchExpr *
1807 : make_op(yyscan_t yyscanner, const char *operator,
1808 : PgBenchExpr *lexpr, PgBenchExpr *rexpr)
1809 : {
1810 : return make_func(yyscanner, find_func(yyscanner, operator),
1811 : make_elist(rexpr, make_elist(lexpr, NULL)));
1812 : }
1813 :
1814 : /* unary operator */
1815 : static PgBenchExpr *
1816 : make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr)
1817 : {
1818 : return make_func(yyscanner, find_func(yyscanner, operator), make_elist(expr, NULL));
1819 : }
1820 :
1821 : /*
1822 : * List of available functions:
1823 : * - fname: function name, "!..." for special internal functions
1824 : * - nargs: number of arguments. Special cases:
1825 : * - PGBENCH_NARGS_VARIABLE is a special value for least & greatest
1826 : * meaning #args >= 1;
1827 : * - PGBENCH_NARGS_CASE is for the "CASE WHEN ..." function, which
1828 : * has #args >= 3 and odd;
1829 : * - PGBENCH_NARGS_HASH is for hash functions, which have one required
1830 : * and one optional argument;
1831 : * - tag: function identifier from PgBenchFunction enum
1832 : */
1833 : static const struct
1834 : {
1835 : const char *fname;
1836 : int nargs;
1837 : PgBenchFunction tag;
1838 : } PGBENCH_FUNCTIONS[] =
1839 :
1840 : {
1841 : /* parsed as operators, executed as functions */
1842 : {
1843 : "+", 2, PGBENCH_ADD
1844 : },
1845 : {
1846 : "-", 2, PGBENCH_SUB
1847 : },
1848 : {
1849 : "*", 2, PGBENCH_MUL
1850 : },
1851 : {
1852 : "/", 2, PGBENCH_DIV
1853 : },
1854 : {
1855 : "mod", 2, PGBENCH_MOD
1856 : },
1857 : /* actual functions */
1858 : {
1859 : "abs", 1, PGBENCH_ABS
1860 : },
1861 : {
1862 : "least", PGBENCH_NARGS_VARIABLE, PGBENCH_LEAST
1863 : },
1864 : {
1865 : "greatest", PGBENCH_NARGS_VARIABLE, PGBENCH_GREATEST
1866 : },
1867 : {
1868 : "debug", 1, PGBENCH_DEBUG
1869 : },
1870 : {
1871 : "pi", 0, PGBENCH_PI
1872 : },
1873 : {
1874 : "sqrt", 1, PGBENCH_SQRT
1875 : },
1876 : {
1877 : "ln", 1, PGBENCH_LN
1878 : },
1879 : {
1880 : "exp", 1, PGBENCH_EXP
1881 : },
1882 : {
1883 : "int", 1, PGBENCH_INT
1884 : },
1885 : {
1886 : "double", 1, PGBENCH_DOUBLE
1887 : },
1888 : {
1889 : "random", 2, PGBENCH_RANDOM
1890 : },
1891 : {
1892 : "random_gaussian", 3, PGBENCH_RANDOM_GAUSSIAN
1893 : },
1894 : {
1895 : "random_exponential", 3, PGBENCH_RANDOM_EXPONENTIAL
1896 : },
1897 : {
1898 : "random_zipfian", 3, PGBENCH_RANDOM_ZIPFIAN
1899 : },
1900 : {
1901 : "pow", 2, PGBENCH_POW
1902 : },
1903 : {
1904 : "power", 2, PGBENCH_POW
1905 : },
1906 : /* logical operators */
1907 : {
1908 : "!and", 2, PGBENCH_AND
1909 : },
1910 : {
1911 : "!or", 2, PGBENCH_OR
1912 : },
1913 : {
1914 : "!not", 1, PGBENCH_NOT
1915 : },
1916 : /* bitwise integer operators */
1917 : {
1918 : "&", 2, PGBENCH_BITAND
1919 : },
1920 : {
1921 : "|", 2, PGBENCH_BITOR
1922 : },
1923 : {
1924 : "#", 2, PGBENCH_BITXOR
1925 : },
1926 : {
1927 : "<<", 2, PGBENCH_LSHIFT
1928 : },
1929 : {
1930 : ">>", 2, PGBENCH_RSHIFT
1931 : },
1932 : /* comparison operators */
1933 : {
1934 : "=", 2, PGBENCH_EQ
1935 : },
1936 : {
1937 : "<>", 2, PGBENCH_NE
1938 : },
1939 : {
1940 : "<=", 2, PGBENCH_LE
1941 : },
1942 : {
1943 : "<", 2, PGBENCH_LT
1944 : },
1945 : {
1946 : "!is", 2, PGBENCH_IS
1947 : },
1948 : /* "case when ... then ... else ... end" construction */
1949 : {
1950 : "!case_end", PGBENCH_NARGS_CASE, PGBENCH_CASE
1951 : },
1952 : {
1953 : "hash", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2
1954 : },
1955 : {
1956 : "hash_murmur2", PGBENCH_NARGS_HASH, PGBENCH_HASH_MURMUR2
1957 : },
1958 : {
1959 : "hash_fnv1a", PGBENCH_NARGS_HASH, PGBENCH_HASH_FNV1A
1960 : },
1961 : {
1962 : "permute", PGBENCH_NARGS_PERMUTE, PGBENCH_PERMUTE
1963 : },
1964 : /* keep as last array element */
1965 : {
1966 : NULL, 0, 0
1967 : }
1968 : };
1969 :
1970 : /*
1971 : * Find a function from its name
1972 : *
1973 : * return the index of the function from the PGBENCH_FUNCTIONS array
1974 : * or fail if the function is unknown.
1975 : */
1976 : static int
1977 : find_func(yyscan_t yyscanner, const char *fname)
1978 : {
1979 : int i = 0;
1980 :
1981 : while (PGBENCH_FUNCTIONS[i].fname)
1982 : {
1983 : if (pg_strcasecmp(fname, PGBENCH_FUNCTIONS[i].fname) == 0)
1984 : return i;
1985 : i++;
1986 : }
1987 :
1988 : expr_yyerror_more(yyscanner, "unexpected function name", fname);
1989 :
1990 : /* not reached */
1991 : return -1;
1992 : }
1993 :
1994 : /* Expression linked list builder */
1995 : static PgBenchExprList *
1996 : make_elist(PgBenchExpr *expr, PgBenchExprList *list)
1997 : {
1998 : PgBenchExprLink *cons;
1999 :
2000 : if (list == NULL)
2001 : {
2002 : list = pg_malloc(sizeof(PgBenchExprList));
2003 : list->head = NULL;
2004 : list->tail = NULL;
2005 : }
2006 :
2007 : cons = pg_malloc(sizeof(PgBenchExprLink));
2008 : cons->expr = expr;
2009 : cons->next = NULL;
2010 :
2011 : if (list->head == NULL)
2012 : list->head = cons;
2013 : else
2014 : list->tail->next = cons;
2015 :
2016 : list->tail = cons;
2017 :
2018 : return list;
2019 : }
2020 :
2021 : /* Return the length of an expression list */
2022 : static int
2023 : elist_length(PgBenchExprList *list)
2024 : {
2025 : PgBenchExprLink *link = list != NULL ? list->head : NULL;
2026 : int len = 0;
2027 :
2028 : for (; link != NULL; link = link->next)
2029 : len++;
2030 :
2031 : return len;
2032 : }
2033 :
2034 : /* Build function call expression */
2035 : static PgBenchExpr *
2036 : make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args)
2037 : {
2038 : int len = elist_length(args);
2039 :
2040 : PgBenchExpr *expr = pg_malloc(sizeof(PgBenchExpr));
2041 :
2042 : Assert(fnumber >= 0);
2043 :
2044 : /* validate arguments number including few special cases */
2045 : switch (PGBENCH_FUNCTIONS[fnumber].nargs)
2046 : {
2047 : /* check at least one arg for least & greatest */
2048 : case PGBENCH_NARGS_VARIABLE:
2049 : if (len == 0)
2050 : expr_yyerror_more(yyscanner, "at least one argument expected",
2051 : PGBENCH_FUNCTIONS[fnumber].fname);
2052 : break;
2053 :
2054 : /* case (when ... then ...)+ (else ...)? end */
2055 : case PGBENCH_NARGS_CASE:
2056 : /* 'else' branch is always present, but could be a NULL-constant */
2057 : if (len < 3 || len % 2 != 1)
2058 : expr_yyerror_more(yyscanner,
2059 : "odd and >= 3 number of arguments expected",
2060 : "case control structure");
2061 : break;
2062 :
2063 : /* hash functions with optional seed argument */
2064 : case PGBENCH_NARGS_HASH:
2065 : if (len < 1 || len > 2)
2066 : expr_yyerror_more(yyscanner, "unexpected number of arguments",
2067 : PGBENCH_FUNCTIONS[fnumber].fname);
2068 :
2069 : if (len == 1)
2070 : {
2071 : PgBenchExpr *var = make_variable("default_seed");
2072 :
2073 : args = make_elist(var, args);
2074 : }
2075 : break;
2076 :
2077 : /* pseudorandom permutation function with optional seed argument */
2078 : case PGBENCH_NARGS_PERMUTE:
2079 : if (len < 2 || len > 3)
2080 : expr_yyerror_more(yyscanner, "unexpected number of arguments",
2081 : PGBENCH_FUNCTIONS[fnumber].fname);
2082 :
2083 : if (len == 2)
2084 : {
2085 : PgBenchExpr *var = make_variable("default_seed");
2086 :
2087 : args = make_elist(var, args);
2088 : }
2089 : break;
2090 :
2091 : /* common case: positive arguments number */
2092 : default:
2093 : Assert(PGBENCH_FUNCTIONS[fnumber].nargs >= 0);
2094 :
2095 : if (PGBENCH_FUNCTIONS[fnumber].nargs != len)
2096 : expr_yyerror_more(yyscanner, "unexpected number of arguments",
2097 : PGBENCH_FUNCTIONS[fnumber].fname);
2098 : }
2099 :
2100 : expr->etype = ENODE_FUNCTION;
2101 : expr->u.function.function = PGBENCH_FUNCTIONS[fnumber].tag;
2102 :
2103 : /* only the link is used, the head/tail is not useful anymore */
2104 : expr->u.function.args = args != NULL ? args->head : NULL;
2105 : if (args)
2106 : pg_free(args);
2107 :
2108 : return expr;
2109 : }
2110 :
2111 : static PgBenchExpr *
2112 : make_case(yyscan_t yyscanner, PgBenchExprList *when_then_list, PgBenchExpr *else_part)
2113 : {
2114 : return make_func(yyscanner,
2115 : find_func(yyscanner, "!case_end"),
2116 : make_elist(else_part, when_then_list));
2117 : }
|