~ubuntu-branches/ubuntu/quantal/postgresql-9.1/quantal-proposed

« 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:39:18 UTC
  • mfrom: (12.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20111202143918-1ftj0oo87w0y8m8d
* 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.
  - Make "contrib/citext"'s upgrade script fix collations of citext
    columns and indexes.
    Existing citext columns and indexes aren't correctly marked as
    being of a collatable data type during pg_upgrade from a pre-9.1
    server. That leads to operations on them failing with errors such
    as "could not determine which collation to use for string
    comparison". This change allows them to be fixed by the same script
    that upgrades the citext module into a proper 9.1 extension during
    CREATE EXTENSION citext FROM unpackaged.
    If you have a previously-upgraded database that is suffering from
    this problem, and you already ran the "CREATE EXTENSION" command,
    you can manually run (as superuser) the "UPDATE" commands found at
    the end of "SHAREDIR/extension/citext--unpackaged--1.0.sql". (Run
    pg_config --sharedir if you're uncertain where "SHAREDIR" is.)
  - Fix possible crash during "UPDATE" or "DELETE" that joins to the
    output of a scalar-returning function.
  - Fix incorrect replay of WAL records for GIN index updates.
  - Fix TOAST-related data corruption during CREATE TABLE dest AS
    SELECT - FROM src or INSERT INTO dest SELECT * FROM src.
  - Fix possible failures during hot standby startup.
  - Start hot standby faster when initial snapshot is incomplete.
  - Fix race condition during toast table access from stale syscache
    entries. The typical symptom was transient errors like "missing chunk
    number 0 for toast value NNNNN in pg_toast_2619", where the cited toast
    table would always belong to a system catalog.
  - 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.
  - Fix incorrect management of placeholder variables in nestloop joins.
    This bug is known to lead to "variable not found in subplan target
    list" planner errors, and could possibly result in wrong query
    output when outer joins are involved.
  - Fix window functions that sort by expressions involving aggregates.
  - Fix "MergeAppend child's targetlist doesn't match MergeAppend"
    planner errors.
  - Fix index matching for operators with both collatable and
    noncollatable inputs. In 9.1.0, an indexable operator that has a
    non-collatable left-hand input type and a collatable right-hand input
    type would not be recognized as matching the left-hand column's index.
    An example is the hstore ? text operator.
  - Allow inlining of set-returning SQL functions with multiple OUT
    parameters.
  - Don't trust deferred-unique indexes for join removal.
  - 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.
  - Fix IF EXISTS to work correctly in "DROP OPERATOR FAMILY".
  - Disallow dropping of an extension from within its own script.
  - Don't mark auto-generated types as extension members.
  - Cope with invalid pre-existing search_path settings during "CREATE
    EXTENSION".
  - Avoid floating-point underflow while tracking buffer allocation
    rate.
  - Prevent autovacuum transactions from running in serializable mode.
    Autovacuum formerly used the cluster-wide default transaction
    isolation level, but there is no need for it to use anything higher
    than READ COMMITTED, and using SERIALIZABLE could result in
    unnecessary delays for other processes.
  - Ensure walsender processes respond promptly to SIGTERM.
  - Exclude "postmaster.opts" from base backups.
  - Fix incorrect field alignment in ecpg's SQLDA area.
  - 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.
  - Avoid platform-specific infinite loop in pg_dump.
  - Fix compression of plain-text output format in pg_dump.
    pg_dump has historically understood -Z with no -F switch to mean
    that it should emit a gzip-compressed version of its plain text
    output. Restore that behavior.
  - Fix pg_dump to dump user-defined casts between auto-generated
    types, such as table rowtypes.
  - Fix missed quoting of foreign server names in pg_dump.
  - Assorted fixes for pg_upgrade. Handle exclusion constraints correctly,
    avoid failures on Windows, don't complain about mismatched toast table
    names in 8.4 databases.
  - In PL/pgSQL, allow foreign tables to define row types.
  - Fix up conversions of PL/Perl functions' results.
    Restore the pre-9.1 behavior that PL/Perl functions returning void
    ignore the result value of their last Perl statement; 9.1.0 would
    throw an error if that statement returned a reference. Also, make
    sure it works to return a string value for a composite type, so
    long as the string meets the type's input format. In addition,
    throw errors for attempts to return Perl arrays or hashes when the
    function's declared result type is not an array or composite type,
    respectively. (Pre-9.1 versions rather uselessly returned strings
    like ARRAY(0x221a9a0) or HASH(0x221aa90) in such cases.)
  - Ensure PL/Perl strings are always correctly UTF8-encoded.
  - Use the preferred version of xsubpp to build PL/Perl, not
    necessarily the operating system's main copy.
  - Correctly propagate SQLSTATE in PL/Python exceptions.
  - Do not install PL/Python extension files for Python major versions
    other than the one built against.
  - Change all the "contrib" extension script files to report a useful
    error message if they are fed to psql. This should help teach people
    about the new method of using "CREATE EXTENSION" to load these files.
    In most cases, sourcing the scripts directly would fail anyway, but
    with harder-to-interpret messages.
  - Fix incorrect coding in "contrib/dict_int" and "contrib/dict_xsyn".
  - Remove "contrib/sepgsql" tests from the regular regression test
    mechanism. Since these tests require root privileges for setup, they're
    impractical to run automatically. Switch over to a manual approach
    instead, and provide a testing script to help with that.
  - Fix assorted errors in "contrib/unaccent"'s configuration file
    parsing.
  - Honor query cancel interrupts promptly in pgstatindex().
  - Revert unintentional enabling of WAL_DEBUG. Fortunately, as debugging
    tools go, this one is pretty cheap; but it's not intended to be enabled
    by default, so revert.
  - 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.
* debian/rules: Fix build failure for binary-indep-only builds.
  (Closes: #646079)

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 1
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
57
 
#define yylloc plpgsql_yylloc
 
66
/* Substitute the variable and function names.  */
 
67
#define yyparse         plpgsql_yyparse
 
68
#define yylex           plpgsql_yylex
 
69
#define yyerror         plpgsql_yyerror
 
70
#define yylval          plpgsql_yylval
 
71
#define yychar          plpgsql_yychar
 
72
#define yydebug         plpgsql_yydebug
 
73
#define yynerrs         plpgsql_yynerrs
 
74
#define yylloc          plpgsql_yylloc
 
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 procedural language
 
84
 *
 
85
 * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
 
86
 * Portions Copyright (c) 1994, Regents of the University of California
 
87
 *
 
88
 *
 
89
 * IDENTIFICATION
 
90
 *        src/pl/plpgsql/src/gram.y
 
91
 *
 
92
 *-------------------------------------------------------------------------
 
93
 */
 
94
 
 
95
#include "plpgsql.h"
 
96
 
 
97
#include "catalog/namespace.h"
 
98
#include "catalog/pg_type.h"
 
99
#include "parser/parser.h"
 
100
#include "parser/parse_type.h"
 
101
#include "parser/scanner.h"
 
102
#include "parser/scansup.h"
 
103
#include "utils/builtins.h"
 
104
 
 
105
 
 
106
/* Location tracking support --- simpler than bison's default */
 
107
#define YYLLOC_DEFAULT(Current, Rhs, N) \
 
108
        do { \
 
109
                if (N) \
 
110
                        (Current) = (Rhs)[1]; \
 
111
                else \
 
112
                        (Current) = (Rhs)[0]; \
 
113
        } while (0)
 
114
 
 
115
/*
 
116
 * Bison doesn't allocate anything that needs to live across parser calls,
 
117
 * so we can easily have it use palloc instead of malloc.  This prevents
 
118
 * memory leaks if we error out during parsing.  Note this only works with
 
119
 * bison >= 2.0.  However, in bison 1.875 the default is to use alloca()
 
120
 * if possible, so there's not really much problem anyhow, at least if
 
121
 * you're building with gcc.
 
122
 */
 
123
#define YYMALLOC palloc
 
124
#define YYFREE   pfree
 
125
 
 
126
 
 
127
typedef struct
 
128
{
 
129
        int                     location;
 
130
        int                     leaderlen;
 
131
} sql_error_callback_arg;
 
132
 
 
133
#define parser_errposition(pos)  plpgsql_scanner_errposition(pos)
 
134
 
 
135
union YYSTYPE;                                  /* need forward reference for tok_is_keyword */
 
136
 
 
137
static  bool                    tok_is_keyword(int token, union YYSTYPE *lval,
 
138
                                                                           int kw_token, const char *kw_str);
 
139
static  void                    word_is_not_variable(PLword *word, int location);
 
140
static  void                    cword_is_not_variable(PLcword *cword, int location);
 
141
static  void                    current_token_is_not_variable(int tok);
 
142
static  PLpgSQL_expr    *read_sql_construct(int until,
 
143
                                                                                        int until2,
 
144
                                                                                        int until3,
 
145
                                                                                        const char *expected,
 
146
                                                                                        const char *sqlstart,
 
147
                                                                                        bool isexpression,
 
148
                                                                                        bool valid_sql,
 
149
                                                                                        int *startloc,
 
150
                                                                                        int *endtoken);
 
151
static  PLpgSQL_expr    *read_sql_expression(int until,
 
152
                                                                                         const char *expected);
 
153
static  PLpgSQL_expr    *read_sql_expression2(int until, int until2,
 
154
                                                                                          const char *expected,
 
155
                                                                                          int *endtoken);
 
156
static  PLpgSQL_expr    *read_sql_stmt(const char *sqlstart);
 
157
static  PLpgSQL_type    *read_datatype(int tok);
 
158
static  PLpgSQL_stmt    *make_execsql_stmt(int firsttoken, int location);
 
159
static  PLpgSQL_stmt_fetch *read_fetch_direction(void);
 
160
static  void                     complete_direction(PLpgSQL_stmt_fetch *fetch,
 
161
                                                                                        bool *check_FROM);
 
162
static  PLpgSQL_stmt    *make_return_stmt(int location);
 
163
static  PLpgSQL_stmt    *make_return_next_stmt(int location);
 
164
static  PLpgSQL_stmt    *make_return_query_stmt(int location);
 
165
static  PLpgSQL_stmt    *make_case(int location, PLpgSQL_expr *t_expr,
 
166
                                                                   List *case_when_list, List *else_stmts);
 
167
static  char                    *NameOfDatum(PLwdatum *wdatum);
 
168
static  void                     check_assignable(PLpgSQL_datum *datum, int location);
 
169
static  void                     read_into_target(PLpgSQL_rec **rec, PLpgSQL_row **row,
 
170
                                                                                  bool *strict);
 
171
static  PLpgSQL_row             *read_into_scalar_list(char *initial_name,
 
172
                                                                                           PLpgSQL_datum *initial_datum,
 
173
                                                                                           int initial_location);
 
174
static  PLpgSQL_row             *make_scalar_list1(char *initial_name,
 
175
                                                                                   PLpgSQL_datum *initial_datum,
 
176
                                                                                   int lineno, int location);
 
177
static  void                     check_sql_expr(const char *stmt, int location,
 
178
                                                                                int leaderlen);
 
179
static  void                     plpgsql_sql_error_callback(void *arg);
 
180
static  PLpgSQL_type    *parse_datatype(const char *string, int location);
 
181
static  void                     check_labels(const char *start_label,
 
182
                                                                          const char *end_label,
 
183
                                                                          int end_location);
 
184
static  PLpgSQL_expr    *read_cursor_args(PLpgSQL_var *cursor,
 
185
                                                                                  int until, const char *expected);
 
186
static  List                    *read_raise_options(void);
 
187
 
 
188
 
 
189
 
 
190
/* Line 189 of yacc.c  */
 
191
#line 192 "pl_gram.c"
 
192
 
 
193
/* Enabling traces.  */
 
194
#ifndef YYDEBUG
 
195
# define YYDEBUG 0
 
196
#endif
 
197
 
 
198
/* Enabling verbose error messages.  */
 
199
#ifdef YYERROR_VERBOSE
 
200
# undef YYERROR_VERBOSE
 
201
# define YYERROR_VERBOSE 1
 
202
#else
 
203
# define YYERROR_VERBOSE 0
 
204
#endif
 
205
 
 
206
/* Enabling the token table.  */
 
207
#ifndef YYTOKEN_TABLE
 
208
# define YYTOKEN_TABLE 0
 
209
#endif
 
210
 
58
211
 
59
212
/* Tokens.  */
60
213
#ifndef YYTOKENTYPE
158
311
     K_WHILE = 351
159
312
   };
160
313
#endif
161
 
#define IDENT 258
162
 
#define FCONST 259
163
 
#define SCONST 260
164
 
#define BCONST 261
165
 
#define XCONST 262
166
 
#define Op 263
167
 
#define ICONST 264
168
 
#define PARAM 265
169
 
#define TYPECAST 266
170
 
#define DOT_DOT 267
171
 
#define COLON_EQUALS 268
172
 
#define T_WORD 269
173
 
#define T_CWORD 270
174
 
#define T_DATUM 271
175
 
#define LESS_LESS 272
176
 
#define GREATER_GREATER 273
177
 
#define K_ABSOLUTE 274
178
 
#define K_ALIAS 275
179
 
#define K_ALL 276
180
 
#define K_ARRAY 277
181
 
#define K_BACKWARD 278
182
 
#define K_BEGIN 279
183
 
#define K_BY 280
184
 
#define K_CASE 281
185
 
#define K_CLOSE 282
186
 
#define K_COLLATE 283
187
 
#define K_CONSTANT 284
188
 
#define K_CONTINUE 285
189
 
#define K_CURSOR 286
190
 
#define K_DEBUG 287
191
 
#define K_DECLARE 288
192
 
#define K_DEFAULT 289
193
 
#define K_DETAIL 290
194
 
#define K_DIAGNOSTICS 291
195
 
#define K_DUMP 292
196
 
#define K_ELSE 293
197
 
#define K_ELSIF 294
198
 
#define K_END 295
199
 
#define K_ERRCODE 296
200
 
#define K_ERROR 297
201
 
#define K_EXCEPTION 298
202
 
#define K_EXECUTE 299
203
 
#define K_EXIT 300
204
 
#define K_FETCH 301
205
 
#define K_FIRST 302
206
 
#define K_FOR 303
207
 
#define K_FOREACH 304
208
 
#define K_FORWARD 305
209
 
#define K_FROM 306
210
 
#define K_GET 307
211
 
#define K_HINT 308
212
 
#define K_IF 309
213
 
#define K_IN 310
214
 
#define K_INFO 311
215
 
#define K_INSERT 312
216
 
#define K_INTO 313
217
 
#define K_IS 314
218
 
#define K_LAST 315
219
 
#define K_LOG 316
220
 
#define K_LOOP 317
221
 
#define K_MESSAGE 318
222
 
#define K_MOVE 319
223
 
#define K_NEXT 320
224
 
#define K_NO 321
225
 
#define K_NOT 322
226
 
#define K_NOTICE 323
227
 
#define K_NULL 324
228
 
#define K_OPEN 325
229
 
#define K_OPTION 326
230
 
#define K_OR 327
231
 
#define K_PERFORM 328
232
 
#define K_PRIOR 329
233
 
#define K_QUERY 330
234
 
#define K_RAISE 331
235
 
#define K_RELATIVE 332
236
 
#define K_RESULT_OID 333
237
 
#define K_RETURN 334
238
 
#define K_REVERSE 335
239
 
#define K_ROWTYPE 336
240
 
#define K_ROW_COUNT 337
241
 
#define K_SCROLL 338
242
 
#define K_SLICE 339
243
 
#define K_SQLSTATE 340
244
 
#define K_STRICT 341
245
 
#define K_THEN 342
246
 
#define K_TO 343
247
 
#define K_TYPE 344
248
 
#define K_USE_COLUMN 345
249
 
#define K_USE_VARIABLE 346
250
 
#define K_USING 347
251
 
#define K_VARIABLE_CONFLICT 348
252
 
#define K_WARNING 349
253
 
#define K_WHEN 350
254
 
#define K_WHILE 351
255
 
 
256
 
 
257
 
 
258
 
 
259
 
/* Copy the first part of user declarations.  */
260
 
#line 1 "gram.y"
261
 
 
262
 
/*-------------------------------------------------------------------------
263
 
 *
264
 
 * gram.y                               - Parser for the PL/pgSQL procedural language
265
 
 *
266
 
 * Portions Copyright (c) 1996-2011, PostgreSQL Global Development Group
267
 
 * Portions Copyright (c) 1994, Regents of the University of California
268
 
 *
269
 
 *
270
 
 * IDENTIFICATION
271
 
 *        src/pl/plpgsql/src/gram.y
272
 
 *
273
 
 *-------------------------------------------------------------------------
274
 
 */
275
 
 
276
 
#include "plpgsql.h"
277
 
 
278
 
#include "catalog/namespace.h"
279
 
#include "catalog/pg_type.h"
280
 
#include "parser/parser.h"
281
 
#include "parser/parse_type.h"
282
 
#include "parser/scanner.h"
283
 
#include "parser/scansup.h"
284
 
#include "utils/builtins.h"
285
 
 
286
 
 
287
 
/* Location tracking support --- simpler than bison's default */
288
 
#define YYLLOC_DEFAULT(Current, Rhs, N) \
289
 
        do { \
290
 
                if (N) \
291
 
                        (Current) = (Rhs)[1]; \
292
 
                else \
293
 
                        (Current) = (Rhs)[0]; \
294
 
        } while (0)
295
 
 
296
 
/*
297
 
 * Bison doesn't allocate anything that needs to live across parser calls,
298
 
 * so we can easily have it use palloc instead of malloc.  This prevents
299
 
 * memory leaks if we error out during parsing.  Note this only works with
300
 
 * bison >= 2.0.  However, in bison 1.875 the default is to use alloca()
301
 
 * if possible, so there's not really much problem anyhow, at least if
302
 
 * you're building with gcc.
303
 
 */
304
 
#define YYMALLOC palloc
305
 
#define YYFREE   pfree
306
 
 
307
 
 
308
 
typedef struct
 
314
 
 
315
 
 
316
 
 
317
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 
318
typedef union YYSTYPE
309
319
{
310
 
        int                     location;
311
 
        int                     leaderlen;
312
 
} sql_error_callback_arg;
313
 
 
314
 
#define parser_errposition(pos)  plpgsql_scanner_errposition(pos)
315
 
 
316
 
union YYSTYPE;                                  /* need forward reference for tok_is_keyword */
317
 
 
318
 
static  bool                    tok_is_keyword(int token, union YYSTYPE *lval,
319
 
                                                                           int kw_token, const char *kw_str);
320
 
static  void                    word_is_not_variable(PLword *word, int location);
321
 
static  void                    cword_is_not_variable(PLcword *cword, int location);
322
 
static  void                    current_token_is_not_variable(int tok);
323
 
static  PLpgSQL_expr    *read_sql_construct(int until,
324
 
                                                                                        int until2,
325
 
                                                                                        int until3,
326
 
                                                                                        const char *expected,
327
 
                                                                                        const char *sqlstart,
328
 
                                                                                        bool isexpression,
329
 
                                                                                        bool valid_sql,
330
 
                                                                                        int *startloc,
331
 
                                                                                        int *endtoken);
332
 
static  PLpgSQL_expr    *read_sql_expression(int until,
333
 
                                                                                         const char *expected);
334
 
static  PLpgSQL_expr    *read_sql_expression2(int until, int until2,
335
 
                                                                                          const char *expected,
336
 
                                                                                          int *endtoken);
337
 
static  PLpgSQL_expr    *read_sql_stmt(const char *sqlstart);
338
 
static  PLpgSQL_type    *read_datatype(int tok);
339
 
static  PLpgSQL_stmt    *make_execsql_stmt(int firsttoken, int location);
340
 
static  PLpgSQL_stmt_fetch *read_fetch_direction(void);
341
 
static  void                     complete_direction(PLpgSQL_stmt_fetch *fetch,
342
 
                                                                                        bool *check_FROM);
343
 
static  PLpgSQL_stmt    *make_return_stmt(int location);
344
 
static  PLpgSQL_stmt    *make_return_next_stmt(int location);
345
 
static  PLpgSQL_stmt    *make_return_query_stmt(int location);
346
 
static  PLpgSQL_stmt    *make_case(int location, PLpgSQL_expr *t_expr,
347
 
                                                                   List *case_when_list, List *else_stmts);
348
 
static  char                    *NameOfDatum(PLwdatum *wdatum);
349
 
static  void                     check_assignable(PLpgSQL_datum *datum, int location);
350
 
static  void                     read_into_target(PLpgSQL_rec **rec, PLpgSQL_row **row,
351
 
                                                                                  bool *strict);
352
 
static  PLpgSQL_row             *read_into_scalar_list(char *initial_name,
353
 
                                                                                           PLpgSQL_datum *initial_datum,
354
 
                                                                                           int initial_location);
355
 
static  PLpgSQL_row             *make_scalar_list1(char *initial_name,
356
 
                                                                                   PLpgSQL_datum *initial_datum,
357
 
                                                                                   int lineno, int location);
358
 
static  void                     check_sql_expr(const char *stmt, int location,
359
 
                                                                                int leaderlen);
360
 
static  void                     plpgsql_sql_error_callback(void *arg);
361
 
static  PLpgSQL_type    *parse_datatype(const char *string, int location);
362
 
static  void                     check_labels(const char *start_label,
363
 
                                                                          const char *end_label,
364
 
                                                                          int end_location);
365
 
static  PLpgSQL_expr    *read_cursor_args(PLpgSQL_var *cursor,
366
 
                                                                                  int until, const char *expected);
367
 
static  List                    *read_raise_options(void);
368
 
 
369
 
 
370
 
 
371
 
/* Enabling traces.  */
372
 
#ifndef YYDEBUG
373
 
# define YYDEBUG 0
374
 
#endif
375
 
 
376
 
/* Enabling verbose error messages.  */
377
 
#ifdef YYERROR_VERBOSE
378
 
# undef YYERROR_VERBOSE
379
 
# define YYERROR_VERBOSE 1
380
 
#else
381
 
# define YYERROR_VERBOSE 0
382
 
#endif
383
 
 
384
 
#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
 
320
 
 
321
/* Line 214 of yacc.c  */
385
322
#line 115 "gram.y"
386
 
typedef union YYSTYPE {
 
323
 
387
324
                core_YYSTYPE                    core_yystype;
388
325
                /* these fields must match core_YYSTYPE: */
389
326
                int                                             ival;
433
370
                PLpgSQL_diag_item               *diagitem;
434
371
                PLpgSQL_stmt_fetch              *fetch;
435
372
                PLpgSQL_case_when               *casewhen;
 
373
 
 
374
 
 
375
 
 
376
/* Line 214 of yacc.c  */
 
377
#line 378 "pl_gram.c"
436
378
} YYSTYPE;
437
 
/* Line 186 of yacc.c.  */
438
 
#line 438 "pl_gram.c"
 
379
# define YYSTYPE_IS_TRIVIAL 1
439
380
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
440
381
# define YYSTYPE_IS_DECLARED 1
441
 
# define YYSTYPE_IS_TRIVIAL 1
442
382
#endif
443
383
 
444
 
#if ! defined (YYLTYPE) && ! defined (YYLTYPE_IS_DECLARED)
 
384
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
445
385
typedef struct YYLTYPE
446
386
{
447
387
  int first_line;
458
398
/* Copy the second part of user declarations.  */
459
399
 
460
400
 
461
 
/* Line 214 of yacc.c.  */
462
 
#line 462 "pl_gram.c"
463
 
 
464
 
#if ! defined (yyoverflow) || YYERROR_VERBOSE
 
401
/* Line 264 of yacc.c  */
 
402
#line 403 "pl_gram.c"
 
403
 
 
404
#ifdef short
 
405
# undef short
 
406
#endif
 
407
 
 
408
#ifdef YYTYPE_UINT8
 
409
typedef YYTYPE_UINT8 yytype_uint8;
 
410
#else
 
411
typedef unsigned char yytype_uint8;
 
412
#endif
 
413
 
 
414
#ifdef YYTYPE_INT8
 
415
typedef YYTYPE_INT8 yytype_int8;
 
416
#elif (defined __STDC__ || defined __C99__FUNC__ \
 
417
     || defined __cplusplus || defined _MSC_VER)
 
418
typedef signed char yytype_int8;
 
419
#else
 
420
typedef short int yytype_int8;
 
421
#endif
 
422
 
 
423
#ifdef YYTYPE_UINT16
 
424
typedef YYTYPE_UINT16 yytype_uint16;
 
425
#else
 
426
typedef unsigned short int yytype_uint16;
 
427
#endif
 
428
 
 
429
#ifdef YYTYPE_INT16
 
430
typedef YYTYPE_INT16 yytype_int16;
 
431
#else
 
432
typedef short int yytype_int16;
 
433
#endif
 
434
 
 
435
#ifndef YYSIZE_T
 
436
# ifdef __SIZE_TYPE__
 
437
#  define YYSIZE_T __SIZE_TYPE__
 
438
# elif defined size_t
 
439
#  define YYSIZE_T size_t
 
440
# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
 
441
     || defined __cplusplus || defined _MSC_VER)
 
442
#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
 
443
#  define YYSIZE_T size_t
 
444
# else
 
445
#  define YYSIZE_T unsigned int
 
446
# endif
 
447
#endif
 
448
 
 
449
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
 
450
 
 
451
#ifndef YY_
 
452
# if YYENABLE_NLS
 
453
#  if ENABLE_NLS
 
454
#   include <libintl.h> /* INFRINGES ON USER NAME SPACE */
 
455
#   define YY_(msgid) dgettext ("bison-runtime", msgid)
 
456
#  endif
 
457
# endif
 
458
# ifndef YY_
 
459
#  define YY_(msgid) msgid
 
460
# endif
 
461
#endif
 
462
 
 
463
/* Suppress unused-variable warnings by "using" E.  */
 
464
#if ! defined lint || defined __GNUC__
 
465
# define YYUSE(e) ((void) (e))
 
466
#else
 
467
# define YYUSE(e) /* empty */
 
468
#endif
 
469
 
 
470
/* Identity function, used to suppress warnings about constant conditions.  */
 
471
#ifndef lint
 
472
# define YYID(n) (n)
 
473
#else
 
474
#if (defined __STDC__ || defined __C99__FUNC__ \
 
475
     || defined __cplusplus || defined _MSC_VER)
 
476
static int
 
477
YYID (int yyi)
 
478
#else
 
479
static int
 
480
YYID (yyi)
 
481
    int yyi;
 
482
#endif
 
483
{
 
484
  return yyi;
 
485
}
 
486
#endif
 
487
 
 
488
#if ! defined yyoverflow || YYERROR_VERBOSE
465
489
 
466
490
/* The parser invokes alloca or malloc; define the necessary symbols.  */
467
491
 
468
 
# if YYSTACK_USE_ALLOCA
469
 
#  define YYSTACK_ALLOC alloca
470
 
# else
471
 
#  ifndef YYSTACK_USE_ALLOCA
472
 
#   if defined (alloca) || defined (_ALLOCA_H)
 
492
# ifdef YYSTACK_USE_ALLOCA
 
493
#  if YYSTACK_USE_ALLOCA
 
494
#   ifdef __GNUC__
 
495
#    define YYSTACK_ALLOC __builtin_alloca
 
496
#   elif defined __BUILTIN_VA_ARG_INCR
 
497
#    include <alloca.h> /* INFRINGES ON USER NAME SPACE */
 
498
#   elif defined _AIX
 
499
#    define YYSTACK_ALLOC __alloca
 
500
#   elif defined _MSC_VER
 
501
#    include <malloc.h> /* INFRINGES ON USER NAME SPACE */
 
502
#    define alloca _alloca
 
503
#   else
473
504
#    define YYSTACK_ALLOC alloca
474
 
#   else
475
 
#    ifdef __GNUC__
476
 
#     define YYSTACK_ALLOC __builtin_alloca
 
505
#    if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
 
506
     || defined __cplusplus || defined _MSC_VER)
 
507
#     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
 
508
#     ifndef _STDLIB_H
 
509
#      define _STDLIB_H 1
 
510
#     endif
477
511
#    endif
478
512
#   endif
479
513
#  endif
480
514
# endif
481
515
 
482
516
# ifdef YYSTACK_ALLOC
483
 
   /* Pacify GCC's `empty if-body' warning. */
484
 
#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
 
517
   /* Pacify GCC's `empty if-body' warning.  */
 
518
#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
 
519
#  ifndef YYSTACK_ALLOC_MAXIMUM
 
520
    /* The OS might guarantee only one guard page at the bottom of the stack,
 
521
       and a page size can be as small as 4096 bytes.  So we cannot safely
 
522
       invoke alloca (N) if N exceeds 4096.  Use a slightly smaller number
 
523
       to allow for a few compiler-allocated temporary stack slots.  */
 
524
#   define YYSTACK_ALLOC_MAXIMUM 4032 /* reasonable circa 2006 */
 
525
#  endif
485
526
# else
486
 
#  if defined (__STDC__) || defined (__cplusplus)
 
527
#  define YYSTACK_ALLOC YYMALLOC
 
528
#  define YYSTACK_FREE YYFREE
 
529
#  ifndef YYSTACK_ALLOC_MAXIMUM
 
530
#   define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
 
531
#  endif
 
532
#  if (defined __cplusplus && ! defined _STDLIB_H \
 
533
       && ! ((defined YYMALLOC || defined malloc) \
 
534
             && (defined YYFREE || defined free)))
487
535
#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
488
 
#   define YYSIZE_T size_t
489
 
#  endif
490
 
#  define YYSTACK_ALLOC malloc
491
 
#  define YYSTACK_FREE free
 
536
#   ifndef _STDLIB_H
 
537
#    define _STDLIB_H 1
 
538
#   endif
 
539
#  endif
 
540
#  ifndef YYMALLOC
 
541
#   define YYMALLOC malloc
 
542
#   if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
 
543
     || defined __cplusplus || defined _MSC_VER)
 
544
void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
 
545
#   endif
 
546
#  endif
 
547
#  ifndef YYFREE
 
548
#   define YYFREE free
 
549
#   if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
 
550
     || defined __cplusplus || defined _MSC_VER)
 
551
void free (void *); /* INFRINGES ON USER NAME SPACE */
 
552
#   endif
 
553
#  endif
492
554
# endif
493
 
#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
494
 
 
495
 
 
496
 
#if (! defined (yyoverflow) \
497
 
     && (! defined (__cplusplus) \
498
 
         || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
 
555
#endif /* ! defined yyoverflow || YYERROR_VERBOSE */
 
556
 
 
557
 
 
558
#if (! defined yyoverflow \
 
559
     && (! defined __cplusplus \
 
560
         || (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
 
561
             && defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
499
562
 
500
563
/* A type that is properly aligned for any stack member.  */
501
564
union yyalloc
502
565
{
503
 
  short yyss;
504
 
  YYSTYPE yyvs;
505
 
    YYLTYPE yyls;
 
566
  yytype_int16 yyss_alloc;
 
567
  YYSTYPE yyvs_alloc;
 
568
  YYLTYPE yyls_alloc;
506
569
};
507
570
 
508
571
/* The size of the maximum gap between one aligned stack and the next.  */
511
574
/* The size of an array large to enough to hold all stacks, each with
512
575
   N elements.  */
513
576
# define YYSTACK_BYTES(N) \
514
 
     ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE))      \
 
577
     ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
515
578
      + 2 * YYSTACK_GAP_MAXIMUM)
516
579
 
517
580
/* Copy COUNT objects from FROM to TO.  The source and destination do
518
581
   not overlap.  */
519
582
# ifndef YYCOPY
520
 
#  if 1 < __GNUC__
 
583
#  if defined __GNUC__ && 1 < __GNUC__
521
584
#   define YYCOPY(To, From, Count) \
522
585
      __builtin_memcpy (To, From, (Count) * sizeof (*(From)))
523
586
#  else
524
587
#   define YYCOPY(To, From, Count)              \
525
588
      do                                        \
526
589
        {                                       \
527
 
          register YYSIZE_T yyi;                \
 
590
          YYSIZE_T yyi;                         \
528
591
          for (yyi = 0; yyi < (Count); yyi++)   \
529
592
            (To)[yyi] = (From)[yyi];            \
530
593
        }                                       \
531
 
      while (0)
 
594
      while (YYID (0))
532
595
#  endif
533
596
# endif
534
597
 
537
600
   elements in the stack, and YYPTR gives the new location of the
538
601
   stack.  Advance YYPTR to a properly aligned location for the next
539
602
   stack.  */
540
 
# define YYSTACK_RELOCATE(Stack)                                        \
 
603
# define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
541
604
    do                                                                  \
542
605
      {                                                                 \
543
606
        YYSIZE_T yynewbytes;                                            \
544
 
        YYCOPY (&yyptr->Stack, Stack, yysize);                          \
545
 
        Stack = &yyptr->Stack;                                          \
 
607
        YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
 
608
        Stack = &yyptr->Stack_alloc;                                    \
546
609
        yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
547
610
        yyptr += yynewbytes / sizeof (*yyptr);                          \
548
611
      }                                                                 \
549
 
    while (0)
550
 
 
551
 
#endif
552
 
 
553
 
#if defined (__STDC__) || defined (__cplusplus)
554
 
   typedef signed char yysigned_char;
555
 
#else
556
 
   typedef short yysigned_char;
557
 
#endif
558
 
 
559
 
/* YYFINAL -- State number of the termination state. */
 
612
    while (YYID (0))
 
613
 
 
614
#endif
 
615
 
 
616
/* YYFINAL -- State number of the termination state.  */
560
617
#define YYFINAL  3
561
618
/* YYLAST -- Last index in YYTABLE.  */
562
619
#define YYLAST   550
563
620
 
564
 
/* YYNTOKENS -- Number of terminals. */
 
621
/* YYNTOKENS -- Number of terminals.  */
565
622
#define YYNTOKENS  104
566
 
/* YYNNTS -- Number of nonterminals. */
 
623
/* YYNNTS -- Number of nonterminals.  */
567
624
#define YYNNTS  81
568
 
/* YYNRULES -- Number of rules. */
 
625
/* YYNRULES -- Number of rules.  */
569
626
#define YYNRULES  188
570
 
/* YYNRULES -- Number of states. */
 
627
/* YYNRULES -- Number of states.  */
571
628
#define YYNSTATES  266
572
629
 
573
630
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
574
631
#define YYUNDEFTOK  2
575
632
#define YYMAXUTOK   351
576
633
 
577
 
#define YYTRANSLATE(YYX)                                                \
 
634
#define YYTRANSLATE(YYX)                                                \
578
635
  ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
579
636
 
580
637
/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
581
 
static const unsigned char yytranslate[] =
 
638
static const yytype_uint8 yytranslate[] =
582
639
{
583
640
       0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
584
641
       2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
621
678
#if YYDEBUG
622
679
/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
623
680
   YYRHS.  */
624
 
static const unsigned short yyprhs[] =
 
681
static const yytype_uint16 yyprhs[] =
625
682
{
626
683
       0,     0,     3,     7,     8,    11,    15,    19,    23,    27,
627
684
      28,    30,    37,    39,    42,    46,    48,    51,    53,    55,
644
701
     458,   460,   462,   464,   466,   468,   470,   472,   474
645
702
};
646
703
 
647
 
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
648
 
static const short yyrhs[] =
 
704
/* YYRHS -- A `-1'-separated list of the rules' RHS.  */
 
705
static const yytype_int16 yyrhs[] =
649
706
{
650
707
     105,     0,    -1,   106,   109,   108,    -1,    -1,   106,   107,
651
708
      -1,    97,    71,    37,    -1,    97,    93,    42,    -1,    97,
698
755
};
699
756
 
700
757
/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
701
 
static const unsigned short yyrline[] =
 
758
static const yytype_uint16 yyrline[] =
702
759
{
703
760
       0,   323,   323,   329,   330,   333,   337,   341,   345,   351,
704
761
     352,   355,   377,   385,   392,   401,   413,   414,   417,   418,
722
779
};
723
780
#endif
724
781
 
725
 
#if YYDEBUG || YYERROR_VERBOSE
726
 
/* YYTNME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
727
 
   First, the terminals, then, starting at YYNTOKENS, nonterminals. */
 
782
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
 
783
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
 
784
   First, the terminals, then, starting at YYNTOKENS, nonterminals.  */
728
785
static const char *const yytname[] =
729
786
{
730
 
  "$end", "error", "$undefined", "IDENT", "FCONST", "SCONST", "BCONST", 
731
 
  "XCONST", "Op", "ICONST", "PARAM", "TYPECAST", "DOT_DOT", 
732
 
  "COLON_EQUALS", "T_WORD", "T_CWORD", "T_DATUM", "LESS_LESS", 
733
 
  "GREATER_GREATER", "K_ABSOLUTE", "K_ALIAS", "K_ALL", "K_ARRAY", 
734
 
  "K_BACKWARD", "K_BEGIN", "K_BY", "K_CASE", "K_CLOSE", "K_COLLATE", 
735
 
  "K_CONSTANT", "K_CONTINUE", "K_CURSOR", "K_DEBUG", "K_DECLARE", 
736
 
  "K_DEFAULT", "K_DETAIL", "K_DIAGNOSTICS", "K_DUMP", "K_ELSE", "K_ELSIF", 
737
 
  "K_END", "K_ERRCODE", "K_ERROR", "K_EXCEPTION", "K_EXECUTE", "K_EXIT", 
738
 
  "K_FETCH", "K_FIRST", "K_FOR", "K_FOREACH", "K_FORWARD", "K_FROM", 
739
 
  "K_GET", "K_HINT", "K_IF", "K_IN", "K_INFO", "K_INSERT", "K_INTO", 
740
 
  "K_IS", "K_LAST", "K_LOG", "K_LOOP", "K_MESSAGE", "K_MOVE", "K_NEXT", 
741
 
  "K_NO", "K_NOT", "K_NOTICE", "K_NULL", "K_OPEN", "K_OPTION", "K_OR", 
742
 
  "K_PERFORM", "K_PRIOR", "K_QUERY", "K_RAISE", "K_RELATIVE", 
743
 
  "K_RESULT_OID", "K_RETURN", "K_REVERSE", "K_ROWTYPE", "K_ROW_COUNT", 
744
 
  "K_SCROLL", "K_SLICE", "K_SQLSTATE", "K_STRICT", "K_THEN", "K_TO", 
745
 
  "K_TYPE", "K_USE_COLUMN", "K_USE_VARIABLE", "K_USING", 
746
 
  "K_VARIABLE_CONFLICT", "K_WARNING", "K_WHEN", "K_WHILE", "'#'", "';'", 
747
 
  "'('", "')'", "','", "'='", "'['", "$accept", "pl_function", 
748
 
  "comp_options", "comp_option", "opt_semi", "pl_block", "decl_sect", 
749
 
  "decl_start", "decl_stmts", "decl_stmt", "decl_statement", "@1", 
750
 
  "opt_scrollable", "decl_cursor_query", "decl_cursor_args", 
751
 
  "decl_cursor_arglist", "decl_cursor_arg", "decl_is_for", 
752
 
  "decl_aliasitem", "decl_varname", "decl_const", "decl_datatype", 
753
 
  "decl_collate", "decl_notnull", "decl_defval", "decl_defkey", 
754
 
  "assign_operator", "proc_sect", "proc_stmts", "proc_stmt", 
755
 
  "stmt_perform", "stmt_assign", "stmt_getdiag", "getdiag_list", 
756
 
  "getdiag_list_item", "getdiag_item", "getdiag_target", "assign_var", 
757
 
  "stmt_if", "stmt_else", "stmt_case", "opt_expr_until_when", 
758
 
  "case_when_list", "case_when", "opt_case_else", "stmt_loop", 
759
 
  "stmt_while", "stmt_for", "for_control", "for_variable", 
760
 
  "stmt_foreach_a", "foreach_slice", "stmt_exit", "exit_type", 
761
 
  "stmt_return", "stmt_raise", "loop_body", "stmt_execsql", 
762
 
  "stmt_dynexecute", "stmt_open", "stmt_fetch", "stmt_move", 
763
 
  "opt_fetch_direction", "stmt_close", "stmt_null", "cursor_variable", 
764
 
  "exception_sect", "@2", "proc_exceptions", "proc_exception", 
765
 
  "proc_conditions", "proc_condition", "expr_until_semi", 
766
 
  "expr_until_rightbracket", "expr_until_then", "expr_until_loop", 
767
 
  "opt_block_label", "opt_label", "opt_exitcond", "any_identifier", 
 
787
  "$end", "error", "$undefined", "IDENT", "FCONST", "SCONST", "BCONST",
 
788
  "XCONST", "Op", "ICONST", "PARAM", "TYPECAST", "DOT_DOT", "COLON_EQUALS",
 
789
  "T_WORD", "T_CWORD", "T_DATUM", "LESS_LESS", "GREATER_GREATER",
 
790
  "K_ABSOLUTE", "K_ALIAS", "K_ALL", "K_ARRAY", "K_BACKWARD", "K_BEGIN",
 
791
  "K_BY", "K_CASE", "K_CLOSE", "K_COLLATE", "K_CONSTANT", "K_CONTINUE",
 
792
  "K_CURSOR", "K_DEBUG", "K_DECLARE", "K_DEFAULT", "K_DETAIL",
 
793
  "K_DIAGNOSTICS", "K_DUMP", "K_ELSE", "K_ELSIF", "K_END", "K_ERRCODE",
 
794
  "K_ERROR", "K_EXCEPTION", "K_EXECUTE", "K_EXIT", "K_FETCH", "K_FIRST",
 
795
  "K_FOR", "K_FOREACH", "K_FORWARD", "K_FROM", "K_GET", "K_HINT", "K_IF",
 
796
  "K_IN", "K_INFO", "K_INSERT", "K_INTO", "K_IS", "K_LAST", "K_LOG",
 
797
  "K_LOOP", "K_MESSAGE", "K_MOVE", "K_NEXT", "K_NO", "K_NOT", "K_NOTICE",
 
798
  "K_NULL", "K_OPEN", "K_OPTION", "K_OR", "K_PERFORM", "K_PRIOR",
 
799
  "K_QUERY", "K_RAISE", "K_RELATIVE", "K_RESULT_OID", "K_RETURN",
 
800
  "K_REVERSE", "K_ROWTYPE", "K_ROW_COUNT", "K_SCROLL", "K_SLICE",
 
801
  "K_SQLSTATE", "K_STRICT", "K_THEN", "K_TO", "K_TYPE", "K_USE_COLUMN",
 
802
  "K_USE_VARIABLE", "K_USING", "K_VARIABLE_CONFLICT", "K_WARNING",
 
803
  "K_WHEN", "K_WHILE", "'#'", "';'", "'('", "')'", "','", "'='", "'['",
 
804
  "$accept", "pl_function", "comp_options", "comp_option", "opt_semi",
 
805
  "pl_block", "decl_sect", "decl_start", "decl_stmts", "decl_stmt",
 
806
  "decl_statement", "$@1", "opt_scrollable", "decl_cursor_query",
 
807
  "decl_cursor_args", "decl_cursor_arglist", "decl_cursor_arg",
 
808
  "decl_is_for", "decl_aliasitem", "decl_varname", "decl_const",
 
809
  "decl_datatype", "decl_collate", "decl_notnull", "decl_defval",
 
810
  "decl_defkey", "assign_operator", "proc_sect", "proc_stmts", "proc_stmt",
 
811
  "stmt_perform", "stmt_assign", "stmt_getdiag", "getdiag_list",
 
812
  "getdiag_list_item", "getdiag_item", "getdiag_target", "assign_var",
 
813
  "stmt_if", "stmt_else", "stmt_case", "opt_expr_until_when",
 
814
  "case_when_list", "case_when", "opt_case_else", "stmt_loop",
 
815
  "stmt_while", "stmt_for", "for_control", "for_variable",
 
816
  "stmt_foreach_a", "foreach_slice", "stmt_exit", "exit_type",
 
817
  "stmt_return", "stmt_raise", "loop_body", "stmt_execsql",
 
818
  "stmt_dynexecute", "stmt_open", "stmt_fetch", "stmt_move",
 
819
  "opt_fetch_direction", "stmt_close", "stmt_null", "cursor_variable",
 
820
  "exception_sect", "@2", "proc_exceptions", "proc_exception",
 
821
  "proc_conditions", "proc_condition", "expr_until_semi",
 
822
  "expr_until_rightbracket", "expr_until_then", "expr_until_loop",
 
823
  "opt_block_label", "opt_label", "opt_exitcond", "any_identifier",
768
824
  "unreserved_keyword", 0
769
825
};
770
826
#endif
772
828
# ifdef YYPRINT
773
829
/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
774
830
   token YYLEX-NUM.  */
775
 
static const unsigned short yytoknum[] =
 
831
static const yytype_uint16 yytoknum[] =
776
832
{
777
833
       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
778
834
     265,   266,   267,   268,   269,   270,   271,   272,   273,   274,
789
845
# endif
790
846
 
791
847
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
792
 
static const unsigned char yyr1[] =
 
848
static const yytype_uint8 yyr1[] =
793
849
{
794
850
       0,   104,   105,   106,   106,   107,   107,   107,   107,   108,
795
851
     108,   109,   110,   110,   110,   111,   112,   112,   113,   113,
813
869
};
814
870
 
815
871
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
816
 
static const unsigned char yyr2[] =
 
872
static const yytype_uint8 yyr2[] =
817
873
{
818
874
       0,     2,     3,     0,     2,     3,     3,     3,     3,     0,
819
875
       1,     6,     1,     2,     3,     1,     2,     1,     1,     1,
839
895
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
840
896
   STATE-NUM when YYTABLE doesn't specify something else to do.  Zero
841
897
   means the default is an error.  */
842
 
static const unsigned char yydefact[] =
 
898
static const yytype_uint8 yydefact[] =
843
899
{
844
900
       3,     0,   143,     1,     0,     0,     4,     9,     0,    12,
845
901
     149,   150,     0,     0,     0,    10,     2,   143,    15,    13,
870
926
      30,     0,    33,    24,   108,    32
871
927
};
872
928
 
873
 
/* YYDEFGOTO[NTERM-NUM]. */
874
 
static const short yydefgoto[] =
 
929
/* YYDEFGOTO[NTERM-NUM].  */
 
930
static const yytype_int16 yydefgoto[] =
875
931
{
876
932
      -1,     1,     2,     6,    16,    43,     8,    19,   110,   111,
877
933
     112,   209,   147,   263,   229,   241,   242,   246,   208,   113,
887
943
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
888
944
   STATE-NUM.  */
889
945
#define YYPACT_NINF -203
890
 
static const short yypact[] =
 
946
static const yytype_int16 yypact[] =
891
947
{
892
948
    -203,    32,    -7,  -203,    69,   -42,  -203,   -62,    54,    55,
893
949
    -203,  -203,    61,    45,   -34,  -203,  -203,   426,  -203,   222,
919
975
};
920
976
 
921
977
/* YYPGOTO[NTERM-NUM].  */
922
 
static const short yypgoto[] =
 
978
static const yytype_int16 yypgoto[] =
923
979
{
924
980
    -203,  -203,  -203,  -203,  -203,   149,  -203,  -203,  -203,    48,
925
981
    -203,  -203,  -203,  -203,  -203,  -203,  -106,  -203,  -203,  -202,
937
993
   number is the opposite.  If zero, do what YYDEFACT says.
938
994
   If YYTABLE_NINF, syntax error.  */
939
995
#define YYTABLE_NINF -56
940
 
static const short yytable[] =
 
996
static const yytype_int16 yytable[] =
941
997
{
942
998
      12,    44,   131,   125,   131,   131,    18,   190,    22,   200,
943
999
       4,   183,   198,   244,   205,    25,    26,    27,     4,   184,
997
1053
      42
998
1054
};
999
1055
 
1000
 
static const short yycheck[] =
 
1056
static const yytype_int16 yycheck[] =
1001
1057
{
1002
1058
       4,    17,    13,    39,    13,    13,    33,   159,    42,   172,
1003
1059
      17,   149,   163,    48,   177,    14,    15,    16,    17,    38,
1059
1115
 
1060
1116
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
1061
1117
   symbol of state STATE-NUM.  */
1062
 
static const unsigned char yystos[] =
 
1118
static const yytype_uint8 yystos[] =
1063
1119
{
1064
1120
       0,   105,   106,     0,    17,    97,   107,   109,   110,   180,
1065
1121
      14,    16,   183,    71,    93,    98,   108,    24,    33,   111,
1090
1146
     100,   101,   125,   117,   160,   120
1091
1147
};
1092
1148
 
1093
 
#if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
1094
 
# define YYSIZE_T __SIZE_TYPE__
1095
 
#endif
1096
 
#if ! defined (YYSIZE_T) && defined (size_t)
1097
 
# define YYSIZE_T size_t
1098
 
#endif
1099
 
#if ! defined (YYSIZE_T)
1100
 
# if defined (__STDC__) || defined (__cplusplus)
1101
 
#  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
1102
 
#  define YYSIZE_T size_t
1103
 
# endif
1104
 
#endif
1105
 
#if ! defined (YYSIZE_T)
1106
 
# define YYSIZE_T unsigned int
1107
 
#endif
1108
 
 
1109
1149
#define yyerrok         (yyerrstatus = 0)
1110
1150
#define yyclearin       (yychar = YYEMPTY)
1111
1151
#define YYEMPTY         (-2)
1113
1153
 
1114
1154
#define YYACCEPT        goto yyacceptlab
1115
1155
#define YYABORT         goto yyabortlab
1116
 
#define YYERROR         goto yyerrlab1
 
1156
#define YYERROR         goto yyerrorlab
 
1157
 
1117
1158
 
1118
1159
/* Like YYERROR except do call yyerror.  This remains here temporarily
1119
1160
   to ease the transition to the new meaning of YYERROR, for GCC.
1130
1171
      yychar = (Token);                                         \
1131
1172
      yylval = (Value);                                         \
1132
1173
      yytoken = YYTRANSLATE (yychar);                           \
1133
 
      YYPOPSTACK;                                               \
 
1174
      YYPOPSTACK (1);                                           \
1134
1175
      goto yybackup;                                            \
1135
1176
    }                                                           \
1136
1177
  else                                                          \
1137
 
    {                                                           \
1138
 
      yyerror ("syntax error: cannot back up");\
 
1178
    {                                                           \
 
1179
      yyerror (YY_("syntax error: cannot back up")); \
1139
1180
      YYERROR;                                                  \
1140
1181
    }                                                           \
1141
 
while (0)
 
1182
while (YYID (0))
 
1183
 
1142
1184
 
1143
1185
#define YYTERROR        1
1144
1186
#define YYERRCODE       256
1145
1187
 
1146
 
/* YYLLOC_DEFAULT -- Compute the default location (before the actions
1147
 
   are run).  */
1148
 
 
 
1188
 
 
1189
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
 
1190
   If N is 0, then set CURRENT to the empty location which ends
 
1191
   the previous symbol: RHS[0] (always defined).  */
 
1192
 
 
1193
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
1149
1194
#ifndef YYLLOC_DEFAULT
1150
 
# define YYLLOC_DEFAULT(Current, Rhs, N)         \
1151
 
  Current.first_line   = Rhs[1].first_line;      \
1152
 
  Current.first_column = Rhs[1].first_column;    \
1153
 
  Current.last_line    = Rhs[N].last_line;       \
1154
 
  Current.last_column  = Rhs[N].last_column;
1155
 
#endif
 
1195
# define YYLLOC_DEFAULT(Current, Rhs, N)                                \
 
1196
    do                                                                  \
 
1197
      if (YYID (N))                                                    \
 
1198
        {                                                               \
 
1199
          (Current).first_line   = YYRHSLOC (Rhs, 1).first_line;        \
 
1200
          (Current).first_column = YYRHSLOC (Rhs, 1).first_column;      \
 
1201
          (Current).last_line    = YYRHSLOC (Rhs, N).last_line;         \
 
1202
          (Current).last_column  = YYRHSLOC (Rhs, N).last_column;       \
 
1203
        }                                                               \
 
1204
      else                                                              \
 
1205
        {                                                               \
 
1206
          (Current).first_line   = (Current).last_line   =              \
 
1207
            YYRHSLOC (Rhs, 0).last_line;                                \
 
1208
          (Current).first_column = (Current).last_column =              \
 
1209
            YYRHSLOC (Rhs, 0).last_column;                              \
 
1210
        }                                                               \
 
1211
    while (YYID (0))
 
1212
#endif
 
1213
 
 
1214
 
 
1215
/* YY_LOCATION_PRINT -- Print the location on the stream.
 
1216
   This macro was not mandated originally: define only if we know
 
1217
   we won't break user code: when these are the locations we know.  */
 
1218
 
 
1219
#ifndef YY_LOCATION_PRINT
 
1220
# if YYLTYPE_IS_TRIVIAL
 
1221
#  define YY_LOCATION_PRINT(File, Loc)                  \
 
1222
     fprintf (File, "%d.%d-%d.%d",                      \
 
1223
              (Loc).first_line, (Loc).first_column,     \
 
1224
              (Loc).last_line,  (Loc).last_column)
 
1225
# else
 
1226
#  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
 
1227
# endif
 
1228
#endif
 
1229
 
1156
1230
 
1157
1231
/* YYLEX -- calling `yylex' with the right arguments.  */
1158
1232
 
1174
1248
do {                                            \
1175
1249
  if (yydebug)                                  \
1176
1250
    YYFPRINTF Args;                             \
1177
 
} while (0)
1178
 
 
1179
 
# define YYDSYMPRINT(Args)                      \
1180
 
do {                                            \
1181
 
  if (yydebug)                                  \
1182
 
    yysymprint Args;                            \
1183
 
} while (0)
1184
 
 
1185
 
# define YYDSYMPRINTF(Title, Token, Value, Location)            \
1186
 
do {                                                            \
1187
 
  if (yydebug)                                                  \
1188
 
    {                                                           \
1189
 
      YYFPRINTF (stderr, "%s ", Title);                         \
1190
 
      yysymprint (stderr,                                       \
1191
 
                  Token, Value, Location);      \
1192
 
      YYFPRINTF (stderr, "\n");                                 \
1193
 
    }                                                           \
1194
 
} while (0)
 
1251
} while (YYID (0))
 
1252
 
 
1253
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
 
1254
do {                                                                      \
 
1255
  if (yydebug)                                                            \
 
1256
    {                                                                     \
 
1257
      YYFPRINTF (stderr, "%s ", Title);                                   \
 
1258
      yy_symbol_print (stderr,                                            \
 
1259
                  Type, Value, Location); \
 
1260
      YYFPRINTF (stderr, "\n");                                           \
 
1261
    }                                                                     \
 
1262
} while (YYID (0))
 
1263
 
 
1264
 
 
1265
/*--------------------------------.
 
1266
| Print this symbol on YYOUTPUT.  |
 
1267
`--------------------------------*/
 
1268
 
 
1269
/*ARGSUSED*/
 
1270
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1271
     || defined __cplusplus || defined _MSC_VER)
 
1272
static void
 
1273
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
 
1274
#else
 
1275
static void
 
1276
yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp)
 
1277
    FILE *yyoutput;
 
1278
    int yytype;
 
1279
    YYSTYPE const * const yyvaluep;
 
1280
    YYLTYPE const * const yylocationp;
 
1281
#endif
 
1282
{
 
1283
  if (!yyvaluep)
 
1284
    return;
 
1285
  YYUSE (yylocationp);
 
1286
# ifdef YYPRINT
 
1287
  if (yytype < YYNTOKENS)
 
1288
    YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
 
1289
# else
 
1290
  YYUSE (yyoutput);
 
1291
# endif
 
1292
  switch (yytype)
 
1293
    {
 
1294
      default:
 
1295
        break;
 
1296
    }
 
1297
}
 
1298
 
 
1299
 
 
1300
/*--------------------------------.
 
1301
| Print this symbol on YYOUTPUT.  |
 
1302
`--------------------------------*/
 
1303
 
 
1304
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1305
     || defined __cplusplus || defined _MSC_VER)
 
1306
static void
 
1307
yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp)
 
1308
#else
 
1309
static void
 
1310
yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp)
 
1311
    FILE *yyoutput;
 
1312
    int yytype;
 
1313
    YYSTYPE const * const yyvaluep;
 
1314
    YYLTYPE const * const yylocationp;
 
1315
#endif
 
1316
{
 
1317
  if (yytype < YYNTOKENS)
 
1318
    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
 
1319
  else
 
1320
    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
 
1321
 
 
1322
  YY_LOCATION_PRINT (yyoutput, *yylocationp);
 
1323
  YYFPRINTF (yyoutput, ": ");
 
1324
  yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp);
 
1325
  YYFPRINTF (yyoutput, ")");
 
1326
}
1195
1327
 
1196
1328
/*------------------------------------------------------------------.
1197
1329
| yy_stack_print -- Print the state stack from its BOTTOM up to its |
1198
 
| TOP (cinluded).                                                   |
 
1330
| TOP (included).                                                   |
1199
1331
`------------------------------------------------------------------*/
1200
1332
 
1201
 
#if defined (__STDC__) || defined (__cplusplus)
 
1333
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1334
     || defined __cplusplus || defined _MSC_VER)
1202
1335
static void
1203
 
yy_stack_print (short *bottom, short *top)
 
1336
yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
1204
1337
#else
1205
1338
static void
1206
 
yy_stack_print (bottom, top)
1207
 
    short *bottom;
1208
 
    short *top;
 
1339
yy_stack_print (yybottom, yytop)
 
1340
    yytype_int16 *yybottom;
 
1341
    yytype_int16 *yytop;
1209
1342
#endif
1210
1343
{
1211
1344
  YYFPRINTF (stderr, "Stack now");
1212
 
  for (/* Nothing. */; bottom <= top; ++bottom)
1213
 
    YYFPRINTF (stderr, " %d", *bottom);
 
1345
  for (; yybottom <= yytop; yybottom++)
 
1346
    {
 
1347
      int yybot = *yybottom;
 
1348
      YYFPRINTF (stderr, " %d", yybot);
 
1349
    }
1214
1350
  YYFPRINTF (stderr, "\n");
1215
1351
}
1216
1352
 
1218
1354
do {                                                            \
1219
1355
  if (yydebug)                                                  \
1220
1356
    yy_stack_print ((Bottom), (Top));                           \
1221
 
} while (0)
 
1357
} while (YYID (0))
1222
1358
 
1223
1359
 
1224
1360
/*------------------------------------------------.
1225
1361
| Report that the YYRULE is going to be reduced.  |
1226
1362
`------------------------------------------------*/
1227
1363
 
1228
 
#if defined (__STDC__) || defined (__cplusplus)
 
1364
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1365
     || defined __cplusplus || defined _MSC_VER)
1229
1366
static void
1230
 
yy_reduce_print (int yyrule)
 
1367
yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule)
1231
1368
#else
1232
1369
static void
1233
 
yy_reduce_print (yyrule)
 
1370
yy_reduce_print (yyvsp, yylsp, yyrule)
 
1371
    YYSTYPE *yyvsp;
 
1372
    YYLTYPE *yylsp;
1234
1373
    int yyrule;
1235
1374
#endif
1236
1375
{
 
1376
  int yynrhs = yyr2[yyrule];
1237
1377
  int yyi;
1238
 
  unsigned int yylineno = yyrline[yyrule];
1239
 
  YYFPRINTF (stderr, "Reducing stack by rule %d (line %u), ",
1240
 
             yyrule - 1, yylineno);
1241
 
  /* Print the symbols being reduced, and their result.  */
1242
 
  for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++)
1243
 
    YYFPRINTF (stderr, "%s ", yytname [yyrhs[yyi]]);
1244
 
  YYFPRINTF (stderr, "-> %s\n", yytname [yyr1[yyrule]]);
 
1378
  unsigned long int yylno = yyrline[yyrule];
 
1379
  YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
 
1380
             yyrule - 1, yylno);
 
1381
  /* The symbols being reduced.  */
 
1382
  for (yyi = 0; yyi < yynrhs; yyi++)
 
1383
    {
 
1384
      YYFPRINTF (stderr, "   $%d = ", yyi + 1);
 
1385
      yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
 
1386
                       &(yyvsp[(yyi + 1) - (yynrhs)])
 
1387
                       , &(yylsp[(yyi + 1) - (yynrhs)])                );
 
1388
      YYFPRINTF (stderr, "\n");
 
1389
    }
1245
1390
}
1246
1391
 
1247
1392
# define YY_REDUCE_PRINT(Rule)          \
1248
1393
do {                                    \
1249
1394
  if (yydebug)                          \
1250
 
    yy_reduce_print (Rule);             \
1251
 
} while (0)
 
1395
    yy_reduce_print (yyvsp, yylsp, Rule); \
 
1396
} while (YYID (0))
1252
1397
 
1253
1398
/* Nonzero means print parse trace.  It is left uninitialized so that
1254
1399
   multiple parsers can coexist.  */
1255
1400
int yydebug;
1256
1401
#else /* !YYDEBUG */
1257
1402
# define YYDPRINTF(Args)
1258
 
# define YYDSYMPRINT(Args)
1259
 
# define YYDSYMPRINTF(Title, Token, Value, Location)
 
1403
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
1260
1404
# define YY_STACK_PRINT(Bottom, Top)
1261
1405
# define YY_REDUCE_PRINT(Rule)
1262
1406
#endif /* !YYDEBUG */
1271
1415
   if the built-in stack extension method is used).
1272
1416
 
1273
1417
   Do not make this value too large; the results are undefined if
1274
 
   SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
 
1418
   YYSTACK_ALLOC_MAXIMUM < YYSTACK_BYTES (YYMAXDEPTH)
1275
1419
   evaluated with infinite-precision integer arithmetic.  */
1276
1420
 
1277
 
#if YYMAXDEPTH == 0
1278
 
# undef YYMAXDEPTH
1279
 
#endif
1280
 
 
1281
1421
#ifndef YYMAXDEPTH
1282
1422
# define YYMAXDEPTH 10000
1283
1423
#endif
1287
1427
#if YYERROR_VERBOSE
1288
1428
 
1289
1429
# ifndef yystrlen
1290
 
#  if defined (__GLIBC__) && defined (_STRING_H)
 
1430
#  if defined __GLIBC__ && defined _STRING_H
1291
1431
#   define yystrlen strlen
1292
1432
#  else
1293
1433
/* Return the length of YYSTR.  */
 
1434
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1435
     || defined __cplusplus || defined _MSC_VER)
1294
1436
static YYSIZE_T
1295
 
#   if defined (__STDC__) || defined (__cplusplus)
1296
1437
yystrlen (const char *yystr)
1297
 
#   else
 
1438
#else
 
1439
static YYSIZE_T
1298
1440
yystrlen (yystr)
1299
 
     const char *yystr;
1300
 
#   endif
 
1441
    const char *yystr;
 
1442
#endif
1301
1443
{
1302
 
  register const char *yys = yystr;
1303
 
 
1304
 
  while (*yys++ != '\0')
 
1444
  YYSIZE_T yylen;
 
1445
  for (yylen = 0; yystr[yylen]; yylen++)
1305
1446
    continue;
1306
 
 
1307
 
  return yys - yystr - 1;
 
1447
  return yylen;
1308
1448
}
1309
1449
#  endif
1310
1450
# endif
1311
1451
 
1312
1452
# ifndef yystpcpy
1313
 
#  if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
 
1453
#  if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
1314
1454
#   define yystpcpy stpcpy
1315
1455
#  else
1316
1456
/* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
1317
1457
   YYDEST.  */
 
1458
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1459
     || defined __cplusplus || defined _MSC_VER)
1318
1460
static char *
1319
 
#   if defined (__STDC__) || defined (__cplusplus)
1320
1461
yystpcpy (char *yydest, const char *yysrc)
1321
 
#   else
 
1462
#else
 
1463
static char *
1322
1464
yystpcpy (yydest, yysrc)
1323
 
     char *yydest;
1324
 
     const char *yysrc;
1325
 
#   endif
 
1465
    char *yydest;
 
1466
    const char *yysrc;
 
1467
#endif
1326
1468
{
1327
 
  register char *yyd = yydest;
1328
 
  register const char *yys = yysrc;
 
1469
  char *yyd = yydest;
 
1470
  const char *yys = yysrc;
1329
1471
 
1330
1472
  while ((*yyd++ = *yys++) != '\0')
1331
1473
    continue;
1335
1477
#  endif
1336
1478
# endif
1337
1479
 
1338
 
#endif /* !YYERROR_VERBOSE */
1339
 
 
 
1480
# ifndef yytnamerr
 
1481
/* Copy to YYRES the contents of YYSTR after stripping away unnecessary
 
1482
   quotes and backslashes, so that it's suitable for yyerror.  The
 
1483
   heuristic is that double-quoting is unnecessary unless the string
 
1484
   contains an apostrophe, a comma, or backslash (other than
 
1485
   backslash-backslash).  YYSTR is taken from yytname.  If YYRES is
 
1486
   null, do not copy; instead, return the length of what the result
 
1487
   would have been.  */
 
1488
static YYSIZE_T
 
1489
yytnamerr (char *yyres, const char *yystr)
 
1490
{
 
1491
  if (*yystr == '"')
 
1492
    {
 
1493
      YYSIZE_T yyn = 0;
 
1494
      char const *yyp = yystr;
 
1495
 
 
1496
      for (;;)
 
1497
        switch (*++yyp)
 
1498
          {
 
1499
          case '\'':
 
1500
          case ',':
 
1501
            goto do_not_strip_quotes;
 
1502
 
 
1503
          case '\\':
 
1504
            if (*++yyp != '\\')
 
1505
              goto do_not_strip_quotes;
 
1506
            /* Fall through.  */
 
1507
          default:
 
1508
            if (yyres)
 
1509
              yyres[yyn] = *yyp;
 
1510
            yyn++;
 
1511
            break;
 
1512
 
 
1513
          case '"':
 
1514
            if (yyres)
 
1515
              yyres[yyn] = '\0';
 
1516
            return yyn;
 
1517
          }
 
1518
    do_not_strip_quotes: ;
 
1519
    }
 
1520
 
 
1521
  if (! yyres)
 
1522
    return yystrlen (yystr);
 
1523
 
 
1524
  return yystpcpy (yyres, yystr) - yyres;
 
1525
}
 
1526
# endif
 
1527
 
 
1528
/* Copy into YYRESULT an error message about the unexpected token
 
1529
   YYCHAR while in state YYSTATE.  Return the number of bytes copied,
 
1530
   including the terminating null byte.  If YYRESULT is null, do not
 
1531
   copy anything; just return the number of bytes that would be
 
1532
   copied.  As a special case, return 0 if an ordinary "syntax error"
 
1533
   message will do.  Return YYSIZE_MAXIMUM if overflow occurs during
 
1534
   size calculation.  */
 
1535
static YYSIZE_T
 
1536
yysyntax_error (char *yyresult, int yystate, int yychar)
 
1537
{
 
1538
  int yyn = yypact[yystate];
 
1539
 
 
1540
  if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
 
1541
    return 0;
 
1542
  else
 
1543
    {
 
1544
      int yytype = YYTRANSLATE (yychar);
 
1545
      YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
 
1546
      YYSIZE_T yysize = yysize0;
 
1547
      YYSIZE_T yysize1;
 
1548
      int yysize_overflow = 0;
 
1549
      enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
 
1550
      char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
 
1551
      int yyx;
 
1552
 
 
1553
# if 0
 
1554
      /* This is so xgettext sees the translatable formats that are
 
1555
         constructed on the fly.  */
 
1556
      YY_("syntax error, unexpected %s");
 
1557
      YY_("syntax error, unexpected %s, expecting %s");
 
1558
      YY_("syntax error, unexpected %s, expecting %s or %s");
 
1559
      YY_("syntax error, unexpected %s, expecting %s or %s or %s");
 
1560
      YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
 
1561
# endif
 
1562
      char *yyfmt;
 
1563
      char const *yyf;
 
1564
      static char const yyunexpected[] = "syntax error, unexpected %s";
 
1565
      static char const yyexpecting[] = ", expecting %s";
 
1566
      static char const yyor[] = " or %s";
 
1567
      char yyformat[sizeof yyunexpected
 
1568
                    + sizeof yyexpecting - 1
 
1569
                    + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
 
1570
                       * (sizeof yyor - 1))];
 
1571
      char const *yyprefix = yyexpecting;
 
1572
 
 
1573
      /* Start YYX at -YYN if negative to avoid negative indexes in
 
1574
         YYCHECK.  */
 
1575
      int yyxbegin = yyn < 0 ? -yyn : 0;
 
1576
 
 
1577
      /* Stay within bounds of both yycheck and yytname.  */
 
1578
      int yychecklim = YYLAST - yyn + 1;
 
1579
      int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
 
1580
      int yycount = 1;
 
1581
 
 
1582
      yyarg[0] = yytname[yytype];
 
1583
      yyfmt = yystpcpy (yyformat, yyunexpected);
 
1584
 
 
1585
      for (yyx = yyxbegin; yyx < yyxend; ++yyx)
 
1586
        if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
 
1587
          {
 
1588
            if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
 
1589
              {
 
1590
                yycount = 1;
 
1591
                yysize = yysize0;
 
1592
                yyformat[sizeof yyunexpected - 1] = '\0';
 
1593
                break;
 
1594
              }
 
1595
            yyarg[yycount++] = yytname[yyx];
 
1596
            yysize1 = yysize + yytnamerr (0, yytname[yyx]);
 
1597
            yysize_overflow |= (yysize1 < yysize);
 
1598
            yysize = yysize1;
 
1599
            yyfmt = yystpcpy (yyfmt, yyprefix);
 
1600
            yyprefix = yyor;
 
1601
          }
 
1602
 
 
1603
      yyf = YY_(yyformat);
 
1604
      yysize1 = yysize + yystrlen (yyf);
 
1605
      yysize_overflow |= (yysize1 < yysize);
 
1606
      yysize = yysize1;
 
1607
 
 
1608
      if (yysize_overflow)
 
1609
        return YYSIZE_MAXIMUM;
 
1610
 
 
1611
      if (yyresult)
 
1612
        {
 
1613
          /* Avoid sprintf, as that infringes on the user's name space.
 
1614
             Don't have undefined behavior even if the translation
 
1615
             produced a string with the wrong number of "%s"s.  */
 
1616
          char *yyp = yyresult;
 
1617
          int yyi = 0;
 
1618
          while ((*yyp = *yyf) != '\0')
 
1619
            {
 
1620
              if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
 
1621
                {
 
1622
                  yyp += yytnamerr (yyp, yyarg[yyi++]);
 
1623
                  yyf += 2;
 
1624
                }
 
1625
              else
 
1626
                {
 
1627
                  yyp++;
 
1628
                  yyf++;
 
1629
                }
 
1630
            }
 
1631
        }
 
1632
      return yysize;
 
1633
    }
 
1634
}
 
1635
#endif /* YYERROR_VERBOSE */
1340
1636
 
1341
1637
 
1342
 
#if YYDEBUG
1343
 
/*--------------------------------.
1344
 
| Print this symbol on YYOUTPUT.  |
1345
 
`--------------------------------*/
1346
 
 
1347
 
#if defined (__STDC__) || defined (__cplusplus)
1348
 
static void
1349
 
yysymprint (FILE *yyoutput, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
1350
 
#else
1351
 
static void
1352
 
yysymprint (yyoutput, yytype, yyvaluep, yylocationp)
1353
 
    FILE *yyoutput;
1354
 
    int yytype;
1355
 
    YYSTYPE *yyvaluep;
1356
 
    YYLTYPE *yylocationp;
1357
 
#endif
1358
 
{
1359
 
  /* Pacify ``unused variable'' warnings.  */
1360
 
  (void) yyvaluep;
1361
 
  (void) yylocationp;
1362
 
 
1363
 
  if (yytype < YYNTOKENS)
1364
 
    {
1365
 
      YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
1366
 
# ifdef YYPRINT
1367
 
      YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
1368
 
# endif
1369
 
    }
1370
 
  else
1371
 
    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
1372
 
 
1373
 
  switch (yytype)
1374
 
    {
1375
 
      default:
1376
 
        break;
1377
 
    }
1378
 
  YYFPRINTF (yyoutput, ")");
1379
 
}
1380
 
 
1381
 
#endif /* ! YYDEBUG */
1382
1638
/*-----------------------------------------------.
1383
1639
| Release the memory associated to this symbol.  |
1384
1640
`-----------------------------------------------*/
1385
1641
 
1386
 
#if defined (__STDC__) || defined (__cplusplus)
 
1642
/*ARGSUSED*/
 
1643
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1644
     || defined __cplusplus || defined _MSC_VER)
1387
1645
static void
1388
 
yydestruct (int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
 
1646
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp)
1389
1647
#else
1390
1648
static void
1391
 
yydestruct (yytype, yyvaluep, yylocationp)
 
1649
yydestruct (yymsg, yytype, yyvaluep, yylocationp)
 
1650
    const char *yymsg;
1392
1651
    int yytype;
1393
1652
    YYSTYPE *yyvaluep;
1394
1653
    YYLTYPE *yylocationp;
1395
1654
#endif
1396
1655
{
1397
 
  /* Pacify ``unused variable'' warnings.  */
1398
 
  (void) yyvaluep;
1399
 
  (void) yylocationp;
 
1656
  YYUSE (yyvaluep);
 
1657
  YYUSE (yylocationp);
 
1658
 
 
1659
  if (!yymsg)
 
1660
    yymsg = "Deleting";
 
1661
  YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
1400
1662
 
1401
1663
  switch (yytype)
1402
1664
    {
1403
1665
 
1404
1666
      default:
1405
 
        break;
 
1667
        break;
1406
1668
    }
1407
1669
}
1408
 
 
1409
1670
 
1410
1671
/* Prevent warnings from -Wmissing-prototypes.  */
1411
 
 
1412
1672
#ifdef YYPARSE_PARAM
1413
 
# if defined (__STDC__) || defined (__cplusplus)
 
1673
#if defined __STDC__ || defined __cplusplus
1414
1674
int yyparse (void *YYPARSE_PARAM);
1415
 
# else
 
1675
#else
1416
1676
int yyparse ();
1417
 
# endif
 
1677
#endif
1418
1678
#else /* ! YYPARSE_PARAM */
1419
 
#if defined (__STDC__) || defined (__cplusplus)
 
1679
#if defined __STDC__ || defined __cplusplus
1420
1680
int yyparse (void);
1421
1681
#else
1422
1682
int yyparse ();
1424
1684
#endif /* ! YYPARSE_PARAM */
1425
1685
 
1426
1686
 
1427
 
 
1428
1687
/* The lookahead symbol.  */
1429
1688
int yychar;
1430
1689
 
1431
1690
/* The semantic value of the lookahead symbol.  */
1432
1691
YYSTYPE yylval;
1433
1692
 
 
1693
/* Location data for the lookahead symbol.  */
 
1694
YYLTYPE yylloc;
 
1695
 
1434
1696
/* Number of syntax errors so far.  */
1435
1697
int yynerrs;
1436
 
/* Location data for the lookahead symbol.  */
1437
 
YYLTYPE yylloc;
1438
 
 
1439
 
 
1440
 
 
1441
 
/*----------.
1442
 
| yyparse.  |
1443
 
`----------*/
 
1698
 
 
1699
 
 
1700
 
 
1701
/*-------------------------.
 
1702
| yyparse or yypush_parse.  |
 
1703
`-------------------------*/
1444
1704
 
1445
1705
#ifdef YYPARSE_PARAM
1446
 
# if defined (__STDC__) || defined (__cplusplus)
1447
 
int yyparse (void *YYPARSE_PARAM)
1448
 
# else
1449
 
int yyparse (YYPARSE_PARAM)
1450
 
  void *YYPARSE_PARAM;
1451
 
# endif
 
1706
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1707
     || defined __cplusplus || defined _MSC_VER)
 
1708
int
 
1709
yyparse (void *YYPARSE_PARAM)
 
1710
#else
 
1711
int
 
1712
yyparse (YYPARSE_PARAM)
 
1713
    void *YYPARSE_PARAM;
 
1714
#endif
1452
1715
#else /* ! YYPARSE_PARAM */
1453
 
#if defined (__STDC__) || defined (__cplusplus)
 
1716
#if (defined __STDC__ || defined __C99__FUNC__ \
 
1717
     || defined __cplusplus || defined _MSC_VER)
1454
1718
int
1455
1719
yyparse (void)
1456
1720
#else
1460
1724
#endif
1461
1725
#endif
1462
1726
{
1463
 
  
1464
 
  register int yystate;
1465
 
  register int yyn;
 
1727
 
 
1728
 
 
1729
    int yystate;
 
1730
    /* Number of tokens to shift before error messages enabled.  */
 
1731
    int yyerrstatus;
 
1732
 
 
1733
    /* The stacks and their tools:
 
1734
       `yyss': related to states.
 
1735
       `yyvs': related to semantic values.
 
1736
       `yyls': related to locations.
 
1737
 
 
1738
       Refer to the stacks thru separate pointers, to allow yyoverflow
 
1739
       to reallocate them elsewhere.  */
 
1740
 
 
1741
    /* The state stack.  */
 
1742
    yytype_int16 yyssa[YYINITDEPTH];
 
1743
    yytype_int16 *yyss;
 
1744
    yytype_int16 *yyssp;
 
1745
 
 
1746
    /* The semantic value stack.  */
 
1747
    YYSTYPE yyvsa[YYINITDEPTH];
 
1748
    YYSTYPE *yyvs;
 
1749
    YYSTYPE *yyvsp;
 
1750
 
 
1751
    /* The location stack.  */
 
1752
    YYLTYPE yylsa[YYINITDEPTH];
 
1753
    YYLTYPE *yyls;
 
1754
    YYLTYPE *yylsp;
 
1755
 
 
1756
    /* The locations where the error started and ended.  */
 
1757
    YYLTYPE yyerror_range[2];
 
1758
 
 
1759
    YYSIZE_T yystacksize;
 
1760
 
 
1761
  int yyn;
1466
1762
  int yyresult;
1467
 
  /* Number of tokens to shift before error messages enabled.  */
1468
 
  int yyerrstatus;
1469
1763
  /* Lookahead token as an internal (translated) token number.  */
1470
 
  int yytoken = 0;
1471
 
 
1472
 
  /* Three stacks and their tools:
1473
 
     `yyss': related to states,
1474
 
     `yyvs': related to semantic values,
1475
 
     `yyls': related to locations.
1476
 
 
1477
 
     Refer to the stacks thru separate pointers, to allow yyoverflow
1478
 
     to reallocate them elsewhere.  */
1479
 
 
1480
 
  /* The state stack.  */
1481
 
  short yyssa[YYINITDEPTH];
1482
 
  short *yyss = yyssa;
1483
 
  register short *yyssp;
1484
 
 
1485
 
  /* The semantic value stack.  */
1486
 
  YYSTYPE yyvsa[YYINITDEPTH];
1487
 
  YYSTYPE *yyvs = yyvsa;
1488
 
  register YYSTYPE *yyvsp;
1489
 
 
1490
 
  /* The location stack.  */
1491
 
  YYLTYPE yylsa[YYINITDEPTH];
1492
 
  YYLTYPE *yyls = yylsa;
1493
 
  YYLTYPE *yylsp;
1494
 
  YYLTYPE *yylerrsp;
1495
 
 
1496
 
#define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
1497
 
 
1498
 
  YYSIZE_T yystacksize = YYINITDEPTH;
1499
 
 
 
1764
  int yytoken;
1500
1765
  /* The variables used to return semantic value and location from the
1501
1766
     action routines.  */
1502
1767
  YYSTYPE yyval;
1503
1768
  YYLTYPE yyloc;
1504
1769
 
1505
 
  /* When reducing, the number of symbols on the RHS of the reduced
1506
 
     rule.  */
1507
 
  int yylen;
 
1770
#if YYERROR_VERBOSE
 
1771
  /* Buffer for error messages, and its allocated size.  */
 
1772
  char yymsgbuf[128];
 
1773
  char *yymsg = yymsgbuf;
 
1774
  YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
 
1775
#endif
 
1776
 
 
1777
#define YYPOPSTACK(N)   (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
 
1778
 
 
1779
  /* The number of symbols on the RHS of the reduced rule.
 
1780
     Keep to zero when no symbol should be popped.  */
 
1781
  int yylen = 0;
 
1782
 
 
1783
  yytoken = 0;
 
1784
  yyss = yyssa;
 
1785
  yyvs = yyvsa;
 
1786
  yyls = yylsa;
 
1787
  yystacksize = YYINITDEPTH;
1508
1788
 
1509
1789
  YYDPRINTF ((stderr, "Starting parse\n"));
1510
1790
 
1511
1791
  yystate = 0;
1512
1792
  yyerrstatus = 0;
1513
1793
  yynerrs = 0;
1514
 
  yychar = YYEMPTY;             /* Cause a token to be read.  */
 
1794
  yychar = YYEMPTY; /* Cause a token to be read.  */
1515
1795
 
1516
1796
  /* Initialize stack pointers.
1517
1797
     Waste one element of value and location stack
1518
1798
     so that they stay on the same level as the state stack.
1519
1799
     The wasted elements are never initialized.  */
1520
 
 
1521
1800
  yyssp = yyss;
1522
1801
  yyvsp = yyvs;
1523
1802
  yylsp = yyls;
 
1803
 
 
1804
#if YYLTYPE_IS_TRIVIAL
 
1805
  /* Initialize the default location before parsing starts.  */
 
1806
  yylloc.first_line   = yylloc.last_line   = 1;
 
1807
  yylloc.first_column = yylloc.last_column = 1;
 
1808
#endif
 
1809
 
1524
1810
  goto yysetstate;
1525
1811
 
1526
1812
/*------------------------------------------------------------.
1528
1814
`------------------------------------------------------------*/
1529
1815
 yynewstate:
1530
1816
  /* In all cases, when you get here, the value and location stacks
1531
 
     have just been pushed. so pushing a state here evens the stacks.
1532
 
     */
 
1817
     have just been pushed.  So pushing a state here evens the stacks.  */
1533
1818
  yyssp++;
1534
1819
 
1535
1820
 yysetstate:
1542
1827
 
1543
1828
#ifdef yyoverflow
1544
1829
      {
1545
 
        /* Give user a chance to reallocate the stack. Use copies of
 
1830
        /* Give user a chance to reallocate the stack.  Use copies of
1546
1831
           these so that the &'s don't force the real ones into
1547
1832
           memory.  */
1548
1833
        YYSTYPE *yyvs1 = yyvs;
1549
 
        short *yyss1 = yyss;
 
1834
        yytype_int16 *yyss1 = yyss;
1550
1835
        YYLTYPE *yyls1 = yyls;
1551
1836
 
1552
1837
        /* Each stack pointer address is followed by the size of the
1553
1838
           data in use in that stack, in bytes.  This used to be a
1554
1839
           conditional around just the two extra args, but that might
1555
1840
           be undefined if yyoverflow is a macro.  */
1556
 
        yyoverflow ("parser stack overflow",
 
1841
        yyoverflow (YY_("memory exhausted"),
1557
1842
                    &yyss1, yysize * sizeof (*yyssp),
1558
1843
                    &yyvs1, yysize * sizeof (*yyvsp),
1559
1844
                    &yyls1, yysize * sizeof (*yylsp),
1560
1845
                    &yystacksize);
 
1846
 
1561
1847
        yyls = yyls1;
1562
1848
        yyss = yyss1;
1563
1849
        yyvs = yyvs1;
1564
1850
      }
1565
1851
#else /* no yyoverflow */
1566
1852
# ifndef YYSTACK_RELOCATE
1567
 
      goto yyoverflowlab;
 
1853
      goto yyexhaustedlab;
1568
1854
# else
1569
1855
      /* Extend the stack our own way.  */
1570
1856
      if (YYMAXDEPTH <= yystacksize)
1571
 
        goto yyoverflowlab;
 
1857
        goto yyexhaustedlab;
1572
1858
      yystacksize *= 2;
1573
1859
      if (YYMAXDEPTH < yystacksize)
1574
1860
        yystacksize = YYMAXDEPTH;
1575
1861
 
1576
1862
      {
1577
 
        short *yyss1 = yyss;
 
1863
        yytype_int16 *yyss1 = yyss;
1578
1864
        union yyalloc *yyptr =
1579
1865
          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
1580
1866
        if (! yyptr)
1581
 
          goto yyoverflowlab;
1582
 
        YYSTACK_RELOCATE (yyss);
1583
 
        YYSTACK_RELOCATE (yyvs);
1584
 
        YYSTACK_RELOCATE (yyls);
 
1867
          goto yyexhaustedlab;
 
1868
        YYSTACK_RELOCATE (yyss_alloc, yyss);
 
1869
        YYSTACK_RELOCATE (yyvs_alloc, yyvs);
 
1870
        YYSTACK_RELOCATE (yyls_alloc, yyls);
1585
1871
#  undef YYSTACK_RELOCATE
1586
1872
        if (yyss1 != yyssa)
1587
1873
          YYSTACK_FREE (yyss1);
1602
1888
 
1603
1889
  YYDPRINTF ((stderr, "Entering state %d\n", yystate));
1604
1890
 
 
1891
  if (yystate == YYFINAL)
 
1892
    YYACCEPT;
 
1893
 
1605
1894
  goto yybackup;
1606
1895
 
1607
1896
/*-----------.
1609
1898
`-----------*/
1610
1899
yybackup:
1611
1900
 
1612
 
/* Do appropriate processing given the current state.  */
1613
 
/* Read a lookahead token if we need one and don't already have one.  */
1614
 
/* yyresume: */
 
1901
  /* Do appropriate processing given the current state.  Read a
 
1902
     lookahead token if we need one and don't already have one.  */
1615
1903
 
1616
1904
  /* First try to decide what to do without reference to lookahead token.  */
1617
 
 
1618
1905
  yyn = yypact[yystate];
1619
1906
  if (yyn == YYPACT_NINF)
1620
1907
    goto yydefault;
1636
1923
  else
1637
1924
    {
1638
1925
      yytoken = YYTRANSLATE (yychar);
1639
 
      YYDSYMPRINTF ("Next token is", yytoken, &yylval, &yylloc);
 
1926
      YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
1640
1927
    }
1641
1928
 
1642
1929
  /* If the proper action on seeing token YYTOKEN is to reduce or to
1653
1940
      goto yyreduce;
1654
1941
    }
1655
1942
 
1656
 
  if (yyn == YYFINAL)
1657
 
    YYACCEPT;
1658
 
 
1659
 
  /* Shift the lookahead token.  */
1660
 
  YYDPRINTF ((stderr, "Shifting token %s, ", yytname[yytoken]));
1661
 
 
1662
 
  /* Discard the token being shifted unless it is eof.  */
1663
 
  if (yychar != YYEOF)
1664
 
    yychar = YYEMPTY;
1665
 
 
1666
 
  *++yyvsp = yylval;
1667
 
  *++yylsp = yylloc;
1668
 
 
1669
1943
  /* Count tokens shifted since error; after three, turn off error
1670
1944
     status.  */
1671
1945
  if (yyerrstatus)
1672
1946
    yyerrstatus--;
1673
1947
 
 
1948
  /* Shift the lookahead token.  */
 
1949
  YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
 
1950
 
 
1951
  /* Discard the shifted token.  */
 
1952
  yychar = YYEMPTY;
 
1953
 
1674
1954
  yystate = yyn;
 
1955
  *++yyvsp = yylval;
 
1956
  *++yylsp = yylloc;
1675
1957
  goto yynewstate;
1676
1958
 
1677
1959
 
1702
1984
     GCC warning that YYVAL may be used uninitialized.  */
1703
1985
  yyval = yyvsp[1-yylen];
1704
1986
 
1705
 
  /* Default location. */
 
1987
  /* Default location.  */
1706
1988
  YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1707
1989
  YY_REDUCE_PRINT (yyn);
1708
1990
  switch (yyn)
1709
1991
    {
1710
1992
        case 2:
 
1993
 
 
1994
/* Line 1455 of yacc.c  */
1711
1995
#line 324 "gram.y"
1712
1996
    {
1713
 
                                                plpgsql_parse_result = (PLpgSQL_stmt_block *) yyvsp[-1].stmt;
 
1997
                                                plpgsql_parse_result = (PLpgSQL_stmt_block *) (yyvsp[(2) - (3)].stmt);
1714
1998
                                        ;}
1715
1999
    break;
1716
2000
 
1717
2001
  case 5:
 
2002
 
 
2003
/* Line 1455 of yacc.c  */
1718
2004
#line 334 "gram.y"
1719
2005
    {
1720
2006
                                                plpgsql_DumpExecTree = true;
1722
2008
    break;
1723
2009
 
1724
2010
  case 6:
 
2011
 
 
2012
/* Line 1455 of yacc.c  */
1725
2013
#line 338 "gram.y"
1726
2014
    {
1727
2015
                                                plpgsql_curr_compile->resolve_option = PLPGSQL_RESOLVE_ERROR;
1729
2017
    break;
1730
2018
 
1731
2019
  case 7:
 
2020
 
 
2021
/* Line 1455 of yacc.c  */
1732
2022
#line 342 "gram.y"
1733
2023
    {
1734
2024
                                                plpgsql_curr_compile->resolve_option = PLPGSQL_RESOLVE_VARIABLE;
1736
2026
    break;
1737
2027
 
1738
2028
  case 8:
 
2029
 
 
2030
/* Line 1455 of yacc.c  */
1739
2031
#line 346 "gram.y"
1740
2032
    {
1741
2033
                                                plpgsql_curr_compile->resolve_option = PLPGSQL_RESOLVE_COLUMN;
1743
2035
    break;
1744
2036
 
1745
2037
  case 11:
 
2038
 
 
2039
/* Line 1455 of yacc.c  */
1746
2040
#line 356 "gram.y"
1747
2041
    {
1748
2042
                                                PLpgSQL_stmt_block *new;
1750
2044
                                                new = palloc0(sizeof(PLpgSQL_stmt_block));
1751
2045
 
1752
2046
                                                new->cmd_type   = PLPGSQL_STMT_BLOCK;
1753
 
                                                new->lineno             = plpgsql_location_to_lineno(yylsp[-4]);
1754
 
                                                new->label              = yyvsp[-5].declhdr.label;
1755
 
                                                new->n_initvars = yyvsp[-5].declhdr.n_initvars;
1756
 
                                                new->initvarnos = yyvsp[-5].declhdr.initvarnos;
1757
 
                                                new->body               = yyvsp[-3].list;
1758
 
                                                new->exceptions = yyvsp[-2].exception_block;
 
2047
                                                new->lineno             = plpgsql_location_to_lineno((yylsp[(2) - (6)]));
 
2048
                                                new->label              = (yyvsp[(1) - (6)].declhdr).label;
 
2049
                                                new->n_initvars = (yyvsp[(1) - (6)].declhdr).n_initvars;
 
2050
                                                new->initvarnos = (yyvsp[(1) - (6)].declhdr).initvarnos;
 
2051
                                                new->body               = (yyvsp[(3) - (6)].list);
 
2052
                                                new->exceptions = (yyvsp[(4) - (6)].exception_block);
1759
2053
 
1760
 
                                                check_labels(yyvsp[-5].declhdr.label, yyvsp[0].str, yylsp[0]);
 
2054
                                                check_labels((yyvsp[(1) - (6)].declhdr).label, (yyvsp[(6) - (6)].str), (yylsp[(6) - (6)]));
1761
2055
                                                plpgsql_ns_pop();
1762
2056
 
1763
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
2057
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
1764
2058
                                        ;}
1765
2059
    break;
1766
2060
 
1767
2061
  case 12:
 
2062
 
 
2063
/* Line 1455 of yacc.c  */
1768
2064
#line 378 "gram.y"
1769
2065
    {
1770
2066
                                                /* done with decls, so resume identifier lookup */
1771
2067
                                                plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_NORMAL;
1772
 
                                                yyval.declhdr.label       = yyvsp[0].str;
1773
 
                                                yyval.declhdr.n_initvars = 0;
1774
 
                                                yyval.declhdr.initvarnos = NULL;
 
2068
                                                (yyval.declhdr).label     = (yyvsp[(1) - (1)].str);
 
2069
                                                (yyval.declhdr).n_initvars = 0;
 
2070
                                                (yyval.declhdr).initvarnos = NULL;
1775
2071
                                        ;}
1776
2072
    break;
1777
2073
 
1778
2074
  case 13:
 
2075
 
 
2076
/* Line 1455 of yacc.c  */
1779
2077
#line 386 "gram.y"
1780
2078
    {
1781
2079
                                                plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_NORMAL;
1782
 
                                                yyval.declhdr.label       = yyvsp[-1].str;
1783
 
                                                yyval.declhdr.n_initvars = 0;
1784
 
                                                yyval.declhdr.initvarnos = NULL;
 
2080
                                                (yyval.declhdr).label     = (yyvsp[(1) - (2)].str);
 
2081
                                                (yyval.declhdr).n_initvars = 0;
 
2082
                                                (yyval.declhdr).initvarnos = NULL;
1785
2083
                                        ;}
1786
2084
    break;
1787
2085
 
1788
2086
  case 14:
 
2087
 
 
2088
/* Line 1455 of yacc.c  */
1789
2089
#line 393 "gram.y"
1790
2090
    {
1791
2091
                                                plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_NORMAL;
1792
 
                                                yyval.declhdr.label       = yyvsp[-2].str;
 
2092
                                                (yyval.declhdr).label     = (yyvsp[(1) - (3)].str);
1793
2093
                                                /* Remember variables declared in decl_stmts */
1794
 
                                                yyval.declhdr.n_initvars = plpgsql_add_initdatums(&(yyval.declhdr.initvarnos));
 
2094
                                                (yyval.declhdr).n_initvars = plpgsql_add_initdatums(&((yyval.declhdr).initvarnos));
1795
2095
                                        ;}
1796
2096
    break;
1797
2097
 
1798
2098
  case 15:
 
2099
 
 
2100
/* Line 1455 of yacc.c  */
1799
2101
#line 402 "gram.y"
1800
2102
    {
1801
2103
                                                /* Forget any variables created before block */
1809
2111
    break;
1810
2112
 
1811
2113
  case 19:
 
2114
 
 
2115
/* Line 1455 of yacc.c  */
1812
2116
#line 419 "gram.y"
1813
2117
    {
1814
2118
                                                /* We allow useless extra DECLAREs */
1816
2120
    break;
1817
2121
 
1818
2122
  case 20:
 
2123
 
 
2124
/* Line 1455 of yacc.c  */
1819
2125
#line 423 "gram.y"
1820
2126
    {
1821
2127
                                                /*
1825
2131
                                                ereport(ERROR,
1826
2132
                                                                (errcode(ERRCODE_SYNTAX_ERROR),
1827
2133
                                                                 errmsg("block label must be placed before DECLARE, not after"),
1828
 
                                                                 parser_errposition(yylsp[-2])));
 
2134
                                                                 parser_errposition((yylsp[(1) - (3)]))));
1829
2135
                                        ;}
1830
2136
    break;
1831
2137
 
1832
2138
  case 21:
 
2139
 
 
2140
/* Line 1455 of yacc.c  */
1833
2141
#line 436 "gram.y"
1834
2142
    {
1835
2143
                                                PLpgSQL_variable        *var;
1840
2148
                                                 * a freshly built struct not shared with other
1841
2149
                                                 * variables.
1842
2150
                                                 */
1843
 
                                                if (OidIsValid(yyvsp[-2].oid))
 
2151
                                                if (OidIsValid((yyvsp[(4) - (6)].oid)))
1844
2152
                                                {
1845
 
                                                        if (!OidIsValid(yyvsp[-3].dtype->collation))
 
2153
                                                        if (!OidIsValid((yyvsp[(3) - (6)].dtype)->collation))
1846
2154
                                                                ereport(ERROR,
1847
2155
                                                                                (errcode(ERRCODE_DATATYPE_MISMATCH),
1848
2156
                                                                                 errmsg("collations are not supported by type %s",
1849
 
                                                                                                format_type_be(yyvsp[-3].dtype->typoid)),
1850
 
                                                                                 parser_errposition(yylsp[-2])));
1851
 
                                                        yyvsp[-3].dtype->collation = yyvsp[-2].oid;
 
2157
                                                                                                format_type_be((yyvsp[(3) - (6)].dtype)->typoid)),
 
2158
                                                                                 parser_errposition((yylsp[(4) - (6)]))));
 
2159
                                                        (yyvsp[(3) - (6)].dtype)->collation = (yyvsp[(4) - (6)].oid);
1852
2160
                                                }
1853
2161
 
1854
 
                                                var = plpgsql_build_variable(yyvsp[-5].varname.name, yyvsp[-5].varname.lineno,
1855
 
                                                                                                         yyvsp[-3].dtype, true);
1856
 
                                                if (yyvsp[-4].boolean)
 
2162
                                                var = plpgsql_build_variable((yyvsp[(1) - (6)].varname).name, (yyvsp[(1) - (6)].varname).lineno,
 
2163
                                                                                                         (yyvsp[(3) - (6)].dtype), true);
 
2164
                                                if ((yyvsp[(2) - (6)].boolean))
1857
2165
                                                {
1858
2166
                                                        if (var->dtype == PLPGSQL_DTYPE_VAR)
1859
 
                                                                ((PLpgSQL_var *) var)->isconst = yyvsp[-4].boolean;
 
2167
                                                                ((PLpgSQL_var *) var)->isconst = (yyvsp[(2) - (6)].boolean);
1860
2168
                                                        else
1861
2169
                                                                ereport(ERROR,
1862
2170
                                                                                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1863
2171
                                                                                 errmsg("row or record variable cannot be CONSTANT"),
1864
 
                                                                                 parser_errposition(yylsp[-4])));
 
2172
                                                                                 parser_errposition((yylsp[(2) - (6)]))));
1865
2173
                                                }
1866
 
                                                if (yyvsp[-1].boolean)
 
2174
                                                if ((yyvsp[(5) - (6)].boolean))
1867
2175
                                                {
1868
2176
                                                        if (var->dtype == PLPGSQL_DTYPE_VAR)
1869
 
                                                                ((PLpgSQL_var *) var)->notnull = yyvsp[-1].boolean;
 
2177
                                                                ((PLpgSQL_var *) var)->notnull = (yyvsp[(5) - (6)].boolean);
1870
2178
                                                        else
1871
2179
                                                                ereport(ERROR,
1872
2180
                                                                                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1873
2181
                                                                                 errmsg("row or record variable cannot be NOT NULL"),
1874
 
                                                                                 parser_errposition(yylsp[-2])));
 
2182
                                                                                 parser_errposition((yylsp[(4) - (6)]))));
1875
2183
 
1876
2184
                                                }
1877
 
                                                if (yyvsp[0].expr != NULL)
 
2185
                                                if ((yyvsp[(6) - (6)].expr) != NULL)
1878
2186
                                                {
1879
2187
                                                        if (var->dtype == PLPGSQL_DTYPE_VAR)
1880
 
                                                                ((PLpgSQL_var *) var)->default_val = yyvsp[0].expr;
 
2188
                                                                ((PLpgSQL_var *) var)->default_val = (yyvsp[(6) - (6)].expr);
1881
2189
                                                        else
1882
2190
                                                                ereport(ERROR,
1883
2191
                                                                                (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
1884
2192
                                                                                 errmsg("default value for row or record variable is not supported"),
1885
 
                                                                                 parser_errposition(yylsp[-1])));
 
2193
                                                                                 parser_errposition((yylsp[(5) - (6)]))));
1886
2194
                                                }
1887
2195
                                        ;}
1888
2196
    break;
1889
2197
 
1890
2198
  case 22:
 
2199
 
 
2200
/* Line 1455 of yacc.c  */
1891
2201
#line 491 "gram.y"
1892
2202
    {
1893
 
                                                plpgsql_ns_additem(yyvsp[-1].nsitem->itemtype,
1894
 
                                                                                   yyvsp[-1].nsitem->itemno, yyvsp[-4].varname.name);
 
2203
                                                plpgsql_ns_additem((yyvsp[(4) - (5)].nsitem)->itemtype,
 
2204
                                                                                   (yyvsp[(4) - (5)].nsitem)->itemno, (yyvsp[(1) - (5)].varname).name);
1895
2205
                                        ;}
1896
2206
    break;
1897
2207
 
1898
2208
  case 23:
 
2209
 
 
2210
/* Line 1455 of yacc.c  */
1899
2211
#line 496 "gram.y"
1900
 
    { plpgsql_ns_push(yyvsp[-2].varname.name); ;}
 
2212
    { plpgsql_ns_push((yyvsp[(1) - (3)].varname).name); ;}
1901
2213
    break;
1902
2214
 
1903
2215
  case 24:
 
2216
 
 
2217
/* Line 1455 of yacc.c  */
1904
2218
#line 498 "gram.y"
1905
2219
    {
1906
2220
                                                PLpgSQL_var *new;
1913
2227
                                                plpgsql_ns_pop();
1914
2228
 
1915
2229
                                                new = (PLpgSQL_var *)
1916
 
                                                        plpgsql_build_variable(yyvsp[-6].varname.name, yyvsp[-6].varname.lineno,
 
2230
                                                        plpgsql_build_variable((yyvsp[(1) - (7)].varname).name, (yyvsp[(1) - (7)].varname).lineno,
1917
2231
                                                                                                   plpgsql_build_datatype(REFCURSOROID,
1918
2232
                                                                                                                                                  -1,
1919
2233
                                                                                                                                                  InvalidOid),
1942
2256
                                                curname_def->query = pstrdup(buf);
1943
2257
                                                new->default_val = curname_def;
1944
2258
 
1945
 
                                                new->cursor_explicit_expr = yyvsp[0].expr;
1946
 
                                                if (yyvsp[-2].datum == NULL)
 
2259
                                                new->cursor_explicit_expr = (yyvsp[(7) - (7)].expr);
 
2260
                                                if ((yyvsp[(5) - (7)].datum) == NULL)
1947
2261
                                                        new->cursor_explicit_argrow = -1;
1948
2262
                                                else
1949
 
                                                        new->cursor_explicit_argrow = yyvsp[-2].datum->dno;
1950
 
                                                new->cursor_options = CURSOR_OPT_FAST_PLAN | yyvsp[-5].ival;
 
2263
                                                        new->cursor_explicit_argrow = (yyvsp[(5) - (7)].datum)->dno;
 
2264
                                                new->cursor_options = CURSOR_OPT_FAST_PLAN | (yyvsp[(2) - (7)].ival);
1951
2265
                                        ;}
1952
2266
    break;
1953
2267
 
1954
2268
  case 25:
 
2269
 
 
2270
/* Line 1455 of yacc.c  */
1955
2271
#line 548 "gram.y"
1956
2272
    {
1957
 
                                                yyval.ival = 0;
 
2273
                                                (yyval.ival) = 0;
1958
2274
                                        ;}
1959
2275
    break;
1960
2276
 
1961
2277
  case 26:
 
2278
 
 
2279
/* Line 1455 of yacc.c  */
1962
2280
#line 552 "gram.y"
1963
2281
    {
1964
 
                                                yyval.ival = CURSOR_OPT_NO_SCROLL;
 
2282
                                                (yyval.ival) = CURSOR_OPT_NO_SCROLL;
1965
2283
                                        ;}
1966
2284
    break;
1967
2285
 
1968
2286
  case 27:
 
2287
 
 
2288
/* Line 1455 of yacc.c  */
1969
2289
#line 556 "gram.y"
1970
2290
    {
1971
 
                                                yyval.ival = CURSOR_OPT_SCROLL;
 
2291
                                                (yyval.ival) = CURSOR_OPT_SCROLL;
1972
2292
                                        ;}
1973
2293
    break;
1974
2294
 
1975
2295
  case 28:
 
2296
 
 
2297
/* Line 1455 of yacc.c  */
1976
2298
#line 562 "gram.y"
1977
2299
    {
1978
 
                                                yyval.expr = read_sql_stmt("");
 
2300
                                                (yyval.expr) = read_sql_stmt("");
1979
2301
                                        ;}
1980
2302
    break;
1981
2303
 
1982
2304
  case 29:
 
2305
 
 
2306
/* Line 1455 of yacc.c  */
1983
2307
#line 568 "gram.y"
1984
2308
    {
1985
 
                                                yyval.datum = NULL;
 
2309
                                                (yyval.datum) = NULL;
1986
2310
                                        ;}
1987
2311
    break;
1988
2312
 
1989
2313
  case 30:
 
2314
 
 
2315
/* Line 1455 of yacc.c  */
1990
2316
#line 572 "gram.y"
1991
2317
    {
1992
2318
                                                PLpgSQL_row *new;
1995
2321
 
1996
2322
                                                new = palloc0(sizeof(PLpgSQL_row));
1997
2323
                                                new->dtype = PLPGSQL_DTYPE_ROW;
1998
 
                                                new->lineno = plpgsql_location_to_lineno(yylsp[-2]);
 
2324
                                                new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (3)]));
1999
2325
                                                new->rowtupdesc = NULL;
2000
 
                                                new->nfields = list_length(yyvsp[-1].list);
 
2326
                                                new->nfields = list_length((yyvsp[(2) - (3)].list));
2001
2327
                                                new->fieldnames = palloc(new->nfields * sizeof(char *));
2002
2328
                                                new->varnos = palloc(new->nfields * sizeof(int));
2003
2329
 
2004
2330
                                                i = 0;
2005
 
                                                foreach (l, yyvsp[-1].list)
 
2331
                                                foreach (l, (yyvsp[(2) - (3)].list))
2006
2332
                                                {
2007
2333
                                                        PLpgSQL_variable *arg = (PLpgSQL_variable *) lfirst(l);
2008
2334
                                                        new->fieldnames[i] = arg->refname;
2009
2335
                                                        new->varnos[i] = arg->dno;
2010
2336
                                                        i++;
2011
2337
                                                }
2012
 
                                                list_free(yyvsp[-1].list);
 
2338
                                                list_free((yyvsp[(2) - (3)].list));
2013
2339
 
2014
2340
                                                plpgsql_adddatum((PLpgSQL_datum *) new);
2015
 
                                                yyval.datum = (PLpgSQL_datum *) new;
 
2341
                                                (yyval.datum) = (PLpgSQL_datum *) new;
2016
2342
                                        ;}
2017
2343
    break;
2018
2344
 
2019
2345
  case 31:
 
2346
 
 
2347
/* Line 1455 of yacc.c  */
2020
2348
#line 601 "gram.y"
2021
2349
    {
2022
 
                                                yyval.list = list_make1(yyvsp[0].datum);
 
2350
                                                (yyval.list) = list_make1((yyvsp[(1) - (1)].datum));
2023
2351
                                        ;}
2024
2352
    break;
2025
2353
 
2026
2354
  case 32:
 
2355
 
 
2356
/* Line 1455 of yacc.c  */
2027
2357
#line 605 "gram.y"
2028
2358
    {
2029
 
                                                yyval.list = lappend(yyvsp[-2].list, yyvsp[0].datum);
 
2359
                                                (yyval.list) = lappend((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].datum));
2030
2360
                                        ;}
2031
2361
    break;
2032
2362
 
2033
2363
  case 33:
 
2364
 
 
2365
/* Line 1455 of yacc.c  */
2034
2366
#line 611 "gram.y"
2035
2367
    {
2036
 
                                                yyval.datum = (PLpgSQL_datum *)
2037
 
                                                        plpgsql_build_variable(yyvsp[-1].varname.name, yyvsp[-1].varname.lineno,
2038
 
                                                                                                   yyvsp[0].dtype, true);
 
2368
                                                (yyval.datum) = (PLpgSQL_datum *)
 
2369
                                                        plpgsql_build_variable((yyvsp[(1) - (2)].varname).name, (yyvsp[(1) - (2)].varname).lineno,
 
2370
                                                                                                   (yyvsp[(2) - (2)].dtype), true);
2039
2371
                                        ;}
2040
2372
    break;
2041
2373
 
2042
2374
  case 36:
 
2375
 
 
2376
/* Line 1455 of yacc.c  */
2043
2377
#line 622 "gram.y"
2044
2378
    {
2045
2379
                                                PLpgSQL_nsitem *nsi;
2046
2380
 
2047
2381
                                                nsi = plpgsql_ns_lookup(plpgsql_ns_top(), false,
2048
 
                                                                                                yyvsp[0].word.ident, NULL, NULL,
 
2382
                                                                                                (yyvsp[(1) - (1)].word).ident, NULL, NULL,
2049
2383
                                                                                                NULL);
2050
2384
                                                if (nsi == NULL)
2051
2385
                                                        ereport(ERROR,
2052
2386
                                                                        (errcode(ERRCODE_UNDEFINED_OBJECT),
2053
2387
                                                                         errmsg("variable \"%s\" does not exist",
2054
 
                                                                                        yyvsp[0].word.ident),
2055
 
                                                                         parser_errposition(yylsp[0])));
2056
 
                                                yyval.nsitem = nsi;
 
2388
                                                                                        (yyvsp[(1) - (1)].word).ident),
 
2389
                                                                         parser_errposition((yylsp[(1) - (1)]))));
 
2390
                                                (yyval.nsitem) = nsi;
2057
2391
                                        ;}
2058
2392
    break;
2059
2393
 
2060
2394
  case 37:
 
2395
 
 
2396
/* Line 1455 of yacc.c  */
2061
2397
#line 637 "gram.y"
2062
2398
    {
2063
2399
                                                PLpgSQL_nsitem *nsi;
2064
2400
 
2065
 
                                                if (list_length(yyvsp[0].cword.idents) == 2)
 
2401
                                                if (list_length((yyvsp[(1) - (1)].cword).idents) == 2)
2066
2402
                                                        nsi = plpgsql_ns_lookup(plpgsql_ns_top(), false,
2067
 
                                                                                                        strVal(linitial(yyvsp[0].cword.idents)),
2068
 
                                                                                                        strVal(lsecond(yyvsp[0].cword.idents)),
 
2403
                                                                                                        strVal(linitial((yyvsp[(1) - (1)].cword).idents)),
 
2404
                                                                                                        strVal(lsecond((yyvsp[(1) - (1)].cword).idents)),
2069
2405
                                                                                                        NULL,
2070
2406
                                                                                                        NULL);
2071
 
                                                else if (list_length(yyvsp[0].cword.idents) == 3)
 
2407
                                                else if (list_length((yyvsp[(1) - (1)].cword).idents) == 3)
2072
2408
                                                        nsi = plpgsql_ns_lookup(plpgsql_ns_top(), false,
2073
 
                                                                                                        strVal(linitial(yyvsp[0].cword.idents)),
2074
 
                                                                                                        strVal(lsecond(yyvsp[0].cword.idents)),
2075
 
                                                                                                        strVal(lthird(yyvsp[0].cword.idents)),
 
2409
                                                                                                        strVal(linitial((yyvsp[(1) - (1)].cword).idents)),
 
2410
                                                                                                        strVal(lsecond((yyvsp[(1) - (1)].cword).idents)),
 
2411
                                                                                                        strVal(lthird((yyvsp[(1) - (1)].cword).idents)),
2076
2412
                                                                                                        NULL);
2077
2413
                                                else
2078
2414
                                                        nsi = NULL;
2080
2416
                                                        ereport(ERROR,
2081
2417
                                                                        (errcode(ERRCODE_UNDEFINED_OBJECT),
2082
2418
                                                                         errmsg("variable \"%s\" does not exist",
2083
 
                                                                                        NameListToString(yyvsp[0].cword.idents)),
2084
 
                                                                         parser_errposition(yylsp[0])));
2085
 
                                                yyval.nsitem = nsi;
 
2419
                                                                                        NameListToString((yyvsp[(1) - (1)].cword).idents)),
 
2420
                                                                         parser_errposition((yylsp[(1) - (1)]))));
 
2421
                                                (yyval.nsitem) = nsi;
2086
2422
                                        ;}
2087
2423
    break;
2088
2424
 
2089
2425
  case 38:
 
2426
 
 
2427
/* Line 1455 of yacc.c  */
2090
2428
#line 665 "gram.y"
2091
2429
    {
2092
 
                                                yyval.varname.name = yyvsp[0].word.ident;
2093
 
                                                yyval.varname.lineno = plpgsql_location_to_lineno(yylsp[0]);
 
2430
                                                (yyval.varname).name = (yyvsp[(1) - (1)].word).ident;
 
2431
                                                (yyval.varname).lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]));
2094
2432
                                                /*
2095
2433
                                                 * Check to make sure name isn't already declared
2096
2434
                                                 * in the current block.
2097
2435
                                                 */
2098
2436
                                                if (plpgsql_ns_lookup(plpgsql_ns_top(), true,
2099
 
                                                                                          yyvsp[0].word.ident, NULL, NULL,
 
2437
                                                                                          (yyvsp[(1) - (1)].word).ident, NULL, NULL,
2100
2438
                                                                                          NULL) != NULL)
2101
2439
                                                        yyerror("duplicate declaration");
2102
2440
                                        ;}
2103
2441
    break;
2104
2442
 
2105
2443
  case 39:
 
2444
 
 
2445
/* Line 1455 of yacc.c  */
2106
2446
#line 678 "gram.y"
2107
2447
    {
2108
 
                                                yyval.varname.name = pstrdup(yyvsp[0].keyword);
2109
 
                                                yyval.varname.lineno = plpgsql_location_to_lineno(yylsp[0]);
 
2448
                                                (yyval.varname).name = pstrdup((yyvsp[(1) - (1)].keyword));
 
2449
                                                (yyval.varname).lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]));
2110
2450
                                                /*
2111
2451
                                                 * Check to make sure name isn't already declared
2112
2452
                                                 * in the current block.
2113
2453
                                                 */
2114
2454
                                                if (plpgsql_ns_lookup(plpgsql_ns_top(), true,
2115
 
                                                                                          yyvsp[0].keyword, NULL, NULL,
 
2455
                                                                                          (yyvsp[(1) - (1)].keyword), NULL, NULL,
2116
2456
                                                                                          NULL) != NULL)
2117
2457
                                                        yyerror("duplicate declaration");
2118
2458
                                        ;}
2119
2459
    break;
2120
2460
 
2121
2461
  case 40:
 
2462
 
 
2463
/* Line 1455 of yacc.c  */
2122
2464
#line 693 "gram.y"
2123
 
    { yyval.boolean = false; ;}
 
2465
    { (yyval.boolean) = false; ;}
2124
2466
    break;
2125
2467
 
2126
2468
  case 41:
 
2469
 
 
2470
/* Line 1455 of yacc.c  */
2127
2471
#line 695 "gram.y"
2128
 
    { yyval.boolean = true; ;}
 
2472
    { (yyval.boolean) = true; ;}
2129
2473
    break;
2130
2474
 
2131
2475
  case 42:
 
2476
 
 
2477
/* Line 1455 of yacc.c  */
2132
2478
#line 699 "gram.y"
2133
2479
    {
2134
2480
                                                /*
2135
2481
                                                 * If there's a lookahead token, read_datatype
2136
2482
                                                 * should consume it.
2137
2483
                                                 */
2138
 
                                                yyval.dtype = read_datatype(yychar);
 
2484
                                                (yyval.dtype) = read_datatype(yychar);
2139
2485
                                                yyclearin;
2140
2486
                                        ;}
2141
2487
    break;
2142
2488
 
2143
2489
  case 43:
 
2490
 
 
2491
/* Line 1455 of yacc.c  */
2144
2492
#line 710 "gram.y"
2145
 
    { yyval.oid = InvalidOid; ;}
 
2493
    { (yyval.oid) = InvalidOid; ;}
2146
2494
    break;
2147
2495
 
2148
2496
  case 44:
 
2497
 
 
2498
/* Line 1455 of yacc.c  */
2149
2499
#line 712 "gram.y"
2150
2500
    {
2151
 
                                                yyval.oid = get_collation_oid(list_make1(makeString(yyvsp[0].word.ident)),
 
2501
                                                (yyval.oid) = get_collation_oid(list_make1(makeString((yyvsp[(2) - (2)].word).ident)),
2152
2502
                                                                                           false);
2153
2503
                                        ;}
2154
2504
    break;
2155
2505
 
2156
2506
  case 45:
 
2507
 
 
2508
/* Line 1455 of yacc.c  */
2157
2509
#line 717 "gram.y"
2158
2510
    {
2159
 
                                                yyval.oid = get_collation_oid(yyvsp[0].cword.idents, false);
 
2511
                                                (yyval.oid) = get_collation_oid((yyvsp[(2) - (2)].cword).idents, false);
2160
2512
                                        ;}
2161
2513
    break;
2162
2514
 
2163
2515
  case 46:
 
2516
 
 
2517
/* Line 1455 of yacc.c  */
2164
2518
#line 723 "gram.y"
2165
 
    { yyval.boolean = false; ;}
 
2519
    { (yyval.boolean) = false; ;}
2166
2520
    break;
2167
2521
 
2168
2522
  case 47:
 
2523
 
 
2524
/* Line 1455 of yacc.c  */
2169
2525
#line 725 "gram.y"
2170
 
    { yyval.boolean = true; ;}
 
2526
    { (yyval.boolean) = true; ;}
2171
2527
    break;
2172
2528
 
2173
2529
  case 48:
 
2530
 
 
2531
/* Line 1455 of yacc.c  */
2174
2532
#line 729 "gram.y"
2175
 
    { yyval.expr = NULL; ;}
 
2533
    { (yyval.expr) = NULL; ;}
2176
2534
    break;
2177
2535
 
2178
2536
  case 49:
 
2537
 
 
2538
/* Line 1455 of yacc.c  */
2179
2539
#line 731 "gram.y"
2180
2540
    {
2181
 
                                                yyval.expr = read_sql_expression(';', ";");
 
2541
                                                (yyval.expr) = read_sql_expression(';', ";");
2182
2542
                                        ;}
2183
2543
    break;
2184
2544
 
2185
2545
  case 54:
 
2546
 
 
2547
/* Line 1455 of yacc.c  */
2186
2548
#line 745 "gram.y"
2187
 
    { yyval.list = NIL; ;}
 
2549
    { (yyval.list) = NIL; ;}
2188
2550
    break;
2189
2551
 
2190
2552
  case 55:
 
2553
 
 
2554
/* Line 1455 of yacc.c  */
2191
2555
#line 747 "gram.y"
2192
 
    { yyval.list = yyvsp[0].list; ;}
 
2556
    { (yyval.list) = (yyvsp[(1) - (1)].list); ;}
2193
2557
    break;
2194
2558
 
2195
2559
  case 56:
 
2560
 
 
2561
/* Line 1455 of yacc.c  */
2196
2562
#line 751 "gram.y"
2197
2563
    {
2198
 
                                                        if (yyvsp[0].stmt == NULL)
2199
 
                                                                yyval.list = yyvsp[-1].list;
 
2564
                                                        if ((yyvsp[(2) - (2)].stmt) == NULL)
 
2565
                                                                (yyval.list) = (yyvsp[(1) - (2)].list);
2200
2566
                                                        else
2201
 
                                                                yyval.list = lappend(yyvsp[-1].list, yyvsp[0].stmt);
 
2567
                                                                (yyval.list) = lappend((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].stmt));
2202
2568
                                                ;}
2203
2569
    break;
2204
2570
 
2205
2571
  case 57:
 
2572
 
 
2573
/* Line 1455 of yacc.c  */
2206
2574
#line 758 "gram.y"
2207
2575
    {
2208
 
                                                        if (yyvsp[0].stmt == NULL)
2209
 
                                                                yyval.list = NIL;
 
2576
                                                        if ((yyvsp[(1) - (1)].stmt) == NULL)
 
2577
                                                                (yyval.list) = NIL;
2210
2578
                                                        else
2211
 
                                                                yyval.list = list_make1(yyvsp[0].stmt);
 
2579
                                                                (yyval.list) = list_make1((yyvsp[(1) - (1)].stmt));
2212
2580
                                                ;}
2213
2581
    break;
2214
2582
 
2215
2583
  case 58:
 
2584
 
 
2585
/* Line 1455 of yacc.c  */
2216
2586
#line 767 "gram.y"
2217
 
    { yyval.stmt = yyvsp[-1].stmt; ;}
 
2587
    { (yyval.stmt) = (yyvsp[(1) - (2)].stmt); ;}
2218
2588
    break;
2219
2589
 
2220
2590
  case 59:
 
2591
 
 
2592
/* Line 1455 of yacc.c  */
2221
2593
#line 769 "gram.y"
2222
 
    { yyval.stmt = yyvsp[0].stmt; ;}
 
2594
    { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2223
2595
    break;
2224
2596
 
2225
2597
  case 60:
 
2598
 
 
2599
/* Line 1455 of yacc.c  */
2226
2600
#line 771 "gram.y"
2227
 
    { yyval.stmt = yyvsp[0].stmt; ;}
 
2601
    { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2228
2602
    break;
2229
2603
 
2230
2604
  case 61:
 
2605
 
 
2606
/* Line 1455 of yacc.c  */
2231
2607
#line 773 "gram.y"
2232
 
    { yyval.stmt = yyvsp[0].stmt; ;}
 
2608
    { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2233
2609
    break;
2234
2610
 
2235
2611
  case 62:
 
2612
 
 
2613
/* Line 1455 of yacc.c  */
2236
2614
#line 775 "gram.y"
2237
 
    { yyval.stmt = yyvsp[0].stmt; ;}
 
2615
    { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2238
2616
    break;
2239
2617
 
2240
2618
  case 63:
 
2619
 
 
2620
/* Line 1455 of yacc.c  */
2241
2621
#line 777 "gram.y"
2242
 
    { yyval.stmt = yyvsp[0].stmt; ;}
 
2622
    { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2243
2623
    break;
2244
2624
 
2245
2625
  case 64:
 
2626
 
 
2627
/* Line 1455 of yacc.c  */
2246
2628
#line 779 "gram.y"
2247
 
    { yyval.stmt = yyvsp[0].stmt; ;}
 
2629
    { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2248
2630
    break;
2249
2631
 
2250
2632
  case 65:
 
2633
 
 
2634
/* Line 1455 of yacc.c  */
2251
2635
#line 781 "gram.y"
2252
 
    { yyval.stmt = yyvsp[0].stmt; ;}
 
2636
    { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2253
2637
    break;
2254
2638
 
2255
2639
  case 66:
 
2640
 
 
2641
/* Line 1455 of yacc.c  */
2256
2642
#line 783 "gram.y"
2257
 
    { yyval.stmt = yyvsp[0].stmt; ;}
 
2643
    { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2258
2644
    break;
2259
2645
 
2260
2646
  case 67:
 
2647
 
 
2648
/* Line 1455 of yacc.c  */
2261
2649
#line 785 "gram.y"
2262
 
    { yyval.stmt = yyvsp[0].stmt; ;}
 
2650
    { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2263
2651
    break;
2264
2652
 
2265
2653
  case 68:
 
2654
 
 
2655
/* Line 1455 of yacc.c  */
2266
2656
#line 787 "gram.y"
2267
 
    { yyval.stmt = yyvsp[0].stmt; ;}
 
2657
    { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2268
2658
    break;
2269
2659
 
2270
2660
  case 69:
 
2661
 
 
2662
/* Line 1455 of yacc.c  */
2271
2663
#line 789 "gram.y"
2272
 
    { yyval.stmt = yyvsp[0].stmt; ;}
 
2664
    { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2273
2665
    break;
2274
2666
 
2275
2667
  case 70:
 
2668
 
 
2669
/* Line 1455 of yacc.c  */
2276
2670
#line 791 "gram.y"
2277
 
    { yyval.stmt = yyvsp[0].stmt; ;}
 
2671
    { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2278
2672
    break;
2279
2673
 
2280
2674
  case 71:
 
2675
 
 
2676
/* Line 1455 of yacc.c  */
2281
2677
#line 793 "gram.y"
2282
 
    { yyval.stmt = yyvsp[0].stmt; ;}
 
2678
    { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2283
2679
    break;
2284
2680
 
2285
2681
  case 72:
 
2682
 
 
2683
/* Line 1455 of yacc.c  */
2286
2684
#line 795 "gram.y"
2287
 
    { yyval.stmt = yyvsp[0].stmt; ;}
 
2685
    { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2288
2686
    break;
2289
2687
 
2290
2688
  case 73:
 
2689
 
 
2690
/* Line 1455 of yacc.c  */
2291
2691
#line 797 "gram.y"
2292
 
    { yyval.stmt = yyvsp[0].stmt; ;}
 
2692
    { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2293
2693
    break;
2294
2694
 
2295
2695
  case 74:
 
2696
 
 
2697
/* Line 1455 of yacc.c  */
2296
2698
#line 799 "gram.y"
2297
 
    { yyval.stmt = yyvsp[0].stmt; ;}
 
2699
    { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2298
2700
    break;
2299
2701
 
2300
2702
  case 75:
 
2703
 
 
2704
/* Line 1455 of yacc.c  */
2301
2705
#line 801 "gram.y"
2302
 
    { yyval.stmt = yyvsp[0].stmt; ;}
 
2706
    { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2303
2707
    break;
2304
2708
 
2305
2709
  case 76:
 
2710
 
 
2711
/* Line 1455 of yacc.c  */
2306
2712
#line 803 "gram.y"
2307
 
    { yyval.stmt = yyvsp[0].stmt; ;}
 
2713
    { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2308
2714
    break;
2309
2715
 
2310
2716
  case 77:
 
2717
 
 
2718
/* Line 1455 of yacc.c  */
2311
2719
#line 805 "gram.y"
2312
 
    { yyval.stmt = yyvsp[0].stmt; ;}
 
2720
    { (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
2313
2721
    break;
2314
2722
 
2315
2723
  case 78:
 
2724
 
 
2725
/* Line 1455 of yacc.c  */
2316
2726
#line 809 "gram.y"
2317
2727
    {
2318
2728
                                                PLpgSQL_stmt_perform *new;
2319
2729
 
2320
2730
                                                new = palloc0(sizeof(PLpgSQL_stmt_perform));
2321
2731
                                                new->cmd_type = PLPGSQL_STMT_PERFORM;
2322
 
                                                new->lineno   = plpgsql_location_to_lineno(yylsp[-1]);
2323
 
                                                new->expr  = yyvsp[0].expr;
 
2732
                                                new->lineno   = plpgsql_location_to_lineno((yylsp[(1) - (2)]));
 
2733
                                                new->expr  = (yyvsp[(2) - (2)].expr);
2324
2734
 
2325
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
2735
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
2326
2736
                                        ;}
2327
2737
    break;
2328
2738
 
2329
2739
  case 79:
 
2740
 
 
2741
/* Line 1455 of yacc.c  */
2330
2742
#line 822 "gram.y"
2331
2743
    {
2332
2744
                                                PLpgSQL_stmt_assign *new;
2333
2745
 
2334
2746
                                                new = palloc0(sizeof(PLpgSQL_stmt_assign));
2335
2747
                                                new->cmd_type = PLPGSQL_STMT_ASSIGN;
2336
 
                                                new->lineno   = plpgsql_location_to_lineno(yylsp[-2]);
2337
 
                                                new->varno = yyvsp[-2].ival;
2338
 
                                                new->expr  = yyvsp[0].expr;
 
2748
                                                new->lineno   = plpgsql_location_to_lineno((yylsp[(1) - (3)]));
 
2749
                                                new->varno = (yyvsp[(1) - (3)].ival);
 
2750
                                                new->expr  = (yyvsp[(3) - (3)].expr);
2339
2751
 
2340
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
2752
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
2341
2753
                                        ;}
2342
2754
    break;
2343
2755
 
2344
2756
  case 80:
 
2757
 
 
2758
/* Line 1455 of yacc.c  */
2345
2759
#line 836 "gram.y"
2346
2760
    {
2347
2761
                                                PLpgSQL_stmt_getdiag     *new;
2348
2762
 
2349
2763
                                                new = palloc0(sizeof(PLpgSQL_stmt_getdiag));
2350
2764
                                                new->cmd_type = PLPGSQL_STMT_GETDIAG;
2351
 
                                                new->lineno   = plpgsql_location_to_lineno(yylsp[-3]);
2352
 
                                                new->diag_items  = yyvsp[-1].list;
 
2765
                                                new->lineno   = plpgsql_location_to_lineno((yylsp[(1) - (4)]));
 
2766
                                                new->diag_items  = (yyvsp[(3) - (4)].list);
2353
2767
 
2354
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
2768
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
2355
2769
                                        ;}
2356
2770
    break;
2357
2771
 
2358
2772
  case 81:
 
2773
 
 
2774
/* Line 1455 of yacc.c  */
2359
2775
#line 849 "gram.y"
2360
2776
    {
2361
 
                                                yyval.list = lappend(yyvsp[-2].list, yyvsp[0].diagitem);
 
2777
                                                (yyval.list) = lappend((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].diagitem));
2362
2778
                                        ;}
2363
2779
    break;
2364
2780
 
2365
2781
  case 82:
 
2782
 
 
2783
/* Line 1455 of yacc.c  */
2366
2784
#line 853 "gram.y"
2367
2785
    {
2368
 
                                                yyval.list = list_make1(yyvsp[0].diagitem);
 
2786
                                                (yyval.list) = list_make1((yyvsp[(1) - (1)].diagitem));
2369
2787
                                        ;}
2370
2788
    break;
2371
2789
 
2372
2790
  case 83:
 
2791
 
 
2792
/* Line 1455 of yacc.c  */
2373
2793
#line 859 "gram.y"
2374
2794
    {
2375
2795
                                                PLpgSQL_diag_item *new;
2376
2796
 
2377
2797
                                                new = palloc(sizeof(PLpgSQL_diag_item));
2378
 
                                                new->target = yyvsp[-2].ival;
2379
 
                                                new->kind = yyvsp[0].ival;
 
2798
                                                new->target = (yyvsp[(1) - (3)].ival);
 
2799
                                                new->kind = (yyvsp[(3) - (3)].ival);
2380
2800
 
2381
 
                                                yyval.diagitem = new;
 
2801
                                                (yyval.diagitem) = new;
2382
2802
                                        ;}
2383
2803
    break;
2384
2804
 
2385
2805
  case 84:
 
2806
 
 
2807
/* Line 1455 of yacc.c  */
2386
2808
#line 871 "gram.y"
2387
2809
    {
2388
2810
                                                int     tok = yylex();
2389
2811
 
2390
2812
                                                if (tok_is_keyword(tok, &yylval,
2391
2813
                                                                                   K_ROW_COUNT, "row_count"))
2392
 
                                                        yyval.ival = PLPGSQL_GETDIAG_ROW_COUNT;
 
2814
                                                        (yyval.ival) = PLPGSQL_GETDIAG_ROW_COUNT;
2393
2815
                                                else if (tok_is_keyword(tok, &yylval,
2394
2816
                                                                                                K_RESULT_OID, "result_oid"))
2395
 
                                                        yyval.ival = PLPGSQL_GETDIAG_RESULT_OID;
 
2817
                                                        (yyval.ival) = PLPGSQL_GETDIAG_RESULT_OID;
2396
2818
                                                else
2397
2819
                                                        yyerror("unrecognized GET DIAGNOSTICS item");
2398
2820
                                        ;}
2399
2821
    break;
2400
2822
 
2401
2823
  case 85:
 
2824
 
 
2825
/* Line 1455 of yacc.c  */
2402
2826
#line 886 "gram.y"
2403
2827
    {
2404
 
                                                check_assignable(yyvsp[0].wdatum.datum, yylsp[0]);
2405
 
                                                if (yyvsp[0].wdatum.datum->dtype == PLPGSQL_DTYPE_ROW ||
2406
 
                                                        yyvsp[0].wdatum.datum->dtype == PLPGSQL_DTYPE_REC)
 
2828
                                                check_assignable((yyvsp[(1) - (1)].wdatum).datum, (yylsp[(1) - (1)]));
 
2829
                                                if ((yyvsp[(1) - (1)].wdatum).datum->dtype == PLPGSQL_DTYPE_ROW ||
 
2830
                                                        (yyvsp[(1) - (1)].wdatum).datum->dtype == PLPGSQL_DTYPE_REC)
2407
2831
                                                        ereport(ERROR,
2408
2832
                                                                        (errcode(ERRCODE_SYNTAX_ERROR),
2409
2833
                                                                         errmsg("\"%s\" is not a scalar variable",
2410
 
                                                                                        NameOfDatum(&(yyvsp[0].wdatum))),
2411
 
                                                                         parser_errposition(yylsp[0])));
2412
 
                                                yyval.ival = yyvsp[0].wdatum.datum->dno;
 
2834
                                                                                        NameOfDatum(&((yyvsp[(1) - (1)].wdatum)))),
 
2835
                                                                         parser_errposition((yylsp[(1) - (1)]))));
 
2836
                                                (yyval.ival) = (yyvsp[(1) - (1)].wdatum).datum->dno;
2413
2837
                                        ;}
2414
2838
    break;
2415
2839
 
2416
2840
  case 86:
 
2841
 
 
2842
/* Line 1455 of yacc.c  */
2417
2843
#line 898 "gram.y"
2418
2844
    {
2419
2845
                                                /* just to give a better message than "syntax error" */
2420
 
                                                word_is_not_variable(&(yyvsp[0].word), yylsp[0]);
 
2846
                                                word_is_not_variable(&((yyvsp[(1) - (1)].word)), (yylsp[(1) - (1)]));
2421
2847
                                        ;}
2422
2848
    break;
2423
2849
 
2424
2850
  case 87:
 
2851
 
 
2852
/* Line 1455 of yacc.c  */
2425
2853
#line 903 "gram.y"
2426
2854
    {
2427
2855
                                                /* just to give a better message than "syntax error" */
2428
 
                                                cword_is_not_variable(&(yyvsp[0].cword), yylsp[0]);
 
2856
                                                cword_is_not_variable(&((yyvsp[(1) - (1)].cword)), (yylsp[(1) - (1)]));
2429
2857
                                        ;}
2430
2858
    break;
2431
2859
 
2432
2860
  case 88:
 
2861
 
 
2862
/* Line 1455 of yacc.c  */
2433
2863
#line 911 "gram.y"
2434
2864
    {
2435
 
                                                check_assignable(yyvsp[0].wdatum.datum, yylsp[0]);
2436
 
                                                yyval.ival = yyvsp[0].wdatum.datum->dno;
 
2865
                                                check_assignable((yyvsp[(1) - (1)].wdatum).datum, (yylsp[(1) - (1)]));
 
2866
                                                (yyval.ival) = (yyvsp[(1) - (1)].wdatum).datum->dno;
2437
2867
                                        ;}
2438
2868
    break;
2439
2869
 
2440
2870
  case 89:
 
2871
 
 
2872
/* Line 1455 of yacc.c  */
2441
2873
#line 916 "gram.y"
2442
2874
    {
2443
2875
                                                PLpgSQL_arrayelem       *new;
2444
2876
 
2445
2877
                                                new = palloc0(sizeof(PLpgSQL_arrayelem));
2446
2878
                                                new->dtype              = PLPGSQL_DTYPE_ARRAYELEM;
2447
 
                                                new->subscript  = yyvsp[0].expr;
2448
 
                                                new->arrayparentno = yyvsp[-2].ival;
 
2879
                                                new->subscript  = (yyvsp[(3) - (3)].expr);
 
2880
                                                new->arrayparentno = (yyvsp[(1) - (3)].ival);
2449
2881
 
2450
2882
                                                plpgsql_adddatum((PLpgSQL_datum *) new);
2451
2883
 
2452
 
                                                yyval.ival = new->dno;
 
2884
                                                (yyval.ival) = new->dno;
2453
2885
                                        ;}
2454
2886
    break;
2455
2887
 
2456
2888
  case 90:
 
2889
 
 
2890
/* Line 1455 of yacc.c  */
2457
2891
#line 931 "gram.y"
2458
2892
    {
2459
2893
                                                PLpgSQL_stmt_if *new;
2460
2894
 
2461
2895
                                                new = palloc0(sizeof(PLpgSQL_stmt_if));
2462
2896
                                                new->cmd_type   = PLPGSQL_STMT_IF;
2463
 
                                                new->lineno             = plpgsql_location_to_lineno(yylsp[-6]);
2464
 
                                                new->cond               = yyvsp[-5].expr;
2465
 
                                                new->true_body  = yyvsp[-4].list;
2466
 
                                                new->false_body = yyvsp[-3].list;
 
2897
                                                new->lineno             = plpgsql_location_to_lineno((yylsp[(1) - (7)]));
 
2898
                                                new->cond               = (yyvsp[(2) - (7)].expr);
 
2899
                                                new->true_body  = (yyvsp[(3) - (7)].list);
 
2900
                                                new->false_body = (yyvsp[(4) - (7)].list);
2467
2901
 
2468
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
2902
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
2469
2903
                                        ;}
2470
2904
    break;
2471
2905
 
2472
2906
  case 91:
 
2907
 
 
2908
/* Line 1455 of yacc.c  */
2473
2909
#line 946 "gram.y"
2474
2910
    {
2475
 
                                                yyval.list = NIL;
 
2911
                                                (yyval.list) = NIL;
2476
2912
                                        ;}
2477
2913
    break;
2478
2914
 
2479
2915
  case 92:
 
2916
 
 
2917
/* Line 1455 of yacc.c  */
2480
2918
#line 950 "gram.y"
2481
2919
    {
2482
2920
                                                /*----------
2498
2936
                                                /* first create a new if-statement */
2499
2937
                                                new_if = palloc0(sizeof(PLpgSQL_stmt_if));
2500
2938
                                                new_if->cmd_type        = PLPGSQL_STMT_IF;
2501
 
                                                new_if->lineno          = plpgsql_location_to_lineno(yylsp[-3]);
2502
 
                                                new_if->cond            = yyvsp[-2].expr;
2503
 
                                                new_if->true_body       = yyvsp[-1].list;
2504
 
                                                new_if->false_body      = yyvsp[0].list;
 
2939
                                                new_if->lineno          = plpgsql_location_to_lineno((yylsp[(1) - (4)]));
 
2940
                                                new_if->cond            = (yyvsp[(2) - (4)].expr);
 
2941
                                                new_if->true_body       = (yyvsp[(3) - (4)].list);
 
2942
                                                new_if->false_body      = (yyvsp[(4) - (4)].list);
2505
2943
 
2506
2944
                                                /* wrap the if-statement in a "container" list */
2507
 
                                                yyval.list = list_make1(new_if);
 
2945
                                                (yyval.list) = list_make1(new_if);
2508
2946
                                        ;}
2509
2947
    break;
2510
2948
 
2511
2949
  case 93:
 
2950
 
 
2951
/* Line 1455 of yacc.c  */
2512
2952
#line 980 "gram.y"
2513
2953
    {
2514
 
                                                yyval.list = yyvsp[0].list;
 
2954
                                                (yyval.list) = (yyvsp[(2) - (2)].list);
2515
2955
                                        ;}
2516
2956
    break;
2517
2957
 
2518
2958
  case 94:
 
2959
 
 
2960
/* Line 1455 of yacc.c  */
2519
2961
#line 986 "gram.y"
2520
2962
    {
2521
 
                                                yyval.stmt = make_case(yylsp[-6], yyvsp[-5].expr, yyvsp[-4].list, yyvsp[-3].list);
 
2963
                                                (yyval.stmt) = make_case((yylsp[(1) - (7)]), (yyvsp[(2) - (7)].expr), (yyvsp[(3) - (7)].list), (yyvsp[(4) - (7)].list));
2522
2964
                                        ;}
2523
2965
    break;
2524
2966
 
2525
2967
  case 95:
 
2968
 
 
2969
/* Line 1455 of yacc.c  */
2526
2970
#line 992 "gram.y"
2527
2971
    {
2528
2972
                                                PLpgSQL_expr *expr = NULL;
2534
2978
                                                        expr = read_sql_expression(K_WHEN, "WHEN");
2535
2979
                                                }
2536
2980
                                                plpgsql_push_back_token(K_WHEN);
2537
 
                                                yyval.expr = expr;
 
2981
                                                (yyval.expr) = expr;
2538
2982
                                        ;}
2539
2983
    break;
2540
2984
 
2541
2985
  case 96:
 
2986
 
 
2987
/* Line 1455 of yacc.c  */
2542
2988
#line 1007 "gram.y"
2543
2989
    {
2544
 
                                                yyval.list = lappend(yyvsp[-1].list, yyvsp[0].casewhen);
 
2990
                                                (yyval.list) = lappend((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].casewhen));
2545
2991
                                        ;}
2546
2992
    break;
2547
2993
 
2548
2994
  case 97:
 
2995
 
 
2996
/* Line 1455 of yacc.c  */
2549
2997
#line 1011 "gram.y"
2550
2998
    {
2551
 
                                                yyval.list = list_make1(yyvsp[0].casewhen);
 
2999
                                                (yyval.list) = list_make1((yyvsp[(1) - (1)].casewhen));
2552
3000
                                        ;}
2553
3001
    break;
2554
3002
 
2555
3003
  case 98:
 
3004
 
 
3005
/* Line 1455 of yacc.c  */
2556
3006
#line 1017 "gram.y"
2557
3007
    {
2558
3008
                                                PLpgSQL_case_when *new = palloc(sizeof(PLpgSQL_case_when));
2559
3009
 
2560
 
                                                new->lineno     = plpgsql_location_to_lineno(yylsp[-2]);
2561
 
                                                new->expr       = yyvsp[-1].expr;
2562
 
                                                new->stmts      = yyvsp[0].list;
2563
 
                                                yyval.casewhen = new;
 
3010
                                                new->lineno     = plpgsql_location_to_lineno((yylsp[(1) - (3)]));
 
3011
                                                new->expr       = (yyvsp[(2) - (3)].expr);
 
3012
                                                new->stmts      = (yyvsp[(3) - (3)].list);
 
3013
                                                (yyval.casewhen) = new;
2564
3014
                                        ;}
2565
3015
    break;
2566
3016
 
2567
3017
  case 99:
 
3018
 
 
3019
/* Line 1455 of yacc.c  */
2568
3020
#line 1028 "gram.y"
2569
3021
    {
2570
 
                                                yyval.list = NIL;
 
3022
                                                (yyval.list) = NIL;
2571
3023
                                        ;}
2572
3024
    break;
2573
3025
 
2574
3026
  case 100:
 
3027
 
 
3028
/* Line 1455 of yacc.c  */
2575
3029
#line 1032 "gram.y"
2576
3030
    {
2577
3031
                                                /*
2580
3034
                                                 * Simplest fix is to return a list with one NULL
2581
3035
                                                 * pointer, which make_case() must take care of.
2582
3036
                                                 */
2583
 
                                                if (yyvsp[0].list != NIL)
2584
 
                                                        yyval.list = yyvsp[0].list;
 
3037
                                                if ((yyvsp[(2) - (2)].list) != NIL)
 
3038
                                                        (yyval.list) = (yyvsp[(2) - (2)].list);
2585
3039
                                                else
2586
 
                                                        yyval.list = list_make1(NULL);
 
3040
                                                        (yyval.list) = list_make1(NULL);
2587
3041
                                        ;}
2588
3042
    break;
2589
3043
 
2590
3044
  case 101:
 
3045
 
 
3046
/* Line 1455 of yacc.c  */
2591
3047
#line 1047 "gram.y"
2592
3048
    {
2593
3049
                                                PLpgSQL_stmt_loop *new;
2594
3050
 
2595
3051
                                                new = palloc0(sizeof(PLpgSQL_stmt_loop));
2596
3052
                                                new->cmd_type = PLPGSQL_STMT_LOOP;
2597
 
                                                new->lineno   = plpgsql_location_to_lineno(yylsp[-1]);
2598
 
                                                new->label        = yyvsp[-2].str;
2599
 
                                                new->body         = yyvsp[0].loop_body.stmts;
 
3053
                                                new->lineno   = plpgsql_location_to_lineno((yylsp[(2) - (3)]));
 
3054
                                                new->label        = (yyvsp[(1) - (3)].str);
 
3055
                                                new->body         = (yyvsp[(3) - (3)].loop_body).stmts;
2600
3056
 
2601
 
                                                check_labels(yyvsp[-2].str, yyvsp[0].loop_body.end_label, yyvsp[0].loop_body.end_label_location);
 
3057
                                                check_labels((yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].loop_body).end_label, (yyvsp[(3) - (3)].loop_body).end_label_location);
2602
3058
                                                plpgsql_ns_pop();
2603
3059
 
2604
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
3060
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
2605
3061
                                        ;}
2606
3062
    break;
2607
3063
 
2608
3064
  case 102:
 
3065
 
 
3066
/* Line 1455 of yacc.c  */
2609
3067
#line 1064 "gram.y"
2610
3068
    {
2611
3069
                                                PLpgSQL_stmt_while *new;
2612
3070
 
2613
3071
                                                new = palloc0(sizeof(PLpgSQL_stmt_while));
2614
3072
                                                new->cmd_type = PLPGSQL_STMT_WHILE;
2615
 
                                                new->lineno   = plpgsql_location_to_lineno(yylsp[-2]);
2616
 
                                                new->label        = yyvsp[-3].str;
2617
 
                                                new->cond         = yyvsp[-1].expr;
2618
 
                                                new->body         = yyvsp[0].loop_body.stmts;
 
3073
                                                new->lineno   = plpgsql_location_to_lineno((yylsp[(2) - (4)]));
 
3074
                                                new->label        = (yyvsp[(1) - (4)].str);
 
3075
                                                new->cond         = (yyvsp[(3) - (4)].expr);
 
3076
                                                new->body         = (yyvsp[(4) - (4)].loop_body).stmts;
2619
3077
 
2620
 
                                                check_labels(yyvsp[-3].str, yyvsp[0].loop_body.end_label, yyvsp[0].loop_body.end_label_location);
 
3078
                                                check_labels((yyvsp[(1) - (4)].str), (yyvsp[(4) - (4)].loop_body).end_label, (yyvsp[(4) - (4)].loop_body).end_label_location);
2621
3079
                                                plpgsql_ns_pop();
2622
3080
 
2623
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
3081
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
2624
3082
                                        ;}
2625
3083
    break;
2626
3084
 
2627
3085
  case 103:
 
3086
 
 
3087
/* Line 1455 of yacc.c  */
2628
3088
#line 1082 "gram.y"
2629
3089
    {
2630
3090
                                                /* This runs after we've scanned the loop body */
2631
 
                                                if (yyvsp[-1].stmt->cmd_type == PLPGSQL_STMT_FORI)
 
3091
                                                if ((yyvsp[(3) - (4)].stmt)->cmd_type == PLPGSQL_STMT_FORI)
2632
3092
                                                {
2633
3093
                                                        PLpgSQL_stmt_fori               *new;
2634
3094
 
2635
 
                                                        new = (PLpgSQL_stmt_fori *) yyvsp[-1].stmt;
2636
 
                                                        new->lineno   = plpgsql_location_to_lineno(yylsp[-2]);
2637
 
                                                        new->label        = yyvsp[-3].str;
2638
 
                                                        new->body         = yyvsp[0].loop_body.stmts;
2639
 
                                                        yyval.stmt = (PLpgSQL_stmt *) new;
 
3095
                                                        new = (PLpgSQL_stmt_fori *) (yyvsp[(3) - (4)].stmt);
 
3096
                                                        new->lineno   = plpgsql_location_to_lineno((yylsp[(2) - (4)]));
 
3097
                                                        new->label        = (yyvsp[(1) - (4)].str);
 
3098
                                                        new->body         = (yyvsp[(4) - (4)].loop_body).stmts;
 
3099
                                                        (yyval.stmt) = (PLpgSQL_stmt *) new;
2640
3100
                                                }
2641
3101
                                                else
2642
3102
                                                {
2643
3103
                                                        PLpgSQL_stmt_forq               *new;
2644
3104
 
2645
 
                                                        Assert(yyvsp[-1].stmt->cmd_type == PLPGSQL_STMT_FORS ||
2646
 
                                                                   yyvsp[-1].stmt->cmd_type == PLPGSQL_STMT_FORC ||
2647
 
                                                                   yyvsp[-1].stmt->cmd_type == PLPGSQL_STMT_DYNFORS);
 
3105
                                                        Assert((yyvsp[(3) - (4)].stmt)->cmd_type == PLPGSQL_STMT_FORS ||
 
3106
                                                                   (yyvsp[(3) - (4)].stmt)->cmd_type == PLPGSQL_STMT_FORC ||
 
3107
                                                                   (yyvsp[(3) - (4)].stmt)->cmd_type == PLPGSQL_STMT_DYNFORS);
2648
3108
                                                        /* forq is the common supertype of all three */
2649
 
                                                        new = (PLpgSQL_stmt_forq *) yyvsp[-1].stmt;
2650
 
                                                        new->lineno   = plpgsql_location_to_lineno(yylsp[-2]);
2651
 
                                                        new->label        = yyvsp[-3].str;
2652
 
                                                        new->body         = yyvsp[0].loop_body.stmts;
2653
 
                                                        yyval.stmt = (PLpgSQL_stmt *) new;
 
3109
                                                        new = (PLpgSQL_stmt_forq *) (yyvsp[(3) - (4)].stmt);
 
3110
                                                        new->lineno   = plpgsql_location_to_lineno((yylsp[(2) - (4)]));
 
3111
                                                        new->label        = (yyvsp[(1) - (4)].str);
 
3112
                                                        new->body         = (yyvsp[(4) - (4)].loop_body).stmts;
 
3113
                                                        (yyval.stmt) = (PLpgSQL_stmt *) new;
2654
3114
                                                }
2655
3115
 
2656
 
                                                check_labels(yyvsp[-3].str, yyvsp[0].loop_body.end_label, yyvsp[0].loop_body.end_label_location);
 
3116
                                                check_labels((yyvsp[(1) - (4)].str), (yyvsp[(4) - (4)].loop_body).end_label, (yyvsp[(4) - (4)].loop_body).end_label_location);
2657
3117
                                                /* close namespace started in opt_block_label */
2658
3118
                                                plpgsql_ns_pop();
2659
3119
                                        ;}
2660
3120
    break;
2661
3121
 
2662
3122
  case 104:
 
3123
 
 
3124
/* Line 1455 of yacc.c  */
2663
3125
#line 1116 "gram.y"
2664
3126
    {
2665
3127
                                                int                     tok = yylex();
2678
3140
 
2679
3141
                                                        new = palloc0(sizeof(PLpgSQL_stmt_dynfors));
2680
3142
                                                        new->cmd_type = PLPGSQL_STMT_DYNFORS;
2681
 
                                                        if (yyvsp[-1].forvariable.rec)
2682
 
                                                        {
2683
 
                                                                new->rec = yyvsp[-1].forvariable.rec;
2684
 
                                                                check_assignable((PLpgSQL_datum *) new->rec, yylsp[-1]);
2685
 
                                                        }
2686
 
                                                        else if (yyvsp[-1].forvariable.row)
2687
 
                                                        {
2688
 
                                                                new->row = yyvsp[-1].forvariable.row;
2689
 
                                                                check_assignable((PLpgSQL_datum *) new->row, yylsp[-1]);
2690
 
                                                        }
2691
 
                                                        else if (yyvsp[-1].forvariable.scalar)
 
3143
                                                        if ((yyvsp[(1) - (2)].forvariable).rec)
 
3144
                                                        {
 
3145
                                                                new->rec = (yyvsp[(1) - (2)].forvariable).rec;
 
3146
                                                                check_assignable((PLpgSQL_datum *) new->rec, (yylsp[(1) - (2)]));
 
3147
                                                        }
 
3148
                                                        else if ((yyvsp[(1) - (2)].forvariable).row)
 
3149
                                                        {
 
3150
                                                                new->row = (yyvsp[(1) - (2)].forvariable).row;
 
3151
                                                                check_assignable((PLpgSQL_datum *) new->row, (yylsp[(1) - (2)]));
 
3152
                                                        }
 
3153
                                                        else if ((yyvsp[(1) - (2)].forvariable).scalar)
2692
3154
                                                        {
2693
3155
                                                                /* convert single scalar to list */
2694
 
                                                                new->row = make_scalar_list1(yyvsp[-1].forvariable.name, yyvsp[-1].forvariable.scalar,
2695
 
                                                                                                                         yyvsp[-1].forvariable.lineno, yylsp[-1]);
 
3156
                                                                new->row = make_scalar_list1((yyvsp[(1) - (2)].forvariable).name, (yyvsp[(1) - (2)].forvariable).scalar,
 
3157
                                                                                                                         (yyvsp[(1) - (2)].forvariable).lineno, (yylsp[(1) - (2)]));
2696
3158
                                                                /* no need for check_assignable */
2697
3159
                                                        }
2698
3160
                                                        else
2700
3162
                                                                ereport(ERROR,
2701
3163
                                                                                (errcode(ERRCODE_DATATYPE_MISMATCH),
2702
3164
                                                                                 errmsg("loop variable of loop over rows must be a record or row variable or list of scalar variables"),
2703
 
                                                                                 parser_errposition(yylsp[-1])));
 
3165
                                                                                 parser_errposition((yylsp[(1) - (2)]))));
2704
3166
                                                        }
2705
3167
                                                        new->query = expr;
2706
3168
 
2715
3177
                                                                } while (term == ',');
2716
3178
                                                        }
2717
3179
 
2718
 
                                                        yyval.stmt = (PLpgSQL_stmt *) new;
 
3180
                                                        (yyval.stmt) = (PLpgSQL_stmt *) new;
2719
3181
                                                }
2720
3182
                                                else if (tok == T_DATUM &&
2721
3183
                                                                 yylval.wdatum.datum->dtype == PLPGSQL_DTYPE_VAR &&
2730
3192
                                                        new->curvar = cursor->dno;
2731
3193
 
2732
3194
                                                        /* Should have had a single variable name */
2733
 
                                                        if (yyvsp[-1].forvariable.scalar && yyvsp[-1].forvariable.row)
 
3195
                                                        if ((yyvsp[(1) - (2)].forvariable).scalar && (yyvsp[(1) - (2)].forvariable).row)
2734
3196
                                                                ereport(ERROR,
2735
3197
                                                                                (errcode(ERRCODE_SYNTAX_ERROR),
2736
3198
                                                                                 errmsg("cursor FOR loop must have only one target variable"),
2737
 
                                                                                 parser_errposition(yylsp[-1])));
 
3199
                                                                                 parser_errposition((yylsp[(1) - (2)]))));
2738
3200
 
2739
3201
                                                        /* can't use an unbound cursor this way */
2740
3202
                                                        if (cursor->cursor_explicit_expr == NULL)
2749
3211
                                                                                                                         "LOOP");
2750
3212
 
2751
3213
                                                        /* create loop's private RECORD variable */
2752
 
                                                        new->rec = plpgsql_build_record(yyvsp[-1].forvariable.name,
2753
 
                                                                                                                        yyvsp[-1].forvariable.lineno,
 
3214
                                                        new->rec = plpgsql_build_record((yyvsp[(1) - (2)].forvariable).name,
 
3215
                                                                                                                        (yyvsp[(1) - (2)].forvariable).lineno,
2754
3216
                                                                                                                        true);
2755
3217
 
2756
 
                                                        yyval.stmt = (PLpgSQL_stmt *) new;
 
3218
                                                        (yyval.stmt) = (PLpgSQL_stmt *) new;
2757
3219
                                                }
2758
3220
                                                else
2759
3221
                                                {
2820
3282
                                                                        expr_by = NULL;
2821
3283
 
2822
3284
                                                                /* Should have had a single variable name */
2823
 
                                                                if (yyvsp[-1].forvariable.scalar && yyvsp[-1].forvariable.row)
 
3285
                                                                if ((yyvsp[(1) - (2)].forvariable).scalar && (yyvsp[(1) - (2)].forvariable).row)
2824
3286
                                                                        ereport(ERROR,
2825
3287
                                                                                        (errcode(ERRCODE_SYNTAX_ERROR),
2826
3288
                                                                                         errmsg("integer FOR loop must have only one target variable"),
2827
 
                                                                                         parser_errposition(yylsp[-1])));
 
3289
                                                                                         parser_errposition((yylsp[(1) - (2)]))));
2828
3290
 
2829
3291
                                                                /* create loop's private variable */
2830
3292
                                                                fvar = (PLpgSQL_var *)
2831
 
                                                                        plpgsql_build_variable(yyvsp[-1].forvariable.name,
2832
 
                                                                                                                   yyvsp[-1].forvariable.lineno,
 
3293
                                                                        plpgsql_build_variable((yyvsp[(1) - (2)].forvariable).name,
 
3294
                                                                                                                   (yyvsp[(1) - (2)].forvariable).lineno,
2833
3295
                                                                                                                   plpgsql_build_datatype(INT4OID,
2834
3296
                                                                                                                                                                  -1,
2835
3297
                                                                                                                                                                  InvalidOid),
2843
3305
                                                                new->upper        = expr2;
2844
3306
                                                                new->step         = expr_by;
2845
3307
 
2846
 
                                                                yyval.stmt = (PLpgSQL_stmt *) new;
 
3308
                                                                (yyval.stmt) = (PLpgSQL_stmt *) new;
2847
3309
                                                        }
2848
3310
                                                        else
2849
3311
                                                        {
2871
3333
 
2872
3334
                                                                new = palloc0(sizeof(PLpgSQL_stmt_fors));
2873
3335
                                                                new->cmd_type = PLPGSQL_STMT_FORS;
2874
 
                                                                if (yyvsp[-1].forvariable.rec)
2875
 
                                                                {
2876
 
                                                                        new->rec = yyvsp[-1].forvariable.rec;
2877
 
                                                                        check_assignable((PLpgSQL_datum *) new->rec, yylsp[-1]);
2878
 
                                                                }
2879
 
                                                                else if (yyvsp[-1].forvariable.row)
2880
 
                                                                {
2881
 
                                                                        new->row = yyvsp[-1].forvariable.row;
2882
 
                                                                        check_assignable((PLpgSQL_datum *) new->row, yylsp[-1]);
2883
 
                                                                }
2884
 
                                                                else if (yyvsp[-1].forvariable.scalar)
 
3336
                                                                if ((yyvsp[(1) - (2)].forvariable).rec)
 
3337
                                                                {
 
3338
                                                                        new->rec = (yyvsp[(1) - (2)].forvariable).rec;
 
3339
                                                                        check_assignable((PLpgSQL_datum *) new->rec, (yylsp[(1) - (2)]));
 
3340
                                                                }
 
3341
                                                                else if ((yyvsp[(1) - (2)].forvariable).row)
 
3342
                                                                {
 
3343
                                                                        new->row = (yyvsp[(1) - (2)].forvariable).row;
 
3344
                                                                        check_assignable((PLpgSQL_datum *) new->row, (yylsp[(1) - (2)]));
 
3345
                                                                }
 
3346
                                                                else if ((yyvsp[(1) - (2)].forvariable).scalar)
2885
3347
                                                                {
2886
3348
                                                                        /* convert single scalar to list */
2887
 
                                                                        new->row = make_scalar_list1(yyvsp[-1].forvariable.name, yyvsp[-1].forvariable.scalar,
2888
 
                                                                                                                                 yyvsp[-1].forvariable.lineno, yylsp[-1]);
 
3349
                                                                        new->row = make_scalar_list1((yyvsp[(1) - (2)].forvariable).name, (yyvsp[(1) - (2)].forvariable).scalar,
 
3350
                                                                                                                                 (yyvsp[(1) - (2)].forvariable).lineno, (yylsp[(1) - (2)]));
2889
3351
                                                                        /* no need for check_assignable */
2890
3352
                                                                }
2891
3353
                                                                else
2893
3355
                                                                        ereport(ERROR,
2894
3356
                                                                                        (errcode(ERRCODE_SYNTAX_ERROR),
2895
3357
                                                                                         errmsg("loop variable of loop over rows must be a record or row variable or list of scalar variables"),
2896
 
                                                                                         parser_errposition(yylsp[-1])));
 
3358
                                                                                         parser_errposition((yylsp[(1) - (2)]))));
2897
3359
                                                                }
2898
3360
 
2899
3361
                                                                new->query = expr1;
2900
 
                                                                yyval.stmt = (PLpgSQL_stmt *) new;
 
3362
                                                                (yyval.stmt) = (PLpgSQL_stmt *) new;
2901
3363
                                                        }
2902
3364
                                                }
2903
3365
                                        ;}
2904
3366
    break;
2905
3367
 
2906
3368
  case 105:
 
3369
 
 
3370
/* Line 1455 of yacc.c  */
2907
3371
#line 1377 "gram.y"
2908
3372
    {
2909
 
                                                yyval.forvariable.name = NameOfDatum(&(yyvsp[0].wdatum));
2910
 
                                                yyval.forvariable.lineno = plpgsql_location_to_lineno(yylsp[0]);
2911
 
                                                if (yyvsp[0].wdatum.datum->dtype == PLPGSQL_DTYPE_ROW)
 
3373
                                                (yyval.forvariable).name = NameOfDatum(&((yyvsp[(1) - (1)].wdatum)));
 
3374
                                                (yyval.forvariable).lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]));
 
3375
                                                if ((yyvsp[(1) - (1)].wdatum).datum->dtype == PLPGSQL_DTYPE_ROW)
2912
3376
                                                {
2913
 
                                                        yyval.forvariable.scalar = NULL;
2914
 
                                                        yyval.forvariable.rec = NULL;
2915
 
                                                        yyval.forvariable.row = (PLpgSQL_row *) yyvsp[0].wdatum.datum;
 
3377
                                                        (yyval.forvariable).scalar = NULL;
 
3378
                                                        (yyval.forvariable).rec = NULL;
 
3379
                                                        (yyval.forvariable).row = (PLpgSQL_row *) (yyvsp[(1) - (1)].wdatum).datum;
2916
3380
                                                }
2917
 
                                                else if (yyvsp[0].wdatum.datum->dtype == PLPGSQL_DTYPE_REC)
 
3381
                                                else if ((yyvsp[(1) - (1)].wdatum).datum->dtype == PLPGSQL_DTYPE_REC)
2918
3382
                                                {
2919
 
                                                        yyval.forvariable.scalar = NULL;
2920
 
                                                        yyval.forvariable.rec = (PLpgSQL_rec *) yyvsp[0].wdatum.datum;
2921
 
                                                        yyval.forvariable.row = NULL;
 
3383
                                                        (yyval.forvariable).scalar = NULL;
 
3384
                                                        (yyval.forvariable).rec = (PLpgSQL_rec *) (yyvsp[(1) - (1)].wdatum).datum;
 
3385
                                                        (yyval.forvariable).row = NULL;
2922
3386
                                                }
2923
3387
                                                else
2924
3388
                                                {
2925
3389
                                                        int                     tok;
2926
3390
 
2927
 
                                                        yyval.forvariable.scalar = yyvsp[0].wdatum.datum;
2928
 
                                                        yyval.forvariable.rec = NULL;
2929
 
                                                        yyval.forvariable.row = NULL;
 
3391
                                                        (yyval.forvariable).scalar = (yyvsp[(1) - (1)].wdatum).datum;
 
3392
                                                        (yyval.forvariable).rec = NULL;
 
3393
                                                        (yyval.forvariable).row = NULL;
2930
3394
                                                        /* check for comma-separated list */
2931
3395
                                                        tok = yylex();
2932
3396
                                                        plpgsql_push_back_token(tok);
2933
3397
                                                        if (tok == ',')
2934
 
                                                                yyval.forvariable.row = read_into_scalar_list(yyval.forvariable.name,
2935
 
                                                                                                                           yyval.forvariable.scalar,
2936
 
                                                                                                                           yylsp[0]);
 
3398
                                                                (yyval.forvariable).row = read_into_scalar_list((yyval.forvariable).name,
 
3399
                                                                                                                           (yyval.forvariable).scalar,
 
3400
                                                                                                                           (yylsp[(1) - (1)]));
2937
3401
                                                }
2938
3402
                                        ;}
2939
3403
    break;
2940
3404
 
2941
3405
  case 106:
 
3406
 
 
3407
/* Line 1455 of yacc.c  */
2942
3408
#line 1409 "gram.y"
2943
3409
    {
2944
3410
                                                int                     tok;
2945
3411
 
2946
 
                                                yyval.forvariable.name = yyvsp[0].word.ident;
2947
 
                                                yyval.forvariable.lineno = plpgsql_location_to_lineno(yylsp[0]);
2948
 
                                                yyval.forvariable.scalar = NULL;
2949
 
                                                yyval.forvariable.rec = NULL;
2950
 
                                                yyval.forvariable.row = NULL;
 
3412
                                                (yyval.forvariable).name = (yyvsp[(1) - (1)].word).ident;
 
3413
                                                (yyval.forvariable).lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]));
 
3414
                                                (yyval.forvariable).scalar = NULL;
 
3415
                                                (yyval.forvariable).rec = NULL;
 
3416
                                                (yyval.forvariable).row = NULL;
2951
3417
                                                /* check for comma-separated list */
2952
3418
                                                tok = yylex();
2953
3419
                                                plpgsql_push_back_token(tok);
2954
3420
                                                if (tok == ',')
2955
 
                                                        word_is_not_variable(&(yyvsp[0].word), yylsp[0]);
 
3421
                                                        word_is_not_variable(&((yyvsp[(1) - (1)].word)), (yylsp[(1) - (1)]));
2956
3422
                                        ;}
2957
3423
    break;
2958
3424
 
2959
3425
  case 107:
 
3426
 
 
3427
/* Line 1455 of yacc.c  */
2960
3428
#line 1424 "gram.y"
2961
3429
    {
2962
3430
                                                /* just to give a better message than "syntax error" */
2963
 
                                                cword_is_not_variable(&(yyvsp[0].cword), yylsp[0]);
 
3431
                                                cword_is_not_variable(&((yyvsp[(1) - (1)].cword)), (yylsp[(1) - (1)]));
2964
3432
                                        ;}
2965
3433
    break;
2966
3434
 
2967
3435
  case 108:
 
3436
 
 
3437
/* Line 1455 of yacc.c  */
2968
3438
#line 1431 "gram.y"
2969
3439
    {
2970
3440
                                                PLpgSQL_stmt_foreach_a *new;
2971
3441
 
2972
3442
                                                new = palloc0(sizeof(PLpgSQL_stmt_foreach_a));
2973
3443
                                                new->cmd_type = PLPGSQL_STMT_FOREACH_A;
2974
 
                                                new->lineno = plpgsql_location_to_lineno(yylsp[-6]);
2975
 
                                                new->label = yyvsp[-7].str;
2976
 
                                                new->slice = yyvsp[-4].ival;
2977
 
                                                new->expr = yyvsp[-1].expr;
2978
 
                                                new->body = yyvsp[0].loop_body.stmts;
 
3444
                                                new->lineno = plpgsql_location_to_lineno((yylsp[(2) - (8)]));
 
3445
                                                new->label = (yyvsp[(1) - (8)].str);
 
3446
                                                new->slice = (yyvsp[(4) - (8)].ival);
 
3447
                                                new->expr = (yyvsp[(7) - (8)].expr);
 
3448
                                                new->body = (yyvsp[(8) - (8)].loop_body).stmts;
2979
3449
 
2980
 
                                                if (yyvsp[-5].forvariable.rec)
2981
 
                                                {
2982
 
                                                        new->varno = yyvsp[-5].forvariable.rec->dno;
2983
 
                                                        check_assignable((PLpgSQL_datum *) yyvsp[-5].forvariable.rec, yylsp[-5]);
2984
 
                                                }
2985
 
                                                else if (yyvsp[-5].forvariable.row)
2986
 
                                                {
2987
 
                                                        new->varno = yyvsp[-5].forvariable.row->dno;
2988
 
                                                        check_assignable((PLpgSQL_datum *) yyvsp[-5].forvariable.row, yylsp[-5]);
2989
 
                                                }
2990
 
                                                else if (yyvsp[-5].forvariable.scalar)
2991
 
                                                {
2992
 
                                                        new->varno = yyvsp[-5].forvariable.scalar->dno;
2993
 
                                                        check_assignable(yyvsp[-5].forvariable.scalar, yylsp[-5]);
 
3450
                                                if ((yyvsp[(3) - (8)].forvariable).rec)
 
3451
                                                {
 
3452
                                                        new->varno = (yyvsp[(3) - (8)].forvariable).rec->dno;
 
3453
                                                        check_assignable((PLpgSQL_datum *) (yyvsp[(3) - (8)].forvariable).rec, (yylsp[(3) - (8)]));
 
3454
                                                }
 
3455
                                                else if ((yyvsp[(3) - (8)].forvariable).row)
 
3456
                                                {
 
3457
                                                        new->varno = (yyvsp[(3) - (8)].forvariable).row->dno;
 
3458
                                                        check_assignable((PLpgSQL_datum *) (yyvsp[(3) - (8)].forvariable).row, (yylsp[(3) - (8)]));
 
3459
                                                }
 
3460
                                                else if ((yyvsp[(3) - (8)].forvariable).scalar)
 
3461
                                                {
 
3462
                                                        new->varno = (yyvsp[(3) - (8)].forvariable).scalar->dno;
 
3463
                                                        check_assignable((yyvsp[(3) - (8)].forvariable).scalar, (yylsp[(3) - (8)]));
2994
3464
                                                }
2995
3465
                                                else
2996
3466
                                                {
2997
3467
                                                        ereport(ERROR,
2998
3468
                                                                        (errcode(ERRCODE_SYNTAX_ERROR),
2999
3469
                                                                         errmsg("loop variable of FOREACH must be a known variable or list of variables"),
3000
 
                                                                                         parser_errposition(yylsp[-5])));
 
3470
                                                                                         parser_errposition((yylsp[(3) - (8)]))));
3001
3471
                                                }
3002
3472
 
3003
 
                                                check_labels(yyvsp[-7].str, yyvsp[0].loop_body.end_label, yyvsp[0].loop_body.end_label_location);
 
3473
                                                check_labels((yyvsp[(1) - (8)].str), (yyvsp[(8) - (8)].loop_body).end_label, (yyvsp[(8) - (8)].loop_body).end_label_location);
3004
3474
                                                plpgsql_ns_pop();
3005
3475
 
3006
 
                                                yyval.stmt = (PLpgSQL_stmt *) new;
 
3476
                                                (yyval.stmt) = (PLpgSQL_stmt *) new;
3007
3477
                                        ;}
3008
3478
    break;
3009
3479
 
3010
3480
  case 109:
 
3481
 
 
3482
/* Line 1455 of yacc.c  */
3011
3483
#line 1473 "gram.y"
3012
3484
    {
3013
 
                                                yyval.ival = 0;
 
3485
                                                (yyval.ival) = 0;
3014
3486
                                        ;}
3015
3487
    break;
3016
3488
 
3017
3489
  case 110:
 
3490
 
 
3491
/* Line 1455 of yacc.c  */
3018
3492
#line 1477 "gram.y"
3019
3493
    {
3020
 
                                                yyval.ival = yyvsp[0].ival;
 
3494
                                                (yyval.ival) = (yyvsp[(2) - (2)].ival);
3021
3495
                                        ;}
3022
3496
    break;
3023
3497
 
3024
3498
  case 111:
 
3499
 
 
3500
/* Line 1455 of yacc.c  */
3025
3501
#line 1483 "gram.y"
3026
3502
    {
3027
3503
                                                PLpgSQL_stmt_exit *new;
3028
3504
 
3029
3505
                                                new = palloc0(sizeof(PLpgSQL_stmt_exit));
3030
3506
                                                new->cmd_type = PLPGSQL_STMT_EXIT;
3031
 
                                                new->is_exit  = yyvsp[-2].boolean;
3032
 
                                                new->lineno       = plpgsql_location_to_lineno(yylsp[-2]);
3033
 
                                                new->label        = yyvsp[-1].str;
3034
 
                                                new->cond         = yyvsp[0].expr;
 
3507
                                                new->is_exit  = (yyvsp[(1) - (3)].boolean);
 
3508
                                                new->lineno       = plpgsql_location_to_lineno((yylsp[(1) - (3)]));
 
3509
                                                new->label        = (yyvsp[(2) - (3)].str);
 
3510
                                                new->cond         = (yyvsp[(3) - (3)].expr);
3035
3511
 
3036
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
3512
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
3037
3513
                                        ;}
3038
3514
    break;
3039
3515
 
3040
3516
  case 112:
 
3517
 
 
3518
/* Line 1455 of yacc.c  */
3041
3519
#line 1498 "gram.y"
3042
3520
    {
3043
 
                                                yyval.boolean = true;
 
3521
                                                (yyval.boolean) = true;
3044
3522
                                        ;}
3045
3523
    break;
3046
3524
 
3047
3525
  case 113:
 
3526
 
 
3527
/* Line 1455 of yacc.c  */
3048
3528
#line 1502 "gram.y"
3049
3529
    {
3050
 
                                                yyval.boolean = false;
 
3530
                                                (yyval.boolean) = false;
3051
3531
                                        ;}
3052
3532
    break;
3053
3533
 
3054
3534
  case 114:
 
3535
 
 
3536
/* Line 1455 of yacc.c  */
3055
3537
#line 1508 "gram.y"
3056
3538
    {
3057
3539
                                                int     tok;
3063
3545
                                                if (tok_is_keyword(tok, &yylval,
3064
3546
                                                                                   K_NEXT, "next"))
3065
3547
                                                {
3066
 
                                                        yyval.stmt = make_return_next_stmt(yylsp[0]);
 
3548
                                                        (yyval.stmt) = make_return_next_stmt((yylsp[(1) - (1)]));
3067
3549
                                                }
3068
3550
                                                else if (tok_is_keyword(tok, &yylval,
3069
3551
                                                                                                K_QUERY, "query"))
3070
3552
                                                {
3071
 
                                                        yyval.stmt = make_return_query_stmt(yylsp[0]);
 
3553
                                                        (yyval.stmt) = make_return_query_stmt((yylsp[(1) - (1)]));
3072
3554
                                                }
3073
3555
                                                else
3074
3556
                                                {
3075
3557
                                                        plpgsql_push_back_token(tok);
3076
 
                                                        yyval.stmt = make_return_stmt(yylsp[0]);
 
3558
                                                        (yyval.stmt) = make_return_stmt((yylsp[(1) - (1)]));
3077
3559
                                                }
3078
3560
                                        ;}
3079
3561
    break;
3080
3562
 
3081
3563
  case 115:
 
3564
 
 
3565
/* Line 1455 of yacc.c  */
3082
3566
#line 1534 "gram.y"
3083
3567
    {
3084
3568
                                                PLpgSQL_stmt_raise              *new;
3087
3571
                                                new = palloc(sizeof(PLpgSQL_stmt_raise));
3088
3572
 
3089
3573
                                                new->cmd_type   = PLPGSQL_STMT_RAISE;
3090
 
                                                new->lineno             = plpgsql_location_to_lineno(yylsp[0]);
 
3574
                                                new->lineno             = plpgsql_location_to_lineno((yylsp[(1) - (1)]));
3091
3575
                                                new->elog_level = ERROR;        /* default */
3092
3576
                                                new->condname   = NULL;
3093
3577
                                                new->message    = NULL;
3214
3698
                                                                new->options = read_raise_options();
3215
3699
                                                }
3216
3700
 
3217
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
3701
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
3218
3702
                                        ;}
3219
3703
    break;
3220
3704
 
3221
3705
  case 116:
 
3706
 
 
3707
/* Line 1455 of yacc.c  */
3222
3708
#line 1673 "gram.y"
3223
3709
    {
3224
 
                                                yyval.loop_body.stmts = yyvsp[-4].list;
3225
 
                                                yyval.loop_body.end_label = yyvsp[-1].str;
3226
 
                                                yyval.loop_body.end_label_location = yylsp[-1];
 
3710
                                                (yyval.loop_body).stmts = (yyvsp[(1) - (5)].list);
 
3711
                                                (yyval.loop_body).end_label = (yyvsp[(4) - (5)].str);
 
3712
                                                (yyval.loop_body).end_label_location = (yylsp[(4) - (5)]);
3227
3713
                                        ;}
3228
3714
    break;
3229
3715
 
3230
3716
  case 117:
 
3717
 
 
3718
/* Line 1455 of yacc.c  */
3231
3719
#line 1691 "gram.y"
3232
3720
    {
3233
 
                                                yyval.stmt = make_execsql_stmt(K_INSERT, yylsp[0]);
 
3721
                                                (yyval.stmt) = make_execsql_stmt(K_INSERT, (yylsp[(1) - (1)]));
3234
3722
                                        ;}
3235
3723
    break;
3236
3724
 
3237
3725
  case 118:
 
3726
 
 
3727
/* Line 1455 of yacc.c  */
3238
3728
#line 1695 "gram.y"
3239
3729
    {
3240
3730
                                                int                     tok;
3242
3732
                                                tok = yylex();
3243
3733
                                                plpgsql_push_back_token(tok);
3244
3734
                                                if (tok == '=' || tok == COLON_EQUALS || tok == '[')
3245
 
                                                        word_is_not_variable(&(yyvsp[0].word), yylsp[0]);
3246
 
                                                yyval.stmt = make_execsql_stmt(T_WORD, yylsp[0]);
 
3735
                                                        word_is_not_variable(&((yyvsp[(1) - (1)].word)), (yylsp[(1) - (1)]));
 
3736
                                                (yyval.stmt) = make_execsql_stmt(T_WORD, (yylsp[(1) - (1)]));
3247
3737
                                        ;}
3248
3738
    break;
3249
3739
 
3250
3740
  case 119:
 
3741
 
 
3742
/* Line 1455 of yacc.c  */
3251
3743
#line 1705 "gram.y"
3252
3744
    {
3253
3745
                                                int                     tok;
3255
3747
                                                tok = yylex();
3256
3748
                                                plpgsql_push_back_token(tok);
3257
3749
                                                if (tok == '=' || tok == COLON_EQUALS || tok == '[')
3258
 
                                                        cword_is_not_variable(&(yyvsp[0].cword), yylsp[0]);
3259
 
                                                yyval.stmt = make_execsql_stmt(T_CWORD, yylsp[0]);
 
3750
                                                        cword_is_not_variable(&((yyvsp[(1) - (1)].cword)), (yylsp[(1) - (1)]));
 
3751
                                                (yyval.stmt) = make_execsql_stmt(T_CWORD, (yylsp[(1) - (1)]));
3260
3752
                                        ;}
3261
3753
    break;
3262
3754
 
3263
3755
  case 120:
 
3756
 
 
3757
/* Line 1455 of yacc.c  */
3264
3758
#line 1717 "gram.y"
3265
3759
    {
3266
3760
                                                PLpgSQL_stmt_dynexecute *new;
3275
3769
 
3276
3770
                                                new = palloc(sizeof(PLpgSQL_stmt_dynexecute));
3277
3771
                                                new->cmd_type = PLPGSQL_STMT_DYNEXECUTE;
3278
 
                                                new->lineno = plpgsql_location_to_lineno(yylsp[0]);
 
3772
                                                new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]));
3279
3773
                                                new->query = expr;
3280
3774
                                                new->into = false;
3281
3775
                                                new->strict = false;
3320
3814
                                                                yyerror("syntax error");
3321
3815
                                                }
3322
3816
 
3323
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
3817
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
3324
3818
                                        ;}
3325
3819
    break;
3326
3820
 
3327
3821
  case 121:
 
3822
 
 
3823
/* Line 1455 of yacc.c  */
3328
3824
#line 1781 "gram.y"
3329
3825
    {
3330
3826
                                                PLpgSQL_stmt_open *new;
3332
3828
 
3333
3829
                                                new = palloc0(sizeof(PLpgSQL_stmt_open));
3334
3830
                                                new->cmd_type = PLPGSQL_STMT_OPEN;
3335
 
                                                new->lineno = plpgsql_location_to_lineno(yylsp[-1]);
3336
 
                                                new->curvar = yyvsp[0].var->dno;
 
3831
                                                new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (2)]));
 
3832
                                                new->curvar = (yyvsp[(2) - (2)].var)->dno;
3337
3833
                                                new->cursor_options = CURSOR_OPT_FAST_PLAN;
3338
3834
 
3339
 
                                                if (yyvsp[0].var->cursor_explicit_expr == NULL)
 
3835
                                                if ((yyvsp[(2) - (2)].var)->cursor_explicit_expr == NULL)
3340
3836
                                                {
3341
3837
                                                        /* be nice if we could use opt_scrollable here */
3342
3838
                                                    tok = yylex();
3395
3891
                                                else
3396
3892
                                                {
3397
3893
                                                        /* predefined cursor query, so read args */
3398
 
                                                        new->argquery = read_cursor_args(yyvsp[0].var, ';', ";");
 
3894
                                                        new->argquery = read_cursor_args((yyvsp[(2) - (2)].var), ';', ";");
3399
3895
                                                }
3400
3896
 
3401
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
3897
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
3402
3898
                                        ;}
3403
3899
    break;
3404
3900
 
3405
3901
  case 122:
 
3902
 
 
3903
/* Line 1455 of yacc.c  */
3406
3904
#line 1858 "gram.y"
3407
3905
    {
3408
 
                                                PLpgSQL_stmt_fetch *fetch = yyvsp[-2].fetch;
 
3906
                                                PLpgSQL_stmt_fetch *fetch = (yyvsp[(2) - (4)].fetch);
3409
3907
                                                PLpgSQL_rec        *rec;
3410
3908
                                                PLpgSQL_row        *row;
3411
3909
 
3423
3921
                                                        ereport(ERROR,
3424
3922
                                                                        (errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
3425
3923
                                                                         errmsg("FETCH statement cannot return multiple rows"),
3426
 
                                                                         parser_errposition(yylsp[-3])));
 
3924
                                                                         parser_errposition((yylsp[(1) - (4)]))));
3427
3925
 
3428
 
                                                fetch->lineno = plpgsql_location_to_lineno(yylsp[-3]);
 
3926
                                                fetch->lineno = plpgsql_location_to_lineno((yylsp[(1) - (4)]));
3429
3927
                                                fetch->rec              = rec;
3430
3928
                                                fetch->row              = row;
3431
 
                                                fetch->curvar   = yyvsp[-1].var->dno;
 
3929
                                                fetch->curvar   = (yyvsp[(3) - (4)].var)->dno;
3432
3930
                                                fetch->is_move  = false;
3433
3931
 
3434
 
                                                yyval.stmt = (PLpgSQL_stmt *)fetch;
 
3932
                                                (yyval.stmt) = (PLpgSQL_stmt *)fetch;
3435
3933
                                        ;}
3436
3934
    break;
3437
3935
 
3438
3936
  case 123:
 
3937
 
 
3938
/* Line 1455 of yacc.c  */
3439
3939
#line 1890 "gram.y"
3440
3940
    {
3441
 
                                                PLpgSQL_stmt_fetch *fetch = yyvsp[-2].fetch;
 
3941
                                                PLpgSQL_stmt_fetch *fetch = (yyvsp[(2) - (4)].fetch);
3442
3942
 
3443
 
                                                fetch->lineno = plpgsql_location_to_lineno(yylsp[-3]);
3444
 
                                                fetch->curvar   = yyvsp[-1].var->dno;
 
3943
                                                fetch->lineno = plpgsql_location_to_lineno((yylsp[(1) - (4)]));
 
3944
                                                fetch->curvar   = (yyvsp[(3) - (4)].var)->dno;
3445
3945
                                                fetch->is_move  = true;
3446
3946
 
3447
 
                                                yyval.stmt = (PLpgSQL_stmt *)fetch;
 
3947
                                                (yyval.stmt) = (PLpgSQL_stmt *)fetch;
3448
3948
                                        ;}
3449
3949
    break;
3450
3950
 
3451
3951
  case 124:
 
3952
 
 
3953
/* Line 1455 of yacc.c  */
3452
3954
#line 1902 "gram.y"
3453
3955
    {
3454
 
                                                yyval.fetch = read_fetch_direction();
 
3956
                                                (yyval.fetch) = read_fetch_direction();
3455
3957
                                        ;}
3456
3958
    break;
3457
3959
 
3458
3960
  case 125:
 
3961
 
 
3962
/* Line 1455 of yacc.c  */
3459
3963
#line 1908 "gram.y"
3460
3964
    {
3461
3965
                                                PLpgSQL_stmt_close *new;
3462
3966
 
3463
3967
                                                new = palloc(sizeof(PLpgSQL_stmt_close));
3464
3968
                                                new->cmd_type = PLPGSQL_STMT_CLOSE;
3465
 
                                                new->lineno = plpgsql_location_to_lineno(yylsp[-2]);
3466
 
                                                new->curvar = yyvsp[-1].var->dno;
 
3969
                                                new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (3)]));
 
3970
                                                new->curvar = (yyvsp[(2) - (3)].var)->dno;
3467
3971
 
3468
 
                                                yyval.stmt = (PLpgSQL_stmt *)new;
 
3972
                                                (yyval.stmt) = (PLpgSQL_stmt *)new;
3469
3973
                                        ;}
3470
3974
    break;
3471
3975
 
3472
3976
  case 126:
 
3977
 
 
3978
/* Line 1455 of yacc.c  */
3473
3979
#line 1921 "gram.y"
3474
3980
    {
3475
3981
                                                /* We do not bother building a node for NULL */
3476
 
                                                yyval.stmt = NULL;
 
3982
                                                (yyval.stmt) = NULL;
3477
3983
                                        ;}
3478
3984
    break;
3479
3985
 
3480
3986
  case 127:
 
3987
 
 
3988
/* Line 1455 of yacc.c  */
3481
3989
#line 1928 "gram.y"
3482
3990
    {
3483
 
                                                if (yyvsp[0].wdatum.datum->dtype != PLPGSQL_DTYPE_VAR)
 
3991
                                                if ((yyvsp[(1) - (1)].wdatum).datum->dtype != PLPGSQL_DTYPE_VAR)
3484
3992
                                                        ereport(ERROR,
3485
3993
                                                                        (errcode(ERRCODE_DATATYPE_MISMATCH),
3486
3994
                                                                         errmsg("cursor variable must be a simple variable"),
3487
 
                                                                         parser_errposition(yylsp[0])));
 
3995
                                                                         parser_errposition((yylsp[(1) - (1)]))));
3488
3996
 
3489
 
                                                if (((PLpgSQL_var *) yyvsp[0].wdatum.datum)->datatype->typoid != REFCURSOROID)
 
3997
                                                if (((PLpgSQL_var *) (yyvsp[(1) - (1)].wdatum).datum)->datatype->typoid != REFCURSOROID)
3490
3998
                                                        ereport(ERROR,
3491
3999
                                                                        (errcode(ERRCODE_DATATYPE_MISMATCH),
3492
4000
                                                                         errmsg("variable \"%s\" must be of type cursor or refcursor",
3493
 
                                                                                        ((PLpgSQL_var *) yyvsp[0].wdatum.datum)->refname),
3494
 
                                                                         parser_errposition(yylsp[0])));
3495
 
                                                yyval.var = (PLpgSQL_var *) yyvsp[0].wdatum.datum;
 
4001
                                                                                        ((PLpgSQL_var *) (yyvsp[(1) - (1)].wdatum).datum)->refname),
 
4002
                                                                         parser_errposition((yylsp[(1) - (1)]))));
 
4003
                                                (yyval.var) = (PLpgSQL_var *) (yyvsp[(1) - (1)].wdatum).datum;
3496
4004
                                        ;}
3497
4005
    break;
3498
4006
 
3499
4007
  case 128:
 
4008
 
 
4009
/* Line 1455 of yacc.c  */
3500
4010
#line 1944 "gram.y"
3501
4011
    {
3502
4012
                                                /* just to give a better message than "syntax error" */
3503
 
                                                word_is_not_variable(&(yyvsp[0].word), yylsp[0]);
 
4013
                                                word_is_not_variable(&((yyvsp[(1) - (1)].word)), (yylsp[(1) - (1)]));
3504
4014
                                        ;}
3505
4015
    break;
3506
4016
 
3507
4017
  case 129:
 
4018
 
 
4019
/* Line 1455 of yacc.c  */
3508
4020
#line 1949 "gram.y"
3509
4021
    {
3510
4022
                                                /* just to give a better message than "syntax error" */
3511
 
                                                cword_is_not_variable(&(yyvsp[0].cword), yylsp[0]);
 
4023
                                                cword_is_not_variable(&((yyvsp[(1) - (1)].cword)), (yylsp[(1) - (1)]));
3512
4024
                                        ;}
3513
4025
    break;
3514
4026
 
3515
4027
  case 130:
 
4028
 
 
4029
/* Line 1455 of yacc.c  */
3516
4030
#line 1956 "gram.y"
3517
 
    { yyval.exception_block = NULL; ;}
 
4031
    { (yyval.exception_block) = NULL; ;}
3518
4032
    break;
3519
4033
 
3520
4034
  case 131:
 
4035
 
 
4036
/* Line 1455 of yacc.c  */
3521
4037
#line 1958 "gram.y"
3522
4038
    {
3523
4039
                                                /*
3527
4043
                                                 * scope of the names extends to the end of the
3528
4044
                                                 * current block.
3529
4045
                                                 */
3530
 
                                                int                     lineno = plpgsql_location_to_lineno(yylsp[0]);
 
4046
                                                int                     lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]));
3531
4047
                                                PLpgSQL_exception_block *new = palloc(sizeof(PLpgSQL_exception_block));
3532
4048
                                                PLpgSQL_variable *var;
3533
4049
 
3547
4063
                                                ((PLpgSQL_var *) var)->isconst = true;
3548
4064
                                                new->sqlerrm_varno = var->dno;
3549
4065
 
3550
 
                                                yyval.exception_block = new;
 
4066
                                                (yyval.exception_block) = new;
3551
4067
                                        ;}
3552
4068
    break;
3553
4069
 
3554
4070
  case 132:
 
4071
 
 
4072
/* Line 1455 of yacc.c  */
3555
4073
#line 1989 "gram.y"
3556
4074
    {
3557
 
                                                PLpgSQL_exception_block *new = yyvsp[-1].exception_block;
3558
 
                                                new->exc_list = yyvsp[0].list;
 
4075
                                                PLpgSQL_exception_block *new = (yyvsp[(2) - (3)].exception_block);
 
4076
                                                new->exc_list = (yyvsp[(3) - (3)].list);
3559
4077
 
3560
 
                                                yyval.exception_block = new;
 
4078
                                                (yyval.exception_block) = new;
3561
4079
                                        ;}
3562
4080
    break;
3563
4081
 
3564
4082
  case 133:
 
4083
 
 
4084
/* Line 1455 of yacc.c  */
3565
4085
#line 1998 "gram.y"
3566
4086
    {
3567
 
                                                        yyval.list = lappend(yyvsp[-1].list, yyvsp[0].exception);
 
4087
                                                        (yyval.list) = lappend((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].exception));
3568
4088
                                                ;}
3569
4089
    break;
3570
4090
 
3571
4091
  case 134:
 
4092
 
 
4093
/* Line 1455 of yacc.c  */
3572
4094
#line 2002 "gram.y"
3573
4095
    {
3574
 
                                                        yyval.list = list_make1(yyvsp[0].exception);
 
4096
                                                        (yyval.list) = list_make1((yyvsp[(1) - (1)].exception));
3575
4097
                                                ;}
3576
4098
    break;
3577
4099
 
3578
4100
  case 135:
 
4101
 
 
4102
/* Line 1455 of yacc.c  */
3579
4103
#line 2008 "gram.y"
3580
4104
    {
3581
4105
                                                PLpgSQL_exception *new;
3582
4106
 
3583
4107
                                                new = palloc0(sizeof(PLpgSQL_exception));
3584
 
                                                new->lineno     = plpgsql_location_to_lineno(yylsp[-3]);
3585
 
                                                new->conditions = yyvsp[-2].condition;
3586
 
                                                new->action         = yyvsp[0].list;
 
4108
                                                new->lineno     = plpgsql_location_to_lineno((yylsp[(1) - (4)]));
 
4109
                                                new->conditions = (yyvsp[(2) - (4)].condition);
 
4110
                                                new->action         = (yyvsp[(4) - (4)].list);
3587
4111
 
3588
 
                                                yyval.exception = new;
 
4112
                                                (yyval.exception) = new;
3589
4113
                                        ;}
3590
4114
    break;
3591
4115
 
3592
4116
  case 136:
 
4117
 
 
4118
/* Line 1455 of yacc.c  */
3593
4119
#line 2021 "gram.y"
3594
4120
    {
3595
4121
                                                        PLpgSQL_condition       *old;
3596
4122
 
3597
 
                                                        for (old = yyvsp[-2].condition; old->next != NULL; old = old->next)
 
4123
                                                        for (old = (yyvsp[(1) - (3)].condition); old->next != NULL; old = old->next)
3598
4124
                                                                /* skip */ ;
3599
 
                                                        old->next = yyvsp[0].condition;
3600
 
                                                        yyval.condition = yyvsp[-2].condition;
 
4125
                                                        old->next = (yyvsp[(3) - (3)].condition);
 
4126
                                                        (yyval.condition) = (yyvsp[(1) - (3)].condition);
3601
4127
                                                ;}
3602
4128
    break;
3603
4129
 
3604
4130
  case 137:
 
4131
 
 
4132
/* Line 1455 of yacc.c  */
3605
4133
#line 2030 "gram.y"
3606
4134
    {
3607
 
                                                        yyval.condition = yyvsp[0].condition;
 
4135
                                                        (yyval.condition) = (yyvsp[(1) - (1)].condition);
3608
4136
                                                ;}
3609
4137
    break;
3610
4138
 
3611
4139
  case 138:
 
4140
 
 
4141
/* Line 1455 of yacc.c  */
3612
4142
#line 2036 "gram.y"
3613
4143
    {
3614
 
                                                        if (strcmp(yyvsp[0].str, "sqlstate") != 0)
 
4144
                                                        if (strcmp((yyvsp[(1) - (1)].str), "sqlstate") != 0)
3615
4145
                                                        {
3616
 
                                                                yyval.condition = plpgsql_parse_err_condition(yyvsp[0].str);
 
4146
                                                                (yyval.condition) = plpgsql_parse_err_condition((yyvsp[(1) - (1)].str));
3617
4147
                                                        }
3618
4148
                                                        else
3619
4149
                                                        {
3640
4170
                                                                new->condname = sqlstatestr;
3641
4171
                                                                new->next = NULL;
3642
4172
 
3643
 
                                                                yyval.condition = new;
 
4173
                                                                (yyval.condition) = new;
3644
4174
                                                        }
3645
4175
                                                ;}
3646
4176
    break;
3647
4177
 
3648
4178
  case 139:
 
4179
 
 
4180
/* Line 1455 of yacc.c  */
3649
4181
#line 2072 "gram.y"
3650
 
    { yyval.expr = read_sql_expression(';', ";"); ;}
 
4182
    { (yyval.expr) = read_sql_expression(';', ";"); ;}
3651
4183
    break;
3652
4184
 
3653
4185
  case 140:
 
4186
 
 
4187
/* Line 1455 of yacc.c  */
3654
4188
#line 2076 "gram.y"
3655
 
    { yyval.expr = read_sql_expression(']', "]"); ;}
 
4189
    { (yyval.expr) = read_sql_expression(']', "]"); ;}
3656
4190
    break;
3657
4191
 
3658
4192
  case 141:
 
4193
 
 
4194
/* Line 1455 of yacc.c  */
3659
4195
#line 2080 "gram.y"
3660
 
    { yyval.expr = read_sql_expression(K_THEN, "THEN"); ;}
 
4196
    { (yyval.expr) = read_sql_expression(K_THEN, "THEN"); ;}
3661
4197
    break;
3662
4198
 
3663
4199
  case 142:
 
4200
 
 
4201
/* Line 1455 of yacc.c  */
3664
4202
#line 2084 "gram.y"
3665
 
    { yyval.expr = read_sql_expression(K_LOOP, "LOOP"); ;}
 
4203
    { (yyval.expr) = read_sql_expression(K_LOOP, "LOOP"); ;}
3666
4204
    break;
3667
4205
 
3668
4206
  case 143:
 
4207
 
 
4208
/* Line 1455 of yacc.c  */
3669
4209
#line 2088 "gram.y"
3670
4210
    {
3671
4211
                                                plpgsql_ns_push(NULL);
3672
 
                                                yyval.str = NULL;
 
4212
                                                (yyval.str) = NULL;
3673
4213
                                        ;}
3674
4214
    break;
3675
4215
 
3676
4216
  case 144:
 
4217
 
 
4218
/* Line 1455 of yacc.c  */
3677
4219
#line 2093 "gram.y"
3678
4220
    {
3679
 
                                                plpgsql_ns_push(yyvsp[-1].str);
3680
 
                                                yyval.str = yyvsp[-1].str;
 
4221
                                                plpgsql_ns_push((yyvsp[(2) - (3)].str));
 
4222
                                                (yyval.str) = (yyvsp[(2) - (3)].str);
3681
4223
                                        ;}
3682
4224
    break;
3683
4225
 
3684
4226
  case 145:
 
4227
 
 
4228
/* Line 1455 of yacc.c  */
3685
4229
#line 2100 "gram.y"
3686
4230
    {
3687
 
                                                yyval.str = NULL;
 
4231
                                                (yyval.str) = NULL;
3688
4232
                                        ;}
3689
4233
    break;
3690
4234
 
3691
4235
  case 146:
 
4236
 
 
4237
/* Line 1455 of yacc.c  */
3692
4238
#line 2104 "gram.y"
3693
4239
    {
3694
 
                                                if (plpgsql_ns_lookup_label(plpgsql_ns_top(), yyvsp[0].str) == NULL)
 
4240
                                                if (plpgsql_ns_lookup_label(plpgsql_ns_top(), (yyvsp[(1) - (1)].str)) == NULL)
3695
4241
                                                        yyerror("label does not exist");
3696
 
                                                yyval.str = yyvsp[0].str;
 
4242
                                                (yyval.str) = (yyvsp[(1) - (1)].str);
3697
4243
                                        ;}
3698
4244
    break;
3699
4245
 
3700
4246
  case 147:
 
4247
 
 
4248
/* Line 1455 of yacc.c  */
3701
4249
#line 2112 "gram.y"
3702
 
    { yyval.expr = NULL; ;}
 
4250
    { (yyval.expr) = NULL; ;}
3703
4251
    break;
3704
4252
 
3705
4253
  case 148:
 
4254
 
 
4255
/* Line 1455 of yacc.c  */
3706
4256
#line 2114 "gram.y"
3707
 
    { yyval.expr = yyvsp[0].expr; ;}
 
4257
    { (yyval.expr) = (yyvsp[(2) - (2)].expr); ;}
3708
4258
    break;
3709
4259
 
3710
4260
  case 149:
 
4261
 
 
4262
/* Line 1455 of yacc.c  */
3711
4263
#line 2121 "gram.y"
3712
4264
    {
3713
 
                                                yyval.str = yyvsp[0].word.ident;
 
4265
                                                (yyval.str) = (yyvsp[(1) - (1)].word).ident;
3714
4266
                                        ;}
3715
4267
    break;
3716
4268
 
3717
4269
  case 150:
 
4270
 
 
4271
/* Line 1455 of yacc.c  */
3718
4272
#line 2125 "gram.y"
3719
4273
    {
3720
 
                                                if (yyvsp[0].wdatum.ident == NULL) /* composite name not OK */
 
4274
                                                if ((yyvsp[(1) - (1)].wdatum).ident == NULL) /* composite name not OK */
3721
4275
                                                        yyerror("syntax error");
3722
 
                                                yyval.str = yyvsp[0].wdatum.ident;
 
4276
                                                (yyval.str) = (yyvsp[(1) - (1)].wdatum).ident;
3723
4277
                                        ;}
3724
4278
    break;
3725
4279
 
3726
4280
 
 
4281
 
 
4282
/* Line 1455 of yacc.c  */
 
4283
#line 4284 "pl_gram.c"
 
4284
      default: break;
3727
4285
    }
3728
 
 
3729
 
/* Line 991 of yacc.c.  */
3730
 
#line 3730 "pl_gram.c"
3731
 
 
3732
 
  yyvsp -= yylen;
3733
 
  yyssp -= yylen;
3734
 
  yylsp -= yylen;
3735
 
 
 
4286
  YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
 
4287
 
 
4288
  YYPOPSTACK (yylen);
 
4289
  yylen = 0;
3736
4290
  YY_STACK_PRINT (yyss, yyssp);
3737
4291
 
3738
4292
  *++yyvsp = yyval;
3761
4315
  if (!yyerrstatus)
3762
4316
    {
3763
4317
      ++yynerrs;
3764
 
#if YYERROR_VERBOSE
3765
 
      yyn = yypact[yystate];
3766
 
 
3767
 
      if (YYPACT_NINF < yyn && yyn < YYLAST)
3768
 
        {
3769
 
          YYSIZE_T yysize = 0;
3770
 
          int yytype = YYTRANSLATE (yychar);
3771
 
          char *yymsg;
3772
 
          int yyx, yycount;
3773
 
 
3774
 
          yycount = 0;
3775
 
          /* Start YYX at -YYN if negative to avoid negative indexes in
3776
 
             YYCHECK.  */
3777
 
          for (yyx = yyn < 0 ? -yyn : 0;
3778
 
               yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
3779
 
            if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3780
 
              yysize += yystrlen (yytname[yyx]) + 15, yycount++;
3781
 
          yysize += yystrlen ("syntax error, unexpected ") + 1;
3782
 
          yysize += yystrlen (yytname[yytype]);
3783
 
          yymsg = (char *) YYSTACK_ALLOC (yysize);
3784
 
          if (yymsg != 0)
3785
 
            {
3786
 
              char *yyp = yystpcpy (yymsg, "syntax error, unexpected ");
3787
 
              yyp = yystpcpy (yyp, yytname[yytype]);
3788
 
 
3789
 
              if (yycount < 5)
3790
 
                {
3791
 
                  yycount = 0;
3792
 
                  for (yyx = yyn < 0 ? -yyn : 0;
3793
 
                       yyx < (int) (sizeof (yytname) / sizeof (char *));
3794
 
                       yyx++)
3795
 
                    if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
3796
 
                      {
3797
 
                        const char *yyq = ! yycount ? ", expecting " : " or ";
3798
 
                        yyp = yystpcpy (yyp, yyq);
3799
 
                        yyp = yystpcpy (yyp, yytname[yyx]);
3800
 
                        yycount++;
3801
 
                      }
3802
 
                }
3803
 
              yyerror (yymsg);
 
4318
#if ! YYERROR_VERBOSE
 
4319
      yyerror (YY_("syntax error"));
 
4320
#else
 
4321
      {
 
4322
        YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
 
4323
        if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
 
4324
          {
 
4325
            YYSIZE_T yyalloc = 2 * yysize;
 
4326
            if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
 
4327
              yyalloc = YYSTACK_ALLOC_MAXIMUM;
 
4328
            if (yymsg != yymsgbuf)
3804
4329
              YYSTACK_FREE (yymsg);
3805
 
            }
3806
 
          else
3807
 
            yyerror ("syntax error; also virtual memory exhausted");
3808
 
        }
3809
 
      else
3810
 
#endif /* YYERROR_VERBOSE */
3811
 
        yyerror ("syntax error");
 
4330
            yymsg = (char *) YYSTACK_ALLOC (yyalloc);
 
4331
            if (yymsg)
 
4332
              yymsg_alloc = yyalloc;
 
4333
            else
 
4334
              {
 
4335
                yymsg = yymsgbuf;
 
4336
                yymsg_alloc = sizeof yymsgbuf;
 
4337
              }
 
4338
          }
 
4339
 
 
4340
        if (0 < yysize && yysize <= yymsg_alloc)
 
4341
          {
 
4342
            (void) yysyntax_error (yymsg, yystate, yychar);
 
4343
            yyerror (yymsg);
 
4344
          }
 
4345
        else
 
4346
          {
 
4347
            yyerror (YY_("syntax error"));
 
4348
            if (yysize != 0)
 
4349
              goto yyexhaustedlab;
 
4350
          }
 
4351
      }
 
4352
#endif
3812
4353
    }
3813
4354
 
3814
 
  yylerrsp = yylsp;
 
4355
  yyerror_range[0] = yylloc;
3815
4356
 
3816
4357
  if (yyerrstatus == 3)
3817
4358
    {
3818
4359
      /* If just tried and failed to reuse lookahead token after an
3819
4360
         error, discard it.  */
3820
4361
 
3821
 
      /* Return failure if at end of input.  */
3822
 
      if (yychar == YYEOF)
3823
 
        {
3824
 
          /* Pop the error token.  */
3825
 
          YYPOPSTACK;
3826
 
          /* Pop the rest of the stack.  */
3827
 
          while (yyss < yyssp)
3828
 
            {
3829
 
              YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
3830
 
              yydestruct (yystos[*yyssp], yyvsp, yylsp);
3831
 
              YYPOPSTACK;
3832
 
            }
3833
 
          YYABORT;
3834
 
        }
3835
 
 
3836
 
      YYDSYMPRINTF ("Error: discarding", yytoken, &yylval, &yylloc);
3837
 
      yydestruct (yytoken, &yylval, &yylloc);
3838
 
      yychar = YYEMPTY;
3839
 
      *++yylerrsp = yylloc;
 
4362
      if (yychar <= YYEOF)
 
4363
        {
 
4364
          /* Return failure if at end of input.  */
 
4365
          if (yychar == YYEOF)
 
4366
            YYABORT;
 
4367
        }
 
4368
      else
 
4369
        {
 
4370
          yydestruct ("Error: discarding",
 
4371
                      yytoken, &yylval, &yylloc);
 
4372
          yychar = YYEMPTY;
 
4373
        }
3840
4374
    }
3841
4375
 
3842
4376
  /* Else will try to reuse lookahead token after shifting the error
3843
4377
     token.  */
3844
 
  goto yyerrlab2;
3845
 
 
3846
 
 
3847
 
/*----------------------------------------------------.
3848
 
| yyerrlab1 -- error raised explicitly by an action.  |
3849
 
`----------------------------------------------------*/
 
4378
  goto yyerrlab1;
 
4379
 
 
4380
 
 
4381
/*---------------------------------------------------.
 
4382
| yyerrorlab -- error raised explicitly by YYERROR.  |
 
4383
`---------------------------------------------------*/
 
4384
yyerrorlab:
 
4385
 
 
4386
  /* Pacify compilers like GCC when the user code never invokes
 
4387
     YYERROR and the label yyerrorlab therefore never appears in user
 
4388
     code.  */
 
4389
  if (/*CONSTCOND*/ 0)
 
4390
     goto yyerrorlab;
 
4391
 
 
4392
  yyerror_range[0] = yylsp[1-yylen];
 
4393
  /* Do not reclaim the symbols of the rule which action triggered
 
4394
     this YYERROR.  */
 
4395
  YYPOPSTACK (yylen);
 
4396
  yylen = 0;
 
4397
  YY_STACK_PRINT (yyss, yyssp);
 
4398
  yystate = *yyssp;
 
4399
  goto yyerrlab1;
 
4400
 
 
4401
 
 
4402
/*-------------------------------------------------------------.
 
4403
| yyerrlab1 -- common code for both syntax error and YYERROR.  |
 
4404
`-------------------------------------------------------------*/
3850
4405
yyerrlab1:
3851
 
 
3852
 
  /* Suppress GCC warning that yyerrlab1 is unused when no action
3853
 
     invokes YYERROR.  */
3854
 
#if defined (__GNUC_MINOR__) && 2093 <= (__GNUC__ * 1000 + __GNUC_MINOR__)
3855
 
  __attribute__ ((__unused__))
3856
 
#endif
3857
 
 
3858
 
  yylerrsp = yylsp;
3859
 
  *++yylerrsp = yyloc;
3860
 
  goto yyerrlab2;
3861
 
 
3862
 
 
3863
 
/*---------------------------------------------------------------.
3864
 
| yyerrlab2 -- pop states until the error token can be shifted.  |
3865
 
`---------------------------------------------------------------*/
3866
 
yyerrlab2:
3867
4406
  yyerrstatus = 3;      /* Each real token shifted decrements this.  */
3868
4407
 
3869
4408
  for (;;)
3884
4423
      if (yyssp == yyss)
3885
4424
        YYABORT;
3886
4425
 
3887
 
      YYDSYMPRINTF ("Error: popping", yystos[*yyssp], yyvsp, yylsp);
3888
 
      yydestruct (yystos[yystate], yyvsp, yylsp);
3889
 
      yyvsp--;
3890
 
      yystate = *--yyssp;
3891
 
      yylsp--;
 
4426
      yyerror_range[0] = *yylsp;
 
4427
      yydestruct ("Error: popping",
 
4428
                  yystos[yystate], yyvsp, yylsp);
 
4429
      YYPOPSTACK (1);
 
4430
      yystate = *yyssp;
3892
4431
      YY_STACK_PRINT (yyss, yyssp);
3893
4432
    }
3894
4433
 
3895
 
  if (yyn == YYFINAL)
3896
 
    YYACCEPT;
3897
 
 
3898
 
  YYDPRINTF ((stderr, "Shifting error token, "));
3899
 
 
3900
4434
  *++yyvsp = yylval;
3901
 
  YYLLOC_DEFAULT (yyloc, yylsp, (yylerrsp - yylsp));
 
4435
 
 
4436
  yyerror_range[1] = yylloc;
 
4437
  /* Using YYLLOC is tempting, but would change the location of
 
4438
     the lookahead.  YYLOC is available though.  */
 
4439
  YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
3902
4440
  *++yylsp = yyloc;
3903
4441
 
 
4442
  /* Shift the error token.  */
 
4443
  YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
 
4444
 
3904
4445
  yystate = yyn;
3905
4446
  goto yynewstate;
3906
4447
 
3919
4460
  yyresult = 1;
3920
4461
  goto yyreturn;
3921
4462
 
3922
 
#ifndef yyoverflow
3923
 
/*----------------------------------------------.
3924
 
| yyoverflowlab -- parser overflow comes here.  |
3925
 
`----------------------------------------------*/
3926
 
yyoverflowlab:
3927
 
  yyerror ("parser stack overflow");
 
4463
#if !defined(yyoverflow) || YYERROR_VERBOSE
 
4464
/*-------------------------------------------------.
 
4465
| yyexhaustedlab -- memory exhaustion comes here.  |
 
4466
`-------------------------------------------------*/
 
4467
yyexhaustedlab:
 
4468
  yyerror (YY_("memory exhausted"));
3928
4469
  yyresult = 2;
3929
4470
  /* Fall through.  */
3930
4471
#endif
3931
4472
 
3932
4473
yyreturn:
 
4474
  if (yychar != YYEMPTY)
 
4475
     yydestruct ("Cleanup: discarding lookahead",
 
4476
                 yytoken, &yylval, &yylloc);
 
4477
  /* Do not reclaim the symbols of the rule which action triggered
 
4478
     this YYABORT or YYACCEPT.  */
 
4479
  YYPOPSTACK (yylen);
 
4480
  YY_STACK_PRINT (yyss, yyssp);
 
4481
  while (yyssp != yyss)
 
4482
    {
 
4483
      yydestruct ("Cleanup: popping",
 
4484
                  yystos[*yyssp], yyvsp, yylsp);
 
4485
      YYPOPSTACK (1);
 
4486
    }
3933
4487
#ifndef yyoverflow
3934
4488
  if (yyss != yyssa)
3935
4489
    YYSTACK_FREE (yyss);
3936
4490
#endif
3937
 
  return yyresult;
 
4491
#if YYERROR_VERBOSE
 
4492
  if (yymsg != yymsgbuf)
 
4493
    YYSTACK_FREE (yymsg);
 
4494
#endif
 
4495
  /* Make sure YYID is used.  */
 
4496
  return YYID (yyresult);
3938
4497
}
3939
4498
 
3940
4499
 
 
4500
 
 
4501
/* Line 1675 of yacc.c  */
3941
4502
#line 2173 "gram.y"
3942
4503
 
3943
4504