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 0
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
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
76
/* Copy the first part of user declarations. */
78
/* Line 189 of yacc.c */
81
/*-------------------------------------------------------------------------
83
* gram.y - Parser for the PL/pgSQL
86
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
87
* Portions Copyright (c) 1994, Regents of the University of California
91
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.125.2.1 2010/08/19 18:58:11 tgl Exp $
93
*-------------------------------------------------------------------------
98
#include "catalog/pg_type.h"
99
#include "parser/parser.h"
103
* Bison doesn't allocate anything that needs to live across parser calls,
104
* so we can easily have it use palloc instead of malloc. This prevents
105
* memory leaks if we error out during parsing. Note this only works with
106
* bison >= 2.0. However, in bison 1.875 the default is to use alloca()
107
* if possible, so there's not really much problem anyhow, at least if
108
* you're building with gcc.
110
#define YYMALLOC palloc
114
static PLpgSQL_expr *read_sql_construct(int until,
117
const char *expected,
118
const char *sqlstart,
122
static PLpgSQL_expr *read_sql_expression2(int until, int until2,
123
const char *expected,
125
static PLpgSQL_expr *read_sql_stmt(const char *sqlstart);
126
static PLpgSQL_type *read_datatype(int tok);
127
static PLpgSQL_stmt *make_execsql_stmt(const char *sqlstart, int lineno);
128
static PLpgSQL_stmt_fetch *read_fetch_direction(void);
129
static PLpgSQL_stmt *make_return_stmt(int lineno);
130
static PLpgSQL_stmt *make_return_next_stmt(int lineno);
131
static PLpgSQL_stmt *make_return_query_stmt(int lineno);
132
static PLpgSQL_stmt *make_case(int lineno, PLpgSQL_expr *t_expr,
133
List *case_when_list, List *else_stmts);
134
static void check_assignable(PLpgSQL_datum *datum);
135
static void read_into_target(PLpgSQL_rec **rec, PLpgSQL_row **row,
137
static PLpgSQL_row *read_into_scalar_list(const char *initial_name,
138
PLpgSQL_datum *initial_datum);
139
static PLpgSQL_row *make_scalar_list1(const char *initial_name,
140
PLpgSQL_datum *initial_datum,
142
static void check_sql_expr(const char *stmt);
143
static void plpgsql_sql_error_callback(void *arg);
144
static char *parse_string_token(const char *token);
145
static void plpgsql_string_error_callback(void *arg);
146
static char *check_label(const char *yytxt);
147
static void check_labels(const char *start_label,
148
const char *end_label);
149
static PLpgSQL_expr *read_cursor_args(PLpgSQL_var *cursor,
150
int until, const char *expected);
151
static List *read_raise_options(void);
155
/* Line 189 of yacc.c */
156
#line 157 "pl_gram.c"
158
/* Enabling traces. */
163
/* Enabling verbose error messages. */
164
#ifdef YYERROR_VERBOSE
165
# undef YYERROR_VERBOSE
166
# define YYERROR_VERBOSE 1
168
# define YYERROR_VERBOSE 0
171
/* Enabling the token table. */
172
#ifndef YYTOKEN_TABLE
173
# define YYTOKEN_TABLE 0
133
#define K_CONSTANT 264
134
#define K_CONTINUE 265
136
#define K_DECLARE 267
137
#define K_DEFAULT 268
138
#define K_DIAGNOSTICS 269
143
#define K_EXCEPTION 274
144
#define K_EXECUTE 275
157
#define K_NOSCROLL 288
162
#define K_PERFORM 293
163
#define K_ROW_COUNT 294
166
#define K_RESULT_OID 297
168
#define K_REVERSE 299
191
/* Copy the first part of user declarations. */
194
/*-------------------------------------------------------------------------
196
* gram.y - Parser for the PL/pgSQL
197
* procedural language
199
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
200
* Portions Copyright (c) 1994, Regents of the University of California
204
* $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.125.2.1 2010/08/19 18:58:11 tgl Exp $
206
*-------------------------------------------------------------------------
211
#include "catalog/pg_type.h"
212
#include "parser/parser.h"
216
* Bison doesn't allocate anything that needs to live across parser calls,
217
* so we can easily have it use palloc instead of malloc. This prevents
218
* memory leaks if we error out during parsing. Note this only works with
219
* bison >= 2.0. However, in bison 1.875 the default is to use alloca()
220
* if possible, so there's not really much problem anyhow, at least if
221
* you're building with gcc.
223
#define YYMALLOC palloc
227
static PLpgSQL_expr *read_sql_construct(int until,
230
const char *expected,
231
const char *sqlstart,
235
static PLpgSQL_expr *read_sql_expression2(int until, int until2,
236
const char *expected,
238
static PLpgSQL_expr *read_sql_stmt(const char *sqlstart);
239
static PLpgSQL_type *read_datatype(int tok);
240
static PLpgSQL_stmt *make_execsql_stmt(const char *sqlstart, int lineno);
241
static PLpgSQL_stmt_fetch *read_fetch_direction(void);
242
static PLpgSQL_stmt *make_return_stmt(int lineno);
243
static PLpgSQL_stmt *make_return_next_stmt(int lineno);
244
static PLpgSQL_stmt *make_return_query_stmt(int lineno);
245
static PLpgSQL_stmt *make_case(int lineno, PLpgSQL_expr *t_expr,
246
List *case_when_list, List *else_stmts);
247
static void check_assignable(PLpgSQL_datum *datum);
248
static void read_into_target(PLpgSQL_rec **rec, PLpgSQL_row **row,
250
static PLpgSQL_row *read_into_scalar_list(const char *initial_name,
251
PLpgSQL_datum *initial_datum);
252
static PLpgSQL_row *make_scalar_list1(const char *initial_name,
253
PLpgSQL_datum *initial_datum,
255
static void check_sql_expr(const char *stmt);
256
static void plpgsql_sql_error_callback(void *arg);
257
static char *parse_string_token(const char *token);
258
static void plpgsql_string_error_callback(void *arg);
259
static char *check_label(const char *yytxt);
260
static void check_labels(const char *start_label,
261
const char *end_label);
262
static PLpgSQL_expr *read_cursor_args(PLpgSQL_var *cursor,
263
int until, const char *expected);
264
static List *read_raise_options(void);
268
/* Enabling traces. */
273
/* Enabling verbose error messages. */
274
#ifdef YYERROR_VERBOSE
275
# undef YYERROR_VERBOSE
276
# define YYERROR_VERBOSE 1
278
# define YYERROR_VERBOSE 0
281
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
248
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
249
typedef union YYSTYPE
252
/* Line 214 of yacc.c */
282
253
#line 79 "gram.y"
283
typedef union YYSTYPE {
325
296
PLpgSQL_diag_item *diagitem;
326
297
PLpgSQL_stmt_fetch *fetch;
327
298
PLpgSQL_case_when *casewhen;
302
/* Line 214 of yacc.c */
303
#line 304 "pl_gram.c"
329
/* Line 186 of yacc.c. */
330
#line 330 "pl_gram.c"
305
# define YYSTYPE_IS_TRIVIAL 1
331
306
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
332
307
# define YYSTYPE_IS_DECLARED 1
333
# define YYSTYPE_IS_TRIVIAL 1
338
311
/* Copy the second part of user declarations. */
341
/* Line 214 of yacc.c. */
342
#line 342 "pl_gram.c"
344
#if ! defined (yyoverflow) || YYERROR_VERBOSE
314
/* Line 264 of yacc.c */
315
#line 316 "pl_gram.c"
322
typedef YYTYPE_UINT8 yytype_uint8;
324
typedef unsigned char yytype_uint8;
328
typedef YYTYPE_INT8 yytype_int8;
329
#elif (defined __STDC__ || defined __C99__FUNC__ \
330
|| defined __cplusplus || defined _MSC_VER)
331
typedef signed char yytype_int8;
333
typedef short int yytype_int8;
337
typedef YYTYPE_UINT16 yytype_uint16;
339
typedef unsigned short int yytype_uint16;
343
typedef YYTYPE_INT16 yytype_int16;
345
typedef short int yytype_int16;
349
# ifdef __SIZE_TYPE__
350
# define YYSIZE_T __SIZE_TYPE__
351
# elif defined size_t
352
# define YYSIZE_T size_t
353
# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
354
|| defined __cplusplus || defined _MSC_VER)
355
# include <stddef.h> /* INFRINGES ON USER NAME SPACE */
356
# define YYSIZE_T size_t
358
# define YYSIZE_T unsigned int
362
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
367
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
368
# define YY_(msgid) dgettext ("bison-runtime", msgid)
372
# define YY_(msgid) msgid
376
/* Suppress unused-variable warnings by "using" E. */
377
#if ! defined lint || defined __GNUC__
378
# define YYUSE(e) ((void) (e))
380
# define YYUSE(e) /* empty */
383
/* Identity function, used to suppress warnings about constant conditions. */
387
#if (defined __STDC__ || defined __C99__FUNC__ \
388
|| defined __cplusplus || defined _MSC_VER)
401
#if ! defined yyoverflow || YYERROR_VERBOSE
346
403
/* The parser invokes alloca or malloc; define the necessary symbols. */
348
# if YYSTACK_USE_ALLOCA
349
# define YYSTACK_ALLOC alloca
351
# ifndef YYSTACK_USE_ALLOCA
352
# if defined (alloca) || defined (_ALLOCA_H)
405
# ifdef YYSTACK_USE_ALLOCA
406
# if YYSTACK_USE_ALLOCA
408
# define YYSTACK_ALLOC __builtin_alloca
409
# elif defined __BUILTIN_VA_ARG_INCR
410
# include <alloca.h> /* INFRINGES ON USER NAME SPACE */
412
# define YYSTACK_ALLOC __alloca
413
# elif defined _MSC_VER
414
# include <malloc.h> /* INFRINGES ON USER NAME SPACE */
415
# define alloca _alloca
353
417
# define YYSTACK_ALLOC alloca
356
# define YYSTACK_ALLOC __builtin_alloca
418
# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
419
|| defined __cplusplus || defined _MSC_VER)
420
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
362
429
# ifdef YYSTACK_ALLOC
363
/* Pacify GCC's `empty if-body' warning. */
364
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
430
/* Pacify GCC's `empty if-body' warning. */
431
# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
432
# ifndef YYSTACK_ALLOC_MAXIMUM
433
/* The OS might guarantee only one guard page at the bottom of the stack,
434
and a page size can be as small as 4096 bytes. So we cannot safely
435
invoke alloca (N) if N exceeds 4096. Use a slightly smaller number
436
to allow for a few compiler-allocated temporary stack slots. */
437
# define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
366
# if defined (__STDC__) || defined (__cplusplus)
440
# define YYSTACK_ALLOC YYMALLOC
441
# define YYSTACK_FREE YYFREE
442
# ifndef YYSTACK_ALLOC_MAXIMUM
443
# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
445
# if (defined __cplusplus && ! defined _STDLIB_H \
446
&& ! ((defined YYMALLOC || defined malloc) \
447
&& (defined YYFREE || defined free)))
367
448
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
368
# define YYSIZE_T size_t
370
# define YYSTACK_ALLOC malloc
371
# define YYSTACK_FREE free
454
# define YYMALLOC malloc
455
# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
456
|| defined __cplusplus || defined _MSC_VER)
457
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
462
# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
463
|| defined __cplusplus || defined _MSC_VER)
464
void free (void *); /* INFRINGES ON USER NAME SPACE */
373
#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
376
#if (! defined (yyoverflow) \
377
&& (! defined (__cplusplus) \
378
|| (YYSTYPE_IS_TRIVIAL)))
468
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
471
#if (! defined yyoverflow \
472
&& (! defined __cplusplus \
473
|| (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
380
475
/* A type that is properly aligned for any stack member. */
478
yytype_int16 yyss_alloc;
387
482
/* The size of the maximum gap between one aligned stack and the next. */
388
483
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
416
511
elements in the stack, and YYPTR gives the new location of the
417
512
stack. Advance YYPTR to a properly aligned location for the next
419
# define YYSTACK_RELOCATE(Stack) \
514
# define YYSTACK_RELOCATE(Stack_alloc, Stack) \
422
517
YYSIZE_T yynewbytes; \
423
YYCOPY (&yyptr->Stack, Stack, yysize); \
424
Stack = &yyptr->Stack; \
518
YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \
519
Stack = &yyptr->Stack_alloc; \
425
520
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
426
521
yyptr += yynewbytes / sizeof (*yyptr); \
432
#if defined (__STDC__) || defined (__cplusplus)
433
typedef signed char yysigned_char;
435
typedef short yysigned_char;
438
/* YYFINAL -- State number of the termination state. */
527
/* YYFINAL -- State number of the termination state. */
439
528
#define YYFINAL 7
440
529
/* YYLAST -- Last index in YYTABLE. */
441
530
#define YYLAST 454
443
/* YYNTOKENS -- Number of terminals. */
532
/* YYNTOKENS -- Number of terminals. */
444
533
#define YYNTOKENS 70
445
/* YYNNTS -- Number of nonterminals. */
534
/* YYNNTS -- Number of nonterminals. */
446
535
#define YYNNTS 81
447
/* YYNRULES -- Number of rules. */
536
/* YYNRULES -- Number of rules. */
448
537
#define YYNRULES 154
449
/* YYNRULES -- Number of states. */
538
/* YYNRULES -- Number of states. */
450
539
#define YYNSTATES 252
452
541
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
453
542
#define YYUNDEFTOK 2
454
543
#define YYMAXUTOK 317
456
#define YYTRANSLATE(YYX) \
545
#define YYTRANSLATE(YYX) \
457
546
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
459
548
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */
460
static const unsigned char yytranslate[] =
549
static const yytype_uint8 yytranslate[] =
462
551
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
463
552
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
589
#if YYDEBUG || YYERROR_VERBOSE
590
/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
591
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
678
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
679
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
680
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
592
681
static const char *const yytname[] =
594
"$end", "error", "$undefined", "K_ALIAS", "K_ASSIGN", "K_BEGIN", "K_BY",
595
"K_CASE", "K_CLOSE", "K_CONSTANT", "K_CONTINUE", "K_CURSOR",
596
"K_DECLARE", "K_DEFAULT", "K_DIAGNOSTICS", "K_DOTDOT", "K_ELSE",
597
"K_ELSIF", "K_END", "K_EXCEPTION", "K_EXECUTE", "K_EXIT", "K_FOR",
598
"K_FETCH", "K_FROM", "K_GET", "K_IF", "K_IN", "K_INSERT", "K_INTO",
599
"K_IS", "K_LOOP", "K_MOVE", "K_NOSCROLL", "K_NOT", "K_NULL", "K_OPEN",
600
"K_OR", "K_PERFORM", "K_ROW_COUNT", "K_RAISE", "K_RENAME",
601
"K_RESULT_OID", "K_RETURN", "K_REVERSE", "K_SCROLL", "K_STRICT",
602
"K_THEN", "K_TO", "K_TYPE", "K_USING", "K_WHEN", "K_WHILE", "T_STRING",
603
"T_NUMBER", "T_SCALAR", "T_ROW", "T_RECORD", "T_DTYPE", "T_WORD",
604
"T_ERROR", "O_OPTION", "O_DUMP", "';'", "'<'", "'>'", "'('", "')'",
605
"','", "'['", "$accept", "pl_function", "comp_optsect", "comp_options",
606
"comp_option", "opt_semi", "pl_block", "decl_sect", "decl_start",
607
"decl_stmts", "decl_stmt", "decl_statement", "@1", "opt_scrollable",
608
"decl_cursor_query", "decl_cursor_args", "decl_cursor_arglist",
609
"decl_cursor_arg", "decl_is_for", "decl_aliasitem", "decl_varname",
610
"decl_renname", "decl_const", "decl_datatype", "decl_notnull",
611
"decl_defval", "decl_defkey", "proc_sect", "proc_stmts", "proc_stmt",
612
"stmt_perform", "stmt_assign", "stmt_getdiag", "getdiag_list",
613
"getdiag_list_item", "getdiag_kind", "getdiag_target", "assign_var",
614
"stmt_if", "stmt_else", "stmt_case", "opt_expr_until_when",
615
"case_when_list", "case_when", "opt_case_else", "stmt_loop",
616
"stmt_while", "stmt_for", "for_control", "for_variable", "stmt_exit",
617
"exit_type", "stmt_return", "stmt_raise", "loop_body", "stmt_execsql",
618
"execsql_start", "stmt_dynexecute", "stmt_open", "stmt_fetch",
619
"stmt_move", "opt_fetch_direction", "stmt_close", "stmt_null",
620
"cursor_variable", "exception_sect", "@2", "proc_exceptions",
621
"proc_exception", "proc_conditions", "proc_condition",
622
"expr_until_semi", "expr_until_rightbracket", "expr_until_then",
623
"expr_until_loop", "opt_block_label", "opt_label", "opt_exitcond",
683
"$end", "error", "$undefined", "K_ALIAS", "K_ASSIGN", "K_BEGIN", "K_BY",
684
"K_CASE", "K_CLOSE", "K_CONSTANT", "K_CONTINUE", "K_CURSOR", "K_DECLARE",
685
"K_DEFAULT", "K_DIAGNOSTICS", "K_DOTDOT", "K_ELSE", "K_ELSIF", "K_END",
686
"K_EXCEPTION", "K_EXECUTE", "K_EXIT", "K_FOR", "K_FETCH", "K_FROM",
687
"K_GET", "K_IF", "K_IN", "K_INSERT", "K_INTO", "K_IS", "K_LOOP",
688
"K_MOVE", "K_NOSCROLL", "K_NOT", "K_NULL", "K_OPEN", "K_OR", "K_PERFORM",
689
"K_ROW_COUNT", "K_RAISE", "K_RENAME", "K_RESULT_OID", "K_RETURN",
690
"K_REVERSE", "K_SCROLL", "K_STRICT", "K_THEN", "K_TO", "K_TYPE",
691
"K_USING", "K_WHEN", "K_WHILE", "T_STRING", "T_NUMBER", "T_SCALAR",
692
"T_ROW", "T_RECORD", "T_DTYPE", "T_WORD", "T_ERROR", "O_OPTION",
693
"O_DUMP", "';'", "'<'", "'>'", "'('", "')'", "','", "'['", "$accept",
694
"pl_function", "comp_optsect", "comp_options", "comp_option", "opt_semi",
695
"pl_block", "decl_sect", "decl_start", "decl_stmts", "decl_stmt",
696
"decl_statement", "$@1", "opt_scrollable", "decl_cursor_query",
697
"decl_cursor_args", "decl_cursor_arglist", "decl_cursor_arg",
698
"decl_is_for", "decl_aliasitem", "decl_varname", "decl_renname",
699
"decl_const", "decl_datatype", "decl_notnull", "decl_defval",
700
"decl_defkey", "proc_sect", "proc_stmts", "proc_stmt", "stmt_perform",
701
"stmt_assign", "stmt_getdiag", "getdiag_list", "getdiag_list_item",
702
"getdiag_kind", "getdiag_target", "assign_var", "stmt_if", "stmt_else",
703
"stmt_case", "opt_expr_until_when", "case_when_list", "case_when",
704
"opt_case_else", "stmt_loop", "stmt_while", "stmt_for", "for_control",
705
"for_variable", "stmt_exit", "exit_type", "stmt_return", "stmt_raise",
706
"loop_body", "stmt_execsql", "execsql_start", "stmt_dynexecute",
707
"stmt_open", "stmt_fetch", "stmt_move", "opt_fetch_direction",
708
"stmt_close", "stmt_null", "cursor_variable", "exception_sect", "@2",
709
"proc_exceptions", "proc_exception", "proc_conditions", "proc_condition",
710
"expr_until_semi", "expr_until_rightbracket", "expr_until_then",
711
"expr_until_loop", "opt_block_label", "opt_label", "opt_exitcond",
624
712
"any_identifier", "any_name", "lno", 0
953
1026
yychar = (Token); \
954
1027
yylval = (Value); \
955
1028
yytoken = YYTRANSLATE (yychar); \
957
1030
goto yybackup; \
961
yyerror ("syntax error: cannot back up");\
1034
yyerror (YY_("syntax error: cannot back up")); \
966
1040
#define YYTERROR 1
967
1041
#define YYERRCODE 256
969
/* YYLLOC_DEFAULT -- Compute the default location (before the actions
1044
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
1045
If N is 0, then set CURRENT to the empty location which ends
1046
the previous symbol: RHS[0] (always defined). */
1048
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
972
1049
#ifndef YYLLOC_DEFAULT
973
# define YYLLOC_DEFAULT(Current, Rhs, N) \
974
Current.first_line = Rhs[1].first_line; \
975
Current.first_column = Rhs[1].first_column; \
976
Current.last_line = Rhs[N].last_line; \
977
Current.last_column = Rhs[N].last_column;
1050
# define YYLLOC_DEFAULT(Current, Rhs, N) \
1054
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
1055
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
1056
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
1057
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
1061
(Current).first_line = (Current).last_line = \
1062
YYRHSLOC (Rhs, 0).last_line; \
1063
(Current).first_column = (Current).last_column = \
1064
YYRHSLOC (Rhs, 0).last_column; \
1070
/* YY_LOCATION_PRINT -- Print the location on the stream.
1071
This macro was not mandated originally: define only if we know
1072
we won't break user code: when these are the locations we know. */
1074
#ifndef YY_LOCATION_PRINT
1075
# if YYLTYPE_IS_TRIVIAL
1076
# define YY_LOCATION_PRINT(File, Loc) \
1077
fprintf (File, "%d.%d-%d.%d", \
1078
(Loc).first_line, (Loc).first_column, \
1079
(Loc).last_line, (Loc).last_column)
1081
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
980
1086
/* YYLEX -- calling `yylex' with the right arguments. */
999
1105
YYFPRINTF Args; \
1002
# define YYDSYMPRINT(Args) \
1008
# define YYDSYMPRINTF(Title, Token, Value, Location) \
1012
YYFPRINTF (stderr, "%s ", Title); \
1013
yysymprint (stderr, \
1015
YYFPRINTF (stderr, "\n"); \
1108
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
1112
YYFPRINTF (stderr, "%s ", Title); \
1113
yy_symbol_print (stderr, \
1115
YYFPRINTF (stderr, "\n"); \
1120
/*--------------------------------.
1121
| Print this symbol on YYOUTPUT. |
1122
`--------------------------------*/
1125
#if (defined __STDC__ || defined __C99__FUNC__ \
1126
|| defined __cplusplus || defined _MSC_VER)
1128
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
1131
yy_symbol_value_print (yyoutput, yytype, yyvaluep)
1134
YYSTYPE const * const yyvaluep;
1140
if (yytype < YYNTOKENS)
1141
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1153
/*--------------------------------.
1154
| Print this symbol on YYOUTPUT. |
1155
`--------------------------------*/
1157
#if (defined __STDC__ || defined __C99__FUNC__ \
1158
|| defined __cplusplus || defined _MSC_VER)
1160
yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
1163
yy_symbol_print (yyoutput, yytype, yyvaluep)
1166
YYSTYPE const * const yyvaluep;
1169
if (yytype < YYNTOKENS)
1170
YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1172
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1174
yy_symbol_value_print (yyoutput, yytype, yyvaluep);
1175
YYFPRINTF (yyoutput, ")");
1019
1178
/*------------------------------------------------------------------.
1020
1179
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
1022
1181
`------------------------------------------------------------------*/
1024
#if defined (__STDC__) || defined (__cplusplus)
1183
#if (defined __STDC__ || defined __C99__FUNC__ \
1184
|| defined __cplusplus || defined _MSC_VER)
1026
yy_stack_print (short *bottom, short *top)
1186
yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1029
yy_stack_print (bottom, top)
1189
yy_stack_print (yybottom, yytop)
1190
yytype_int16 *yybottom;
1191
yytype_int16 *yytop;
1034
1194
YYFPRINTF (stderr, "Stack now");
1035
for (/* Nothing. */; bottom <= top; ++bottom)
1036
YYFPRINTF (stderr, " %d", *bottom);
1195
for (; yybottom <= yytop; yybottom++)
1197
int yybot = *yybottom;
1198
YYFPRINTF (stderr, " %d", yybot);
1037
1200
YYFPRINTF (stderr, "\n");
1043
1206
yy_stack_print ((Bottom), (Top)); \
1047
1210
/*------------------------------------------------.
1048
1211
| Report that the YYRULE is going to be reduced. |
1049
1212
`------------------------------------------------*/
1051
#if defined (__STDC__) || defined (__cplusplus)
1214
#if (defined __STDC__ || defined __C99__FUNC__ \
1215
|| defined __cplusplus || defined _MSC_VER)
1053
yy_reduce_print (int yyrule)
1217
yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
1056
yy_reduce_print (yyrule)
1220
yy_reduce_print (yyvsp, yyrule)
1225
int yynrhs = yyr2[yyrule];
1061
unsigned int yylineno = yyrline[yyrule];
1062
YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
1063
yyrule - 1, yylineno);
1064
/* Print the symbols being reduced, and their result. */
1065
for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
1066
YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
1067
YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
1227
unsigned long int yylno = yyrline[yyrule];
1228
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
1230
/* The symbols being reduced. */
1231
for (yyi = 0; yyi < yynrhs; yyi++)
1233
YYFPRINTF (stderr, " $%d = ", yyi + 1);
1234
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
1235
&(yyvsp[(yyi + 1) - (yynrhs)])
1237
YYFPRINTF (stderr, "\n");
1070
1241
# define YY_REDUCE_PRINT(Rule) \
1073
yy_reduce_print (Rule); \
1244
yy_reduce_print (yyvsp, Rule); \
1076
1247
/* Nonzero means print parse trace. It is left uninitialized so that
1077
1248
multiple parsers can coexist. */
1079
1250
#else /* !YYDEBUG */
1080
1251
# define YYDPRINTF(Args)
1081
# define YYDSYMPRINT(Args)
1082
# define YYDSYMPRINTF(Title, Token, Value, Location)
1252
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1083
1253
# define YY_STACK_PRINT(Bottom, Top)
1084
1254
# define YY_REDUCE_PRINT(Rule)
1085
1255
#endif /* !YYDEBUG */
1161
#endif /* !YYERROR_VERBOSE */
1330
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
1331
quotes and backslashes, so that it's suitable for yyerror. The
1332
heuristic is that double-quoting is unnecessary unless the string
1333
contains an apostrophe, a comma, or backslash (other than
1334
backslash-backslash). YYSTR is taken from yytname. If YYRES is
1335
null, do not copy; instead, return the length of what the result
1338
yytnamerr (char *yyres, const char *yystr)
1343
char const *yyp = yystr;
1350
goto do_not_strip_quotes;
1354
goto do_not_strip_quotes;
1367
do_not_strip_quotes: ;
1371
return yystrlen (yystr);
1373
return yystpcpy (yyres, yystr) - yyres;
1377
/* Copy into YYRESULT an error message about the unexpected token
1378
YYCHAR while in state YYSTATE. Return the number of bytes copied,
1379
including the terminating null byte. If YYRESULT is null, do not
1380
copy anything; just return the number of bytes that would be
1381
copied. As a special case, return 0 if an ordinary "syntax error"
1382
message will do. Return YYSIZE_MAXIMUM if overflow occurs during
1383
size calculation. */
1385
yysyntax_error (char *yyresult, int yystate, int yychar)
1387
int yyn = yypact[yystate];
1389
if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
1393
int yytype = YYTRANSLATE (yychar);
1394
YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
1395
YYSIZE_T yysize = yysize0;
1397
int yysize_overflow = 0;
1398
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
1399
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
1403
/* This is so xgettext sees the translatable formats that are
1404
constructed on the fly. */
1405
YY_("syntax error, unexpected %s");
1406
YY_("syntax error, unexpected %s, expecting %s");
1407
YY_("syntax error, unexpected %s, expecting %s or %s");
1408
YY_("syntax error, unexpected %s, expecting %s or %s or %s");
1409
YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
1413
static char const yyunexpected[] = "syntax error, unexpected %s";
1414
static char const yyexpecting[] = ", expecting %s";
1415
static char const yyor[] = " or %s";
1416
char yyformat[sizeof yyunexpected
1417
+ sizeof yyexpecting - 1
1418
+ ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
1419
* (sizeof yyor - 1))];
1420
char const *yyprefix = yyexpecting;
1422
/* Start YYX at -YYN if negative to avoid negative indexes in
1424
int yyxbegin = yyn < 0 ? -yyn : 0;
1426
/* Stay within bounds of both yycheck and yytname. */
1427
int yychecklim = YYLAST - yyn + 1;
1428
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
1431
yyarg[0] = yytname[yytype];
1432
yyfmt = yystpcpy (yyformat, yyunexpected);
1434
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
1435
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
1437
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
1441
yyformat[sizeof yyunexpected - 1] = '\0';
1444
yyarg[yycount++] = yytname[yyx];
1445
yysize1 = yysize + yytnamerr (0, yytname[yyx]);
1446
yysize_overflow |= (yysize1 < yysize);
1448
yyfmt = yystpcpy (yyfmt, yyprefix);
1452
yyf = YY_(yyformat);
1453
yysize1 = yysize + yystrlen (yyf);
1454
yysize_overflow |= (yysize1 < yysize);
1457
if (yysize_overflow)
1458
return YYSIZE_MAXIMUM;
1462
/* Avoid sprintf, as that infringes on the user's name space.
1463
Don't have undefined behavior even if the translation
1464
produced a string with the wrong number of "%s"s. */
1465
char *yyp = yyresult;
1467
while ((*yyp = *yyf) != '\0')
1469
if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
1471
yyp += yytnamerr (yyp, yyarg[yyi++]);
1484
#endif /* YYERROR_VERBOSE */
1166
/*--------------------------------.
1167
| Print this symbol on YYOUTPUT. |
1168
`--------------------------------*/
1170
#if defined (__STDC__) || defined (__cplusplus)
1172
yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
1175
yysymprint (yyoutput, yytype, yyvaluep)
1181
/* Pacify ``unused variable'' warnings. */
1184
if (yytype < YYNTOKENS)
1186
YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1188
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1192
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1199
YYFPRINTF (yyoutput, ")");
1202
#endif /* ! YYDEBUG */
1203
1487
/*-----------------------------------------------.
1204
1488
| Release the memory associated to this symbol. |
1205
1489
`-----------------------------------------------*/
1207
#if defined (__STDC__) || defined (__cplusplus)
1492
#if (defined __STDC__ || defined __C99__FUNC__ \
1493
|| defined __cplusplus || defined _MSC_VER)
1209
yydestruct (int yytype, YYSTYPE *yyvaluep)
1495
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1212
yydestruct (yytype, yyvaluep)
1498
yydestruct (yymsg, yytype, yyvaluep)
1214
1501
YYSTYPE *yyvaluep;
1217
/* Pacify ``unused variable'' warnings. */
1508
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1220
1510
switch (yytype)
1229
1518
/* Prevent warnings from -Wmissing-prototypes. */
1231
1519
#ifdef YYPARSE_PARAM
1232
# if defined (__STDC__) || defined (__cplusplus)
1520
#if defined __STDC__ || defined __cplusplus
1233
1521
int yyparse (void *YYPARSE_PARAM);
1235
1523
int yyparse ();
1237
1525
#else /* ! YYPARSE_PARAM */
1238
#if defined (__STDC__) || defined (__cplusplus)
1526
#if defined __STDC__ || defined __cplusplus
1239
1527
int yyparse (void);
1241
1529
int yyparse ();
1281
register int yystate;
1574
/* Number of tokens to shift before error messages enabled. */
1577
/* The stacks and their tools:
1578
`yyss': related to states.
1579
`yyvs': related to semantic values.
1581
Refer to the stacks thru separate pointers, to allow yyoverflow
1582
to reallocate them elsewhere. */
1584
/* The state stack. */
1585
yytype_int16 yyssa[YYINITDEPTH];
1587
yytype_int16 *yyssp;
1589
/* The semantic value stack. */
1590
YYSTYPE yyvsa[YYINITDEPTH];
1594
YYSIZE_T yystacksize;
1284
/* Number of tokens to shift before error messages enabled. */
1286
1598
/* Lookahead token as an internal (translated) token number. */
1289
/* Three stacks and their tools:
1290
`yyss': related to states,
1291
`yyvs': related to semantic values,
1292
`yyls': related to locations.
1294
Refer to the stacks thru separate pointers, to allow yyoverflow
1295
to reallocate them elsewhere. */
1297
/* The state stack. */
1298
short yyssa[YYINITDEPTH];
1299
short *yyss = yyssa;
1300
register short *yyssp;
1302
/* The semantic value stack. */
1303
YYSTYPE yyvsa[YYINITDEPTH];
1304
YYSTYPE *yyvs = yyvsa;
1305
register YYSTYPE *yyvsp;
1309
#define YYPOPSTACK (yyvsp--, yyssp--)
1311
YYSIZE_T yystacksize = YYINITDEPTH;
1313
1600
/* The variables used to return semantic value and location from the
1314
1601
action routines. */
1318
/* When reducing, the number of symbols on the RHS of the reduced
1605
/* Buffer for error messages, and its allocated size. */
1607
char *yymsg = yymsgbuf;
1608
YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
1611
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N))
1613
/* The number of symbols on the RHS of the reduced rule.
1614
Keep to zero when no symbol should be popped. */
1620
yystacksize = YYINITDEPTH;
1322
1622
YYDPRINTF ((stderr, "Starting parse\n"));
1325
1625
yyerrstatus = 0;
1327
yychar = YYEMPTY; /* Cause a token to be read. */
1627
yychar = YYEMPTY; /* Cause a token to be read. */
1329
1629
/* Initialize stack pointers.
1330
1630
Waste one element of value and location stack
1331
1631
so that they stay on the same level as the state stack.
1332
1632
The wasted elements are never initialized. */
1541
1837
new = palloc0(sizeof(PLpgSQL_stmt_block));
1543
1839
new->cmd_type = PLPGSQL_STMT_BLOCK;
1544
new->lineno = yyvsp[-4].ival;
1545
new->label = yyvsp[-6].declhdr.label;
1546
new->n_initvars = yyvsp[-6].declhdr.n_initvars;
1547
new->initvarnos = yyvsp[-6].declhdr.initvarnos;
1548
new->body = yyvsp[-3].list;
1549
new->exceptions = yyvsp[-2].exception_block;
1840
new->lineno = (yyvsp[(3) - (7)].ival);
1841
new->label = (yyvsp[(1) - (7)].declhdr).label;
1842
new->n_initvars = (yyvsp[(1) - (7)].declhdr).n_initvars;
1843
new->initvarnos = (yyvsp[(1) - (7)].declhdr).initvarnos;
1844
new->body = (yyvsp[(4) - (7)].list);
1845
new->exceptions = (yyvsp[(5) - (7)].exception_block);
1551
check_labels(yyvsp[-6].declhdr.label, yyvsp[0].str);
1847
check_labels((yyvsp[(1) - (7)].declhdr).label, (yyvsp[(7) - (7)].str));
1552
1848
plpgsql_ns_pop();
1554
yyval.stmt = (PLpgSQL_stmt *)new;
1850
(yyval.stmt) = (PLpgSQL_stmt *)new;
1856
/* Line 1455 of yacc.c */
1559
1857
#line 294 "gram.y"
1561
1859
plpgsql_ns_setlocal(false);
1562
yyval.declhdr.label = yyvsp[0].str;
1563
yyval.declhdr.n_initvars = 0;
1564
yyval.declhdr.initvarnos = NULL;
1860
(yyval.declhdr).label = (yyvsp[(1) - (1)].str);
1861
(yyval.declhdr).n_initvars = 0;
1862
(yyval.declhdr).initvarnos = NULL;
1868
/* Line 1455 of yacc.c */
1569
1869
#line 301 "gram.y"
1571
1871
plpgsql_ns_setlocal(false);
1572
yyval.declhdr.label = yyvsp[-1].str;
1573
yyval.declhdr.n_initvars = 0;
1574
yyval.declhdr.initvarnos = NULL;
1872
(yyval.declhdr).label = (yyvsp[(1) - (2)].str);
1873
(yyval.declhdr).n_initvars = 0;
1874
(yyval.declhdr).initvarnos = NULL;
1880
/* Line 1455 of yacc.c */
1579
1881
#line 308 "gram.y"
1581
1883
plpgsql_ns_setlocal(false);
1582
if (yyvsp[0].str != NULL)
1583
yyval.declhdr.label = yyvsp[0].str;
1884
if ((yyvsp[(3) - (3)].str) != NULL)
1885
(yyval.declhdr).label = (yyvsp[(3) - (3)].str);
1585
yyval.declhdr.label = yyvsp[-2].str;
1887
(yyval.declhdr).label = (yyvsp[(1) - (3)].str);
1586
1888
/* Remember variables declared in decl_stmts */
1587
yyval.declhdr.n_initvars = plpgsql_add_initdatums(&(yyval.declhdr.initvarnos));
1889
(yyval.declhdr).n_initvars = plpgsql_add_initdatums(&((yyval.declhdr).initvarnos));
1895
/* Line 1455 of yacc.c */
1592
1896
#line 320 "gram.y"
1594
1898
/* Forget any variables created before block */
2248
/* Line 1455 of yacc.c */
1895
2249
#line 574 "gram.y"
1899
2253
plpgsql_convert_ident(yytext, &name, 1);
1900
2254
/* the result must be palloc'd, see plpgsql_ns_rename */
2261
/* Line 1455 of yacc.c */
1906
2262
#line 584 "gram.y"
1907
{ yyval.boolean = false; ;}
2263
{ (yyval.boolean) = false; ;}
2268
/* Line 1455 of yacc.c */
1911
2269
#line 586 "gram.y"
1912
{ yyval.boolean = true; ;}
2270
{ (yyval.boolean) = true; ;}
2275
/* Line 1455 of yacc.c */
1916
2276
#line 590 "gram.y"
1919
2279
* If there's a lookahead token, read_datatype
1920
2280
* should consume it.
1922
yyval.dtype = read_datatype(yychar);
2282
(yyval.dtype) = read_datatype(yychar);
2289
/* Line 1455 of yacc.c */
1928
2290
#line 601 "gram.y"
1929
{ yyval.boolean = false; ;}
2291
{ (yyval.boolean) = false; ;}
2296
/* Line 1455 of yacc.c */
1933
2297
#line 603 "gram.y"
1934
{ yyval.boolean = true; ;}
2298
{ (yyval.boolean) = true; ;}
2303
/* Line 1455 of yacc.c */
1938
2304
#line 607 "gram.y"
1939
{ yyval.expr = NULL; ;}
2305
{ (yyval.expr) = NULL; ;}
2310
/* Line 1455 of yacc.c */
1943
2311
#line 609 "gram.y"
1945
2313
plpgsql_ns_setlocal(false);
1946
yyval.expr = plpgsql_read_expression(';', ";");
2314
(yyval.expr) = plpgsql_read_expression(';', ";");
1947
2315
plpgsql_ns_setlocal(true);
2321
/* Line 1455 of yacc.c */
1952
2322
#line 621 "gram.y"
1953
{ yyval.list = NIL; ;}
2323
{ (yyval.list) = NIL; ;}
2328
/* Line 1455 of yacc.c */
1957
2329
#line 623 "gram.y"
1958
{ yyval.list = yyvsp[0].list; ;}
2330
{ (yyval.list) = (yyvsp[(1) - (1)].list); ;}
2335
/* Line 1455 of yacc.c */
1962
2336
#line 627 "gram.y"
1964
if (yyvsp[0].stmt == NULL)
1965
yyval.list = yyvsp[-1].list;
2338
if ((yyvsp[(2) - (2)].stmt) == NULL)
2339
(yyval.list) = (yyvsp[(1) - (2)].list);
1967
yyval.list = lappend(yyvsp[-1].list, yyvsp[0].stmt);
2341
(yyval.list) = lappend((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].stmt));
2347
/* Line 1455 of yacc.c */
1972
2348
#line 634 "gram.y"
1974
if (yyvsp[0].stmt == NULL)
2350
if ((yyvsp[(1) - (1)].stmt) == NULL)
1977
yyval.list = list_make1(yyvsp[0].stmt);
2353
(yyval.list) = list_make1((yyvsp[(1) - (1)].stmt));
2359
/* Line 1455 of yacc.c */
1982
2360
#line 643 "gram.y"
1983
{ yyval.stmt = yyvsp[-1].stmt; ;}
2361
{ (yyval.stmt) = (yyvsp[(1) - (2)].stmt); ;}
2366
/* Line 1455 of yacc.c */
1987
2367
#line 645 "gram.y"
1988
{ yyval.stmt = yyvsp[0].stmt; ;}
2368
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2373
/* Line 1455 of yacc.c */
1992
2374
#line 647 "gram.y"
1993
{ yyval.stmt = yyvsp[0].stmt; ;}
2375
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2380
/* Line 1455 of yacc.c */
1997
2381
#line 649 "gram.y"
1998
{ yyval.stmt = yyvsp[0].stmt; ;}
2382
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2387
/* Line 1455 of yacc.c */
2002
2388
#line 651 "gram.y"
2003
{ yyval.stmt = yyvsp[0].stmt; ;}
2389
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2394
/* Line 1455 of yacc.c */
2007
2395
#line 653 "gram.y"
2008
{ yyval.stmt = yyvsp[0].stmt; ;}
2396
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2401
/* Line 1455 of yacc.c */
2012
2402
#line 655 "gram.y"
2013
{ yyval.stmt = yyvsp[0].stmt; ;}
2403
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2408
/* Line 1455 of yacc.c */
2017
2409
#line 657 "gram.y"
2018
{ yyval.stmt = yyvsp[0].stmt; ;}
2410
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2415
/* Line 1455 of yacc.c */
2022
2416
#line 659 "gram.y"
2023
{ yyval.stmt = yyvsp[0].stmt; ;}
2417
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2422
/* Line 1455 of yacc.c */
2027
2423
#line 661 "gram.y"
2028
{ yyval.stmt = yyvsp[0].stmt; ;}
2424
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2429
/* Line 1455 of yacc.c */
2032
2430
#line 663 "gram.y"
2033
{ yyval.stmt = yyvsp[0].stmt; ;}
2431
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2436
/* Line 1455 of yacc.c */
2037
2437
#line 665 "gram.y"
2038
{ yyval.stmt = yyvsp[0].stmt; ;}
2438
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2443
/* Line 1455 of yacc.c */
2042
2444
#line 667 "gram.y"
2043
{ yyval.stmt = yyvsp[0].stmt; ;}
2445
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2450
/* Line 1455 of yacc.c */
2047
2451
#line 669 "gram.y"
2048
{ yyval.stmt = yyvsp[0].stmt; ;}
2452
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2457
/* Line 1455 of yacc.c */
2052
2458
#line 671 "gram.y"
2053
{ yyval.stmt = yyvsp[0].stmt; ;}
2459
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2464
/* Line 1455 of yacc.c */
2057
2465
#line 673 "gram.y"
2058
{ yyval.stmt = yyvsp[0].stmt; ;}
2466
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2471
/* Line 1455 of yacc.c */
2062
2472
#line 675 "gram.y"
2063
{ yyval.stmt = yyvsp[0].stmt; ;}
2473
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2478
/* Line 1455 of yacc.c */
2067
2479
#line 677 "gram.y"
2068
{ yyval.stmt = yyvsp[0].stmt; ;}
2480
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2485
/* Line 1455 of yacc.c */
2072
2486
#line 679 "gram.y"
2073
{ yyval.stmt = yyvsp[0].stmt; ;}
2487
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2492
/* Line 1455 of yacc.c */
2077
2493
#line 683 "gram.y"
2079
2495
PLpgSQL_stmt_perform *new;
2081
2497
new = palloc0(sizeof(PLpgSQL_stmt_perform));
2082
2498
new->cmd_type = PLPGSQL_STMT_PERFORM;
2083
new->lineno = yyvsp[-1].ival;
2084
new->expr = yyvsp[0].expr;
2499
new->lineno = (yyvsp[(2) - (3)].ival);
2500
new->expr = (yyvsp[(3) - (3)].expr);
2086
yyval.stmt = (PLpgSQL_stmt *)new;
2502
(yyval.stmt) = (PLpgSQL_stmt *)new;
2508
/* Line 1455 of yacc.c */
2091
2509
#line 696 "gram.y"
2093
2511
PLpgSQL_stmt_assign *new;
2095
2513
new = palloc0(sizeof(PLpgSQL_stmt_assign));
2096
2514
new->cmd_type = PLPGSQL_STMT_ASSIGN;
2097
new->lineno = yyvsp[-2].ival;
2098
new->varno = yyvsp[-3].ival;
2099
new->expr = yyvsp[0].expr;
2515
new->lineno = (yyvsp[(2) - (4)].ival);
2516
new->varno = (yyvsp[(1) - (4)].ival);
2517
new->expr = (yyvsp[(4) - (4)].expr);
2101
yyval.stmt = (PLpgSQL_stmt *)new;
2519
(yyval.stmt) = (PLpgSQL_stmt *)new;
2525
/* Line 1455 of yacc.c */
2106
2526
#line 710 "gram.y"
2108
2528
PLpgSQL_stmt_getdiag *new;
2110
2530
new = palloc0(sizeof(PLpgSQL_stmt_getdiag));
2111
2531
new->cmd_type = PLPGSQL_STMT_GETDIAG;
2112
new->lineno = yyvsp[-2].ival;
2113
new->diag_items = yyvsp[-1].list;
2532
new->lineno = (yyvsp[(3) - (5)].ival);
2533
new->diag_items = (yyvsp[(4) - (5)].list);
2115
yyval.stmt = (PLpgSQL_stmt *)new;
2535
(yyval.stmt) = (PLpgSQL_stmt *)new;
2541
/* Line 1455 of yacc.c */
2120
2542
#line 723 "gram.y"
2122
yyval.list = lappend(yyvsp[-2].list, yyvsp[0].diagitem);
2544
(yyval.list) = lappend((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].diagitem));
2550
/* Line 1455 of yacc.c */
2127
2551
#line 727 "gram.y"
2129
yyval.list = list_make1(yyvsp[0].diagitem);
2553
(yyval.list) = list_make1((yyvsp[(1) - (1)].diagitem));
2559
/* Line 1455 of yacc.c */
2134
2560
#line 733 "gram.y"
2136
2562
PLpgSQL_diag_item *new;
2138
2564
new = palloc(sizeof(PLpgSQL_diag_item));
2139
new->target = yyvsp[-2].ival;
2140
new->kind = yyvsp[0].ival;
2565
new->target = (yyvsp[(1) - (3)].ival);
2566
new->kind = (yyvsp[(3) - (3)].ival);
2142
yyval.diagitem = new;
2568
(yyval.diagitem) = new;
2574
/* Line 1455 of yacc.c */
2147
2575
#line 745 "gram.y"
2149
yyval.ival = PLPGSQL_GETDIAG_ROW_COUNT;
2577
(yyval.ival) = PLPGSQL_GETDIAG_ROW_COUNT;
2583
/* Line 1455 of yacc.c */
2154
2584
#line 749 "gram.y"
2156
yyval.ival = PLPGSQL_GETDIAG_RESULT_OID;
2586
(yyval.ival) = PLPGSQL_GETDIAG_RESULT_OID;
2592
/* Line 1455 of yacc.c */
2161
2593
#line 755 "gram.y"
2163
2595
check_assignable(yylval.scalar);
2164
yyval.ival = yylval.scalar->dno;
2596
(yyval.ival) = yylval.scalar->dno;
2602
/* Line 1455 of yacc.c */
2169
2603
#line 760 "gram.y"
2171
2605
yyerror("expected an integer variable");
2352
2820
* Simplest fix is to return a list with one NULL
2353
2821
* pointer, which make_case() must take care of.
2355
if (yyvsp[0].list != NIL)
2356
yyval.list = yyvsp[0].list;
2823
if ((yyvsp[(2) - (2)].list) != NIL)
2824
(yyval.list) = (yyvsp[(2) - (2)].list);
2358
yyval.list = list_make1(NULL);
2826
(yyval.list) = list_make1(NULL);
2832
/* Line 1455 of yacc.c */
2363
2833
#line 920 "gram.y"
2365
2835
PLpgSQL_stmt_loop *new;
2367
2837
new = palloc0(sizeof(PLpgSQL_stmt_loop));
2368
2838
new->cmd_type = PLPGSQL_STMT_LOOP;
2369
new->lineno = yyvsp[-1].ival;
2370
new->label = yyvsp[-3].str;
2371
new->body = yyvsp[0].loop_body.stmts;
2839
new->lineno = (yyvsp[(3) - (4)].ival);
2840
new->label = (yyvsp[(1) - (4)].str);
2841
new->body = (yyvsp[(4) - (4)].loop_body).stmts;
2373
check_labels(yyvsp[-3].str, yyvsp[0].loop_body.end_label);
2843
check_labels((yyvsp[(1) - (4)].str), (yyvsp[(4) - (4)].loop_body).end_label);
2374
2844
plpgsql_ns_pop();
2376
yyval.stmt = (PLpgSQL_stmt *)new;
2846
(yyval.stmt) = (PLpgSQL_stmt *)new;
2852
/* Line 1455 of yacc.c */
2381
2853
#line 937 "gram.y"
2383
2855
PLpgSQL_stmt_while *new;
2385
2857
new = palloc0(sizeof(PLpgSQL_stmt_while));
2386
2858
new->cmd_type = PLPGSQL_STMT_WHILE;
2387
new->lineno = yyvsp[-2].ival;
2388
new->label = yyvsp[-4].str;
2389
new->cond = yyvsp[-1].expr;
2390
new->body = yyvsp[0].loop_body.stmts;
2859
new->lineno = (yyvsp[(3) - (5)].ival);
2860
new->label = (yyvsp[(1) - (5)].str);
2861
new->cond = (yyvsp[(4) - (5)].expr);
2862
new->body = (yyvsp[(5) - (5)].loop_body).stmts;
2392
check_labels(yyvsp[-4].str, yyvsp[0].loop_body.end_label);
2864
check_labels((yyvsp[(1) - (5)].str), (yyvsp[(5) - (5)].loop_body).end_label);
2393
2865
plpgsql_ns_pop();
2395
yyval.stmt = (PLpgSQL_stmt *)new;
2867
(yyval.stmt) = (PLpgSQL_stmt *)new;
2873
/* Line 1455 of yacc.c */
2400
2874
#line 955 "gram.y"
2402
2876
/* This runs after we've scanned the loop body */
2403
if (yyvsp[-1].stmt->cmd_type == PLPGSQL_STMT_FORI)
2877
if ((yyvsp[(3) - (4)].stmt)->cmd_type == PLPGSQL_STMT_FORI)
2405
2879
PLpgSQL_stmt_fori *new;
2407
new = (PLpgSQL_stmt_fori *) yyvsp[-1].stmt;
2408
new->label = yyvsp[-3].str;
2409
new->body = yyvsp[0].loop_body.stmts;
2410
yyval.stmt = (PLpgSQL_stmt *) new;
2881
new = (PLpgSQL_stmt_fori *) (yyvsp[(3) - (4)].stmt);
2882
new->label = (yyvsp[(1) - (4)].str);
2883
new->body = (yyvsp[(4) - (4)].loop_body).stmts;
2884
(yyval.stmt) = (PLpgSQL_stmt *) new;
2414
2888
PLpgSQL_stmt_forq *new;
2416
Assert(yyvsp[-1].stmt->cmd_type == PLPGSQL_STMT_FORS ||
2417
yyvsp[-1].stmt->cmd_type == PLPGSQL_STMT_FORC ||
2418
yyvsp[-1].stmt->cmd_type == PLPGSQL_STMT_DYNFORS);
2890
Assert((yyvsp[(3) - (4)].stmt)->cmd_type == PLPGSQL_STMT_FORS ||
2891
(yyvsp[(3) - (4)].stmt)->cmd_type == PLPGSQL_STMT_FORC ||
2892
(yyvsp[(3) - (4)].stmt)->cmd_type == PLPGSQL_STMT_DYNFORS);
2419
2893
/* forq is the common supertype of all three */
2420
new = (PLpgSQL_stmt_forq *) yyvsp[-1].stmt;
2421
new->label = yyvsp[-3].str;
2422
new->body = yyvsp[0].loop_body.stmts;
2423
yyval.stmt = (PLpgSQL_stmt *) new;
2894
new = (PLpgSQL_stmt_forq *) (yyvsp[(3) - (4)].stmt);
2895
new->label = (yyvsp[(1) - (4)].str);
2896
new->body = (yyvsp[(4) - (4)].loop_body).stmts;
2897
(yyval.stmt) = (PLpgSQL_stmt *) new;
2426
check_labels(yyvsp[-3].str, yyvsp[0].loop_body.end_label);
2900
check_labels((yyvsp[(1) - (4)].str), (yyvsp[(4) - (4)].loop_body).end_label);
2427
2901
/* close namespace started in opt_block_label */
2428
2902
plpgsql_ns_pop();
2908
/* Line 1455 of yacc.c */
2433
2909
#line 988 "gram.y"
2435
2911
int tok = yylex();
2637
3113
new = palloc0(sizeof(PLpgSQL_stmt_fors));
2638
3114
new->cmd_type = PLPGSQL_STMT_FORS;
2639
new->lineno = yyvsp[-2].ival;
2640
if (yyvsp[-1].forvariable.rec)
3115
new->lineno = (yyvsp[(1) - (3)].ival);
3116
if ((yyvsp[(2) - (3)].forvariable).rec)
2642
new->rec = yyvsp[-1].forvariable.rec;
3118
new->rec = (yyvsp[(2) - (3)].forvariable).rec;
2643
3119
check_assignable((PLpgSQL_datum *) new->rec);
2645
else if (yyvsp[-1].forvariable.row)
3121
else if ((yyvsp[(2) - (3)].forvariable).row)
2647
new->row = yyvsp[-1].forvariable.row;
3123
new->row = (yyvsp[(2) - (3)].forvariable).row;
2648
3124
check_assignable((PLpgSQL_datum *) new->row);
2650
else if (yyvsp[-1].forvariable.scalar)
3126
else if ((yyvsp[(2) - (3)].forvariable).scalar)
2652
3128
/* convert single scalar to list */
2653
new->row = make_scalar_list1(yyvsp[-1].forvariable.name, yyvsp[-1].forvariable.scalar, yyvsp[-1].forvariable.lineno);
3129
new->row = make_scalar_list1((yyvsp[(2) - (3)].forvariable).name, (yyvsp[(2) - (3)].forvariable).scalar, (yyvsp[(2) - (3)].forvariable).lineno);
2654
3130
/* no need for check_assignable */
2658
plpgsql_error_lineno = yyvsp[-1].forvariable.lineno;
3134
plpgsql_error_lineno = (yyvsp[(2) - (3)].forvariable).lineno;
2659
3135
yyerror("loop variable of loop over rows must be a record or row variable or list of scalar variables");
2662
3138
new->query = expr1;
2663
yyval.stmt = (PLpgSQL_stmt *) new;
3139
(yyval.stmt) = (PLpgSQL_stmt *) new;
3147
/* Line 1455 of yacc.c */
2670
3148
#line 1242 "gram.y"
2674
yyval.forvariable.name = pstrdup(yytext);
2675
yyval.forvariable.lineno = plpgsql_scanner_lineno();
2676
yyval.forvariable.scalar = yylval.scalar;
2677
yyval.forvariable.rec = NULL;
2678
yyval.forvariable.row = NULL;
3152
(yyval.forvariable).name = pstrdup(yytext);
3153
(yyval.forvariable).lineno = plpgsql_scanner_lineno();
3154
(yyval.forvariable).scalar = yylval.scalar;
3155
(yyval.forvariable).rec = NULL;
3156
(yyval.forvariable).row = NULL;
2679
3157
/* check for comma-separated list */
2681
3159
plpgsql_push_back_token(tok);
2682
3160
if (tok == ',')
2683
yyval.forvariable.row = read_into_scalar_list(yyval.forvariable.name, yyval.forvariable.scalar);
3161
(yyval.forvariable).row = read_into_scalar_list((yyval.forvariable).name, (yyval.forvariable).scalar);
3167
/* Line 1455 of yacc.c */
2688
3168
#line 1257 "gram.y"
2692
yyval.forvariable.name = pstrdup(yytext);
2693
yyval.forvariable.lineno = plpgsql_scanner_lineno();
2694
yyval.forvariable.scalar = NULL;
2695
yyval.forvariable.rec = NULL;
2696
yyval.forvariable.row = NULL;
3172
(yyval.forvariable).name = pstrdup(yytext);
3173
(yyval.forvariable).lineno = plpgsql_scanner_lineno();
3174
(yyval.forvariable).scalar = NULL;
3175
(yyval.forvariable).rec = NULL;
3176
(yyval.forvariable).row = NULL;
2697
3177
/* check for comma-separated list */
2699
3179
plpgsql_push_back_token(tok);
2700
3180
if (tok == ',')
2702
plpgsql_error_lineno = yyval.forvariable.lineno;
3182
plpgsql_error_lineno = (yyval.forvariable).lineno;
2704
3184
(errcode(ERRCODE_SYNTAX_ERROR),
2705
3185
errmsg("\"%s\" is not a scalar variable",
2706
yyval.forvariable.name)));
3186
(yyval.forvariable).name)));
3193
/* Line 1455 of yacc.c */
2712
3194
#line 1278 "gram.y"
2714
yyval.forvariable.name = pstrdup(yytext);
2715
yyval.forvariable.lineno = plpgsql_scanner_lineno();
2716
yyval.forvariable.scalar = NULL;
2717
yyval.forvariable.rec = yylval.rec;
2718
yyval.forvariable.row = NULL;
3196
(yyval.forvariable).name = pstrdup(yytext);
3197
(yyval.forvariable).lineno = plpgsql_scanner_lineno();
3198
(yyval.forvariable).scalar = NULL;
3199
(yyval.forvariable).rec = yylval.rec;
3200
(yyval.forvariable).row = NULL;
3206
/* Line 1455 of yacc.c */
2723
3207
#line 1286 "gram.y"
2725
yyval.forvariable.name = pstrdup(yytext);
2726
yyval.forvariable.lineno = plpgsql_scanner_lineno();
2727
yyval.forvariable.scalar = NULL;
2728
yyval.forvariable.row = yylval.row;
2729
yyval.forvariable.rec = NULL;
3209
(yyval.forvariable).name = pstrdup(yytext);
3210
(yyval.forvariable).lineno = plpgsql_scanner_lineno();
3211
(yyval.forvariable).scalar = NULL;
3212
(yyval.forvariable).row = yylval.row;
3213
(yyval.forvariable).rec = NULL;
3219
/* Line 1455 of yacc.c */
2734
3220
#line 1296 "gram.y"
2736
3222
PLpgSQL_stmt_exit *new;
2738
3224
new = palloc0(sizeof(PLpgSQL_stmt_exit));
2739
3225
new->cmd_type = PLPGSQL_STMT_EXIT;
2740
new->is_exit = yyvsp[-3].boolean;
2741
new->lineno = yyvsp[-2].ival;
2742
new->label = yyvsp[-1].str;
2743
new->cond = yyvsp[0].expr;
3226
new->is_exit = (yyvsp[(1) - (4)].boolean);
3227
new->lineno = (yyvsp[(2) - (4)].ival);
3228
new->label = (yyvsp[(3) - (4)].str);
3229
new->cond = (yyvsp[(4) - (4)].expr);
2745
yyval.stmt = (PLpgSQL_stmt *)new;
3231
(yyval.stmt) = (PLpgSQL_stmt *)new;
3237
/* Line 1455 of yacc.c */
2750
3238
#line 1311 "gram.y"
2752
yyval.boolean = true;
3240
(yyval.boolean) = true;
3246
/* Line 1455 of yacc.c */
2757
3247
#line 1315 "gram.y"
2759
yyval.boolean = false;
3249
(yyval.boolean) = false;
3255
/* Line 1455 of yacc.c */
2764
3256
#line 1321 "gram.y"
3198
3728
PLpgSQL_exception_block *new = palloc(sizeof(PLpgSQL_exception_block));
3199
3729
PLpgSQL_variable *var;
3201
var = plpgsql_build_variable("sqlstate", yyvsp[0].ival,
3731
var = plpgsql_build_variable("sqlstate", (yyvsp[(2) - (2)].ival),
3202
3732
plpgsql_build_datatype(TEXTOID, -1),
3204
3734
((PLpgSQL_var *) var)->isconst = true;
3205
3735
new->sqlstate_varno = var->dno;
3207
var = plpgsql_build_variable("sqlerrm", yyvsp[0].ival,
3737
var = plpgsql_build_variable("sqlerrm", (yyvsp[(2) - (2)].ival),
3208
3738
plpgsql_build_datatype(TEXTOID, -1),
3210
3740
((PLpgSQL_var *) var)->isconst = true;
3211
3741
new->sqlerrm_varno = var->dno;
3213
yyval.exception_block = new;
3743
(yyval.exception_block) = new;
3749
/* Line 1455 of yacc.c */
3218
3750
#line 1743 "gram.y"
3220
PLpgSQL_exception_block *new = yyvsp[-1].exception_block;
3221
new->exc_list = yyvsp[0].list;
3752
PLpgSQL_exception_block *new = (yyvsp[(3) - (4)].exception_block);
3753
new->exc_list = (yyvsp[(4) - (4)].list);
3223
yyval.exception_block = new;
3755
(yyval.exception_block) = new;
3761
/* Line 1455 of yacc.c */
3228
3762
#line 1752 "gram.y"
3230
yyval.list = lappend(yyvsp[-1].list, yyvsp[0].exception);
3764
(yyval.list) = lappend((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].exception));
3770
/* Line 1455 of yacc.c */
3235
3771
#line 1756 "gram.y"
3237
yyval.list = list_make1(yyvsp[0].exception);
3773
(yyval.list) = list_make1((yyvsp[(1) - (1)].exception));
3779
/* Line 1455 of yacc.c */
3242
3780
#line 1762 "gram.y"
3244
3782
PLpgSQL_exception *new;
3246
3784
new = palloc0(sizeof(PLpgSQL_exception));
3247
new->lineno = yyvsp[-3].ival;
3248
new->conditions = yyvsp[-2].condition;
3249
new->action = yyvsp[0].list;
3785
new->lineno = (yyvsp[(2) - (5)].ival);
3786
new->conditions = (yyvsp[(3) - (5)].condition);
3787
new->action = (yyvsp[(5) - (5)].list);
3251
yyval.exception = new;
3789
(yyval.exception) = new;
3795
/* Line 1455 of yacc.c */
3256
3796
#line 1775 "gram.y"
3258
3798
PLpgSQL_condition *old;
3260
for (old = yyvsp[-2].condition; old->next != NULL; old = old->next)
3800
for (old = (yyvsp[(1) - (3)].condition); old->next != NULL; old = old->next)
3262
old->next = yyvsp[0].condition;
3263
yyval.condition = yyvsp[-2].condition;
3802
old->next = (yyvsp[(3) - (3)].condition);
3803
(yyval.condition) = (yyvsp[(1) - (3)].condition);
3809
/* Line 1455 of yacc.c */
3268
3810
#line 1784 "gram.y"
3270
yyval.condition = yyvsp[0].condition;
3812
(yyval.condition) = (yyvsp[(1) - (1)].condition);
3818
/* Line 1455 of yacc.c */
3275
3819
#line 1790 "gram.y"
3277
if (strcmp(yyvsp[0].str, "sqlstate") != 0)
3821
if (strcmp((yyvsp[(1) - (1)].str), "sqlstate") != 0)
3279
yyval.condition = plpgsql_parse_err_condition(yyvsp[0].str);
3823
(yyval.condition) = plpgsql_parse_err_condition((yyvsp[(1) - (1)].str));
3303
3847
new->condname = sqlstatestr;
3304
3848
new->next = NULL;
3306
yyval.condition = new;
3850
(yyval.condition) = new;
3857
/* Line 1455 of yacc.c */
3312
3858
#line 1826 "gram.y"
3313
{ yyval.expr = plpgsql_read_expression(';', ";"); ;}
3859
{ (yyval.expr) = plpgsql_read_expression(';', ";"); ;}
3864
/* Line 1455 of yacc.c */
3317
3865
#line 1830 "gram.y"
3318
{ yyval.expr = plpgsql_read_expression(']', "]"); ;}
3866
{ (yyval.expr) = plpgsql_read_expression(']', "]"); ;}
3871
/* Line 1455 of yacc.c */
3322
3872
#line 1834 "gram.y"
3323
{ yyval.expr = plpgsql_read_expression(K_THEN, "THEN"); ;}
3873
{ (yyval.expr) = plpgsql_read_expression(K_THEN, "THEN"); ;}
3878
/* Line 1455 of yacc.c */
3327
3879
#line 1838 "gram.y"
3328
{ yyval.expr = plpgsql_read_expression(K_LOOP, "LOOP"); ;}
3880
{ (yyval.expr) = plpgsql_read_expression(K_LOOP, "LOOP"); ;}
3885
/* Line 1455 of yacc.c */
3332
3886
#line 1842 "gram.y"
3334
3888
plpgsql_ns_push(NULL);
3895
/* Line 1455 of yacc.c */
3340
3896
#line 1847 "gram.y"
3342
plpgsql_ns_push(yyvsp[-2].str);
3343
yyval.str = yyvsp[-2].str;
3898
plpgsql_ns_push((yyvsp[(3) - (5)].str));
3899
(yyval.str) = (yyvsp[(3) - (5)].str);
3905
/* Line 1455 of yacc.c */
3348
3906
#line 1854 "gram.y"
3914
/* Line 1455 of yacc.c */
3355
3915
#line 1858 "gram.y"
3357
yyval.str = check_label(yyvsp[0].str);
3917
(yyval.str) = check_label((yyvsp[(1) - (1)].str));
3923
/* Line 1455 of yacc.c */
3362
3924
#line 1864 "gram.y"
3363
{ yyval.expr = NULL; ;}
3925
{ (yyval.expr) = NULL; ;}
3930
/* Line 1455 of yacc.c */
3367
3931
#line 1866 "gram.y"
3368
{ yyval.expr = yyvsp[0].expr; ;}
3932
{ (yyval.expr) = (yyvsp[(2) - (2)].expr); ;}
3937
/* Line 1455 of yacc.c */
3372
3938
#line 1873 "gram.y"
3940
(yyval.str) = yytext;
3946
/* Line 1455 of yacc.c */
3379
3947
#line 1877 "gram.y"
3949
(yyval.str) = yytext;
3955
/* Line 1455 of yacc.c */
3386
3956
#line 1881 "gram.y"
3958
(yyval.str) = yytext;
3964
/* Line 1455 of yacc.c */
3393
3965
#line 1885 "gram.y"
3967
(yyval.str) = yytext;
3973
/* Line 1455 of yacc.c */
3400
3974
#line 1891 "gram.y"
3404
plpgsql_convert_ident(yyvsp[0].str, &name, 1);
3978
plpgsql_convert_ident((yyvsp[(1) - (1)].str), &name, 1);
3985
/* Line 1455 of yacc.c */
3410
3986
#line 1900 "gram.y"
3412
yyval.ival = plpgsql_error_lineno = plpgsql_scanner_lineno();
3988
(yyval.ival) = plpgsql_error_lineno = plpgsql_scanner_lineno();
3994
/* Line 1455 of yacc.c */
3995
#line 3996 "pl_gram.c"
3419
/* Line 991 of yacc.c. */
3420
#line 3420 "pl_gram.c"
3998
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
3426
4002
YY_STACK_PRINT (yyss, yyssp);
3428
4004
*++yyvsp = yyval;
3431
4006
/* Now `shift' the result of the reduction. Determine what state
3432
4007
that goes to, based on the state we popped back to and the rule
3433
4008
number reduced by. */
3451
4026
if (!yyerrstatus)
3455
yyn = yypact[yystate];
3457
if (YYPACT_NINF < yyn && yyn < YYLAST)
3459
YYSIZE_T yysize = 0;
3460
int yytype = YYTRANSLATE (yychar);
3465
/* Start YYX at -YYN if negative to avoid negative indexes in
3467
for (yyx = yyn < 0 ? -yyn : 0;
3468
yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
3469
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3470
yysize += yystrlen (yytname[yyx]) + 15, yycount++;
3471
yysize += yystrlen ("syntax error, unexpected ") + 1;
3472
yysize += yystrlen (yytname[yytype]);
3473
yymsg = (char *) YYSTACK_ALLOC (yysize);
3476
char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
3477
yyp = yystpcpy (yyp, yytname[yytype]);
3482
for (yyx = yyn < 0 ? -yyn : 0;
3483
yyx < (int) (sizeof (yytname) / sizeof (char *));
3485
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3487
const char *yyq = ! yycount ? ", expecting " : " or ";
3488
yyp = yystpcpy (yyp, yyq);
3489
yyp = yystpcpy (yyp, yytname[yyx]);
4029
#if ! YYERROR_VERBOSE
4030
yyerror (YY_("syntax error"));
4033
YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
4034
if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
4036
YYSIZE_T yyalloc = 2 * yysize;
4037
if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
4038
yyalloc = YYSTACK_ALLOC_MAXIMUM;
4039
if (yymsg != yymsgbuf)
3494
4040
YYSTACK_FREE (yymsg);
3497
yyerror ("syntax error; also virtual memory exhausted");
3500
#endif /* YYERROR_VERBOSE */
3501
yyerror ("syntax error");
4041
yymsg = (char *) YYSTACK_ALLOC (yyalloc);
4043
yymsg_alloc = yyalloc;
4047
yymsg_alloc = sizeof yymsgbuf;
4051
if (0 < yysize && yysize <= yymsg_alloc)
4053
(void) yysyntax_error (yymsg, yystate, yychar);
4058
yyerror (YY_("syntax error"));
4060
goto yyexhaustedlab;