mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-24 18:55:04 +08:00
Indent C code in flex and bison files
In the style of pgindent, done semi-manually. Discussion: https://www.postgresql.org/message-id/flat/7d062ecc-7444-23ec-a159-acd8adf9b586%40enterprisedb.com
This commit is contained in:
parent
0cf16cb8ca
commit
30ed71e423
@ -45,7 +45,7 @@ static NDBOX *write_point_as_box(int dim, char *str);
|
||||
|
||||
box: O_BRACKET paren_list COMMA paren_list C_BRACKET
|
||||
{
|
||||
int dim;
|
||||
int dim;
|
||||
|
||||
dim = item_count($2, ',');
|
||||
if (item_count($4, ',') != dim)
|
||||
@ -72,7 +72,7 @@ box: O_BRACKET paren_list COMMA paren_list C_BRACKET
|
||||
|
||||
| paren_list COMMA paren_list
|
||||
{
|
||||
int dim;
|
||||
int dim;
|
||||
|
||||
dim = item_count($1, ',');
|
||||
if (item_count($3, ',') != dim)
|
||||
@ -99,7 +99,7 @@ box: O_BRACKET paren_list COMMA paren_list C_BRACKET
|
||||
|
||||
| paren_list
|
||||
{
|
||||
int dim;
|
||||
int dim;
|
||||
|
||||
dim = item_count($1, ',');
|
||||
if (dim > CUBE_MAX_DIM)
|
||||
@ -117,7 +117,7 @@ box: O_BRACKET paren_list COMMA paren_list C_BRACKET
|
||||
|
||||
| list
|
||||
{
|
||||
int dim;
|
||||
int dim;
|
||||
|
||||
dim = item_count($1, ',');
|
||||
if (dim > CUBE_MAX_DIM)
|
||||
|
@ -38,13 +38,15 @@ static char strbuf[25] = {
|
||||
%expect 0
|
||||
%name-prefix="seg_yy"
|
||||
|
||||
%union {
|
||||
struct BND {
|
||||
float val;
|
||||
char ext;
|
||||
char sigd;
|
||||
%union
|
||||
{
|
||||
struct BND
|
||||
{
|
||||
float val;
|
||||
char ext;
|
||||
char sigd;
|
||||
} bnd;
|
||||
char * text;
|
||||
char *text;
|
||||
}
|
||||
%token <text> SEGFLOAT
|
||||
%token <text> RANGE
|
||||
@ -119,7 +121,7 @@ range: boundary PLUMIN deviation
|
||||
boundary: SEGFLOAT
|
||||
{
|
||||
/* temp variable avoids a gcc 3.3.x bug on Sparc64 */
|
||||
float val = seg_atof($1);
|
||||
float val = seg_atof($1);
|
||||
|
||||
$$.ext = '\0';
|
||||
$$.sigd = significant_digits($1);
|
||||
@ -128,7 +130,7 @@ boundary: SEGFLOAT
|
||||
| EXTENSION SEGFLOAT
|
||||
{
|
||||
/* temp variable avoids a gcc 3.3.x bug on Sparc64 */
|
||||
float val = seg_atof($2);
|
||||
float val = seg_atof($2);
|
||||
|
||||
$$.ext = $1[0];
|
||||
$$.sigd = significant_digits($2);
|
||||
@ -139,7 +141,7 @@ boundary: SEGFLOAT
|
||||
deviation: SEGFLOAT
|
||||
{
|
||||
/* temp variable avoids a gcc 3.3.x bug on Sparc64 */
|
||||
float val = seg_atof($1);
|
||||
float val = seg_atof($1);
|
||||
|
||||
$$.ext = '\0';
|
||||
$$.sigd = significant_digits($1);
|
||||
@ -153,7 +155,7 @@ deviation: SEGFLOAT
|
||||
static float
|
||||
seg_atof(const char *value)
|
||||
{
|
||||
Datum datum;
|
||||
Datum datum;
|
||||
|
||||
datum = DirectFunctionCall1(float4in, CStringGetDatum(value));
|
||||
return DatumGetFloat4(datum);
|
||||
|
@ -167,9 +167,9 @@ Boot_CreateStmt:
|
||||
}
|
||||
RPAREN
|
||||
{
|
||||
TupleDesc tupdesc;
|
||||
bool shared_relation;
|
||||
bool mapped_relation;
|
||||
TupleDesc tupdesc;
|
||||
bool shared_relation;
|
||||
bool mapped_relation;
|
||||
|
||||
do_start();
|
||||
|
||||
@ -218,7 +218,7 @@ Boot_CreateStmt:
|
||||
}
|
||||
else
|
||||
{
|
||||
Oid id;
|
||||
Oid id;
|
||||
|
||||
id = heap_create_with_catalog($2,
|
||||
PG_CATALOG_NAMESPACE,
|
||||
@ -269,8 +269,8 @@ Boot_InsertStmt:
|
||||
Boot_DeclareIndexStmt:
|
||||
XDECLARE INDEX boot_ident oidspec ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN
|
||||
{
|
||||
IndexStmt *stmt = makeNode(IndexStmt);
|
||||
Oid relationId;
|
||||
IndexStmt *stmt = makeNode(IndexStmt);
|
||||
Oid relationId;
|
||||
|
||||
elog(DEBUG4, "creating index \"%s\"", $3);
|
||||
|
||||
@ -321,8 +321,8 @@ Boot_DeclareIndexStmt:
|
||||
Boot_DeclareUniqueIndexStmt:
|
||||
XDECLARE UNIQUE INDEX boot_ident oidspec ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN
|
||||
{
|
||||
IndexStmt *stmt = makeNode(IndexStmt);
|
||||
Oid relationId;
|
||||
IndexStmt *stmt = makeNode(IndexStmt);
|
||||
Oid relationId;
|
||||
|
||||
elog(DEBUG4, "creating unique index \"%s\"", $4);
|
||||
|
||||
@ -400,7 +400,8 @@ boot_index_params:
|
||||
boot_index_param:
|
||||
boot_ident boot_ident
|
||||
{
|
||||
IndexElem *n = makeNode(IndexElem);
|
||||
IndexElem *n = makeNode(IndexElem);
|
||||
|
||||
n->name = $1;
|
||||
n->expr = NULL;
|
||||
n->indexcolname = NULL;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -42,15 +42,15 @@ Node *replication_parse_result;
|
||||
%expect 0
|
||||
%name-prefix="replication_yy"
|
||||
|
||||
%union {
|
||||
char *str;
|
||||
bool boolval;
|
||||
uint32 uintval;
|
||||
|
||||
XLogRecPtr recptr;
|
||||
Node *node;
|
||||
List *list;
|
||||
DefElem *defelt;
|
||||
%union
|
||||
{
|
||||
char *str;
|
||||
bool boolval;
|
||||
uint32 uintval;
|
||||
XLogRecPtr recptr;
|
||||
Node *node;
|
||||
List *list;
|
||||
DefElem *defelt;
|
||||
}
|
||||
|
||||
/* Non-keyword tokens */
|
||||
@ -215,27 +215,27 @@ create_slot_legacy_opt:
|
||||
K_EXPORT_SNAPSHOT
|
||||
{
|
||||
$$ = makeDefElem("snapshot",
|
||||
(Node *)makeString("export"), -1);
|
||||
(Node *) makeString("export"), -1);
|
||||
}
|
||||
| K_NOEXPORT_SNAPSHOT
|
||||
{
|
||||
$$ = makeDefElem("snapshot",
|
||||
(Node *)makeString("nothing"), -1);
|
||||
(Node *) makeString("nothing"), -1);
|
||||
}
|
||||
| K_USE_SNAPSHOT
|
||||
{
|
||||
$$ = makeDefElem("snapshot",
|
||||
(Node *)makeString("use"), -1);
|
||||
(Node *) makeString("use"), -1);
|
||||
}
|
||||
| K_RESERVE_WAL
|
||||
{
|
||||
$$ = makeDefElem("reserve_wal",
|
||||
(Node *)makeBoolean(true), -1);
|
||||
(Node *) makeBoolean(true), -1);
|
||||
}
|
||||
| K_TWO_PHASE
|
||||
{
|
||||
$$ = makeDefElem("two_phase",
|
||||
(Node *)makeBoolean(true), -1);
|
||||
(Node *) makeBoolean(true), -1);
|
||||
}
|
||||
;
|
||||
|
||||
|
@ -169,7 +169,8 @@ WAIT { return K_WAIT; }
|
||||
}
|
||||
|
||||
<xd>{xdstop} {
|
||||
int len;
|
||||
int len;
|
||||
|
||||
yyless(1);
|
||||
BEGIN(INITIAL);
|
||||
yylval.str = litbufdup();
|
||||
@ -183,7 +184,7 @@ WAIT { return K_WAIT; }
|
||||
}
|
||||
|
||||
{identifier} {
|
||||
int len = strlen(yytext);
|
||||
int len = strlen(yytext);
|
||||
|
||||
yylval.str = downcase_truncate_identifier(yytext, len, true);
|
||||
return IDENT;
|
||||
|
@ -77,7 +77,8 @@ static JsonPathParseItem *makeItemLikeRegex(JsonPathParseItem *expr,
|
||||
%error-verbose
|
||||
%parse-param {JsonPathParseResult **result}
|
||||
|
||||
%union {
|
||||
%union
|
||||
{
|
||||
JsonPathString str;
|
||||
List *elems; /* list of JsonPathParseItem */
|
||||
List *indexs; /* list of integers */
|
||||
@ -313,7 +314,7 @@ method:
|
||||
static JsonPathParseItem *
|
||||
makeItemType(JsonPathItemType type)
|
||||
{
|
||||
JsonPathParseItem *v = palloc(sizeof(*v));
|
||||
JsonPathParseItem *v = palloc(sizeof(*v));
|
||||
|
||||
CHECK_FOR_INTERRUPTS();
|
||||
|
||||
@ -326,7 +327,7 @@ makeItemType(JsonPathItemType type)
|
||||
static JsonPathParseItem *
|
||||
makeItemString(JsonPathString *s)
|
||||
{
|
||||
JsonPathParseItem *v;
|
||||
JsonPathParseItem *v;
|
||||
|
||||
if (s == NULL)
|
||||
{
|
||||
@ -345,7 +346,7 @@ makeItemString(JsonPathString *s)
|
||||
static JsonPathParseItem *
|
||||
makeItemVariable(JsonPathString *s)
|
||||
{
|
||||
JsonPathParseItem *v;
|
||||
JsonPathParseItem *v;
|
||||
|
||||
v = makeItemType(jpiVariable);
|
||||
v->value.string.val = s->val;
|
||||
@ -357,7 +358,7 @@ makeItemVariable(JsonPathString *s)
|
||||
static JsonPathParseItem *
|
||||
makeItemKey(JsonPathString *s)
|
||||
{
|
||||
JsonPathParseItem *v;
|
||||
JsonPathParseItem *v;
|
||||
|
||||
v = makeItemString(s);
|
||||
v->type = jpiKey;
|
||||
@ -368,7 +369,7 @@ makeItemKey(JsonPathString *s)
|
||||
static JsonPathParseItem *
|
||||
makeItemNumeric(JsonPathString *s)
|
||||
{
|
||||
JsonPathParseItem *v;
|
||||
JsonPathParseItem *v;
|
||||
|
||||
v = makeItemType(jpiNumeric);
|
||||
v->value.numeric =
|
||||
@ -383,7 +384,7 @@ makeItemNumeric(JsonPathString *s)
|
||||
static JsonPathParseItem *
|
||||
makeItemBool(bool val)
|
||||
{
|
||||
JsonPathParseItem *v = makeItemType(jpiBool);
|
||||
JsonPathParseItem *v = makeItemType(jpiBool);
|
||||
|
||||
v->value.boolean = val;
|
||||
|
||||
@ -393,7 +394,7 @@ makeItemBool(bool val)
|
||||
static JsonPathParseItem *
|
||||
makeItemBinary(JsonPathItemType type, JsonPathParseItem *la, JsonPathParseItem *ra)
|
||||
{
|
||||
JsonPathParseItem *v = makeItemType(type);
|
||||
JsonPathParseItem *v = makeItemType(type);
|
||||
|
||||
v->value.args.left = la;
|
||||
v->value.args.right = ra;
|
||||
@ -404,7 +405,7 @@ makeItemBinary(JsonPathItemType type, JsonPathParseItem *la, JsonPathParseItem *
|
||||
static JsonPathParseItem *
|
||||
makeItemUnary(JsonPathItemType type, JsonPathParseItem *a)
|
||||
{
|
||||
JsonPathParseItem *v;
|
||||
JsonPathParseItem *v;
|
||||
|
||||
if (type == jpiPlus && a->type == jpiNumeric && !a->next)
|
||||
return a;
|
||||
@ -428,9 +429,9 @@ makeItemUnary(JsonPathItemType type, JsonPathParseItem *a)
|
||||
static JsonPathParseItem *
|
||||
makeItemList(List *list)
|
||||
{
|
||||
JsonPathParseItem *head,
|
||||
*end;
|
||||
ListCell *cell;
|
||||
JsonPathParseItem *head,
|
||||
*end;
|
||||
ListCell *cell;
|
||||
|
||||
head = end = (JsonPathParseItem *) linitial(list);
|
||||
|
||||
@ -455,9 +456,9 @@ makeItemList(List *list)
|
||||
static JsonPathParseItem *
|
||||
makeIndexArray(List *list)
|
||||
{
|
||||
JsonPathParseItem *v = makeItemType(jpiIndexArray);
|
||||
ListCell *cell;
|
||||
int i = 0;
|
||||
JsonPathParseItem *v = makeItemType(jpiIndexArray);
|
||||
ListCell *cell;
|
||||
int i = 0;
|
||||
|
||||
Assert(list_length(list) > 0);
|
||||
v->value.array.nelems = list_length(list);
|
||||
@ -467,7 +468,7 @@ makeIndexArray(List *list)
|
||||
|
||||
foreach(cell, list)
|
||||
{
|
||||
JsonPathParseItem *jpi = lfirst(cell);
|
||||
JsonPathParseItem *jpi = lfirst(cell);
|
||||
|
||||
Assert(jpi->type == jpiSubscript);
|
||||
|
||||
@ -481,7 +482,7 @@ makeIndexArray(List *list)
|
||||
static JsonPathParseItem *
|
||||
makeAny(int first, int last)
|
||||
{
|
||||
JsonPathParseItem *v = makeItemType(jpiAny);
|
||||
JsonPathParseItem *v = makeItemType(jpiAny);
|
||||
|
||||
v->value.anybounds.first = (first >= 0) ? first : PG_UINT32_MAX;
|
||||
v->value.anybounds.last = (last >= 0) ? last : PG_UINT32_MAX;
|
||||
@ -493,9 +494,9 @@ static JsonPathParseItem *
|
||||
makeItemLikeRegex(JsonPathParseItem *expr, JsonPathString *pattern,
|
||||
JsonPathString *flags)
|
||||
{
|
||||
JsonPathParseItem *v = makeItemType(jpiLikeRegex);
|
||||
int i;
|
||||
int cflags;
|
||||
JsonPathParseItem *v = makeItemType(jpiLikeRegex);
|
||||
int i;
|
||||
int cflags;
|
||||
|
||||
v->value.like_regex.expr = expr;
|
||||
v->value.like_regex.pattern = pattern->val;
|
||||
|
@ -332,8 +332,8 @@ static const JsonPathKeyword keywords[] = {
|
||||
static enum yytokentype
|
||||
checkKeyword()
|
||||
{
|
||||
int res = IDENT_P;
|
||||
int diff;
|
||||
int res = IDENT_P;
|
||||
int diff;
|
||||
const JsonPathKeyword *StopLow = keywords,
|
||||
*StopHigh = keywords + lengthof(keywords),
|
||||
*StopMiddle;
|
||||
|
@ -49,10 +49,10 @@ static sigjmp_buf *GUC_flex_fatal_jmp;
|
||||
static void FreeConfigVariable(ConfigVariable *item);
|
||||
|
||||
static void record_config_file_error(const char *errmsg,
|
||||
const char *config_file,
|
||||
int lineno,
|
||||
ConfigVariable **head_p,
|
||||
ConfigVariable **tail_p);
|
||||
const char *config_file,
|
||||
int lineno,
|
||||
ConfigVariable **head_p,
|
||||
ConfigVariable **tail_p);
|
||||
|
||||
static int GUC_flex_fatal(const char *msg);
|
||||
|
||||
|
@ -30,7 +30,7 @@ static PgBenchExpr *make_integer_constant(int64 ival);
|
||||
static PgBenchExpr *make_double_constant(double dval);
|
||||
static PgBenchExpr *make_variable(char *varname);
|
||||
static PgBenchExpr *make_op(yyscan_t yyscanner, const char *operator,
|
||||
PgBenchExpr *lexpr, PgBenchExpr *rexpr);
|
||||
PgBenchExpr *lexpr, PgBenchExpr *rexpr);
|
||||
static PgBenchExpr *make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr);
|
||||
static int find_func(yyscan_t yyscanner, const char *fname);
|
||||
static PgBenchExpr *make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args);
|
||||
@ -240,7 +240,7 @@ make_uop(yyscan_t yyscanner, const char *operator, PgBenchExpr *expr)
|
||||
* meaning #args >= 1;
|
||||
* - PGBENCH_NARGS_CASE is for the "CASE WHEN ..." function, which
|
||||
* has #args >= 3 and odd;
|
||||
* - PGBENCH_NARGS_HASH is for hash functions, which have one required
|
||||
* - PGBENCH_NARGS_HASH is for hash functions, which have one required
|
||||
* and one optional argument;
|
||||
* - tag: function identifier from PgBenchFunction enum
|
||||
*/
|
||||
|
@ -99,9 +99,9 @@ static short preproc_tos;
|
||||
static bool ifcond;
|
||||
static struct _if_value
|
||||
{
|
||||
bool active;
|
||||
bool saw_active;
|
||||
bool else_branch;
|
||||
bool active;
|
||||
bool saw_active;
|
||||
bool else_branch;
|
||||
} stacked_if_value[MAX_NESTED_IF];
|
||||
|
||||
%}
|
||||
@ -1031,7 +1031,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
|
||||
char* endptr;
|
||||
|
||||
errno = 0;
|
||||
base_yylval.ival = strtoul((char *)yytext,&endptr,16);
|
||||
base_yylval.ival = strtoul((char *) yytext, &endptr, 16);
|
||||
if (*endptr != '\0' || errno == ERANGE)
|
||||
{
|
||||
errno = 0;
|
||||
@ -1166,7 +1166,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
|
||||
*/
|
||||
for (i = strlen(yytext)-2;
|
||||
i > 0 && ecpg_isspace(yytext[i]);
|
||||
i-- )
|
||||
i--)
|
||||
;
|
||||
yytext[i+1] = '\0';
|
||||
|
||||
@ -1290,7 +1290,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
|
||||
}
|
||||
|
||||
<C,xskip>{exec_sql}{else}{space}*";" { /* only exec sql endif pops the stack, so take care of duplicated 'else' */
|
||||
if ( preproc_tos == 0 )
|
||||
if (preproc_tos == 0)
|
||||
mmfatal(PARSE_ERROR, "missing matching \"EXEC SQL IFDEF\" / \"EXEC SQL IFNDEF\"");
|
||||
else if (stacked_if_value[preproc_tos].else_branch)
|
||||
mmfatal(PARSE_ERROR, "more than one EXEC SQL ELSE");
|
||||
@ -1312,7 +1312,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
|
||||
/* are we simulating Informix? */
|
||||
if (INFORMIX_MODE)
|
||||
{
|
||||
if ( preproc_tos == 0 )
|
||||
if (preproc_tos == 0)
|
||||
mmfatal(PARSE_ERROR, "missing matching \"EXEC SQL IFDEF\" / \"EXEC SQL IFNDEF\"");
|
||||
else if (stacked_if_value[preproc_tos].else_branch)
|
||||
mmfatal(PARSE_ERROR, "more than one EXEC SQL ELSE");
|
||||
@ -1382,7 +1382,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
|
||||
*/
|
||||
for (i = strlen(yytext)-2;
|
||||
i > 0 && ecpg_isspace(yytext[i]);
|
||||
i-- )
|
||||
i--)
|
||||
;
|
||||
yytext[i+1] = '\0';
|
||||
|
||||
@ -1456,7 +1456,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
|
||||
<<EOF>> {
|
||||
if (yy_buffer == NULL)
|
||||
{
|
||||
if ( preproc_tos > 0 )
|
||||
if (preproc_tos > 0)
|
||||
{
|
||||
preproc_tos = 0;
|
||||
mmfatal(PARSE_ERROR, "missing \"EXEC SQL ENDIF;\"");
|
||||
@ -1479,7 +1479,7 @@ cppline {space}*#([^i][A-Za-z]*|{if}|{ifdef}|{ifndef}|{import})((\/\*[^*/]*\*+
|
||||
if (yyin != NULL)
|
||||
fclose(yyin);
|
||||
|
||||
yy_delete_buffer( YY_CURRENT_BUFFER );
|
||||
yy_delete_buffer(YY_CURRENT_BUFFER);
|
||||
yy_switch_to_buffer(yy_buffer->buffer);
|
||||
|
||||
yylineno = yy_buffer->lineno;
|
||||
@ -1661,7 +1661,7 @@ parse_include(void)
|
||||
if (strcmp(inc_file + strlen(inc_file) - 2, ".h") != 0)
|
||||
{
|
||||
strcat(inc_file, ".h");
|
||||
yyin = fopen( inc_file, "r" );
|
||||
yyin = fopen(inc_file, "r");
|
||||
}
|
||||
}
|
||||
/* if the command was "include_next" we have to disregard the first hit */
|
||||
@ -1677,7 +1677,7 @@ parse_include(void)
|
||||
mmfatal(NO_INCLUDE_FILE, "could not open include file \"%s\" on line %d", yytext, yylineno);
|
||||
|
||||
input_filename = mm_strdup(inc_file);
|
||||
yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE ));
|
||||
yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE));
|
||||
yylineno = 1;
|
||||
output_line_number();
|
||||
|
||||
|
@ -116,55 +116,56 @@ static void check_raise_parameters(PLpgSQL_stmt_raise *stmt);
|
||||
%name-prefix="plpgsql_yy"
|
||||
%locations
|
||||
|
||||
%union {
|
||||
core_YYSTYPE core_yystype;
|
||||
/* these fields must match core_YYSTYPE: */
|
||||
int ival;
|
||||
char *str;
|
||||
const char *keyword;
|
||||
%union
|
||||
{
|
||||
core_YYSTYPE core_yystype;
|
||||
/* these fields must match 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;
|
||||
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;
|
||||
}
|
||||
|
||||
%type <declhdr> decl_sect
|
||||
@ -425,7 +426,7 @@ pl_block : decl_sect K_BEGIN proc_sect exception_sect K_END opt_label
|
||||
check_labels($1.label, $6, @6);
|
||||
plpgsql_ns_pop();
|
||||
|
||||
$$ = (PLpgSQL_stmt *)new;
|
||||
$$ = (PLpgSQL_stmt *) new;
|
||||
}
|
||||
;
|
||||
|
||||
@ -538,8 +539,8 @@ decl_statement : decl_varname decl_const decl_datatype decl_collate decl_notnull
|
||||
PLpgSQL_var *new;
|
||||
PLpgSQL_expr *curname_def;
|
||||
char buf[NAMEDATALEN * 2 + 64];
|
||||
char *cp1;
|
||||
char *cp2;
|
||||
char *cp1;
|
||||
char *cp2;
|
||||
|
||||
/* pop local namespace for cursor args */
|
||||
plpgsql_ns_pop();
|
||||
@ -611,8 +612,8 @@ decl_cursor_args :
|
||||
| '(' decl_cursor_arglist ')'
|
||||
{
|
||||
PLpgSQL_row *new;
|
||||
int i;
|
||||
ListCell *l;
|
||||
int i;
|
||||
ListCell *l;
|
||||
|
||||
new = palloc0(sizeof(PLpgSQL_row));
|
||||
new->dtype = PLPGSQL_DTYPE_ROW;
|
||||
@ -903,7 +904,7 @@ proc_stmt : pl_block ';'
|
||||
stmt_perform : K_PERFORM
|
||||
{
|
||||
PLpgSQL_stmt_perform *new;
|
||||
int startloc;
|
||||
int startloc;
|
||||
|
||||
new = palloc0(sizeof(PLpgSQL_stmt_perform));
|
||||
new->cmd_type = PLPGSQL_STMT_PERFORM;
|
||||
@ -932,7 +933,7 @@ stmt_perform : K_PERFORM
|
||||
check_sql_expr(new->expr->query, new->expr->parseMode,
|
||||
startloc + 1);
|
||||
|
||||
$$ = (PLpgSQL_stmt *)new;
|
||||
$$ = (PLpgSQL_stmt *) new;
|
||||
}
|
||||
;
|
||||
|
||||
@ -951,7 +952,7 @@ stmt_call : K_CALL
|
||||
/* Remember we may need a procedure resource owner */
|
||||
plpgsql_curr_compile->requires_procedure_resowner = true;
|
||||
|
||||
$$ = (PLpgSQL_stmt *)new;
|
||||
$$ = (PLpgSQL_stmt *) new;
|
||||
|
||||
}
|
||||
| K_DO
|
||||
@ -970,7 +971,7 @@ stmt_call : K_CALL
|
||||
/* Remember we may need a procedure resource owner */
|
||||
plpgsql_curr_compile->requires_procedure_resowner = true;
|
||||
|
||||
$$ = (PLpgSQL_stmt *)new;
|
||||
$$ = (PLpgSQL_stmt *) new;
|
||||
|
||||
}
|
||||
;
|
||||
@ -1000,7 +1001,7 @@ stmt_assign : T_DATUM
|
||||
check_assignable($1.datum, @1);
|
||||
new = palloc0(sizeof(PLpgSQL_stmt_assign));
|
||||
new->cmd_type = PLPGSQL_STMT_ASSIGN;
|
||||
new->lineno = plpgsql_location_to_lineno(@1);
|
||||
new->lineno = plpgsql_location_to_lineno(@1);
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->varno = $1.datum->dno;
|
||||
/* Push back the head name to include it in the stmt */
|
||||
@ -1010,19 +1011,19 @@ stmt_assign : T_DATUM
|
||||
false, true, true,
|
||||
NULL, NULL);
|
||||
|
||||
$$ = (PLpgSQL_stmt *)new;
|
||||
$$ = (PLpgSQL_stmt *) new;
|
||||
}
|
||||
;
|
||||
|
||||
stmt_getdiag : K_GET getdiag_area_opt K_DIAGNOSTICS getdiag_list ';'
|
||||
{
|
||||
PLpgSQL_stmt_getdiag *new;
|
||||
ListCell *lc;
|
||||
PLpgSQL_stmt_getdiag *new;
|
||||
ListCell *lc;
|
||||
|
||||
new = palloc0(sizeof(PLpgSQL_stmt_getdiag));
|
||||
new->cmd_type = PLPGSQL_STMT_GETDIAG;
|
||||
new->lineno = plpgsql_location_to_lineno(@1);
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->lineno = plpgsql_location_to_lineno(@1);
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->is_stacked = $2;
|
||||
new->diag_items = $4;
|
||||
|
||||
@ -1072,7 +1073,7 @@ stmt_getdiag : K_GET getdiag_area_opt K_DIAGNOSTICS getdiag_list ';'
|
||||
}
|
||||
}
|
||||
|
||||
$$ = (PLpgSQL_stmt *)new;
|
||||
$$ = (PLpgSQL_stmt *) new;
|
||||
}
|
||||
;
|
||||
|
||||
@ -1114,7 +1115,7 @@ getdiag_list_item : getdiag_target assign_operator getdiag_item
|
||||
|
||||
getdiag_item :
|
||||
{
|
||||
int tok = yylex();
|
||||
int tok = yylex();
|
||||
|
||||
if (tok_is_keyword(tok, &yylval,
|
||||
K_ROW_COUNT, "row_count"))
|
||||
@ -1192,15 +1193,15 @@ stmt_if : K_IF expr_until_then proc_sect stmt_elsifs stmt_else K_END K_IF ';'
|
||||
PLpgSQL_stmt_if *new;
|
||||
|
||||
new = palloc0(sizeof(PLpgSQL_stmt_if));
|
||||
new->cmd_type = PLPGSQL_STMT_IF;
|
||||
new->lineno = plpgsql_location_to_lineno(@1);
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->cond = $2;
|
||||
new->then_body = $3;
|
||||
new->cmd_type = PLPGSQL_STMT_IF;
|
||||
new->lineno = plpgsql_location_to_lineno(@1);
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->cond = $2;
|
||||
new->then_body = $3;
|
||||
new->elsif_list = $4;
|
||||
new->else_body = $5;
|
||||
new->else_body = $5;
|
||||
|
||||
$$ = (PLpgSQL_stmt *)new;
|
||||
$$ = (PLpgSQL_stmt *) new;
|
||||
}
|
||||
;
|
||||
|
||||
@ -1214,8 +1215,8 @@ stmt_elsifs :
|
||||
|
||||
new = palloc0(sizeof(PLpgSQL_if_elsif));
|
||||
new->lineno = plpgsql_location_to_lineno(@2);
|
||||
new->cond = $3;
|
||||
new->stmts = $4;
|
||||
new->cond = $3;
|
||||
new->stmts = $4;
|
||||
|
||||
$$ = lappend($1, new);
|
||||
}
|
||||
@ -1240,7 +1241,7 @@ stmt_case : K_CASE opt_expr_until_when case_when_list opt_case_else K_END K_CAS
|
||||
opt_expr_until_when :
|
||||
{
|
||||
PLpgSQL_expr *expr = NULL;
|
||||
int tok = yylex();
|
||||
int tok = yylex();
|
||||
|
||||
if (tok != K_WHEN)
|
||||
{
|
||||
@ -1267,8 +1268,8 @@ case_when : K_WHEN expr_until_then proc_sect
|
||||
PLpgSQL_case_when *new = palloc(sizeof(PLpgSQL_case_when));
|
||||
|
||||
new->lineno = plpgsql_location_to_lineno(@1);
|
||||
new->expr = $2;
|
||||
new->stmts = $3;
|
||||
new->expr = $2;
|
||||
new->stmts = $3;
|
||||
$$ = new;
|
||||
}
|
||||
;
|
||||
@ -1298,15 +1299,15 @@ stmt_loop : opt_loop_label K_LOOP loop_body
|
||||
|
||||
new = palloc0(sizeof(PLpgSQL_stmt_loop));
|
||||
new->cmd_type = PLPGSQL_STMT_LOOP;
|
||||
new->lineno = plpgsql_location_to_lineno(@2);
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->label = $1;
|
||||
new->body = $3.stmts;
|
||||
new->lineno = plpgsql_location_to_lineno(@2);
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->label = $1;
|
||||
new->body = $3.stmts;
|
||||
|
||||
check_labels($1, $3.end_label, $3.end_label_location);
|
||||
plpgsql_ns_pop();
|
||||
|
||||
$$ = (PLpgSQL_stmt *)new;
|
||||
$$ = (PLpgSQL_stmt *) new;
|
||||
}
|
||||
;
|
||||
|
||||
@ -1316,16 +1317,16 @@ stmt_while : opt_loop_label K_WHILE expr_until_loop loop_body
|
||||
|
||||
new = palloc0(sizeof(PLpgSQL_stmt_while));
|
||||
new->cmd_type = PLPGSQL_STMT_WHILE;
|
||||
new->lineno = plpgsql_location_to_lineno(@2);
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->label = $1;
|
||||
new->cond = $3;
|
||||
new->body = $4.stmts;
|
||||
new->lineno = plpgsql_location_to_lineno(@2);
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->label = $1;
|
||||
new->cond = $3;
|
||||
new->body = $4.stmts;
|
||||
|
||||
check_labels($1, $4.end_label, $4.end_label_location);
|
||||
plpgsql_ns_pop();
|
||||
|
||||
$$ = (PLpgSQL_stmt *)new;
|
||||
$$ = (PLpgSQL_stmt *) new;
|
||||
}
|
||||
;
|
||||
|
||||
@ -1334,26 +1335,26 @@ stmt_for : opt_loop_label K_FOR for_control loop_body
|
||||
/* This runs after we've scanned the loop body */
|
||||
if ($3->cmd_type == PLPGSQL_STMT_FORI)
|
||||
{
|
||||
PLpgSQL_stmt_fori *new;
|
||||
PLpgSQL_stmt_fori *new;
|
||||
|
||||
new = (PLpgSQL_stmt_fori *) $3;
|
||||
new->lineno = plpgsql_location_to_lineno(@2);
|
||||
new->label = $1;
|
||||
new->body = $4.stmts;
|
||||
new->lineno = plpgsql_location_to_lineno(@2);
|
||||
new->label = $1;
|
||||
new->body = $4.stmts;
|
||||
$$ = (PLpgSQL_stmt *) new;
|
||||
}
|
||||
else
|
||||
{
|
||||
PLpgSQL_stmt_forq *new;
|
||||
PLpgSQL_stmt_forq *new;
|
||||
|
||||
Assert($3->cmd_type == PLPGSQL_STMT_FORS ||
|
||||
$3->cmd_type == PLPGSQL_STMT_FORC ||
|
||||
$3->cmd_type == PLPGSQL_STMT_DYNFORS);
|
||||
/* forq is the common supertype of all three */
|
||||
new = (PLpgSQL_stmt_forq *) $3;
|
||||
new->lineno = plpgsql_location_to_lineno(@2);
|
||||
new->label = $1;
|
||||
new->body = $4.stmts;
|
||||
new->lineno = plpgsql_location_to_lineno(@2);
|
||||
new->label = $1;
|
||||
new->body = $4.stmts;
|
||||
$$ = (PLpgSQL_stmt *) new;
|
||||
}
|
||||
|
||||
@ -1371,9 +1372,9 @@ for_control : for_variable K_IN
|
||||
if (tok == K_EXECUTE)
|
||||
{
|
||||
/* EXECUTE means it's a dynamic FOR loop */
|
||||
PLpgSQL_stmt_dynfors *new;
|
||||
PLpgSQL_expr *expr;
|
||||
int term;
|
||||
PLpgSQL_stmt_dynfors *new;
|
||||
PLpgSQL_expr *expr;
|
||||
int term;
|
||||
|
||||
expr = read_sql_expression2(K_LOOP, K_USING,
|
||||
"LOOP or USING",
|
||||
@ -1381,7 +1382,7 @@ for_control : for_variable K_IN
|
||||
|
||||
new = palloc0(sizeof(PLpgSQL_stmt_dynfors));
|
||||
new->cmd_type = PLPGSQL_STMT_DYNFORS;
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
if ($1.row)
|
||||
{
|
||||
new->var = (PLpgSQL_variable *) $1.row;
|
||||
@ -1422,8 +1423,8 @@ for_control : for_variable K_IN
|
||||
((PLpgSQL_var *) yylval.wdatum.datum)->datatype->typoid == REFCURSOROID)
|
||||
{
|
||||
/* It's FOR var IN cursor */
|
||||
PLpgSQL_stmt_forc *new;
|
||||
PLpgSQL_var *cursor = (PLpgSQL_var *) yylval.wdatum.datum;
|
||||
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;
|
||||
@ -1460,9 +1461,9 @@ for_control : for_variable K_IN
|
||||
}
|
||||
else
|
||||
{
|
||||
PLpgSQL_expr *expr1;
|
||||
int expr1loc;
|
||||
bool reverse = false;
|
||||
PLpgSQL_expr *expr1;
|
||||
int expr1loc;
|
||||
bool reverse = false;
|
||||
|
||||
/*
|
||||
* We have to distinguish between two
|
||||
@ -1503,10 +1504,10 @@ for_control : for_variable K_IN
|
||||
if (tok == DOT_DOT)
|
||||
{
|
||||
/* Saw "..", so it must be an integer loop */
|
||||
PLpgSQL_expr *expr2;
|
||||
PLpgSQL_expr *expr_by;
|
||||
PLpgSQL_var *fvar;
|
||||
PLpgSQL_stmt_fori *new;
|
||||
PLpgSQL_expr *expr2;
|
||||
PLpgSQL_expr *expr_by;
|
||||
PLpgSQL_var *fvar;
|
||||
PLpgSQL_stmt_fori *new;
|
||||
|
||||
/*
|
||||
* Relabel first expression as an expression;
|
||||
@ -1547,12 +1548,12 @@ for_control : for_variable K_IN
|
||||
|
||||
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;
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->var = fvar;
|
||||
new->reverse = reverse;
|
||||
new->lower = expr1;
|
||||
new->upper = expr2;
|
||||
new->step = expr_by;
|
||||
|
||||
$$ = (PLpgSQL_stmt *) new;
|
||||
}
|
||||
@ -1561,7 +1562,7 @@ for_control : for_variable K_IN
|
||||
/*
|
||||
* No "..", so it must be a query loop.
|
||||
*/
|
||||
PLpgSQL_stmt_fors *new;
|
||||
PLpgSQL_stmt_fors *new;
|
||||
|
||||
if (reverse)
|
||||
ereport(ERROR,
|
||||
@ -1723,11 +1724,11 @@ stmt_exit : exit_type opt_label opt_exitcond
|
||||
|
||||
new = palloc0(sizeof(PLpgSQL_stmt_exit));
|
||||
new->cmd_type = PLPGSQL_STMT_EXIT;
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->is_exit = $1;
|
||||
new->lineno = plpgsql_location_to_lineno(@1);
|
||||
new->label = $2;
|
||||
new->cond = $3;
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->is_exit = $1;
|
||||
new->lineno = plpgsql_location_to_lineno(@1);
|
||||
new->label = $2;
|
||||
new->cond = $3;
|
||||
|
||||
if ($2)
|
||||
{
|
||||
@ -1766,7 +1767,7 @@ stmt_exit : exit_type opt_label opt_exitcond
|
||||
parser_errposition(@1)));
|
||||
}
|
||||
|
||||
$$ = (PLpgSQL_stmt *)new;
|
||||
$$ = (PLpgSQL_stmt *) new;
|
||||
}
|
||||
;
|
||||
|
||||
@ -1782,7 +1783,7 @@ exit_type : K_EXIT
|
||||
|
||||
stmt_return : K_RETURN
|
||||
{
|
||||
int tok;
|
||||
int tok;
|
||||
|
||||
tok = yylex();
|
||||
if (tok == 0)
|
||||
@ -1808,19 +1809,19 @@ stmt_return : K_RETURN
|
||||
|
||||
stmt_raise : K_RAISE
|
||||
{
|
||||
PLpgSQL_stmt_raise *new;
|
||||
int tok;
|
||||
PLpgSQL_stmt_raise *new;
|
||||
int tok;
|
||||
|
||||
new = palloc(sizeof(PLpgSQL_stmt_raise));
|
||||
|
||||
new->cmd_type = PLPGSQL_STMT_RAISE;
|
||||
new->lineno = plpgsql_location_to_lineno(@1);
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->cmd_type = PLPGSQL_STMT_RAISE;
|
||||
new->lineno = plpgsql_location_to_lineno(@1);
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->elog_level = ERROR; /* default */
|
||||
new->condname = NULL;
|
||||
new->message = NULL;
|
||||
new->params = NIL;
|
||||
new->options = NIL;
|
||||
new->condname = NULL;
|
||||
new->message = NULL;
|
||||
new->params = NIL;
|
||||
new->options = NIL;
|
||||
|
||||
tok = yylex();
|
||||
if (tok == 0)
|
||||
@ -1913,7 +1914,7 @@ stmt_raise : K_RAISE
|
||||
K_SQLSTATE, "sqlstate"))
|
||||
{
|
||||
/* next token should be a string literal */
|
||||
char *sqlstatestr;
|
||||
char *sqlstatestr;
|
||||
|
||||
if (yylex() != SCONST)
|
||||
yyerror("syntax error");
|
||||
@ -1947,20 +1948,20 @@ stmt_raise : K_RAISE
|
||||
|
||||
check_raise_parameters(new);
|
||||
|
||||
$$ = (PLpgSQL_stmt *)new;
|
||||
$$ = (PLpgSQL_stmt *) new;
|
||||
}
|
||||
;
|
||||
|
||||
stmt_assert : K_ASSERT
|
||||
{
|
||||
PLpgSQL_stmt_assert *new;
|
||||
int tok;
|
||||
PLpgSQL_stmt_assert *new;
|
||||
int tok;
|
||||
|
||||
new = palloc(sizeof(PLpgSQL_stmt_assert));
|
||||
|
||||
new->cmd_type = PLPGSQL_STMT_ASSERT;
|
||||
new->lineno = plpgsql_location_to_lineno(@1);
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->cmd_type = PLPGSQL_STMT_ASSERT;
|
||||
new->lineno = plpgsql_location_to_lineno(@1);
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
|
||||
new->cond = read_sql_expression2(',', ';',
|
||||
", or ;",
|
||||
@ -2033,7 +2034,7 @@ stmt_dynexecute : K_EXECUTE
|
||||
{
|
||||
PLpgSQL_stmt_dynexecute *new;
|
||||
PLpgSQL_expr *expr;
|
||||
int endtoken;
|
||||
int endtoken;
|
||||
|
||||
expr = read_sql_construct(K_INTO, K_USING, ';',
|
||||
"INTO or USING or ;",
|
||||
@ -2088,7 +2089,7 @@ stmt_dynexecute : K_EXECUTE
|
||||
yyerror("syntax error");
|
||||
}
|
||||
|
||||
$$ = (PLpgSQL_stmt *)new;
|
||||
$$ = (PLpgSQL_stmt *) new;
|
||||
}
|
||||
;
|
||||
|
||||
@ -2096,7 +2097,7 @@ stmt_dynexecute : K_EXECUTE
|
||||
stmt_open : K_OPEN cursor_variable
|
||||
{
|
||||
PLpgSQL_stmt_open *new;
|
||||
int tok;
|
||||
int tok;
|
||||
|
||||
new = palloc0(sizeof(PLpgSQL_stmt_open));
|
||||
new->cmd_type = PLPGSQL_STMT_OPEN;
|
||||
@ -2133,7 +2134,7 @@ stmt_open : K_OPEN cursor_variable
|
||||
tok = yylex();
|
||||
if (tok == K_EXECUTE)
|
||||
{
|
||||
int endtoken;
|
||||
int endtoken;
|
||||
|
||||
new->dynquery =
|
||||
read_sql_expression2(K_USING, ';',
|
||||
@ -2167,7 +2168,7 @@ stmt_open : K_OPEN cursor_variable
|
||||
new->argquery = read_cursor_args($2, ';');
|
||||
}
|
||||
|
||||
$$ = (PLpgSQL_stmt *)new;
|
||||
$$ = (PLpgSQL_stmt *) new;
|
||||
}
|
||||
;
|
||||
|
||||
@ -2197,7 +2198,7 @@ stmt_fetch : K_FETCH opt_fetch_direction cursor_variable K_INTO
|
||||
fetch->curvar = $3->dno;
|
||||
fetch->is_move = false;
|
||||
|
||||
$$ = (PLpgSQL_stmt *)fetch;
|
||||
$$ = (PLpgSQL_stmt *) fetch;
|
||||
}
|
||||
;
|
||||
|
||||
@ -2206,10 +2207,10 @@ stmt_move : K_MOVE opt_fetch_direction cursor_variable ';'
|
||||
PLpgSQL_stmt_fetch *fetch = $2;
|
||||
|
||||
fetch->lineno = plpgsql_location_to_lineno(@1);
|
||||
fetch->curvar = $3->dno;
|
||||
fetch->is_move = true;
|
||||
fetch->curvar = $3->dno;
|
||||
fetch->is_move = true;
|
||||
|
||||
$$ = (PLpgSQL_stmt *)fetch;
|
||||
$$ = (PLpgSQL_stmt *) fetch;
|
||||
}
|
||||
;
|
||||
|
||||
@ -2229,7 +2230,7 @@ stmt_close : K_CLOSE cursor_variable ';'
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->curvar = $2->dno;
|
||||
|
||||
$$ = (PLpgSQL_stmt *)new;
|
||||
$$ = (PLpgSQL_stmt *) new;
|
||||
}
|
||||
;
|
||||
|
||||
@ -2250,7 +2251,7 @@ stmt_commit : K_COMMIT opt_transaction_chain ';'
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->chain = $2;
|
||||
|
||||
$$ = (PLpgSQL_stmt *)new;
|
||||
$$ = (PLpgSQL_stmt *) new;
|
||||
}
|
||||
;
|
||||
|
||||
@ -2264,7 +2265,7 @@ stmt_rollback : K_ROLLBACK opt_transaction_chain ';'
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->chain = $2;
|
||||
|
||||
$$ = (PLpgSQL_stmt *)new;
|
||||
$$ = (PLpgSQL_stmt *) new;
|
||||
}
|
||||
;
|
||||
|
||||
@ -2710,12 +2711,12 @@ read_sql_construct(int until,
|
||||
int *startloc,
|
||||
int *endtoken)
|
||||
{
|
||||
int tok;
|
||||
StringInfoData ds;
|
||||
IdentifierLookup save_IdentifierLookup;
|
||||
int startlocation = -1;
|
||||
int parenlevel = 0;
|
||||
PLpgSQL_expr *expr;
|
||||
int tok;
|
||||
StringInfoData ds;
|
||||
IdentifierLookup save_IdentifierLookup;
|
||||
int startlocation = -1;
|
||||
int parenlevel = 0;
|
||||
PLpgSQL_expr *expr;
|
||||
|
||||
initStringInfo(&ds);
|
||||
|
||||
@ -2792,12 +2793,12 @@ read_sql_construct(int until,
|
||||
}
|
||||
|
||||
expr = palloc0(sizeof(PLpgSQL_expr));
|
||||
expr->query = pstrdup(ds.data);
|
||||
expr->parseMode = parsemode;
|
||||
expr->plan = NULL;
|
||||
expr->paramnos = NULL;
|
||||
expr->target_param = -1;
|
||||
expr->ns = plpgsql_ns_top();
|
||||
expr->query = pstrdup(ds.data);
|
||||
expr->parseMode = parsemode;
|
||||
expr->plan = NULL;
|
||||
expr->paramnos = NULL;
|
||||
expr->target_param = -1;
|
||||
expr->ns = plpgsql_ns_top();
|
||||
pfree(ds.data);
|
||||
|
||||
if (valid_sql)
|
||||
@ -2809,11 +2810,11 @@ read_sql_construct(int until,
|
||||
static PLpgSQL_type *
|
||||
read_datatype(int tok)
|
||||
{
|
||||
StringInfoData ds;
|
||||
char *type_name;
|
||||
int startlocation;
|
||||
PLpgSQL_type *result;
|
||||
int parenlevel = 0;
|
||||
StringInfoData ds;
|
||||
char *type_name;
|
||||
int startlocation;
|
||||
PLpgSQL_type *result;
|
||||
int parenlevel = 0;
|
||||
|
||||
/* Should only be called while parsing DECLARE sections */
|
||||
Assert(plpgsql_IdentifierLookup == IDENTIFIER_LOOKUP_DECLARE);
|
||||
@ -2830,7 +2831,7 @@ read_datatype(int tok)
|
||||
*/
|
||||
if (tok == T_WORD)
|
||||
{
|
||||
char *dtname = yylval.word.ident;
|
||||
char *dtname = yylval.word.ident;
|
||||
|
||||
tok = yylex();
|
||||
if (tok == '%')
|
||||
@ -2854,7 +2855,7 @@ read_datatype(int tok)
|
||||
}
|
||||
else if (plpgsql_token_is_unreserved_keyword(tok))
|
||||
{
|
||||
char *dtname = pstrdup(yylval.keyword);
|
||||
char *dtname = pstrdup(yylval.keyword);
|
||||
|
||||
tok = yylex();
|
||||
if (tok == '%')
|
||||
@ -2878,7 +2879,7 @@ read_datatype(int tok)
|
||||
}
|
||||
else if (tok == T_CWORD)
|
||||
{
|
||||
List *dtnames = yylval.cword.idents;
|
||||
List *dtnames = yylval.cword.idents;
|
||||
|
||||
tok = yylex();
|
||||
if (tok == '%')
|
||||
@ -2945,17 +2946,17 @@ read_datatype(int tok)
|
||||
static PLpgSQL_stmt *
|
||||
make_execsql_stmt(int firsttoken, int location)
|
||||
{
|
||||
StringInfoData ds;
|
||||
IdentifierLookup save_IdentifierLookup;
|
||||
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;
|
||||
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;
|
||||
|
||||
initStringInfo(&ds);
|
||||
|
||||
@ -3041,24 +3042,24 @@ make_execsql_stmt(int firsttoken, int location)
|
||||
ds.data[--ds.len] = '\0';
|
||||
|
||||
expr = palloc0(sizeof(PLpgSQL_expr));
|
||||
expr->query = pstrdup(ds.data);
|
||||
expr->parseMode = RAW_PARSE_DEFAULT;
|
||||
expr->plan = NULL;
|
||||
expr->paramnos = NULL;
|
||||
expr->target_param = -1;
|
||||
expr->ns = plpgsql_ns_top();
|
||||
expr->query = pstrdup(ds.data);
|
||||
expr->parseMode = RAW_PARSE_DEFAULT;
|
||||
expr->plan = NULL;
|
||||
expr->paramnos = NULL;
|
||||
expr->target_param = -1;
|
||||
expr->ns = plpgsql_ns_top();
|
||||
pfree(ds.data);
|
||||
|
||||
check_sql_expr(expr->query, expr->parseMode, location);
|
||||
|
||||
execsql = palloc0(sizeof(PLpgSQL_stmt_execsql));
|
||||
execsql->cmd_type = PLPGSQL_STMT_EXECSQL;
|
||||
execsql->lineno = plpgsql_location_to_lineno(location);
|
||||
execsql->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
execsql->lineno = plpgsql_location_to_lineno(location);
|
||||
execsql->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
execsql->sqlstmt = expr;
|
||||
execsql->into = have_into;
|
||||
execsql->strict = have_strict;
|
||||
execsql->target = target;
|
||||
execsql->into = have_into;
|
||||
execsql->strict = have_strict;
|
||||
execsql->target = target;
|
||||
|
||||
return (PLpgSQL_stmt *) execsql;
|
||||
}
|
||||
@ -3080,11 +3081,11 @@ read_fetch_direction(void)
|
||||
*/
|
||||
fetch = (PLpgSQL_stmt_fetch *) palloc0(sizeof(PLpgSQL_stmt_fetch));
|
||||
fetch->cmd_type = PLPGSQL_STMT_FETCH;
|
||||
fetch->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
fetch->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
/* set direction defaults: */
|
||||
fetch->direction = FETCH_FORWARD;
|
||||
fetch->how_many = 1;
|
||||
fetch->expr = NULL;
|
||||
fetch->how_many = 1;
|
||||
fetch->expr = NULL;
|
||||
fetch->returns_multiple_rows = false;
|
||||
|
||||
tok = yylex();
|
||||
@ -3232,9 +3233,9 @@ make_return_stmt(int location)
|
||||
|
||||
new = palloc0(sizeof(PLpgSQL_stmt_return));
|
||||
new->cmd_type = PLPGSQL_STMT_RETURN;
|
||||
new->lineno = plpgsql_location_to_lineno(location);
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->expr = NULL;
|
||||
new->lineno = plpgsql_location_to_lineno(location);
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->expr = NULL;
|
||||
new->retvarno = -1;
|
||||
|
||||
if (plpgsql_curr_compile->fn_retset)
|
||||
@ -3277,7 +3278,7 @@ make_return_stmt(int location)
|
||||
* We want to special-case simple variable references for efficiency.
|
||||
* So peek ahead to see if that's what we have.
|
||||
*/
|
||||
int tok = yylex();
|
||||
int tok = yylex();
|
||||
|
||||
if (tok == T_DATUM && plpgsql_peek() == ';' &&
|
||||
(yylval.wdatum.datum->dtype == PLPGSQL_DTYPE_VAR ||
|
||||
@ -3319,11 +3320,11 @@ make_return_next_stmt(int location)
|
||||
parser_errposition(location)));
|
||||
|
||||
new = palloc0(sizeof(PLpgSQL_stmt_return_next));
|
||||
new->cmd_type = PLPGSQL_STMT_RETURN_NEXT;
|
||||
new->lineno = plpgsql_location_to_lineno(location);
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->expr = NULL;
|
||||
new->retvarno = -1;
|
||||
new->cmd_type = PLPGSQL_STMT_RETURN_NEXT;
|
||||
new->lineno = plpgsql_location_to_lineno(location);
|
||||
new->stmtid = ++plpgsql_curr_compile->nstatements;
|
||||
new->expr = NULL;
|
||||
new->retvarno = -1;
|
||||
|
||||
if (plpgsql_curr_compile->out_param_varno >= 0)
|
||||
{
|
||||
@ -3340,7 +3341,7 @@ make_return_next_stmt(int location)
|
||||
* We want to special-case simple variable references for efficiency.
|
||||
* So peek ahead to see if that's what we have.
|
||||
*/
|
||||
int tok = yylex();
|
||||
int tok = yylex();
|
||||
|
||||
if (tok == T_DATUM && plpgsql_peek() == ';' &&
|
||||
(yylval.wdatum.datum->dtype == PLPGSQL_DTYPE_VAR ||
|
||||
@ -3397,7 +3398,7 @@ make_return_query_stmt(int location)
|
||||
else
|
||||
{
|
||||
/* dynamic SQL */
|
||||
int term;
|
||||
int term;
|
||||
|
||||
new->dynquery = read_sql_expression2(';', K_USING, "; or USING",
|
||||
&term);
|
||||
@ -3525,16 +3526,16 @@ read_into_scalar_list(char *initial_name,
|
||||
PLpgSQL_datum *initial_datum,
|
||||
int initial_location)
|
||||
{
|
||||
int nfields;
|
||||
char *fieldnames[1024];
|
||||
int varnos[1024];
|
||||
PLpgSQL_row *row;
|
||||
int tok;
|
||||
int nfields;
|
||||
char *fieldnames[1024];
|
||||
int varnos[1024];
|
||||
PLpgSQL_row *row;
|
||||
int tok;
|
||||
|
||||
check_assignable(initial_datum, initial_location);
|
||||
fieldnames[0] = initial_name;
|
||||
varnos[0] = initial_datum->dno;
|
||||
nfields = 1;
|
||||
varnos[0] = initial_datum->dno;
|
||||
nfields = 1;
|
||||
|
||||
while ((tok = yylex()) == ',')
|
||||
{
|
||||
@ -3587,7 +3588,7 @@ read_into_scalar_list(char *initial_name,
|
||||
row->varnos[nfields] = varnos[nfields];
|
||||
}
|
||||
|
||||
plpgsql_adddatum((PLpgSQL_datum *)row);
|
||||
plpgsql_adddatum((PLpgSQL_datum *) row);
|
||||
|
||||
return row;
|
||||
}
|
||||
@ -3604,7 +3605,7 @@ make_scalar_list1(char *initial_name,
|
||||
PLpgSQL_datum *initial_datum,
|
||||
int lineno, int location)
|
||||
{
|
||||
PLpgSQL_row *row;
|
||||
PLpgSQL_row *row;
|
||||
|
||||
check_assignable(initial_datum, location);
|
||||
|
||||
@ -3619,7 +3620,7 @@ make_scalar_list1(char *initial_name,
|
||||
row->fieldnames[0] = initial_name;
|
||||
row->varnos[0] = initial_datum->dno;
|
||||
|
||||
plpgsql_adddatum((PLpgSQL_datum *)row);
|
||||
plpgsql_adddatum((PLpgSQL_datum *) row);
|
||||
|
||||
return row;
|
||||
}
|
||||
@ -3691,7 +3692,7 @@ plpgsql_sql_error_callback(void *arg)
|
||||
errpos = geterrposition();
|
||||
if (errpos > 0)
|
||||
{
|
||||
int myerrpos = getinternalerrposition();
|
||||
int myerrpos = getinternalerrposition();
|
||||
|
||||
if (myerrpos > 0) /* safety check */
|
||||
internalerrposition(myerrpos + errpos - 1);
|
||||
@ -3818,11 +3819,11 @@ read_cursor_args(PLpgSQL_var *cursor, int until)
|
||||
for (argc = 0; argc < row->nfields; argc++)
|
||||
{
|
||||
PLpgSQL_expr *item;
|
||||
int endtoken;
|
||||
int argpos;
|
||||
int tok1,
|
||||
tok2;
|
||||
int arglocation;
|
||||
int endtoken;
|
||||
int argpos;
|
||||
int tok1,
|
||||
tok2;
|
||||
int arglocation;
|
||||
|
||||
/* Check if it's a named parameter: "param := value" */
|
||||
plpgsql_peek2(&tok1, &tok2, &arglocation, NULL);
|
||||
@ -3923,12 +3924,12 @@ read_cursor_args(PLpgSQL_var *cursor, int until)
|
||||
}
|
||||
|
||||
expr = palloc0(sizeof(PLpgSQL_expr));
|
||||
expr->query = pstrdup(ds.data);
|
||||
expr->parseMode = RAW_PARSE_PLPGSQL_EXPR;
|
||||
expr->plan = NULL;
|
||||
expr->paramnos = NULL;
|
||||
expr->target_param = -1;
|
||||
expr->ns = plpgsql_ns_top();
|
||||
expr->query = pstrdup(ds.data);
|
||||
expr->parseMode = RAW_PARSE_PLPGSQL_EXPR;
|
||||
expr->plan = NULL;
|
||||
expr->paramnos = NULL;
|
||||
expr->target_param = -1;
|
||||
expr->ns = plpgsql_ns_top();
|
||||
pfree(ds.data);
|
||||
|
||||
/* Next we'd better find the until token */
|
||||
@ -3950,7 +3951,7 @@ read_raise_options(void)
|
||||
for (;;)
|
||||
{
|
||||
PLpgSQL_raise_option *opt;
|
||||
int tok;
|
||||
int tok;
|
||||
|
||||
if ((tok = yylex()) == 0)
|
||||
yyerror("unexpected end of function definition");
|
||||
@ -4044,7 +4045,7 @@ static PLpgSQL_stmt *
|
||||
make_case(int location, PLpgSQL_expr *t_expr,
|
||||
List *case_when_list, List *else_stmts)
|
||||
{
|
||||
PLpgSQL_stmt_case *new;
|
||||
PLpgSQL_stmt_case *new;
|
||||
|
||||
new = palloc(sizeof(PLpgSQL_stmt_case));
|
||||
new->cmd_type = PLPGSQL_STMT_CASE;
|
||||
@ -4070,9 +4071,9 @@ make_case(int location, PLpgSQL_expr *t_expr,
|
||||
*/
|
||||
if (t_expr)
|
||||
{
|
||||
char varname[32];
|
||||
char varname[32];
|
||||
PLpgSQL_var *t_var;
|
||||
ListCell *l;
|
||||
ListCell *l;
|
||||
|
||||
/* use a name unlikely to collide with any user names */
|
||||
snprintf(varname, sizeof(varname), "__Case__Variable_%d__",
|
||||
@ -4095,7 +4096,7 @@ make_case(int location, PLpgSQL_expr *t_expr,
|
||||
{
|
||||
PLpgSQL_case_when *cwt = (PLpgSQL_case_when *) lfirst(l);
|
||||
PLpgSQL_expr *expr = cwt->expr;
|
||||
StringInfoData ds;
|
||||
StringInfoData ds;
|
||||
|
||||
/* We expect to have expressions not statements */
|
||||
Assert(expr->parseMode == RAW_PARSE_PLPGSQL_EXPR);
|
||||
|
Loading…
Reference in New Issue
Block a user