#define YYBISON 1
#define YYBISON_VERSION "2.3"
#define YYSKELETON_NAME "yacc.c"
#define YYPURE 1
#define YYLSP_NEEDED 1
#define yyparse plpgsql_yyparse
#define yylex plpgsql_yylex
#define yyerror plpgsql_yyerror
#define yylval plpgsql_yylval
#define yychar plpgsql_yychar
#define yydebug plpgsql_yydebug
#define yynerrs plpgsql_yynerrs
#define yylloc plpgsql_yylloc
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
enum yytokentype {
IDENT = 258,
UIDENT = 259,
FCONST = 260,
SCONST = 261,
USCONST = 262,
BCONST = 263,
XCONST = 264,
Op = 265,
ICONST = 266,
PARAM = 267,
TYPECAST = 268,
DOT_DOT = 269,
COLON_EQUALS = 270,
EQUALS_GREATER = 271,
LESS_EQUALS = 272,
GREATER_EQUALS = 273,
NOT_EQUALS = 274,
SQL_COMMENT = 275,
C_COMMENT = 276,
T_WORD = 277,
T_CWORD = 278,
T_DATUM = 279,
LESS_LESS = 280,
GREATER_GREATER = 281,
K_ABSOLUTE = 282,
K_ALIAS = 283,
K_ALL = 284,
K_AND = 285,
K_ARRAY = 286,
K_ASSERT = 287,
K_BACKWARD = 288,
K_BEGIN = 289,
K_BY = 290,
K_CALL = 291,
K_CASE = 292,
K_CHAIN = 293,
K_CLOSE = 294,
K_COLLATE = 295,
K_COLUMN = 296,
K_COLUMN_NAME = 297,
K_COMMIT = 298,
K_CONSTANT = 299,
K_CONSTRAINT = 300,
K_CONSTRAINT_NAME = 301,
K_CONTINUE = 302,
K_CURRENT = 303,
K_CURSOR = 304,
K_DATATYPE = 305,
K_DEBUG = 306,
K_DECLARE = 307,
K_DEFAULT = 308,
K_DETAIL = 309,
K_DIAGNOSTICS = 310,
K_DO = 311,
K_DUMP = 312,
K_ELSE = 313,
K_ELSIF = 314,
K_END = 315,
K_ERRCODE = 316,
K_ERROR = 317,
K_EXCEPTION = 318,
K_EXECUTE = 319,
K_EXIT = 320,
K_FETCH = 321,
K_FIRST = 322,
K_FOR = 323,
K_FOREACH = 324,
K_FORWARD = 325,
K_FROM = 326,
K_GET = 327,
K_HINT = 328,
K_IF = 329,
K_IMPORT = 330,
K_IN = 331,
K_INFO = 332,
K_INSERT = 333,
K_INTO = 334,
K_IS = 335,
K_LAST = 336,
K_LOG = 337,
K_LOOP = 338,
K_MERGE = 339,
K_MESSAGE = 340,
K_MESSAGE_TEXT = 341,
K_MOVE = 342,
K_NEXT = 343,
K_NO = 344,
K_NOT = 345,
K_NOTICE = 346,
K_NULL = 347,
K_OPEN = 348,
K_OPTION = 349,
K_OR = 350,
K_PERFORM = 351,
K_PG_CONTEXT = 352,
K_PG_DATATYPE_NAME = 353,
K_PG_EXCEPTION_CONTEXT = 354,
K_PG_EXCEPTION_DETAIL = 355,
K_PG_EXCEPTION_HINT = 356,
K_PG_ROUTINE_OID = 357,
K_PRINT_STRICT_PARAMS = 358,
K_PRIOR = 359,
K_QUERY = 360,
K_RAISE = 361,
K_RELATIVE = 362,
K_RETURN = 363,
K_RETURNED_SQLSTATE = 364,
K_REVERSE = 365,
K_ROLLBACK = 366,
K_ROW_COUNT = 367,
K_ROWTYPE = 368,
K_SCHEMA = 369,
K_SCHEMA_NAME = 370,
K_SCROLL = 371,
K_SLICE = 372,
K_SQLSTATE = 373,
K_STACKED = 374,
K_STRICT = 375,
K_TABLE = 376,
K_TABLE_NAME = 377,
K_THEN = 378,
K_TO = 379,
K_TYPE = 380,
K_USE_COLUMN = 381,
K_USE_VARIABLE = 382,
K_USING = 383,
K_VARIABLE_CONFLICT = 384,
K_WARNING = 385,
K_WHEN = 386,
K_WHILE = 387
};
#endif
#define IDENT 258
#define UIDENT 259
#define FCONST 260
#define SCONST 261
#define USCONST 262
#define BCONST 263
#define XCONST 264
#define Op 265
#define ICONST 266
#define PARAM 267
#define TYPECAST 268
#define DOT_DOT 269
#define COLON_EQUALS 270
#define EQUALS_GREATER 271
#define LESS_EQUALS 272
#define GREATER_EQUALS 273
#define NOT_EQUALS 274
#define SQL_COMMENT 275
#define C_COMMENT 276
#define T_WORD 277
#define T_CWORD 278
#define T_DATUM 279
#define LESS_LESS 280
#define GREATER_GREATER 281
#define K_ABSOLUTE 282
#define K_ALIAS 283
#define K_ALL 284
#define K_AND 285
#define K_ARRAY 286
#define K_ASSERT 287
#define K_BACKWARD 288
#define K_BEGIN 289
#define K_BY 290
#define K_CALL 291
#define K_CASE 292
#define K_CHAIN 293
#define K_CLOSE 294
#define K_COLLATE 295
#define K_COLUMN 296
#define K_COLUMN_NAME 297
#define K_COMMIT 298
#define K_CONSTANT 299
#define K_CONSTRAINT 300
#define K_CONSTRAINT_NAME 301
#define K_CONTINUE 302
#define K_CURRENT 303
#define K_CURSOR 304
#define K_DATATYPE 305
#define K_DEBUG 306
#define K_DECLARE 307
#define K_DEFAULT 308
#define K_DETAIL 309
#define K_DIAGNOSTICS 310
#define K_DO 311
#define K_DUMP 312
#define K_ELSE 313
#define K_ELSIF 314
#define K_END 315
#define K_ERRCODE 316
#define K_ERROR 317
#define K_EXCEPTION 318
#define K_EXECUTE 319
#define K_EXIT 320
#define K_FETCH 321
#define K_FIRST 322
#define K_FOR 323
#define K_FOREACH 324
#define K_FORWARD 325
#define K_FROM 326
#define K_GET 327
#define K_HINT 328
#define K_IF 329
#define K_IMPORT 330
#define K_IN 331
#define K_INFO 332
#define K_INSERT 333
#define K_INTO 334
#define K_IS 335
#define K_LAST 336
#define K_LOG 337
#define K_LOOP 338
#define K_MERGE 339
#define K_MESSAGE 340
#define K_MESSAGE_TEXT 341
#define K_MOVE 342
#define K_NEXT 343
#define K_NO 344
#define K_NOT 345
#define K_NOTICE 346
#define K_NULL 347
#define K_OPEN 348
#define K_OPTION 349
#define K_OR 350
#define K_PERFORM 351
#define K_PG_CONTEXT 352
#define K_PG_DATATYPE_NAME 353
#define K_PG_EXCEPTION_CONTEXT 354
#define K_PG_EXCEPTION_DETAIL 355
#define K_PG_EXCEPTION_HINT 356
#define K_PG_ROUTINE_OID 357
#define K_PRINT_STRICT_PARAMS 358
#define K_PRIOR 359
#define K_QUERY 360
#define K_RAISE 361
#define K_RELATIVE 362
#define K_RETURN 363
#define K_RETURNED_SQLSTATE 364
#define K_REVERSE 365
#define K_ROLLBACK 366
#define K_ROW_COUNT 367
#define K_ROWTYPE 368
#define K_SCHEMA 369
#define K_SCHEMA_NAME 370
#define K_SCROLL 371
#define K_SLICE 372
#define K_SQLSTATE 373
#define K_STACKED 374
#define K_STRICT 375
#define K_TABLE 376
#define K_TABLE_NAME 377
#define K_THEN 378
#define K_TO 379
#define K_TYPE 380
#define K_USE_COLUMN 381
#define K_USE_VARIABLE 382
#define K_USING 383
#define K_VARIABLE_CONFLICT 384
#define K_WARNING 385
#define K_WHEN 386
#define K_WHILE 387
#line 1 "pl_gram.y"
#include "postgres.h"
#include "catalog/namespace.h"
#include "catalog/pg_proc.h"
#include "catalog/pg_type.h"
#include "parser/parser.h"
#include "parser/parse_type.h"
#include "parser/scanner.h"
#include "parser/scansup.h"
#include "utils/builtins.h"
#include "plpgsql.h"
#include "pl_gram.h"
#define YYLLOC_DEFAULT(Current, Rhs, N) \
do { \
if (N) \
(Current) = (Rhs)[1]; \
else \
(Current) = (Rhs)[0]; \
} while (0)
#define YYMALLOC palloc
#define YYFREE pfree
typedef struct
{
int location;
yyscan_t yyscanner;
} sql_error_callback_arg;
#define parser_errposition(pos) plpgsql_scanner_errposition(pos, yyscanner)
union YYSTYPE;
static bool tok_is_keyword(int token, union YYSTYPE *lval,
int kw_token, const char *kw_str);
static void word_is_not_variable(PLword *word, int location, yyscan_t yyscanner);
static void cword_is_not_variable(PLcword *cword, int location, yyscan_t yyscanner);
static void current_token_is_not_variable(int tok, YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner);
static PLpgSQL_expr *make_plpgsql_expr(const char *query,
RawParseMode parsemode);
static void mark_expr_as_assignment_source(PLpgSQL_expr *expr,
PLpgSQL_datum *target);
static PLpgSQL_expr *read_sql_construct(int until,
int until2,
int until3,
const char *expected,
RawParseMode parsemode,
bool isexpression,
bool valid_sql,
int *startloc,
int *endtoken,
YYSTYPE *yylvalp, YYLTYPE *yyllocp,
yyscan_t yyscanner);
static PLpgSQL_expr *read_sql_expression(int until, const char *expected,
YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner);
static PLpgSQL_expr *read_sql_expression2(int until, int until2,
const char *expected, int *endtoken,
YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner);
static PLpgSQL_expr *read_sql_stmt(YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner);
static PLpgSQL_type *read_datatype(int tok, YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner);
static PLpgSQL_stmt *make_execsql_stmt(int firsttoken, int location,
PLword *word, YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner);
static PLpgSQL_stmt_fetch *read_fetch_direction(YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner);
static void complete_direction(PLpgSQL_stmt_fetch *fetch,
bool *check_FROM, YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner);
static PLpgSQL_stmt *make_return_stmt(int location, YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner);
static PLpgSQL_stmt *make_return_next_stmt(int location, YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner);
static PLpgSQL_stmt *make_return_query_stmt(int location, YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner);
static PLpgSQL_stmt *make_case(int location, PLpgSQL_expr *t_expr,
List *case_when_list, List *else_stmts, yyscan_t yyscanner);
static char *NameOfDatum(PLwdatum *wdatum);
static void check_assignable(PLpgSQL_datum *datum, int location, yyscan_t yyscanner);
static void read_into_target(PLpgSQL_variable **target, bool *strict,
YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner);
static PLpgSQL_row *read_into_scalar_list(char *initial_name,
PLpgSQL_datum *initial_datum,
int initial_location,
YYSTYPE *yylvalp, YYLTYPE *yyllocp,
yyscan_t yyscanner);
static PLpgSQL_row *make_scalar_list1(char *initial_name,
PLpgSQL_datum *initial_datum,
int lineno, int location, yyscan_t yyscanner);
static void check_sql_expr(const char *stmt,
RawParseMode parseMode, int location, yyscan_t yyscanner);
static void plpgsql_sql_error_callback(void *arg);
static PLpgSQL_type *parse_datatype(const char *string, int location, yyscan_t yyscanner);
static void check_labels(const char *start_label,
const char *end_label,
int end_location,
yyscan_t yyscanner);
static PLpgSQL_expr *read_cursor_args(PLpgSQL_var *cursor, int until,
YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner);
static List *read_raise_options(YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner);
static void check_raise_parameters(PLpgSQL_stmt_raise *stmt);
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#ifdef YYERROR_VERBOSE
# undef YYERROR_VERBOSE
# define YYERROR_VERBOSE 1
#else
# define YYERROR_VERBOSE 0
#endif
#ifndef YYTOKEN_TABLE
# define YYTOKEN_TABLE 0
#endif
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
#line 132 "pl_gram.y"
{
core_YYSTYPE core_yystype;
int ival;
char *str;
const char *keyword;
PLword word;
PLcword cword;
PLwdatum wdatum;
bool boolean;
Oid oid;
struct
{
char *name;
int lineno;
} varname;
struct
{
char *name;
int lineno;
PLpgSQL_datum *scalar;
PLpgSQL_datum *row;
} forvariable;
struct
{
char *label;
int n_initvars;
int *initvarnos;
} declhdr;
struct
{
List *stmts;
char *end_label;
int end_label_location;
} loop_body;
List *list;
PLpgSQL_type *dtype;
PLpgSQL_datum *datum;
PLpgSQL_var *var;
PLpgSQL_expr *expr;
PLpgSQL_stmt *stmt;
PLpgSQL_condition *condition;
PLpgSQL_exception *exception;
PLpgSQL_exception_block *exception_block;
PLpgSQL_nsitem *nsitem;
PLpgSQL_diag_item *diagitem;
PLpgSQL_stmt_fetch *fetch;
PLpgSQL_case_when *casewhen;
}
#line 541 "pl_gram.c"
YYSTYPE;
# define yystype YYSTYPE
# define YYSTYPE_IS_DECLARED 1
# define YYSTYPE_IS_TRIVIAL 1
#endif
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
typedef struct YYLTYPE
{
int first_line;
int first_column;
int last_line;
int last_column;
} YYLTYPE;
# define yyltype YYLTYPE
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
#endif
#line 566 "pl_gram.c"
#ifdef short
# undef short
#endif
#ifdef YYTYPE_UINT8
typedef YYTYPE_UINT8 yytype_uint8;
#else
typedef unsigned char yytype_uint8;
#endif
#ifdef YYTYPE_INT8
typedef YYTYPE_INT8 yytype_int8;
#elif (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
typedef signed char yytype_int8;
#else
typedef short int yytype_int8;
#endif
#ifdef YYTYPE_UINT16
typedef YYTYPE_UINT16 yytype_uint16;
#else
typedef unsigned short int yytype_uint16;
#endif
#ifdef YYTYPE_INT16
typedef YYTYPE_INT16 yytype_int16;
#else
typedef short int yytype_int16;
#endif
#ifndef YYSIZE_T
# ifdef __SIZE_TYPE__
# define YYSIZE_T __SIZE_TYPE__
# elif defined size_t
# define YYSIZE_T size_t
# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
# include <stddef.h>
# define YYSIZE_T size_t
# else
# define YYSIZE_T unsigned int
# endif
#endif
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
#ifndef YY_
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h>
# define YY_(msgid) dgettext ("bison-runtime", msgid)
# endif
# endif
# ifndef YY_
# define YY_(msgid) msgid
# endif
#endif
#if ! defined lint || defined __GNUC__
# define YYUSE(e) ((void) (e))
#else
# define YYUSE(e)
#endif
#ifndef lint
# define YYID(n) (n)
#else
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static int
YYID (int i)
#else
static int
YYID (i)
int i;
#endif
{
return i;
}
#endif
#if ! defined yyoverflow || YYERROR_VERBOSE
# ifdef YYSTACK_USE_ALLOCA
# if YYSTACK_USE_ALLOCA
# ifdef __GNUC__
# define YYSTACK_ALLOC __builtin_alloca
# elif defined __BUILTIN_VA_ARG_INCR
# include <alloca.h>
# elif defined _AIX
# define YYSTACK_ALLOC __alloca
# elif defined _MSC_VER
# include <malloc.h>
# define alloca _alloca
# else
# define YYSTACK_ALLOC alloca
# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
# include <stdlib.h>
# ifndef _STDLIB_H
# define _STDLIB_H 1
# endif
# endif
# endif
# endif
# endif
# ifdef YYSTACK_ALLOC
# define YYSTACK_FREE(Ptr) do { ; } while (YYID (0))
# ifndef YYSTACK_ALLOC_MAXIMUM
# define YYSTACK_ALLOC_MAXIMUM 4032
# endif
# else
# define YYSTACK_ALLOC YYMALLOC
# define YYSTACK_FREE YYFREE
# ifndef YYSTACK_ALLOC_MAXIMUM
# define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM
# endif
# if (defined __cplusplus && ! defined _STDLIB_H \
&& ! ((defined YYMALLOC || defined malloc) \
&& (defined YYFREE || defined free)))
# include <stdlib.h>
# ifndef _STDLIB_H
# define _STDLIB_H 1
# endif
# endif
# ifndef YYMALLOC
# define YYMALLOC malloc
# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
void *malloc (YYSIZE_T);
# endif
# endif
# ifndef YYFREE
# define YYFREE free
# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
void free (void *);
# endif
# endif
# endif
#endif
#if (! defined yyoverflow \
&& (! defined __cplusplus \
|| (defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL \
&& defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
union yyalloc
{
yytype_int16 yyss;
YYSTYPE yyvs;
YYLTYPE yyls;
};
# define YYSTACK_GAP_MAXIMUM (sizeof (union yyalloc) - 1)
# define YYSTACK_BYTES(N) \
((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
+ 2 * YYSTACK_GAP_MAXIMUM)
# ifndef YYCOPY
# if defined __GNUC__ && 1 < __GNUC__
# define YYCOPY(To, From, Count) \
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
# else
# define YYCOPY(To, From, Count) \
do \
{ \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(To)[yyi] = (From)[yyi]; \
} \
while (YYID (0))
# endif
# endif
# define YYSTACK_RELOCATE(Stack) \
do \
{ \
YYSIZE_T yynewbytes; \
YYCOPY (&yyptr->Stack, Stack, yysize); \
Stack = &yyptr->Stack; \
yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
yyptr += yynewbytes / sizeof (*yyptr); \
} \
while (YYID (0))
#endif
#define YYFINAL 3
#define YYLAST 1335
#define YYNTOKENS 139
#define YYNNTS 87
#define YYNRULES 253
#define YYNSTATES 334
#define YYUNDEFTOK 2
#define YYMAXUTOK 387
#define YYTRANSLATE(YYX) \
((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
static const yytype_uint8 yytranslate[] =
{
0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 133, 2, 2, 2, 2,
135, 136, 2, 2, 137, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 134,
2, 138, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 1, 2, 3, 4,
5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 33, 34,
35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, 52, 53, 54,
55, 56, 57, 58, 59, 60, 61, 62, 63, 64,
65, 66, 67, 68, 69, 70, 71, 72, 73, 74,
75, 76, 77, 78, 79, 80, 81, 82, 83, 84,
85, 86, 87, 88, 89, 90, 91, 92, 93, 94,
95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
115, 116, 117, 118, 119, 120, 121, 122, 123, 124,
125, 126, 127, 128, 129, 130, 131, 132
};
#if YYDEBUG
static const yytype_uint16 yyprhs[] =
{
0, 0, 3, 7, 8, 11, 15, 19, 23, 27,
31, 33, 35, 36, 38, 45, 47, 50, 54, 56,
59, 61, 63, 65, 69, 76, 82, 83, 91, 92,
95, 97, 98, 99, 103, 105, 109, 112, 114, 116,
118, 120, 122, 124, 126, 127, 129, 130, 131, 134,
137, 140, 141, 144, 146, 148, 150, 152, 154, 156,
157, 160, 163, 165, 167, 169, 171, 173, 175, 177,
179, 181, 183, 185, 187, 189, 191, 193, 195, 197,
199, 201, 203, 205, 207, 209, 211, 213, 215, 217,
223, 224, 226, 228, 232, 234, 238, 239, 241, 243,
245, 254, 255, 260, 261, 264, 272, 273, 276, 278,
282, 283, 286, 290, 295, 300, 303, 305, 307, 309,
318, 319, 322, 326, 328, 330, 332, 334, 336, 342,
344, 346, 348, 350, 352, 354, 357, 362, 367, 368,
372, 375, 379, 383, 386, 390, 391, 393, 395, 397,
398, 399, 403, 406, 408, 413, 417, 419, 421, 422,
423, 424, 425, 429, 430, 434, 435, 437, 439, 442,
444, 446, 448, 450, 452, 454, 456, 458, 460, 462,
464, 466, 468, 470, 472, 474, 476, 478, 480, 482,
484, 486, 488, 490, 492, 494, 496, 498, 500, 502,
504, 506, 508, 510, 512, 514, 516, 518, 520, 522,
524, 526, 528, 530, 532, 534, 536, 538, 540, 542,
544, 546, 548, 550, 552, 554, 556, 558, 560, 562,
564, 566, 568, 570, 572, 574, 576, 578, 580, 582,
584, 586, 588, 590, 592, 594, 596, 598, 600, 602,
604, 606, 608, 610
};
static const yytype_int16 yyrhs[] =
{
140, 0, -1, 141, 145, 144, -1, -1, 141, 142,
-1, 133, 94, 57, -1, 133, 103, 143, -1, 133,
129, 62, -1, 133, 129, 127, -1, 133, 129, 126,
-1, 22, -1, 225, -1, -1, 134, -1, 146, 34,
167, 211, 60, 222, -1, 220, -1, 220, 147, -1,
220, 147, 148, -1, 52, -1, 148, 149, -1, 149,
-1, 150, -1, 52, -1, 25, 224, 26, -1, 159,
160, 161, 162, 163, 164, -1, 159, 28, 68, 158,
134, -1, -1, 159, 152, 49, 151, 154, 157, 153,
-1, -1, 89, 116, -1, 116, -1, -1, -1, 135,
155, 136, -1, 156, -1, 155, 137, 156, -1, 159,
161, -1, 80, -1, 68, -1, 22, -1, 225, -1,
23, -1, 22, -1, 225, -1, -1, 44, -1, -1,
-1, 40, 22, -1, 40, 225, -1, 40, 23, -1,
-1, 90, 92, -1, 134, -1, 165, -1, 166, -1,
53, -1, 138, -1, 15, -1, -1, 167, 168, -1,
145, 134, -1, 171, -1, 178, -1, 181, -1, 186,
-1, 187, -1, 188, -1, 191, -1, 193, -1, 195,
-1, 196, -1, 197, -1, 199, -1, 200, -1, 169,
-1, 170, -1, 172, -1, 201, -1, 202, -1, 203,
-1, 205, -1, 206, -1, 207, -1, 208, -1, 96,
-1, 36, -1, 56, -1, 24, -1, 72, 173, 55,
174, 134, -1, -1, 48, -1, 119, -1, 174, 137,
175, -1, 175, -1, 177, 166, 176, -1, -1, 24,
-1, 22, -1, 23, -1, 74, 218, 167, 179, 180,
60, 74, 134, -1, -1, 179, 59, 218, 167, -1,
-1, 58, 167, -1, 37, 182, 183, 185, 60, 37,
134, -1, -1, 183, 184, -1, 184, -1, 131, 218,
167, -1, -1, 58, 167, -1, 221, 83, 198, -1,
221, 132, 219, 198, -1, 221, 68, 189, 198, -1,
190, 76, -1, 24, -1, 22, -1, 23, -1, 221,
69, 190, 192, 76, 31, 219, 198, -1, -1, 117,
11, -1, 194, 222, 223, -1, 65, -1, 47, -1,
108, -1, 106, -1, 32, -1, 167, 60, 83, 222,
134, -1, 75, -1, 78, -1, 84, -1, 22, -1,
23, -1, 64, -1, 93, 210, -1, 66, 204, 210,
79, -1, 87, 204, 210, 134, -1, -1, 39, 210,
134, -1, 92, 134, -1, 43, 209, 134, -1, 111,
209, 134, -1, 30, 38, -1, 30, 89, 38, -1,
-1, 24, -1, 22, -1, 23, -1, -1, -1, 63,
212, 213, -1, 213, 214, -1, 214, -1, 131, 215,
123, 167, -1, 215, 95, 216, -1, 216, -1, 224,
-1, -1, -1, -1, -1, 25, 224, 26, -1, -1,
25, 224, 26, -1, -1, 224, -1, 134, -1, 131,
217, -1, 22, -1, 225, -1, 24, -1, 27, -1,
28, -1, 30, -1, 31, -1, 32, -1, 33, -1,
36, -1, 38, -1, 39, -1, 40, -1, 41, -1,
42, -1, 43, -1, 44, -1, 45, -1, 46, -1,
47, -1, 48, -1, 49, -1, 50, -1, 51, -1,
53, -1, 54, -1, 55, -1, 56, -1, 57, -1,
59, -1, 61, -1, 62, -1, 63, -1, 65, -1,
66, -1, 67, -1, 70, -1, 72, -1, 73, -1,
75, -1, 77, -1, 78, -1, 80, -1, 81, -1,
82, -1, 84, -1, 85, -1, 86, -1, 87, -1,
88, -1, 89, -1, 91, -1, 93, -1, 94, -1,
96, -1, 97, -1, 98, -1, 99, -1, 100, -1,
101, -1, 102, -1, 103, -1, 104, -1, 105, -1,
106, -1, 107, -1, 108, -1, 109, -1, 110, -1,
111, -1, 112, -1, 113, -1, 114, -1, 115, -1,
116, -1, 117, -1, 118, -1, 119, -1, 121, -1,
122, -1, 125, -1, 126, -1, 127, -1, 129, -1,
130, -1
};
static const yytype_uint16 yyrline[] =
{
0, 375, 375, 382, 383, 386, 390, 399, 403, 407,
413, 417, 422, 423, 426, 449, 457, 464, 473, 485,
486, 489, 490, 494, 507, 549, 555, 554, 581, 584,
588, 595, 601, 604, 635, 639, 645, 653, 654, 656,
671, 686, 714, 742, 773, 774, 779, 791, 792, 797,
802, 809, 810, 814, 816, 822, 823, 831, 832, 836,
837, 847, 849, 851, 853, 855, 857, 859, 861, 863,
865, 867, 869, 871, 873, 875, 877, 879, 881, 883,
885, 887, 889, 891, 893, 897, 934, 952, 973, 1014,
1078, 1081, 1085, 1091, 1095, 1101, 1114, 1161, 1179, 1184,
1191, 1209, 1212, 1226, 1229, 1235, 1242, 1256, 1260, 1266,
1278, 1281, 1296, 1314, 1333, 1367, 1625, 1653, 1667, 1674,
1713, 1716, 1722, 1775, 1779, 1785, 1811, 1957, 1981, 1999,
2003, 2007, 2011, 2022, 2035, 2101, 2179, 2209, 2222, 2227,
2241, 2248, 2262, 2277, 2278, 2279, 2283, 2305, 2310, 2318,
2320, 2319, 2363, 2367, 2373, 2386, 2395, 2401, 2438, 2442,
2446, 2450, 2454, 2462, 2466, 2474, 2477, 2484, 2486, 2493,
2497, 2501, 2510, 2511, 2512, 2513, 2514, 2515, 2516, 2517,
2518, 2519, 2520, 2521, 2522, 2523, 2524, 2525, 2526, 2527,
2528, 2529, 2530, 2531, 2532, 2533, 2534, 2535, 2536, 2537,
2538, 2539, 2540, 2541, 2542, 2543, 2544, 2545, 2546, 2547,
2548, 2549, 2550, 2551, 2552, 2553, 2554, 2555, 2556, 2557,
2558, 2559, 2560, 2561, 2562, 2563, 2564, 2565, 2566, 2567,
2568, 2569, 2570, 2571, 2572, 2573, 2574, 2575, 2576, 2577,
2578, 2579, 2580, 2581, 2582, 2583, 2584, 2585, 2586, 2587,
2588, 2589, 2590, 2591
};
#endif
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
static const char *const yytname[] =
{
"$end", "error", "$undefined", "IDENT", "UIDENT", "FCONST", "SCONST",
"USCONST", "BCONST", "XCONST", "Op", "ICONST", "PARAM", "TYPECAST",
"DOT_DOT", "COLON_EQUALS", "EQUALS_GREATER", "LESS_EQUALS",
"GREATER_EQUALS", "NOT_EQUALS", "SQL_COMMENT", "C_COMMENT", "T_WORD",
"T_CWORD", "T_DATUM", "LESS_LESS", "GREATER_GREATER", "K_ABSOLUTE",
"K_ALIAS", "K_ALL", "K_AND", "K_ARRAY", "K_ASSERT", "K_BACKWARD",
"K_BEGIN", "K_BY", "K_CALL", "K_CASE", "K_CHAIN", "K_CLOSE", "K_COLLATE",
"K_COLUMN", "K_COLUMN_NAME", "K_COMMIT", "K_CONSTANT", "K_CONSTRAINT",
"K_CONSTRAINT_NAME", "K_CONTINUE", "K_CURRENT", "K_CURSOR", "K_DATATYPE",
"K_DEBUG", "K_DECLARE", "K_DEFAULT", "K_DETAIL", "K_DIAGNOSTICS", "K_DO",
"K_DUMP", "K_ELSE", "K_ELSIF", "K_END", "K_ERRCODE", "K_ERROR",
"K_EXCEPTION", "K_EXECUTE", "K_EXIT", "K_FETCH", "K_FIRST", "K_FOR",
"K_FOREACH", "K_FORWARD", "K_FROM", "K_GET", "K_HINT", "K_IF",
"K_IMPORT", "K_IN", "K_INFO", "K_INSERT", "K_INTO", "K_IS", "K_LAST",
"K_LOG", "K_LOOP", "K_MERGE", "K_MESSAGE", "K_MESSAGE_TEXT", "K_MOVE",
"K_NEXT", "K_NO", "K_NOT", "K_NOTICE", "K_NULL", "K_OPEN", "K_OPTION",
"K_OR", "K_PERFORM", "K_PG_CONTEXT", "K_PG_DATATYPE_NAME",
"K_PG_EXCEPTION_CONTEXT", "K_PG_EXCEPTION_DETAIL", "K_PG_EXCEPTION_HINT",
"K_PG_ROUTINE_OID", "K_PRINT_STRICT_PARAMS", "K_PRIOR", "K_QUERY",
"K_RAISE", "K_RELATIVE", "K_RETURN", "K_RETURNED_SQLSTATE", "K_REVERSE",
"K_ROLLBACK", "K_ROW_COUNT", "K_ROWTYPE", "K_SCHEMA", "K_SCHEMA_NAME",
"K_SCROLL", "K_SLICE", "K_SQLSTATE", "K_STACKED", "K_STRICT", "K_TABLE",
"K_TABLE_NAME", "K_THEN", "K_TO", "K_TYPE", "K_USE_COLUMN",
"K_USE_VARIABLE", "K_USING", "K_VARIABLE_CONFLICT", "K_WARNING",
"K_WHEN", "K_WHILE", "'#'", "';'", "'('", "')'", "','", "'='", "$accept",
"pl_function", "comp_options", "comp_option", "option_value", "opt_semi",
"pl_block", "decl_sect", "decl_start", "decl_stmts", "decl_stmt",
"decl_statement", "@1", "opt_scrollable", "decl_cursor_query",
"decl_cursor_args", "decl_cursor_arglist", "decl_cursor_arg",
"decl_is_for", "decl_aliasitem", "decl_varname", "decl_const",
"decl_datatype", "decl_collate", "decl_notnull", "decl_defval",
"decl_defkey", "assign_operator", "proc_sect", "proc_stmt",
"stmt_perform", "stmt_call", "stmt_assign", "stmt_getdiag",
"getdiag_area_opt", "getdiag_list", "getdiag_list_item", "getdiag_item",
"getdiag_target", "stmt_if", "stmt_elsifs", "stmt_else", "stmt_case",
"opt_expr_until_when", "case_when_list", "case_when", "opt_case_else",
"stmt_loop", "stmt_while", "stmt_for", "for_control", "for_variable",
"stmt_foreach_a", "foreach_slice", "stmt_exit", "exit_type",
"stmt_return", "stmt_raise", "stmt_assert", "loop_body", "stmt_execsql",
"stmt_dynexecute", "stmt_open", "stmt_fetch", "stmt_move",
"opt_fetch_direction", "stmt_close", "stmt_null", "stmt_commit",
"stmt_rollback", "opt_transaction_chain", "cursor_variable",
"exception_sect", "@2", "proc_exceptions", "proc_exception",
"proc_conditions", "proc_condition", "expr_until_semi",
"expr_until_then", "expr_until_loop", "opt_block_label",
"opt_loop_label", "opt_label", "opt_exitcond", "any_identifier",
"unreserved_keyword", 0
};
#endif
# ifdef YYPRINT
static const yytype_uint16 yytoknum[] =
{
0, 256, 257, 258, 259, 260, 261, 262, 263, 264,
265, 266, 267, 268, 269, 270, 271, 272, 273, 274,
275, 276, 277, 278, 279, 280, 281, 282, 283, 284,
285, 286, 287, 288, 289, 290, 291, 292, 293, 294,
295, 296, 297, 298, 299, 300, 301, 302, 303, 304,
305, 306, 307, 308, 309, 310, 311, 312, 313, 314,
315, 316, 317, 318, 319, 320, 321, 322, 323, 324,
325, 326, 327, 328, 329, 330, 331, 332, 333, 334,
335, 336, 337, 338, 339, 340, 341, 342, 343, 344,
345, 346, 347, 348, 349, 350, 351, 352, 353, 354,
355, 356, 357, 358, 359, 360, 361, 362, 363, 364,
365, 366, 367, 368, 369, 370, 371, 372, 373, 374,
375, 376, 377, 378, 379, 380, 381, 382, 383, 384,
385, 386, 387, 35, 59, 40, 41, 44, 61
};
# endif
static const yytype_uint8 yyr1[] =
{
0, 139, 140, 141, 141, 142, 142, 142, 142, 142,
143, 143, 144, 144, 145, 146, 146, 146, 147, 148,
148, 149, 149, 149, 150, 150, 151, 150, 152, 152,
152, 153, 154, 154, 155, 155, 156, 157, 157, 158,
158, 158, 159, 159, 160, 160, 161, 162, 162, 162,
162, 163, 163, 164, 164, 165, 165, 166, 166, 167,
167, 168, 168, 168, 168, 168, 168, 168, 168, 168,
168, 168, 168, 168, 168, 168, 168, 168, 168, 168,
168, 168, 168, 168, 168, 169, 170, 170, 171, 172,
173, 173, 173, 174, 174, 175, 176, 177, 177, 177,
178, 179, 179, 180, 180, 181, 182, 183, 183, 184,
185, 185, 186, 187, 188, 189, 190, 190, 190, 191,
192, 192, 193, 194, 194, 195, 196, 197, 198, 199,
199, 199, 199, 199, 200, 201, 202, 203, 204, 205,
206, 207, 208, 209, 209, 209, 210, 210, 210, 211,
212, 211, 213, 213, 214, 215, 215, 216, 217, 218,
219, 220, 220, 221, 221, 222, 222, 223, 223, 224,
224, 224, 225, 225, 225, 225, 225, 225, 225, 225,
225, 225, 225, 225, 225, 225, 225, 225, 225, 225,
225, 225, 225, 225, 225, 225, 225, 225, 225, 225,
225, 225, 225, 225, 225, 225, 225, 225, 225, 225,
225, 225, 225, 225, 225, 225, 225, 225, 225, 225,
225, 225, 225, 225, 225, 225, 225, 225, 225, 225,
225, 225, 225, 225, 225, 225, 225, 225, 225, 225,
225, 225, 225, 225, 225, 225, 225, 225, 225, 225,
225, 225, 225, 225
};
static const yytype_uint8 yyr2[] =
{
0, 2, 3, 0, 2, 3, 3, 3, 3, 3,
1, 1, 0, 1, 6, 1, 2, 3, 1, 2,
1, 1, 1, 3, 6, 5, 0, 7, 0, 2,
1, 0, 0, 3, 1, 3, 2, 1, 1, 1,
1, 1, 1, 1, 0, 1, 0, 0, 2, 2,
2, 0, 2, 1, 1, 1, 1, 1, 1, 0,
2, 2, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 5,
0, 1, 1, 3, 1, 3, 0, 1, 1, 1,
8, 0, 4, 0, 2, 7, 0, 2, 1, 3,
0, 2, 3, 4, 4, 2, 1, 1, 1, 8,
0, 2, 3, 1, 1, 1, 1, 1, 5, 1,
1, 1, 1, 1, 1, 2, 4, 4, 0, 3,
2, 3, 3, 2, 3, 0, 1, 1, 1, 0,
0, 3, 2, 1, 4, 3, 1, 1, 0, 0,
0, 0, 3, 0, 3, 0, 1, 1, 2, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1
};
static const yytype_uint8 yydefact[] =
{
3, 0, 161, 1, 0, 0, 4, 12, 0, 15,
169, 171, 172, 173, 174, 175, 176, 177, 178, 179,
180, 181, 182, 183, 184, 185, 186, 187, 188, 189,
190, 191, 192, 193, 194, 195, 196, 197, 198, 199,
200, 201, 202, 203, 204, 205, 206, 207, 208, 209,
210, 211, 212, 213, 214, 215, 216, 217, 218, 219,
220, 221, 222, 223, 224, 225, 226, 227, 228, 229,
230, 231, 232, 233, 234, 235, 236, 237, 238, 239,
240, 241, 242, 243, 244, 245, 246, 247, 248, 249,
250, 251, 252, 253, 0, 170, 0, 0, 0, 13,
2, 59, 18, 16, 162, 5, 10, 6, 11, 7,
9, 8, 163, 42, 0, 22, 17, 20, 21, 44,
43, 132, 133, 88, 0, 127, 86, 106, 0, 145,
124, 87, 150, 134, 123, 138, 90, 159, 129, 130,
131, 138, 0, 0, 85, 126, 125, 145, 0, 60,
75, 76, 62, 77, 63, 64, 65, 66, 67, 68,
69, 165, 70, 71, 72, 73, 74, 78, 79, 80,
81, 82, 83, 84, 0, 0, 0, 19, 0, 45,
0, 30, 0, 46, 0, 0, 147, 148, 146, 0,
0, 0, 0, 0, 91, 92, 0, 59, 0, 140,
135, 0, 61, 0, 166, 165, 0, 0, 59, 160,
23, 0, 29, 26, 47, 164, 159, 110, 108, 139,
143, 0, 141, 0, 151, 153, 0, 0, 163, 0,
142, 158, 167, 122, 14, 117, 118, 116, 59, 0,
120, 163, 112, 59, 39, 41, 0, 40, 32, 0,
51, 59, 59, 107, 0, 144, 0, 156, 157, 152,
136, 98, 99, 97, 0, 94, 0, 103, 137, 168,
114, 115, 0, 0, 0, 113, 25, 0, 0, 48,
50, 49, 0, 0, 163, 163, 0, 0, 59, 89,
0, 58, 57, 96, 59, 159, 0, 121, 0, 165,
0, 34, 46, 38, 37, 31, 52, 56, 53, 24,
54, 55, 0, 155, 163, 93, 95, 163, 59, 0,
160, 0, 33, 0, 36, 27, 105, 163, 0, 59,
128, 35, 100, 119
};
static const yytype_int16 yydefgoto[] =
{
-1, 1, 2, 6, 107, 100, 148, 8, 103, 116,
117, 118, 248, 182, 325, 278, 300, 301, 305, 246,
119, 183, 214, 250, 283, 309, 310, 293, 241, 149,
150, 151, 152, 153, 196, 264, 265, 316, 266, 154,
267, 296, 155, 185, 217, 218, 254, 156, 157, 158,
238, 239, 159, 273, 160, 161, 162, 163, 164, 242,
165, 166, 167, 168, 169, 193, 170, 171, 172, 173,
191, 189, 174, 192, 224, 225, 256, 257, 269, 197,
243, 9, 175, 203, 233, 204, 95
};
#define YYPACT_NINF -260
static const yytype_int16 yypact[] =
{
-260, 21, -20, -260, 355, -61, -260, -99, 3, 7,
-260, -260, -260, -260, -260, -260, -260, -260, -260, -260,
-260, -260, -260, -260, -260, -260, -260, -260, -260, -260,
-260, -260, -260, -260, -260, -260, -260, -260, -260, -260,
-260, -260, -260, -260, -260, -260, -260, -260, -260, -260,
-260, -260, -260, -260, -260, -260, -260, -260, -260, -260,
-260, -260, -260, -260, -260, -260, -260, -260, -260, -260,
-260, -260, -260, -260, -260, -260, -260, -260, -260, -260,
-260, -260, -260, -260, -260, -260, -260, -260, -260, -260,
-260, -260, -260, -260, 22, -260, 23, 679, -38, -260,
-260, -260, -260, 246, -260, -260, -260, -260, -260, -260,
-260, -260, 1026, -260, 355, -260, 246, -260, -260, -18,
-260, -260, -260, -260, 355, -260, -260, -260, 30, 49,
-260, -260, -260, -260, -260, -260, -37, -260, -260, -260,
-260, -260, -48, 30, -260, -260, -260, 49, -33, -260,
-260, -260, -260, -260, -260, -260, -260, -260, -260, -260,
-260, 355, -260, -260, -260, -260, -260, -260, -260, -260,
-260, -260, -260, -260, 36, -23, 78, -260, 37, -260,
-10, -260, 58, -260, 85, -17, -260, -260, -260, -22,
-19, -16, -15, 30, -260, -260, 62, -260, 30, -260,
-260, -11, -260, -95, -260, 355, 68, 68, -260, -260,
-260, 464, -260, -260, 79, -2, -260, -50, -260, -260,
-260, 86, -260, 355, -15, -260, 48, 71, 894, -6,
-260, -260, -260, -260, -260, -260, -260, -260, -260, 53,
13, 1092, -260, -260, -260, -260, -3, -260, -1, 573,
42, -260, -260, -260, 73, -260, -51, -260, -260, -260,
-260, -260, -260, -260, -76, -260, -12, 15, -260, -260,
-260, -260, 125, 59, 54, -260, -260, 785, -39, -260,
-260, -260, 46, -13, -9, 1158, 102, 355, -260, -260,
71, -260, -260, -260, -260, -260, 80, -260, 110, 355,
-60, -260, -260, -260, -260, -260, -260, -260, -260, -260,
-260, -260, 8, -260, 124, -260, -260, 1224, -260, 69,
-260, 10, -260, 785, -260, -260, -260, 960, 11, -260,
-260, -260, -260, -260
};
static const yytype_int16 yypgoto[] =
{
-260, -260, -260, -260, -260, -260, 148, -260, -260, -260,
35, -260, -260, -260, -260, -260, -260, -171, -260, -260,
-259, -260, -145, -260, -260, -260, -260, -124, -97, -260,
-260, -260, -260, -260, -260, -260, -128, -260, -260, -260,
-260, -260, -260, -260, -260, -53, -260, -260, -260, -260,
-260, -42, -260, -260, -260, -260, -260, -260, -260, -221,
-260, -260, -260, -260, -260, 25, -260, -260, -260, -260,
26, -131, -260, -260, -260, -56, -260, -118, -260, -210,
-150, -260, -260, -196, -260, -4, -96
};
#define YYTABLE_NINF -163
static const yytype_int16 yytable[] =
{
94, 108, 291, 291, 112, 4, 251, 120, 252, 234,
178, 194, 200, 121, 122, 123, 124, 270, 302, 220,
120, 3, 275, 125, 109, -161, 179, 126, 127, 303,
128, -28, -162, 96, 129, 99, 231, 101, 130, 232,
307, 304, 97, -161, 287, 206, 207, 131, 104, -109,
-162, -109, 186, 187, 188, 133, 134, 135, 289, 102,
208, 290, 226, 136, 302, 137, 138, 229, 98, 139,
221, 180, 288, 294, 295, 140, 322, 323, 141, 190,
105, 216, 195, 142, 143, 318, 199, 144, 110, 111,
235, 236, 237, 261, 262, 263, 205, 145, 181, 146,
228, 202, 147, 321, 210, 211, 212, 213, 333, 209,
176, 215, 219, 5, 216, 247, 223, 227, 222, 249,
184, 308, -109, 230, 255, 292, 292, 260, 268, 271,
272, 276, 282, 286, 277, 298, 297, 299, 306, 312,
319, 320, 326, 328, 330, 332, 121, 122, 123, 124,
7, 177, 331, 281, 284, 285, 125, 324, -161, 311,
126, 127, 315, 128, 253, 240, 198, 129, 259, 313,
329, 130, 0, 201, 0, 0, -161, 0, 0, 0,
131, 120, 0, 0, -154, 0, 0, 0, 133, 134,
135, 314, 0, 0, 0, 0, 136, 317, 137, 138,
0, 0, 139, 0, 0, 0, 0, 0, 140, 0,
0, 141, 0, 0, 0, 0, 142, 143, 0, 258,
144, 327, 0, 0, 0, 0, 0, 120, 0, 0,
145, 0, 146, 0, 0, 147, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, -154, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 113, 0,
0, 114, 0, 12, 13, 0, 14, 15, 16, 17,
0, 0, 18, 258, 19, 20, 21, 22, 23, 24,
25, 26, 27, 28, 29, 30, 31, 32, 115, 33,
34, 35, 36, 37, 0, 38, 0, 39, 40, 41,
0, 42, 43, 44, 0, 0, 45, 0, 46, 47,
0, 48, 0, 49, 50, 0, 51, 52, 53, 0,
54, 55, 56, 57, 58, 59, 0, 60, 0, 61,
62, 0, 63, 64, 65, 66, 67, 68, 69, 70,
71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
81, 82, 83, 84, 85, 86, 0, 87, 88, 0,
0, 89, 90, 91, 0, 92, 93, 10, 0, 11,
0, 0, 12, 13, 0, 14, 15, 16, 17, 0,
0, 18, 0, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 0, 33, 34,
35, 36, 37, 0, 38, 0, 39, 40, 41, 0,
42, 43, 44, 0, 0, 45, 0, 46, 47, 0,
48, 0, 49, 50, 0, 51, 52, 53, 0, 54,
55, 56, 57, 58, 59, 0, 60, 0, 61, 62,
0, 63, 64, 65, 66, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
82, 83, 84, 85, 86, 0, 87, 88, 0, 0,
89, 90, 91, 0, 92, 93, 244, 245, 0, 0,
0, 12, 13, 0, 14, 15, 16, 17, 0, 0,
18, 0, 19, 20, 21, 22, 23, 24, 25, 26,
27, 28, 29, 30, 31, 32, 0, 33, 34, 35,
36, 37, 0, 38, 0, 39, 40, 41, 0, 42,
43, 44, 0, 0, 45, 0, 46, 47, 0, 48,
0, 49, 50, 0, 51, 52, 53, 0, 54, 55,
56, 57, 58, 59, 0, 60, 0, 61, 62, 0,
63, 64, 65, 66, 67, 68, 69, 70, 71, 72,
73, 74, 75, 76, 77, 78, 79, 80, 81, 82,
83, 84, 85, 86, 0, 87, 88, 0, 0, 89,
90, 91, 0, 92, 93, 279, 280, 0, 0, 0,
12, 13, 0, 14, 15, 16, 17, 0, 0, 18,
0, 19, 20, 21, 22, 23, 24, 25, 26, 27,
28, 29, 30, 31, 32, 0, 33, 34, 35, 36,
37, 0, 38, 0, 39, 40, 41, 0, 42, 43,
44, 0, 0, 45, 0, 46, 47, 0, 48, 0,
49, 50, 0, 51, 52, 53, 0, 54, 55, 56,
57, 58, 59, 0, 60, 0, 61, 62, 0, 63,
64, 65, 66, 67, 68, 69, 70, 71, 72, 73,
74, 75, 76, 77, 78, 79, 80, 81, 82, 83,
84, 85, 86, 0, 87, 88, 0, 0, 89, 90,
91, 106, 92, 93, 0, 0, 12, 13, 0, 14,
15, 16, 17, 0, 0, 18, 0, 19, 20, 21,
22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
32, 0, 33, 34, 35, 36, 37, 0, 38, 0,
39, 40, 41, 0, 42, 43, 44, 0, 0, 45,
0, 46, 47, 0, 48, 0, 49, 50, 0, 51,
52, 53, 0, 54, 55, 56, 57, 58, 59, 0,
60, 0, 61, 62, 0, 63, 64, 65, 66, 67,
68, 69, 70, 71, 72, 73, 74, 75, 76, 77,
78, 79, 80, 81, 82, 83, 84, 85, 86, 0,
87, 88, 0, 0, 89, 90, 91, 113, 92, 93,
0, 0, 12, 13, 0, 14, 15, 16, 17, 0,
0, 18, 0, 19, 20, 21, 22, 23, 24, 25,
26, 27, 28, 29, 30, 31, 32, 0, 33, 34,
35, 36, 37, 0, 38, 0, 39, 40, 41, 0,
42, 43, 44, 0, 0, 45, 0, 46, 47, 0,
48, 0, 49, 50, 0, 51, 52, 53, 0, 54,
55, 56, 57, 58, 59, 0, 60, 0, 61, 62,
0, 63, 64, 65, 66, 67, 68, 69, 70, 71,
72, 73, 74, 75, 76, 77, 78, 79, 80, 81,
82, 83, 84, 85, 86, 0, 87, 88, 0, 0,
89, 90, 91, 0, 92, 93, 121, 122, 123, 124,
0, 0, 0, 0, 0, 0, 125, 0, -161, 0,
126, 127, 0, 128, 0, 0, 0, 129, 0, 0,
0, 130, 0, 0, 0, 0, -161, 0, 0, 0,
131, 0, -101, -101, -101, 0, 0, 0, 133, 134,
135, 0, 0, 0, 0, 0, 136, 0, 137, 138,
0, 0, 139, 0, 0, 0, 0, 0, 140, 0,
0, 141, 121, 122, 123, 124, 142, 143, 0, 0,
144, 0, 125, 0, -161, 0, 126, 127, 0, 128,
145, 0, 146, 129, 0, 147, 0, 130, 0, 0,
0, 0, -161, 0, 0, 0, 131, 0, -102, -102,
-102, 0, 0, 0, 133, 134, 135, 0, 0, 0,
0, 0, 136, 0, 137, 138, 0, 0, 139, 0,
0, 0, 0, 0, 140, 0, 0, 141, 121, 122,
123, 124, 142, 143, 0, 0, 144, 0, 125, 0,
-161, 0, 126, 127, 0, 128, 145, 0, 146, 129,
0, 147, 0, 130, 0, 0, 0, 0, -161, 0,
0, 0, 131, 0, 0, 0, -149, 0, 0, 132,
133, 134, 135, 0, 0, 0, 0, 0, 136, 0,
137, 138, 0, 0, 139, 0, 0, 0, 0, 0,
140, 0, 0, 141, 121, 122, 123, 124, 142, 143,
0, 0, 144, 0, 125, 0, -161, 0, 126, 127,
0, 128, 145, 0, 146, 129, 0, 147, 0, 130,
0, 0, 0, 0, -161, 0, 0, 0, 131, 0,
0, 0, 274, 0, 0, 0, 133, 134, 135, 0,
0, 0, 0, 0, 136, 0, 137, 138, 0, 0,
139, 0, 0, 0, 0, 0, 140, 0, 0, 141,
121, 122, 123, 124, 142, 143, 0, 0, 144, 0,
125, 0, -161, 0, 126, 127, 0, 128, 145, 0,
146, 129, 0, 147, 0, 130, 0, 0, 0, 0,
-161, 0, 0, 0, 131, 0, 0, 0, -111, 0,
0, 0, 133, 134, 135, 0, 0, 0, 0, 0,
136, 0, 137, 138, 0, 0, 139, 0, 0, 0,
0, 0, 140, 0, 0, 141, 121, 122, 123, 124,
142, 143, 0, 0, 144, 0, 125, 0, -161, 0,
126, 127, 0, 128, 145, 0, 146, 129, 0, 147,
0, 130, 0, 0, 0, 0, -161, 0, 0, 0,
131, 0, 0, 0, -104, 0, 0, 0, 133, 134,
135, 0, 0, 0, 0, 0, 136, 0, 137, 138,
0, 0, 139, 0, 0, 0, 0, 0, 140, 0,
0, 141, 0, 0, 0, 0, 142, 143, 0, 0,
144, 0, 0, 0, 0, 0, 0, 0, 0, 0,
145, 0, 146, 0, 0, 147
};
static const yytype_int16 yycheck[] =
{
4, 97, 15, 15, 101, 25, 216, 103, 58, 205,
28, 48, 143, 22, 23, 24, 25, 238, 277, 38,
116, 0, 243, 32, 62, 34, 44, 36, 37, 68,
39, 49, 34, 94, 43, 134, 131, 34, 47, 134,
53, 80, 103, 52, 95, 68, 69, 56, 26, 58,
52, 60, 22, 23, 24, 64, 65, 66, 134, 52,
83, 137, 193, 72, 323, 74, 75, 198, 129, 78,
89, 89, 123, 58, 59, 84, 136, 137, 87, 30,
57, 131, 119, 92, 93, 295, 134, 96, 126, 127,
22, 23, 24, 22, 23, 24, 60, 106, 116, 108,
197, 134, 111, 299, 26, 68, 116, 49, 329, 132,
114, 26, 134, 133, 131, 211, 131, 55, 134, 40,
124, 134, 131, 134, 38, 138, 138, 79, 134, 76,
117, 134, 90, 60, 135, 76, 11, 83, 92, 37,
60, 31, 134, 74, 134, 134, 22, 23, 24, 25,
2, 116, 323, 249, 251, 252, 32, 302, 34, 283,
36, 37, 290, 39, 217, 207, 141, 43, 224, 287,
320, 47, -1, 147, -1, -1, 52, -1, -1, -1,
56, 277, -1, -1, 60, -1, -1, -1, 64, 65,
66, 288, -1, -1, -1, -1, 72, 294, 74, 75,
-1, -1, 78, -1, -1, -1, -1, -1, 84, -1,
-1, 87, -1, -1, -1, -1, 92, 93, -1, 223,
96, 318, -1, -1, -1, -1, -1, 323, -1, -1,
106, -1, 108, -1, -1, 111, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, 131, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, 22, -1,
-1, 25, -1, 27, 28, -1, 30, 31, 32, 33,
-1, -1, 36, 287, 38, 39, 40, 41, 42, 43,
44, 45, 46, 47, 48, 49, 50, 51, 52, 53,
54, 55, 56, 57, -1, 59, -1, 61, 62, 63,
-1, 65, 66, 67, -1, -1, 70, -1, 72, 73,
-1, 75, -1, 77, 78, -1, 80, 81, 82, -1,
84, 85, 86, 87, 88, 89, -1, 91, -1, 93,
94, -1, 96, 97, 98, 99, 100, 101, 102, 103,
104, 105, 106, 107, 108, 109, 110, 111, 112, 113,
114, 115, 116, 117, 118, 119, -1, 121, 122, -1,
-1, 125, 126, 127, -1, 129, 130, 22, -1, 24,
-1, -1, 27, 28, -1, 30, 31, 32, 33, -1,
-1, 36, -1, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, -1, 53, 54,
55, 56, 57, -1, 59, -1, 61, 62, 63, -1,
65, 66, 67, -1, -1, 70, -1, 72, 73, -1,
75, -1, 77, 78, -1, 80, 81, 82, -1, 84,
85, 86, 87, 88, 89, -1, 91, -1, 93, 94,
-1, 96, 97, 98, 99, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
115, 116, 117, 118, 119, -1, 121, 122, -1, -1,
125, 126, 127, -1, 129, 130, 22, 23, -1, -1,
-1, 27, 28, -1, 30, 31, 32, 33, -1, -1,
36, -1, 38, 39, 40, 41, 42, 43, 44, 45,
46, 47, 48, 49, 50, 51, -1, 53, 54, 55,
56, 57, -1, 59, -1, 61, 62, 63, -1, 65,
66, 67, -1, -1, 70, -1, 72, 73, -1, 75,
-1, 77, 78, -1, 80, 81, 82, -1, 84, 85,
86, 87, 88, 89, -1, 91, -1, 93, 94, -1,
96, 97, 98, 99, 100, 101, 102, 103, 104, 105,
106, 107, 108, 109, 110, 111, 112, 113, 114, 115,
116, 117, 118, 119, -1, 121, 122, -1, -1, 125,
126, 127, -1, 129, 130, 22, 23, -1, -1, -1,
27, 28, -1, 30, 31, 32, 33, -1, -1, 36,
-1, 38, 39, 40, 41, 42, 43, 44, 45, 46,
47, 48, 49, 50, 51, -1, 53, 54, 55, 56,
57, -1, 59, -1, 61, 62, 63, -1, 65, 66,
67, -1, -1, 70, -1, 72, 73, -1, 75, -1,
77, 78, -1, 80, 81, 82, -1, 84, 85, 86,
87, 88, 89, -1, 91, -1, 93, 94, -1, 96,
97, 98, 99, 100, 101, 102, 103, 104, 105, 106,
107, 108, 109, 110, 111, 112, 113, 114, 115, 116,
117, 118, 119, -1, 121, 122, -1, -1, 125, 126,
127, 22, 129, 130, -1, -1, 27, 28, -1, 30,
31, 32, 33, -1, -1, 36, -1, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50,
51, -1, 53, 54, 55, 56, 57, -1, 59, -1,
61, 62, 63, -1, 65, 66, 67, -1, -1, 70,
-1, 72, 73, -1, 75, -1, 77, 78, -1, 80,
81, 82, -1, 84, 85, 86, 87, 88, 89, -1,
91, -1, 93, 94, -1, 96, 97, 98, 99, 100,
101, 102, 103, 104, 105, 106, 107, 108, 109, 110,
111, 112, 113, 114, 115, 116, 117, 118, 119, -1,
121, 122, -1, -1, 125, 126, 127, 22, 129, 130,
-1, -1, 27, 28, -1, 30, 31, 32, 33, -1,
-1, 36, -1, 38, 39, 40, 41, 42, 43, 44,
45, 46, 47, 48, 49, 50, 51, -1, 53, 54,
55, 56, 57, -1, 59, -1, 61, 62, 63, -1,
65, 66, 67, -1, -1, 70, -1, 72, 73, -1,
75, -1, 77, 78, -1, 80, 81, 82, -1, 84,
85, 86, 87, 88, 89, -1, 91, -1, 93, 94,
-1, 96, 97, 98, 99, 100, 101, 102, 103, 104,
105, 106, 107, 108, 109, 110, 111, 112, 113, 114,
115, 116, 117, 118, 119, -1, 121, 122, -1, -1,
125, 126, 127, -1, 129, 130, 22, 23, 24, 25,
-1, -1, -1, -1, -1, -1, 32, -1, 34, -1,
36, 37, -1, 39, -1, -1, -1, 43, -1, -1,
-1, 47, -1, -1, -1, -1, 52, -1, -1, -1,
56, -1, 58, 59, 60, -1, -1, -1, 64, 65,
66, -1, -1, -1, -1, -1, 72, -1, 74, 75,
-1, -1, 78, -1, -1, -1, -1, -1, 84, -1,
-1, 87, 22, 23, 24, 25, 92, 93, -1, -1,
96, -1, 32, -1, 34, -1, 36, 37, -1, 39,
106, -1, 108, 43, -1, 111, -1, 47, -1, -1,
-1, -1, 52, -1, -1, -1, 56, -1, 58, 59,
60, -1, -1, -1, 64, 65, 66, -1, -1, -1,
-1, -1, 72, -1, 74, 75, -1, -1, 78, -1,
-1, -1, -1, -1, 84, -1, -1, 87, 22, 23,
24, 25, 92, 93, -1, -1, 96, -1, 32, -1,
34, -1, 36, 37, -1, 39, 106, -1, 108, 43,
-1, 111, -1, 47, -1, -1, -1, -1, 52, -1,
-1, -1, 56, -1, -1, -1, 60, -1, -1, 63,
64, 65, 66, -1, -1, -1, -1, -1, 72, -1,
74, 75, -1, -1, 78, -1, -1, -1, -1, -1,
84, -1, -1, 87, 22, 23, 24, 25, 92, 93,
-1, -1, 96, -1, 32, -1, 34, -1, 36, 37,
-1, 39, 106, -1, 108, 43, -1, 111, -1, 47,
-1, -1, -1, -1, 52, -1, -1, -1, 56, -1,
-1, -1, 60, -1, -1, -1, 64, 65, 66, -1,
-1, -1, -1, -1, 72, -1, 74, 75, -1, -1,
78, -1, -1, -1, -1, -1, 84, -1, -1, 87,
22, 23, 24, 25, 92, 93, -1, -1, 96, -1,
32, -1, 34, -1, 36, 37, -1, 39, 106, -1,
108, 43, -1, 111, -1, 47, -1, -1, -1, -1,
52, -1, -1, -1, 56, -1, -1, -1, 60, -1,
-1, -1, 64, 65, 66, -1, -1, -1, -1, -1,
72, -1, 74, 75, -1, -1, 78, -1, -1, -1,
-1, -1, 84, -1, -1, 87, 22, 23, 24, 25,
92, 93, -1, -1, 96, -1, 32, -1, 34, -1,
36, 37, -1, 39, 106, -1, 108, 43, -1, 111,
-1, 47, -1, -1, -1, -1, 52, -1, -1, -1,
56, -1, -1, -1, 60, -1, -1, -1, 64, 65,
66, -1, -1, -1, -1, -1, 72, -1, 74, 75,
-1, -1, 78, -1, -1, -1, -1, -1, 84, -1,
-1, 87, -1, -1, -1, -1, 92, 93, -1, -1,
96, -1, -1, -1, -1, -1, -1, -1, -1, -1,
106, -1, 108, -1, -1, 111
};
static const yytype_uint8 yystos[] =
{
0, 140, 141, 0, 25, 133, 142, 145, 146, 220,
22, 24, 27, 28, 30, 31, 32, 33, 36, 38,
39, 40, 41, 42, 43, 44, 45, 46, 47, 48,
49, 50, 51, 53, 54, 55, 56, 57, 59, 61,
62, 63, 65, 66, 67, 70, 72, 73, 75, 77,
78, 80, 81, 82, 84, 85, 86, 87, 88, 89,
91, 93, 94, 96, 97, 98, 99, 100, 101, 102,
103, 104, 105, 106, 107, 108, 109, 110, 111, 112,
113, 114, 115, 116, 117, 118, 119, 121, 122, 125,
126, 127, 129, 130, 224, 225, 94, 103, 129, 134,
144, 34, 52, 147, 26, 57, 22, 143, 225, 62,
126, 127, 167, 22, 25, 52, 148, 149, 150, 159,
225, 22, 23, 24, 25, 32, 36, 37, 39, 43,
47, 56, 63, 64, 65, 66, 72, 74, 75, 78,
84, 87, 92, 93, 96, 106, 108, 111, 145, 168,
169, 170, 171, 172, 178, 181, 186, 187, 188, 191,
193, 194, 195, 196, 197, 199, 200, 201, 202, 203,
205, 206, 207, 208, 211, 221, 224, 149, 28, 44,
89, 116, 152, 160, 224, 182, 22, 23, 24, 210,
30, 209, 212, 204, 48, 119, 173, 218, 204, 134,
210, 209, 134, 222, 224, 60, 68, 69, 83, 132,
26, 68, 116, 49, 161, 26, 131, 183, 184, 134,
38, 89, 134, 131, 213, 214, 210, 55, 167, 210,
134, 131, 134, 223, 222, 22, 23, 24, 189, 190,
190, 167, 198, 219, 22, 23, 158, 225, 151, 40,
162, 218, 58, 184, 185, 38, 215, 216, 224, 214,
79, 22, 23, 24, 174, 175, 177, 179, 134, 217,
198, 76, 117, 192, 60, 198, 134, 135, 154, 22,
23, 225, 90, 163, 167, 167, 60, 95, 123, 134,
137, 15, 138, 166, 58, 59, 180, 11, 76, 83,
155, 156, 159, 68, 80, 157, 92, 53, 134, 164,
165, 166, 37, 216, 167, 175, 176, 167, 218, 60,
31, 222, 136, 137, 161, 153, 134, 167, 74, 219,
134, 156, 134, 198
};
#define yyerrok (yyerrstatus = 0)
#define yyclearin (yychar = YYEMPTY)
#define YYEMPTY (-2)
#define YYEOF 0
#define YYACCEPT goto yyacceptlab
#define YYABORT goto yyabortlab
#define YYERROR goto yyerrorlab
#define YYFAIL goto yyerrlab
#define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(Token, Value) \
do \
if (yychar == YYEMPTY && yylen == 1) \
{ \
yychar = (Token); \
yylval = (Value); \
yytoken = YYTRANSLATE (yychar); \
YYPOPSTACK (1); \
goto yybackup; \
} \
else \
{ \
yyerror (&yylloc, plpgsql_parse_result_p, yyscanner, YY_("syntax error: cannot back up")); \
YYERROR; \
} \
while (YYID (0))
#define YYTERROR 1
#define YYERRCODE 256
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (YYID (N)) \
{ \
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
} \
else \
{ \
(Current).first_line = (Current).last_line = \
YYRHSLOC (Rhs, 0).last_line; \
(Current).first_column = (Current).last_column = \
YYRHSLOC (Rhs, 0).last_column; \
} \
while (YYID (0))
#endif
#ifndef YY_LOCATION_PRINT
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
# define YY_LOCATION_PRINT(File, Loc) \
fprintf (File, "%d.%d-%d.%d", \
(Loc).first_line, (Loc).first_column, \
(Loc).last_line, (Loc).last_column)
# else
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
# endif
#endif
#ifdef YYLEX_PARAM
# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
#else
# define YYLEX yylex (&yylval, &yylloc, yyscanner)
#endif
#if YYDEBUG
# ifndef YYFPRINTF
# include <stdio.h>
# define YYFPRINTF fprintf
# endif
# define YYDPRINTF(Args) \
do { \
if (yydebug) \
YYFPRINTF Args; \
} while (YYID (0))
# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \
do { \
if (yydebug) \
{ \
YYFPRINTF (stderr, "%s ", Title); \
yy_symbol_print (stderr, \
Type, Value, Location, plpgsql_parse_result_p, yyscanner); \
YYFPRINTF (stderr, "\n"); \
} \
} while (YYID (0))
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, PLpgSQL_stmt_block **plpgsql_parse_result_p, yyscan_t yyscanner)
#else
static void
yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, plpgsql_parse_result_p, yyscanner)
FILE *yyoutput;
int yytype;
YYSTYPE const * const yyvaluep;
YYLTYPE const * const yylocationp;
PLpgSQL_stmt_block **plpgsql_parse_result_p;
yyscan_t yyscanner;
#endif
{
if (!yyvaluep)
return;
YYUSE (yylocationp);
YYUSE (plpgsql_parse_result_p);
YYUSE (yyscanner);
# ifdef YYPRINT
if (yytype < YYNTOKENS)
YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
# else
YYUSE (yyoutput);
# endif
switch (yytype)
{
default:
break;
}
}
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, PLpgSQL_stmt_block **plpgsql_parse_result_p, yyscan_t yyscanner)
#else
static void
yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, plpgsql_parse_result_p, yyscanner)
FILE *yyoutput;
int yytype;
YYSTYPE const * const yyvaluep;
YYLTYPE const * const yylocationp;
PLpgSQL_stmt_block **plpgsql_parse_result_p;
yyscan_t yyscanner;
#endif
{
if (yytype < YYNTOKENS)
YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
else
YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
YY_LOCATION_PRINT (yyoutput, *yylocationp);
YYFPRINTF (yyoutput, ": ");
yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, plpgsql_parse_result_p, yyscanner);
YYFPRINTF (yyoutput, ")");
}
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yy_stack_print (yytype_int16 *bottom, yytype_int16 *top)
#else
static void
yy_stack_print (bottom, top)
yytype_int16 *bottom;
yytype_int16 *top;
#endif
{
YYFPRINTF (stderr, "Stack now");
for (; bottom <= top; ++bottom)
YYFPRINTF (stderr, " %d", *bottom);
YYFPRINTF (stderr, "\n");
}
# define YY_STACK_PRINT(Bottom, Top) \
do { \
if (yydebug) \
yy_stack_print ((Bottom), (Top)); \
} while (YYID (0))
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, PLpgSQL_stmt_block **plpgsql_parse_result_p, yyscan_t yyscanner)
#else
static void
yy_reduce_print (yyvsp, yylsp, yyrule, plpgsql_parse_result_p, yyscanner)
YYSTYPE *yyvsp;
YYLTYPE *yylsp;
int yyrule;
PLpgSQL_stmt_block **plpgsql_parse_result_p;
yyscan_t yyscanner;
#endif
{
int yynrhs = yyr2[yyrule];
int yyi;
unsigned long int yylno = yyrline[yyrule];
YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
yyrule - 1, yylno);
for (yyi = 0; yyi < yynrhs; yyi++)
{
fprintf (stderr, " $%d = ", yyi + 1);
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
&(yyvsp[(yyi + 1) - (yynrhs)])
, &(yylsp[(yyi + 1) - (yynrhs)]) , plpgsql_parse_result_p, yyscanner);
fprintf (stderr, "\n");
}
}
# define YY_REDUCE_PRINT(Rule) \
do { \
if (yydebug) \
yy_reduce_print (yyvsp, yylsp, Rule, plpgsql_parse_result_p, yyscanner); \
} while (YYID (0))
int yydebug;
#else
# define YYDPRINTF(Args)
# define YY_SYMBOL_PRINT(Title, Type, Value, Location)
# define YY_STACK_PRINT(Bottom, Top)
# define YY_REDUCE_PRINT(Rule)
#endif
#ifndef YYINITDEPTH
# define YYINITDEPTH 200
#endif
#ifndef YYMAXDEPTH
# define YYMAXDEPTH 10000
#endif
#if YYERROR_VERBOSE
# ifndef yystrlen
# if defined __GLIBC__ && defined _STRING_H
# define yystrlen strlen
# else
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static YYSIZE_T
yystrlen (const char *yystr)
#else
static YYSIZE_T
yystrlen (yystr)
const char *yystr;
#endif
{
YYSIZE_T yylen;
for (yylen = 0; yystr[yylen]; yylen++)
continue;
return yylen;
}
# endif
# endif
# ifndef yystpcpy
# if defined __GLIBC__ && defined _STRING_H && defined _GNU_SOURCE
# define yystpcpy stpcpy
# else
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static char *
yystpcpy (char *yydest, const char *yysrc)
#else
static char *
yystpcpy (yydest, yysrc)
char *yydest;
const char *yysrc;
#endif
{
char *yyd = yydest;
const char *yys = yysrc;
while ((*yyd++ = *yys++) != '\0')
continue;
return yyd - 1;
}
# endif
# endif
# ifndef yytnamerr
static YYSIZE_T
yytnamerr (char *yyres, const char *yystr)
{
if (*yystr == '"')
{
YYSIZE_T yyn = 0;
char const *yyp = yystr;
for (;;)
switch (*++yyp)
{
case '\'':
case ',':
goto do_not_strip_quotes;
case '\\':
if (*++yyp != '\\')
goto do_not_strip_quotes;
default:
if (yyres)
yyres[yyn] = *yyp;
yyn++;
break;
case '"':
if (yyres)
yyres[yyn] = '\0';
return yyn;
}
do_not_strip_quotes: ;
}
if (! yyres)
return yystrlen (yystr);
return yystpcpy (yyres, yystr) - yyres;
}
# endif
static YYSIZE_T
yysyntax_error (char *yyresult, int yystate, int yychar)
{
int yyn = yypact[yystate];
if (! (YYPACT_NINF < yyn && yyn <= YYLAST))
return 0;
else
{
int yytype = YYTRANSLATE (yychar);
YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]);
YYSIZE_T yysize = yysize0;
YYSIZE_T yysize1;
int yysize_overflow = 0;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
int yyx;
# if 0
YY_("syntax error, unexpected %s");
YY_("syntax error, unexpected %s, expecting %s");
YY_("syntax error, unexpected %s, expecting %s or %s");
YY_("syntax error, unexpected %s, expecting %s or %s or %s");
YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s");
# endif
char *yyfmt;
char const *yyf;
static char const yyunexpected[] = "syntax error, unexpected %s";
static char const yyexpecting[] = ", expecting %s";
static char const yyor[] = " or %s";
char yyformat[sizeof yyunexpected
+ sizeof yyexpecting - 1
+ ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2)
* (sizeof yyor - 1))];
char const *yyprefix = yyexpecting;
int yyxbegin = yyn < 0 ? -yyn : 0;
int yychecklim = YYLAST - yyn + 1;
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
int yycount = 1;
yyarg[0] = yytname[yytype];
yyfmt = yystpcpy (yyformat, yyunexpected);
for (yyx = yyxbegin; yyx < yyxend; ++yyx)
if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR)
{
if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM)
{
yycount = 1;
yysize = yysize0;
yyformat[sizeof yyunexpected - 1] = '\0';
break;
}
yyarg[yycount++] = yytname[yyx];
yysize1 = yysize + yytnamerr (0, yytname[yyx]);
yysize_overflow |= (yysize1 < yysize);
yysize = yysize1;
yyfmt = yystpcpy (yyfmt, yyprefix);
yyprefix = yyor;
}
yyf = YY_(yyformat);
yysize1 = yysize + yystrlen (yyf);
yysize_overflow |= (yysize1 < yysize);
yysize = yysize1;
if (yysize_overflow)
return YYSIZE_MAXIMUM;
if (yyresult)
{
char *yyp = yyresult;
int yyi = 0;
while ((*yyp = *yyf) != '\0')
{
if (*yyp == '%' && yyf[1] == 's' && yyi < yycount)
{
yyp += yytnamerr (yyp, yyarg[yyi++]);
yyf += 2;
}
else
{
yyp++;
yyf++;
}
}
}
return yysize;
}
}
#endif
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
static void
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, PLpgSQL_stmt_block **plpgsql_parse_result_p, yyscan_t yyscanner)
#else
static void
yydestruct (yymsg, yytype, yyvaluep, yylocationp, plpgsql_parse_result_p, yyscanner)
const char *yymsg;
int yytype;
YYSTYPE *yyvaluep;
YYLTYPE *yylocationp;
PLpgSQL_stmt_block **plpgsql_parse_result_p;
yyscan_t yyscanner;
#endif
{
YYUSE (yyvaluep);
YYUSE (yylocationp);
YYUSE (plpgsql_parse_result_p);
YYUSE (yyscanner);
if (!yymsg)
yymsg = "Deleting";
YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
switch (yytype)
{
default:
break;
}
}
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
#else
int yyparse ();
#endif
#else
#if defined __STDC__ || defined __cplusplus
int yyparse (PLpgSQL_stmt_block **plpgsql_parse_result_p, yyscan_t yyscanner);
#else
int yyparse ();
#endif
#endif
#ifdef YYPARSE_PARAM
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
int
yyparse (void *YYPARSE_PARAM)
#else
int
yyparse (YYPARSE_PARAM)
void *YYPARSE_PARAM;
#endif
#else
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
int
yyparse (PLpgSQL_stmt_block **plpgsql_parse_result_p, yyscan_t yyscanner)
#else
int
yyparse (plpgsql_parse_result_p, yyscanner)
PLpgSQL_stmt_block **plpgsql_parse_result_p;
yyscan_t yyscanner;
#endif
#endif
{
int yychar;
YYSTYPE yylval;
int yynerrs;
YYLTYPE yylloc;
int yystate;
int yyn;
int yyresult;
int yyerrstatus;
int yytoken = 0;
#if YYERROR_VERBOSE
char yymsgbuf[128];
char *yymsg = yymsgbuf;
YYSIZE_T yymsg_alloc = sizeof yymsgbuf;
#endif
yytype_int16 yyssa[YYINITDEPTH];
yytype_int16 *yyss = yyssa;
yytype_int16 *yyssp;
YYSTYPE yyvsa[YYINITDEPTH];
YYSTYPE *yyvs = yyvsa;
YYSTYPE *yyvsp;
YYLTYPE yylsa[YYINITDEPTH];
YYLTYPE *yyls = yylsa;
YYLTYPE *yylsp;
YYLTYPE yyerror_range[2];
#define YYPOPSTACK(N) (yyvsp -= (N), yyssp -= (N), yylsp -= (N))
YYSIZE_T yystacksize = YYINITDEPTH;
YYSTYPE yyval;
YYLTYPE yyloc;
int yylen = 0;
YYDPRINTF ((stderr, "Starting parse\n"));
yystate = 0;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY;
yyssp = yyss;
yyvsp = yyvs;
yylsp = yyls;
#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
yylloc.first_line = yylloc.last_line = 1;
yylloc.first_column = yylloc.last_column = 0;
#endif
goto yysetstate;
yynewstate:
yyssp++;
yysetstate:
*yyssp = yystate;
if (yyss + yystacksize - 1 <= yyssp)
{
YYSIZE_T yysize = yyssp - yyss + 1;
#ifdef yyoverflow
{
YYSTYPE *yyvs1 = yyvs;
yytype_int16 *yyss1 = yyss;
YYLTYPE *yyls1 = yyls;
yyoverflow (YY_("memory exhausted"),
&yyss1, yysize * sizeof (*yyssp),
&yyvs1, yysize * sizeof (*yyvsp),
&yyls1, yysize * sizeof (*yylsp),
&yystacksize);
yyls = yyls1;
yyss = yyss1;
yyvs = yyvs1;
}
#else
# ifndef YYSTACK_RELOCATE
goto yyexhaustedlab;
# else
if (YYMAXDEPTH <= yystacksize)
goto yyexhaustedlab;
yystacksize *= 2;
if (YYMAXDEPTH < yystacksize)
yystacksize = YYMAXDEPTH;
{
yytype_int16 *yyss1 = yyss;
union yyalloc *yyptr =
(union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
if (! yyptr)
goto yyexhaustedlab;
YYSTACK_RELOCATE (yyss);
YYSTACK_RELOCATE (yyvs);
YYSTACK_RELOCATE (yyls);
# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
# endif
#endif
yyssp = yyss + yysize - 1;
yyvsp = yyvs + yysize - 1;
yylsp = yyls + yysize - 1;
YYDPRINTF ((stderr, "Stack size increased to %lu\n",
(unsigned long int) yystacksize));
if (yyss + yystacksize - 1 <= yyssp)
YYABORT;
}
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
goto yybackup;
yybackup:
yyn = yypact[yystate];
if (yyn == YYPACT_NINF)
goto yydefault;
if (yychar == YYEMPTY)
{
YYDPRINTF ((stderr, "Reading a token: "));
yychar = YYLEX;
}
if (yychar <= YYEOF)
{
yychar = yytoken = YYEOF;
YYDPRINTF ((stderr, "Now at end of input.\n"));
}
else
{
yytoken = YYTRANSLATE (yychar);
YY_SYMBOL_PRINT ("Next token is", yytoken, &yylval, &yylloc);
}
yyn += yytoken;
if (yyn < 0 || YYLAST < yyn || yycheck[yyn] != yytoken)
goto yydefault;
yyn = yytable[yyn];
if (yyn <= 0)
{
if (yyn == 0 || yyn == YYTABLE_NINF)
goto yyerrlab;
yyn = -yyn;
goto yyreduce;
}
if (yyn == YYFINAL)
YYACCEPT;
if (yyerrstatus)
yyerrstatus--;
YY_SYMBOL_PRINT ("Shifting", yytoken, &yylval, &yylloc);
if (yychar != YYEOF)
yychar = YYEMPTY;
yystate = yyn;
*++yyvsp = yylval;
*++yylsp = yylloc;
goto yynewstate;
yydefault:
yyn = yydefact[yystate];
if (yyn == 0)
goto yyerrlab;
goto yyreduce;
yyreduce:
yylen = yyr2[yyn];
yyval = yyvsp[1-yylen];
YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
YY_REDUCE_PRINT (yyn);
switch (yyn)
{
case 2:
#line 376 "pl_gram.y"
{
*plpgsql_parse_result_p = (PLpgSQL_stmt_block *) (yyvsp[(2) - (3)].stmt);
(void) yynerrs;
;}
break;
case 5:
#line 387 "pl_gram.y"
{
plpgsql_DumpExecTree = true;
;}
break;
case 6:
#line 391 "pl_gram.y"
{
if (strcmp((yyvsp[(3) - (3)].str), "on") == 0)
plpgsql_curr_compile->print_strict_params = true;
else if (strcmp((yyvsp[(3) - (3)].str), "off") == 0)
plpgsql_curr_compile->print_strict_params = false;
else
elog(ERROR, "unrecognized print_strict_params option %s", (yyvsp[(3) - (3)].str));
;}
break;
case 7:
#line 400 "pl_gram.y"
{
plpgsql_curr_compile->resolve_option = PLPGSQL_RESOLVE_ERROR;
;}
break;
case 8:
#line 404 "pl_gram.y"
{
plpgsql_curr_compile->resolve_option = PLPGSQL_RESOLVE_VARIABLE;
;}
break;
case 9:
#line 408 "pl_gram.y"
{
plpgsql_curr_compile->resolve_option = PLPGSQL_RESOLVE_COLUMN;
;}
break;
case 10:
#line 414 "pl_gram.y"
{
(yyval.str) = (yyvsp[(1) - (1)].word).ident;
;}
break;
case 11:
#line 418 "pl_gram.y"
{
(yyval.str) = pstrdup((yyvsp[(1) - (1)].keyword));
;}
break;
case 14:
#line 427 "pl_gram.y"
{
PLpgSQL_stmt_block *new;
new = palloc0(sizeof(PLpgSQL_stmt_block));
new->cmd_type = PLPGSQL_STMT_BLOCK;
new->lineno = plpgsql_location_to_lineno((yylsp[(2) - (6)]), yyscanner);
new->stmtid = ++plpgsql_curr_compile->nstatements;
new->label = (yyvsp[(1) - (6)].declhdr).label;
new->n_initvars = (yyvsp[(1) - (6)].declhdr).n_initvars;
new->initvarnos = (yyvsp[(1) - (6)].declhdr).initvarnos;
new->body = (yyvsp[(3) - (6)].list);
new->exceptions = (yyvsp[(4) - (6)].exception_block);
check_labels((yyvsp[(1) - (6)].declhdr).label, (yyvsp[(6) - (6)].str), (yylsp[(6) - (6)]), yyscanner);
plpgsql_ns_pop();
(yyval.stmt) = (PLpgSQL_stmt *) new;
;}
break;
case 15:
#line 450 "pl_gram.y"
{
plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_NORMAL;
(yyval.declhdr).label = (yyvsp[(1) - (1)].str);
(yyval.declhdr).n_initvars = 0;
(yyval.declhdr).initvarnos = NULL;
;}
break;
case 16:
#line 458 "pl_gram.y"
{
plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_NORMAL;
(yyval.declhdr).label = (yyvsp[(1) - (2)].str);
(yyval.declhdr).n_initvars = 0;
(yyval.declhdr).initvarnos = NULL;
;}
break;
case 17:
#line 465 "pl_gram.y"
{
plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_NORMAL;
(yyval.declhdr).label = (yyvsp[(1) - (3)].str);
(yyval.declhdr).n_initvars = plpgsql_add_initdatums(&((yyval.declhdr).initvarnos));
;}
break;
case 18:
#line 474 "pl_gram.y"
{
plpgsql_add_initdatums(NULL);
plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_DECLARE;
;}
break;
case 22:
#line 491 "pl_gram.y"
{
;}
break;
case 23:
#line 495 "pl_gram.y"
{
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("block label must be placed before DECLARE, not after"),
parser_errposition((yylsp[(1) - (3)]))));
;}
break;
case 24:
#line 508 "pl_gram.y"
{
PLpgSQL_variable *var;
if (OidIsValid((yyvsp[(4) - (6)].oid)))
{
if (!OidIsValid((yyvsp[(3) - (6)].dtype)->collation))
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("collations are not supported by type %s",
format_type_be((yyvsp[(3) - (6)].dtype)->typoid)),
parser_errposition((yylsp[(4) - (6)]))));
(yyvsp[(3) - (6)].dtype)->collation = (yyvsp[(4) - (6)].oid);
}
var = plpgsql_build_variable((yyvsp[(1) - (6)].varname).name, (yyvsp[(1) - (6)].varname).lineno,
(yyvsp[(3) - (6)].dtype), true);
var->isconst = (yyvsp[(2) - (6)].boolean);
var->notnull = (yyvsp[(5) - (6)].boolean);
var->default_val = (yyvsp[(6) - (6)].expr);
if (var->notnull && var->default_val == NULL)
ereport(ERROR,
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),
errmsg("variable \"%s\" must have a default value, since it's declared NOT NULL",
var->refname),
parser_errposition((yylsp[(5) - (6)]))));
if (var->default_val != NULL)
mark_expr_as_assignment_source(var->default_val,
(PLpgSQL_datum *) var);
;}
break;
case 25:
#line 550 "pl_gram.y"
{
plpgsql_ns_additem((yyvsp[(4) - (5)].nsitem)->itemtype,
(yyvsp[(4) - (5)].nsitem)->itemno, (yyvsp[(1) - (5)].varname).name);
;}
break;
case 26:
#line 555 "pl_gram.y"
{ plpgsql_ns_push((yyvsp[(1) - (3)].varname).name, PLPGSQL_LABEL_OTHER); ;}
break;
case 27:
#line 557 "pl_gram.y"
{
PLpgSQL_var *new;
plpgsql_ns_pop();
new = (PLpgSQL_var *)
plpgsql_build_variable((yyvsp[(1) - (7)].varname).name, (yyvsp[(1) - (7)].varname).lineno,
plpgsql_build_datatype(REFCURSOROID,
-1,
InvalidOid,
NULL),
true);
new->cursor_explicit_expr = (yyvsp[(7) - (7)].expr);
if ((yyvsp[(5) - (7)].datum) == NULL)
new->cursor_explicit_argrow = -1;
else
new->cursor_explicit_argrow = (yyvsp[(5) - (7)].datum)->dno;
new->cursor_options = CURSOR_OPT_FAST_PLAN | (yyvsp[(2) - (7)].ival);
;}
break;
case 28:
#line 581 "pl_gram.y"
{
(yyval.ival) = 0;
;}
break;
case 29:
#line 585 "pl_gram.y"
{
(yyval.ival) = CURSOR_OPT_NO_SCROLL;
;}
break;
case 30:
#line 589 "pl_gram.y"
{
(yyval.ival) = CURSOR_OPT_SCROLL;
;}
break;
case 31:
#line 595 "pl_gram.y"
{
(yyval.expr) = read_sql_stmt(&yylval, &yylloc, yyscanner);
;}
break;
case 32:
#line 601 "pl_gram.y"
{
(yyval.datum) = NULL;
;}
break;
case 33:
#line 605 "pl_gram.y"
{
PLpgSQL_row *new;
int i;
ListCell *l;
new = palloc0(sizeof(PLpgSQL_row));
new->dtype = PLPGSQL_DTYPE_ROW;
new->refname = "(unnamed row)";
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (3)]), yyscanner);
new->rowtupdesc = NULL;
new->nfields = list_length((yyvsp[(2) - (3)].list));
new->fieldnames = palloc(new->nfields * sizeof(char *));
new->varnos = palloc(new->nfields * sizeof(int));
i = 0;
foreach (l, (yyvsp[(2) - (3)].list))
{
PLpgSQL_variable *arg = (PLpgSQL_variable *) lfirst(l);
Assert(!arg->isconst);
new->fieldnames[i] = arg->refname;
new->varnos[i] = arg->dno;
i++;
}
list_free((yyvsp[(2) - (3)].list));
plpgsql_adddatum((PLpgSQL_datum *) new);
(yyval.datum) = (PLpgSQL_datum *) new;
;}
break;
case 34:
#line 636 "pl_gram.y"
{
(yyval.list) = list_make1((yyvsp[(1) - (1)].datum));
;}
break;
case 35:
#line 640 "pl_gram.y"
{
(yyval.list) = lappend((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].datum));
;}
break;
case 36:
#line 646 "pl_gram.y"
{
(yyval.datum) = (PLpgSQL_datum *)
plpgsql_build_variable((yyvsp[(1) - (2)].varname).name, (yyvsp[(1) - (2)].varname).lineno,
(yyvsp[(2) - (2)].dtype), true);
;}
break;
case 39:
#line 657 "pl_gram.y"
{
PLpgSQL_nsitem *nsi;
nsi = plpgsql_ns_lookup(plpgsql_ns_top(), false,
(yyvsp[(1) - (1)].word).ident, NULL, NULL,
NULL);
if (nsi == NULL)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("variable \"%s\" does not exist",
(yyvsp[(1) - (1)].word).ident),
parser_errposition((yylsp[(1) - (1)]))));
(yyval.nsitem) = nsi;
;}
break;
case 40:
#line 672 "pl_gram.y"
{
PLpgSQL_nsitem *nsi;
nsi = plpgsql_ns_lookup(plpgsql_ns_top(), false,
(yyvsp[(1) - (1)].keyword), NULL, NULL,
NULL);
if (nsi == NULL)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("variable \"%s\" does not exist",
(yyvsp[(1) - (1)].keyword)),
parser_errposition((yylsp[(1) - (1)]))));
(yyval.nsitem) = nsi;
;}
break;
case 41:
#line 687 "pl_gram.y"
{
PLpgSQL_nsitem *nsi;
if (list_length((yyvsp[(1) - (1)].cword).idents) == 2)
nsi = plpgsql_ns_lookup(plpgsql_ns_top(), false,
strVal(linitial((yyvsp[(1) - (1)].cword).idents)),
strVal(lsecond((yyvsp[(1) - (1)].cword).idents)),
NULL,
NULL);
else if (list_length((yyvsp[(1) - (1)].cword).idents) == 3)
nsi = plpgsql_ns_lookup(plpgsql_ns_top(), false,
strVal(linitial((yyvsp[(1) - (1)].cword).idents)),
strVal(lsecond((yyvsp[(1) - (1)].cword).idents)),
strVal(lthird((yyvsp[(1) - (1)].cword).idents)),
NULL);
else
nsi = NULL;
if (nsi == NULL)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("variable \"%s\" does not exist",
NameListToString((yyvsp[(1) - (1)].cword).idents)),
parser_errposition((yylsp[(1) - (1)]))));
(yyval.nsitem) = nsi;
;}
break;
case 42:
#line 715 "pl_gram.y"
{
(yyval.varname).name = (yyvsp[(1) - (1)].word).ident;
(yyval.varname).lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]), yyscanner);
if (plpgsql_ns_lookup(plpgsql_ns_top(), true,
(yyvsp[(1) - (1)].word).ident, NULL, NULL,
NULL) != NULL)
yyerror(&yylloc, NULL, yyscanner, "duplicate declaration");
if (plpgsql_curr_compile->extra_warnings & PLPGSQL_XCHECK_SHADOWVAR ||
plpgsql_curr_compile->extra_errors & PLPGSQL_XCHECK_SHADOWVAR)
{
PLpgSQL_nsitem *nsi;
nsi = plpgsql_ns_lookup(plpgsql_ns_top(), false,
(yyvsp[(1) - (1)].word).ident, NULL, NULL, NULL);
if (nsi != NULL)
ereport(plpgsql_curr_compile->extra_errors & PLPGSQL_XCHECK_SHADOWVAR ? ERROR : WARNING,
(errcode(ERRCODE_DUPLICATE_ALIAS),
errmsg("variable \"%s\" shadows a previously defined variable",
(yyvsp[(1) - (1)].word).ident),
parser_errposition((yylsp[(1) - (1)]))));
}
;}
break;
case 43:
#line 743 "pl_gram.y"
{
(yyval.varname).name = pstrdup((yyvsp[(1) - (1)].keyword));
(yyval.varname).lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]), yyscanner);
if (plpgsql_ns_lookup(plpgsql_ns_top(), true,
(yyvsp[(1) - (1)].keyword), NULL, NULL,
NULL) != NULL)
yyerror(&yylloc, NULL, yyscanner, "duplicate declaration");
if (plpgsql_curr_compile->extra_warnings & PLPGSQL_XCHECK_SHADOWVAR ||
plpgsql_curr_compile->extra_errors & PLPGSQL_XCHECK_SHADOWVAR)
{
PLpgSQL_nsitem *nsi;
nsi = plpgsql_ns_lookup(plpgsql_ns_top(), false,
(yyvsp[(1) - (1)].keyword), NULL, NULL, NULL);
if (nsi != NULL)
ereport(plpgsql_curr_compile->extra_errors & PLPGSQL_XCHECK_SHADOWVAR ? ERROR : WARNING,
(errcode(ERRCODE_DUPLICATE_ALIAS),
errmsg("variable \"%s\" shadows a previously defined variable",
(yyvsp[(1) - (1)].keyword)),
parser_errposition((yylsp[(1) - (1)]))));
}
;}
break;
case 44:
#line 773 "pl_gram.y"
{ (yyval.boolean) = false; ;}
break;
case 45:
#line 775 "pl_gram.y"
{ (yyval.boolean) = true; ;}
break;
case 46:
#line 779 "pl_gram.y"
{
(yyval.dtype) = read_datatype(yychar, &yylval, &yylloc, yyscanner);
yyclearin;
;}
break;
case 47:
#line 791 "pl_gram.y"
{ (yyval.oid) = InvalidOid; ;}
break;
case 48:
#line 793 "pl_gram.y"
{
(yyval.oid) = get_collation_oid(list_make1(makeString((yyvsp[(2) - (2)].word).ident)),
false);
;}
break;
case 49:
#line 798 "pl_gram.y"
{
(yyval.oid) = get_collation_oid(list_make1(makeString(pstrdup((yyvsp[(2) - (2)].keyword)))),
false);
;}
break;
case 50:
#line 803 "pl_gram.y"
{
(yyval.oid) = get_collation_oid((yyvsp[(2) - (2)].cword).idents, false);
;}
break;
case 51:
#line 809 "pl_gram.y"
{ (yyval.boolean) = false; ;}
break;
case 52:
#line 811 "pl_gram.y"
{ (yyval.boolean) = true; ;}
break;
case 53:
#line 815 "pl_gram.y"
{ (yyval.expr) = NULL; ;}
break;
case 54:
#line 817 "pl_gram.y"
{
(yyval.expr) = read_sql_expression(';', ";", &yylval, &yylloc, yyscanner);
;}
break;
case 59:
#line 836 "pl_gram.y"
{ (yyval.list) = NIL; ;}
break;
case 60:
#line 838 "pl_gram.y"
{
if ((yyvsp[(2) - (2)].stmt) == NULL)
(yyval.list) = (yyvsp[(1) - (2)].list);
else
(yyval.list) = lappend((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].stmt));
;}
break;
case 61:
#line 848 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (2)].stmt); ;}
break;
case 62:
#line 850 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 63:
#line 852 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 64:
#line 854 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 65:
#line 856 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 66:
#line 858 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 67:
#line 860 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 68:
#line 862 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 69:
#line 864 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 70:
#line 866 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 71:
#line 868 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 72:
#line 870 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 73:
#line 872 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 74:
#line 874 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 75:
#line 876 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 76:
#line 878 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 77:
#line 880 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 78:
#line 882 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 79:
#line 884 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 80:
#line 886 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 81:
#line 888 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 82:
#line 890 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 83:
#line 892 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 84:
#line 894 "pl_gram.y"
{ (yyval.stmt) = (yyvsp[(1) - (1)].stmt); ;}
break;
case 85:
#line 898 "pl_gram.y"
{
PLpgSQL_stmt_perform *new;
int startloc;
new = palloc0(sizeof(PLpgSQL_stmt_perform));
new->cmd_type = PLPGSQL_STMT_PERFORM;
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]), yyscanner);
new->stmtid = ++plpgsql_curr_compile->nstatements;
plpgsql_push_back_token(K_PERFORM, &yylval, &yylloc, yyscanner);
new->expr = read_sql_construct(';', 0, 0, ";",
RAW_PARSE_DEFAULT,
false, false,
&startloc, NULL,
&yylval, &yylloc, yyscanner);
memcpy(new->expr->query, " SELECT", 7);
memmove(new->expr->query, new->expr->query + 1,
strlen(new->expr->query));
check_sql_expr(new->expr->query, new->expr->parseMode,
startloc + 1, yyscanner);
(yyval.stmt) = (PLpgSQL_stmt *) new;
;}
break;
case 86:
#line 935 "pl_gram.y"
{
PLpgSQL_stmt_call *new;
new = palloc0(sizeof(PLpgSQL_stmt_call));
new->cmd_type = PLPGSQL_STMT_CALL;
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]), yyscanner);
new->stmtid = ++plpgsql_curr_compile->nstatements;
plpgsql_push_back_token(K_CALL, &yylval, &yylloc, yyscanner);
new->expr = read_sql_stmt(&yylval, &yylloc, yyscanner);
new->is_call = true;
plpgsql_curr_compile->requires_procedure_resowner = true;
(yyval.stmt) = (PLpgSQL_stmt *) new;
;}
break;
case 87:
#line 953 "pl_gram.y"
{
PLpgSQL_stmt_call *new;
new = palloc0(sizeof(PLpgSQL_stmt_call));
new->cmd_type = PLPGSQL_STMT_CALL;
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]), yyscanner);
new->stmtid = ++plpgsql_curr_compile->nstatements;
plpgsql_push_back_token(K_DO, &yylval, &yylloc, yyscanner);
new->expr = read_sql_stmt(&yylval, &yylloc, yyscanner);
new->is_call = false;
plpgsql_curr_compile->requires_procedure_resowner = true;
(yyval.stmt) = (PLpgSQL_stmt *) new;
;}
break;
case 88:
#line 974 "pl_gram.y"
{
PLpgSQL_stmt_assign *new;
RawParseMode pmode;
switch ((yyvsp[(1) - (1)].wdatum).ident ? 1 : list_length((yyvsp[(1) - (1)].wdatum).idents))
{
case 1:
pmode = RAW_PARSE_PLPGSQL_ASSIGN1;
break;
case 2:
pmode = RAW_PARSE_PLPGSQL_ASSIGN2;
break;
case 3:
pmode = RAW_PARSE_PLPGSQL_ASSIGN3;
break;
default:
elog(ERROR, "unexpected number of names");
pmode = 0;
}
check_assignable((yyvsp[(1) - (1)].wdatum).datum, (yylsp[(1) - (1)]), yyscanner);
new = palloc0(sizeof(PLpgSQL_stmt_assign));
new->cmd_type = PLPGSQL_STMT_ASSIGN;
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]), yyscanner);
new->stmtid = ++plpgsql_curr_compile->nstatements;
new->varno = (yyvsp[(1) - (1)].wdatum).datum->dno;
plpgsql_push_back_token(T_DATUM, &yylval, &yylloc, yyscanner);
new->expr = read_sql_construct(';', 0, 0, ";",
pmode,
false, true,
NULL, NULL,
&yylval, &yylloc, yyscanner);
mark_expr_as_assignment_source(new->expr, (yyvsp[(1) - (1)].wdatum).datum);
(yyval.stmt) = (PLpgSQL_stmt *) new;
;}
break;
case 89:
#line 1015 "pl_gram.y"
{
PLpgSQL_stmt_getdiag *new;
ListCell *lc;
new = palloc0(sizeof(PLpgSQL_stmt_getdiag));
new->cmd_type = PLPGSQL_STMT_GETDIAG;
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (5)]), yyscanner);
new->stmtid = ++plpgsql_curr_compile->nstatements;
new->is_stacked = (yyvsp[(2) - (5)].boolean);
new->diag_items = (yyvsp[(4) - (5)].list);
foreach(lc, new->diag_items)
{
PLpgSQL_diag_item *ditem = (PLpgSQL_diag_item *) lfirst(lc);
switch (ditem->kind)
{
case PLPGSQL_GETDIAG_ROW_COUNT:
case PLPGSQL_GETDIAG_ROUTINE_OID:
if (new->is_stacked)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("diagnostics item %s is not allowed in GET STACKED DIAGNOSTICS",
plpgsql_getdiag_kindname(ditem->kind)),
parser_errposition((yylsp[(1) - (5)]))));
break;
case PLPGSQL_GETDIAG_ERROR_CONTEXT:
case PLPGSQL_GETDIAG_ERROR_DETAIL:
case PLPGSQL_GETDIAG_ERROR_HINT:
case PLPGSQL_GETDIAG_RETURNED_SQLSTATE:
case PLPGSQL_GETDIAG_COLUMN_NAME:
case PLPGSQL_GETDIAG_CONSTRAINT_NAME:
case PLPGSQL_GETDIAG_DATATYPE_NAME:
case PLPGSQL_GETDIAG_MESSAGE_TEXT:
case PLPGSQL_GETDIAG_TABLE_NAME:
case PLPGSQL_GETDIAG_SCHEMA_NAME:
if (!new->is_stacked)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("diagnostics item %s is not allowed in GET CURRENT DIAGNOSTICS",
plpgsql_getdiag_kindname(ditem->kind)),
parser_errposition((yylsp[(1) - (5)]))));
break;
case PLPGSQL_GETDIAG_CONTEXT:
break;
default:
elog(ERROR, "unrecognized diagnostic item kind: %d",
ditem->kind);
break;
}
}
(yyval.stmt) = (PLpgSQL_stmt *) new;
;}
break;
case 90:
#line 1078 "pl_gram.y"
{
(yyval.boolean) = false;
;}
break;
case 91:
#line 1082 "pl_gram.y"
{
(yyval.boolean) = false;
;}
break;
case 92:
#line 1086 "pl_gram.y"
{
(yyval.boolean) = true;
;}
break;
case 93:
#line 1092 "pl_gram.y"
{
(yyval.list) = lappend((yyvsp[(1) - (3)].list), (yyvsp[(3) - (3)].diagitem));
;}
break;
case 94:
#line 1096 "pl_gram.y"
{
(yyval.list) = list_make1((yyvsp[(1) - (1)].diagitem));
;}
break;
case 95:
#line 1102 "pl_gram.y"
{
PLpgSQL_diag_item *new;
new = palloc(sizeof(PLpgSQL_diag_item));
new->target = (yyvsp[(1) - (3)].datum)->dno;
new->kind = (yyvsp[(3) - (3)].ival);
(yyval.diagitem) = new;
;}
break;
case 96:
#line 1114 "pl_gram.y"
{
int tok = yylex(&yylval, &yylloc, yyscanner);
if (tok_is_keyword(tok, &yylval,
K_ROW_COUNT, "row_count"))
(yyval.ival) = PLPGSQL_GETDIAG_ROW_COUNT;
else if (tok_is_keyword(tok, &yylval,
K_PG_ROUTINE_OID, "pg_routine_oid"))
(yyval.ival) = PLPGSQL_GETDIAG_ROUTINE_OID;
else if (tok_is_keyword(tok, &yylval,
K_PG_CONTEXT, "pg_context"))
(yyval.ival) = PLPGSQL_GETDIAG_CONTEXT;
else if (tok_is_keyword(tok, &yylval,
K_PG_EXCEPTION_DETAIL, "pg_exception_detail"))
(yyval.ival) = PLPGSQL_GETDIAG_ERROR_DETAIL;
else if (tok_is_keyword(tok, &yylval,
K_PG_EXCEPTION_HINT, "pg_exception_hint"))
(yyval.ival) = PLPGSQL_GETDIAG_ERROR_HINT;
else if (tok_is_keyword(tok, &yylval,
K_PG_EXCEPTION_CONTEXT, "pg_exception_context"))
(yyval.ival) = PLPGSQL_GETDIAG_ERROR_CONTEXT;
else if (tok_is_keyword(tok, &yylval,
K_COLUMN_NAME, "column_name"))
(yyval.ival) = PLPGSQL_GETDIAG_COLUMN_NAME;
else if (tok_is_keyword(tok, &yylval,
K_CONSTRAINT_NAME, "constraint_name"))
(yyval.ival) = PLPGSQL_GETDIAG_CONSTRAINT_NAME;
else if (tok_is_keyword(tok, &yylval,
K_PG_DATATYPE_NAME, "pg_datatype_name"))
(yyval.ival) = PLPGSQL_GETDIAG_DATATYPE_NAME;
else if (tok_is_keyword(tok, &yylval,
K_MESSAGE_TEXT, "message_text"))
(yyval.ival) = PLPGSQL_GETDIAG_MESSAGE_TEXT;
else if (tok_is_keyword(tok, &yylval,
K_TABLE_NAME, "table_name"))
(yyval.ival) = PLPGSQL_GETDIAG_TABLE_NAME;
else if (tok_is_keyword(tok, &yylval,
K_SCHEMA_NAME, "schema_name"))
(yyval.ival) = PLPGSQL_GETDIAG_SCHEMA_NAME;
else if (tok_is_keyword(tok, &yylval,
K_RETURNED_SQLSTATE, "returned_sqlstate"))
(yyval.ival) = PLPGSQL_GETDIAG_RETURNED_SQLSTATE;
else
yyerror(&yylloc, NULL, yyscanner, "unrecognized GET DIAGNOSTICS item");
;}
break;
case 97:
#line 1162 "pl_gram.y"
{
if ((yyvsp[(1) - (1)].wdatum).datum->dtype == PLPGSQL_DTYPE_ROW ||
(yyvsp[(1) - (1)].wdatum).datum->dtype == PLPGSQL_DTYPE_REC ||
plpgsql_peek(yyscanner) == '[')
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("\"%s\" is not a scalar variable",
NameOfDatum(&((yyvsp[(1) - (1)].wdatum)))),
parser_errposition((yylsp[(1) - (1)]))));
check_assignable((yyvsp[(1) - (1)].wdatum).datum, (yylsp[(1) - (1)]), yyscanner);
(yyval.datum) = (yyvsp[(1) - (1)].wdatum).datum;
;}
break;
case 98:
#line 1180 "pl_gram.y"
{
word_is_not_variable(&((yyvsp[(1) - (1)].word)), (yylsp[(1) - (1)]), yyscanner);
;}
break;
case 99:
#line 1185 "pl_gram.y"
{
cword_is_not_variable(&((yyvsp[(1) - (1)].cword)), (yylsp[(1) - (1)]), yyscanner);
;}
break;
case 100:
#line 1192 "pl_gram.y"
{
PLpgSQL_stmt_if *new;
new = palloc0(sizeof(PLpgSQL_stmt_if));
new->cmd_type = PLPGSQL_STMT_IF;
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (8)]), yyscanner);
new->stmtid = ++plpgsql_curr_compile->nstatements;
new->cond = (yyvsp[(2) - (8)].expr);
new->then_body = (yyvsp[(3) - (8)].list);
new->elsif_list = (yyvsp[(4) - (8)].list);
new->else_body = (yyvsp[(5) - (8)].list);
(yyval.stmt) = (PLpgSQL_stmt *) new;
;}
break;
case 101:
#line 1209 "pl_gram.y"
{
(yyval.list) = NIL;
;}
break;
case 102:
#line 1213 "pl_gram.y"
{
PLpgSQL_if_elsif *new;
new = palloc0(sizeof(PLpgSQL_if_elsif));
new->lineno = plpgsql_location_to_lineno((yylsp[(2) - (4)]), yyscanner);
new->cond = (yyvsp[(3) - (4)].expr);
new->stmts = (yyvsp[(4) - (4)].list);
(yyval.list) = lappend((yyvsp[(1) - (4)].list), new);
;}
break;
case 103:
#line 1226 "pl_gram.y"
{
(yyval.list) = NIL;
;}
break;
case 104:
#line 1230 "pl_gram.y"
{
(yyval.list) = (yyvsp[(2) - (2)].list);
;}
break;
case 105:
#line 1236 "pl_gram.y"
{
(yyval.stmt) = make_case((yylsp[(1) - (7)]), (yyvsp[(2) - (7)].expr), (yyvsp[(3) - (7)].list), (yyvsp[(4) - (7)].list), yyscanner);
;}
break;
case 106:
#line 1242 "pl_gram.y"
{
PLpgSQL_expr *expr = NULL;
int tok = yylex(&yylval, &yylloc, yyscanner);
if (tok != K_WHEN)
{
plpgsql_push_back_token(tok, &yylval, &yylloc, yyscanner);
expr = read_sql_expression(K_WHEN, "WHEN", &yylval, &yylloc, yyscanner);
}
plpgsql_push_back_token(K_WHEN, &yylval, &yylloc, yyscanner);
(yyval.expr) = expr;
;}
break;
case 107:
#line 1257 "pl_gram.y"
{
(yyval.list) = lappend((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].casewhen));
;}
break;
case 108:
#line 1261 "pl_gram.y"
{
(yyval.list) = list_make1((yyvsp[(1) - (1)].casewhen));
;}
break;
case 109:
#line 1267 "pl_gram.y"
{
PLpgSQL_case_when *new = palloc(sizeof(PLpgSQL_case_when));
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (3)]), yyscanner);
new->expr = (yyvsp[(2) - (3)].expr);
new->stmts = (yyvsp[(3) - (3)].list);
(yyval.casewhen) = new;
;}
break;
case 110:
#line 1278 "pl_gram.y"
{
(yyval.list) = NIL;
;}
break;
case 111:
#line 1282 "pl_gram.y"
{
if ((yyvsp[(2) - (2)].list) != NIL)
(yyval.list) = (yyvsp[(2) - (2)].list);
else
(yyval.list) = list_make1(NULL);
;}
break;
case 112:
#line 1297 "pl_gram.y"
{
PLpgSQL_stmt_loop *new;
new = palloc0(sizeof(PLpgSQL_stmt_loop));
new->cmd_type = PLPGSQL_STMT_LOOP;
new->lineno = plpgsql_location_to_lineno((yylsp[(2) - (3)]), yyscanner);
new->stmtid = ++plpgsql_curr_compile->nstatements;
new->label = (yyvsp[(1) - (3)].str);
new->body = (yyvsp[(3) - (3)].loop_body).stmts;
check_labels((yyvsp[(1) - (3)].str), (yyvsp[(3) - (3)].loop_body).end_label, (yyvsp[(3) - (3)].loop_body).end_label_location, yyscanner);
plpgsql_ns_pop();
(yyval.stmt) = (PLpgSQL_stmt *) new;
;}
break;
case 113:
#line 1315 "pl_gram.y"
{
PLpgSQL_stmt_while *new;
new = palloc0(sizeof(PLpgSQL_stmt_while));
new->cmd_type = PLPGSQL_STMT_WHILE;
new->lineno = plpgsql_location_to_lineno((yylsp[(2) - (4)]), yyscanner);
new->stmtid = ++plpgsql_curr_compile->nstatements;
new->label = (yyvsp[(1) - (4)].str);
new->cond = (yyvsp[(3) - (4)].expr);
new->body = (yyvsp[(4) - (4)].loop_body).stmts;
check_labels((yyvsp[(1) - (4)].str), (yyvsp[(4) - (4)].loop_body).end_label, (yyvsp[(4) - (4)].loop_body).end_label_location, yyscanner);
plpgsql_ns_pop();
(yyval.stmt) = (PLpgSQL_stmt *) new;
;}
break;
case 114:
#line 1334 "pl_gram.y"
{
if ((yyvsp[(3) - (4)].stmt)->cmd_type == PLPGSQL_STMT_FORI)
{
PLpgSQL_stmt_fori *new;
new = (PLpgSQL_stmt_fori *) (yyvsp[(3) - (4)].stmt);
new->lineno = plpgsql_location_to_lineno((yylsp[(2) - (4)]), yyscanner);
new->label = (yyvsp[(1) - (4)].str);
new->body = (yyvsp[(4) - (4)].loop_body).stmts;
(yyval.stmt) = (PLpgSQL_stmt *) new;
}
else
{
PLpgSQL_stmt_forq *new;
Assert((yyvsp[(3) - (4)].stmt)->cmd_type == PLPGSQL_STMT_FORS ||
(yyvsp[(3) - (4)].stmt)->cmd_type == PLPGSQL_STMT_FORC ||
(yyvsp[(3) - (4)].stmt)->cmd_type == PLPGSQL_STMT_DYNFORS);
new = (PLpgSQL_stmt_forq *) (yyvsp[(3) - (4)].stmt);
new->lineno = plpgsql_location_to_lineno((yylsp[(2) - (4)]), yyscanner);
new->label = (yyvsp[(1) - (4)].str);
new->body = (yyvsp[(4) - (4)].loop_body).stmts;
(yyval.stmt) = (PLpgSQL_stmt *) new;
}
check_labels((yyvsp[(1) - (4)].str), (yyvsp[(4) - (4)].loop_body).end_label, (yyvsp[(4) - (4)].loop_body).end_label_location, yyscanner);
plpgsql_ns_pop();
;}
break;
case 115:
#line 1368 "pl_gram.y"
{
int tok = yylex(&yylval, &yylloc, yyscanner);
int tokloc = yylloc;
if (tok == K_EXECUTE)
{
PLpgSQL_stmt_dynfors *new;
PLpgSQL_expr *expr;
int term;
expr = read_sql_expression2(K_LOOP, K_USING,
"LOOP or USING",
&term, &yylval, &yylloc, yyscanner);
new = palloc0(sizeof(PLpgSQL_stmt_dynfors));
new->cmd_type = PLPGSQL_STMT_DYNFORS;
new->stmtid = ++plpgsql_curr_compile->nstatements;
if ((yyvsp[(1) - (2)].forvariable).row)
{
new->var = (PLpgSQL_variable *) (yyvsp[(1) - (2)].forvariable).row;
check_assignable((yyvsp[(1) - (2)].forvariable).row, (yylsp[(1) - (2)]), yyscanner);
}
else if ((yyvsp[(1) - (2)].forvariable).scalar)
{
new->var = (PLpgSQL_variable *)
make_scalar_list1((yyvsp[(1) - (2)].forvariable).name, (yyvsp[(1) - (2)].forvariable).scalar,
(yyvsp[(1) - (2)].forvariable).lineno, (yylsp[(1) - (2)]), yyscanner);
}
else
{
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("loop variable of loop over rows must be a record variable or list of scalar variables"),
parser_errposition((yylsp[(1) - (2)]))));
}
new->query = expr;
if (term == K_USING)
{
do
{
expr = read_sql_expression2(',', K_LOOP,
", or LOOP",
&term, &yylval, &yylloc, yyscanner);
new->params = lappend(new->params, expr);
} while (term == ',');
}
(yyval.stmt) = (PLpgSQL_stmt *) new;
}
else if (tok == T_DATUM &&
yylval.wdatum.datum->dtype == PLPGSQL_DTYPE_VAR &&
((PLpgSQL_var *) yylval.wdatum.datum)->datatype->typoid == REFCURSOROID)
{
PLpgSQL_stmt_forc *new;
PLpgSQL_var *cursor = (PLpgSQL_var *) yylval.wdatum.datum;
new = (PLpgSQL_stmt_forc *) palloc0(sizeof(PLpgSQL_stmt_forc));
new->cmd_type = PLPGSQL_STMT_FORC;
new->stmtid = ++plpgsql_curr_compile->nstatements;
new->curvar = cursor->dno;
if ((yyvsp[(1) - (2)].forvariable).scalar && (yyvsp[(1) - (2)].forvariable).row)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("cursor FOR loop must have only one target variable"),
parser_errposition((yylsp[(1) - (2)]))));
if (cursor->cursor_explicit_expr == NULL)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("cursor FOR loop must use a bound cursor variable"),
parser_errposition(tokloc)));
new->argquery = read_cursor_args(cursor, K_LOOP, &yylval, &yylloc, yyscanner);
new->var = (PLpgSQL_variable *)
plpgsql_build_record((yyvsp[(1) - (2)].forvariable).name,
(yyvsp[(1) - (2)].forvariable).lineno,
NULL,
RECORDOID,
true);
(yyval.stmt) = (PLpgSQL_stmt *) new;
}
else
{
PLpgSQL_expr *expr1;
int expr1loc;
bool reverse = false;
if (tok_is_keyword(tok, &yylval,
K_REVERSE, "reverse"))
reverse = true;
else
plpgsql_push_back_token(tok, &yylval, &yylloc, yyscanner);
expr1 = read_sql_construct(DOT_DOT,
K_LOOP,
0,
"LOOP",
RAW_PARSE_DEFAULT,
true,
false,
&expr1loc,
&tok,
&yylval, &yylloc, yyscanner);
if (tok == DOT_DOT)
{
PLpgSQL_expr *expr2;
PLpgSQL_expr *expr_by;
PLpgSQL_var *fvar;
PLpgSQL_stmt_fori *new;
expr1->parseMode = RAW_PARSE_PLPGSQL_EXPR;
check_sql_expr(expr1->query, expr1->parseMode,
expr1loc, yyscanner);
expr2 = read_sql_expression2(K_LOOP, K_BY,
"LOOP",
&tok, &yylval, &yylloc, yyscanner);
if (tok == K_BY)
expr_by = read_sql_expression(K_LOOP,
"LOOP", &yylval, &yylloc, yyscanner);
else
expr_by = NULL;
if ((yyvsp[(1) - (2)].forvariable).scalar && (yyvsp[(1) - (2)].forvariable).row)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("integer FOR loop must have only one target variable"),
parser_errposition((yylsp[(1) - (2)]))));
fvar = (PLpgSQL_var *)
plpgsql_build_variable((yyvsp[(1) - (2)].forvariable).name,
(yyvsp[(1) - (2)].forvariable).lineno,
plpgsql_build_datatype(INT4OID,
-1,
InvalidOid,
NULL),
true);
new = palloc0(sizeof(PLpgSQL_stmt_fori));
new->cmd_type = PLPGSQL_STMT_FORI;
new->stmtid = ++plpgsql_curr_compile->nstatements;
new->var = fvar;
new->reverse = reverse;
new->lower = expr1;
new->upper = expr2;
new->step = expr_by;
(yyval.stmt) = (PLpgSQL_stmt *) new;
}
else
{
PLpgSQL_stmt_fors *new;
if (reverse)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("cannot specify REVERSE in query FOR loop"),
parser_errposition(tokloc)));
check_sql_expr(expr1->query, expr1->parseMode,
expr1loc, yyscanner);
new = palloc0(sizeof(PLpgSQL_stmt_fors));
new->cmd_type = PLPGSQL_STMT_FORS;
new->stmtid = ++plpgsql_curr_compile->nstatements;
if ((yyvsp[(1) - (2)].forvariable).row)
{
new->var = (PLpgSQL_variable *) (yyvsp[(1) - (2)].forvariable).row;
check_assignable((yyvsp[(1) - (2)].forvariable).row, (yylsp[(1) - (2)]), yyscanner);
}
else if ((yyvsp[(1) - (2)].forvariable).scalar)
{
new->var = (PLpgSQL_variable *)
make_scalar_list1((yyvsp[(1) - (2)].forvariable).name, (yyvsp[(1) - (2)].forvariable).scalar,
(yyvsp[(1) - (2)].forvariable).lineno, (yylsp[(1) - (2)]), yyscanner);
}
else
{
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("loop variable of loop over rows must be a record variable or list of scalar variables"),
parser_errposition((yylsp[(1) - (2)]))));
}
new->query = expr1;
(yyval.stmt) = (PLpgSQL_stmt *) new;
}
}
;}
break;
case 116:
#line 1626 "pl_gram.y"
{
(yyval.forvariable).name = NameOfDatum(&((yyvsp[(1) - (1)].wdatum)));
(yyval.forvariable).lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]), yyscanner);
if ((yyvsp[(1) - (1)].wdatum).datum->dtype == PLPGSQL_DTYPE_ROW ||
(yyvsp[(1) - (1)].wdatum).datum->dtype == PLPGSQL_DTYPE_REC)
{
(yyval.forvariable).scalar = NULL;
(yyval.forvariable).row = (yyvsp[(1) - (1)].wdatum).datum;
}
else
{
int tok;
(yyval.forvariable).scalar = (yyvsp[(1) - (1)].wdatum).datum;
(yyval.forvariable).row = NULL;
tok = yylex(&yylval, &yylloc, yyscanner);
plpgsql_push_back_token(tok, &yylval, &yylloc, yyscanner);
if (tok == ',')
(yyval.forvariable).row = (PLpgSQL_datum *)
read_into_scalar_list((yyval.forvariable).name,
(yyval.forvariable).scalar,
(yylsp[(1) - (1)]),
&yylval, &yylloc,
yyscanner);
}
;}
break;
case 117:
#line 1654 "pl_gram.y"
{
int tok;
(yyval.forvariable).name = (yyvsp[(1) - (1)].word).ident;
(yyval.forvariable).lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]), yyscanner);
(yyval.forvariable).scalar = NULL;
(yyval.forvariable).row = NULL;
tok = yylex(&yylval, &yylloc, yyscanner);
plpgsql_push_back_token(tok, &yylval, &yylloc, yyscanner);
if (tok == ',')
word_is_not_variable(&((yyvsp[(1) - (1)].word)), (yylsp[(1) - (1)]), yyscanner);
;}
break;
case 118:
#line 1668 "pl_gram.y"
{
cword_is_not_variable(&((yyvsp[(1) - (1)].cword)), (yylsp[(1) - (1)]), yyscanner);
;}
break;
case 119:
#line 1675 "pl_gram.y"
{
PLpgSQL_stmt_foreach_a *new;
new = palloc0(sizeof(PLpgSQL_stmt_foreach_a));
new->cmd_type = PLPGSQL_STMT_FOREACH_A;
new->lineno = plpgsql_location_to_lineno((yylsp[(2) - (8)]), yyscanner);
new->stmtid = ++plpgsql_curr_compile->nstatements;
new->label = (yyvsp[(1) - (8)].str);
new->slice = (yyvsp[(4) - (8)].ival);
new->expr = (yyvsp[(7) - (8)].expr);
new->body = (yyvsp[(8) - (8)].loop_body).stmts;
if ((yyvsp[(3) - (8)].forvariable).row)
{
new->varno = (yyvsp[(3) - (8)].forvariable).row->dno;
check_assignable((yyvsp[(3) - (8)].forvariable).row, (yylsp[(3) - (8)]), yyscanner);
}
else if ((yyvsp[(3) - (8)].forvariable).scalar)
{
new->varno = (yyvsp[(3) - (8)].forvariable).scalar->dno;
check_assignable((yyvsp[(3) - (8)].forvariable).scalar, (yylsp[(3) - (8)]), yyscanner);
}
else
{
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("loop variable of FOREACH must be a known variable or list of variables"),
parser_errposition((yylsp[(3) - (8)]))));
}
check_labels((yyvsp[(1) - (8)].str), (yyvsp[(8) - (8)].loop_body).end_label, (yyvsp[(8) - (8)].loop_body).end_label_location, yyscanner);
plpgsql_ns_pop();
(yyval.stmt) = (PLpgSQL_stmt *) new;
;}
break;
case 120:
#line 1713 "pl_gram.y"
{
(yyval.ival) = 0;
;}
break;
case 121:
#line 1717 "pl_gram.y"
{
(yyval.ival) = (yyvsp[(2) - (2)].ival);
;}
break;
case 122:
#line 1723 "pl_gram.y"
{
PLpgSQL_stmt_exit *new;
new = palloc0(sizeof(PLpgSQL_stmt_exit));
new->cmd_type = PLPGSQL_STMT_EXIT;
new->stmtid = ++plpgsql_curr_compile->nstatements;
new->is_exit = (yyvsp[(1) - (3)].boolean);
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (3)]), yyscanner);
new->label = (yyvsp[(2) - (3)].str);
new->cond = (yyvsp[(3) - (3)].expr);
if ((yyvsp[(2) - (3)].str))
{
PLpgSQL_nsitem *label;
label = plpgsql_ns_lookup_label(plpgsql_ns_top(), (yyvsp[(2) - (3)].str));
if (label == NULL)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("there is no label \"%s\" "
"attached to any block or loop enclosing this statement",
(yyvsp[(2) - (3)].str)),
parser_errposition((yylsp[(2) - (3)]))));
if (label->itemno != PLPGSQL_LABEL_LOOP && !new->is_exit)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("block label \"%s\" cannot be used in CONTINUE",
(yyvsp[(2) - (3)].str)),
parser_errposition((yylsp[(2) - (3)]))));
}
else
{
if (plpgsql_ns_find_nearest_loop(plpgsql_ns_top()) == NULL)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
new->is_exit ?
errmsg("EXIT cannot be used outside a loop, unless it has a label") :
errmsg("CONTINUE cannot be used outside a loop"),
parser_errposition((yylsp[(1) - (3)]))));
}
(yyval.stmt) = (PLpgSQL_stmt *) new;
;}
break;
case 123:
#line 1776 "pl_gram.y"
{
(yyval.boolean) = true;
;}
break;
case 124:
#line 1780 "pl_gram.y"
{
(yyval.boolean) = false;
;}
break;
case 125:
#line 1786 "pl_gram.y"
{
int tok;
tok = yylex(&yylval, &yylloc, yyscanner);
if (tok == 0)
yyerror(&yylloc, NULL, yyscanner, "unexpected end of function definition");
if (tok_is_keyword(tok, &yylval,
K_NEXT, "next"))
{
(yyval.stmt) = make_return_next_stmt((yylsp[(1) - (1)]), &yylval, &yylloc, yyscanner);
}
else if (tok_is_keyword(tok, &yylval,
K_QUERY, "query"))
{
(yyval.stmt) = make_return_query_stmt((yylsp[(1) - (1)]), &yylval, &yylloc, yyscanner);
}
else
{
plpgsql_push_back_token(tok, &yylval, &yylloc, yyscanner);
(yyval.stmt) = make_return_stmt((yylsp[(1) - (1)]), &yylval, &yylloc, yyscanner);
}
;}
break;
case 126:
#line 1812 "pl_gram.y"
{
PLpgSQL_stmt_raise *new;
int tok;
new = palloc(sizeof(PLpgSQL_stmt_raise));
new->cmd_type = PLPGSQL_STMT_RAISE;
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]), yyscanner);
new->stmtid = ++plpgsql_curr_compile->nstatements;
new->elog_level = ERROR;
new->condname = NULL;
new->message = NULL;
new->params = NIL;
new->options = NIL;
tok = yylex(&yylval, &yylloc, yyscanner);
if (tok == 0)
yyerror(&yylloc, NULL, yyscanner, "unexpected end of function definition");
if (tok != ';')
{
if (tok_is_keyword(tok, &yylval,
K_EXCEPTION, "exception"))
{
new->elog_level = ERROR;
tok = yylex(&yylval, &yylloc, yyscanner);
}
else if (tok_is_keyword(tok, &yylval,
K_WARNING, "warning"))
{
new->elog_level = WARNING;
tok = yylex(&yylval, &yylloc, yyscanner);
}
else if (tok_is_keyword(tok, &yylval,
K_NOTICE, "notice"))
{
new->elog_level = NOTICE;
tok = yylex(&yylval, &yylloc, yyscanner);
}
else if (tok_is_keyword(tok, &yylval,
K_INFO, "info"))
{
new->elog_level = INFO;
tok = yylex(&yylval, &yylloc, yyscanner);
}
else if (tok_is_keyword(tok, &yylval,
K_LOG, "log"))
{
new->elog_level = LOG;
tok = yylex(&yylval, &yylloc, yyscanner);
}
else if (tok_is_keyword(tok, &yylval,
K_DEBUG, "debug"))
{
new->elog_level = DEBUG1;
tok = yylex(&yylval, &yylloc, yyscanner);
}
if (tok == 0)
yyerror(&yylloc, NULL, yyscanner, "unexpected end of function definition");
if (tok == SCONST)
{
new->message = yylval.str;
tok = yylex(&yylval, &yylloc, yyscanner);
if (tok != ',' && tok != ';' && tok != K_USING)
yyerror(&yylloc, NULL, yyscanner, "syntax error");
while (tok == ',')
{
PLpgSQL_expr *expr;
expr = read_sql_construct(',', ';', K_USING,
", or ; or USING",
RAW_PARSE_PLPGSQL_EXPR,
true, true,
NULL, &tok,
&yylval, &yylloc, yyscanner);
new->params = lappend(new->params, expr);
}
}
else if (tok != K_USING)
{
if (tok_is_keyword(tok, &yylval,
K_SQLSTATE, "sqlstate"))
{
char *sqlstatestr;
if (yylex(&yylval, &yylloc, yyscanner) != SCONST)
yyerror(&yylloc, NULL, yyscanner, "syntax error");
sqlstatestr = yylval.str;
if (strlen(sqlstatestr) != 5)
yyerror(&yylloc, NULL, yyscanner, "invalid SQLSTATE code");
if (strspn(sqlstatestr, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ") != 5)
yyerror(&yylloc, NULL, yyscanner, "invalid SQLSTATE code");
new->condname = sqlstatestr;
}
else
{
if (tok == T_WORD)
new->condname = yylval.word.ident;
else if (plpgsql_token_is_unreserved_keyword(tok))
new->condname = pstrdup(yylval.keyword);
else
yyerror(&yylloc, NULL, yyscanner, "syntax error");
plpgsql_recognize_err_condition(new->condname,
false);
}
tok = yylex(&yylval, &yylloc, yyscanner);
if (tok != ';' && tok != K_USING)
yyerror(&yylloc, NULL, yyscanner, "syntax error");
}
if (tok == K_USING)
new->options = read_raise_options(&yylval, &yylloc, yyscanner);
}
check_raise_parameters(new);
(yyval.stmt) = (PLpgSQL_stmt *) new;
;}
break;
case 127:
#line 1958 "pl_gram.y"
{
PLpgSQL_stmt_assert *new;
int tok;
new = palloc(sizeof(PLpgSQL_stmt_assert));
new->cmd_type = PLPGSQL_STMT_ASSERT;
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]), yyscanner);
new->stmtid = ++plpgsql_curr_compile->nstatements;
new->cond = read_sql_expression2(',', ';',
", or ;",
&tok, &yylval, &yylloc, yyscanner);
if (tok == ',')
new->message = read_sql_expression(';', ";", &yylval, &yylloc, yyscanner);
else
new->message = NULL;
(yyval.stmt) = (PLpgSQL_stmt *) new;
;}
break;
case 128:
#line 1982 "pl_gram.y"
{
(yyval.loop_body).stmts = (yyvsp[(1) - (5)].list);
(yyval.loop_body).end_label = (yyvsp[(4) - (5)].str);
(yyval.loop_body).end_label_location = (yylsp[(4) - (5)]);
;}
break;
case 129:
#line 2000 "pl_gram.y"
{
(yyval.stmt) = make_execsql_stmt(K_IMPORT, (yylsp[(1) - (1)]), NULL, &yylval, &yylloc, yyscanner);
;}
break;
case 130:
#line 2004 "pl_gram.y"
{
(yyval.stmt) = make_execsql_stmt(K_INSERT, (yylsp[(1) - (1)]), NULL, &yylval, &yylloc, yyscanner);
;}
break;
case 131:
#line 2008 "pl_gram.y"
{
(yyval.stmt) = make_execsql_stmt(K_MERGE, (yylsp[(1) - (1)]), NULL, &yylval, &yylloc, yyscanner);
;}
break;
case 132:
#line 2012 "pl_gram.y"
{
int tok;
tok = yylex(&yylval, &yylloc, yyscanner);
plpgsql_push_back_token(tok, &yylval, &yylloc, yyscanner);
if (tok == '=' || tok == COLON_EQUALS ||
tok == '[' || tok == '.')
word_is_not_variable(&((yyvsp[(1) - (1)].word)), (yylsp[(1) - (1)]), yyscanner);
(yyval.stmt) = make_execsql_stmt(T_WORD, (yylsp[(1) - (1)]), &((yyvsp[(1) - (1)].word)), &yylval, &yylloc, yyscanner);
;}
break;
case 133:
#line 2023 "pl_gram.y"
{
int tok;
tok = yylex(&yylval, &yylloc, yyscanner);
plpgsql_push_back_token(tok, &yylval, &yylloc, yyscanner);
if (tok == '=' || tok == COLON_EQUALS ||
tok == '[' || tok == '.')
cword_is_not_variable(&((yyvsp[(1) - (1)].cword)), (yylsp[(1) - (1)]), yyscanner);
(yyval.stmt) = make_execsql_stmt(T_CWORD, (yylsp[(1) - (1)]), NULL, &yylval, &yylloc, yyscanner);
;}
break;
case 134:
#line 2036 "pl_gram.y"
{
PLpgSQL_stmt_dynexecute *new;
PLpgSQL_expr *expr;
int endtoken;
expr = read_sql_construct(K_INTO, K_USING, ';',
"INTO or USING or ;",
RAW_PARSE_PLPGSQL_EXPR,
true, true,
NULL, &endtoken,
&yylval, &yylloc, yyscanner);
new = palloc(sizeof(PLpgSQL_stmt_dynexecute));
new->cmd_type = PLPGSQL_STMT_DYNEXECUTE;
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]), yyscanner);
new->stmtid = ++plpgsql_curr_compile->nstatements;
new->query = expr;
new->into = false;
new->strict = false;
new->target = NULL;
new->params = NIL;
for (;;)
{
if (endtoken == K_INTO)
{
if (new->into)
yyerror(&yylloc, NULL, yyscanner, "syntax error");
new->into = true;
read_into_target(&new->target, &new->strict, &yylval, &yylloc, yyscanner);
endtoken = yylex(&yylval, &yylloc, yyscanner);
}
else if (endtoken == K_USING)
{
if (new->params)
yyerror(&yylloc, NULL, yyscanner, "syntax error");
do
{
expr = read_sql_construct(',', ';', K_INTO,
", or ; or INTO",
RAW_PARSE_PLPGSQL_EXPR,
true, true,
NULL, &endtoken,
&yylval, &yylloc, yyscanner);
new->params = lappend(new->params, expr);
} while (endtoken == ',');
}
else if (endtoken == ';')
break;
else
yyerror(&yylloc, NULL, yyscanner, "syntax error");
}
(yyval.stmt) = (PLpgSQL_stmt *) new;
;}
break;
case 135:
#line 2102 "pl_gram.y"
{
PLpgSQL_stmt_open *new;
int tok;
new = palloc0(sizeof(PLpgSQL_stmt_open));
new->cmd_type = PLPGSQL_STMT_OPEN;
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (2)]), yyscanner);
new->stmtid = ++plpgsql_curr_compile->nstatements;
new->curvar = (yyvsp[(2) - (2)].var)->dno;
new->cursor_options = CURSOR_OPT_FAST_PLAN;
if ((yyvsp[(2) - (2)].var)->cursor_explicit_expr == NULL)
{
tok = yylex(&yylval, &yylloc, yyscanner);
if (tok_is_keyword(tok, &yylval,
K_NO, "no"))
{
tok = yylex(&yylval, &yylloc, yyscanner);
if (tok_is_keyword(tok, &yylval,
K_SCROLL, "scroll"))
{
new->cursor_options |= CURSOR_OPT_NO_SCROLL;
tok = yylex(&yylval, &yylloc, yyscanner);
}
}
else if (tok_is_keyword(tok, &yylval,
K_SCROLL, "scroll"))
{
new->cursor_options |= CURSOR_OPT_SCROLL;
tok = yylex(&yylval, &yylloc, yyscanner);
}
if (tok != K_FOR)
yyerror(&yylloc, NULL, yyscanner, "syntax error, expected \"FOR\"");
tok = yylex(&yylval, &yylloc, yyscanner);
if (tok == K_EXECUTE)
{
int endtoken;
new->dynquery =
read_sql_expression2(K_USING, ';',
"USING or ;",
&endtoken, &yylval, &yylloc, yyscanner);
if (endtoken == K_USING)
{
PLpgSQL_expr *expr;
do
{
expr = read_sql_expression2(',', ';',
", or ;",
&endtoken, &yylval, &yylloc, yyscanner);
new->params = lappend(new->params,
expr);
} while (endtoken == ',');
}
}
else
{
plpgsql_push_back_token(tok, &yylval, &yylloc, yyscanner);
new->query = read_sql_stmt(&yylval, &yylloc, yyscanner);
}
}
else
{
new->argquery = read_cursor_args((yyvsp[(2) - (2)].var), ';', &yylval, &yylloc, yyscanner);
}
(yyval.stmt) = (PLpgSQL_stmt *) new;
;}
break;
case 136:
#line 2180 "pl_gram.y"
{
PLpgSQL_stmt_fetch *fetch = (yyvsp[(2) - (4)].fetch);
PLpgSQL_variable *target;
read_into_target(&target, NULL, &yylval, &yylloc, yyscanner);
if (yylex(&yylval, &yylloc, yyscanner) != ';')
yyerror(&yylloc, NULL, yyscanner, "syntax error");
if (fetch->returns_multiple_rows)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("FETCH statement cannot return multiple rows"),
parser_errposition((yylsp[(1) - (4)]))));
fetch->lineno = plpgsql_location_to_lineno((yylsp[(1) - (4)]), yyscanner);
fetch->target = target;
fetch->curvar = (yyvsp[(3) - (4)].var)->dno;
fetch->is_move = false;
(yyval.stmt) = (PLpgSQL_stmt *) fetch;
;}
break;
case 137:
#line 2210 "pl_gram.y"
{
PLpgSQL_stmt_fetch *fetch = (yyvsp[(2) - (4)].fetch);
fetch->lineno = plpgsql_location_to_lineno((yylsp[(1) - (4)]), yyscanner);
fetch->curvar = (yyvsp[(3) - (4)].var)->dno;
fetch->is_move = true;
(yyval.stmt) = (PLpgSQL_stmt *) fetch;
;}
break;
case 138:
#line 2222 "pl_gram.y"
{
(yyval.fetch) = read_fetch_direction(&yylval, &yylloc, yyscanner);
;}
break;
case 139:
#line 2228 "pl_gram.y"
{
PLpgSQL_stmt_close *new;
new = palloc(sizeof(PLpgSQL_stmt_close));
new->cmd_type = PLPGSQL_STMT_CLOSE;
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (3)]), yyscanner);
new->stmtid = ++plpgsql_curr_compile->nstatements;
new->curvar = (yyvsp[(2) - (3)].var)->dno;
(yyval.stmt) = (PLpgSQL_stmt *) new;
;}
break;
case 140:
#line 2242 "pl_gram.y"
{
(yyval.stmt) = NULL;
;}
break;
case 141:
#line 2249 "pl_gram.y"
{
PLpgSQL_stmt_commit *new;
new = palloc(sizeof(PLpgSQL_stmt_commit));
new->cmd_type = PLPGSQL_STMT_COMMIT;
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (3)]), yyscanner);
new->stmtid = ++plpgsql_curr_compile->nstatements;
new->chain = (yyvsp[(2) - (3)].ival);
(yyval.stmt) = (PLpgSQL_stmt *) new;
;}
break;
case 142:
#line 2263 "pl_gram.y"
{
PLpgSQL_stmt_rollback *new;
new = palloc(sizeof(PLpgSQL_stmt_rollback));
new->cmd_type = PLPGSQL_STMT_ROLLBACK;
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (3)]), yyscanner);
new->stmtid = ++plpgsql_curr_compile->nstatements;
new->chain = (yyvsp[(2) - (3)].ival);
(yyval.stmt) = (PLpgSQL_stmt *) new;
;}
break;
case 143:
#line 2277 "pl_gram.y"
{ (yyval.ival) = true; ;}
break;
case 144:
#line 2278 "pl_gram.y"
{ (yyval.ival) = false; ;}
break;
case 145:
#line 2279 "pl_gram.y"
{ (yyval.ival) = false; ;}
break;
case 146:
#line 2284 "pl_gram.y"
{
if ((yyvsp[(1) - (1)].wdatum).datum->dtype != PLPGSQL_DTYPE_VAR ||
plpgsql_peek(yyscanner) == '[')
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("cursor variable must be a simple variable"),
parser_errposition((yylsp[(1) - (1)]))));
if (((PLpgSQL_var *) (yyvsp[(1) - (1)].wdatum).datum)->datatype->typoid != REFCURSOROID)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("variable \"%s\" must be of type cursor or refcursor",
((PLpgSQL_var *) (yyvsp[(1) - (1)].wdatum).datum)->refname),
parser_errposition((yylsp[(1) - (1)]))));
(yyval.var) = (PLpgSQL_var *) (yyvsp[(1) - (1)].wdatum).datum;
;}
break;
case 147:
#line 2306 "pl_gram.y"
{
word_is_not_variable(&((yyvsp[(1) - (1)].word)), (yylsp[(1) - (1)]), yyscanner);
;}
break;
case 148:
#line 2311 "pl_gram.y"
{
cword_is_not_variable(&((yyvsp[(1) - (1)].cword)), (yylsp[(1) - (1)]), yyscanner);
;}
break;
case 149:
#line 2318 "pl_gram.y"
{ (yyval.exception_block) = NULL; ;}
break;
case 150:
#line 2320 "pl_gram.y"
{
int lineno = plpgsql_location_to_lineno((yylsp[(1) - (1)]), yyscanner);
PLpgSQL_exception_block *new = palloc(sizeof(PLpgSQL_exception_block));
PLpgSQL_variable *var;
plpgsql_curr_compile->has_exception_block = true;
var = plpgsql_build_variable("sqlstate", lineno,
plpgsql_build_datatype(TEXTOID,
-1,
plpgsql_curr_compile->fn_input_collation,
NULL),
true);
var->isconst = true;
new->sqlstate_varno = var->dno;
var = plpgsql_build_variable("sqlerrm", lineno,
plpgsql_build_datatype(TEXTOID,
-1,
plpgsql_curr_compile->fn_input_collation,
NULL),
true);
var->isconst = true;
new->sqlerrm_varno = var->dno;
(yyval.exception_block) = new;
;}
break;
case 151:
#line 2355 "pl_gram.y"
{
PLpgSQL_exception_block *new = (yyvsp[(2) - (3)].exception_block);
new->exc_list = (yyvsp[(3) - (3)].list);
(yyval.exception_block) = new;
;}
break;
case 152:
#line 2364 "pl_gram.y"
{
(yyval.list) = lappend((yyvsp[(1) - (2)].list), (yyvsp[(2) - (2)].exception));
;}
break;
case 153:
#line 2368 "pl_gram.y"
{
(yyval.list) = list_make1((yyvsp[(1) - (1)].exception));
;}
break;
case 154:
#line 2374 "pl_gram.y"
{
PLpgSQL_exception *new;
new = palloc0(sizeof(PLpgSQL_exception));
new->lineno = plpgsql_location_to_lineno((yylsp[(1) - (4)]), yyscanner);
new->conditions = (yyvsp[(2) - (4)].condition);
new->action = (yyvsp[(4) - (4)].list);
(yyval.exception) = new;
;}
break;
case 155:
#line 2387 "pl_gram.y"
{
PLpgSQL_condition *old;
for (old = (yyvsp[(1) - (3)].condition); old->next != NULL; old = old->next)
;
old->next = (yyvsp[(3) - (3)].condition);
(yyval.condition) = (yyvsp[(1) - (3)].condition);
;}
break;
case 156:
#line 2396 "pl_gram.y"
{
(yyval.condition) = (yyvsp[(1) - (1)].condition);
;}
break;
case 157:
#line 2402 "pl_gram.y"
{
if (strcmp((yyvsp[(1) - (1)].str), "sqlstate") != 0)
{
(yyval.condition) = plpgsql_parse_err_condition((yyvsp[(1) - (1)].str));
}
else
{
PLpgSQL_condition *new;
char *sqlstatestr;
if (yylex(&yylval, &yylloc, yyscanner) != SCONST)
yyerror(&yylloc, NULL, yyscanner, "syntax error");
sqlstatestr = yylval.str;
if (strlen(sqlstatestr) != 5)
yyerror(&yylloc, NULL, yyscanner, "invalid SQLSTATE code");
if (strspn(sqlstatestr, "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ") != 5)
yyerror(&yylloc, NULL, yyscanner, "invalid SQLSTATE code");
new = palloc(sizeof(PLpgSQL_condition));
new->sqlerrstate =
MAKE_SQLSTATE(sqlstatestr[0],
sqlstatestr[1],
sqlstatestr[2],
sqlstatestr[3],
sqlstatestr[4]);
new->condname = sqlstatestr;
new->next = NULL;
(yyval.condition) = new;
}
;}
break;
case 158:
#line 2438 "pl_gram.y"
{ (yyval.expr) = read_sql_expression(';', ";", &yylval, &yylloc, yyscanner); ;}
break;
case 159:
#line 2442 "pl_gram.y"
{ (yyval.expr) = read_sql_expression(K_THEN, "THEN", &yylval, &yylloc, yyscanner); ;}
break;
case 160:
#line 2446 "pl_gram.y"
{ (yyval.expr) = read_sql_expression(K_LOOP, "LOOP", &yylval, &yylloc, yyscanner); ;}
break;
case 161:
#line 2450 "pl_gram.y"
{
plpgsql_ns_push(NULL, PLPGSQL_LABEL_BLOCK);
(yyval.str) = NULL;
;}
break;
case 162:
#line 2455 "pl_gram.y"
{
plpgsql_ns_push((yyvsp[(2) - (3)].str), PLPGSQL_LABEL_BLOCK);
(yyval.str) = (yyvsp[(2) - (3)].str);
;}
break;
case 163:
#line 2462 "pl_gram.y"
{
plpgsql_ns_push(NULL, PLPGSQL_LABEL_LOOP);
(yyval.str) = NULL;
;}
break;
case 164:
#line 2467 "pl_gram.y"
{
plpgsql_ns_push((yyvsp[(2) - (3)].str), PLPGSQL_LABEL_LOOP);
(yyval.str) = (yyvsp[(2) - (3)].str);
;}
break;
case 165:
#line 2474 "pl_gram.y"
{
(yyval.str) = NULL;
;}
break;
case 166:
#line 2478 "pl_gram.y"
{
(yyval.str) = (yyvsp[(1) - (1)].str);
;}
break;
case 167:
#line 2485 "pl_gram.y"
{ (yyval.expr) = NULL; ;}
break;
case 168:
#line 2487 "pl_gram.y"
{ (yyval.expr) = (yyvsp[(2) - (2)].expr); ;}
break;
case 169:
#line 2494 "pl_gram.y"
{
(yyval.str) = (yyvsp[(1) - (1)].word).ident;
;}
break;
case 170:
#line 2498 "pl_gram.y"
{
(yyval.str) = pstrdup((yyvsp[(1) - (1)].keyword));
;}
break;
case 171:
#line 2502 "pl_gram.y"
{
if ((yyvsp[(1) - (1)].wdatum).ident == NULL)
yyerror(&yylloc, NULL, yyscanner, "syntax error");
(yyval.str) = (yyvsp[(1) - (1)].wdatum).ident;
;}
break;
#line 4786 "pl_gram.c"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
*++yyvsp = yyval;
*++yylsp = yyloc;
yyn = yyr1[yyn];
yystate = yypgoto[yyn - YYNTOKENS] + *yyssp;
if (0 <= yystate && yystate <= YYLAST && yycheck[yystate] == *yyssp)
yystate = yytable[yystate];
else
yystate = yydefgoto[yyn - YYNTOKENS];
goto yynewstate;
yyerrlab:
if (!yyerrstatus)
{
++yynerrs;
#if ! YYERROR_VERBOSE
yyerror (&yylloc, plpgsql_parse_result_p, yyscanner, YY_("syntax error"));
#else
{
YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM)
{
YYSIZE_T yyalloc = 2 * yysize;
if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM))
yyalloc = YYSTACK_ALLOC_MAXIMUM;
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
yymsg = (char *) YYSTACK_ALLOC (yyalloc);
if (yymsg)
yymsg_alloc = yyalloc;
else
{
yymsg = yymsgbuf;
yymsg_alloc = sizeof yymsgbuf;
}
}
if (0 < yysize && yysize <= yymsg_alloc)
{
(void) yysyntax_error (yymsg, yystate, yychar);
yyerror (&yylloc, plpgsql_parse_result_p, yyscanner, yymsg);
}
else
{
yyerror (&yylloc, plpgsql_parse_result_p, yyscanner, YY_("syntax error"));
if (yysize != 0)
goto yyexhaustedlab;
}
}
#endif
}
yyerror_range[0] = yylloc;
if (yyerrstatus == 3)
{
if (yychar <= YYEOF)
{
if (yychar == YYEOF)
YYABORT;
}
else
{
yydestruct ("Error: discarding",
yytoken, &yylval, &yylloc, plpgsql_parse_result_p, yyscanner);
yychar = YYEMPTY;
}
}
goto yyerrlab1;
yyerrorlab:
if ( 0)
goto yyerrorlab;
yyerror_range[0] = yylsp[1-yylen];
YYPOPSTACK (yylen);
yylen = 0;
YY_STACK_PRINT (yyss, yyssp);
yystate = *yyssp;
goto yyerrlab1;
yyerrlab1:
yyerrstatus = 3;
for (;;)
{
yyn = yypact[yystate];
if (yyn != YYPACT_NINF)
{
yyn += YYTERROR;
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
{
yyn = yytable[yyn];
if (0 < yyn)
break;
}
}
if (yyssp == yyss)
YYABORT;
yyerror_range[0] = *yylsp;
yydestruct ("Error: popping",
yystos[yystate], yyvsp, yylsp, plpgsql_parse_result_p, yyscanner);
YYPOPSTACK (1);
yystate = *yyssp;
YY_STACK_PRINT (yyss, yyssp);
}
if (yyn == YYFINAL)
YYACCEPT;
*++yyvsp = yylval;
yyerror_range[1] = yylloc;
YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
*++yylsp = yyloc;
YY_SYMBOL_PRINT ("Shifting", yystos[yyn], yyvsp, yylsp);
yystate = yyn;
goto yynewstate;
yyacceptlab:
yyresult = 0;
goto yyreturn;
yyabortlab:
yyresult = 1;
goto yyreturn;
#ifndef yyoverflow
yyexhaustedlab:
yyerror (&yylloc, plpgsql_parse_result_p, yyscanner, YY_("memory exhausted"));
yyresult = 2;
#endif
yyreturn:
if (yychar != YYEOF && yychar != YYEMPTY)
yydestruct ("Cleanup: discarding lookahead",
yytoken, &yylval, &yylloc, plpgsql_parse_result_p, yyscanner);
YYPOPSTACK (yylen);
YY_STACK_PRINT (yyss, yyssp);
while (yyssp != yyss)
{
yydestruct ("Cleanup: popping",
yystos[*yyssp], yyvsp, yylsp, plpgsql_parse_result_p, yyscanner);
YYPOPSTACK (1);
}
#ifndef yyoverflow
if (yyss != yyssa)
YYSTACK_FREE (yyss);
#endif
#if YYERROR_VERBOSE
if (yymsg != yymsgbuf)
YYSTACK_FREE (yymsg);
#endif
return YYID (yyresult);
}
#line 2594 "pl_gram.y"
static bool
tok_is_keyword(int token, union YYSTYPE *lval,
int kw_token, const char *kw_str)
{
if (token == kw_token)
{
return true;
}
else if (token == T_DATUM)
{
if (!lval->wdatum.quoted && lval->wdatum.ident != NULL &&
strcmp(lval->wdatum.ident, kw_str) == 0)
return true;
}
return false;
}
static void
word_is_not_variable(PLword *word, int location, yyscan_t yyscanner)
{
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("\"%s\" is not a known variable",
word->ident),
parser_errposition(location)));
}
static void
cword_is_not_variable(PLcword *cword, int location, yyscan_t yyscanner)
{
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("\"%s\" is not a known variable",
NameListToString(cword->idents)),
parser_errposition(location)));
}
static void
current_token_is_not_variable(int tok, YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner)
{
if (tok == T_WORD)
word_is_not_variable(&(yylvalp->word), *yyllocp, yyscanner);
else if (tok == T_CWORD)
cword_is_not_variable(&(yylvalp->cword), *yyllocp, yyscanner);
else
yyerror(yyllocp, NULL, yyscanner, "syntax error");
}
static PLpgSQL_expr *
make_plpgsql_expr(const char *query,
RawParseMode parsemode)
{
PLpgSQL_expr *expr = palloc0(sizeof(PLpgSQL_expr));
expr->query = pstrdup(query);
expr->parseMode = parsemode;
expr->func = plpgsql_curr_compile;
expr->ns = plpgsql_ns_top();
expr->target_param = -1;
expr->target_is_local = false;
return expr;
}
static void
mark_expr_as_assignment_source(PLpgSQL_expr *expr, PLpgSQL_datum *target)
{
if (target->dtype == PLPGSQL_DTYPE_VAR)
{
expr->target_param = target->dno;
expr->target_is_local = true;
}
else
{
expr->target_param = -1;
expr->target_is_local = false;
}
}
static PLpgSQL_expr *
read_sql_expression(int until, const char *expected, YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner)
{
return read_sql_construct(until, 0, 0, expected,
RAW_PARSE_PLPGSQL_EXPR,
true, true, NULL, NULL,
yylvalp, yyllocp, yyscanner);
}
static PLpgSQL_expr *
read_sql_expression2(int until, int until2, const char *expected,
int *endtoken, YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner)
{
return read_sql_construct(until, until2, 0, expected,
RAW_PARSE_PLPGSQL_EXPR,
true, true, NULL, endtoken,
yylvalp, yyllocp, yyscanner);
}
static PLpgSQL_expr *
read_sql_stmt(YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner)
{
return read_sql_construct(';', 0, 0, ";",
RAW_PARSE_DEFAULT,
false, true, NULL, NULL,
yylvalp, yyllocp, yyscanner);
}
static PLpgSQL_expr *
read_sql_construct(int until,
int until2,
int until3,
const char *expected,
RawParseMode parsemode,
bool isexpression,
bool valid_sql,
int *startloc,
int *endtoken,
YYSTYPE *yylvalp, YYLTYPE *yyllocp,
yyscan_t yyscanner)
{
int tok;
StringInfoData ds;
IdentifierLookup save_IdentifierLookup;
int startlocation = -1;
int endlocation = -1;
int parenlevel = 0;
PLpgSQL_expr *expr;
initStringInfo(&ds);
save_IdentifierLookup = plpgsql_IdentifierLookup;
plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_EXPR;
for (;;)
{
tok = yylex(yylvalp, yyllocp, yyscanner);
if (startlocation < 0)
startlocation = *yyllocp;
if (tok == until && parenlevel == 0)
break;
if (tok == until2 && parenlevel == 0)
break;
if (tok == until3 && parenlevel == 0)
break;
if (tok == '(' || tok == '[')
parenlevel++;
else if (tok == ')' || tok == ']')
{
parenlevel--;
if (parenlevel < 0)
yyerror(yyllocp, NULL, yyscanner, "mismatched parentheses");
}
if (tok == 0 || tok == ';')
{
if (parenlevel != 0)
yyerror(yyllocp, NULL, yyscanner, "mismatched parentheses");
if (isexpression)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("missing \"%s\" at end of SQL expression",
expected),
parser_errposition(*yyllocp)));
else
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("missing \"%s\" at end of SQL statement",
expected),
parser_errposition(*yyllocp)));
}
endlocation = *yyllocp + plpgsql_token_length(yyscanner);
}
plpgsql_IdentifierLookup = save_IdentifierLookup;
if (startloc)
*startloc = startlocation;
if (endtoken)
*endtoken = tok;
if (startlocation >= endlocation)
{
if (isexpression)
yyerror(yyllocp, NULL, yyscanner, "missing expression");
else
yyerror(yyllocp, NULL, yyscanner, "missing SQL statement");
}
plpgsql_append_source_text(&ds, startlocation, endlocation, yyscanner);
expr = make_plpgsql_expr(ds.data, parsemode);
pfree(ds.data);
if (valid_sql)
check_sql_expr(expr->query, expr->parseMode, startlocation, yyscanner);
return expr;
}
static PLpgSQL_type *
read_datatype(int tok, YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner)
{
StringInfoData ds;
char *type_name;
int startlocation;
PLpgSQL_type *result = NULL;
int parenlevel = 0;
Assert(plpgsql_IdentifierLookup == IDENTIFIER_LOOKUP_DECLARE);
if (tok == YYEMPTY)
tok = yylex(yylvalp, yyllocp, yyscanner);
startlocation = *yyllocp;
if (tok == T_WORD)
{
char *dtname = yylvalp->word.ident;
tok = yylex(yylvalp, yyllocp, yyscanner);
if (tok == '%')
{
tok = yylex(yylvalp, yyllocp, yyscanner);
if (tok_is_keyword(tok, yylvalp,
K_TYPE, "type"))
result = plpgsql_parse_wordtype(dtname);
else if (tok_is_keyword(tok, yylvalp,
K_ROWTYPE, "rowtype"))
result = plpgsql_parse_wordrowtype(dtname);
}
}
else if (plpgsql_token_is_unreserved_keyword(tok))
{
char *dtname = pstrdup(yylvalp->keyword);
tok = yylex(yylvalp, yyllocp, yyscanner);
if (tok == '%')
{
tok = yylex(yylvalp, yyllocp, yyscanner);
if (tok_is_keyword(tok, yylvalp,
K_TYPE, "type"))
result = plpgsql_parse_wordtype(dtname);
else if (tok_is_keyword(tok, yylvalp,
K_ROWTYPE, "rowtype"))
result = plpgsql_parse_wordrowtype(dtname);
}
}
else if (tok == T_CWORD)
{
List *dtnames = yylvalp->cword.idents;
tok = yylex(yylvalp, yyllocp, yyscanner);
if (tok == '%')
{
tok = yylex(yylvalp, yyllocp, yyscanner);
if (tok_is_keyword(tok, yylvalp,
K_TYPE, "type"))
result = plpgsql_parse_cwordtype(dtnames);
else if (tok_is_keyword(tok, yylvalp,
K_ROWTYPE, "rowtype"))
result = plpgsql_parse_cwordrowtype(dtnames);
}
}
if (result)
{
bool is_array = false;
tok = yylex(yylvalp, yyllocp, yyscanner);
if (tok_is_keyword(tok, yylvalp,
K_ARRAY, "array"))
{
is_array = true;
tok = yylex(yylvalp, yyllocp, yyscanner);
}
while (tok == '[')
{
is_array = true;
tok = yylex(yylvalp, yyllocp, yyscanner);
if (tok == ICONST)
tok = yylex(yylvalp, yyllocp, yyscanner);
if (tok != ']')
yyerror(yyllocp, NULL, yyscanner, "syntax error, expected \"]\"");
tok = yylex(yylvalp, yyllocp, yyscanner);
}
plpgsql_push_back_token(tok, yylvalp, yyllocp, yyscanner);
if (is_array)
result = plpgsql_build_datatype_arrayof(result);
return result;
}
while (tok != ';')
{
if (tok == 0)
{
if (parenlevel != 0)
yyerror(yyllocp, NULL, yyscanner, "mismatched parentheses");
else
yyerror(yyllocp, NULL, yyscanner, "incomplete data type declaration");
}
if (tok == K_COLLATE || tok == K_NOT ||
tok == '=' || tok == COLON_EQUALS || tok == K_DEFAULT)
break;
if ((tok == ',' || tok == ')') && parenlevel == 0)
break;
if (tok == '(')
parenlevel++;
else if (tok == ')')
parenlevel--;
tok = yylex(yylvalp, yyllocp, yyscanner);
}
initStringInfo(&ds);
plpgsql_append_source_text(&ds, startlocation, *yyllocp, yyscanner);
type_name = ds.data;
if (type_name[0] == '\0')
yyerror(yyllocp, NULL, yyscanner, "missing data type declaration");
result = parse_datatype(type_name, startlocation, yyscanner);
pfree(ds.data);
plpgsql_push_back_token(tok, yylvalp, yyllocp, yyscanner);
return result;
}
static PLpgSQL_stmt *
make_execsql_stmt(int firsttoken, int location, PLword *word, YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner)
{
StringInfoData ds;
IdentifierLookup save_IdentifierLookup;
PLpgSQL_stmt_execsql *execsql;
PLpgSQL_expr *expr;
PLpgSQL_variable *target = NULL;
int tok;
int prev_tok;
bool have_into = false;
bool have_strict = false;
int into_start_loc = -1;
int into_end_loc = -1;
int paren_depth = 0;
int begin_depth = 0;
bool in_routine_definition = false;
int token_count = 0;
char tokens[4];
initStringInfo(&ds);
memset(tokens, 0, sizeof(tokens));
save_IdentifierLookup = plpgsql_IdentifierLookup;
plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_EXPR;
tok = firsttoken;
if (tok == T_WORD && strcmp(word->ident, "create") == 0)
tokens[token_count] = 'c';
token_count++;
for (;;)
{
prev_tok = tok;
tok = yylex(yylvalp, yyllocp, yyscanner);
if (have_into && into_end_loc < 0)
into_end_loc = *yyllocp;
if (tokens[0] == 'c' && token_count < sizeof(tokens))
{
if (tok == K_OR)
tokens[token_count] = 'o';
else if (tok == T_WORD &&
strcmp(yylvalp->word.ident, "replace") == 0)
tokens[token_count] = 'r';
else if (tok == T_WORD &&
strcmp(yylvalp->word.ident, "function") == 0)
tokens[token_count] = 'f';
else if (tok == T_WORD &&
strcmp(yylvalp->word.ident, "procedure") == 0)
tokens[token_count] = 'f';
if (tokens[1] == 'f' ||
(tokens[1] == 'o' && tokens[2] == 'r' && tokens[3] == 'f'))
in_routine_definition = true;
token_count++;
}
if (tok == '(')
paren_depth++;
else if (tok == ')' && paren_depth > 0)
paren_depth--;
if (in_routine_definition && paren_depth == 0)
{
if (tok == K_BEGIN || tok == K_CASE)
begin_depth++;
else if (tok == K_END && begin_depth > 0)
begin_depth--;
}
if (tok == ';' && paren_depth == 0 && begin_depth == 0)
break;
if (tok == 0)
yyerror(yyllocp, NULL, yyscanner, "unexpected end of function definition");
if (tok == K_INTO)
{
if (prev_tok == K_INSERT)
continue;
if (prev_tok == K_MERGE)
continue;
if (firsttoken == K_IMPORT)
continue;
if (have_into)
yyerror(yyllocp, NULL, yyscanner, "INTO specified more than once");
have_into = true;
into_start_loc = *yyllocp;
plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_NORMAL;
read_into_target(&target, &have_strict, yylvalp, yyllocp, yyscanner);
plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_EXPR;
}
}
plpgsql_IdentifierLookup = save_IdentifierLookup;
if (have_into)
{
plpgsql_append_source_text(&ds, location, into_start_loc, yyscanner);
appendStringInfoSpaces(&ds, into_end_loc - into_start_loc);
plpgsql_append_source_text(&ds, into_end_loc, *yyllocp, yyscanner);
}
else
plpgsql_append_source_text(&ds, location, *yyllocp, yyscanner);
while (ds.len > 0 && scanner_isspace(ds.data[ds.len - 1]))
ds.data[--ds.len] = '\0';
expr = make_plpgsql_expr(ds.data, RAW_PARSE_DEFAULT);
pfree(ds.data);
check_sql_expr(expr->query, expr->parseMode, location, yyscanner);
execsql = palloc0(sizeof(PLpgSQL_stmt_execsql));
execsql->cmd_type = PLPGSQL_STMT_EXECSQL;
execsql->lineno = plpgsql_location_to_lineno(location, yyscanner);
execsql->stmtid = ++plpgsql_curr_compile->nstatements;
execsql->sqlstmt = expr;
execsql->into = have_into;
execsql->strict = have_strict;
execsql->target = target;
return (PLpgSQL_stmt *) execsql;
}
static PLpgSQL_stmt_fetch *
read_fetch_direction(YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner)
{
PLpgSQL_stmt_fetch *fetch;
int tok;
bool check_FROM = true;
fetch = (PLpgSQL_stmt_fetch *) palloc0(sizeof(PLpgSQL_stmt_fetch));
fetch->cmd_type = PLPGSQL_STMT_FETCH;
fetch->stmtid = ++plpgsql_curr_compile->nstatements;
fetch->direction = FETCH_FORWARD;
fetch->how_many = 1;
fetch->expr = NULL;
fetch->returns_multiple_rows = false;
tok = yylex(yylvalp, yyllocp, yyscanner);
if (tok == 0)
yyerror(yyllocp, NULL, yyscanner, "unexpected end of function definition");
if (tok_is_keyword(tok, yylvalp,
K_NEXT, "next"))
{
}
else if (tok_is_keyword(tok, yylvalp,
K_PRIOR, "prior"))
{
fetch->direction = FETCH_BACKWARD;
}
else if (tok_is_keyword(tok, yylvalp,
K_FIRST, "first"))
{
fetch->direction = FETCH_ABSOLUTE;
}
else if (tok_is_keyword(tok, yylvalp,
K_LAST, "last"))
{
fetch->direction = FETCH_ABSOLUTE;
fetch->how_many = -1;
}
else if (tok_is_keyword(tok, yylvalp,
K_ABSOLUTE, "absolute"))
{
fetch->direction = FETCH_ABSOLUTE;
fetch->expr = read_sql_expression2(K_FROM, K_IN,
"FROM or IN",
NULL, yylvalp, yyllocp, yyscanner);
check_FROM = false;
}
else if (tok_is_keyword(tok, yylvalp,
K_RELATIVE, "relative"))
{
fetch->direction = FETCH_RELATIVE;
fetch->expr = read_sql_expression2(K_FROM, K_IN,
"FROM or IN",
NULL, yylvalp, yyllocp, yyscanner);
check_FROM = false;
}
else if (tok_is_keyword(tok, yylvalp,
K_ALL, "all"))
{
fetch->how_many = FETCH_ALL;
fetch->returns_multiple_rows = true;
}
else if (tok_is_keyword(tok, yylvalp,
K_FORWARD, "forward"))
{
complete_direction(fetch, &check_FROM, yylvalp, yyllocp, yyscanner);
}
else if (tok_is_keyword(tok, yylvalp,
K_BACKWARD, "backward"))
{
fetch->direction = FETCH_BACKWARD;
complete_direction(fetch, &check_FROM, yylvalp, yyllocp, yyscanner);
}
else if (tok == K_FROM || tok == K_IN)
{
check_FROM = false;
}
else if (tok == T_DATUM)
{
plpgsql_push_back_token(tok, yylvalp, yyllocp, yyscanner);
check_FROM = false;
}
else
{
plpgsql_push_back_token(tok, yylvalp, yyllocp, yyscanner);
fetch->expr = read_sql_expression2(K_FROM, K_IN,
"FROM or IN",
NULL, yylvalp, yyllocp, yyscanner);
fetch->returns_multiple_rows = true;
check_FROM = false;
}
if (check_FROM)
{
tok = yylex(yylvalp, yyllocp, yyscanner);
if (tok != K_FROM && tok != K_IN)
yyerror(yyllocp, NULL, yyscanner, "expected FROM or IN");
}
return fetch;
}
static void
complete_direction(PLpgSQL_stmt_fetch *fetch, bool *check_FROM, YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner)
{
int tok;
tok = yylex(yylvalp, yyllocp, yyscanner);
if (tok == 0)
yyerror(yyllocp, NULL, yyscanner, "unexpected end of function definition");
if (tok == K_FROM || tok == K_IN)
{
*check_FROM = false;
return;
}
if (tok == K_ALL)
{
fetch->how_many = FETCH_ALL;
fetch->returns_multiple_rows = true;
*check_FROM = true;
return;
}
plpgsql_push_back_token(tok, yylvalp, yyllocp, yyscanner);
fetch->expr = read_sql_expression2(K_FROM, K_IN,
"FROM or IN",
NULL, yylvalp, yyllocp, yyscanner);
fetch->returns_multiple_rows = true;
*check_FROM = false;
}
static PLpgSQL_stmt *
make_return_stmt(int location, YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner)
{
PLpgSQL_stmt_return *new;
new = palloc0(sizeof(PLpgSQL_stmt_return));
new->cmd_type = PLPGSQL_STMT_RETURN;
new->lineno = plpgsql_location_to_lineno(location, yyscanner);
new->stmtid = ++plpgsql_curr_compile->nstatements;
new->expr = NULL;
new->retvarno = -1;
if (plpgsql_curr_compile->fn_retset)
{
if (yylex(yylvalp, yyllocp, yyscanner) != ';')
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("RETURN cannot have a parameter in function returning set"),
errhint("Use RETURN NEXT or RETURN QUERY."),
parser_errposition(*yyllocp)));
}
else if (plpgsql_curr_compile->fn_rettype == VOIDOID)
{
if (yylex(yylvalp, yyllocp, yyscanner) != ';')
{
if (plpgsql_curr_compile->fn_prokind == PROKIND_PROCEDURE)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("RETURN cannot have a parameter in a procedure"),
parser_errposition(*yyllocp)));
else
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("RETURN cannot have a parameter in function returning void"),
parser_errposition(*yyllocp)));
}
}
else if (plpgsql_curr_compile->out_param_varno >= 0)
{
if (yylex(yylvalp, yyllocp, yyscanner) != ';')
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("RETURN cannot have a parameter in function with OUT parameters"),
parser_errposition(*yyllocp)));
new->retvarno = plpgsql_curr_compile->out_param_varno;
}
else
{
int tok = yylex(yylvalp, yyllocp, yyscanner);
if (tok == T_DATUM && plpgsql_peek(yyscanner) == ';' &&
(yylvalp->wdatum.datum->dtype == PLPGSQL_DTYPE_VAR ||
yylvalp->wdatum.datum->dtype == PLPGSQL_DTYPE_PROMISE ||
yylvalp->wdatum.datum->dtype == PLPGSQL_DTYPE_ROW ||
yylvalp->wdatum.datum->dtype == PLPGSQL_DTYPE_REC))
{
new->retvarno = yylvalp->wdatum.datum->dno;
tok = yylex(yylvalp, yyllocp, yyscanner);
Assert(tok == ';');
}
else
{
plpgsql_push_back_token(tok, yylvalp, yyllocp, yyscanner);
new->expr = read_sql_expression(';', ";", yylvalp, yyllocp, yyscanner);
}
}
return (PLpgSQL_stmt *) new;
}
static PLpgSQL_stmt *
make_return_next_stmt(int location, YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner)
{
PLpgSQL_stmt_return_next *new;
if (!plpgsql_curr_compile->fn_retset)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("cannot use RETURN NEXT in a non-SETOF function"),
parser_errposition(location)));
new = palloc0(sizeof(PLpgSQL_stmt_return_next));
new->cmd_type = PLPGSQL_STMT_RETURN_NEXT;
new->lineno = plpgsql_location_to_lineno(location, yyscanner);
new->stmtid = ++plpgsql_curr_compile->nstatements;
new->expr = NULL;
new->retvarno = -1;
if (plpgsql_curr_compile->out_param_varno >= 0)
{
if (yylex(yylvalp, yyllocp, yyscanner) != ';')
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("RETURN NEXT cannot have a parameter in function with OUT parameters"),
parser_errposition(*yyllocp)));
new->retvarno = plpgsql_curr_compile->out_param_varno;
}
else
{
int tok = yylex(yylvalp, yyllocp, yyscanner);
if (tok == T_DATUM && plpgsql_peek(yyscanner) == ';' &&
(yylvalp->wdatum.datum->dtype == PLPGSQL_DTYPE_VAR ||
yylvalp->wdatum.datum->dtype == PLPGSQL_DTYPE_PROMISE ||
yylvalp->wdatum.datum->dtype == PLPGSQL_DTYPE_ROW ||
yylvalp->wdatum.datum->dtype == PLPGSQL_DTYPE_REC))
{
new->retvarno = yylvalp->wdatum.datum->dno;
tok = yylex(yylvalp, yyllocp, yyscanner);
Assert(tok == ';');
}
else
{
plpgsql_push_back_token(tok, yylvalp, yyllocp, yyscanner);
new->expr = read_sql_expression(';', ";", yylvalp, yyllocp, yyscanner);
}
}
return (PLpgSQL_stmt *) new;
}
static PLpgSQL_stmt *
make_return_query_stmt(int location, YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner)
{
PLpgSQL_stmt_return_query *new;
int tok;
if (!plpgsql_curr_compile->fn_retset)
ereport(ERROR,
(errcode(ERRCODE_DATATYPE_MISMATCH),
errmsg("cannot use RETURN QUERY in a non-SETOF function"),
parser_errposition(location)));
new = palloc0(sizeof(PLpgSQL_stmt_return_query));
new->cmd_type = PLPGSQL_STMT_RETURN_QUERY;
new->lineno = plpgsql_location_to_lineno(location, yyscanner);
new->stmtid = ++plpgsql_curr_compile->nstatements;
if ((tok = yylex(yylvalp, yyllocp, yyscanner)) != K_EXECUTE)
{
plpgsql_push_back_token(tok, yylvalp, yyllocp, yyscanner);
new->query = read_sql_stmt(yylvalp, yyllocp, yyscanner);
}
else
{
int term;
new->dynquery = read_sql_expression2(';', K_USING, "; or USING",
&term, yylvalp, yyllocp, yyscanner);
if (term == K_USING)
{
do
{
PLpgSQL_expr *expr;
expr = read_sql_expression2(',', ';', ", or ;", &term, yylvalp, yyllocp, yyscanner);
new->params = lappend(new->params, expr);
} while (term == ',');
}
}
return (PLpgSQL_stmt *) new;
}
static char *
NameOfDatum(PLwdatum *wdatum)
{
if (wdatum->ident)
return wdatum->ident;
Assert(wdatum->idents != NIL);
return NameListToString(wdatum->idents);
}
static void
check_assignable(PLpgSQL_datum *datum, int location, yyscan_t yyscanner)
{
switch (datum->dtype)
{
case PLPGSQL_DTYPE_VAR:
case PLPGSQL_DTYPE_PROMISE:
case PLPGSQL_DTYPE_REC:
if (((PLpgSQL_variable *) datum)->isconst)
ereport(ERROR,
(errcode(ERRCODE_ERROR_IN_ASSIGNMENT),
errmsg("variable \"%s\" is declared CONSTANT",
((PLpgSQL_variable *) datum)->refname),
parser_errposition(location)));
break;
case PLPGSQL_DTYPE_ROW:
break;
case PLPGSQL_DTYPE_RECFIELD:
check_assignable(plpgsql_Datums[((PLpgSQL_recfield *) datum)->recparentno],
location, yyscanner);
break;
default:
elog(ERROR, "unrecognized dtype: %d", datum->dtype);
break;
}
}
static void
read_into_target(PLpgSQL_variable **target, bool *strict, YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner)
{
int tok;
*target = NULL;
if (strict)
*strict = false;
tok = yylex(yylvalp, yyllocp, yyscanner);
if (strict && tok == K_STRICT)
{
*strict = true;
tok = yylex(yylvalp, yyllocp, yyscanner);
}
switch (tok)
{
case T_DATUM:
if (yylvalp->wdatum.datum->dtype == PLPGSQL_DTYPE_ROW ||
yylvalp->wdatum.datum->dtype == PLPGSQL_DTYPE_REC)
{
check_assignable(yylvalp->wdatum.datum, *yyllocp, yyscanner);
*target = (PLpgSQL_variable *) yylvalp->wdatum.datum;
if ((tok = yylex(yylvalp, yyllocp, yyscanner)) == ',')
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("record variable cannot be part of multiple-item INTO list"),
parser_errposition(*yyllocp)));
plpgsql_push_back_token(tok, yylvalp, yyllocp, yyscanner);
}
else
{
*target = (PLpgSQL_variable *)
read_into_scalar_list(NameOfDatum(&(yylvalp->wdatum)),
yylvalp->wdatum.datum, *yyllocp, yylvalp, yyllocp, yyscanner);
}
break;
default:
current_token_is_not_variable(tok, yylvalp, yyllocp, yyscanner);
}
}
static PLpgSQL_row *
read_into_scalar_list(char *initial_name,
PLpgSQL_datum *initial_datum,
int initial_location,
YYSTYPE *yylvalp, YYLTYPE *yyllocp,
yyscan_t yyscanner)
{
int nfields;
char *fieldnames[1024];
int varnos[1024];
PLpgSQL_row *row;
int tok;
check_assignable(initial_datum, initial_location, yyscanner);
fieldnames[0] = initial_name;
varnos[0] = initial_datum->dno;
nfields = 1;
while ((tok = yylex(yylvalp, yyllocp, yyscanner)) == ',')
{
if (nfields >= 1024)
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("too many INTO variables specified"),
parser_errposition(*yyllocp)));
tok = yylex(yylvalp, yyllocp, yyscanner);
switch (tok)
{
case T_DATUM:
check_assignable(yylvalp->wdatum.datum, *yyllocp, yyscanner);
if (yylvalp->wdatum.datum->dtype == PLPGSQL_DTYPE_ROW ||
yylvalp->wdatum.datum->dtype == PLPGSQL_DTYPE_REC)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("\"%s\" is not a scalar variable",
NameOfDatum(&(yylvalp->wdatum))),
parser_errposition(*yyllocp)));
fieldnames[nfields] = NameOfDatum(&(yylvalp->wdatum));
varnos[nfields++] = yylvalp->wdatum.datum->dno;
break;
default:
current_token_is_not_variable(tok, yylvalp, yyllocp, yyscanner);
}
}
plpgsql_push_back_token(tok, yylvalp, yyllocp, yyscanner);
row = palloc0(sizeof(PLpgSQL_row));
row->dtype = PLPGSQL_DTYPE_ROW;
row->refname = "(unnamed row)";
row->lineno = plpgsql_location_to_lineno(initial_location, yyscanner);
row->rowtupdesc = NULL;
row->nfields = nfields;
row->fieldnames = palloc(sizeof(char *) * nfields);
row->varnos = palloc(sizeof(int) * nfields);
while (--nfields >= 0)
{
row->fieldnames[nfields] = fieldnames[nfields];
row->varnos[nfields] = varnos[nfields];
}
plpgsql_adddatum((PLpgSQL_datum *) row);
return row;
}
static PLpgSQL_row *
make_scalar_list1(char *initial_name,
PLpgSQL_datum *initial_datum,
int lineno, int location, yyscan_t yyscanner)
{
PLpgSQL_row *row;
check_assignable(initial_datum, location, yyscanner);
row = palloc0(sizeof(PLpgSQL_row));
row->dtype = PLPGSQL_DTYPE_ROW;
row->refname = "(unnamed row)";
row->lineno = lineno;
row->rowtupdesc = NULL;
row->nfields = 1;
row->fieldnames = palloc(sizeof(char *));
row->varnos = palloc(sizeof(int));
row->fieldnames[0] = initial_name;
row->varnos[0] = initial_datum->dno;
plpgsql_adddatum((PLpgSQL_datum *) row);
return row;
}
static void
check_sql_expr(const char *stmt, RawParseMode parseMode, int location, yyscan_t yyscanner)
{
sql_error_callback_arg cbarg;
ErrorContextCallback syntax_errcontext;
MemoryContext oldCxt;
if (!plpgsql_check_syntax)
return;
cbarg.location = location;
cbarg.yyscanner = yyscanner;
syntax_errcontext.callback = plpgsql_sql_error_callback;
syntax_errcontext.arg = &cbarg;
syntax_errcontext.previous = error_context_stack;
error_context_stack = &syntax_errcontext;
oldCxt = MemoryContextSwitchTo(plpgsql_compile_tmp_cxt);
(void) raw_parser(stmt, parseMode);
MemoryContextSwitchTo(oldCxt);
error_context_stack = syntax_errcontext.previous;
}
static void
plpgsql_sql_error_callback(void *arg)
{
sql_error_callback_arg *cbarg = (sql_error_callback_arg *) arg;
yyscan_t yyscanner = cbarg->yyscanner;
int errpos;
parser_errposition(cbarg->location);
errpos = geterrposition();
if (errpos > 0)
{
int myerrpos = getinternalerrposition();
if (myerrpos > 0)
internalerrposition(myerrpos + errpos - 1);
}
errposition(0);
}
static PLpgSQL_type *
parse_datatype(const char *string, int location, yyscan_t yyscanner)
{
TypeName *typeName;
Oid type_id;
int32 typmod;
sql_error_callback_arg cbarg;
ErrorContextCallback syntax_errcontext;
cbarg.location = location;
cbarg.yyscanner = yyscanner;
syntax_errcontext.callback = plpgsql_sql_error_callback;
syntax_errcontext.arg = &cbarg;
syntax_errcontext.previous = error_context_stack;
error_context_stack = &syntax_errcontext;
typeName = typeStringToTypeName(string, NULL);
typenameTypeIdAndMod(NULL, typeName, &type_id, &typmod);
error_context_stack = syntax_errcontext.previous;
return plpgsql_build_datatype(type_id, typmod,
plpgsql_curr_compile->fn_input_collation,
typeName);
}
static void
check_labels(const char *start_label, const char *end_label, int end_location, yyscan_t yyscanner)
{
if (end_label)
{
if (!start_label)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("end label \"%s\" specified for unlabeled block",
end_label),
parser_errposition(end_location)));
if (strcmp(start_label, end_label) != 0)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("end label \"%s\" differs from block's label \"%s\"",
end_label, start_label),
parser_errposition(end_location)));
}
}
static PLpgSQL_expr *
read_cursor_args(PLpgSQL_var *cursor, int until, YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner)
{
PLpgSQL_expr *expr;
PLpgSQL_row *row;
int tok;
int argc;
char **argv;
StringInfoData ds;
bool any_named = false;
tok = yylex(yylvalp, yyllocp, yyscanner);
if (cursor->cursor_explicit_argrow < 0)
{
if (tok == '(')
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("cursor \"%s\" has no arguments",
cursor->refname),
parser_errposition(*yyllocp)));
if (tok != until)
yyerror(yyllocp, NULL, yyscanner, "syntax error");
return NULL;
}
if (tok != '(')
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("cursor \"%s\" has arguments",
cursor->refname),
parser_errposition(*yyllocp)));
row = (PLpgSQL_row *) plpgsql_Datums[cursor->cursor_explicit_argrow];
argv = (char **) palloc0(row->nfields * sizeof(char *));
for (argc = 0; argc < row->nfields; argc++)
{
PLpgSQL_expr *item;
int endtoken;
int argpos;
int tok1,
tok2;
int arglocation;
plpgsql_peek2(&tok1, &tok2, &arglocation, NULL, yyscanner);
if (tok1 == IDENT && (tok2 == COLON_EQUALS || tok2 == EQUALS_GREATER))
{
char *argname;
IdentifierLookup save_IdentifierLookup;
save_IdentifierLookup = plpgsql_IdentifierLookup;
plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_DECLARE;
yylex(yylvalp, yyllocp, yyscanner);
argname = yylvalp->str;
plpgsql_IdentifierLookup = save_IdentifierLookup;
for (argpos = 0; argpos < row->nfields; argpos++)
{
if (strcmp(row->fieldnames[argpos], argname) == 0)
break;
}
if (argpos == row->nfields)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("cursor \"%s\" has no argument named \"%s\"",
cursor->refname, argname),
parser_errposition(*yyllocp)));
tok2 = yylex(yylvalp, yyllocp, yyscanner);
if (tok2 != COLON_EQUALS && tok2 != EQUALS_GREATER)
yyerror(yyllocp, NULL, yyscanner, "syntax error");
any_named = true;
}
else
argpos = argc;
if (argv[argpos] != NULL)
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("value for parameter \"%s\" of cursor \"%s\" specified more than once",
row->fieldnames[argpos], cursor->refname),
parser_errposition(arglocation)));
item = read_sql_construct(',', ')', 0,
",\" or \")",
RAW_PARSE_PLPGSQL_EXPR,
true, true,
NULL, &endtoken,
yylvalp, yyllocp, yyscanner);
argv[argpos] = item->query;
if (endtoken == ')' && !(argc == row->nfields - 1))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("not enough arguments for cursor \"%s\"",
cursor->refname),
parser_errposition(*yyllocp)));
if (endtoken == ',' && (argc == row->nfields - 1))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("too many arguments for cursor \"%s\"",
cursor->refname),
parser_errposition(*yyllocp)));
}
initStringInfo(&ds);
for (argc = 0; argc < row->nfields; argc++)
{
Assert(argv[argc] != NULL);
appendStringInfoString(&ds, argv[argc]);
if (any_named)
appendStringInfo(&ds, " AS %s",
quote_identifier(row->fieldnames[argc]));
if (argc < row->nfields - 1)
appendStringInfoString(&ds, ", ");
}
expr = make_plpgsql_expr(ds.data, RAW_PARSE_PLPGSQL_EXPR);
pfree(ds.data);
tok = yylex(yylvalp, yyllocp, yyscanner);
if (tok != until)
yyerror(yyllocp, NULL, yyscanner, "syntax error");
return expr;
}
static List *
read_raise_options(YYSTYPE *yylvalp, YYLTYPE *yyllocp, yyscan_t yyscanner)
{
List *result = NIL;
for (;;)
{
PLpgSQL_raise_option *opt;
int tok;
if ((tok = yylex(yylvalp, yyllocp, yyscanner)) == 0)
yyerror(yyllocp, NULL, yyscanner, "unexpected end of function definition");
opt = (PLpgSQL_raise_option *) palloc(sizeof(PLpgSQL_raise_option));
if (tok_is_keyword(tok, yylvalp,
K_ERRCODE, "errcode"))
opt->opt_type = PLPGSQL_RAISEOPTION_ERRCODE;
else if (tok_is_keyword(tok, yylvalp,
K_MESSAGE, "message"))
opt->opt_type = PLPGSQL_RAISEOPTION_MESSAGE;
else if (tok_is_keyword(tok, yylvalp,
K_DETAIL, "detail"))
opt->opt_type = PLPGSQL_RAISEOPTION_DETAIL;
else if (tok_is_keyword(tok, yylvalp,
K_HINT, "hint"))
opt->opt_type = PLPGSQL_RAISEOPTION_HINT;
else if (tok_is_keyword(tok, yylvalp,
K_COLUMN, "column"))
opt->opt_type = PLPGSQL_RAISEOPTION_COLUMN;
else if (tok_is_keyword(tok, yylvalp,
K_CONSTRAINT, "constraint"))
opt->opt_type = PLPGSQL_RAISEOPTION_CONSTRAINT;
else if (tok_is_keyword(tok, yylvalp,
K_DATATYPE, "datatype"))
opt->opt_type = PLPGSQL_RAISEOPTION_DATATYPE;
else if (tok_is_keyword(tok, yylvalp,
K_TABLE, "table"))
opt->opt_type = PLPGSQL_RAISEOPTION_TABLE;
else if (tok_is_keyword(tok, yylvalp,
K_SCHEMA, "schema"))
opt->opt_type = PLPGSQL_RAISEOPTION_SCHEMA;
else
yyerror(yyllocp, NULL, yyscanner, "unrecognized RAISE statement option");
tok = yylex(yylvalp, yyllocp, yyscanner);
if (tok != '=' && tok != COLON_EQUALS)
yyerror(yyllocp, NULL, yyscanner, "syntax error, expected \"=\"");
opt->expr = read_sql_expression2(',', ';', ", or ;", &tok, yylvalp, yyllocp, yyscanner);
result = lappend(result, opt);
if (tok == ';')
break;
}
return result;
}
static void
check_raise_parameters(PLpgSQL_stmt_raise *stmt)
{
char *cp;
int expected_nparams = 0;
if (stmt->message == NULL)
return;
for (cp = stmt->message; *cp; cp++)
{
if (cp[0] == '%')
{
if (cp[1] == '%')
cp++;
else
expected_nparams++;
}
}
if (expected_nparams < list_length(stmt->params))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("too many parameters specified for RAISE")));
if (expected_nparams > list_length(stmt->params))
ereport(ERROR,
(errcode(ERRCODE_SYNTAX_ERROR),
errmsg("too few parameters specified for RAISE")));
}
static PLpgSQL_stmt *
make_case(int location, PLpgSQL_expr *t_expr,
List *case_when_list, List *else_stmts, yyscan_t yyscanner)
{
PLpgSQL_stmt_case *new;
new = palloc(sizeof(PLpgSQL_stmt_case));
new->cmd_type = PLPGSQL_STMT_CASE;
new->lineno = plpgsql_location_to_lineno(location, yyscanner);
new->stmtid = ++plpgsql_curr_compile->nstatements;
new->t_expr = t_expr;
new->t_varno = 0;
new->case_when_list = case_when_list;
new->have_else = (else_stmts != NIL);
if (list_length(else_stmts) == 1 && linitial(else_stmts) == NULL)
new->else_stmts = NIL;
else
new->else_stmts = else_stmts;
if (t_expr)
{
char varname[32];
PLpgSQL_var *t_var;
ListCell *l;
snprintf(varname, sizeof(varname), "__Case__Variable_%d__",
plpgsql_nDatums);
t_var = (PLpgSQL_var *)
plpgsql_build_variable(varname, new->lineno,
plpgsql_build_datatype(INT4OID,
-1,
InvalidOid,
NULL),
true);
new->t_varno = t_var->dno;
foreach(l, case_when_list)
{
PLpgSQL_case_when *cwt = (PLpgSQL_case_when *) lfirst(l);
PLpgSQL_expr *expr = cwt->expr;
StringInfoData ds;
Assert(expr->parseMode == RAW_PARSE_PLPGSQL_EXPR);
initStringInfo(&ds);
appendStringInfo(&ds, "\"%s\" IN (%s)",
varname, expr->query);
pfree(expr->query);
expr->query = pstrdup(ds.data);
expr->ns = plpgsql_ns_top();
pfree(ds.data);
}
}
return (PLpgSQL_stmt *) new;
}