~ubuntu-branches/ubuntu/saucy/postgresql-8.4/saucy

« back to all changes in this revision

Viewing changes to src/pl/plpgsql/src/pl_gram.c

  • Committer: Package Import Robot
  • Author(s): Martin Pitt
  • Date: 2011-12-02 14:46:33 UTC
  • mfrom: (13.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20111202144633-azdcoyqh7sduwr15
Tags: 8.4.10-1
* New upstream bug fix release:
  - Fix bugs in information_schema.referential_constraints view.
    This view was being insufficiently careful about matching the
    foreign-key constraint to the depended-on primary or unique key
    constraint. That could result in failure to show a foreign key
    constraint at all, or showing it multiple times, or claiming that
    it depends on a different constraint than the one it really does.
    Since the view definition is installed by initdb, merely upgrading
    will not fix the problem. If you need to fix this in an existing
    installation, you can (as a superuser) drop the information_schema
    schema then re-create it by sourcing
    "SHAREDIR/information_schema.sql". (Run pg_config --sharedir if
    you're uncertain where "SHAREDIR" is.) This must be repeated in
    each database to be fixed.
  - Fix incorrect replay of WAL records for GIN index updates.
    This could result in transiently failing to find index entries
    after a crash, or on a hot-standby server. The problem would be
    repaired by the next "VACUUM" of the index, however.
  - Fix TOAST-related data corruption during CREATE TABLE dest AS
    SELECT - FROM src or INSERT INTO dest SELECT * FROM src.
    If a table has been modified by "ALTER TABLE ADD COLUMN", attempts
    to copy its data verbatim to another table could produce corrupt
    results in certain corner cases. The problem can only manifest in
    this precise form in 8.4 and later, but we patched earlier versions
    as well in case there are other code paths that could trigger the
    same bug.
  - Fix race condition during toast table access from stale syscache
    entries.
  - Track dependencies of functions on items used in parameter default
    expressions. Previously, a referenced object could be dropped without
    having dropped or modified the function, leading to misbehavior when the
    function was used. Note that merely installing this update will not fix
    the missing dependency entries; to do that, you'd need to "CREATE OR
    REPLACE" each such function afterwards. If you have functions whose
    defaults depend on non-built-in objects, doing so is recommended.
  - Allow inlining of set-returning SQL functions with multiple OUT
    parameters.
  - Make DatumGetInetP() unpack inet datums that have a 1-byte header,
    and add a new macro, DatumGetInetPP(), that does not.
  - Improve locale support in money type's input and output.
    Aside from not supporting all standard lc_monetary formatting
    options, the input and output functions were inconsistent, meaning
    there were locales in which dumped money values could not be
    re-read.
  - Don't let transform_null_equals affect CASE foo WHEN NULL ...
    constructs. transform_null_equals is only supposed to affect foo = NULL
    expressions written directly by the user, not equality checks
    generated internally by this form of CASE.
  - Change foreign-key trigger creation order to better support
    self-referential foreign keys. For a cascading foreign key that
    references its own table, a row update will fire both the ON UPDATE
    trigger and the CHECK trigger as one event. The ON UPDATE trigger must
    execute first, else the CHECK will check a non-final state of the row
    and possibly throw an inappropriate error. However, the firing order of
    these triggers is determined by their names, which generally sort in
    creation order since the triggers have auto-generated names following
    the convention "RI_ConstraintTrigger_NNNN". A proper fix would require
    modifying that convention, which we will do in 9.2, but it seems risky
    to change it in existing releases. So this patch just changes the
    creation order of the triggers. Users encountering this type of error
    should drop and re-create the foreign key constraint to get its triggers
    into the right order.
  - Avoid floating-point underflow while tracking buffer allocation
    rate.
  - Preserve blank lines within commands in psql's command history.
    The former behavior could cause problems if an empty line was
    removed from within a string literal, for example.
  - Fix pg_dump to dump user-defined casts between auto-generated
    types, such as table rowtypes.
  - Use the preferred version of xsubpp to build PL/Perl, not
    necessarily the operating system's main copy.
  - Fix incorrect coding in "contrib/dict_int" and "contrib/dict_xsyn".
  - Honor query cancel interrupts promptly in pgstatindex().
  - Ensure VPATH builds properly install all server header files.
  - Shorten file names reported in verbose error messages.
    Regular builds have always reported just the name of the C file
    containing the error message call, but VPATH builds formerly
    reported an absolute path name.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* A Bison parser, made by GNU Bison 1.875.  */
2
 
 
3
 
/* Skeleton parser for Yacc-like parsing with Bison,
4
 
   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
5
 
 
6
 
   This program is free software; you can redistribute it and/or modify
 
1
 
 
2
/* A Bison parser, made by GNU Bison 2.4.1.  */
 
3
 
 
4
/* Skeleton implementation for Bison's Yacc-like parsers in C
 
5
   
 
6
      Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
 
7
   Free Software Foundation, Inc.
 
8
   
 
9
   This program is free software: you can redistribute it and/or modify
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)
9
 
   any later version.
10
 
 
 
11
   the Free Software Foundation, either version 3 of the License, or
 
12
   (at your option) any later version.
 
13
   
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.
15
 
 
 
18
   
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.  */
20
 
 
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.  */
25
 
 
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/>.  */
 
21
 
 
22
/* As a special exception, you may create a larger work that contains
 
23
   part or all of the Bison parser skeleton and distribute that work
 
24
   under terms of your choice, so long as that work isn't itself a
 
25
   parser generator using the skeleton or a modified version thereof
 
26
   as a parser skeleton.  Alternatively, if you modify or redistribute
 
27
   the parser skeleton itself, you may (at your option) remove this
 
28
   special exception, which will cause the skeleton and the resulting
 
29
   Bison output files to be licensed under the GNU General Public
 
30
   License without this special exception.
 
31
   
 
32
   This special exception was added by the Free Software Foundation in
 
33
   version 2.2 of Bison.  */
 
34
 
 
35
/* C LALR(1) parser skeleton written by Richard Stallman, by
 
36
   simplifying the original so-called "semantic" parser.  */
28
37
 
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.  */
37
46
#define YYBISON 1
38
47
 
 
48
/* Bison version.  */
 
49
#define YYBISON_VERSION "2.4.1"
 
50
 
39
51
/* Skeleton name.  */
40
52
#define YYSKELETON_NAME "yacc.c"
41
53
 
42
54
/* Pure parsers.  */
43
55
#define YYPURE 0
44
56
 
 
57
/* Push parsers.  */
 
58
#define YYPUSH 0
 
59
 
 
60
/* Pull parsers.  */
 
61
#define YYPULL 1
 
62
 
45
63
/* Using locations.  */
46
64
#define YYLSP_NEEDED 0
47
65
 
48
 
/* If NAME_PREFIX is specified substitute the variables and functions
49
 
   names.  */
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
 
74
 
 
75
 
 
76
/* Copy the first part of user declarations.  */
 
77
 
 
78
/* Line 189 of yacc.c  */
 
79
#line 1 "gram.y"
 
80
 
 
81
/*-------------------------------------------------------------------------
 
82
 *
 
83
 * gram.y                               - Parser for the PL/pgSQL
 
84
 *                                                procedural language
 
85
 *
 
86
 * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
 
87
 * Portions Copyright (c) 1994, Regents of the University of California
 
88
 *
 
89
 *
 
90
 * IDENTIFICATION
 
91
 *        $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.125.2.1 2010/08/19 18:58:11 tgl Exp $
 
92
 *
 
93
 *-------------------------------------------------------------------------
 
94
 */
 
95
 
 
96
#include "plpgsql.h"
 
97
 
 
98
#include "catalog/pg_type.h"
 
99
#include "parser/parser.h"
 
100
 
 
101
 
 
102
/*
 
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.
 
109
 */
 
110
#define YYMALLOC palloc
 
111
#define YYFREE   pfree
 
112
 
 
113
 
 
114
static PLpgSQL_expr             *read_sql_construct(int until,
 
115
                                                                                        int until2,
 
116
                                                                                        int until3,
 
117
                                                                                        const char *expected,
 
118
                                                                                        const char *sqlstart,
 
119
                                                                                        bool isexpression,
 
120
                                                                                        bool valid_sql,
 
121
                                                                                        int *endtoken);
 
122
static PLpgSQL_expr             *read_sql_expression2(int until, int until2,
 
123
                                                                                          const char *expected,
 
124
                                                                                          int *endtoken);
 
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,
 
136
                                                                                  bool *strict);
 
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,
 
141
                                                                                   int lineno);
 
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);
 
152
 
 
153
 
 
154
 
 
155
/* Line 189 of yacc.c  */
 
156
#line 157 "pl_gram.c"
 
157
 
 
158
/* Enabling traces.  */
 
159
#ifndef YYDEBUG
 
160
# define YYDEBUG 0
 
161
#endif
 
162
 
 
163
/* Enabling verbose error messages.  */
 
164
#ifdef YYERROR_VERBOSE
 
165
# undef YYERROR_VERBOSE
 
166
# define YYERROR_VERBOSE 1
 
167
#else
 
168
# define YYERROR_VERBOSE 0
 
169
#endif
 
170
 
 
171
/* Enabling the token table.  */
 
172
#ifndef YYTOKEN_TABLE
 
173
# define YYTOKEN_TABLE 0
 
174
#endif
57
175
 
58
176
 
59
177
/* Tokens.  */
124
242
     O_DUMP = 317
125
243
   };
126
244
#endif
127
 
#define K_ALIAS 258
128
 
#define K_ASSIGN 259
129
 
#define K_BEGIN 260
130
 
#define K_BY 261
131
 
#define K_CASE 262
132
 
#define K_CLOSE 263
133
 
#define K_CONSTANT 264
134
 
#define K_CONTINUE 265
135
 
#define K_CURSOR 266
136
 
#define K_DECLARE 267
137
 
#define K_DEFAULT 268
138
 
#define K_DIAGNOSTICS 269
139
 
#define K_DOTDOT 270
140
 
#define K_ELSE 271
141
 
#define K_ELSIF 272
142
 
#define K_END 273
143
 
#define K_EXCEPTION 274
144
 
#define K_EXECUTE 275
145
 
#define K_EXIT 276
146
 
#define K_FOR 277
147
 
#define K_FETCH 278
148
 
#define K_FROM 279
149
 
#define K_GET 280
150
 
#define K_IF 281
151
 
#define K_IN 282
152
 
#define K_INSERT 283
153
 
#define K_INTO 284
154
 
#define K_IS 285
155
 
#define K_LOOP 286
156
 
#define K_MOVE 287
157
 
#define K_NOSCROLL 288
158
 
#define K_NOT 289
159
 
#define K_NULL 290
160
 
#define K_OPEN 291
161
 
#define K_OR 292
162
 
#define K_PERFORM 293
163
 
#define K_ROW_COUNT 294
164
 
#define K_RAISE 295
165
 
#define K_RENAME 296
166
 
#define K_RESULT_OID 297
167
 
#define K_RETURN 298
168
 
#define K_REVERSE 299
169
 
#define K_SCROLL 300
170
 
#define K_STRICT 301
171
 
#define K_THEN 302
172
 
#define K_TO 303
173
 
#define K_TYPE 304
174
 
#define K_USING 305
175
 
#define K_WHEN 306
176
 
#define K_WHILE 307
177
 
#define T_STRING 308
178
 
#define T_NUMBER 309
179
 
#define T_SCALAR 310
180
 
#define T_ROW 311
181
 
#define T_RECORD 312
182
 
#define T_DTYPE 313
183
 
#define T_WORD 314
184
 
#define T_ERROR 315
185
 
#define O_OPTION 316
186
 
#define O_DUMP 317
187
 
 
188
 
 
189
 
 
190
 
 
191
 
/* Copy the first part of user declarations.  */
192
 
#line 1 "gram.y"
193
 
 
194
 
/*-------------------------------------------------------------------------
195
 
 *
196
 
 * gram.y                               - Parser for the PL/pgSQL
197
 
 *                                                procedural language
198
 
 *
199
 
 * Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
200
 
 * Portions Copyright (c) 1994, Regents of the University of California
201
 
 *
202
 
 *
203
 
 * IDENTIFICATION
204
 
 *        $PostgreSQL: pgsql/src/pl/plpgsql/src/gram.y,v 1.125.2.1 2010/08/19 18:58:11 tgl Exp $
205
 
 *
206
 
 *-------------------------------------------------------------------------
207
 
 */
208
 
 
209
 
#include "plpgsql.h"
210
 
 
211
 
#include "catalog/pg_type.h"
212
 
#include "parser/parser.h"
213
 
 
214
 
 
215
 
/*
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.
222
 
 */
223
 
#define YYMALLOC palloc
224
 
#define YYFREE   pfree
225
 
 
226
 
 
227
 
static PLpgSQL_expr             *read_sql_construct(int until,
228
 
                                                                                        int until2,
229
 
                                                                                        int until3,
230
 
                                                                                        const char *expected,
231
 
                                                                                        const char *sqlstart,
232
 
                                                                                        bool isexpression,
233
 
                                                                                        bool valid_sql,
234
 
                                                                                        int *endtoken);
235
 
static PLpgSQL_expr             *read_sql_expression2(int until, int until2,
236
 
                                                                                          const char *expected,
237
 
                                                                                          int *endtoken);
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,
249
 
                                                                                  bool *strict);
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,
254
 
                                                                                   int lineno);
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);
265
 
 
266
 
 
267
 
 
268
 
/* Enabling traces.  */
269
 
#ifndef YYDEBUG
270
 
# define YYDEBUG 0
271
 
#endif
272
 
 
273
 
/* Enabling verbose error messages.  */
274
 
#ifdef YYERROR_VERBOSE
275
 
# undef YYERROR_VERBOSE
276
 
# define YYERROR_VERBOSE 1
277
 
#else
278
 
# define YYERROR_VERBOSE 0
279
 
#endif
280
 
 
281
 
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
 
245
 
 
246
 
 
247
 
 
248
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 
249
typedef union YYSTYPE
 
250
{
 
251
 
 
252
/* Line 214 of yacc.c  */
282
253
#line 79 "gram.y"
283
 
typedef union YYSTYPE {
 
254
 
284
255
                int32                                   ival;
285
256
                bool                                    boolean;
286
257
                char                                    *str;
325
296
                PLpgSQL_diag_item               *diagitem;
326
297
                PLpgSQL_stmt_fetch              *fetch;
327
298
                PLpgSQL_case_when               *casewhen;
 
299
 
 
300
 
 
301
 
 
302
/* Line 214 of yacc.c  */
 
303
#line 304 "pl_gram.c"
328
304
} YYSTYPE;
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
334
308
#endif
335
309
 
336
310
 
337
 
 
338
311
/* Copy the second part of user declarations.  */
339
312
 
340
313
 
341
 
/* Line 214 of yacc.c.  */
342
 
#line 342 "pl_gram.c"
343
 
 
344
 
#if ! defined (yyoverflow) || YYERROR_VERBOSE
 
314
/* Line 264 of yacc.c  */
 
315
#line 316 "pl_gram.c"
 
316
 
 
317
#ifdef short
 
318
# undef short
 
319
#endif
 
320
 
 
321
#ifdef YYTYPE_UINT8
 
322
typedef YYTYPE_UINT8 yytype_uint8;
 
323
#else
 
324
typedef unsigned char yytype_uint8;
 
325
#endif
 
326
 
 
327
#ifdef YYTYPE_INT8
 
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;
 
332
#else
 
333
typedef short int yytype_int8;
 
334
#endif
 
335
 
 
336
#ifdef YYTYPE_UINT16
 
337
typedef YYTYPE_UINT16 yytype_uint16;
 
338
#else
 
339
typedef unsigned short int yytype_uint16;
 
340
#endif
 
341
 
 
342
#ifdef YYTYPE_INT16
 
343
typedef YYTYPE_INT16 yytype_int16;
 
344
#else
 
345
typedef short int yytype_int16;
 
346
#endif
 
347
 
 
348
#ifndef YYSIZE_T
 
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
 
357
# else
 
358
#  define YYSIZE_T unsigned int
 
359
# endif
 
360
#endif
 
361
 
 
362
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
 
363
 
 
364
#ifndef YY_
 
365
# if YYENABLE_NLS
 
366
#  if ENABLE_NLS
 
367
#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
 
368
#   define YY_(msgid) dgettext ("bison-runtime", msgid)
 
369
#  endif
 
370
# endif
 
371
# ifndef YY_
 
372
#  define YY_(msgid) msgid
 
373
# endif
 
374
#endif
 
375
 
 
376
/* Suppress unused-variable warnings by "using" E.  */
 
377
#if ! defined lint || defined __GNUC__
 
378
# define YYUSE(e) ((void) (e))
 
379
#else
 
380
# define YYUSE(e) /* empty */
 
381
#endif
 
382
 
 
383
/* Identity function, used to suppress warnings about constant conditions.  */
 
384
#ifndef lint
 
385
# define YYID(n) (n)
 
386
#else
 
387
#if (defined __STDC__ || defined __C99__FUNC__ \
 
388
     || defined __cplusplus || defined _MSC_VER)
 
389
static int
 
390
YYID (int yyi)
 
391
#else
 
392
static int
 
393
YYID (yyi)
 
394
    int yyi;
 
395
#endif
 
396
{
 
397
  return yyi;
 
398
}
 
399
#endif
 
400
 
 
401
#if ! defined yyoverflow || YYERROR_VERBOSE
345
402
 
346
403
/* The parser invokes alloca or malloc; define the necessary symbols.  */
347
404
 
348
 
# if YYSTACK_USE_ALLOCA
349
 
#  define YYSTACK_ALLOC alloca
350
 
# else
351
 
#  ifndef YYSTACK_USE_ALLOCA
352
 
#   if defined (alloca) || defined (_ALLOCA_H)
 
405
# ifdef YYSTACK_USE_ALLOCA
 
406
#  if YYSTACK_USE_ALLOCA
 
407
#   ifdef __GNUC__
 
408
#    define YYSTACK_ALLOC __builtin_alloca
 
409
#   elif defined __BUILTIN_VA_ARG_INCR
 
410
#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
 
411
#   elif defined _AIX
 
412
#    define YYSTACK_ALLOC __alloca
 
413
#   elif defined _MSC_VER
 
414
#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
 
415
#    define alloca _alloca
 
416
#   else
353
417
#    define YYSTACK_ALLOC alloca
354
 
#   else
355
 
#    ifdef __GNUC__
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 */
 
421
#     ifndef _STDLIB_H
 
422
#      define _STDLIB_H 1
 
423
#     endif
357
424
#    endif
358
425
#   endif
359
426
#  endif
360
427
# endif
361
428
 
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 */
 
438
#  endif
365
439
# else
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
 
444
#  endif
 
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
369
 
#  endif
370
 
#  define YYSTACK_ALLOC malloc
371
 
#  define YYSTACK_FREE free
 
449
#   ifndef _STDLIB_H
 
450
#    define _STDLIB_H 1
 
451
#   endif
 
452
#  endif
 
453
#  ifndef YYMALLOC
 
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 */
 
458
#   endif
 
459
#  endif
 
460
#  ifndef YYFREE
 
461
#   define YYFREE free
 
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 */
 
465
#   endif
 
466
#  endif
372
467
# endif
373
 
#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
374
 
 
375
 
 
376
 
#if (! defined (yyoverflow) \
377
 
     && (! defined (__cplusplus) \
378
 
         || (YYSTYPE_IS_TRIVIAL)))
 
468
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
 
469
 
 
470
 
 
471
#if (! defined yyoverflow \
 
472
     && (! defined __cplusplus \
 
473
         || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
379
474
 
380
475
/* A type that is properly aligned for any stack member.  */
381
476
union yyalloc
382
477
{
383
 
  short yyss;
384
 
  YYSTYPE yyvs;
385
 
  };
 
478
  yytype_int16 yyss_alloc;
 
479
  YYSTYPE yyvs_alloc;
 
480
};
386
481
 
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)
390
485
/* The size of an array large to enough to hold all stacks, each with
391
486
   N elements.  */
392
487
# define YYSTACK_BYTES(N) \
393
 
     ((N) * (sizeof (short) + sizeof (YYSTYPE))                         \
 
488
     ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \
394
489
      + YYSTACK_GAP_MAXIMUM)
395
490
 
396
491
/* Copy COUNT objects from FROM to TO.  The source and destination do
397
492
   not overlap.  */
398
493
# ifndef YYCOPY
399
 
#  if 1 < __GNUC__
 
494
#  if defined __GNUC__ && 1 < __GNUC__
400
495
#   define YYCOPY(To, From, Count) \
401
496
      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
402
497
#  else
403
498
#   define YYCOPY(To, From, Count)              \
404
499
      do                                        \
405
500
        {                                       \
406
 
          register YYSIZE_T yyi;                \
 
501
          YYSIZE_T yyi;                         \
407
502
          for (yyi = 0; yyi < (Count); yyi++)   \
408
503
            (To)[yyi] = (From)[yyi];            \
409
504
        }                                       \
410
 
      while (0)
 
505
      while (YYID (0))
411
506
#  endif
412
507
# endif
413
508
 
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
418
513
   stack.  */
419
 
# define YYSTACK_RELOCATE(Stack)                                        \
 
514
# define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
420
515
    do                                                                  \
421
516
      {                                                                 \
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);                          \
427
522
      }                                                                 \
428
 
    while (0)
429
 
 
430
 
#endif
431
 
 
432
 
#if defined (__STDC__) || defined (__cplusplus)
433
 
   typedef signed char yysigned_char;
434
 
#else
435
 
   typedef short yysigned_char;
436
 
#endif
437
 
 
438
 
/* YYFINAL -- State number of the termination state. */
 
523
    while (YYID (0))
 
524
 
 
525
#endif
 
526
 
 
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
442
531
 
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
451
540
 
452
541
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
453
542
#define YYUNDEFTOK  2
454
543
#define YYMAXUTOK   317
455
544
 
456
 
#define YYTRANSLATE(YYX)                                                \
 
545
#define YYTRANSLATE(YYX)                                                \
457
546
  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
458
547
 
459
548
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
460
 
static const unsigned char yytranslate[] =
 
549
static const yytype_uint8 yytranslate[] =
461
550
{
462
551
       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
463
552
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
496
585
#if YYDEBUG
497
586
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
498
587
   YYRHS.  */
499
 
static const unsigned short yyprhs[] =
 
588
static const yytype_uint16 yyprhs[] =
500
589
{
501
590
       0,     0,     3,     7,     8,    10,    13,    15,    18,    19,
502
591
      21,    29,    31,    34,    38,    40,    43,    45,    51,    53,
516
605
     412,   414,   416,   418,   420
517
606
};
518
607
 
519
 
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
520
 
static const short yyrhs[] =
 
608
/* YYRHS -- A `-1'-separated list of the rules' RHS.  */
 
609
static const yytype_int16 yyrhs[] =
521
610
{
522
611
      71,     0,    -1,    72,    76,    75,    -1,    -1,    73,    -1,
523
612
      73,    74,    -1,    74,    -1,    61,    62,    -1,    -1,    63,
565
654
};
566
655
 
567
656
/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
568
 
static const unsigned short yyrline[] =
 
657
static const yytype_uint16 yyrline[] =
569
658
{
570
659
       0,   247,   247,   253,   254,   257,   258,   261,   267,   268,
571
660
     271,   293,   300,   307,   319,   328,   330,   334,   336,   338,
586
675
};
587
676
#endif
588
677
 
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[] =
593
682
{
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
625
713
};
626
714
#endif
628
716
# ifdef YYPRINT
629
717
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
630
718
   token YYLEX-NUM.  */
631
 
static const unsigned short yytoknum[] =
 
719
static const yytype_uint16 yytoknum[] =
632
720
{
633
721
       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
634
722
     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
641
729
# endif
642
730
 
643
731
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
644
 
static const unsigned char yyr1[] =
 
732
static const yytype_uint8 yyr1[] =
645
733
{
646
734
       0,    70,    71,    72,    72,    73,    73,    74,    75,    75,
647
735
      76,    77,    77,    77,    78,    79,    79,    80,    80,    80,
662
750
};
663
751
 
664
752
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
665
 
static const unsigned char yyr2[] =
 
753
static const yytype_uint8 yyr2[] =
666
754
{
667
755
       0,     2,     3,     0,     1,     2,     1,     2,     0,     1,
668
756
       7,     1,     2,     3,     1,     2,     1,     5,     1,     1,
685
773
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
686
774
   STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
687
775
   means the default is an error.  */
688
 
static const unsigned char yydefact[] =
 
776
static const yytype_uint8 yydefact[] =
689
777
{
690
778
       3,     0,     0,   143,     4,     6,     7,     1,     0,     8,
691
779
       0,    11,     5,     0,     9,     2,   154,    14,    12,   150,
715
803
     136,   135
716
804
};
717
805
 
718
 
/* YYDEFGOTO[NTERM-NUM]. */
719
 
static const short yydefgoto[] =
 
806
/* YYDEFGOTO[NTERM-NUM].  */
 
807
static const yytype_int16 yydefgoto[] =
720
808
{
721
809
      -1,     2,     3,     4,     5,    15,    58,    10,    18,    33,
722
810
      34,    35,   149,    92,   233,   185,   211,   212,   216,   147,
732
820
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
733
821
   STATE-NUM.  */
734
822
#define YYPACT_NINF -178
735
 
static const short yypact[] =
 
823
static const yytype_int16 yypact[] =
736
824
{
737
825
     -15,   -38,    65,     2,   -15,  -178,  -178,  -178,     4,     6,
738
826
      67,    58,  -178,    26,  -178,  -178,  -178,  -178,    -7,  -178,
763
851
};
764
852
 
765
853
/* YYPGOTO[NTERM-NUM].  */
766
 
static const short yypgoto[] =
 
854
static const yytype_int16 yypgoto[] =
767
855
{
768
856
    -178,  -178,  -178,  -178,   155,  -178,   166,  -178,  -178,  -178,
769
857
     138,  -178,  -178,  -178,  -178,  -178,  -178,   -59,  -178,  -178,
781
869
   number is the opposite.  If zero, do what YYDEFACT says.
782
870
   If YYTABLE_NINF, syntax error.  */
783
871
#define YYTABLE_NINF -144
784
 
static const short yytable[] =
 
872
static const yytype_int16 yytable[] =
785
873
{
786
874
      59,    95,    96,   167,    97,    26,    98,   213,   100,   140,
787
875
     101,    24,   103,   104,   105,   106,   148,   187,   179,   169,
831
919
      57,     0,     0,     0,     8
832
920
};
833
921
 
834
 
static const short yycheck[] =
 
922
static const yytype_int16 yycheck[] =
835
923
{
836
924
      25,    38,    39,   136,    41,    12,    43,   184,    45,   113,
837
925
      47,    13,    49,    50,    51,    52,   120,     4,   143,    51,
883
971
 
884
972
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
885
973
   symbol of state STATE-NUM.  */
886
 
static const unsigned char yystos[] =
 
974
static const yytype_uint8 yystos[] =
887
975
{
888
976
       0,    61,    71,    72,    73,    74,    62,     0,    64,    76,
889
977
      77,   145,    74,    64,    63,    75,     5,    12,    78,    55,
913
1001
     140,    97
914
1002
};
915
1003
 
916
 
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
917
 
# define YYSIZE_T __SIZE_TYPE__
918
 
#endif
919
 
#if ! defined (YYSIZE_T) && defined (size_t)
920
 
# define YYSIZE_T size_t
921
 
#endif
922
 
#if ! defined (YYSIZE_T)
923
 
# if defined (__STDC__) || defined (__cplusplus)
924
 
#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
925
 
#  define YYSIZE_T size_t
926
 
# endif
927
 
#endif
928
 
#if ! defined (YYSIZE_T)
929
 
# define YYSIZE_T unsigned int
930
 
#endif
931
 
 
932
1004
#define yyerrok         (yyerrstatus = 0)
933
1005
#define yyclearin       (yychar = YYEMPTY)
934
1006
#define YYEMPTY         (-2)
936
1008
 
937
1009
#define YYACCEPT        goto yyacceptlab
938
1010
#define YYABORT         goto yyabortlab
939
 
#define YYERROR         goto yyerrlab1
 
1011
#define YYERROR         goto yyerrorlab
 
1012
 
940
1013
 
941
1014
/* Like YYERROR except do call yyerror.  This remains here temporarily
942
1015
   to ease the transition to the new meaning of YYERROR, for GCC.
953
1026
      yychar = (Token);                                         \
954
1027
      yylval = (Value);                                         \
955
1028
      yytoken = YYTRANSLATE (yychar);                           \
956
 
      YYPOPSTACK;                                               \
 
1029
      YYPOPSTACK (1);                                           \
957
1030
      goto yybackup;                                            \
958
1031
    }                                                           \
959
1032
  else                                                          \
960
 
    {                                                           \
961
 
      yyerror ("syntax error: cannot back up");\
 
1033
    {                                                           \
 
1034
      yyerror (YY_("syntax error: cannot back up")); \
962
1035
      YYERROR;                                                  \
963
1036
    }                                                           \
964
 
while (0)
 
1037
while (YYID (0))
 
1038
 
965
1039
 
966
1040
#define YYTERROR        1
967
1041
#define YYERRCODE       256
968
1042
 
969
 
/* YYLLOC_DEFAULT -- Compute the default location (before the actions
970
 
   are run).  */
971
 
 
 
1043
 
 
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).  */
 
1047
 
 
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;
978
 
#endif
 
1050
# define YYLLOC_DEFAULT(Current, Rhs, N)                                \
 
1051
    do                                                                  \
 
1052
      if (YYID (N))                                                    \
 
1053
        {                                                               \
 
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;       \
 
1058
        }                                                               \
 
1059
      else                                                              \
 
1060
        {                                                               \
 
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;                              \
 
1065
        }                                                               \
 
1066
    while (YYID (0))
 
1067
#endif
 
1068
 
 
1069
 
 
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.  */
 
1073
 
 
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)
 
1080
# else
 
1081
#  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
 
1082
# endif
 
1083
#endif
 
1084
 
979
1085
 
980
1086
/* YYLEX -- calling `yylex' with the right arguments.  */
981
1087
 
997
1103
do {                                            \
998
1104
  if (yydebug)                                  \
999
1105
    YYFPRINTF Args;                             \
1000
 
} while (0)
1001
 
 
1002
 
# define YYDSYMPRINT(Args)                      \
1003
 
do {                                            \
1004
 
  if (yydebug)                                  \
1005
 
    yysymprint Args;                            \
1006
 
} while (0)
1007
 
 
1008
 
# define YYDSYMPRINTF(Title, Token, Value, Location)            \
1009
 
do {                                                            \
1010
 
  if (yydebug)                                                  \
1011
 
    {                                                           \
1012
 
      YYFPRINTF (stderr, "%s ", Title);                         \
1013
 
      yysymprint (stderr,                                       \
1014
 
                  Token, Value);        \
1015
 
      YYFPRINTF (stderr, "\n");                                 \
1016
 
    }                                                           \
1017
 
} while (0)
 
1106
} while (YYID (0))
 
1107
 
 
1108
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
 
1109
do {                                                                      \
 
1110
  if (yydebug)                                                            \
 
1111
    {                                                                     \
 
1112
      YYFPRINTF (stderr, "%s ", Title);                                   \
 
1113
      yy_symbol_print (stderr,                                            \
 
1114
                  Type, Value); \
 
1115
      YYFPRINTF (stderr, "\n");                                           \
 
1116
    }                                                                     \
 
1117
} while (YYID (0))
 
1118
 
 
1119
 
 
1120
/*--------------------------------.
 
1121
| Print this symbol on YYOUTPUT.  |
 
1122
`--------------------------------*/
 
1123
 
 
1124
/*ARGSUSED*/
 
1125
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1126
     || defined __cplusplus || defined _MSC_VER)
 
1127
static void
 
1128
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
 
1129
#else
 
1130
static void
 
1131
yy_symbol_value_print (yyoutput, yytype, yyvaluep)
 
1132
    FILE *yyoutput;
 
1133
    int yytype;
 
1134
    YYSTYPE const * const yyvaluep;
 
1135
#endif
 
1136
{
 
1137
  if (!yyvaluep)
 
1138
    return;
 
1139
# ifdef YYPRINT
 
1140
  if (yytype < YYNTOKENS)
 
1141
    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
 
1142
# else
 
1143
  YYUSE (yyoutput);
 
1144
# endif
 
1145
  switch (yytype)
 
1146
    {
 
1147
      default:
 
1148
        break;
 
1149
    }
 
1150
}
 
1151
 
 
1152
 
 
1153
/*--------------------------------.
 
1154
| Print this symbol on YYOUTPUT.  |
 
1155
`--------------------------------*/
 
1156
 
 
1157
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1158
     || defined __cplusplus || defined _MSC_VER)
 
1159
static void
 
1160
yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep)
 
1161
#else
 
1162
static void
 
1163
yy_symbol_print (yyoutput, yytype, yyvaluep)
 
1164
    FILE *yyoutput;
 
1165
    int yytype;
 
1166
    YYSTYPE const * const yyvaluep;
 
1167
#endif
 
1168
{
 
1169
  if (yytype < YYNTOKENS)
 
1170
    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
 
1171
  else
 
1172
    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
 
1173
 
 
1174
  yy_symbol_value_print (yyoutput, yytype, yyvaluep);
 
1175
  YYFPRINTF (yyoutput, ")");
 
1176
}
1018
1177
 
1019
1178
/*------------------------------------------------------------------.
1020
1179
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
1021
 
| TOP (cinluded).                                                   |
 
1180
| TOP (included).                                                   |
1022
1181
`------------------------------------------------------------------*/
1023
1182
 
1024
 
#if defined (__STDC__) || defined (__cplusplus)
 
1183
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1184
     || defined __cplusplus || defined _MSC_VER)
1025
1185
static void
1026
 
yy_stack_print (short *bottom, short *top)
 
1186
yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1027
1187
#else
1028
1188
static void
1029
 
yy_stack_print (bottom, top)
1030
 
    short *bottom;
1031
 
    short *top;
 
1189
yy_stack_print (yybottom, yytop)
 
1190
    yytype_int16 *yybottom;
 
1191
    yytype_int16 *yytop;
1032
1192
#endif
1033
1193
{
1034
1194
  YYFPRINTF (stderr, "Stack now");
1035
 
  for (/* Nothing. */; bottom <= top; ++bottom)
1036
 
    YYFPRINTF (stderr, " %d", *bottom);
 
1195
  for (; yybottom <= yytop; yybottom++)
 
1196
    {
 
1197
      int yybot = *yybottom;
 
1198
      YYFPRINTF (stderr, " %d", yybot);
 
1199
    }
1037
1200
  YYFPRINTF (stderr, "\n");
1038
1201
}
1039
1202
 
1041
1204
do {                                                            \
1042
1205
  if (yydebug)                                                  \
1043
1206
    yy_stack_print ((Bottom), (Top));                           \
1044
 
} while (0)
 
1207
} while (YYID (0))
1045
1208
 
1046
1209
 
1047
1210
/*------------------------------------------------.
1048
1211
| Report that the YYRULE is going to be reduced.  |
1049
1212
`------------------------------------------------*/
1050
1213
 
1051
 
#if defined (__STDC__) || defined (__cplusplus)
 
1214
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1215
     || defined __cplusplus || defined _MSC_VER)
1052
1216
static void
1053
 
yy_reduce_print (int yyrule)
 
1217
yy_reduce_print (YYSTYPE *yyvsp, int yyrule)
1054
1218
#else
1055
1219
static void
1056
 
yy_reduce_print (yyrule)
 
1220
yy_reduce_print (yyvsp, yyrule)
 
1221
    YYSTYPE *yyvsp;
1057
1222
    int yyrule;
1058
1223
#endif
1059
1224
{
 
1225
  int yynrhs = yyr2[yyrule];
1060
1226
  int yyi;
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",
 
1229
             yyrule - 1, yylno);
 
1230
  /* The symbols being reduced.  */
 
1231
  for (yyi = 0; yyi < yynrhs; yyi++)
 
1232
    {
 
1233
      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
 
1234
      yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
 
1235
                       &(yyvsp[(yyi + 1) - (yynrhs)])
 
1236
                                       );
 
1237
      YYFPRINTF (stderr, "\n");
 
1238
    }
1068
1239
}
1069
1240
 
1070
1241
# define YY_REDUCE_PRINT(Rule)          \
1071
1242
do {                                    \
1072
1243
  if (yydebug)                          \
1073
 
    yy_reduce_print (Rule);             \
1074
 
} while (0)
 
1244
    yy_reduce_print (yyvsp, Rule); \
 
1245
} while (YYID (0))
1075
1246
 
1076
1247
/* Nonzero means print parse trace.  It is left uninitialized so that
1077
1248
   multiple parsers can coexist.  */
1078
1249
int yydebug;
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 */
1094
1264
   if the built-in stack extension method is used).
1095
1265
 
1096
1266
   Do not make this value too large; the results are undefined if
1097
 
   SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
 
1267
   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1098
1268
   evaluated with infinite-precision integer arithmetic.  */
1099
1269
 
1100
 
#if YYMAXDEPTH == 0
1101
 
# undef YYMAXDEPTH
1102
 
#endif
1103
 
 
1104
1270
#ifndef YYMAXDEPTH
1105
1271
# define YYMAXDEPTH 10000
1106
1272
#endif
1110
1276
#if YYERROR_VERBOSE
1111
1277
 
1112
1278
# ifndef yystrlen
1113
 
#  if defined (__GLIBC__) && defined (_STRING_H)
 
1279
#  if defined __GLIBC__ && defined _STRING_H
1114
1280
#   define yystrlen strlen
1115
1281
#  else
1116
1282
/* Return the length of YYSTR.  */
 
1283
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1284
     || defined __cplusplus || defined _MSC_VER)
1117
1285
static YYSIZE_T
1118
 
#   if defined (__STDC__) || defined (__cplusplus)
1119
1286
yystrlen (const char *yystr)
1120
 
#   else
 
1287
#else
 
1288
static YYSIZE_T
1121
1289
yystrlen (yystr)
1122
 
     const char *yystr;
1123
 
#   endif
 
1290
    const char *yystr;
 
1291
#endif
1124
1292
{
1125
 
  register const char *yys = yystr;
1126
 
 
1127
 
  while (*yys++ != '\0')
 
1293
  YYSIZE_T yylen;
 
1294
  for (yylen = 0; yystr[yylen]; yylen++)
1128
1295
    continue;
1129
 
 
1130
 
  return yys - yystr - 1;
 
1296
  return yylen;
1131
1297
}
1132
1298
#  endif
1133
1299
# endif
1134
1300
 
1135
1301
# ifndef yystpcpy
1136
 
#  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
 
1302
#  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1137
1303
#   define yystpcpy stpcpy
1138
1304
#  else
1139
1305
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1140
1306
   YYDEST.  */
 
1307
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1308
     || defined __cplusplus || defined _MSC_VER)
1141
1309
static char *
1142
 
#   if defined (__STDC__) || defined (__cplusplus)
1143
1310
yystpcpy (char *yydest, const char *yysrc)
1144
 
#   else
 
1311
#else
 
1312
static char *
1145
1313
yystpcpy (yydest, yysrc)
1146
 
     char *yydest;
1147
 
     const char *yysrc;
1148
 
#   endif
 
1314
    char *yydest;
 
1315
    const char *yysrc;
 
1316
#endif
1149
1317
{
1150
 
  register char *yyd = yydest;
1151
 
  register const char *yys = yysrc;
 
1318
  char *yyd = yydest;
 
1319
  const char *yys = yysrc;
1152
1320
 
1153
1321
  while ((*yyd++ = *yys++) != '\0')
1154
1322
    continue;
1158
1326
#  endif
1159
1327
# endif
1160
1328
 
1161
 
#endif /* !YYERROR_VERBOSE */
1162
 
 
 
1329
# ifndef yytnamerr
 
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
 
1336
   would have been.  */
 
1337
static YYSIZE_T
 
1338
yytnamerr (char *yyres, const char *yystr)
 
1339
{
 
1340
  if (*yystr == '"')
 
1341
    {
 
1342
      YYSIZE_T yyn = 0;
 
1343
      char const *yyp = yystr;
 
1344
 
 
1345
      for (;;)
 
1346
        switch (*++yyp)
 
1347
          {
 
1348
          case '\'':
 
1349
          case ',':
 
1350
            goto do_not_strip_quotes;
 
1351
 
 
1352
          case '\\':
 
1353
            if (*++yyp != '\\')
 
1354
              goto do_not_strip_quotes;
 
1355
            /* Fall through.  */
 
1356
          default:
 
1357
            if (yyres)
 
1358
              yyres[yyn] = *yyp;
 
1359
            yyn++;
 
1360
            break;
 
1361
 
 
1362
          case '"':
 
1363
            if (yyres)
 
1364
              yyres[yyn] = '\0';
 
1365
            return yyn;
 
1366
          }
 
1367
    do_not_strip_quotes: ;
 
1368
    }
 
1369
 
 
1370
  if (! yyres)
 
1371
    return yystrlen (yystr);
 
1372
 
 
1373
  return yystpcpy (yyres, yystr) - yyres;
 
1374
}
 
1375
# endif
 
1376
 
 
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.  */
 
1384
static YYSIZE_T
 
1385
yysyntax_error (char *yyresult, int yystate, int yychar)
 
1386
{
 
1387
  int yyn = yypact[yystate];
 
1388
 
 
1389
  if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
 
1390
    return 0;
 
1391
  else
 
1392
    {
 
1393
      int yytype = YYTRANSLATE (yychar);
 
1394
      YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
 
1395
      YYSIZE_T yysize = yysize0;
 
1396
      YYSIZE_T yysize1;
 
1397
      int yysize_overflow = 0;
 
1398
      enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
 
1399
      char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
 
1400
      int yyx;
 
1401
 
 
1402
# if 0
 
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");
 
1410
# endif
 
1411
      char *yyfmt;
 
1412
      char const *yyf;
 
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;
 
1421
 
 
1422
      /* Start YYX at -YYN if negative to avoid negative indexes in
 
1423
         YYCHECK.  */
 
1424
      int yyxbegin = yyn < 0 ? -yyn : 0;
 
1425
 
 
1426
      /* Stay within bounds of both yycheck and yytname.  */
 
1427
      int yychecklim = YYLAST - yyn + 1;
 
1428
      int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
 
1429
      int yycount = 1;
 
1430
 
 
1431
      yyarg[0] = yytname[yytype];
 
1432
      yyfmt = yystpcpy (yyformat, yyunexpected);
 
1433
 
 
1434
      for (yyx = yyxbegin; yyx < yyxend; ++yyx)
 
1435
        if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
 
1436
          {
 
1437
            if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
 
1438
              {
 
1439
                yycount = 1;
 
1440
                yysize = yysize0;
 
1441
                yyformat[sizeof yyunexpected - 1] = '\0';
 
1442
                break;
 
1443
              }
 
1444
            yyarg[yycount++] = yytname[yyx];
 
1445
            yysize1 = yysize + yytnamerr (0, yytname[yyx]);
 
1446
            yysize_overflow |= (yysize1 < yysize);
 
1447
            yysize = yysize1;
 
1448
            yyfmt = yystpcpy (yyfmt, yyprefix);
 
1449
            yyprefix = yyor;
 
1450
          }
 
1451
 
 
1452
      yyf = YY_(yyformat);
 
1453
      yysize1 = yysize + yystrlen (yyf);
 
1454
      yysize_overflow |= (yysize1 < yysize);
 
1455
      yysize = yysize1;
 
1456
 
 
1457
      if (yysize_overflow)
 
1458
        return YYSIZE_MAXIMUM;
 
1459
 
 
1460
      if (yyresult)
 
1461
        {
 
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;
 
1466
          int yyi = 0;
 
1467
          while ((*yyp = *yyf) != '\0')
 
1468
            {
 
1469
              if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
 
1470
                {
 
1471
                  yyp += yytnamerr (yyp, yyarg[yyi++]);
 
1472
                  yyf += 2;
 
1473
                }
 
1474
              else
 
1475
                {
 
1476
                  yyp++;
 
1477
                  yyf++;
 
1478
                }
 
1479
            }
 
1480
        }
 
1481
      return yysize;
 
1482
    }
 
1483
}
 
1484
#endif /* YYERROR_VERBOSE */
1163
1485
 
1164
1486
 
1165
 
#if YYDEBUG
1166
 
/*--------------------------------.
1167
 
| Print this symbol on YYOUTPUT.  |
1168
 
`--------------------------------*/
1169
 
 
1170
 
#if defined (__STDC__) || defined (__cplusplus)
1171
 
static void
1172
 
yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep)
1173
 
#else
1174
 
static void
1175
 
yysymprint (yyoutput, yytype, yyvaluep)
1176
 
    FILE *yyoutput;
1177
 
    int yytype;
1178
 
    YYSTYPE *yyvaluep;
1179
 
#endif
1180
 
{
1181
 
  /* Pacify ``unused variable'' warnings.  */
1182
 
  (void) yyvaluep;
1183
 
 
1184
 
  if (yytype < YYNTOKENS)
1185
 
    {
1186
 
      YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1187
 
# ifdef YYPRINT
1188
 
      YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1189
 
# endif
1190
 
    }
1191
 
  else
1192
 
    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1193
 
 
1194
 
  switch (yytype)
1195
 
    {
1196
 
      default:
1197
 
        break;
1198
 
    }
1199
 
  YYFPRINTF (yyoutput, ")");
1200
 
}
1201
 
 
1202
 
#endif /* ! YYDEBUG */
1203
1487
/*-----------------------------------------------.
1204
1488
| Release the memory associated to this symbol.  |
1205
1489
`-----------------------------------------------*/
1206
1490
 
1207
 
#if defined (__STDC__) || defined (__cplusplus)
 
1491
/*ARGSUSED*/
 
1492
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1493
     || defined __cplusplus || defined _MSC_VER)
1208
1494
static void
1209
 
yydestruct (int yytype, YYSTYPE *yyvaluep)
 
1495
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep)
1210
1496
#else
1211
1497
static void
1212
 
yydestruct (yytype, yyvaluep)
 
1498
yydestruct (yymsg, yytype, yyvaluep)
 
1499
    const char *yymsg;
1213
1500
    int yytype;
1214
1501
    YYSTYPE *yyvaluep;
1215
1502
#endif
1216
1503
{
1217
 
  /* Pacify ``unused variable'' warnings.  */
1218
 
  (void) yyvaluep;
 
1504
  YYUSE (yyvaluep);
 
1505
 
 
1506
  if (!yymsg)
 
1507
    yymsg = "Deleting";
 
1508
  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1219
1509
 
1220
1510
  switch (yytype)
1221
1511
    {
1222
1512
 
1223
1513
      default:
1224
 
        break;
 
1514
        break;
1225
1515
    }
1226
1516
}
1227
 
 
1228
1517
 
1229
1518
/* Prevent warnings from -Wmissing-prototypes.  */
1230
 
 
1231
1519
#ifdef YYPARSE_PARAM
1232
 
# if defined (__STDC__) || defined (__cplusplus)
 
1520
#if defined __STDC__ || defined __cplusplus
1233
1521
int yyparse (void *YYPARSE_PARAM);
1234
 
# else
 
1522
#else
1235
1523
int yyparse ();
1236
 
# endif
 
1524
#endif
1237
1525
#else /* ! YYPARSE_PARAM */
1238
 
#if defined (__STDC__) || defined (__cplusplus)
 
1526
#if defined __STDC__ || defined __cplusplus
1239
1527
int yyparse (void);
1240
1528
#else
1241
1529
int yyparse ();
1243
1531
#endif /* ! YYPARSE_PARAM */
1244
1532
 
1245
1533
 
1246
 
 
1247
1534
/* The lookahead symbol.  */
1248
1535
int yychar;
1249
1536
 
1255
1542
 
1256
1543
 
1257
1544
 
1258
 
/*----------.
1259
 
| yyparse.  |
1260
 
`----------*/
 
1545
/*-------------------------.
 
1546
| yyparse or yypush_parse.  |
 
1547
`-------------------------*/
1261
1548
 
1262
1549
#ifdef YYPARSE_PARAM
1263
 
# if defined (__STDC__) || defined (__cplusplus)
1264
 
int yyparse (void *YYPARSE_PARAM)
1265
 
# else
1266
 
int yyparse (YYPARSE_PARAM)
1267
 
  void *YYPARSE_PARAM;
1268
 
# endif
 
1550
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1551
     || defined __cplusplus || defined _MSC_VER)
 
1552
int
 
1553
yyparse (void *YYPARSE_PARAM)
 
1554
#else
 
1555
int
 
1556
yyparse (YYPARSE_PARAM)
 
1557
    void *YYPARSE_PARAM;
 
1558
#endif
1269
1559
#else /* ! YYPARSE_PARAM */
1270
 
#if defined (__STDC__) || defined (__cplusplus)
 
1560
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1561
     || defined __cplusplus || defined _MSC_VER)
1271
1562
int
1272
1563
yyparse (void)
1273
1564
#else
1277
1568
#endif
1278
1569
#endif
1279
1570
{
1280
 
  
1281
 
  register int yystate;
1282
 
  register int yyn;
 
1571
 
 
1572
 
 
1573
    int yystate;
 
1574
    /* Number of tokens to shift before error messages enabled.  */
 
1575
    int yyerrstatus;
 
1576
 
 
1577
    /* The stacks and their tools:
 
1578
       `yyss': related to states.
 
1579
       `yyvs': related to semantic values.
 
1580
 
 
1581
       Refer to the stacks thru separate pointers, to allow yyoverflow
 
1582
       to reallocate them elsewhere.  */
 
1583
 
 
1584
    /* The state stack.  */
 
1585
    yytype_int16 yyssa[YYINITDEPTH];
 
1586
    yytype_int16 *yyss;
 
1587
    yytype_int16 *yyssp;
 
1588
 
 
1589
    /* The semantic value stack.  */
 
1590
    YYSTYPE yyvsa[YYINITDEPTH];
 
1591
    YYSTYPE *yyvs;
 
1592
    YYSTYPE *yyvsp;
 
1593
 
 
1594
    YYSIZE_T yystacksize;
 
1595
 
 
1596
  int yyn;
1283
1597
  int yyresult;
1284
 
  /* Number of tokens to shift before error messages enabled.  */
1285
 
  int yyerrstatus;
1286
1598
  /* Lookahead token as an internal (translated) token number.  */
1287
 
  int yytoken = 0;
1288
 
 
1289
 
  /* Three stacks and their tools:
1290
 
     `yyss': related to states,
1291
 
     `yyvs': related to semantic values,
1292
 
     `yyls': related to locations.
1293
 
 
1294
 
     Refer to the stacks thru separate pointers, to allow yyoverflow
1295
 
     to reallocate them elsewhere.  */
1296
 
 
1297
 
  /* The state stack.  */
1298
 
  short yyssa[YYINITDEPTH];
1299
 
  short *yyss = yyssa;
1300
 
  register short *yyssp;
1301
 
 
1302
 
  /* The semantic value stack.  */
1303
 
  YYSTYPE yyvsa[YYINITDEPTH];
1304
 
  YYSTYPE *yyvs = yyvsa;
1305
 
  register YYSTYPE *yyvsp;
1306
 
 
1307
 
 
1308
 
 
1309
 
#define YYPOPSTACK   (yyvsp--, yyssp--)
1310
 
 
1311
 
  YYSIZE_T yystacksize = YYINITDEPTH;
1312
 
 
 
1599
  int yytoken;
1313
1600
  /* The variables used to return semantic value and location from the
1314
1601
     action routines.  */
1315
1602
  YYSTYPE yyval;
1316
1603
 
1317
 
 
1318
 
  /* When reducing, the number of symbols on the RHS of the reduced
1319
 
     rule.  */
1320
 
  int yylen;
 
1604
#if YYERROR_VERBOSE
 
1605
  /* Buffer for error messages, and its allocated size.  */
 
1606
  char yymsgbuf[128];
 
1607
  char *yymsg = yymsgbuf;
 
1608
  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
 
1609
#endif
 
1610
 
 
1611
#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N))
 
1612
 
 
1613
  /* The number of symbols on the RHS of the reduced rule.
 
1614
     Keep to zero when no symbol should be popped.  */
 
1615
  int yylen = 0;
 
1616
 
 
1617
  yytoken = 0;
 
1618
  yyss = yyssa;
 
1619
  yyvs = yyvsa;
 
1620
  yystacksize = YYINITDEPTH;
1321
1621
 
1322
1622
  YYDPRINTF ((stderr, "Starting parse\n"));
1323
1623
 
1324
1624
  yystate = 0;
1325
1625
  yyerrstatus = 0;
1326
1626
  yynerrs = 0;
1327
 
  yychar = YYEMPTY;             /* Cause a token to be read.  */
 
1627
  yychar = YYEMPTY; /* Cause a token to be read.  */
1328
1628
 
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.  */
1333
 
 
1334
1633
  yyssp = yyss;
1335
1634
  yyvsp = yyvs;
1336
1635
 
1341
1640
`------------------------------------------------------------*/
1342
1641
 yynewstate:
1343
1642
  /* In all cases, when you get here, the value and location stacks
1344
 
     have just been pushed. so pushing a state here evens the stacks.
1345
 
     */
 
1643
     have just been pushed.  So pushing a state here evens the stacks.  */
1346
1644
  yyssp++;
1347
1645
 
1348
1646
 yysetstate:
1355
1653
 
1356
1654
#ifdef yyoverflow
1357
1655
      {
1358
 
        /* Give user a chance to reallocate the stack. Use copies of
 
1656
        /* Give user a chance to reallocate the stack.  Use copies of
1359
1657
           these so that the &'s don't force the real ones into
1360
1658
           memory.  */
1361
1659
        YYSTYPE *yyvs1 = yyvs;
1362
 
        short *yyss1 = yyss;
1363
 
 
 
1660
        yytype_int16 *yyss1 = yyss;
1364
1661
 
1365
1662
        /* Each stack pointer address is followed by the size of the
1366
1663
           data in use in that stack, in bytes.  This used to be a
1367
1664
           conditional around just the two extra args, but that might
1368
1665
           be undefined if yyoverflow is a macro.  */
1369
 
        yyoverflow ("parser stack overflow",
 
1666
        yyoverflow (YY_("memory exhausted"),
1370
1667
                    &yyss1, yysize * sizeof (*yyssp),
1371
1668
                    &yyvs1, yysize * sizeof (*yyvsp),
1372
 
 
1373
1669
                    &yystacksize);
1374
1670
 
1375
1671
        yyss = yyss1;
1377
1673
      }
1378
1674
#else /* no yyoverflow */
1379
1675
# ifndef YYSTACK_RELOCATE
1380
 
      goto yyoverflowlab;
 
1676
      goto yyexhaustedlab;
1381
1677
# else
1382
1678
      /* Extend the stack our own way.  */
1383
1679
      if (YYMAXDEPTH <= yystacksize)
1384
 
        goto yyoverflowlab;
 
1680
        goto yyexhaustedlab;
1385
1681
      yystacksize *= 2;
1386
1682
      if (YYMAXDEPTH < yystacksize)
1387
1683
        yystacksize = YYMAXDEPTH;
1388
1684
 
1389
1685
      {
1390
 
        short *yyss1 = yyss;
 
1686
        yytype_int16 *yyss1 = yyss;
1391
1687
        union yyalloc *yyptr =
1392
1688
          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1393
1689
        if (! yyptr)
1394
 
          goto yyoverflowlab;
1395
 
        YYSTACK_RELOCATE (yyss);
1396
 
        YYSTACK_RELOCATE (yyvs);
1397
 
 
 
1690
          goto yyexhaustedlab;
 
1691
        YYSTACK_RELOCATE (yyss_alloc, yyss);
 
1692
        YYSTACK_RELOCATE (yyvs_alloc, yyvs);
1398
1693
#  undef YYSTACK_RELOCATE
1399
1694
        if (yyss1 != yyssa)
1400
1695
          YYSTACK_FREE (yyss1);
1405
1700
      yyssp = yyss + yysize - 1;
1406
1701
      yyvsp = yyvs + yysize - 1;
1407
1702
 
1408
 
 
1409
1703
      YYDPRINTF ((stderr, "Stack size increased to %lu\n",
1410
1704
                  (unsigned long int) yystacksize));
1411
1705
 
1415
1709
 
1416
1710
  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1417
1711
 
 
1712
  if (yystate == YYFINAL)
 
1713
    YYACCEPT;
 
1714
 
1418
1715
  goto yybackup;
1419
1716
 
1420
1717
/*-----------.
1422
1719
`-----------*/
1423
1720
yybackup:
1424
1721
 
1425
 
/* Do appropriate processing given the current state.  */
1426
 
/* Read a lookahead token if we need one and don't already have one.  */
1427
 
/* yyresume: */
 
1722
  /* Do appropriate processing given the current state.  Read a
 
1723
     lookahead token if we need one and don't already have one.  */
1428
1724
 
1429
1725
  /* First try to decide what to do without reference to lookahead token.  */
1430
 
 
1431
1726
  yyn = yypact[yystate];
1432
1727
  if (yyn == YYPACT_NINF)
1433
1728
    goto yydefault;
1449
1744
  else
1450
1745
    {
1451
1746
      yytoken = YYTRANSLATE (yychar);
1452
 
      YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
 
1747
      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1453
1748
    }
1454
1749
 
1455
1750
  /* If the proper action on seeing token YYTOKEN is to reduce or to
1466
1761
      goto yyreduce;
1467
1762
    }
1468
1763
 
1469
 
  if (yyn == YYFINAL)
1470
 
    YYACCEPT;
1471
 
 
1472
 
  /* Shift the lookahead token.  */
1473
 
  YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
1474
 
 
1475
 
  /* Discard the token being shifted unless it is eof.  */
1476
 
  if (yychar != YYEOF)
1477
 
    yychar = YYEMPTY;
1478
 
 
1479
 
  *++yyvsp = yylval;
1480
 
 
1481
 
 
1482
1764
  /* Count tokens shifted since error; after three, turn off error
1483
1765
     status.  */
1484
1766
  if (yyerrstatus)
1485
1767
    yyerrstatus--;
1486
1768
 
 
1769
  /* Shift the lookahead token.  */
 
1770
  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
 
1771
 
 
1772
  /* Discard the shifted token.  */
 
1773
  yychar = YYEMPTY;
 
1774
 
1487
1775
  yystate = yyn;
 
1776
  *++yyvsp = yylval;
 
1777
 
1488
1778
  goto yynewstate;
1489
1779
 
1490
1780
 
1520
1810
  switch (yyn)
1521
1811
    {
1522
1812
        case 2:
 
1813
 
 
1814
/* Line 1455 of yacc.c  */
1523
1815
#line 248 "gram.y"
1524
1816
    {
1525
 
                                                yylval.program = (PLpgSQL_stmt_block *) yyvsp[-1].stmt;
 
1817
                                                yylval.program = (PLpgSQL_stmt_block *) (yyvsp[(2) - (3)].stmt);
1526
1818
                                        ;}
1527
1819
    break;
1528
1820
 
1529
1821
  case 7:
 
1822
 
 
1823
/* Line 1455 of yacc.c  */
1530
1824
#line 262 "gram.y"
1531
1825
    {
1532
1826
                                                plpgsql_DumpExecTree = true;
1534
1828
    break;
1535
1829
 
1536
1830
  case 10:
 
1831
 
 
1832
/* Line 1455 of yacc.c  */
1537
1833
#line 272 "gram.y"
1538
1834
    {
1539
1835
                                                PLpgSQL_stmt_block *new;
1541
1837
                                                new = palloc0(sizeof(PLpgSQL_stmt_block));
1542
1838
 
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);
1550
1846
 
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();
1553
1849
 
1554
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
1850
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
1555
1851
                                        ;}
1556
1852
    break;
1557
1853
 
1558
1854
  case 11:
 
1855
 
 
1856
/* Line 1455 of yacc.c  */
1559
1857
#line 294 "gram.y"
1560
1858
    {
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;
1565
1863
                                        ;}
1566
1864
    break;
1567
1865
 
1568
1866
  case 12:
 
1867
 
 
1868
/* Line 1455 of yacc.c  */
1569
1869
#line 301 "gram.y"
1570
1870
    {
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;
1575
1875
                                        ;}
1576
1876
    break;
1577
1877
 
1578
1878
  case 13:
 
1879
 
 
1880
/* Line 1455 of yacc.c  */
1579
1881
#line 308 "gram.y"
1580
1882
    {
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);
1584
1886
                                                else
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));
1588
1890
                                        ;}
1589
1891
    break;
1590
1892
 
1591
1893
  case 14:
 
1894
 
 
1895
/* Line 1455 of yacc.c  */
1592
1896
#line 320 "gram.y"
1593
1897
    {
1594
1898
                                                /* Forget any variables created before block */
1599
1903
    break;
1600
1904
 
1601
1905
  case 15:
 
1906
 
 
1907
/* Line 1455 of yacc.c  */
1602
1908
#line 329 "gram.y"
1603
 
    {   yyval.str = yyvsp[0].str;       ;}
 
1909
    {   (yyval.str) = (yyvsp[(2) - (2)].str);   ;}
1604
1910
    break;
1605
1911
 
1606
1912
  case 16:
 
1913
 
 
1914
/* Line 1455 of yacc.c  */
1607
1915
#line 331 "gram.y"
1608
 
    {   yyval.str = yyvsp[0].str;       ;}
 
1916
    {   (yyval.str) = (yyvsp[(1) - (1)].str);   ;}
1609
1917
    break;
1610
1918
 
1611
1919
  case 17:
 
1920
 
 
1921
/* Line 1455 of yacc.c  */
1612
1922
#line 335 "gram.y"
1613
 
    {   yyval.str = yyvsp[-2].str;      ;}
 
1923
    {   (yyval.str) = (yyvsp[(3) - (5)].str);   ;}
1614
1924
    break;
1615
1925
 
1616
1926
  case 18:
 
1927
 
 
1928
/* Line 1455 of yacc.c  */
1617
1929
#line 337 "gram.y"
1618
 
    {   yyval.str = NULL;       ;}
 
1930
    {   (yyval.str) = NULL;     ;}
1619
1931
    break;
1620
1932
 
1621
1933
  case 19:
 
1934
 
 
1935
/* Line 1455 of yacc.c  */
1622
1936
#line 339 "gram.y"
1623
 
    {   yyval.str = NULL;       ;}
 
1937
    {   (yyval.str) = NULL;     ;}
1624
1938
    break;
1625
1939
 
1626
1940
  case 20:
 
1941
 
 
1942
/* Line 1455 of yacc.c  */
1627
1943
#line 343 "gram.y"
1628
1944
    {
1629
1945
                                                PLpgSQL_variable        *var;
1630
1946
 
1631
 
                                                var = plpgsql_build_variable(yyvsp[-4].varname.name, yyvsp[-4].varname.lineno,
1632
 
                                                                                                         yyvsp[-2].dtype, true);
1633
 
                                                if (yyvsp[-3].boolean)
 
1947
                                                var = plpgsql_build_variable((yyvsp[(1) - (5)].varname).name, (yyvsp[(1) - (5)].varname).lineno,
 
1948
                                                                                                         (yyvsp[(3) - (5)].dtype), true);
 
1949
                                                if ((yyvsp[(2) - (5)].boolean))
1634
1950
                                                {
1635
1951
                                                        if (var->dtype == PLPGSQL_DTYPE_VAR)
1636
 
                                                                ((PLpgSQL_var *) var)->isconst = yyvsp[-3].boolean;
 
1952
                                                                ((PLpgSQL_var *) var)->isconst = (yyvsp[(2) - (5)].boolean);
1637
1953
                                                        else
1638
1954
                                                                ereport(ERROR,
1639
1955
                                                                                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1640
1956
                                                                                 errmsg("row or record variable cannot be CONSTANT")));
1641
1957
                                                }
1642
 
                                                if (yyvsp[-1].boolean)
 
1958
                                                if ((yyvsp[(4) - (5)].boolean))
1643
1959
                                                {
1644
1960
                                                        if (var->dtype == PLPGSQL_DTYPE_VAR)
1645
 
                                                                ((PLpgSQL_var *) var)->notnull = yyvsp[-1].boolean;
 
1961
                                                                ((PLpgSQL_var *) var)->notnull = (yyvsp[(4) - (5)].boolean);
1646
1962
                                                        else
1647
1963
                                                                ereport(ERROR,
1648
1964
                                                                                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1649
1965
                                                                                 errmsg("row or record variable cannot be NOT NULL")));
1650
1966
                                                }
1651
 
                                                if (yyvsp[0].expr != NULL)
 
1967
                                                if ((yyvsp[(5) - (5)].expr) != NULL)
1652
1968
                                                {
1653
1969
                                                        if (var->dtype == PLPGSQL_DTYPE_VAR)
1654
 
                                                                ((PLpgSQL_var *) var)->default_val = yyvsp[0].expr;
 
1970
                                                                ((PLpgSQL_var *) var)->default_val = (yyvsp[(5) - (5)].expr);
1655
1971
                                                        else
1656
1972
                                                                ereport(ERROR,
1657
1973
                                                                                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1661
1977
    break;
1662
1978
 
1663
1979
  case 21:
 
1980
 
 
1981
/* Line 1455 of yacc.c  */
1664
1982
#line 377 "gram.y"
1665
1983
    {
1666
 
                                                plpgsql_ns_additem(yyvsp[-1].nsitem->itemtype,
1667
 
                                                                                   yyvsp[-1].nsitem->itemno, yyvsp[-4].varname.name);
 
1984
                                                plpgsql_ns_additem((yyvsp[(4) - (5)].nsitem)->itemtype,
 
1985
                                                                                   (yyvsp[(4) - (5)].nsitem)->itemno, (yyvsp[(1) - (5)].varname).name);
1668
1986
                                        ;}
1669
1987
    break;
1670
1988
 
1671
1989
  case 22:
 
1990
 
 
1991
/* Line 1455 of yacc.c  */
1672
1992
#line 382 "gram.y"
1673
1993
    {
1674
 
                                                plpgsql_ns_rename(yyvsp[-3].str, yyvsp[-1].str);
 
1994
                                                plpgsql_ns_rename((yyvsp[(2) - (5)].str), (yyvsp[(4) - (5)].str));
1675
1995
                                        ;}
1676
1996
    break;
1677
1997
 
1678
1998
  case 23:
 
1999
 
 
2000
/* Line 1455 of yacc.c  */
1679
2001
#line 386 "gram.y"
1680
 
    { plpgsql_ns_push(yyvsp[-2].varname.name); ;}
 
2002
    { plpgsql_ns_push((yyvsp[(1) - (3)].varname).name); ;}
1681
2003
    break;
1682
2004
 
1683
2005
  case 24:
 
2006
 
 
2007
/* Line 1455 of yacc.c  */
1684
2008
#line 388 "gram.y"
1685
2009
    {
1686
2010
                                                PLpgSQL_var *new;
1693
2017
                                                plpgsql_ns_pop();
1694
2018
 
1695
2019
                                                new = (PLpgSQL_var *)
1696
 
                                                        plpgsql_build_variable(yyvsp[-6].varname.name, yyvsp[-6].varname.lineno,
 
2020
                                                        plpgsql_build_variable((yyvsp[(1) - (7)].varname).name, (yyvsp[(1) - (7)].varname).lineno,
1697
2021
                                                                                                   plpgsql_build_datatype(REFCURSOROID,
1698
2022
                                                                                                                                                  -1),
1699
2023
                                                                                                   true);
1721
2045
                                                curname_def->query = pstrdup(buf);
1722
2046
                                                new->default_val = curname_def;
1723
2047
 
1724
 
                                                new->cursor_explicit_expr = yyvsp[0].expr;
1725
 
                                                if (yyvsp[-2].row == NULL)
 
2048
                                                new->cursor_explicit_expr = (yyvsp[(7) - (7)].expr);
 
2049
                                                if ((yyvsp[(5) - (7)].row) == NULL)
1726
2050
                                                        new->cursor_explicit_argrow = -1;
1727
2051
                                                else
1728
 
                                                        new->cursor_explicit_argrow = yyvsp[-2].row->dno;
1729
 
                                                new->cursor_options = CURSOR_OPT_FAST_PLAN | yyvsp[-5].ival;
 
2052
                                                        new->cursor_explicit_argrow = (yyvsp[(5) - (7)].row)->dno;
 
2053
                                                new->cursor_options = CURSOR_OPT_FAST_PLAN | (yyvsp[(2) - (7)].ival);
1730
2054
                                        ;}
1731
2055
    break;
1732
2056
 
1733
2057
  case 25:
 
2058
 
 
2059
/* Line 1455 of yacc.c  */
1734
2060
#line 437 "gram.y"
1735
2061
    {
1736
 
                                                yyval.ival = 0;
 
2062
                                                (yyval.ival) = 0;
1737
2063
                                        ;}
1738
2064
    break;
1739
2065
 
1740
2066
  case 26:
 
2067
 
 
2068
/* Line 1455 of yacc.c  */
1741
2069
#line 441 "gram.y"
1742
2070
    {
1743
 
                                                yyval.ival = CURSOR_OPT_NO_SCROLL;
 
2071
                                                (yyval.ival) = CURSOR_OPT_NO_SCROLL;
1744
2072
                                        ;}
1745
2073
    break;
1746
2074
 
1747
2075
  case 27:
 
2076
 
 
2077
/* Line 1455 of yacc.c  */
1748
2078
#line 445 "gram.y"
1749
2079
    {
1750
 
                                                yyval.ival = CURSOR_OPT_SCROLL;
 
2080
                                                (yyval.ival) = CURSOR_OPT_SCROLL;
1751
2081
                                        ;}
1752
2082
    break;
1753
2083
 
1754
2084
  case 28:
 
2085
 
 
2086
/* Line 1455 of yacc.c  */
1755
2087
#line 451 "gram.y"
1756
2088
    {
1757
2089
                                                PLpgSQL_expr *query;
1760
2092
                                                query = read_sql_stmt("");
1761
2093
                                                plpgsql_ns_setlocal(true);
1762
2094
 
1763
 
                                                yyval.expr = query;
 
2095
                                                (yyval.expr) = query;
1764
2096
                                        ;}
1765
2097
    break;
1766
2098
 
1767
2099
  case 29:
 
2100
 
 
2101
/* Line 1455 of yacc.c  */
1768
2102
#line 463 "gram.y"
1769
2103
    {
1770
 
                                                yyval.row = NULL;
 
2104
                                                (yyval.row) = NULL;
1771
2105
                                        ;}
1772
2106
    break;
1773
2107
 
1774
2108
  case 30:
 
2109
 
 
2110
/* Line 1455 of yacc.c  */
1775
2111
#line 467 "gram.y"
1776
2112
    {
1777
2113
                                                PLpgSQL_row *new;
1782
2118
                                                new->dtype = PLPGSQL_DTYPE_ROW;
1783
2119
                                                new->lineno = plpgsql_scanner_lineno();
1784
2120
                                                new->rowtupdesc = NULL;
1785
 
                                                new->nfields = list_length(yyvsp[-1].list);
 
2121
                                                new->nfields = list_length((yyvsp[(2) - (3)].list));
1786
2122
                                                new->fieldnames = palloc(new->nfields * sizeof(char *));
1787
2123
                                                new->varnos = palloc(new->nfields * sizeof(int));
1788
2124
 
1789
2125
                                                i = 0;
1790
 
                                                foreach (l, yyvsp[-1].list)
 
2126
                                                foreach (l, (yyvsp[(2) - (3)].list))
1791
2127
                                                {
1792
2128
                                                        PLpgSQL_variable *arg = (PLpgSQL_variable *) lfirst(l);
1793
2129
                                                        new->fieldnames[i] = arg->refname;
1794
2130
                                                        new->varnos[i] = arg->dno;
1795
2131
                                                        i++;
1796
2132
                                                }
1797
 
                                                list_free(yyvsp[-1].list);
 
2133
                                                list_free((yyvsp[(2) - (3)].list));
1798
2134
 
1799
2135
                                                plpgsql_adddatum((PLpgSQL_datum *) new);
1800
 
                                                yyval.row = new;
 
2136
                                                (yyval.row) = new;
1801
2137
                                        ;}
1802
2138
    break;
1803
2139
 
1804
2140
  case 31:
 
2141
 
 
2142
/* Line 1455 of yacc.c  */
1805
2143
#line 496 "gram.y"
1806
2144
    {
1807
 
                                                yyval.list = list_make1(yyvsp[0].variable);
 
2145
                                                (yyval.list) = list_make1((yyvsp[(1) - (1)].variable));
1808
2146
                                        ;}
1809
2147
    break;
1810
2148
 
1811
2149
  case 32:
 
2150
 
 
2151
/* Line 1455 of yacc.c  */
1812
2152
#line 500 "gram.y"
1813
2153
    {
1814
 
                                                yyval.list = lappend(yyvsp[-2].list, yyvsp[0].variable);
 
2154
                                                (yyval.list) = lappend((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].variable));
1815
2155
                                        ;}
1816
2156
    break;
1817
2157
 
1818
2158
  case 33:
 
2159
 
 
2160
/* Line 1455 of yacc.c  */
1819
2161
#line 506 "gram.y"
1820
2162
    {
1821
 
                                                yyval.variable = plpgsql_build_variable(yyvsp[-1].varname.name, yyvsp[-1].varname.lineno,
1822
 
                                                                                                        yyvsp[0].dtype, true);
 
2163
                                                (yyval.variable) = plpgsql_build_variable((yyvsp[(1) - (2)].varname).name, (yyvsp[(1) - (2)].varname).lineno,
 
2164
                                                                                                        (yyvsp[(2) - (2)].dtype), true);
1823
2165
                                        ;}
1824
2166
    break;
1825
2167
 
1826
2168
  case 36:
 
2169
 
 
2170
/* Line 1455 of yacc.c  */
1827
2171
#line 516 "gram.y"
1828
2172
    {
1829
2173
                                                char    *name;
1830
2174
                                                PLpgSQL_nsitem *nsi;
1831
2175
 
1832
 
                                                plpgsql_convert_ident(yyvsp[0].str, &name, 1);
 
2176
                                                plpgsql_convert_ident((yyvsp[(1) - (1)].str), &name, 1);
1833
2177
                                                if (name[0] != '$')
1834
2178
                                                        yyerror("only positional parameters can be aliased");
1835
2179
 
1849
2193
 
1850
2194
                                                pfree(name);
1851
2195
 
1852
 
                                                yyval.nsitem = nsi;
 
2196
                                                (yyval.nsitem) = nsi;
1853
2197
                                        ;}
1854
2198
    break;
1855
2199
 
1856
2200
  case 37:
 
2201
 
 
2202
/* Line 1455 of yacc.c  */
1857
2203
#line 545 "gram.y"
1858
2204
    {
1859
2205
                                                char    *name;
1860
2206
 
1861
2207
                                                plpgsql_convert_ident(yytext, &name, 1);
1862
 
                                                yyval.varname.name = name;
1863
 
                                                yyval.varname.lineno  = plpgsql_scanner_lineno();
 
2208
                                                (yyval.varname).name = name;
 
2209
                                                (yyval.varname).lineno  = plpgsql_scanner_lineno();
1864
2210
                                        ;}
1865
2211
    break;
1866
2212
 
1867
2213
  case 38:
 
2214
 
 
2215
/* Line 1455 of yacc.c  */
1868
2216
#line 553 "gram.y"
1869
2217
    {
1870
2218
                                                /*
1878
2226
    break;
1879
2227
 
1880
2228
  case 39:
 
2229
 
 
2230
/* Line 1455 of yacc.c  */
1881
2231
#line 563 "gram.y"
1882
2232
    {
1883
2233
                                                yyerror("duplicate declaration");
1885
2235
    break;
1886
2236
 
1887
2237
  case 40:
 
2238
 
 
2239
/* Line 1455 of yacc.c  */
1888
2240
#line 567 "gram.y"
1889
2241
    {
1890
2242
                                                yyerror("duplicate declaration");
1892
2244
    break;
1893
2245
 
1894
2246
  case 41:
 
2247
 
 
2248
/* Line 1455 of yacc.c  */
1895
2249
#line 574 "gram.y"
1896
2250
    {
1897
2251
                                                char    *name;
1898
2252
 
1899
2253
                                                plpgsql_convert_ident(yytext, &name, 1);
1900
2254
                                                /* the result must be palloc'd, see plpgsql_ns_rename */
1901
 
                                                yyval.str = name;
 
2255
                                                (yyval.str) = name;
1902
2256
                                        ;}
1903
2257
    break;
1904
2258
 
1905
2259
  case 42:
 
2260
 
 
2261
/* Line 1455 of yacc.c  */
1906
2262
#line 584 "gram.y"
1907
 
    { yyval.boolean = false; ;}
 
2263
    { (yyval.boolean) = false; ;}
1908
2264
    break;
1909
2265
 
1910
2266
  case 43:
 
2267
 
 
2268
/* Line 1455 of yacc.c  */
1911
2269
#line 586 "gram.y"
1912
 
    { yyval.boolean = true; ;}
 
2270
    { (yyval.boolean) = true; ;}
1913
2271
    break;
1914
2272
 
1915
2273
  case 44:
 
2274
 
 
2275
/* Line 1455 of yacc.c  */
1916
2276
#line 590 "gram.y"
1917
2277
    {
1918
2278
                                                /*
1919
2279
                                                 * If there's a lookahead token, read_datatype
1920
2280
                                                 * should consume it.
1921
2281
                                                 */
1922
 
                                                yyval.dtype = read_datatype(yychar);
 
2282
                                                (yyval.dtype) = read_datatype(yychar);
1923
2283
                                                yyclearin;
1924
2284
                                        ;}
1925
2285
    break;
1926
2286
 
1927
2287
  case 45:
 
2288
 
 
2289
/* Line 1455 of yacc.c  */
1928
2290
#line 601 "gram.y"
1929
 
    { yyval.boolean = false; ;}
 
2291
    { (yyval.boolean) = false; ;}
1930
2292
    break;
1931
2293
 
1932
2294
  case 46:
 
2295
 
 
2296
/* Line 1455 of yacc.c  */
1933
2297
#line 603 "gram.y"
1934
 
    { yyval.boolean = true; ;}
 
2298
    { (yyval.boolean) = true; ;}
1935
2299
    break;
1936
2300
 
1937
2301
  case 47:
 
2302
 
 
2303
/* Line 1455 of yacc.c  */
1938
2304
#line 607 "gram.y"
1939
 
    { yyval.expr = NULL; ;}
 
2305
    { (yyval.expr) = NULL; ;}
1940
2306
    break;
1941
2307
 
1942
2308
  case 48:
 
2309
 
 
2310
/* Line 1455 of yacc.c  */
1943
2311
#line 609 "gram.y"
1944
2312
    {
1945
2313
                                                plpgsql_ns_setlocal(false);
1946
 
                                                yyval.expr = plpgsql_read_expression(';', ";");
 
2314
                                                (yyval.expr) = plpgsql_read_expression(';', ";");
1947
2315
                                                plpgsql_ns_setlocal(true);
1948
2316
                                        ;}
1949
2317
    break;
1950
2318
 
1951
2319
  case 51:
 
2320
 
 
2321
/* Line 1455 of yacc.c  */
1952
2322
#line 621 "gram.y"
1953
 
    { yyval.list = NIL; ;}
 
2323
    { (yyval.list) = NIL; ;}
1954
2324
    break;
1955
2325
 
1956
2326
  case 52:
 
2327
 
 
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); ;}
1959
2331
    break;
1960
2332
 
1961
2333
  case 53:
 
2334
 
 
2335
/* Line 1455 of yacc.c  */
1962
2336
#line 627 "gram.y"
1963
2337
    {
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);
1966
2340
                                                        else
1967
 
                                                                yyval.list = lappend(yyvsp[-1].list, yyvsp[0].stmt);
 
2341
                                                                (yyval.list) = lappend((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].stmt));
1968
2342
                                                ;}
1969
2343
    break;
1970
2344
 
1971
2345
  case 54:
 
2346
 
 
2347
/* Line 1455 of yacc.c  */
1972
2348
#line 634 "gram.y"
1973
2349
    {
1974
 
                                                        if (yyvsp[0].stmt == NULL)
1975
 
                                                                yyval.list = NIL;
 
2350
                                                        if ((yyvsp[(1) - (1)].stmt) == NULL)
 
2351
                                                                (yyval.list) = NIL;
1976
2352
                                                        else
1977
 
                                                                yyval.list = list_make1(yyvsp[0].stmt);
 
2353
                                                                (yyval.list) = list_make1((yyvsp[(1) - (1)].stmt));
1978
2354
                                                ;}
1979
2355
    break;
1980
2356
 
1981
2357
  case 55:
 
2358
 
 
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); ;}
1984
2362
    break;
1985
2363
 
1986
2364
  case 56:
 
2365
 
 
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); ;}
1989
2369
    break;
1990
2370
 
1991
2371
  case 57:
 
2372
 
 
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); ;}
1994
2376
    break;
1995
2377
 
1996
2378
  case 58:
 
2379
 
 
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); ;}
1999
2383
    break;
2000
2384
 
2001
2385
  case 59:
 
2386
 
 
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); ;}
2004
2390
    break;
2005
2391
 
2006
2392
  case 60:
 
2393
 
 
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); ;}
2009
2397
    break;
2010
2398
 
2011
2399
  case 61:
 
2400
 
 
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); ;}
2014
2404
    break;
2015
2405
 
2016
2406
  case 62:
 
2407
 
 
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); ;}
2019
2411
    break;
2020
2412
 
2021
2413
  case 63:
 
2414
 
 
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); ;}
2024
2418
    break;
2025
2419
 
2026
2420
  case 64:
 
2421
 
 
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); ;}
2029
2425
    break;
2030
2426
 
2031
2427
  case 65:
 
2428
 
 
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); ;}
2034
2432
    break;
2035
2433
 
2036
2434
  case 66:
 
2435
 
 
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); ;}
2039
2439
    break;
2040
2440
 
2041
2441
  case 67:
 
2442
 
 
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); ;}
2044
2446
    break;
2045
2447
 
2046
2448
  case 68:
 
2449
 
 
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); ;}
2049
2453
    break;
2050
2454
 
2051
2455
  case 69:
 
2456
 
 
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); ;}
2054
2460
    break;
2055
2461
 
2056
2462
  case 70:
 
2463
 
 
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); ;}
2059
2467
    break;
2060
2468
 
2061
2469
  case 71:
 
2470
 
 
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); ;}
2064
2474
    break;
2065
2475
 
2066
2476
  case 72:
 
2477
 
 
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); ;}
2069
2481
    break;
2070
2482
 
2071
2483
  case 73:
 
2484
 
 
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); ;}
2074
2488
    break;
2075
2489
 
2076
2490
  case 74:
 
2491
 
 
2492
/* Line 1455 of yacc.c  */
2077
2493
#line 683 "gram.y"
2078
2494
    {
2079
2495
                                                PLpgSQL_stmt_perform *new;
2080
2496
 
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);
2085
2501
 
2086
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
2502
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
2087
2503
                                        ;}
2088
2504
    break;
2089
2505
 
2090
2506
  case 75:
 
2507
 
 
2508
/* Line 1455 of yacc.c  */
2091
2509
#line 696 "gram.y"
2092
2510
    {
2093
2511
                                                PLpgSQL_stmt_assign *new;
2094
2512
 
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);
2100
2518
 
2101
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
2519
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
2102
2520
                                        ;}
2103
2521
    break;
2104
2522
 
2105
2523
  case 76:
 
2524
 
 
2525
/* Line 1455 of yacc.c  */
2106
2526
#line 710 "gram.y"
2107
2527
    {
2108
2528
                                                PLpgSQL_stmt_getdiag     *new;
2109
2529
 
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);
2114
2534
 
2115
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
2535
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
2116
2536
                                        ;}
2117
2537
    break;
2118
2538
 
2119
2539
  case 77:
 
2540
 
 
2541
/* Line 1455 of yacc.c  */
2120
2542
#line 723 "gram.y"
2121
2543
    {
2122
 
                                                yyval.list = lappend(yyvsp[-2].list, yyvsp[0].diagitem);
 
2544
                                                (yyval.list) = lappend((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].diagitem));
2123
2545
                                        ;}
2124
2546
    break;
2125
2547
 
2126
2548
  case 78:
 
2549
 
 
2550
/* Line 1455 of yacc.c  */
2127
2551
#line 727 "gram.y"
2128
2552
    {
2129
 
                                                yyval.list = list_make1(yyvsp[0].diagitem);
 
2553
                                                (yyval.list) = list_make1((yyvsp[(1) - (1)].diagitem));
2130
2554
                                        ;}
2131
2555
    break;
2132
2556
 
2133
2557
  case 79:
 
2558
 
 
2559
/* Line 1455 of yacc.c  */
2134
2560
#line 733 "gram.y"
2135
2561
    {
2136
2562
                                                PLpgSQL_diag_item *new;
2137
2563
 
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);
2141
2567
 
2142
 
                                                yyval.diagitem = new;
 
2568
                                                (yyval.diagitem) = new;
2143
2569
                                        ;}
2144
2570
    break;
2145
2571
 
2146
2572
  case 80:
 
2573
 
 
2574
/* Line 1455 of yacc.c  */
2147
2575
#line 745 "gram.y"
2148
2576
    {
2149
 
                                                yyval.ival = PLPGSQL_GETDIAG_ROW_COUNT;
 
2577
                                                (yyval.ival) = PLPGSQL_GETDIAG_ROW_COUNT;
2150
2578
                                        ;}
2151
2579
    break;
2152
2580
 
2153
2581
  case 81:
 
2582
 
 
2583
/* Line 1455 of yacc.c  */
2154
2584
#line 749 "gram.y"
2155
2585
    {
2156
 
                                                yyval.ival = PLPGSQL_GETDIAG_RESULT_OID;
 
2586
                                                (yyval.ival) = PLPGSQL_GETDIAG_RESULT_OID;
2157
2587
                                        ;}
2158
2588
    break;
2159
2589
 
2160
2590
  case 82:
 
2591
 
 
2592
/* Line 1455 of yacc.c  */
2161
2593
#line 755 "gram.y"
2162
2594
    {
2163
2595
                                                check_assignable(yylval.scalar);
2164
 
                                                yyval.ival = yylval.scalar->dno;
 
2596
                                                (yyval.ival) = yylval.scalar->dno;
2165
2597
                                        ;}
2166
2598
    break;
2167
2599
 
2168
2600
  case 83:
 
2601
 
 
2602
/* Line 1455 of yacc.c  */
2169
2603
#line 760 "gram.y"
2170
2604
    {
2171
2605
                                                yyerror("expected an integer variable");
2173
2607
    break;
2174
2608
 
2175
2609
  case 84:
 
2610
 
 
2611
/* Line 1455 of yacc.c  */
2176
2612
#line 764 "gram.y"
2177
2613
    {
2178
2614
                                                yyerror("expected an integer variable");
2180
2616
    break;
2181
2617
 
2182
2618
  case 85:
 
2619
 
 
2620
/* Line 1455 of yacc.c  */
2183
2621
#line 768 "gram.y"
2184
2622
    {
2185
2623
                                                yyerror("expected an integer variable");
2187
2625
    break;
2188
2626
 
2189
2627
  case 86:
 
2628
 
 
2629
/* Line 1455 of yacc.c  */
2190
2630
#line 775 "gram.y"
2191
2631
    {
2192
2632
                                                check_assignable(yylval.scalar);
2193
 
                                                yyval.ival = yylval.scalar->dno;
 
2633
                                                (yyval.ival) = yylval.scalar->dno;
2194
2634
                                        ;}
2195
2635
    break;
2196
2636
 
2197
2637
  case 87:
 
2638
 
 
2639
/* Line 1455 of yacc.c  */
2198
2640
#line 780 "gram.y"
2199
2641
    {
2200
2642
                                                check_assignable((PLpgSQL_datum *) yylval.row);
2201
 
                                                yyval.ival = yylval.row->dno;
 
2643
                                                (yyval.ival) = yylval.row->dno;
2202
2644
                                        ;}
2203
2645
    break;
2204
2646
 
2205
2647
  case 88:
 
2648
 
 
2649
/* Line 1455 of yacc.c  */
2206
2650
#line 785 "gram.y"
2207
2651
    {
2208
2652
                                                check_assignable((PLpgSQL_datum *) yylval.rec);
2209
 
                                                yyval.ival = yylval.rec->dno;
 
2653
                                                (yyval.ival) = yylval.rec->dno;
2210
2654
                                        ;}
2211
2655
    break;
2212
2656
 
2213
2657
  case 89:
 
2658
 
 
2659
/* Line 1455 of yacc.c  */
2214
2660
#line 790 "gram.y"
2215
2661
    {
2216
2662
                                                PLpgSQL_arrayelem       *new;
2217
2663
 
2218
2664
                                                new = palloc0(sizeof(PLpgSQL_arrayelem));
2219
2665
                                                new->dtype              = PLPGSQL_DTYPE_ARRAYELEM;
2220
 
                                                new->subscript  = yyvsp[0].expr;
2221
 
                                                new->arrayparentno = yyvsp[-2].ival;
 
2666
                                                new->subscript  = (yyvsp[(3) - (3)].expr);
 
2667
                                                new->arrayparentno = (yyvsp[(1) - (3)].ival);
2222
2668
 
2223
2669
                                                plpgsql_adddatum((PLpgSQL_datum *)new);
2224
2670
 
2225
 
                                                yyval.ival = new->dno;
 
2671
                                                (yyval.ival) = new->dno;
2226
2672
                                        ;}
2227
2673
    break;
2228
2674
 
2229
2675
  case 90:
 
2676
 
 
2677
/* Line 1455 of yacc.c  */
2230
2678
#line 805 "gram.y"
2231
2679
    {
2232
2680
                                                PLpgSQL_stmt_if *new;
2233
2681
 
2234
2682
                                                new = palloc0(sizeof(PLpgSQL_stmt_if));
2235
2683
                                                new->cmd_type   = PLPGSQL_STMT_IF;
2236
 
                                                new->lineno             = yyvsp[-6].ival;
2237
 
                                                new->cond               = yyvsp[-5].expr;
2238
 
                                                new->true_body  = yyvsp[-4].list;
2239
 
                                                new->false_body = yyvsp[-3].list;
 
2684
                                                new->lineno             = (yyvsp[(2) - (8)].ival);
 
2685
                                                new->cond               = (yyvsp[(3) - (8)].expr);
 
2686
                                                new->true_body  = (yyvsp[(4) - (8)].list);
 
2687
                                                new->false_body = (yyvsp[(5) - (8)].list);
2240
2688
 
2241
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
2689
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
2242
2690
                                        ;}
2243
2691
    break;
2244
2692
 
2245
2693
  case 91:
 
2694
 
 
2695
/* Line 1455 of yacc.c  */
2246
2696
#line 820 "gram.y"
2247
2697
    {
2248
 
                                                yyval.list = NIL;
 
2698
                                                (yyval.list) = NIL;
2249
2699
                                        ;}
2250
2700
    break;
2251
2701
 
2252
2702
  case 92:
 
2703
 
 
2704
/* Line 1455 of yacc.c  */
2253
2705
#line 824 "gram.y"
2254
2706
    {
2255
2707
                                                /*
2270
2722
                                                /* first create a new if-statement */
2271
2723
                                                new_if = palloc0(sizeof(PLpgSQL_stmt_if));
2272
2724
                                                new_if->cmd_type        = PLPGSQL_STMT_IF;
2273
 
                                                new_if->lineno          = yyvsp[-3].ival;
2274
 
                                                new_if->cond            = yyvsp[-2].expr;
2275
 
                                                new_if->true_body       = yyvsp[-1].list;
2276
 
                                                new_if->false_body      = yyvsp[0].list;
 
2725
                                                new_if->lineno          = (yyvsp[(2) - (5)].ival);
 
2726
                                                new_if->cond            = (yyvsp[(3) - (5)].expr);
 
2727
                                                new_if->true_body       = (yyvsp[(4) - (5)].list);
 
2728
                                                new_if->false_body      = (yyvsp[(5) - (5)].list);
2277
2729
 
2278
2730
                                                /* wrap the if-statement in a "container" list */
2279
 
                                                yyval.list = list_make1(new_if);
 
2731
                                                (yyval.list) = list_make1(new_if);
2280
2732
                                        ;}
2281
2733
    break;
2282
2734
 
2283
2735
  case 93:
 
2736
 
 
2737
/* Line 1455 of yacc.c  */
2284
2738
#line 853 "gram.y"
2285
2739
    {
2286
 
                                                yyval.list = yyvsp[0].list;
 
2740
                                                (yyval.list) = (yyvsp[(2) - (2)].list);
2287
2741
                                        ;}
2288
2742
    break;
2289
2743
 
2290
2744
  case 94:
 
2745
 
 
2746
/* Line 1455 of yacc.c  */
2291
2747
#line 859 "gram.y"
2292
2748
    {
2293
 
                                                yyval.stmt = make_case(yyvsp[-6].ival, yyvsp[-5].expr, yyvsp[-4].list, yyvsp[-3].list);
 
2749
                                                (yyval.stmt) = make_case((yyvsp[(2) - (8)].ival), (yyvsp[(3) - (8)].expr), (yyvsp[(4) - (8)].list), (yyvsp[(5) - (8)].list));
2294
2750
                                        ;}
2295
2751
    break;
2296
2752
 
2297
2753
  case 95:
 
2754
 
 
2755
/* Line 1455 of yacc.c  */
2298
2756
#line 865 "gram.y"
2299
2757
    {
2300
2758
                                                PLpgSQL_expr *expr = NULL;
2306
2764
                                                        expr = plpgsql_read_expression(K_WHEN, "WHEN");
2307
2765
                                                }
2308
2766
                                                plpgsql_push_back_token(K_WHEN);
2309
 
                                                yyval.expr = expr;
 
2767
                                                (yyval.expr) = expr;
2310
2768
                                        ;}
2311
2769
    break;
2312
2770
 
2313
2771
  case 96:
 
2772
 
 
2773
/* Line 1455 of yacc.c  */
2314
2774
#line 880 "gram.y"
2315
2775
    {
2316
 
                                                yyval.list = lappend(yyvsp[-1].list, yyvsp[0].casewhen);
 
2776
                                                (yyval.list) = lappend((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].casewhen));
2317
2777
                                        ;}
2318
2778
    break;
2319
2779
 
2320
2780
  case 97:
 
2781
 
 
2782
/* Line 1455 of yacc.c  */
2321
2783
#line 884 "gram.y"
2322
2784
    {
2323
 
                                                yyval.list = list_make1(yyvsp[0].casewhen);
 
2785
                                                (yyval.list) = list_make1((yyvsp[(1) - (1)].casewhen));
2324
2786
                                        ;}
2325
2787
    break;
2326
2788
 
2327
2789
  case 98:
 
2790
 
 
2791
/* Line 1455 of yacc.c  */
2328
2792
#line 890 "gram.y"
2329
2793
    {
2330
2794
                                                PLpgSQL_case_when *new = palloc(sizeof(PLpgSQL_case_when));
2331
2795
 
2332
 
                                                new->lineno     = yyvsp[-2].ival;
2333
 
                                                new->expr       = yyvsp[-1].expr;
2334
 
                                                new->stmts      = yyvsp[0].list;
2335
 
                                                yyval.casewhen = new;
 
2796
                                                new->lineno     = (yyvsp[(2) - (4)].ival);
 
2797
                                                new->expr       = (yyvsp[(3) - (4)].expr);
 
2798
                                                new->stmts      = (yyvsp[(4) - (4)].list);
 
2799
                                                (yyval.casewhen) = new;
2336
2800
                                        ;}
2337
2801
    break;
2338
2802
 
2339
2803
  case 99:
 
2804
 
 
2805
/* Line 1455 of yacc.c  */
2340
2806
#line 901 "gram.y"
2341
2807
    {
2342
 
                                                yyval.list = NIL;
 
2808
                                                (yyval.list) = NIL;
2343
2809
                                        ;}
2344
2810
    break;
2345
2811
 
2346
2812
  case 100:
 
2813
 
 
2814
/* Line 1455 of yacc.c  */
2347
2815
#line 905 "gram.y"
2348
2816
    {
2349
2817
                                                /*
2352
2820
                                                 * Simplest fix is to return a list with one NULL
2353
2821
                                                 * pointer, which make_case() must take care of.
2354
2822
                                                 */
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);
2357
2825
                                                else
2358
 
                                                        yyval.list = list_make1(NULL);
 
2826
                                                        (yyval.list) = list_make1(NULL);
2359
2827
                                        ;}
2360
2828
    break;
2361
2829
 
2362
2830
  case 101:
 
2831
 
 
2832
/* Line 1455 of yacc.c  */
2363
2833
#line 920 "gram.y"
2364
2834
    {
2365
2835
                                                PLpgSQL_stmt_loop *new;
2366
2836
 
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;
2372
2842
 
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();
2375
2845
 
2376
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
2846
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
2377
2847
                                        ;}
2378
2848
    break;
2379
2849
 
2380
2850
  case 102:
 
2851
 
 
2852
/* Line 1455 of yacc.c  */
2381
2853
#line 937 "gram.y"
2382
2854
    {
2383
2855
                                                PLpgSQL_stmt_while *new;
2384
2856
 
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;
2391
2863
 
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();
2394
2866
 
2395
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
2867
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
2396
2868
                                        ;}
2397
2869
    break;
2398
2870
 
2399
2871
  case 103:
 
2872
 
 
2873
/* Line 1455 of yacc.c  */
2400
2874
#line 955 "gram.y"
2401
2875
    {
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)
2404
2878
                                                {
2405
2879
                                                        PLpgSQL_stmt_fori               *new;
2406
2880
 
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;
2411
2885
                                                }
2412
2886
                                                else
2413
2887
                                                {
2414
2888
                                                        PLpgSQL_stmt_forq               *new;
2415
2889
 
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;
2424
2898
                                                }
2425
2899
 
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();
2429
2903
                                        ;}
2430
2904
    break;
2431
2905
 
2432
2906
  case 104:
 
2907
 
 
2908
/* Line 1455 of yacc.c  */
2433
2909
#line 988 "gram.y"
2434
2910
    {
2435
2911
                                                int                     tok = yylex();
2447
2923
 
2448
2924
                                                        new = palloc0(sizeof(PLpgSQL_stmt_dynfors));
2449
2925
                                                        new->cmd_type = PLPGSQL_STMT_DYNFORS;
2450
 
                                                        new->lineno   = yyvsp[-2].ival;
2451
 
                                                        if (yyvsp[-1].forvariable.rec)
 
2926
                                                        new->lineno   = (yyvsp[(1) - (3)].ival);
 
2927
                                                        if ((yyvsp[(2) - (3)].forvariable).rec)
2452
2928
                                                        {
2453
 
                                                                new->rec = yyvsp[-1].forvariable.rec;
 
2929
                                                                new->rec = (yyvsp[(2) - (3)].forvariable).rec;
2454
2930
                                                                check_assignable((PLpgSQL_datum *) new->rec);
2455
2931
                                                        }
2456
 
                                                        else if (yyvsp[-1].forvariable.row)
 
2932
                                                        else if ((yyvsp[(2) - (3)].forvariable).row)
2457
2933
                                                        {
2458
 
                                                                new->row = yyvsp[-1].forvariable.row;
 
2934
                                                                new->row = (yyvsp[(2) - (3)].forvariable).row;
2459
2935
                                                                check_assignable((PLpgSQL_datum *) new->row);
2460
2936
                                                        }
2461
 
                                                        else if (yyvsp[-1].forvariable.scalar)
 
2937
                                                        else if ((yyvsp[(2) - (3)].forvariable).scalar)
2462
2938
                                                        {
2463
2939
                                                                /* convert single scalar to list */
2464
 
                                                                new->row = make_scalar_list1(yyvsp[-1].forvariable.name, yyvsp[-1].forvariable.scalar, yyvsp[-1].forvariable.lineno);
 
2940
                                                                new->row = make_scalar_list1((yyvsp[(2) - (3)].forvariable).name, (yyvsp[(2) - (3)].forvariable).scalar, (yyvsp[(2) - (3)].forvariable).lineno);
2465
2941
                                                                /* no need for check_assignable */
2466
2942
                                                        }
2467
2943
                                                        else
2468
2944
                                                        {
2469
 
                                                                plpgsql_error_lineno = yyvsp[-1].forvariable.lineno;
 
2945
                                                                plpgsql_error_lineno = (yyvsp[(2) - (3)].forvariable).lineno;
2470
2946
                                                                yyerror("loop variable of loop over rows must be a record or row variable or list of scalar variables");
2471
2947
                                                        }
2472
2948
                                                        new->query = expr;
2482
2958
                                                                } while (term == ',');
2483
2959
                                                        }
2484
2960
 
2485
 
                                                        yyval.stmt = (PLpgSQL_stmt *) new;
 
2961
                                                        (yyval.stmt) = (PLpgSQL_stmt *) new;
2486
2962
                                                }
2487
2963
                                                else if (tok == T_SCALAR &&
2488
2964
                                                                 yylval.scalar->dtype == PLPGSQL_DTYPE_VAR &&
2495
2971
 
2496
2972
                                                        new = (PLpgSQL_stmt_forc *) palloc0(sizeof(PLpgSQL_stmt_forc));
2497
2973
                                                        new->cmd_type = PLPGSQL_STMT_FORC;
2498
 
                                                        new->lineno = yyvsp[-2].ival;
 
2974
                                                        new->lineno = (yyvsp[(1) - (3)].ival);
2499
2975
 
2500
2976
                                                        new->curvar = cursor->dno;
2501
2977
 
2502
2978
                                                        /* Should have had a single variable name */
2503
 
                                                        plpgsql_error_lineno = yyvsp[-1].forvariable.lineno;
2504
 
                                                        if (yyvsp[-1].forvariable.scalar && yyvsp[-1].forvariable.row)
 
2979
                                                        plpgsql_error_lineno = (yyvsp[(2) - (3)].forvariable).lineno;
 
2980
                                                        if ((yyvsp[(2) - (3)].forvariable).scalar && (yyvsp[(2) - (3)].forvariable).row)
2505
2981
                                                                ereport(ERROR,
2506
2982
                                                                                (errcode(ERRCODE_SYNTAX_ERROR),
2507
2983
                                                                                 errmsg("cursor FOR loop must have only one target variable")));
2508
2984
 
2509
2985
                                                        /* create loop's private RECORD variable */
2510
 
                                                        plpgsql_convert_ident(yyvsp[-1].forvariable.name, &varname, 1);
 
2986
                                                        plpgsql_convert_ident((yyvsp[(2) - (3)].forvariable).name, &varname, 1);
2511
2987
                                                        new->rec = plpgsql_build_record(varname,
2512
 
                                                                                                                        yyvsp[-1].forvariable.lineno,
 
2988
                                                                                                                        (yyvsp[(2) - (3)].forvariable).lineno,
2513
2989
                                                                                                                        true);
2514
2990
 
2515
2991
                                                        /* can't use an unbound cursor this way */
2523
2999
                                                                                                                         K_LOOP,
2524
3000
                                                                                                                         "LOOP");
2525
3001
 
2526
 
                                                        yyval.stmt = (PLpgSQL_stmt *) new;
 
3002
                                                        (yyval.stmt) = (PLpgSQL_stmt *) new;
2527
3003
                                                }
2528
3004
                                                else
2529
3005
                                                {
2588
3064
                                                                        expr_by = NULL;
2589
3065
 
2590
3066
                                                                /* Should have had a single variable name */
2591
 
                                                                plpgsql_error_lineno = yyvsp[-1].forvariable.lineno;
2592
 
                                                                if (yyvsp[-1].forvariable.scalar && yyvsp[-1].forvariable.row)
 
3067
                                                                plpgsql_error_lineno = (yyvsp[(2) - (3)].forvariable).lineno;
 
3068
                                                                if ((yyvsp[(2) - (3)].forvariable).scalar && (yyvsp[(2) - (3)].forvariable).row)
2593
3069
                                                                        ereport(ERROR,
2594
3070
                                                                                        (errcode(ERRCODE_SYNTAX_ERROR),
2595
3071
                                                                                         errmsg("integer FOR loop must have only one target variable")));
2596
3072
 
2597
3073
                                                                /* create loop's private variable */
2598
 
                                                                plpgsql_convert_ident(yyvsp[-1].forvariable.name, &varname, 1);
 
3074
                                                                plpgsql_convert_ident((yyvsp[(2) - (3)].forvariable).name, &varname, 1);
2599
3075
                                                                fvar = (PLpgSQL_var *)
2600
3076
                                                                        plpgsql_build_variable(varname,
2601
 
                                                                                                                   yyvsp[-1].forvariable.lineno,
 
3077
                                                                                                                   (yyvsp[(2) - (3)].forvariable).lineno,
2602
3078
                                                                                                                   plpgsql_build_datatype(INT4OID,
2603
3079
                                                                                                                                                                  -1),
2604
3080
                                                                                                                   true);
2605
3081
 
2606
3082
                                                                new = palloc0(sizeof(PLpgSQL_stmt_fori));
2607
3083
                                                                new->cmd_type = PLPGSQL_STMT_FORI;
2608
 
                                                                new->lineno   = yyvsp[-2].ival;
 
3084
                                                                new->lineno   = (yyvsp[(1) - (3)].ival);
2609
3085
                                                                new->var          = fvar;
2610
3086
                                                                new->reverse  = reverse;
2611
3087
                                                                new->lower        = expr1;
2612
3088
                                                                new->upper        = expr2;
2613
3089
                                                                new->step         = expr_by;
2614
3090
 
2615
 
                                                                yyval.stmt = (PLpgSQL_stmt *) new;
 
3091
                                                                (yyval.stmt) = (PLpgSQL_stmt *) new;
2616
3092
                                                        }
2617
3093
                                                        else
2618
3094
                                                        {
2636
3112
 
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)
2641
3117
                                                                {
2642
 
                                                                        new->rec = yyvsp[-1].forvariable.rec;
 
3118
                                                                        new->rec = (yyvsp[(2) - (3)].forvariable).rec;
2643
3119
                                                                        check_assignable((PLpgSQL_datum *) new->rec);
2644
3120
                                                                }
2645
 
                                                                else if (yyvsp[-1].forvariable.row)
 
3121
                                                                else if ((yyvsp[(2) - (3)].forvariable).row)
2646
3122
                                                                {
2647
 
                                                                        new->row = yyvsp[-1].forvariable.row;
 
3123
                                                                        new->row = (yyvsp[(2) - (3)].forvariable).row;
2648
3124
                                                                        check_assignable((PLpgSQL_datum *) new->row);
2649
3125
                                                                }
2650
 
                                                                else if (yyvsp[-1].forvariable.scalar)
 
3126
                                                                else if ((yyvsp[(2) - (3)].forvariable).scalar)
2651
3127
                                                                {
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 */
2655
3131
                                                                }
2656
3132
                                                                else
2657
3133
                                                                {
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");
2660
3136
                                                                }
2661
3137
 
2662
3138
                                                                new->query = expr1;
2663
 
                                                                yyval.stmt = (PLpgSQL_stmt *) new;
 
3139
                                                                (yyval.stmt) = (PLpgSQL_stmt *) new;
2664
3140
                                                        }
2665
3141
                                                }
2666
3142
                                        ;}
2667
3143
    break;
2668
3144
 
2669
3145
  case 105:
 
3146
 
 
3147
/* Line 1455 of yacc.c  */
2670
3148
#line 1242 "gram.y"
2671
3149
    {
2672
3150
                                                int                     tok;
2673
3151
 
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 */
2680
3158
                                                tok = yylex();
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);
2684
3162
                                        ;}
2685
3163
    break;
2686
3164
 
2687
3165
  case 106:
 
3166
 
 
3167
/* Line 1455 of yacc.c  */
2688
3168
#line 1257 "gram.y"
2689
3169
    {
2690
3170
                                                int                     tok;
2691
3171
 
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 */
2698
3178
                                                tok = yylex();
2699
3179
                                                plpgsql_push_back_token(tok);
2700
3180
                                                if (tok == ',')
2701
3181
                                                {
2702
 
                                                        plpgsql_error_lineno = yyval.forvariable.lineno;
 
3182
                                                        plpgsql_error_lineno = (yyval.forvariable).lineno;
2703
3183
                                                        ereport(ERROR,
2704
3184
                                                                        (errcode(ERRCODE_SYNTAX_ERROR),
2705
3185
                                                                         errmsg("\"%s\" is not a scalar variable",
2706
 
                                                                                        yyval.forvariable.name)));
 
3186
                                                                                        (yyval.forvariable).name)));
2707
3187
                                                }
2708
3188
                                        ;}
2709
3189
    break;
2710
3190
 
2711
3191
  case 107:
 
3192
 
 
3193
/* Line 1455 of yacc.c  */
2712
3194
#line 1278 "gram.y"
2713
3195
    {
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;
2719
3201
                                        ;}
2720
3202
    break;
2721
3203
 
2722
3204
  case 108:
 
3205
 
 
3206
/* Line 1455 of yacc.c  */
2723
3207
#line 1286 "gram.y"
2724
3208
    {
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;
2730
3214
                                        ;}
2731
3215
    break;
2732
3216
 
2733
3217
  case 109:
 
3218
 
 
3219
/* Line 1455 of yacc.c  */
2734
3220
#line 1296 "gram.y"
2735
3221
    {
2736
3222
                                                PLpgSQL_stmt_exit *new;
2737
3223
 
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);
2744
3230
 
2745
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
3231
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
2746
3232
                                        ;}
2747
3233
    break;
2748
3234
 
2749
3235
  case 110:
 
3236
 
 
3237
/* Line 1455 of yacc.c  */
2750
3238
#line 1311 "gram.y"
2751
3239
    {
2752
 
                                                yyval.boolean = true;
 
3240
                                                (yyval.boolean) = true;
2753
3241
                                        ;}
2754
3242
    break;
2755
3243
 
2756
3244
  case 111:
 
3245
 
 
3246
/* Line 1455 of yacc.c  */
2757
3247
#line 1315 "gram.y"
2758
3248
    {
2759
 
                                                yyval.boolean = false;
 
3249
                                                (yyval.boolean) = false;
2760
3250
                                        ;}
2761
3251
    break;
2762
3252
 
2763
3253
  case 112:
 
3254
 
 
3255
/* Line 1455 of yacc.c  */
2764
3256
#line 1321 "gram.y"
2765
3257
    {
2766
3258
                                                int     tok;
2776
3268
                                                 */
2777
3269
                                                if (pg_strcasecmp(yytext, "next") == 0)
2778
3270
                                                {
2779
 
                                                        yyval.stmt = make_return_next_stmt(yyvsp[0].ival);
 
3271
                                                        (yyval.stmt) = make_return_next_stmt((yyvsp[(2) - (2)].ival));
2780
3272
                                                }
2781
3273
                                                else if (pg_strcasecmp(yytext, "query") == 0)
2782
3274
                                                {
2783
 
                                                        yyval.stmt = make_return_query_stmt(yyvsp[0].ival);
 
3275
                                                        (yyval.stmt) = make_return_query_stmt((yyvsp[(2) - (2)].ival));
2784
3276
                                                }
2785
3277
                                                else
2786
3278
                                                {
2787
3279
                                                        plpgsql_push_back_token(tok);
2788
 
                                                        yyval.stmt = make_return_stmt(yyvsp[0].ival);
 
3280
                                                        (yyval.stmt) = make_return_stmt((yyvsp[(2) - (2)].ival));
2789
3281
                                                }
2790
3282
                                        ;}
2791
3283
    break;
2792
3284
 
2793
3285
  case 113:
 
3286
 
 
3287
/* Line 1455 of yacc.c  */
2794
3288
#line 1350 "gram.y"
2795
3289
    {
2796
3290
                                                PLpgSQL_stmt_raise              *new;
2799
3293
                                                new = palloc(sizeof(PLpgSQL_stmt_raise));
2800
3294
 
2801
3295
                                                new->cmd_type   = PLPGSQL_STMT_RAISE;
2802
 
                                                new->lineno             = yyvsp[0].ival;
 
3296
                                                new->lineno             = (yyvsp[(2) - (2)].ival);
2803
3297
                                                new->elog_level = ERROR;        /* default */
2804
3298
                                                new->condname   = NULL;
2805
3299
                                                new->message    = NULL;
2923
3417
                                                                new->options = read_raise_options();
2924
3418
                                                }
2925
3419
 
2926
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
3420
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
2927
3421
                                        ;}
2928
3422
    break;
2929
3423
 
2930
3424
  case 114:
 
3425
 
 
3426
/* Line 1455 of yacc.c  */
2931
3427
#line 1486 "gram.y"
2932
3428
    {
2933
 
                                                yyval.loop_body.stmts = yyvsp[-4].list;
2934
 
                                                yyval.loop_body.end_label = yyvsp[-1].str;
 
3429
                                                (yyval.loop_body).stmts = (yyvsp[(1) - (5)].list);
 
3430
                                                (yyval.loop_body).end_label = (yyvsp[(4) - (5)].str);
2935
3431
                                        ;}
2936
3432
    break;
2937
3433
 
2938
3434
  case 115:
 
3435
 
 
3436
/* Line 1455 of yacc.c  */
2939
3437
#line 1493 "gram.y"
2940
3438
    {
2941
 
                                                yyval.stmt = make_execsql_stmt(yyvsp[-1].str, yyvsp[0].ival);
 
3439
                                                (yyval.stmt) = make_execsql_stmt((yyvsp[(1) - (2)].str), (yyvsp[(2) - (2)].ival));
2942
3440
                                        ;}
2943
3441
    break;
2944
3442
 
2945
3443
  case 116:
 
3444
 
 
3445
/* Line 1455 of yacc.c  */
2946
3446
#line 1500 "gram.y"
2947
 
    { yyval.str = pstrdup(yytext); ;}
 
3447
    { (yyval.str) = pstrdup(yytext); ;}
2948
3448
    break;
2949
3449
 
2950
3450
  case 117:
 
3451
 
 
3452
/* Line 1455 of yacc.c  */
2951
3453
#line 1502 "gram.y"
2952
 
    { yyval.str = pstrdup(yytext); ;}
 
3454
    { (yyval.str) = pstrdup(yytext); ;}
2953
3455
    break;
2954
3456
 
2955
3457
  case 118:
 
3458
 
 
3459
/* Line 1455 of yacc.c  */
2956
3460
#line 1504 "gram.y"
2957
 
    { yyval.str = pstrdup(yytext); ;}
 
3461
    { (yyval.str) = pstrdup(yytext); ;}
2958
3462
    break;
2959
3463
 
2960
3464
  case 119:
 
3465
 
 
3466
/* Line 1455 of yacc.c  */
2961
3467
#line 1508 "gram.y"
2962
3468
    {
2963
3469
                                                PLpgSQL_stmt_dynexecute *new;
2971
3477
 
2972
3478
                                                new = palloc(sizeof(PLpgSQL_stmt_dynexecute));
2973
3479
                                                new->cmd_type = PLPGSQL_STMT_DYNEXECUTE;
2974
 
                                                new->lineno = yyvsp[0].ival;
 
3480
                                                new->lineno = (yyvsp[(2) - (2)].ival);
2975
3481
                                                new->query = expr;
2976
3482
                                                new->into = false;
2977
3483
                                                new->strict = false;
3016
3522
                                                                yyerror("syntax error");
3017
3523
                                                }
3018
3524
 
3019
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
3525
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
3020
3526
                                        ;}
3021
3527
    break;
3022
3528
 
3023
3529
  case 120:
 
3530
 
 
3531
/* Line 1455 of yacc.c  */
3024
3532
#line 1571 "gram.y"
3025
3533
    {
3026
3534
                                                PLpgSQL_stmt_open *new;
3028
3536
 
3029
3537
                                                new = palloc0(sizeof(PLpgSQL_stmt_open));
3030
3538
                                                new->cmd_type = PLPGSQL_STMT_OPEN;
3031
 
                                                new->lineno = yyvsp[-1].ival;
3032
 
                                                new->curvar = yyvsp[0].var->dno;
 
3539
                                                new->lineno = (yyvsp[(2) - (3)].ival);
 
3540
                                                new->curvar = (yyvsp[(3) - (3)].var)->dno;
3033
3541
                                                new->cursor_options = CURSOR_OPT_FAST_PLAN;
3034
3542
 
3035
 
                                                if (yyvsp[0].var->cursor_explicit_expr == NULL)
 
3543
                                                if ((yyvsp[(3) - (3)].var)->cursor_explicit_expr == NULL)
3036
3544
                                                {
3037
3545
                                                        /* be nice if we could use opt_scrollable here */
3038
3546
                                                    tok = yylex();
3049
3557
 
3050
3558
                                                        if (tok != K_FOR)
3051
3559
                                                        {
3052
 
                                                                plpgsql_error_lineno = yyvsp[-1].ival;
 
3560
                                                                plpgsql_error_lineno = (yyvsp[(2) - (3)].ival);
3053
3561
                                                                ereport(ERROR,
3054
3562
                                                                                (errcode(ERRCODE_SYNTAX_ERROR),
3055
3563
                                                                                 errmsg("syntax error at \"%s\"",
3071
3579
                                                else
3072
3580
                                                {
3073
3581
                                                        /* predefined cursor query, so read args */
3074
 
                                                        new->argquery = read_cursor_args(yyvsp[0].var, ';', ";");
 
3582
                                                        new->argquery = read_cursor_args((yyvsp[(3) - (3)].var), ';', ";");
3075
3583
                                                }
3076
3584
 
3077
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
3585
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
3078
3586
                                        ;}
3079
3587
    break;
3080
3588
 
3081
3589
  case 121:
 
3590
 
 
3591
/* Line 1455 of yacc.c  */
3082
3592
#line 1628 "gram.y"
3083
3593
    {
3084
 
                                                PLpgSQL_stmt_fetch *fetch = yyvsp[-2].fetch;
 
3594
                                                PLpgSQL_stmt_fetch *fetch = (yyvsp[(3) - (5)].fetch);
3085
3595
                                                PLpgSQL_rec        *rec;
3086
3596
                                                PLpgSQL_row        *row;
3087
3597
 
3091
3601
                                                if (yylex() != ';')
3092
3602
                                                        yyerror("syntax error");
3093
3603
 
3094
 
                                                fetch->lineno = yyvsp[-3].ival;
 
3604
                                                fetch->lineno = (yyvsp[(2) - (5)].ival);
3095
3605
                                                fetch->rec              = rec;
3096
3606
                                                fetch->row              = row;
3097
 
                                                fetch->curvar   = yyvsp[-1].var->dno;
 
3607
                                                fetch->curvar   = (yyvsp[(4) - (5)].var)->dno;
3098
3608
                                                fetch->is_move  = false;
3099
3609
 
3100
 
                                                yyval.stmt = (PLpgSQL_stmt *)fetch;
 
3610
                                                (yyval.stmt) = (PLpgSQL_stmt *)fetch;
3101
3611
                                        ;}
3102
3612
    break;
3103
3613
 
3104
3614
  case 122:
 
3615
 
 
3616
/* Line 1455 of yacc.c  */
3105
3617
#line 1650 "gram.y"
3106
3618
    {
3107
 
                                                PLpgSQL_stmt_fetch *fetch = yyvsp[-2].fetch;
 
3619
                                                PLpgSQL_stmt_fetch *fetch = (yyvsp[(3) - (5)].fetch);
3108
3620
 
3109
 
                                                fetch->lineno = yyvsp[-3].ival;
3110
 
                                                fetch->curvar   = yyvsp[-1].var->dno;
 
3621
                                                fetch->lineno = (yyvsp[(2) - (5)].ival);
 
3622
                                                fetch->curvar   = (yyvsp[(4) - (5)].var)->dno;
3111
3623
                                                fetch->is_move  = true;
3112
3624
 
3113
 
                                                yyval.stmt = (PLpgSQL_stmt *)fetch;
 
3625
                                                (yyval.stmt) = (PLpgSQL_stmt *)fetch;
3114
3626
                                        ;}
3115
3627
    break;
3116
3628
 
3117
3629
  case 123:
 
3630
 
 
3631
/* Line 1455 of yacc.c  */
3118
3632
#line 1662 "gram.y"
3119
3633
    {
3120
 
                                                yyval.fetch = read_fetch_direction();
 
3634
                                                (yyval.fetch) = read_fetch_direction();
3121
3635
                                        ;}
3122
3636
    break;
3123
3637
 
3124
3638
  case 124:
 
3639
 
 
3640
/* Line 1455 of yacc.c  */
3125
3641
#line 1668 "gram.y"
3126
3642
    {
3127
3643
                                                PLpgSQL_stmt_close *new;
3128
3644
 
3129
3645
                                                new = palloc(sizeof(PLpgSQL_stmt_close));
3130
3646
                                                new->cmd_type = PLPGSQL_STMT_CLOSE;
3131
 
                                                new->lineno = yyvsp[-2].ival;
3132
 
                                                new->curvar = yyvsp[-1].var->dno;
 
3647
                                                new->lineno = (yyvsp[(2) - (4)].ival);
 
3648
                                                new->curvar = (yyvsp[(3) - (4)].var)->dno;
3133
3649
 
3134
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
3650
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
3135
3651
                                        ;}
3136
3652
    break;
3137
3653
 
3138
3654
  case 125:
 
3655
 
 
3656
/* Line 1455 of yacc.c  */
3139
3657
#line 1681 "gram.y"
3140
3658
    {
3141
3659
                                                /* We do not bother building a node for NULL */
3142
 
                                                yyval.stmt = NULL;
 
3660
                                                (yyval.stmt) = NULL;
3143
3661
                                        ;}
3144
3662
    break;
3145
3663
 
3146
3664
  case 126:
 
3665
 
 
3666
/* Line 1455 of yacc.c  */
3147
3667
#line 1688 "gram.y"
3148
3668
    {
3149
3669
                                                if (yylval.scalar->dtype != PLPGSQL_DTYPE_VAR)
3157
3677
                                                                         errmsg("variable \"%s\" must be of type cursor or refcursor",
3158
3678
                                                                                        ((PLpgSQL_var *) yylval.scalar)->refname)));
3159
3679
                                                }
3160
 
                                                yyval.var = (PLpgSQL_var *) yylval.scalar;
 
3680
                                                (yyval.var) = (PLpgSQL_var *) yylval.scalar;
3161
3681
                                        ;}
3162
3682
    break;
3163
3683
 
3164
3684
  case 127:
 
3685
 
 
3686
/* Line 1455 of yacc.c  */
3165
3687
#line 1703 "gram.y"
3166
3688
    {
3167
3689
                                                yyerror("expected a cursor or refcursor variable");
3169
3691
    break;
3170
3692
 
3171
3693
  case 128:
 
3694
 
 
3695
/* Line 1455 of yacc.c  */
3172
3696
#line 1707 "gram.y"
3173
3697
    {
3174
3698
                                                yyerror("expected a cursor or refcursor variable");
3176
3700
    break;
3177
3701
 
3178
3702
  case 129:
 
3703
 
 
3704
/* Line 1455 of yacc.c  */
3179
3705
#line 1711 "gram.y"
3180
3706
    {
3181
3707
                                                yyerror("expected a cursor or refcursor variable");
3183
3709
    break;
3184
3710
 
3185
3711
  case 130:
 
3712
 
 
3713
/* Line 1455 of yacc.c  */
3186
3714
#line 1717 "gram.y"
3187
 
    { yyval.exception_block = NULL; ;}
 
3715
    { (yyval.exception_block) = NULL; ;}
3188
3716
    break;
3189
3717
 
3190
3718
  case 131:
 
3719
 
 
3720
/* Line 1455 of yacc.c  */
3191
3721
#line 1719 "gram.y"
3192
3722
    {
3193
3723
                                                /*
3198
3728
                                                PLpgSQL_exception_block *new = palloc(sizeof(PLpgSQL_exception_block));
3199
3729
                                                PLpgSQL_variable *var;
3200
3730
 
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),
3203
3733
                                                                                                         true);
3204
3734
                                                ((PLpgSQL_var *) var)->isconst = true;
3205
3735
                                                new->sqlstate_varno = var->dno;
3206
3736
 
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),
3209
3739
                                                                                                         true);
3210
3740
                                                ((PLpgSQL_var *) var)->isconst = true;
3211
3741
                                                new->sqlerrm_varno = var->dno;
3212
3742
 
3213
 
                                                yyval.exception_block = new;
 
3743
                                                (yyval.exception_block) = new;
3214
3744
                                        ;}
3215
3745
    break;
3216
3746
 
3217
3747
  case 132:
 
3748
 
 
3749
/* Line 1455 of yacc.c  */
3218
3750
#line 1743 "gram.y"
3219
3751
    {
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);
3222
3754
 
3223
 
                                                yyval.exception_block = new;
 
3755
                                                (yyval.exception_block) = new;
3224
3756
                                        ;}
3225
3757
    break;
3226
3758
 
3227
3759
  case 133:
 
3760
 
 
3761
/* Line 1455 of yacc.c  */
3228
3762
#line 1752 "gram.y"
3229
3763
    {
3230
 
                                                        yyval.list = lappend(yyvsp[-1].list, yyvsp[0].exception);
 
3764
                                                        (yyval.list) = lappend((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].exception));
3231
3765
                                                ;}
3232
3766
    break;
3233
3767
 
3234
3768
  case 134:
 
3769
 
 
3770
/* Line 1455 of yacc.c  */
3235
3771
#line 1756 "gram.y"
3236
3772
    {
3237
 
                                                        yyval.list = list_make1(yyvsp[0].exception);
 
3773
                                                        (yyval.list) = list_make1((yyvsp[(1) - (1)].exception));
3238
3774
                                                ;}
3239
3775
    break;
3240
3776
 
3241
3777
  case 135:
 
3778
 
 
3779
/* Line 1455 of yacc.c  */
3242
3780
#line 1762 "gram.y"
3243
3781
    {
3244
3782
                                                PLpgSQL_exception *new;
3245
3783
 
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);
3250
3788
 
3251
 
                                                yyval.exception = new;
 
3789
                                                (yyval.exception) = new;
3252
3790
                                        ;}
3253
3791
    break;
3254
3792
 
3255
3793
  case 136:
 
3794
 
 
3795
/* Line 1455 of yacc.c  */
3256
3796
#line 1775 "gram.y"
3257
3797
    {
3258
3798
                                                        PLpgSQL_condition       *old;
3259
3799
 
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)
3261
3801
                                                                /* skip */ ;
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);
3264
3804
                                                ;}
3265
3805
    break;
3266
3806
 
3267
3807
  case 137:
 
3808
 
 
3809
/* Line 1455 of yacc.c  */
3268
3810
#line 1784 "gram.y"
3269
3811
    {
3270
 
                                                        yyval.condition = yyvsp[0].condition;
 
3812
                                                        (yyval.condition) = (yyvsp[(1) - (1)].condition);
3271
3813
                                                ;}
3272
3814
    break;
3273
3815
 
3274
3816
  case 138:
 
3817
 
 
3818
/* Line 1455 of yacc.c  */
3275
3819
#line 1790 "gram.y"
3276
3820
    {
3277
 
                                                        if (strcmp(yyvsp[0].str, "sqlstate") != 0)
 
3821
                                                        if (strcmp((yyvsp[(1) - (1)].str), "sqlstate") != 0)
3278
3822
                                                        {
3279
 
                                                                yyval.condition = plpgsql_parse_err_condition(yyvsp[0].str);
 
3823
                                                                (yyval.condition) = plpgsql_parse_err_condition((yyvsp[(1) - (1)].str));
3280
3824
                                                        }
3281
3825
                                                        else
3282
3826
                                                        {
3303
3847
                                                                new->condname = sqlstatestr;
3304
3848
                                                                new->next = NULL;
3305
3849
 
3306
 
                                                                yyval.condition = new;
 
3850
                                                                (yyval.condition) = new;
3307
3851
                                                        }
3308
3852
                                                ;}
3309
3853
    break;
3310
3854
 
3311
3855
  case 139:
 
3856
 
 
3857
/* Line 1455 of yacc.c  */
3312
3858
#line 1826 "gram.y"
3313
 
    { yyval.expr = plpgsql_read_expression(';', ";"); ;}
 
3859
    { (yyval.expr) = plpgsql_read_expression(';', ";"); ;}
3314
3860
    break;
3315
3861
 
3316
3862
  case 140:
 
3863
 
 
3864
/* Line 1455 of yacc.c  */
3317
3865
#line 1830 "gram.y"
3318
 
    { yyval.expr = plpgsql_read_expression(']', "]"); ;}
 
3866
    { (yyval.expr) = plpgsql_read_expression(']', "]"); ;}
3319
3867
    break;
3320
3868
 
3321
3869
  case 141:
 
3870
 
 
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"); ;}
3324
3874
    break;
3325
3875
 
3326
3876
  case 142:
 
3877
 
 
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"); ;}
3329
3881
    break;
3330
3882
 
3331
3883
  case 143:
 
3884
 
 
3885
/* Line 1455 of yacc.c  */
3332
3886
#line 1842 "gram.y"
3333
3887
    {
3334
3888
                                                plpgsql_ns_push(NULL);
3335
 
                                                yyval.str = NULL;
 
3889
                                                (yyval.str) = NULL;
3336
3890
                                        ;}
3337
3891
    break;
3338
3892
 
3339
3893
  case 144:
 
3894
 
 
3895
/* Line 1455 of yacc.c  */
3340
3896
#line 1847 "gram.y"
3341
3897
    {
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);
3344
3900
                                        ;}
3345
3901
    break;
3346
3902
 
3347
3903
  case 145:
 
3904
 
 
3905
/* Line 1455 of yacc.c  */
3348
3906
#line 1854 "gram.y"
3349
3907
    {
3350
 
                                                yyval.str = NULL;
 
3908
                                                (yyval.str) = NULL;
3351
3909
                                        ;}
3352
3910
    break;
3353
3911
 
3354
3912
  case 146:
 
3913
 
 
3914
/* Line 1455 of yacc.c  */
3355
3915
#line 1858 "gram.y"
3356
3916
    {
3357
 
                                                yyval.str = check_label(yyvsp[0].str);
 
3917
                                                (yyval.str) = check_label((yyvsp[(1) - (1)].str));
3358
3918
                                        ;}
3359
3919
    break;
3360
3920
 
3361
3921
  case 147:
 
3922
 
 
3923
/* Line 1455 of yacc.c  */
3362
3924
#line 1864 "gram.y"
3363
 
    { yyval.expr = NULL; ;}
 
3925
    { (yyval.expr) = NULL; ;}
3364
3926
    break;
3365
3927
 
3366
3928
  case 148:
 
3929
 
 
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); ;}
3369
3933
    break;
3370
3934
 
3371
3935
  case 149:
 
3936
 
 
3937
/* Line 1455 of yacc.c  */
3372
3938
#line 1873 "gram.y"
3373
3939
    {
3374
 
                                                yyval.str = yytext;
 
3940
                                                (yyval.str) = yytext;
3375
3941
                                        ;}
3376
3942
    break;
3377
3943
 
3378
3944
  case 150:
 
3945
 
 
3946
/* Line 1455 of yacc.c  */
3379
3947
#line 1877 "gram.y"
3380
3948
    {
3381
 
                                                yyval.str = yytext;
 
3949
                                                (yyval.str) = yytext;
3382
3950
                                        ;}
3383
3951
    break;
3384
3952
 
3385
3953
  case 151:
 
3954
 
 
3955
/* Line 1455 of yacc.c  */
3386
3956
#line 1881 "gram.y"
3387
3957
    {
3388
 
                                                yyval.str = yytext;
 
3958
                                                (yyval.str) = yytext;
3389
3959
                                        ;}
3390
3960
    break;
3391
3961
 
3392
3962
  case 152:
 
3963
 
 
3964
/* Line 1455 of yacc.c  */
3393
3965
#line 1885 "gram.y"
3394
3966
    {
3395
 
                                                yyval.str = yytext;
 
3967
                                                (yyval.str) = yytext;
3396
3968
                                        ;}
3397
3969
    break;
3398
3970
 
3399
3971
  case 153:
 
3972
 
 
3973
/* Line 1455 of yacc.c  */
3400
3974
#line 1891 "gram.y"
3401
3975
    {
3402
3976
                                                char    *name;
3403
3977
 
3404
 
                                                plpgsql_convert_ident(yyvsp[0].str, &name, 1);
3405
 
                                                yyval.str = name;
 
3978
                                                plpgsql_convert_ident((yyvsp[(1) - (1)].str), &name, 1);
 
3979
                                                (yyval.str) = name;
3406
3980
                                        ;}
3407
3981
    break;
3408
3982
 
3409
3983
  case 154:
 
3984
 
 
3985
/* Line 1455 of yacc.c  */
3410
3986
#line 1900 "gram.y"
3411
3987
    {
3412
 
                                                yyval.ival = plpgsql_error_lineno = plpgsql_scanner_lineno();
 
3988
                                                (yyval.ival) = plpgsql_error_lineno = plpgsql_scanner_lineno();
3413
3989
                                        ;}
3414
3990
    break;
3415
3991
 
3416
3992
 
 
3993
 
 
3994
/* Line 1455 of yacc.c  */
 
3995
#line 3996 "pl_gram.c"
 
3996
      default: break;
3417
3997
    }
3418
 
 
3419
 
/* Line 991 of yacc.c.  */
3420
 
#line 3420 "pl_gram.c"
3421
 
 
3422
 
  yyvsp -= yylen;
3423
 
  yyssp -= yylen;
3424
 
 
3425
 
 
 
3998
  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
 
3999
 
 
4000
  YYPOPSTACK (yylen);
 
4001
  yylen = 0;
3426
4002
  YY_STACK_PRINT (yyss, yyssp);
3427
4003
 
3428
4004
  *++yyvsp = yyval;
3429
4005
 
3430
 
 
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)
3452
4027
    {
3453
4028
      ++yynerrs;
3454
 
#if YYERROR_VERBOSE
3455
 
      yyn = yypact[yystate];
3456
 
 
3457
 
      if (YYPACT_NINF < yyn && yyn < YYLAST)
3458
 
        {
3459
 
          YYSIZE_T yysize = 0;
3460
 
          int yytype = YYTRANSLATE (yychar);
3461
 
          char *yymsg;
3462
 
          int yyx, yycount;
3463
 
 
3464
 
          yycount = 0;
3465
 
          /* Start YYX at -YYN if negative to avoid negative indexes in
3466
 
             YYCHECK.  */
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);
3474
 
          if (yymsg != 0)
3475
 
            {
3476
 
              char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
3477
 
              yyp = yystpcpy (yyp, yytname[yytype]);
3478
 
 
3479
 
              if (yycount < 5)
3480
 
                {
3481
 
                  yycount = 0;
3482
 
                  for (yyx = yyn < 0 ? -yyn : 0;
3483
 
                       yyx < (int) (sizeof (yytname) / sizeof (char *));
3484
 
                       yyx++)
3485
 
                    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3486
 
                      {
3487
 
                        const char *yyq = ! yycount ? ", expecting " : " or ";
3488
 
                        yyp = yystpcpy (yyp, yyq);
3489
 
                        yyp = yystpcpy (yyp, yytname[yyx]);
3490
 
                        yycount++;
3491
 
                      }
3492
 
                }
3493
 
              yyerror (yymsg);
 
4029
#if ! YYERROR_VERBOSE
 
4030
      yyerror (YY_("syntax error"));
 
4031
#else
 
4032
      {
 
4033
        YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
 
4034
        if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
 
4035
          {
 
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);
3495
 
            }
3496
 
          else
3497
 
            yyerror ("syntax error; also virtual memory exhausted");
3498
 
        }
3499
 
      else
3500
 
#endif /* YYERROR_VERBOSE */
3501
 
        yyerror ("syntax error");
 
4041
            yymsg = (char *) YYSTACK_ALLOC (yyalloc);
 
4042
            if (yymsg)
 
4043
              yymsg_alloc = yyalloc;
 
4044
            else
 
4045
              {
 
4046
                yymsg = yymsgbuf;
 
4047
                yymsg_alloc = sizeof yymsgbuf;
 
4048
              }
 
4049
          }
 
4050
 
 
4051
        if (0 < yysize && yysize <= yymsg_alloc)
 
4052
          {
 
4053
            (void) yysyntax_error (yymsg, yystate, yychar);
 
4054
            yyerror (yymsg);
 
4055
          }
 
4056
        else
 
4057
          {
 
4058
            yyerror (YY_("syntax error"));
 
4059
            if (yysize != 0)
 
4060
              goto yyexhaustedlab;
 
4061
          }
 
4062
      }
 
4063
#endif
3502
4064
    }
3503
4065
 
3504
4066
 
3508
4070
      /* If just tried and failed to reuse lookahead token after an
3509
4071
         error, discard it.  */
3510
4072
 
3511
 
      /* Return failure if at end of input.  */
3512
 
      if (yychar == YYEOF)
3513
 
        {
3514
 
          /* Pop the error token.  */
3515
 
          YYPOPSTACK;
3516
 
          /* Pop the rest of the stack.  */
3517
 
          while (yyss < yyssp)
3518
 
            {
3519
 
              YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
3520
 
              yydestruct (yystos[*yyssp], yyvsp);
3521
 
              YYPOPSTACK;
3522
 
            }
3523
 
          YYABORT;
3524
 
        }
3525
 
 
3526
 
      YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
3527
 
      yydestruct (yytoken, &yylval);
3528
 
      yychar = YYEMPTY;
3529
 
 
 
4073
      if (yychar <= YYEOF)
 
4074
        {
 
4075
          /* Return failure if at end of input.  */
 
4076
          if (yychar == YYEOF)
 
4077
            YYABORT;
 
4078
        }
 
4079
      else
 
4080
        {
 
4081
          yydestruct ("Error: discarding",
 
4082
                      yytoken, &yylval);
 
4083
          yychar = YYEMPTY;
 
4084
        }
3530
4085
    }
3531
4086
 
3532
4087
  /* Else will try to reuse lookahead token after shifting the error
3533
4088
     token.  */
3534
 
  goto yyerrlab2;
3535
 
 
3536
 
 
3537
 
/*----------------------------------------------------.
3538
 
| yyerrlab1 -- error raised explicitly by an action.  |
3539
 
`----------------------------------------------------*/
 
4089
  goto yyerrlab1;
 
4090
 
 
4091
 
 
4092
/*---------------------------------------------------.
 
4093
| yyerrorlab -- error raised explicitly by YYERROR.  |
 
4094
`---------------------------------------------------*/
 
4095
yyerrorlab:
 
4096
 
 
4097
  /* Pacify compilers like GCC when the user code never invokes
 
4098
     YYERROR and the label yyerrorlab therefore never appears in user
 
4099
     code.  */
 
4100
  if (/*CONSTCOND*/ 0)
 
4101
     goto yyerrorlab;
 
4102
 
 
4103
  /* Do not reclaim the symbols of the rule which action triggered
 
4104
     this YYERROR.  */
 
4105
  YYPOPSTACK (yylen);
 
4106
  yylen = 0;
 
4107
  YY_STACK_PRINT (yyss, yyssp);
 
4108
  yystate = *yyssp;
 
4109
  goto yyerrlab1;
 
4110
 
 
4111
 
 
4112
/*-------------------------------------------------------------.
 
4113
| yyerrlab1 -- common code for both syntax error and YYERROR.  |
 
4114
`-------------------------------------------------------------*/
3540
4115
yyerrlab1:
3541
 
 
3542
 
  /* Suppress GCC warning that yyerrlab1 is unused when no action
3543
 
     invokes YYERROR.  */
3544
 
#if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__)
3545
 
  __attribute__ ((__unused__))
3546
 
#endif
3547
 
 
3548
 
 
3549
 
  goto yyerrlab2;
3550
 
 
3551
 
 
3552
 
/*---------------------------------------------------------------.
3553
 
| yyerrlab2 -- pop states until the error token can be shifted.  |
3554
 
`---------------------------------------------------------------*/
3555
 
yyerrlab2:
3556
4116
  yyerrstatus = 3;      /* Each real token shifted decrements this.  */
3557
4117
 
3558
4118
  for (;;)
3573
4133
      if (yyssp == yyss)
3574
4134
        YYABORT;
3575
4135
 
3576
 
      YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
3577
 
      yydestruct (yystos[yystate], yyvsp);
3578
 
      yyvsp--;
3579
 
      yystate = *--yyssp;
3580
4136
 
 
4137
      yydestruct ("Error: popping",
 
4138
                  yystos[yystate], yyvsp);
 
4139
      YYPOPSTACK (1);
 
4140
      yystate = *yyssp;
3581
4141
      YY_STACK_PRINT (yyss, yyssp);
3582
4142
    }
3583
4143
 
3584
 
  if (yyn == YYFINAL)
3585
 
    YYACCEPT;
3586
 
 
3587
 
  YYDPRINTF ((stderr, "Shifting error token, "));
3588
 
 
3589
4144
  *++yyvsp = yylval;
3590
4145
 
3591
4146
 
 
4147
  /* Shift the error token.  */
 
4148
  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
 
4149
 
3592
4150
  yystate = yyn;
3593
4151
  goto yynewstate;
3594
4152
 
3607
4165
  yyresult = 1;
3608
4166
  goto yyreturn;
3609
4167
 
3610
 
#ifndef yyoverflow
3611
 
/*----------------------------------------------.
3612
 
| yyoverflowlab -- parser overflow comes here.  |
3613
 
`----------------------------------------------*/
3614
 
yyoverflowlab:
3615
 
  yyerror ("parser stack overflow");
 
4168
#if !defined(yyoverflow) || YYERROR_VERBOSE
 
4169
/*-------------------------------------------------.
 
4170
| yyexhaustedlab -- memory exhaustion comes here.  |
 
4171
`-------------------------------------------------*/
 
4172
yyexhaustedlab:
 
4173
  yyerror (YY_("memory exhausted"));
3616
4174
  yyresult = 2;
3617
4175
  /* Fall through.  */
3618
4176
#endif
3619
4177
 
3620
4178
yyreturn:
 
4179
  if (yychar != YYEMPTY)
 
4180
     yydestruct ("Cleanup: discarding lookahead",
 
4181
                 yytoken, &yylval);
 
4182
  /* Do not reclaim the symbols of the rule which action triggered
 
4183
     this YYABORT or YYACCEPT.  */
 
4184
  YYPOPSTACK (yylen);
 
4185
  YY_STACK_PRINT (yyss, yyssp);
 
4186
  while (yyssp != yyss)
 
4187
    {
 
4188
      yydestruct ("Cleanup: popping",
 
4189
                  yystos[*yyssp], yyvsp);
 
4190
      YYPOPSTACK (1);
 
4191
    }
3621
4192
#ifndef yyoverflow
3622
4193
  if (yyss != yyssa)
3623
4194
    YYSTACK_FREE (yyss);
3624
4195
#endif
3625
 
  return yyresult;
 
4196
#if YYERROR_VERBOSE
 
4197
  if (yymsg != yymsgbuf)
 
4198
    YYSTACK_FREE (yymsg);
 
4199
#endif
 
4200
  /* Make sure YYID is used.  */
 
4201
  return YYID (yyresult);
3626
4202
}
3627
4203
 
3628
4204
 
 
4205
 
 
4206
/* Line 1675 of yacc.c  */
3629
4207
#line 1905 "gram.y"
3630
4208
 
3631
4209