1
/* A Bison parser, made by GNU Bison 1.875. */
3
/* Skeleton parser for Yacc-like parsing with Bison,
4
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
6
This program is free software; you can redistribute it and/or modify
2
/* A Bison parser, made by GNU Bison 2.4.1. */
4
/* Skeleton implementation for Bison's Yacc-like parsers in C
6
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
7
Free Software Foundation, Inc.
9
This program is free software: you can redistribute it and/or modify
7
10
it under the terms of the GNU General Public License as published by
8
the Free Software Foundation; either version 2, or (at your option)
11
the Free Software Foundation, either version 3 of the License, or
12
(at your option) any later version.
11
14
This program is distributed in the hope that it will be useful,
12
15
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
16
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
17
GNU General Public License for more details.
16
19
You should have received a copy of the GNU General Public License
17
along with this program; if not, write to the Free Software
18
Foundation, Inc., 59 Temple Place - Suite 330,
19
Boston, MA 02111-1307, USA. */
21
/* As a special exception, when this file is copied by Bison into a
22
Bison output file, you may use that output file without restriction.
23
This special exception was added by the Free Software Foundation
24
in version 1.24 of Bison. */
26
/* Written by Richard Stallman by simplifying the original so called
27
``semantic'' parser. */
20
along with this program. If not, see <http://www.gnu.org/licenses/>. */
22
/* As a special exception, you may create a larger work that contains
23
part or all of the Bison parser skeleton and distribute that work
24
under terms of your choice, so long as that work isn't itself a
25
parser generator using the skeleton or a modified version thereof
26
as a parser skeleton. Alternatively, if you modify or redistribute
27
the parser skeleton itself, you may (at your option) remove this
28
special exception, which will cause the skeleton and the resulting
29
Bison output files to be licensed under the GNU General Public
30
License without this special exception.
32
This special exception was added by the Free Software Foundation in
33
version 2.2 of Bison. */
35
/* C LALR(1) parser skeleton written by Richard Stallman, by
36
simplifying the original so-called "semantic" parser. */
29
38
/* All symbols defined below should begin with yy or YY, to avoid
30
39
infringing on user name space. This should be done even for local
36
45
/* Identify Bison output. */
49
#define YYBISON_VERSION "2.4.1"
39
51
/* Skeleton name. */
40
52
#define YYSKELETON_NAME "yacc.c"
42
54
/* Pure parsers. */
45
63
/* Using locations. */
46
64
#define YYLSP_NEEDED 1
48
/* If NAME_PREFIX is specified substitute the variables and functions
50
#define yyparse plpgsql_yyparse
51
#define yylex plpgsql_yylex
52
#define yyerror plpgsql_yyerror
53
#define yylval plpgsql_yylval
54
#define yychar plpgsql_yychar
55
#define yydebug plpgsql_yydebug
56
#define yynerrs plpgsql_yynerrs
57
#define yylloc plpgsql_yylloc
66
/* Substitute the variable and function names. */
67
#define yyparse plpgsql_yyparse
68
#define yylex plpgsql_yylex
69
#define yyerror plpgsql_yyerror
70
#define yylval plpgsql_yylval
71
#define yychar plpgsql_yychar
72
#define yydebug plpgsql_yydebug
73
#define yynerrs plpgsql_yynerrs
74
#define yylloc plpgsql_yylloc
76
/* Copy the first part of user declarations. */
78
/* Line 189 of yacc.c */
81
/*-------------------------------------------------------------------------
83
* gram.y - Parser for the PL/pgSQL procedural language
85
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
86
* Portions Copyright (c) 1994, Regents of the University of California
90
* src/pl/plpgsql/src/gram.y
92
*-------------------------------------------------------------------------
97
#include "catalog/namespace.h"
98
#include "catalog/pg_type.h"
99
#include "parser/parser.h"
100
#include "parser/parse_type.h"
101
#include "parser/scanner.h"
102
#include "parser/scansup.h"
103
#include "utils/builtins.h"
106
/* Location tracking support --- simpler than bison's default */
107
#define YYLLOC_DEFAULT(Current, Rhs, N) \
110
(Current) = (Rhs)[1]; \
112
(Current) = (Rhs)[0]; \
116
* Bison doesn't allocate anything that needs to live across parser calls,
117
* so we can easily have it use palloc instead of malloc. This prevents
118
* memory leaks if we error out during parsing. Note this only works with
119
* bison >= 2.0. However, in bison 1.875 the default is to use alloca()
120
* if possible, so there's not really much problem anyhow, at least if
121
* you're building with gcc.
123
#define YYMALLOC palloc
131
} sql_error_callback_arg;
133
#define parser_errposition(pos) plpgsql_scanner_errposition(pos)
135
union YYSTYPE; /* need forward reference for tok_is_keyword */
137
static bool tok_is_keyword(int token, union YYSTYPE *lval,
138
int kw_token, const char *kw_str);
139
static void word_is_not_variable(PLword *word, int location);
140
static void cword_is_not_variable(PLcword *cword, int location);
141
static void current_token_is_not_variable(int tok);
142
static PLpgSQL_expr *read_sql_construct(int until,
145
const char *expected,
146
const char *sqlstart,
151
static PLpgSQL_expr *read_sql_expression(int until,
152
const char *expected);
153
static PLpgSQL_expr *read_sql_expression2(int until, int until2,
154
const char *expected,
156
static PLpgSQL_expr *read_sql_stmt(const char *sqlstart);
157
static PLpgSQL_type *read_datatype(int tok);
158
static PLpgSQL_stmt *make_execsql_stmt(int firsttoken, int location);
159
static PLpgSQL_stmt_fetch *read_fetch_direction(void);
160
static void complete_direction(PLpgSQL_stmt_fetch *fetch,
162
static PLpgSQL_stmt *make_return_stmt(int location);
163
static PLpgSQL_stmt *make_return_next_stmt(int location);
164
static PLpgSQL_stmt *make_return_query_stmt(int location);
165
static PLpgSQL_stmt *make_case(int location, PLpgSQL_expr *t_expr,
166
List *case_when_list, List *else_stmts);
167
static char *NameOfDatum(PLwdatum *wdatum);
168
static void check_assignable(PLpgSQL_datum *datum, int location);
169
static void read_into_target(PLpgSQL_rec **rec, PLpgSQL_row **row,
171
static PLpgSQL_row *read_into_scalar_list(char *initial_name,
172
PLpgSQL_datum *initial_datum,
173
int initial_location);
174
static PLpgSQL_row *make_scalar_list1(char *initial_name,
175
PLpgSQL_datum *initial_datum,
176
int lineno, int location);
177
static void check_sql_expr(const char *stmt, int location,
179
static void plpgsql_sql_error_callback(void *arg);
180
static PLpgSQL_type *parse_datatype(const char *string, int location);
181
static void check_labels(const char *start_label,
182
const char *end_label,
184
static PLpgSQL_expr *read_cursor_args(PLpgSQL_var *cursor,
185
int until, const char *expected);
186
static List *read_raise_options(void);
190
/* Line 189 of yacc.c */
191
#line 192 "pl_gram.c"
193
/* Enabling traces. */
198
/* Enabling verbose error messages. */
199
#ifdef YYERROR_VERBOSE
200
# undef YYERROR_VERBOSE
201
# define YYERROR_VERBOSE 1
203
# define YYERROR_VERBOSE 0
206
/* Enabling the token table. */
207
#ifndef YYTOKEN_TABLE
208
# define YYTOKEN_TABLE 0
60
213
#ifndef YYTOKENTYPE
171
#define COLON_EQUALS 268
175
#define LESS_LESS 272
176
#define GREATER_GREATER 273
177
#define K_ABSOLUTE 274
181
#define K_BACKWARD 278
186
#define K_COLLATE 283
187
#define K_CONSTANT 284
188
#define K_CONTINUE 285
191
#define K_DECLARE 288
192
#define K_DEFAULT 289
194
#define K_DIAGNOSTICS 291
199
#define K_ERRCODE 296
201
#define K_EXCEPTION 298
202
#define K_EXECUTE 299
207
#define K_FOREACH 304
208
#define K_FORWARD 305
221
#define K_MESSAGE 318
231
#define K_PERFORM 328
235
#define K_RELATIVE 332
236
#define K_RESULT_OID 333
238
#define K_REVERSE 335
239
#define K_ROWTYPE 336
240
#define K_ROW_COUNT 337
243
#define K_SQLSTATE 340
248
#define K_USE_COLUMN 345
249
#define K_USE_VARIABLE 346
251
#define K_VARIABLE_CONFLICT 348
252
#define K_WARNING 349
259
/* Copy the first part of user declarations. */
262
/*-------------------------------------------------------------------------
264
* gram.y - Parser for the PL/pgSQL procedural language
266
* Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
267
* Portions Copyright (c) 1994, Regents of the University of California
271
* src/pl/plpgsql/src/gram.y
273
*-------------------------------------------------------------------------
278
#include "catalog/namespace.h"
279
#include "catalog/pg_type.h"
280
#include "parser/parser.h"
281
#include "parser/parse_type.h"
282
#include "parser/scanner.h"
283
#include "parser/scansup.h"
284
#include "utils/builtins.h"
287
/* Location tracking support --- simpler than bison's default */
288
#define YYLLOC_DEFAULT(Current, Rhs, N) \
291
(Current) = (Rhs)[1]; \
293
(Current) = (Rhs)[0]; \
297
* Bison doesn't allocate anything that needs to live across parser calls,
298
* so we can easily have it use palloc instead of malloc. This prevents
299
* memory leaks if we error out during parsing. Note this only works with
300
* bison >= 2.0. However, in bison 1.875 the default is to use alloca()
301
* if possible, so there's not really much problem anyhow, at least if
302
* you're building with gcc.
304
#define YYMALLOC palloc
317
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
318
typedef union YYSTYPE
312
} sql_error_callback_arg;
314
#define parser_errposition(pos) plpgsql_scanner_errposition(pos)
316
union YYSTYPE; /* need forward reference for tok_is_keyword */
318
static bool tok_is_keyword(int token, union YYSTYPE *lval,
319
int kw_token, const char *kw_str);
320
static void word_is_not_variable(PLword *word, int location);
321
static void cword_is_not_variable(PLcword *cword, int location);
322
static void current_token_is_not_variable(int tok);
323
static PLpgSQL_expr *read_sql_construct(int until,
326
const char *expected,
327
const char *sqlstart,
332
static PLpgSQL_expr *read_sql_expression(int until,
333
const char *expected);
334
static PLpgSQL_expr *read_sql_expression2(int until, int until2,
335
const char *expected,
337
static PLpgSQL_expr *read_sql_stmt(const char *sqlstart);
338
static PLpgSQL_type *read_datatype(int tok);
339
static PLpgSQL_stmt *make_execsql_stmt(int firsttoken, int location);
340
static PLpgSQL_stmt_fetch *read_fetch_direction(void);
341
static void complete_direction(PLpgSQL_stmt_fetch *fetch,
343
static PLpgSQL_stmt *make_return_stmt(int location);
344
static PLpgSQL_stmt *make_return_next_stmt(int location);
345
static PLpgSQL_stmt *make_return_query_stmt(int location);
346
static PLpgSQL_stmt *make_case(int location, PLpgSQL_expr *t_expr,
347
List *case_when_list, List *else_stmts);
348
static char *NameOfDatum(PLwdatum *wdatum);
349
static void check_assignable(PLpgSQL_datum *datum, int location);
350
static void read_into_target(PLpgSQL_rec **rec, PLpgSQL_row **row,
352
static PLpgSQL_row *read_into_scalar_list(char *initial_name,
353
PLpgSQL_datum *initial_datum,
354
int initial_location);
355
static PLpgSQL_row *make_scalar_list1(char *initial_name,
356
PLpgSQL_datum *initial_datum,
357
int lineno, int location);
358
static void check_sql_expr(const char *stmt, int location,
360
static void plpgsql_sql_error_callback(void *arg);
361
static PLpgSQL_type *parse_datatype(const char *string, int location);
362
static void check_labels(const char *start_label,
363
const char *end_label,
365
static PLpgSQL_expr *read_cursor_args(PLpgSQL_var *cursor,
366
int until, const char *expected);
367
static List *read_raise_options(void);
371
/* Enabling traces. */
376
/* Enabling verbose error messages. */
377
#ifdef YYERROR_VERBOSE
378
# undef YYERROR_VERBOSE
379
# define YYERROR_VERBOSE 1
381
# define YYERROR_VERBOSE 0
384
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
321
/* Line 214 of yacc.c */
385
322
#line 115 "gram.y"
386
typedef union YYSTYPE {
387
324
core_YYSTYPE core_yystype;
388
325
/* these fields must match core_YYSTYPE: */
458
398
/* Copy the second part of user declarations. */
461
/* Line 214 of yacc.c. */
462
#line 462 "pl_gram.c"
464
#if ! defined (yyoverflow) || YYERROR_VERBOSE
401
/* Line 264 of yacc.c */
402
#line 403 "pl_gram.c"
409
typedef YYTYPE_UINT8 yytype_uint8;
411
typedef unsigned char yytype_uint8;
415
typedef YYTYPE_INT8 yytype_int8;
416
#elif (defined __STDC__ || defined __C99__FUNC__ \
417
|| defined __cplusplus || defined _MSC_VER)
418
typedef signed char yytype_int8;
420
typedef short int yytype_int8;
424
typedef YYTYPE_UINT16 yytype_uint16;
426
typedef unsigned short int yytype_uint16;
430
typedef YYTYPE_INT16 yytype_int16;
432
typedef short int yytype_int16;
436
# ifdef __SIZE_TYPE__
437
# define YYSIZE_T __SIZE_TYPE__
438
# elif defined size_t
439
# define YYSIZE_T size_t
440
# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
441
|| defined __cplusplus || defined _MSC_VER)
442
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
443
# define YYSIZE_T size_t
445
# define YYSIZE_T unsigned int
449
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
454
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
455
# define YY_(msgid) dgettext ("bison-runtime", msgid)
459
# define YY_(msgid) msgid
463
/* Suppress unused-variable warnings by "using" E. */
464
#if ! defined lint || defined __GNUC__
465
# define YYUSE(e) ((void) (e))
467
# define YYUSE(e) /* empty */
470
/* Identity function, used to suppress warnings about constant conditions. */
474
#if (defined __STDC__ || defined __C99__FUNC__ \
475
|| defined __cplusplus || defined _MSC_VER)
488
#if ! defined yyoverflow || YYERROR_VERBOSE
466
490
/* The parser invokes alloca or malloc; define the necessary symbols. */
468
# if YYSTACK_USE_ALLOCA
469
# define YYSTACK_ALLOC alloca
471
# ifndef YYSTACK_USE_ALLOCA
472
# if defined (alloca) || defined (_ALLOCA_H)
492
# ifdef YYSTACK_USE_ALLOCA
493
# if YYSTACK_USE_ALLOCA
495
# define YYSTACK_ALLOC __builtin_alloca
496
# elif defined __BUILTIN_VA_ARG_INCR
497
# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
499
# define YYSTACK_ALLOC __alloca
500
# elif defined _MSC_VER
501
# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
502
# define alloca _alloca
473
504
# define YYSTACK_ALLOC alloca
476
# define YYSTACK_ALLOC __builtin_alloca
505
# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
506
|| defined __cplusplus || defined _MSC_VER)
507
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
482
516
# ifdef YYSTACK_ALLOC
483
/* Pacify GCC's `empty if-body' warning. */
484
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
517
/* Pacify GCC's `empty if-body' warning. */
518
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
519
# ifndef YYSTACK_ALLOC_MAXIMUM
520
/* The OS might guarantee only one guard page at the bottom of the stack,
521
and a page size can be as small as 4096 bytes. So we cannot safely
522
invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
523
to allow for a few compiler-allocated temporary stack slots. */
524
# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
486
# if defined (__STDC__) || defined (__cplusplus)
527
# define YYSTACK_ALLOC YYMALLOC
528
# define YYSTACK_FREE YYFREE
529
# ifndef YYSTACK_ALLOC_MAXIMUM
530
# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
532
# if (defined __cplusplus && ! defined _STDLIB_H \
533
&& ! ((defined YYMALLOC || defined malloc) \
534
&& (defined YYFREE || defined free)))
487
535
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
488
# define YYSIZE_T size_t
490
# define YYSTACK_ALLOC malloc
491
# define YYSTACK_FREE free
541
# define YYMALLOC malloc
542
# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
543
|| defined __cplusplus || defined _MSC_VER)
544
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
549
# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
550
|| defined __cplusplus || defined _MSC_VER)
551
void free (void *); /* INFRINGES ON USER NAME SPACE */
493
#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
496
#if (! defined (yyoverflow) \
497
&& (! defined (__cplusplus) \
498
|| (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
555
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
558
#if (! defined yyoverflow \
559
&& (! defined __cplusplus \
560
|| (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
561
&& defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
500
563
/* A type that is properly aligned for any stack member. */
566
yytype_int16 yyss_alloc;
508
571
/* The size of the maximum gap between one aligned stack and the next. */
725
#if YYDEBUG || YYERROR_VERBOSE
726
/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
727
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
782
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
783
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
784
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
728
785
static const char *const yytname[] =
730
"$end", "error", "$undefined", "IDENT", "FCONST", "SCONST", "BCONST",
731
"XCONST", "Op", "ICONST", "PARAM", "TYPECAST", "DOT_DOT",
732
"COLON_EQUALS", "T_WORD", "T_CWORD", "T_DATUM", "LESS_LESS",
733
"GREATER_GREATER", "K_ABSOLUTE", "K_ALIAS", "K_ALL", "K_ARRAY",
734
"K_BACKWARD", "K_BEGIN", "K_BY", "K_CASE", "K_CLOSE", "K_COLLATE",
735
"K_CONSTANT", "K_CONTINUE", "K_CURSOR", "K_DEBUG", "K_DECLARE",
736
"K_DEFAULT", "K_DETAIL", "K_DIAGNOSTICS", "K_DUMP", "K_ELSE", "K_ELSIF",
737
"K_END", "K_ERRCODE", "K_ERROR", "K_EXCEPTION", "K_EXECUTE", "K_EXIT",
738
"K_FETCH", "K_FIRST", "K_FOR", "K_FOREACH", "K_FORWARD", "K_FROM",
739
"K_GET", "K_HINT", "K_IF", "K_IN", "K_INFO", "K_INSERT", "K_INTO",
740
"K_IS", "K_LAST", "K_LOG", "K_LOOP", "K_MESSAGE", "K_MOVE", "K_NEXT",
741
"K_NO", "K_NOT", "K_NOTICE", "K_NULL", "K_OPEN", "K_OPTION", "K_OR",
742
"K_PERFORM", "K_PRIOR", "K_QUERY", "K_RAISE", "K_RELATIVE",
743
"K_RESULT_OID", "K_RETURN", "K_REVERSE", "K_ROWTYPE", "K_ROW_COUNT",
744
"K_SCROLL", "K_SLICE", "K_SQLSTATE", "K_STRICT", "K_THEN", "K_TO",
745
"K_TYPE", "K_USE_COLUMN", "K_USE_VARIABLE", "K_USING",
746
"K_VARIABLE_CONFLICT", "K_WARNING", "K_WHEN", "K_WHILE", "'#'", "';'",
747
"'('", "')'", "','", "'='", "'['", "$accept", "pl_function",
748
"comp_options", "comp_option", "opt_semi", "pl_block", "decl_sect",
749
"decl_start", "decl_stmts", "decl_stmt", "decl_statement", "@1",
750
"opt_scrollable", "decl_cursor_query", "decl_cursor_args",
751
"decl_cursor_arglist", "decl_cursor_arg", "decl_is_for",
752
"decl_aliasitem", "decl_varname", "decl_const", "decl_datatype",
753
"decl_collate", "decl_notnull", "decl_defval", "decl_defkey",
754
"assign_operator", "proc_sect", "proc_stmts", "proc_stmt",
755
"stmt_perform", "stmt_assign", "stmt_getdiag", "getdiag_list",
756
"getdiag_list_item", "getdiag_item", "getdiag_target", "assign_var",
757
"stmt_if", "stmt_else", "stmt_case", "opt_expr_until_when",
758
"case_when_list", "case_when", "opt_case_else", "stmt_loop",
759
"stmt_while", "stmt_for", "for_control", "for_variable",
760
"stmt_foreach_a", "foreach_slice", "stmt_exit", "exit_type",
761
"stmt_return", "stmt_raise", "loop_body", "stmt_execsql",
762
"stmt_dynexecute", "stmt_open", "stmt_fetch", "stmt_move",
763
"opt_fetch_direction", "stmt_close", "stmt_null", "cursor_variable",
764
"exception_sect", "@2", "proc_exceptions", "proc_exception",
765
"proc_conditions", "proc_condition", "expr_until_semi",
766
"expr_until_rightbracket", "expr_until_then", "expr_until_loop",
767
"opt_block_label", "opt_label", "opt_exitcond", "any_identifier",
787
"$end", "error", "$undefined", "IDENT", "FCONST", "SCONST", "BCONST",
788
"XCONST", "Op", "ICONST", "PARAM", "TYPECAST", "DOT_DOT", "COLON_EQUALS",
789
"T_WORD", "T_CWORD", "T_DATUM", "LESS_LESS", "GREATER_GREATER",
790
"K_ABSOLUTE", "K_ALIAS", "K_ALL", "K_ARRAY", "K_BACKWARD", "K_BEGIN",
791
"K_BY", "K_CASE", "K_CLOSE", "K_COLLATE", "K_CONSTANT", "K_CONTINUE",
792
"K_CURSOR", "K_DEBUG", "K_DECLARE", "K_DEFAULT", "K_DETAIL",
793
"K_DIAGNOSTICS", "K_DUMP", "K_ELSE", "K_ELSIF", "K_END", "K_ERRCODE",
794
"K_ERROR", "K_EXCEPTION", "K_EXECUTE", "K_EXIT", "K_FETCH", "K_FIRST",
795
"K_FOR", "K_FOREACH", "K_FORWARD", "K_FROM", "K_GET", "K_HINT", "K_IF",
796
"K_IN", "K_INFO", "K_INSERT", "K_INTO", "K_IS", "K_LAST", "K_LOG",
797
"K_LOOP", "K_MESSAGE", "K_MOVE", "K_NEXT", "K_NO", "K_NOT", "K_NOTICE",
798
"K_NULL", "K_OPEN", "K_OPTION", "K_OR", "K_PERFORM", "K_PRIOR",
799
"K_QUERY", "K_RAISE", "K_RELATIVE", "K_RESULT_OID", "K_RETURN",
800
"K_REVERSE", "K_ROWTYPE", "K_ROW_COUNT", "K_SCROLL", "K_SLICE",
801
"K_SQLSTATE", "K_STRICT", "K_THEN", "K_TO", "K_TYPE", "K_USE_COLUMN",
802
"K_USE_VARIABLE", "K_USING", "K_VARIABLE_CONFLICT", "K_WARNING",
803
"K_WHEN", "K_WHILE", "'#'", "';'", "'('", "')'", "','", "'='", "'['",
804
"$accept", "pl_function", "comp_options", "comp_option", "opt_semi",
805
"pl_block", "decl_sect", "decl_start", "decl_stmts", "decl_stmt",
806
"decl_statement", "$@1", "opt_scrollable", "decl_cursor_query",
807
"decl_cursor_args", "decl_cursor_arglist", "decl_cursor_arg",
808
"decl_is_for", "decl_aliasitem", "decl_varname", "decl_const",
809
"decl_datatype", "decl_collate", "decl_notnull", "decl_defval",
810
"decl_defkey", "assign_operator", "proc_sect", "proc_stmts", "proc_stmt",
811
"stmt_perform", "stmt_assign", "stmt_getdiag", "getdiag_list",
812
"getdiag_list_item", "getdiag_item", "getdiag_target", "assign_var",
813
"stmt_if", "stmt_else", "stmt_case", "opt_expr_until_when",
814
"case_when_list", "case_when", "opt_case_else", "stmt_loop",
815
"stmt_while", "stmt_for", "for_control", "for_variable",
816
"stmt_foreach_a", "foreach_slice", "stmt_exit", "exit_type",
817
"stmt_return", "stmt_raise", "loop_body", "stmt_execsql",
818
"stmt_dynexecute", "stmt_open", "stmt_fetch", "stmt_move",
819
"opt_fetch_direction", "stmt_close", "stmt_null", "cursor_variable",
820
"exception_sect", "@2", "proc_exceptions", "proc_exception",
821
"proc_conditions", "proc_condition", "expr_until_semi",
822
"expr_until_rightbracket", "expr_until_then", "expr_until_loop",
823
"opt_block_label", "opt_label", "opt_exitcond", "any_identifier",
768
824
"unreserved_keyword", 0
1176
1250
YYFPRINTF Args; \
1179
# define YYDSYMPRINT(Args) \
1185
# define YYDSYMPRINTF(Title, Token, Value, Location) \
1189
YYFPRINTF (stderr, "%s ", Title); \
1190
yysymprint (stderr, \
1191
Token, Value, Location); \
1192
YYFPRINTF (stderr, "\n"); \
1253
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1257
YYFPRINTF (stderr, "%s ", Title); \
1258
yy_symbol_print (stderr, \
1259
Type, Value, Location); \
1260
YYFPRINTF (stderr, "\n"); \
1265
/*--------------------------------.
1266
| Print this symbol on YYOUTPUT. |
1267
`--------------------------------*/
1270
#if (defined __STDC__ || defined __C99__FUNC__ \
1271
|| defined __cplusplus || defined _MSC_VER)
1273
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
1276
yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp)
1279
YYSTYPE const * const yyvaluep;
1280
YYLTYPE const * const yylocationp;
1285
YYUSE (yylocationp);
1287
if (yytype < YYNTOKENS)
1288
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1300
/*--------------------------------.
1301
| Print this symbol on YYOUTPUT. |
1302
`--------------------------------*/
1304
#if (defined __STDC__ || defined __C99__FUNC__ \
1305
|| defined __cplusplus || defined _MSC_VER)
1307
yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
1310
yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp)
1313
YYSTYPE const * const yyvaluep;
1314
YYLTYPE const * const yylocationp;
1317
if (yytype < YYNTOKENS)
1318
YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1320
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1322
YY_LOCATION_PRINT (yyoutput, *yylocationp);
1323
YYFPRINTF (yyoutput, ": ");
1324
yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp);
1325
YYFPRINTF (yyoutput, ")");
1196
1328
/*------------------------------------------------------------------.
1197
1329
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
1199
1331
`------------------------------------------------------------------*/
1201
#if defined (__STDC__) || defined (__cplusplus)
1333
#if (defined __STDC__ || defined __C99__FUNC__ \
1334
|| defined __cplusplus || defined _MSC_VER)
1203
yy_stack_print (short *bottom, short *top)
1336
yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1206
yy_stack_print (bottom, top)
1339
yy_stack_print (yybottom, yytop)
1340
yytype_int16 *yybottom;
1341
yytype_int16 *yytop;
1211
1344
YYFPRINTF (stderr, "Stack now");
1212
for (/* Nothing. */; bottom <= top; ++bottom)
1213
YYFPRINTF (stderr, " %d", *bottom);
1345
for (; yybottom <= yytop; yybottom++)
1347
int yybot = *yybottom;
1348
YYFPRINTF (stderr, " %d", yybot);
1214
1350
YYFPRINTF (stderr, "\n");
1220
1356
yy_stack_print ((Bottom), (Top)); \
1224
1360
/*------------------------------------------------.
1225
1361
| Report that the YYRULE is going to be reduced. |
1226
1362
`------------------------------------------------*/
1228
#if defined (__STDC__) || defined (__cplusplus)
1364
#if (defined __STDC__ || defined __C99__FUNC__ \
1365
|| defined __cplusplus || defined _MSC_VER)
1230
yy_reduce_print (int yyrule)
1367
yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule)
1233
yy_reduce_print (yyrule)
1370
yy_reduce_print (yyvsp, yylsp, yyrule)
1376
int yynrhs = yyr2[yyrule];
1238
unsigned int yylineno = yyrline[yyrule];
1239
YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
1240
yyrule - 1, yylineno);
1241
/* Print the symbols being reduced, and their result. */
1242
for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
1243
YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
1244
YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
1378
unsigned long int yylno = yyrline[yyrule];
1379
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1381
/* The symbols being reduced. */
1382
for (yyi = 0; yyi < yynrhs; yyi++)
1384
YYFPRINTF (stderr, " $%d = ", yyi + 1);
1385
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1386
&(yyvsp[(yyi + 1) - (yynrhs)])
1387
, &(yylsp[(yyi + 1) - (yynrhs)]) );
1388
YYFPRINTF (stderr, "\n");
1247
1392
# define YY_REDUCE_PRINT(Rule) \
1250
yy_reduce_print (Rule); \
1395
yy_reduce_print (yyvsp, yylsp, Rule); \
1253
1398
/* Nonzero means print parse trace. It is left uninitialized so that
1254
1399
multiple parsers can coexist. */
1256
1401
#else /* !YYDEBUG */
1257
1402
# define YYDPRINTF(Args)
1258
# define YYDSYMPRINT(Args)
1259
# define YYDSYMPRINTF(Title, Token, Value, Location)
1403
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1260
1404
# define YY_STACK_PRINT(Bottom, Top)
1261
1405
# define YY_REDUCE_PRINT(Rule)
1262
1406
#endif /* !YYDEBUG */
1338
#endif /* !YYERROR_VERBOSE */
1481
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1482
quotes and backslashes, so that it's suitable for yyerror. The
1483
heuristic is that double-quoting is unnecessary unless the string
1484
contains an apostrophe, a comma, or backslash (other than
1485
backslash-backslash). YYSTR is taken from yytname. If YYRES is
1486
null, do not copy; instead, return the length of what the result
1489
yytnamerr (char *yyres, const char *yystr)
1494
char const *yyp = yystr;
1501
goto do_not_strip_quotes;
1505
goto do_not_strip_quotes;
1518
do_not_strip_quotes: ;
1522
return yystrlen (yystr);
1524
return yystpcpy (yyres, yystr) - yyres;
1528
/* Copy into YYRESULT an error message about the unexpected token
1529
YYCHAR while in state YYSTATE. Return the number of bytes copied,
1530
including the terminating null byte. If YYRESULT is null, do not
1531
copy anything; just return the number of bytes that would be
1532
copied. As a special case, return 0 if an ordinary "syntax error"
1533
message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1534
size calculation. */
1536
yysyntax_error (char *yyresult, int yystate, int yychar)
1538
int yyn = yypact[yystate];
1540
if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1544
int yytype = YYTRANSLATE (yychar);
1545
YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1546
YYSIZE_T yysize = yysize0;
1548
int yysize_overflow = 0;
1549
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1550
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1554
/* This is so xgettext sees the translatable formats that are
1555
constructed on the fly. */
1556
YY_("syntax error, unexpected %s");
1557
YY_("syntax error, unexpected %s, expecting %s");
1558
YY_("syntax error, unexpected %s, expecting %s or %s");
1559
YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1560
YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1564
static char const yyunexpected[] = "syntax error, unexpected %s";
1565
static char const yyexpecting[] = ", expecting %s";
1566
static char const yyor[] = " or %s";
1567
char yyformat[sizeof yyunexpected
1568
+ sizeof yyexpecting - 1
1569
+ ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1570
* (sizeof yyor - 1))];
1571
char const *yyprefix = yyexpecting;
1573
/* Start YYX at -YYN if negative to avoid negative indexes in
1575
int yyxbegin = yyn < 0 ? -yyn : 0;
1577
/* Stay within bounds of both yycheck and yytname. */
1578
int yychecklim = YYLAST - yyn + 1;
1579
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1582
yyarg[0] = yytname[yytype];
1583
yyfmt = yystpcpy (yyformat, yyunexpected);
1585
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1586
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1588
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1592
yyformat[sizeof yyunexpected - 1] = '\0';
1595
yyarg[yycount++] = yytname[yyx];
1596
yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1597
yysize_overflow |= (yysize1 < yysize);
1599
yyfmt = yystpcpy (yyfmt, yyprefix);
1603
yyf = YY_(yyformat);
1604
yysize1 = yysize + yystrlen (yyf);
1605
yysize_overflow |= (yysize1 < yysize);
1608
if (yysize_overflow)
1609
return YYSIZE_MAXIMUM;
1613
/* Avoid sprintf, as that infringes on the user's name space.
1614
Don't have undefined behavior even if the translation
1615
produced a string with the wrong number of "%s"s. */
1616
char *yyp = yyresult;
1618
while ((*yyp = *yyf) != '\0')
1620
if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1622
yyp += yytnamerr (yyp, yyarg[yyi++]);
1635
#endif /* YYERROR_VERBOSE */
1343
/*--------------------------------.
1344
| Print this symbol on YYOUTPUT. |
1345
`--------------------------------*/
1347
#if defined (__STDC__) || defined (__cplusplus)
1349
yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
1352
yysymprint (yyoutput, yytype, yyvaluep, yylocationp)
1356
YYLTYPE *yylocationp;
1359
/* Pacify ``unused variable'' warnings. */
1363
if (yytype < YYNTOKENS)
1365
YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1367
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1371
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1378
YYFPRINTF (yyoutput, ")");
1381
#endif /* ! YYDEBUG */
1382
1638
/*-----------------------------------------------.
1383
1639
| Release the memory associated to this symbol. |
1384
1640
`-----------------------------------------------*/
1386
#if defined (__STDC__) || defined (__cplusplus)
1643
#if (defined __STDC__ || defined __C99__FUNC__ \
1644
|| defined __cplusplus || defined _MSC_VER)
1388
yydestruct (int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
1646
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
1391
yydestruct (yytype, yyvaluep, yylocationp)
1649
yydestruct (yymsg, yytype, yyvaluep, yylocationp)
1393
1652
YYSTYPE *yyvaluep;
1394
1653
YYLTYPE *yylocationp;
1397
/* Pacify ``unused variable'' warnings. */
1657
YYUSE (yylocationp);
1661
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1401
1663
switch (yytype)
1410
1671
/* Prevent warnings from -Wmissing-prototypes. */
1412
1672
#ifdef YYPARSE_PARAM
1413
# if defined (__STDC__) || defined (__cplusplus)
1673
#if defined __STDC__ || defined __cplusplus
1414
1674
int yyparse (void *YYPARSE_PARAM);
1416
1676
int yyparse ();
1418
1678
#else /* ! YYPARSE_PARAM */
1419
#if defined (__STDC__) || defined (__cplusplus)
1679
#if defined __STDC__ || defined __cplusplus
1420
1680
int yyparse (void);
1422
1682
int yyparse ();
1464
register int yystate;
1730
/* Number of tokens to shift before error messages enabled. */
1733
/* The stacks and their tools:
1734
`yyss': related to states.
1735
`yyvs': related to semantic values.
1736
`yyls': related to locations.
1738
Refer to the stacks thru separate pointers, to allow yyoverflow
1739
to reallocate them elsewhere. */
1741
/* The state stack. */
1742
yytype_int16 yyssa[YYINITDEPTH];
1744
yytype_int16 *yyssp;
1746
/* The semantic value stack. */
1747
YYSTYPE yyvsa[YYINITDEPTH];
1751
/* The location stack. */
1752
YYLTYPE yylsa[YYINITDEPTH];
1756
/* The locations where the error started and ended. */
1757
YYLTYPE yyerror_range[2];
1759
YYSIZE_T yystacksize;
1467
/* Number of tokens to shift before error messages enabled. */
1469
1763
/* Lookahead token as an internal (translated) token number. */
1472
/* Three stacks and their tools:
1473
`yyss': related to states,
1474
`yyvs': related to semantic values,
1475
`yyls': related to locations.
1477
Refer to the stacks thru separate pointers, to allow yyoverflow
1478
to reallocate them elsewhere. */
1480
/* The state stack. */
1481
short yyssa[YYINITDEPTH];
1482
short *yyss = yyssa;
1483
register short *yyssp;
1485
/* The semantic value stack. */
1486
YYSTYPE yyvsa[YYINITDEPTH];
1487
YYSTYPE *yyvs = yyvsa;
1488
register YYSTYPE *yyvsp;
1490
/* The location stack. */
1491
YYLTYPE yylsa[YYINITDEPTH];
1492
YYLTYPE *yyls = yylsa;
1496
#define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
1498
YYSIZE_T yystacksize = YYINITDEPTH;
1500
1765
/* The variables used to return semantic value and location from the
1501
1766
action routines. */
1505
/* When reducing, the number of symbols on the RHS of the reduced
1771
/* Buffer for error messages, and its allocated size. */
1773
char *yymsg = yymsgbuf;
1774
YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1777
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
1779
/* The number of symbols on the RHS of the reduced rule.
1780
Keep to zero when no symbol should be popped. */
1787
yystacksize = YYINITDEPTH;
1509
1789
YYDPRINTF ((stderr, "Starting parse\n"));
1512
1792
yyerrstatus = 0;
1514
yychar = YYEMPTY; /* Cause a token to be read. */
1794
yychar = YYEMPTY; /* Cause a token to be read. */
1516
1796
/* Initialize stack pointers.
1517
1797
Waste one element of value and location stack
1518
1798
so that they stay on the same level as the state stack.
1519
1799
The wasted elements are never initialized. */
1804
#if YYLTYPE_IS_TRIVIAL
1805
/* Initialize the default location before parsing starts. */
1806
yylloc.first_line = yylloc.last_line = 1;
1807
yylloc.first_column = yylloc.last_column = 1;
1524
1810
goto yysetstate;
1526
1812
/*------------------------------------------------------------.
1840
2148
* a freshly built struct not shared with other
1843
if (OidIsValid(yyvsp[-2].oid))
2151
if (OidIsValid((yyvsp[(4) - (6)].oid)))
1845
if (!OidIsValid(yyvsp[-3].dtype->collation))
2153
if (!OidIsValid((yyvsp[(3) - (6)].dtype)->collation))
1847
2155
(errcode(ERRCODE_DATATYPE_MISMATCH),
1848
2156
errmsg("collations are not supported by type %s",
1849
format_type_be(yyvsp[-3].dtype->typoid)),
1850
parser_errposition(yylsp[-2])));
1851
yyvsp[-3].dtype->collation = yyvsp[-2].oid;
2157
format_type_be((yyvsp[(3) - (6)].dtype)->typoid)),
2158
parser_errposition((yylsp[(4) - (6)]))));
2159
(yyvsp[(3) - (6)].dtype)->collation = (yyvsp[(4) - (6)].oid);
1854
var = plpgsql_build_variable(yyvsp[-5].varname.name, yyvsp[-5].varname.lineno,
1855
yyvsp[-3].dtype, true);
1856
if (yyvsp[-4].boolean)
2162
var = plpgsql_build_variable((yyvsp[(1) - (6)].varname).name, (yyvsp[(1) - (6)].varname).lineno,
2163
(yyvsp[(3) - (6)].dtype), true);
2164
if ((yyvsp[(2) - (6)].boolean))
1858
2166
if (var->dtype == PLPGSQL_DTYPE_VAR)
1859
((PLpgSQL_var *) var)->isconst = yyvsp[-4].boolean;
2167
((PLpgSQL_var *) var)->isconst = (yyvsp[(2) - (6)].boolean);
1862
2170
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1863
2171
errmsg("row or record variable cannot be CONSTANT"),
1864
parser_errposition(yylsp[-4])));
2172
parser_errposition((yylsp[(2) - (6)]))));
1866
if (yyvsp[-1].boolean)
2174
if ((yyvsp[(5) - (6)].boolean))
1868
2176
if (var->dtype == PLPGSQL_DTYPE_VAR)
1869
((PLpgSQL_var *) var)->notnull = yyvsp[-1].boolean;
2177
((PLpgSQL_var *) var)->notnull = (yyvsp[(5) - (6)].boolean);
1872
2180
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1873
2181
errmsg("row or record variable cannot be NOT NULL"),
1874
parser_errposition(yylsp[-2])));
2182
parser_errposition((yylsp[(4) - (6)]))));
1877
if (yyvsp[0].expr != NULL)
2185
if ((yyvsp[(6) - (6)].expr) != NULL)
1879
2187
if (var->dtype == PLPGSQL_DTYPE_VAR)
1880
((PLpgSQL_var *) var)->default_val = yyvsp[0].expr;
2188
((PLpgSQL_var *) var)->default_val = (yyvsp[(6) - (6)].expr);
1883
2191
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1884
2192
errmsg("default value for row or record variable is not supported"),
1885
parser_errposition(yylsp[-1])));
2193
parser_errposition((yylsp[(5) - (6)]))));
2200
/* Line 1455 of yacc.c */
1891
2201
#line 491 "gram.y"
1893
plpgsql_ns_additem(yyvsp[-1].nsitem->itemtype,
1894
yyvsp[-1].nsitem->itemno, yyvsp[-4].varname.name);
2203
plpgsql_ns_additem((yyvsp[(4) - (5)].nsitem)->itemtype,
2204
(yyvsp[(4) - (5)].nsitem)->itemno, (yyvsp[(1) - (5)].varname).name);
2210
/* Line 1455 of yacc.c */
1899
2211
#line 496 "gram.y"
1900
{ plpgsql_ns_push(yyvsp[-2].varname.name); ;}
2212
{ plpgsql_ns_push((yyvsp[(1) - (3)].varname).name); ;}
2217
/* Line 1455 of yacc.c */
1904
2218
#line 498 "gram.y"
1906
2220
PLpgSQL_var *new;
1996
2322
new = palloc0(sizeof(PLpgSQL_row));
1997
2323
new->dtype = PLPGSQL_DTYPE_ROW;
1998
new->lineno = plpgsql_location_to_lineno(yylsp[-2]);
2324
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (3)]));
1999
2325
new->rowtupdesc = NULL;
2000
new->nfields = list_length(yyvsp[-1].list);
2326
new->nfields = list_length((yyvsp[(2) - (3)].list));
2001
2327
new->fieldnames = palloc(new->nfields * sizeof(char *));
2002
2328
new->varnos = palloc(new->nfields * sizeof(int));
2005
foreach (l, yyvsp[-1].list)
2331
foreach (l, (yyvsp[(2) - (3)].list))
2007
2333
PLpgSQL_variable *arg = (PLpgSQL_variable *) lfirst(l);
2008
2334
new->fieldnames[i] = arg->refname;
2009
2335
new->varnos[i] = arg->dno;
2012
list_free(yyvsp[-1].list);
2338
list_free((yyvsp[(2) - (3)].list));
2014
2340
plpgsql_adddatum((PLpgSQL_datum *) new);
2015
yyval.datum = (PLpgSQL_datum *) new;
2341
(yyval.datum) = (PLpgSQL_datum *) new;
2347
/* Line 1455 of yacc.c */
2020
2348
#line 601 "gram.y"
2022
yyval.list = list_make1(yyvsp[0].datum);
2350
(yyval.list) = list_make1((yyvsp[(1) - (1)].datum));
2356
/* Line 1455 of yacc.c */
2027
2357
#line 605 "gram.y"
2029
yyval.list = lappend(yyvsp[-2].list, yyvsp[0].datum);
2359
(yyval.list) = lappend((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].datum));
2365
/* Line 1455 of yacc.c */
2034
2366
#line 611 "gram.y"
2036
yyval.datum = (PLpgSQL_datum *)
2037
plpgsql_build_variable(yyvsp[-1].varname.name, yyvsp[-1].varname.lineno,
2038
yyvsp[0].dtype, true);
2368
(yyval.datum) = (PLpgSQL_datum *)
2369
plpgsql_build_variable((yyvsp[(1) - (2)].varname).name, (yyvsp[(1) - (2)].varname).lineno,
2370
(yyvsp[(2) - (2)].dtype), true);
2376
/* Line 1455 of yacc.c */
2043
2377
#line 622 "gram.y"
2045
2379
PLpgSQL_nsitem *nsi;
2047
2381
nsi = plpgsql_ns_lookup(plpgsql_ns_top(), false,
2048
yyvsp[0].word.ident, NULL, NULL,
2382
(yyvsp[(1) - (1)].word).ident, NULL, NULL,
2050
2384
if (nsi == NULL)
2052
2386
(errcode(ERRCODE_UNDEFINED_OBJECT),
2053
2387
errmsg("variable \"%s\" does not exist",
2054
yyvsp[0].word.ident),
2055
parser_errposition(yylsp[0])));
2388
(yyvsp[(1) - (1)].word).ident),
2389
parser_errposition((yylsp[(1) - (1)]))));
2390
(yyval.nsitem) = nsi;
2396
/* Line 1455 of yacc.c */
2061
2397
#line 637 "gram.y"
2063
2399
PLpgSQL_nsitem *nsi;
2065
if (list_length(yyvsp[0].cword.idents) == 2)
2401
if (list_length((yyvsp[(1) - (1)].cword).idents) == 2)
2066
2402
nsi = plpgsql_ns_lookup(plpgsql_ns_top(), false,
2067
strVal(linitial(yyvsp[0].cword.idents)),
2068
strVal(lsecond(yyvsp[0].cword.idents)),
2403
strVal(linitial((yyvsp[(1) - (1)].cword).idents)),
2404
strVal(lsecond((yyvsp[(1) - (1)].cword).idents)),
2071
else if (list_length(yyvsp[0].cword.idents) == 3)
2407
else if (list_length((yyvsp[(1) - (1)].cword).idents) == 3)
2072
2408
nsi = plpgsql_ns_lookup(plpgsql_ns_top(), false,
2073
strVal(linitial(yyvsp[0].cword.idents)),
2074
strVal(lsecond(yyvsp[0].cword.idents)),
2075
strVal(lthird(yyvsp[0].cword.idents)),
2409
strVal(linitial((yyvsp[(1) - (1)].cword).idents)),
2410
strVal(lsecond((yyvsp[(1) - (1)].cword).idents)),
2411
strVal(lthird((yyvsp[(1) - (1)].cword).idents)),
2081
2417
(errcode(ERRCODE_UNDEFINED_OBJECT),
2082
2418
errmsg("variable \"%s\" does not exist",
2083
NameListToString(yyvsp[0].cword.idents)),
2084
parser_errposition(yylsp[0])));
2419
NameListToString((yyvsp[(1) - (1)].cword).idents)),
2420
parser_errposition((yylsp[(1) - (1)]))));
2421
(yyval.nsitem) = nsi;
2427
/* Line 1455 of yacc.c */
2090
2428
#line 665 "gram.y"
2092
yyval.varname.name = yyvsp[0].word.ident;
2093
yyval.varname.lineno = plpgsql_location_to_lineno(yylsp[0]);
2430
(yyval.varname).name = (yyvsp[(1) - (1)].word).ident;
2431
(yyval.varname).lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]));
2095
2433
* Check to make sure name isn't already declared
2096
2434
* in the current block.
2098
2436
if (plpgsql_ns_lookup(plpgsql_ns_top(), true,
2099
yyvsp[0].word.ident, NULL, NULL,
2437
(yyvsp[(1) - (1)].word).ident, NULL, NULL,
2101
2439
yyerror("duplicate declaration");
2445
/* Line 1455 of yacc.c */
2106
2446
#line 678 "gram.y"
2108
yyval.varname.name = pstrdup(yyvsp[0].keyword);
2109
yyval.varname.lineno = plpgsql_location_to_lineno(yylsp[0]);
2448
(yyval.varname).name = pstrdup((yyvsp[(1) - (1)].keyword));
2449
(yyval.varname).lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]));
2111
2451
* Check to make sure name isn't already declared
2112
2452
* in the current block.
2114
2454
if (plpgsql_ns_lookup(plpgsql_ns_top(), true,
2115
yyvsp[0].keyword, NULL, NULL,
2455
(yyvsp[(1) - (1)].keyword), NULL, NULL,
2117
2457
yyerror("duplicate declaration");
2463
/* Line 1455 of yacc.c */
2122
2464
#line 693 "gram.y"
2123
{ yyval.boolean = false; ;}
2465
{ (yyval.boolean) = false; ;}
2470
/* Line 1455 of yacc.c */
2127
2471
#line 695 "gram.y"
2128
{ yyval.boolean = true; ;}
2472
{ (yyval.boolean) = true; ;}
2477
/* Line 1455 of yacc.c */
2132
2478
#line 699 "gram.y"
2135
2481
* If there's a lookahead token, read_datatype
2136
2482
* should consume it.
2138
yyval.dtype = read_datatype(yychar);
2484
(yyval.dtype) = read_datatype(yychar);
2491
/* Line 1455 of yacc.c */
2144
2492
#line 710 "gram.y"
2145
{ yyval.oid = InvalidOid; ;}
2493
{ (yyval.oid) = InvalidOid; ;}
2498
/* Line 1455 of yacc.c */
2149
2499
#line 712 "gram.y"
2151
yyval.oid = get_collation_oid(list_make1(makeString(yyvsp[0].word.ident)),
2501
(yyval.oid) = get_collation_oid(list_make1(makeString((yyvsp[(2) - (2)].word).ident)),
2508
/* Line 1455 of yacc.c */
2157
2509
#line 717 "gram.y"
2159
yyval.oid = get_collation_oid(yyvsp[0].cword.idents, false);
2511
(yyval.oid) = get_collation_oid((yyvsp[(2) - (2)].cword).idents, false);
2517
/* Line 1455 of yacc.c */
2164
2518
#line 723 "gram.y"
2165
{ yyval.boolean = false; ;}
2519
{ (yyval.boolean) = false; ;}
2524
/* Line 1455 of yacc.c */
2169
2525
#line 725 "gram.y"
2170
{ yyval.boolean = true; ;}
2526
{ (yyval.boolean) = true; ;}
2531
/* Line 1455 of yacc.c */
2174
2532
#line 729 "gram.y"
2175
{ yyval.expr = NULL; ;}
2533
{ (yyval.expr) = NULL; ;}
2538
/* Line 1455 of yacc.c */
2179
2539
#line 731 "gram.y"
2181
yyval.expr = read_sql_expression(';', ";");
2541
(yyval.expr) = read_sql_expression(';', ";");
2547
/* Line 1455 of yacc.c */
2186
2548
#line 745 "gram.y"
2187
{ yyval.list = NIL; ;}
2549
{ (yyval.list) = NIL; ;}
2554
/* Line 1455 of yacc.c */
2191
2555
#line 747 "gram.y"
2192
{ yyval.list = yyvsp[0].list; ;}
2556
{ (yyval.list) = (yyvsp[(1) - (1)].list); ;}
2561
/* Line 1455 of yacc.c */
2196
2562
#line 751 "gram.y"
2198
if (yyvsp[0].stmt == NULL)
2199
yyval.list = yyvsp[-1].list;
2564
if ((yyvsp[(2) - (2)].stmt) == NULL)
2565
(yyval.list) = (yyvsp[(1) - (2)].list);
2201
yyval.list = lappend(yyvsp[-1].list, yyvsp[0].stmt);
2567
(yyval.list) = lappend((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].stmt));
2573
/* Line 1455 of yacc.c */
2206
2574
#line 758 "gram.y"
2208
if (yyvsp[0].stmt == NULL)
2576
if ((yyvsp[(1) - (1)].stmt) == NULL)
2211
yyval.list = list_make1(yyvsp[0].stmt);
2579
(yyval.list) = list_make1((yyvsp[(1) - (1)].stmt));
2585
/* Line 1455 of yacc.c */
2216
2586
#line 767 "gram.y"
2217
{ yyval.stmt = yyvsp[-1].stmt; ;}
2587
{ (yyval.stmt) = (yyvsp[(1) - (2)].stmt); ;}
2592
/* Line 1455 of yacc.c */
2221
2593
#line 769 "gram.y"
2222
{ yyval.stmt = yyvsp[0].stmt; ;}
2594
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2599
/* Line 1455 of yacc.c */
2226
2600
#line 771 "gram.y"
2227
{ yyval.stmt = yyvsp[0].stmt; ;}
2601
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2606
/* Line 1455 of yacc.c */
2231
2607
#line 773 "gram.y"
2232
{ yyval.stmt = yyvsp[0].stmt; ;}
2608
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2613
/* Line 1455 of yacc.c */
2236
2614
#line 775 "gram.y"
2237
{ yyval.stmt = yyvsp[0].stmt; ;}
2615
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2620
/* Line 1455 of yacc.c */
2241
2621
#line 777 "gram.y"
2242
{ yyval.stmt = yyvsp[0].stmt; ;}
2622
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2627
/* Line 1455 of yacc.c */
2246
2628
#line 779 "gram.y"
2247
{ yyval.stmt = yyvsp[0].stmt; ;}
2629
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2634
/* Line 1455 of yacc.c */
2251
2635
#line 781 "gram.y"
2252
{ yyval.stmt = yyvsp[0].stmt; ;}
2636
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2641
/* Line 1455 of yacc.c */
2256
2642
#line 783 "gram.y"
2257
{ yyval.stmt = yyvsp[0].stmt; ;}
2643
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2648
/* Line 1455 of yacc.c */
2261
2649
#line 785 "gram.y"
2262
{ yyval.stmt = yyvsp[0].stmt; ;}
2650
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2655
/* Line 1455 of yacc.c */
2266
2656
#line 787 "gram.y"
2267
{ yyval.stmt = yyvsp[0].stmt; ;}
2657
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2662
/* Line 1455 of yacc.c */
2271
2663
#line 789 "gram.y"
2272
{ yyval.stmt = yyvsp[0].stmt; ;}
2664
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2669
/* Line 1455 of yacc.c */
2276
2670
#line 791 "gram.y"
2277
{ yyval.stmt = yyvsp[0].stmt; ;}
2671
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2676
/* Line 1455 of yacc.c */
2281
2677
#line 793 "gram.y"
2282
{ yyval.stmt = yyvsp[0].stmt; ;}
2678
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2683
/* Line 1455 of yacc.c */
2286
2684
#line 795 "gram.y"
2287
{ yyval.stmt = yyvsp[0].stmt; ;}
2685
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2690
/* Line 1455 of yacc.c */
2291
2691
#line 797 "gram.y"
2292
{ yyval.stmt = yyvsp[0].stmt; ;}
2692
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2697
/* Line 1455 of yacc.c */
2296
2698
#line 799 "gram.y"
2297
{ yyval.stmt = yyvsp[0].stmt; ;}
2699
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2704
/* Line 1455 of yacc.c */
2301
2705
#line 801 "gram.y"
2302
{ yyval.stmt = yyvsp[0].stmt; ;}
2706
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2711
/* Line 1455 of yacc.c */
2306
2712
#line 803 "gram.y"
2307
{ yyval.stmt = yyvsp[0].stmt; ;}
2713
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2718
/* Line 1455 of yacc.c */
2311
2719
#line 805 "gram.y"
2312
{ yyval.stmt = yyvsp[0].stmt; ;}
2720
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2725
/* Line 1455 of yacc.c */
2316
2726
#line 809 "gram.y"
2318
2728
PLpgSQL_stmt_perform *new;
2320
2730
new = palloc0(sizeof(PLpgSQL_stmt_perform));
2321
2731
new->cmd_type = PLPGSQL_STMT_PERFORM;
2322
new->lineno = plpgsql_location_to_lineno(yylsp[-1]);
2323
new->expr = yyvsp[0].expr;
2732
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (2)]));
2733
new->expr = (yyvsp[(2) - (2)].expr);
2325
yyval.stmt = (PLpgSQL_stmt *)new;
2735
(yyval.stmt) = (PLpgSQL_stmt *)new;
2741
/* Line 1455 of yacc.c */
2330
2742
#line 822 "gram.y"
2332
2744
PLpgSQL_stmt_assign *new;
2334
2746
new = palloc0(sizeof(PLpgSQL_stmt_assign));
2335
2747
new->cmd_type = PLPGSQL_STMT_ASSIGN;
2336
new->lineno = plpgsql_location_to_lineno(yylsp[-2]);
2337
new->varno = yyvsp[-2].ival;
2338
new->expr = yyvsp[0].expr;
2748
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (3)]));
2749
new->varno = (yyvsp[(1) - (3)].ival);
2750
new->expr = (yyvsp[(3) - (3)].expr);
2340
yyval.stmt = (PLpgSQL_stmt *)new;
2752
(yyval.stmt) = (PLpgSQL_stmt *)new;
2758
/* Line 1455 of yacc.c */
2345
2759
#line 836 "gram.y"
2347
2761
PLpgSQL_stmt_getdiag *new;
2349
2763
new = palloc0(sizeof(PLpgSQL_stmt_getdiag));
2350
2764
new->cmd_type = PLPGSQL_STMT_GETDIAG;
2351
new->lineno = plpgsql_location_to_lineno(yylsp[-3]);
2352
new->diag_items = yyvsp[-1].list;
2765
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (4)]));
2766
new->diag_items = (yyvsp[(3) - (4)].list);
2354
yyval.stmt = (PLpgSQL_stmt *)new;
2768
(yyval.stmt) = (PLpgSQL_stmt *)new;
2774
/* Line 1455 of yacc.c */
2359
2775
#line 849 "gram.y"
2361
yyval.list = lappend(yyvsp[-2].list, yyvsp[0].diagitem);
2777
(yyval.list) = lappend((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].diagitem));
2783
/* Line 1455 of yacc.c */
2366
2784
#line 853 "gram.y"
2368
yyval.list = list_make1(yyvsp[0].diagitem);
2786
(yyval.list) = list_make1((yyvsp[(1) - (1)].diagitem));
2792
/* Line 1455 of yacc.c */
2373
2793
#line 859 "gram.y"
2375
2795
PLpgSQL_diag_item *new;
2377
2797
new = palloc(sizeof(PLpgSQL_diag_item));
2378
new->target = yyvsp[-2].ival;
2379
new->kind = yyvsp[0].ival;
2798
new->target = (yyvsp[(1) - (3)].ival);
2799
new->kind = (yyvsp[(3) - (3)].ival);
2381
yyval.diagitem = new;
2801
(yyval.diagitem) = new;
2807
/* Line 1455 of yacc.c */
2386
2808
#line 871 "gram.y"
2388
2810
int tok = yylex();
2390
2812
if (tok_is_keyword(tok, &yylval,
2391
2813
K_ROW_COUNT, "row_count"))
2392
yyval.ival = PLPGSQL_GETDIAG_ROW_COUNT;
2814
(yyval.ival) = PLPGSQL_GETDIAG_ROW_COUNT;
2393
2815
else if (tok_is_keyword(tok, &yylval,
2394
2816
K_RESULT_OID, "result_oid"))
2395
yyval.ival = PLPGSQL_GETDIAG_RESULT_OID;
2817
(yyval.ival) = PLPGSQL_GETDIAG_RESULT_OID;
2397
2819
yyerror("unrecognized GET DIAGNOSTICS item");
2825
/* Line 1455 of yacc.c */
2402
2826
#line 886 "gram.y"
2404
check_assignable(yyvsp[0].wdatum.datum, yylsp[0]);
2405
if (yyvsp[0].wdatum.datum->dtype == PLPGSQL_DTYPE_ROW ||
2406
yyvsp[0].wdatum.datum->dtype == PLPGSQL_DTYPE_REC)
2828
check_assignable((yyvsp[(1) - (1)].wdatum).datum, (yylsp[(1) - (1)]));
2829
if ((yyvsp[(1) - (1)].wdatum).datum->dtype == PLPGSQL_DTYPE_ROW ||
2830
(yyvsp[(1) - (1)].wdatum).datum->dtype == PLPGSQL_DTYPE_REC)
2408
2832
(errcode(ERRCODE_SYNTAX_ERROR),
2409
2833
errmsg("\"%s\" is not a scalar variable",
2410
NameOfDatum(&(yyvsp[0].wdatum))),
2411
parser_errposition(yylsp[0])));
2412
yyval.ival = yyvsp[0].wdatum.datum->dno;
2834
NameOfDatum(&((yyvsp[(1) - (1)].wdatum)))),
2835
parser_errposition((yylsp[(1) - (1)]))));
2836
(yyval.ival) = (yyvsp[(1) - (1)].wdatum).datum->dno;
2842
/* Line 1455 of yacc.c */
2417
2843
#line 898 "gram.y"
2419
2845
/* just to give a better message than "syntax error" */
2420
word_is_not_variable(&(yyvsp[0].word), yylsp[0]);
2846
word_is_not_variable(&((yyvsp[(1) - (1)].word)), (yylsp[(1) - (1)]));
2852
/* Line 1455 of yacc.c */
2425
2853
#line 903 "gram.y"
2427
2855
/* just to give a better message than "syntax error" */
2428
cword_is_not_variable(&(yyvsp[0].cword), yylsp[0]);
2856
cword_is_not_variable(&((yyvsp[(1) - (1)].cword)), (yylsp[(1) - (1)]));
2862
/* Line 1455 of yacc.c */
2433
2863
#line 911 "gram.y"
2435
check_assignable(yyvsp[0].wdatum.datum, yylsp[0]);
2436
yyval.ival = yyvsp[0].wdatum.datum->dno;
2865
check_assignable((yyvsp[(1) - (1)].wdatum).datum, (yylsp[(1) - (1)]));
2866
(yyval.ival) = (yyvsp[(1) - (1)].wdatum).datum->dno;
2872
/* Line 1455 of yacc.c */
2441
2873
#line 916 "gram.y"
2443
2875
PLpgSQL_arrayelem *new;
2445
2877
new = palloc0(sizeof(PLpgSQL_arrayelem));
2446
2878
new->dtype = PLPGSQL_DTYPE_ARRAYELEM;
2447
new->subscript = yyvsp[0].expr;
2448
new->arrayparentno = yyvsp[-2].ival;
2879
new->subscript = (yyvsp[(3) - (3)].expr);
2880
new->arrayparentno = (yyvsp[(1) - (3)].ival);
2450
2882
plpgsql_adddatum((PLpgSQL_datum *) new);
2452
yyval.ival = new->dno;
2884
(yyval.ival) = new->dno;
2890
/* Line 1455 of yacc.c */
2457
2891
#line 931 "gram.y"
2459
2893
PLpgSQL_stmt_if *new;
2461
2895
new = palloc0(sizeof(PLpgSQL_stmt_if));
2462
2896
new->cmd_type = PLPGSQL_STMT_IF;
2463
new->lineno = plpgsql_location_to_lineno(yylsp[-6]);
2464
new->cond = yyvsp[-5].expr;
2465
new->true_body = yyvsp[-4].list;
2466
new->false_body = yyvsp[-3].list;
2897
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (7)]));
2898
new->cond = (yyvsp[(2) - (7)].expr);
2899
new->true_body = (yyvsp[(3) - (7)].list);
2900
new->false_body = (yyvsp[(4) - (7)].list);
2468
yyval.stmt = (PLpgSQL_stmt *)new;
2902
(yyval.stmt) = (PLpgSQL_stmt *)new;
2908
/* Line 1455 of yacc.c */
2473
2909
#line 946 "gram.y"
2917
/* Line 1455 of yacc.c */
2480
2918
#line 950 "gram.y"
2580
3034
* Simplest fix is to return a list with one NULL
2581
3035
* pointer, which make_case() must take care of.
2583
if (yyvsp[0].list != NIL)
2584
yyval.list = yyvsp[0].list;
3037
if ((yyvsp[(2) - (2)].list) != NIL)
3038
(yyval.list) = (yyvsp[(2) - (2)].list);
2586
yyval.list = list_make1(NULL);
3040
(yyval.list) = list_make1(NULL);
3046
/* Line 1455 of yacc.c */
2591
3047
#line 1047 "gram.y"
2593
3049
PLpgSQL_stmt_loop *new;
2595
3051
new = palloc0(sizeof(PLpgSQL_stmt_loop));
2596
3052
new->cmd_type = PLPGSQL_STMT_LOOP;
2597
new->lineno = plpgsql_location_to_lineno(yylsp[-1]);
2598
new->label = yyvsp[-2].str;
2599
new->body = yyvsp[0].loop_body.stmts;
3053
new->lineno = plpgsql_location_to_lineno((yylsp[(2) - (3)]));
3054
new->label = (yyvsp[(1) - (3)].str);
3055
new->body = (yyvsp[(3) - (3)].loop_body).stmts;
2601
check_labels(yyvsp[-2].str, yyvsp[0].loop_body.end_label, yyvsp[0].loop_body.end_label_location);
3057
check_labels((yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].loop_body).end_label, (yyvsp[(3) - (3)].loop_body).end_label_location);
2602
3058
plpgsql_ns_pop();
2604
yyval.stmt = (PLpgSQL_stmt *)new;
3060
(yyval.stmt) = (PLpgSQL_stmt *)new;
3066
/* Line 1455 of yacc.c */
2609
3067
#line 1064 "gram.y"
2611
3069
PLpgSQL_stmt_while *new;
2613
3071
new = palloc0(sizeof(PLpgSQL_stmt_while));
2614
3072
new->cmd_type = PLPGSQL_STMT_WHILE;
2615
new->lineno = plpgsql_location_to_lineno(yylsp[-2]);
2616
new->label = yyvsp[-3].str;
2617
new->cond = yyvsp[-1].expr;
2618
new->body = yyvsp[0].loop_body.stmts;
3073
new->lineno = plpgsql_location_to_lineno((yylsp[(2) - (4)]));
3074
new->label = (yyvsp[(1) - (4)].str);
3075
new->cond = (yyvsp[(3) - (4)].expr);
3076
new->body = (yyvsp[(4) - (4)].loop_body).stmts;
2620
check_labels(yyvsp[-3].str, yyvsp[0].loop_body.end_label, yyvsp[0].loop_body.end_label_location);
3078
check_labels((yyvsp[(1) - (4)].str), (yyvsp[(4) - (4)].loop_body).end_label, (yyvsp[(4) - (4)].loop_body).end_label_location);
2621
3079
plpgsql_ns_pop();
2623
yyval.stmt = (PLpgSQL_stmt *)new;
3081
(yyval.stmt) = (PLpgSQL_stmt *)new;
3087
/* Line 1455 of yacc.c */
2628
3088
#line 1082 "gram.y"
2630
3090
/* This runs after we've scanned the loop body */
2631
if (yyvsp[-1].stmt->cmd_type == PLPGSQL_STMT_FORI)
3091
if ((yyvsp[(3) - (4)].stmt)->cmd_type == PLPGSQL_STMT_FORI)
2633
3093
PLpgSQL_stmt_fori *new;
2635
new = (PLpgSQL_stmt_fori *) yyvsp[-1].stmt;
2636
new->lineno = plpgsql_location_to_lineno(yylsp[-2]);
2637
new->label = yyvsp[-3].str;
2638
new->body = yyvsp[0].loop_body.stmts;
2639
yyval.stmt = (PLpgSQL_stmt *) new;
3095
new = (PLpgSQL_stmt_fori *) (yyvsp[(3) - (4)].stmt);
3096
new->lineno = plpgsql_location_to_lineno((yylsp[(2) - (4)]));
3097
new->label = (yyvsp[(1) - (4)].str);
3098
new->body = (yyvsp[(4) - (4)].loop_body).stmts;
3099
(yyval.stmt) = (PLpgSQL_stmt *) new;
2643
3103
PLpgSQL_stmt_forq *new;
2645
Assert(yyvsp[-1].stmt->cmd_type == PLPGSQL_STMT_FORS ||
2646
yyvsp[-1].stmt->cmd_type == PLPGSQL_STMT_FORC ||
2647
yyvsp[-1].stmt->cmd_type == PLPGSQL_STMT_DYNFORS);
3105
Assert((yyvsp[(3) - (4)].stmt)->cmd_type == PLPGSQL_STMT_FORS ||
3106
(yyvsp[(3) - (4)].stmt)->cmd_type == PLPGSQL_STMT_FORC ||
3107
(yyvsp[(3) - (4)].stmt)->cmd_type == PLPGSQL_STMT_DYNFORS);
2648
3108
/* forq is the common supertype of all three */
2649
new = (PLpgSQL_stmt_forq *) yyvsp[-1].stmt;
2650
new->lineno = plpgsql_location_to_lineno(yylsp[-2]);
2651
new->label = yyvsp[-3].str;
2652
new->body = yyvsp[0].loop_body.stmts;
2653
yyval.stmt = (PLpgSQL_stmt *) new;
3109
new = (PLpgSQL_stmt_forq *) (yyvsp[(3) - (4)].stmt);
3110
new->lineno = plpgsql_location_to_lineno((yylsp[(2) - (4)]));
3111
new->label = (yyvsp[(1) - (4)].str);
3112
new->body = (yyvsp[(4) - (4)].loop_body).stmts;
3113
(yyval.stmt) = (PLpgSQL_stmt *) new;
2656
check_labels(yyvsp[-3].str, yyvsp[0].loop_body.end_label, yyvsp[0].loop_body.end_label_location);
3116
check_labels((yyvsp[(1) - (4)].str), (yyvsp[(4) - (4)].loop_body).end_label, (yyvsp[(4) - (4)].loop_body).end_label_location);
2657
3117
/* close namespace started in opt_block_label */
2658
3118
plpgsql_ns_pop();
3124
/* Line 1455 of yacc.c */
2663
3125
#line 1116 "gram.y"
2665
3127
int tok = yylex();
2894
3356
(errcode(ERRCODE_SYNTAX_ERROR),
2895
3357
errmsg("loop variable of loop over rows must be a record or row variable or list of scalar variables"),
2896
parser_errposition(yylsp[-1])));
3358
parser_errposition((yylsp[(1) - (2)]))));
2899
3361
new->query = expr1;
2900
yyval.stmt = (PLpgSQL_stmt *) new;
3362
(yyval.stmt) = (PLpgSQL_stmt *) new;
3370
/* Line 1455 of yacc.c */
2907
3371
#line 1377 "gram.y"
2909
yyval.forvariable.name = NameOfDatum(&(yyvsp[0].wdatum));
2910
yyval.forvariable.lineno = plpgsql_location_to_lineno(yylsp[0]);
2911
if (yyvsp[0].wdatum.datum->dtype == PLPGSQL_DTYPE_ROW)
3373
(yyval.forvariable).name = NameOfDatum(&((yyvsp[(1) - (1)].wdatum)));
3374
(yyval.forvariable).lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]));
3375
if ((yyvsp[(1) - (1)].wdatum).datum->dtype == PLPGSQL_DTYPE_ROW)
2913
yyval.forvariable.scalar = NULL;
2914
yyval.forvariable.rec = NULL;
2915
yyval.forvariable.row = (PLpgSQL_row *) yyvsp[0].wdatum.datum;
3377
(yyval.forvariable).scalar = NULL;
3378
(yyval.forvariable).rec = NULL;
3379
(yyval.forvariable).row = (PLpgSQL_row *) (yyvsp[(1) - (1)].wdatum).datum;
2917
else if (yyvsp[0].wdatum.datum->dtype == PLPGSQL_DTYPE_REC)
3381
else if ((yyvsp[(1) - (1)].wdatum).datum->dtype == PLPGSQL_DTYPE_REC)
2919
yyval.forvariable.scalar = NULL;
2920
yyval.forvariable.rec = (PLpgSQL_rec *) yyvsp[0].wdatum.datum;
2921
yyval.forvariable.row = NULL;
3383
(yyval.forvariable).scalar = NULL;
3384
(yyval.forvariable).rec = (PLpgSQL_rec *) (yyvsp[(1) - (1)].wdatum).datum;
3385
(yyval.forvariable).row = NULL;
2927
yyval.forvariable.scalar = yyvsp[0].wdatum.datum;
2928
yyval.forvariable.rec = NULL;
2929
yyval.forvariable.row = NULL;
3391
(yyval.forvariable).scalar = (yyvsp[(1) - (1)].wdatum).datum;
3392
(yyval.forvariable).rec = NULL;
3393
(yyval.forvariable).row = NULL;
2930
3394
/* check for comma-separated list */
2932
3396
plpgsql_push_back_token(tok);
2933
3397
if (tok == ',')
2934
yyval.forvariable.row = read_into_scalar_list(yyval.forvariable.name,
2935
yyval.forvariable.scalar,
3398
(yyval.forvariable).row = read_into_scalar_list((yyval.forvariable).name,
3399
(yyval.forvariable).scalar,
3400
(yylsp[(1) - (1)]));
3407
/* Line 1455 of yacc.c */
2942
3408
#line 1409 "gram.y"
2946
yyval.forvariable.name = yyvsp[0].word.ident;
2947
yyval.forvariable.lineno = plpgsql_location_to_lineno(yylsp[0]);
2948
yyval.forvariable.scalar = NULL;
2949
yyval.forvariable.rec = NULL;
2950
yyval.forvariable.row = NULL;
3412
(yyval.forvariable).name = (yyvsp[(1) - (1)].word).ident;
3413
(yyval.forvariable).lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]));
3414
(yyval.forvariable).scalar = NULL;
3415
(yyval.forvariable).rec = NULL;
3416
(yyval.forvariable).row = NULL;
2951
3417
/* check for comma-separated list */
2953
3419
plpgsql_push_back_token(tok);
2954
3420
if (tok == ',')
2955
word_is_not_variable(&(yyvsp[0].word), yylsp[0]);
3421
word_is_not_variable(&((yyvsp[(1) - (1)].word)), (yylsp[(1) - (1)]));
3427
/* Line 1455 of yacc.c */
2960
3428
#line 1424 "gram.y"
2962
3430
/* just to give a better message than "syntax error" */
2963
cword_is_not_variable(&(yyvsp[0].cword), yylsp[0]);
3431
cword_is_not_variable(&((yyvsp[(1) - (1)].cword)), (yylsp[(1) - (1)]));
3437
/* Line 1455 of yacc.c */
2968
3438
#line 1431 "gram.y"
2970
3440
PLpgSQL_stmt_foreach_a *new;
2972
3442
new = palloc0(sizeof(PLpgSQL_stmt_foreach_a));
2973
3443
new->cmd_type = PLPGSQL_STMT_FOREACH_A;
2974
new->lineno = plpgsql_location_to_lineno(yylsp[-6]);
2975
new->label = yyvsp[-7].str;
2976
new->slice = yyvsp[-4].ival;
2977
new->expr = yyvsp[-1].expr;
2978
new->body = yyvsp[0].loop_body.stmts;
3444
new->lineno = plpgsql_location_to_lineno((yylsp[(2) - (8)]));
3445
new->label = (yyvsp[(1) - (8)].str);
3446
new->slice = (yyvsp[(4) - (8)].ival);
3447
new->expr = (yyvsp[(7) - (8)].expr);
3448
new->body = (yyvsp[(8) - (8)].loop_body).stmts;
2980
if (yyvsp[-5].forvariable.rec)
2982
new->varno = yyvsp[-5].forvariable.rec->dno;
2983
check_assignable((PLpgSQL_datum *) yyvsp[-5].forvariable.rec, yylsp[-5]);
2985
else if (yyvsp[-5].forvariable.row)
2987
new->varno = yyvsp[-5].forvariable.row->dno;
2988
check_assignable((PLpgSQL_datum *) yyvsp[-5].forvariable.row, yylsp[-5]);
2990
else if (yyvsp[-5].forvariable.scalar)
2992
new->varno = yyvsp[-5].forvariable.scalar->dno;
2993
check_assignable(yyvsp[-5].forvariable.scalar, yylsp[-5]);
3450
if ((yyvsp[(3) - (8)].forvariable).rec)
3452
new->varno = (yyvsp[(3) - (8)].forvariable).rec->dno;
3453
check_assignable((PLpgSQL_datum *) (yyvsp[(3) - (8)].forvariable).rec, (yylsp[(3) - (8)]));
3455
else if ((yyvsp[(3) - (8)].forvariable).row)
3457
new->varno = (yyvsp[(3) - (8)].forvariable).row->dno;
3458
check_assignable((PLpgSQL_datum *) (yyvsp[(3) - (8)].forvariable).row, (yylsp[(3) - (8)]));
3460
else if ((yyvsp[(3) - (8)].forvariable).scalar)
3462
new->varno = (yyvsp[(3) - (8)].forvariable).scalar->dno;
3463
check_assignable((yyvsp[(3) - (8)].forvariable).scalar, (yylsp[(3) - (8)]));
2998
3468
(errcode(ERRCODE_SYNTAX_ERROR),
2999
3469
errmsg("loop variable of FOREACH must be a known variable or list of variables"),
3000
parser_errposition(yylsp[-5])));
3470
parser_errposition((yylsp[(3) - (8)]))));
3003
check_labels(yyvsp[-7].str, yyvsp[0].loop_body.end_label, yyvsp[0].loop_body.end_label_location);
3473
check_labels((yyvsp[(1) - (8)].str), (yyvsp[(8) - (8)].loop_body).end_label, (yyvsp[(8) - (8)].loop_body).end_label_location);
3004
3474
plpgsql_ns_pop();
3006
yyval.stmt = (PLpgSQL_stmt *) new;
3476
(yyval.stmt) = (PLpgSQL_stmt *) new;
3482
/* Line 1455 of yacc.c */
3011
3483
#line 1473 "gram.y"
3491
/* Line 1455 of yacc.c */
3018
3492
#line 1477 "gram.y"
3020
yyval.ival = yyvsp[0].ival;
3494
(yyval.ival) = (yyvsp[(2) - (2)].ival);
3500
/* Line 1455 of yacc.c */
3025
3501
#line 1483 "gram.y"
3027
3503
PLpgSQL_stmt_exit *new;
3029
3505
new = palloc0(sizeof(PLpgSQL_stmt_exit));
3030
3506
new->cmd_type = PLPGSQL_STMT_EXIT;
3031
new->is_exit = yyvsp[-2].boolean;
3032
new->lineno = plpgsql_location_to_lineno(yylsp[-2]);
3033
new->label = yyvsp[-1].str;
3034
new->cond = yyvsp[0].expr;
3507
new->is_exit = (yyvsp[(1) - (3)].boolean);
3508
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (3)]));
3509
new->label = (yyvsp[(2) - (3)].str);
3510
new->cond = (yyvsp[(3) - (3)].expr);
3036
yyval.stmt = (PLpgSQL_stmt *)new;
3512
(yyval.stmt) = (PLpgSQL_stmt *)new;
3518
/* Line 1455 of yacc.c */
3041
3519
#line 1498 "gram.y"
3043
yyval.boolean = true;
3521
(yyval.boolean) = true;
3527
/* Line 1455 of yacc.c */
3048
3528
#line 1502 "gram.y"
3050
yyval.boolean = false;
3530
(yyval.boolean) = false;
3536
/* Line 1455 of yacc.c */
3055
3537
#line 1508 "gram.y"
3424
3922
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3425
3923
errmsg("FETCH statement cannot return multiple rows"),
3426
parser_errposition(yylsp[-3])));
3924
parser_errposition((yylsp[(1) - (4)]))));
3428
fetch->lineno = plpgsql_location_to_lineno(yylsp[-3]);
3926
fetch->lineno = plpgsql_location_to_lineno((yylsp[(1) - (4)]));
3429
3927
fetch->rec = rec;
3430
3928
fetch->row = row;
3431
fetch->curvar = yyvsp[-1].var->dno;
3929
fetch->curvar = (yyvsp[(3) - (4)].var)->dno;
3432
3930
fetch->is_move = false;
3434
yyval.stmt = (PLpgSQL_stmt *)fetch;
3932
(yyval.stmt) = (PLpgSQL_stmt *)fetch;
3938
/* Line 1455 of yacc.c */
3439
3939
#line 1890 "gram.y"
3441
PLpgSQL_stmt_fetch *fetch = yyvsp[-2].fetch;
3941
PLpgSQL_stmt_fetch *fetch = (yyvsp[(2) - (4)].fetch);
3443
fetch->lineno = plpgsql_location_to_lineno(yylsp[-3]);
3444
fetch->curvar = yyvsp[-1].var->dno;
3943
fetch->lineno = plpgsql_location_to_lineno((yylsp[(1) - (4)]));
3944
fetch->curvar = (yyvsp[(3) - (4)].var)->dno;
3445
3945
fetch->is_move = true;
3447
yyval.stmt = (PLpgSQL_stmt *)fetch;
3947
(yyval.stmt) = (PLpgSQL_stmt *)fetch;
3953
/* Line 1455 of yacc.c */
3452
3954
#line 1902 "gram.y"
3454
yyval.fetch = read_fetch_direction();
3956
(yyval.fetch) = read_fetch_direction();
3962
/* Line 1455 of yacc.c */
3459
3963
#line 1908 "gram.y"
3461
3965
PLpgSQL_stmt_close *new;
3463
3967
new = palloc(sizeof(PLpgSQL_stmt_close));
3464
3968
new->cmd_type = PLPGSQL_STMT_CLOSE;
3465
new->lineno = plpgsql_location_to_lineno(yylsp[-2]);
3466
new->curvar = yyvsp[-1].var->dno;
3969
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (3)]));
3970
new->curvar = (yyvsp[(2) - (3)].var)->dno;
3468
yyval.stmt = (PLpgSQL_stmt *)new;
3972
(yyval.stmt) = (PLpgSQL_stmt *)new;
3978
/* Line 1455 of yacc.c */
3473
3979
#line 1921 "gram.y"
3475
3981
/* We do not bother building a node for NULL */
3982
(yyval.stmt) = NULL;
3988
/* Line 1455 of yacc.c */
3481
3989
#line 1928 "gram.y"
3483
if (yyvsp[0].wdatum.datum->dtype != PLPGSQL_DTYPE_VAR)
3991
if ((yyvsp[(1) - (1)].wdatum).datum->dtype != PLPGSQL_DTYPE_VAR)
3485
3993
(errcode(ERRCODE_DATATYPE_MISMATCH),
3486
3994
errmsg("cursor variable must be a simple variable"),
3487
parser_errposition(yylsp[0])));
3995
parser_errposition((yylsp[(1) - (1)]))));
3489
if (((PLpgSQL_var *) yyvsp[0].wdatum.datum)->datatype->typoid != REFCURSOROID)
3997
if (((PLpgSQL_var *) (yyvsp[(1) - (1)].wdatum).datum)->datatype->typoid != REFCURSOROID)
3491
3999
(errcode(ERRCODE_DATATYPE_MISMATCH),
3492
4000
errmsg("variable \"%s\" must be of type cursor or refcursor",
3493
((PLpgSQL_var *) yyvsp[0].wdatum.datum)->refname),
3494
parser_errposition(yylsp[0])));
3495
yyval.var = (PLpgSQL_var *) yyvsp[0].wdatum.datum;
4001
((PLpgSQL_var *) (yyvsp[(1) - (1)].wdatum).datum)->refname),
4002
parser_errposition((yylsp[(1) - (1)]))));
4003
(yyval.var) = (PLpgSQL_var *) (yyvsp[(1) - (1)].wdatum).datum;
4009
/* Line 1455 of yacc.c */
3500
4010
#line 1944 "gram.y"
3502
4012
/* just to give a better message than "syntax error" */
3503
word_is_not_variable(&(yyvsp[0].word), yylsp[0]);
4013
word_is_not_variable(&((yyvsp[(1) - (1)].word)), (yylsp[(1) - (1)]));
4019
/* Line 1455 of yacc.c */
3508
4020
#line 1949 "gram.y"
3510
4022
/* just to give a better message than "syntax error" */
3511
cword_is_not_variable(&(yyvsp[0].cword), yylsp[0]);
4023
cword_is_not_variable(&((yyvsp[(1) - (1)].cword)), (yylsp[(1) - (1)]));
4029
/* Line 1455 of yacc.c */
3516
4030
#line 1956 "gram.y"
3517
{ yyval.exception_block = NULL; ;}
4031
{ (yyval.exception_block) = NULL; ;}
4036
/* Line 1455 of yacc.c */
3521
4037
#line 1958 "gram.y"
3640
4170
new->condname = sqlstatestr;
3641
4171
new->next = NULL;
3643
yyval.condition = new;
4173
(yyval.condition) = new;
4180
/* Line 1455 of yacc.c */
3649
4181
#line 2072 "gram.y"
3650
{ yyval.expr = read_sql_expression(';', ";"); ;}
4182
{ (yyval.expr) = read_sql_expression(';', ";"); ;}
4187
/* Line 1455 of yacc.c */
3654
4188
#line 2076 "gram.y"
3655
{ yyval.expr = read_sql_expression(']', "]"); ;}
4189
{ (yyval.expr) = read_sql_expression(']', "]"); ;}
4194
/* Line 1455 of yacc.c */
3659
4195
#line 2080 "gram.y"
3660
{ yyval.expr = read_sql_expression(K_THEN, "THEN"); ;}
4196
{ (yyval.expr) = read_sql_expression(K_THEN, "THEN"); ;}
4201
/* Line 1455 of yacc.c */
3664
4202
#line 2084 "gram.y"
3665
{ yyval.expr = read_sql_expression(K_LOOP, "LOOP"); ;}
4203
{ (yyval.expr) = read_sql_expression(K_LOOP, "LOOP"); ;}
4208
/* Line 1455 of yacc.c */
3669
4209
#line 2088 "gram.y"
3671
4211
plpgsql_ns_push(NULL);
4218
/* Line 1455 of yacc.c */
3677
4219
#line 2093 "gram.y"
3679
plpgsql_ns_push(yyvsp[-1].str);
3680
yyval.str = yyvsp[-1].str;
4221
plpgsql_ns_push((yyvsp[(2) - (3)].str));
4222
(yyval.str) = (yyvsp[(2) - (3)].str);
4228
/* Line 1455 of yacc.c */
3685
4229
#line 2100 "gram.y"
4237
/* Line 1455 of yacc.c */
3692
4238
#line 2104 "gram.y"
3694
if (plpgsql_ns_lookup_label(plpgsql_ns_top(), yyvsp[0].str) == NULL)
4240
if (plpgsql_ns_lookup_label(plpgsql_ns_top(), (yyvsp[(1) - (1)].str)) == NULL)
3695
4241
yyerror("label does not exist");
3696
yyval.str = yyvsp[0].str;
4242
(yyval.str) = (yyvsp[(1) - (1)].str);
4248
/* Line 1455 of yacc.c */
3701
4249
#line 2112 "gram.y"
3702
{ yyval.expr = NULL; ;}
4250
{ (yyval.expr) = NULL; ;}
4255
/* Line 1455 of yacc.c */
3706
4256
#line 2114 "gram.y"
3707
{ yyval.expr = yyvsp[0].expr; ;}
4257
{ (yyval.expr) = (yyvsp[(2) - (2)].expr); ;}
4262
/* Line 1455 of yacc.c */
3711
4263
#line 2121 "gram.y"
3713
yyval.str = yyvsp[0].word.ident;
4265
(yyval.str) = (yyvsp[(1) - (1)].word).ident;
4271
/* Line 1455 of yacc.c */
3718
4272
#line 2125 "gram.y"
3720
if (yyvsp[0].wdatum.ident == NULL) /* composite name not OK */
4274
if ((yyvsp[(1) - (1)].wdatum).ident == NULL) /* composite name not OK */
3721
4275
yyerror("syntax error");
3722
yyval.str = yyvsp[0].wdatum.ident;
4276
(yyval.str) = (yyvsp[(1) - (1)].wdatum).ident;
4282
/* Line 1455 of yacc.c */
4283
#line 4284 "pl_gram.c"
3729
/* Line 991 of yacc.c. */
3730
#line 3730 "pl_gram.c"
4286
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
3736
4290
YY_STACK_PRINT (yyss, yyssp);
3738
4292
*++yyvsp = yyval;
3761
4315
if (!yyerrstatus)
3765
yyn = yypact[yystate];
3767
if (YYPACT_NINF < yyn && yyn < YYLAST)
3769
YYSIZE_T yysize = 0;
3770
int yytype = YYTRANSLATE (yychar);
3775
/* Start YYX at -YYN if negative to avoid negative indexes in
3777
for (yyx = yyn < 0 ? -yyn : 0;
3778
yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
3779
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3780
yysize += yystrlen (yytname[yyx]) + 15, yycount++;
3781
yysize += yystrlen ("syntax error, unexpected ") + 1;
3782
yysize += yystrlen (yytname[yytype]);
3783
yymsg = (char *) YYSTACK_ALLOC (yysize);
3786
char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
3787
yyp = yystpcpy (yyp, yytname[yytype]);
3792
for (yyx = yyn < 0 ? -yyn : 0;
3793
yyx < (int) (sizeof (yytname) / sizeof (char *));
3795
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3797
const char *yyq = ! yycount ? ", expecting " : " or ";
3798
yyp = yystpcpy (yyp, yyq);
3799
yyp = yystpcpy (yyp, yytname[yyx]);
4318
#if ! YYERROR_VERBOSE
4319
yyerror (YY_("syntax error"));
4322
YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
4323
if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
4325
YYSIZE_T yyalloc = 2 * yysize;
4326
if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
4327
yyalloc = YYSTACK_ALLOC_MAXIMUM;
4328
if (yymsg != yymsgbuf)
3804
4329
YYSTACK_FREE (yymsg);
3807
yyerror ("syntax error; also virtual memory exhausted");
3810
#endif /* YYERROR_VERBOSE */
3811
yyerror ("syntax error");
4330
yymsg = (char *) YYSTACK_ALLOC (yyalloc);
4332
yymsg_alloc = yyalloc;
4336
yymsg_alloc = sizeof yymsgbuf;
4340
if (0 < yysize && yysize <= yymsg_alloc)
4342
(void) yysyntax_error (yymsg, yystate, yychar);
4347
yyerror (YY_("syntax error"));
4349
goto yyexhaustedlab;
4355
yyerror_range[0] = yylloc;
3816
4357
if (yyerrstatus == 3)
3818
4359
/* If just tried and failed to reuse lookahead token after an
3819
4360
error, discard it. */
3821
/* Return failure if at end of input. */
3822
if (yychar == YYEOF)
3824
/* Pop the error token. */
3826
/* Pop the rest of the stack. */
3827
while (yyss < yyssp)
3829
YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
3830
yydestruct (yystos[*yyssp], yyvsp, yylsp);
3836
YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
3837
yydestruct (yytoken, &yylval, &yylloc);
3839
*++yylerrsp = yylloc;
4362
if (yychar <= YYEOF)
4364
/* Return failure if at end of input. */
4365
if (yychar == YYEOF)
4370
yydestruct ("Error: discarding",
4371
yytoken, &yylval, &yylloc);
3842
4376
/* Else will try to reuse lookahead token after shifting the error
3847
/*----------------------------------------------------.
3848
| yyerrlab1 -- error raised explicitly by an action. |
3849
`----------------------------------------------------*/
4381
/*---------------------------------------------------.
4382
| yyerrorlab -- error raised explicitly by YYERROR. |
4383
`---------------------------------------------------*/
4386
/* Pacify compilers like GCC when the user code never invokes
4387
YYERROR and the label yyerrorlab therefore never appears in user
4389
if (/*CONSTCOND*/ 0)
4392
yyerror_range[0] = yylsp[1-yylen];
4393
/* Do not reclaim the symbols of the rule which action triggered
4397
YY_STACK_PRINT (yyss, yyssp);
4402
/*-------------------------------------------------------------.
4403
| yyerrlab1 -- common code for both syntax error and YYERROR. |
4404
`-------------------------------------------------------------*/
3852
/* Suppress GCC warning that yyerrlab1 is unused when no action
3854
#if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__)
3855
__attribute__ ((__unused__))
3859
*++yylerrsp = yyloc;
3863
/*---------------------------------------------------------------.
3864
| yyerrlab2 -- pop states until the error token can be shifted. |
3865
`---------------------------------------------------------------*/
3867
4406
yyerrstatus = 3; /* Each real token shifted decrements this. */