mirror of
https://github.com/postgres/postgres.git
synced 2025-05-13 01:13:08 -04:00
Partial pgindent of .l and .y files
Trying to clean up the code a bit while we're working on these files for the reentrant scanner/pure parser patches. This cleanup only touches the code sections after the second '%%' in each file, via a manually-supervised and locally hacked up pgindent.
This commit is contained in:
parent
2571c1d5cc
commit
301de6a6f6
@ -244,8 +244,8 @@ write_box(int dim, char *str1, char *str2,
|
|||||||
* The value turned out to be a point, ie. all the upper-right
|
* The value turned out to be a point, ie. all the upper-right
|
||||||
* coordinates were equal to the lower-left coordinates. Resize the
|
* coordinates were equal to the lower-left coordinates. Resize the
|
||||||
* cube we constructed. Note: we don't bother to repalloc() it
|
* cube we constructed. Note: we don't bother to repalloc() it
|
||||||
* smaller, as it's unlikely that the tiny amount of memory freed
|
* smaller, as it's unlikely that the tiny amount of memory freed that
|
||||||
* that way would be useful, and the output is always short-lived.
|
* way would be useful, and the output is always short-lived.
|
||||||
*/
|
*/
|
||||||
size = POINT_SIZE(dim);
|
size = POINT_SIZE(dim);
|
||||||
SET_VARSIZE(bp, size);
|
SET_VARSIZE(bp, size);
|
||||||
|
@ -73,7 +73,8 @@ cube_yyerror(NDBOX **result, Size scanbuflen,
|
|||||||
yyscan_t yyscanner,
|
yyscan_t yyscanner,
|
||||||
const char *message)
|
const char *message)
|
||||||
{
|
{
|
||||||
struct yyguts_t * yyg = (struct yyguts_t *) yyscanner; /* needed for yytext macro */
|
struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; /* needed for yytext
|
||||||
|
* macro */
|
||||||
|
|
||||||
if (*yytext == YY_END_OF_BUFFER_CHAR)
|
if (*yytext == YY_END_OF_BUFFER_CHAR)
|
||||||
{
|
{
|
||||||
|
@ -66,7 +66,8 @@ float ({integer}|{real})([eE]{integer})?
|
|||||||
void
|
void
|
||||||
seg_yyerror(SEG *result, struct Node *escontext, yyscan_t yyscanner, const char *message)
|
seg_yyerror(SEG *result, struct Node *escontext, yyscan_t yyscanner, const char *message)
|
||||||
{
|
{
|
||||||
struct yyguts_t * yyg = (struct yyguts_t *) yyscanner; /* needed for yytext macro */
|
struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; /* needed for yytext
|
||||||
|
* macro */
|
||||||
|
|
||||||
/* if we already reported an error, don't overwrite it */
|
/* if we already reported an error, don't overwrite it */
|
||||||
if (SOFT_ERROR_OCCURRED(escontext))
|
if (SOFT_ERROR_OCCURRED(escontext))
|
||||||
|
@ -131,7 +131,8 @@ NULL { yylval->kw = "NULL"; return XNULL; }
|
|||||||
void
|
void
|
||||||
boot_yyerror(yyscan_t yyscanner, const char *message)
|
boot_yyerror(yyscan_t yyscanner, const char *message)
|
||||||
{
|
{
|
||||||
struct yyguts_t * yyg = (struct yyguts_t *) yyscanner; /* needed for yylineno macro */
|
struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; /* needed for yylineno
|
||||||
|
* macro */
|
||||||
|
|
||||||
elog(ERROR, "%s at line %d", message, yylineno);
|
elog(ERROR, "%s at line %d", message, yylineno);
|
||||||
}
|
}
|
||||||
|
@ -18646,31 +18646,31 @@ updatePreparableStmtEnd(Node *n, int end_location)
|
|||||||
{
|
{
|
||||||
if (IsA(n, SelectStmt))
|
if (IsA(n, SelectStmt))
|
||||||
{
|
{
|
||||||
SelectStmt *stmt = (SelectStmt *)n;
|
SelectStmt *stmt = (SelectStmt *) n;
|
||||||
|
|
||||||
stmt->stmt_len = end_location - stmt->stmt_location;
|
stmt->stmt_len = end_location - stmt->stmt_location;
|
||||||
}
|
}
|
||||||
else if (IsA(n, InsertStmt))
|
else if (IsA(n, InsertStmt))
|
||||||
{
|
{
|
||||||
InsertStmt *stmt = (InsertStmt *)n;
|
InsertStmt *stmt = (InsertStmt *) n;
|
||||||
|
|
||||||
stmt->stmt_len = end_location - stmt->stmt_location;
|
stmt->stmt_len = end_location - stmt->stmt_location;
|
||||||
}
|
}
|
||||||
else if (IsA(n, UpdateStmt))
|
else if (IsA(n, UpdateStmt))
|
||||||
{
|
{
|
||||||
UpdateStmt *stmt = (UpdateStmt *)n;
|
UpdateStmt *stmt = (UpdateStmt *) n;
|
||||||
|
|
||||||
stmt->stmt_len = end_location - stmt->stmt_location;
|
stmt->stmt_len = end_location - stmt->stmt_location;
|
||||||
}
|
}
|
||||||
else if (IsA(n, DeleteStmt))
|
else if (IsA(n, DeleteStmt))
|
||||||
{
|
{
|
||||||
DeleteStmt *stmt = (DeleteStmt *)n;
|
DeleteStmt *stmt = (DeleteStmt *) n;
|
||||||
|
|
||||||
stmt->stmt_len = end_location - stmt->stmt_location;
|
stmt->stmt_len = end_location - stmt->stmt_location;
|
||||||
}
|
}
|
||||||
else if (IsA(n, MergeStmt))
|
else if (IsA(n, MergeStmt))
|
||||||
{
|
{
|
||||||
MergeStmt *stmt = (MergeStmt *)n;
|
MergeStmt *stmt = (MergeStmt *) n;
|
||||||
|
|
||||||
stmt->stmt_len = end_location - stmt->stmt_location;
|
stmt->stmt_len = end_location - stmt->stmt_location;
|
||||||
}
|
}
|
||||||
@ -18683,10 +18683,10 @@ makeColumnRef(char *colname, List *indirection,
|
|||||||
int location, core_yyscan_t yyscanner)
|
int location, core_yyscan_t yyscanner)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Generate a ColumnRef node, with an A_Indirection node added if there
|
* Generate a ColumnRef node, with an A_Indirection node added if there is
|
||||||
* is any subscripting in the specified indirection list. However,
|
* any subscripting in the specified indirection list. However, any field
|
||||||
* any field selection at the start of the indirection list must be
|
* selection at the start of the indirection list must be transposed into
|
||||||
* transposed into the "fields" part of the ColumnRef node.
|
* the "fields" part of the ColumnRef node.
|
||||||
*/
|
*/
|
||||||
ColumnRef *c = makeNode(ColumnRef);
|
ColumnRef *c = makeNode(ColumnRef);
|
||||||
int nfields = 0;
|
int nfields = 0;
|
||||||
@ -18952,8 +18952,8 @@ makeOrderedSetArgs(List *directargs, List *orderedargs,
|
|||||||
FunctionParameter *firsto = (FunctionParameter *) linitial(orderedargs);
|
FunctionParameter *firsto = (FunctionParameter *) linitial(orderedargs);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We ignore the names, though the aggr_arg production allows them;
|
* We ignore the names, though the aggr_arg production allows them; it
|
||||||
* it doesn't allow default values, so those need not be checked.
|
* doesn't allow default values, so those need not be checked.
|
||||||
*/
|
*/
|
||||||
if (list_length(orderedargs) != 1 ||
|
if (list_length(orderedargs) != 1 ||
|
||||||
firsto->mode != FUNC_PARAM_VARIADIC ||
|
firsto->mode != FUNC_PARAM_VARIADIC ||
|
||||||
@ -19143,7 +19143,7 @@ doNegateFloat(Float *v)
|
|||||||
if (*oldval == '+')
|
if (*oldval == '+')
|
||||||
oldval++;
|
oldval++;
|
||||||
if (*oldval == '-')
|
if (*oldval == '-')
|
||||||
v->fval = oldval+1; /* just strip the '-' */
|
v->fval = oldval + 1; /* just strip the '-' */
|
||||||
else
|
else
|
||||||
v->fval = psprintf("-%s", oldval);
|
v->fval = psprintf("-%s", oldval);
|
||||||
}
|
}
|
||||||
@ -19218,6 +19218,7 @@ makeXmlExpr(XmlExprOp op, char *name, List *named_args, List *args,
|
|||||||
|
|
||||||
x->op = op;
|
x->op = op;
|
||||||
x->name = name;
|
x->name = name;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* named_args is a list of ResTarget; it'll be split apart into separate
|
* named_args is a list of ResTarget; it'll be split apart into separate
|
||||||
* expression and name lists in transformXmlExpr().
|
* expression and name lists in transformXmlExpr().
|
||||||
@ -19556,8 +19557,8 @@ preprocess_pubobj_list(List *pubobjspec_list, core_yyscan_t yyscanner)
|
|||||||
parser_errposition(pubobj->location));
|
parser_errposition(pubobj->location));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We can distinguish between the different type of schema
|
* We can distinguish between the different type of schema objects
|
||||||
* objects based on whether name and pubtable is set.
|
* based on whether name and pubtable is set.
|
||||||
*/
|
*/
|
||||||
if (pubobj->name)
|
if (pubobj->name)
|
||||||
pubobj->pubobjtype = PUBLICATIONOBJ_TABLES_IN_SCHEMA;
|
pubobj->pubobjtype = PUBLICATIONOBJ_TABLES_IN_SCHEMA;
|
||||||
@ -19612,9 +19613,11 @@ makeRecursiveViewSelect(char *relname, List *aliases, Node *query)
|
|||||||
w->ctes = list_make1(cte);
|
w->ctes = list_make1(cte);
|
||||||
w->location = -1;
|
w->location = -1;
|
||||||
|
|
||||||
/* create target list for the new SELECT from the alias list of the
|
/*
|
||||||
* recursive view specification */
|
* create target list for the new SELECT from the alias list of the
|
||||||
foreach (lc, aliases)
|
* recursive view specification
|
||||||
|
*/
|
||||||
|
foreach(lc, aliases)
|
||||||
{
|
{
|
||||||
ResTarget *rt = makeNode(ResTarget);
|
ResTarget *rt = makeNode(ResTarget);
|
||||||
|
|
||||||
@ -19626,8 +19629,10 @@ makeRecursiveViewSelect(char *relname, List *aliases, Node *query)
|
|||||||
tl = lappend(tl, rt);
|
tl = lappend(tl, rt);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create new SELECT combining WITH clause, target list, and fake FROM
|
/*
|
||||||
* clause */
|
* create new SELECT combining WITH clause, target list, and fake FROM
|
||||||
|
* clause
|
||||||
|
*/
|
||||||
s->withClause = w;
|
s->withClause = w;
|
||||||
s->targetList = tl;
|
s->targetList = tl;
|
||||||
s->fromClause = list_make1(makeRangeVar(NULL, relname, -1));
|
s->fromClause = list_make1(makeRangeVar(NULL, relname, -1));
|
||||||
|
@ -140,7 +140,8 @@ xdinside [^"]+
|
|||||||
void
|
void
|
||||||
syncrep_yyerror(yyscan_t yyscanner, const char *message)
|
syncrep_yyerror(yyscan_t yyscanner, const char *message)
|
||||||
{
|
{
|
||||||
struct yyguts_t * yyg = (struct yyguts_t *) yyscanner; /* needed for yytext macro */
|
struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; /* needed for yytext
|
||||||
|
* macro */
|
||||||
|
|
||||||
/* report only the first error in a parse operation */
|
/* report only the first error in a parse operation */
|
||||||
if (syncrep_parse_error_msg)
|
if (syncrep_parse_error_msg)
|
||||||
|
@ -562,7 +562,7 @@ makeAny(int first, int last)
|
|||||||
|
|
||||||
static bool
|
static bool
|
||||||
makeItemLikeRegex(JsonPathParseItem *expr, JsonPathString *pattern,
|
makeItemLikeRegex(JsonPathParseItem *expr, JsonPathString *pattern,
|
||||||
JsonPathString *flags, JsonPathParseItem ** result,
|
JsonPathString *flags, JsonPathParseItem **result,
|
||||||
struct Node *escontext)
|
struct Node *escontext)
|
||||||
{
|
{
|
||||||
JsonPathParseItem *v = makeItemType(jpiLikeRegex);
|
JsonPathParseItem *v = makeItemType(jpiLikeRegex);
|
||||||
@ -605,7 +605,7 @@ makeItemLikeRegex(JsonPathParseItem *expr, JsonPathString *pattern,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Convert flags to what pg_regcomp needs */
|
/* Convert flags to what pg_regcomp needs */
|
||||||
if ( !jspConvertRegexFlags(v->value.like_regex.flags, &cflags, escontext))
|
if (!jspConvertRegexFlags(v->value.like_regex.flags, &cflags, escontext))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* check regex validity */
|
/* check regex validity */
|
||||||
|
@ -363,7 +363,8 @@ jsonpath_yyerror(JsonPathParseResult **result, struct Node *escontext,
|
|||||||
yyscan_t yyscanner,
|
yyscan_t yyscanner,
|
||||||
const char *message)
|
const char *message)
|
||||||
{
|
{
|
||||||
struct yyguts_t * yyg = (struct yyguts_t *) yyscanner; /* needed for yytext macro */
|
struct yyguts_t *yyg = (struct yyguts_t *) yyscanner; /* needed for yytext
|
||||||
|
* macro */
|
||||||
|
|
||||||
/* don't overwrite escontext if it's already been set */
|
/* don't overwrite escontext if it's already been set */
|
||||||
if (SOFT_ERROR_OCCURRED(escontext))
|
if (SOFT_ERROR_OCCURRED(escontext))
|
||||||
@ -399,39 +400,39 @@ typedef struct JsonPathKeyword
|
|||||||
* alphabetical order
|
* alphabetical order
|
||||||
*/
|
*/
|
||||||
static const JsonPathKeyword keywords[] = {
|
static const JsonPathKeyword keywords[] = {
|
||||||
{ 2, false, IS_P, "is"},
|
{2, false, IS_P, "is"},
|
||||||
{ 2, false, TO_P, "to"},
|
{2, false, TO_P, "to"},
|
||||||
{ 3, false, ABS_P, "abs"},
|
{3, false, ABS_P, "abs"},
|
||||||
{ 3, false, LAX_P, "lax"},
|
{3, false, LAX_P, "lax"},
|
||||||
{ 4, false, DATE_P, "date"},
|
{4, false, DATE_P, "date"},
|
||||||
{ 4, false, FLAG_P, "flag"},
|
{4, false, FLAG_P, "flag"},
|
||||||
{ 4, false, LAST_P, "last"},
|
{4, false, LAST_P, "last"},
|
||||||
{ 4, true, NULL_P, "null"},
|
{4, true, NULL_P, "null"},
|
||||||
{ 4, false, SIZE_P, "size"},
|
{4, false, SIZE_P, "size"},
|
||||||
{ 4, false, TIME_P, "time"},
|
{4, false, TIME_P, "time"},
|
||||||
{ 4, true, TRUE_P, "true"},
|
{4, true, TRUE_P, "true"},
|
||||||
{ 4, false, TYPE_P, "type"},
|
{4, false, TYPE_P, "type"},
|
||||||
{ 4, false, WITH_P, "with"},
|
{4, false, WITH_P, "with"},
|
||||||
{ 5, true, FALSE_P, "false"},
|
{5, true, FALSE_P, "false"},
|
||||||
{ 5, false, FLOOR_P, "floor"},
|
{5, false, FLOOR_P, "floor"},
|
||||||
{ 6, false, BIGINT_P, "bigint"},
|
{6, false, BIGINT_P, "bigint"},
|
||||||
{ 6, false, DOUBLE_P, "double"},
|
{6, false, DOUBLE_P, "double"},
|
||||||
{ 6, false, EXISTS_P, "exists"},
|
{6, false, EXISTS_P, "exists"},
|
||||||
{ 6, false, NUMBER_P, "number"},
|
{6, false, NUMBER_P, "number"},
|
||||||
{ 6, false, STARTS_P, "starts"},
|
{6, false, STARTS_P, "starts"},
|
||||||
{ 6, false, STRICT_P, "strict"},
|
{6, false, STRICT_P, "strict"},
|
||||||
{ 6, false, STRINGFUNC_P, "string"},
|
{6, false, STRINGFUNC_P, "string"},
|
||||||
{ 7, false, BOOLEAN_P, "boolean"},
|
{7, false, BOOLEAN_P, "boolean"},
|
||||||
{ 7, false, CEILING_P, "ceiling"},
|
{7, false, CEILING_P, "ceiling"},
|
||||||
{ 7, false, DECIMAL_P, "decimal"},
|
{7, false, DECIMAL_P, "decimal"},
|
||||||
{ 7, false, INTEGER_P, "integer"},
|
{7, false, INTEGER_P, "integer"},
|
||||||
{ 7, false, TIME_TZ_P, "time_tz"},
|
{7, false, TIME_TZ_P, "time_tz"},
|
||||||
{ 7, false, UNKNOWN_P, "unknown"},
|
{7, false, UNKNOWN_P, "unknown"},
|
||||||
{ 8, false, DATETIME_P, "datetime"},
|
{8, false, DATETIME_P, "datetime"},
|
||||||
{ 8, false, KEYVALUE_P, "keyvalue"},
|
{8, false, KEYVALUE_P, "keyvalue"},
|
||||||
{ 9, false, TIMESTAMP_P, "timestamp"},
|
{9, false, TIMESTAMP_P, "timestamp"},
|
||||||
{ 10,false, LIKE_REGEX_P, "like_regex"},
|
{10, false, LIKE_REGEX_P, "like_regex"},
|
||||||
{ 12,false, TIMESTAMP_TZ_P, "timestamp_tz"},
|
{12, false, TIMESTAMP_TZ_P, "timestamp_tz"},
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -593,7 +594,7 @@ addUnicodeChar(int ch, struct Node *escontext, yyscan_t yyscanner)
|
|||||||
* more detailed errors.
|
* more detailed errors.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (! escontext || ! IsA(escontext, ErrorSaveContext))
|
if (!escontext || !IsA(escontext, ErrorSaveContext))
|
||||||
pg_unicode_to_server(ch, (unsigned char *) cbuf);
|
pg_unicode_to_server(ch, (unsigned char *) cbuf);
|
||||||
else if (!pg_unicode_to_server_noerror(ch, (unsigned char *) cbuf))
|
else if (!pg_unicode_to_server_noerror(ch, (unsigned char *) cbuf))
|
||||||
ereturn(escontext, false,
|
ereturn(escontext, false,
|
||||||
@ -655,7 +656,8 @@ parseUnicode(char *s, int l, struct Node *escontext, yyscan_t yyscanner)
|
|||||||
for (i = 2; i < l; i += 2) /* skip '\u' */
|
for (i = 2; i < l; i += 2) /* skip '\u' */
|
||||||
{
|
{
|
||||||
int ch = 0;
|
int ch = 0;
|
||||||
int j, si;
|
int j,
|
||||||
|
si;
|
||||||
|
|
||||||
if (s[i] == '{') /* parse '\u{XX...}' */
|
if (s[i] == '{') /* parse '\u{XX...}' */
|
||||||
{
|
{
|
||||||
@ -677,7 +679,7 @@ parseUnicode(char *s, int l, struct Node *escontext, yyscan_t yyscanner)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! addUnicode(ch, &hi_surrogate, escontext, yyscanner))
|
if (!addUnicode(ch, &hi_surrogate, escontext, yyscanner))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -697,7 +699,10 @@ parseUnicode(char *s, int l, struct Node *escontext, yyscan_t yyscanner)
|
|||||||
static bool
|
static bool
|
||||||
parseHexChar(char *s, struct Node *escontext, yyscan_t yyscanner)
|
parseHexChar(char *s, struct Node *escontext, yyscan_t yyscanner)
|
||||||
{
|
{
|
||||||
int s2, s3, ch;
|
int s2,
|
||||||
|
s3,
|
||||||
|
ch;
|
||||||
|
|
||||||
if (!hexval(s[2], &s2, escontext, yyscanner))
|
if (!hexval(s[2], &s2, escontext, yyscanner))
|
||||||
return false;
|
return false;
|
||||||
if (!hexval(s[3], &s3, escontext, yyscanner))
|
if (!hexval(s[3], &s3, escontext, yyscanner))
|
||||||
|
@ -253,6 +253,7 @@ static const struct
|
|||||||
int nargs;
|
int nargs;
|
||||||
PgBenchFunction tag;
|
PgBenchFunction tag;
|
||||||
} PGBENCH_FUNCTIONS[] =
|
} PGBENCH_FUNCTIONS[] =
|
||||||
|
|
||||||
{
|
{
|
||||||
/* parsed as operators, executed as functions */
|
/* parsed as operators, executed as functions */
|
||||||
{
|
{
|
||||||
@ -485,6 +486,7 @@ make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args)
|
|||||||
if (len == 1)
|
if (len == 1)
|
||||||
{
|
{
|
||||||
PgBenchExpr *var = make_variable("default_seed");
|
PgBenchExpr *var = make_variable("default_seed");
|
||||||
|
|
||||||
args = make_elist(var, args);
|
args = make_elist(var, args);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -498,6 +500,7 @@ make_func(yyscan_t yyscanner, int fnumber, PgBenchExprList *args)
|
|||||||
if (len == 2)
|
if (len == 2)
|
||||||
{
|
{
|
||||||
PgBenchExpr *var = make_variable("default_seed");
|
PgBenchExpr *var = make_variable("default_seed");
|
||||||
|
|
||||||
args = make_elist(var, args);
|
args = make_elist(var, args);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -598,9 +598,9 @@ psql_scan_slash_option(PsqlScanState state,
|
|||||||
psql_scan_reselect_sql_lexer(state);
|
psql_scan_reselect_sql_lexer(state);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Check the lex result: we should have gotten back either LEXRES_OK
|
* Check the lex result: we should have gotten back either LEXRES_OK or
|
||||||
* or LEXRES_EOL (the latter indicating end of string). If we were inside
|
* LEXRES_EOL (the latter indicating end of string). If we were inside a
|
||||||
* a quoted string, as indicated by final_state, EOL is an error.
|
* quoted string, as indicated by final_state, EOL is an error.
|
||||||
*/
|
*/
|
||||||
Assert(lexresult == LEXRES_EOL || lexresult == LEXRES_OK);
|
Assert(lexresult == LEXRES_EOL || lexresult == LEXRES_OK);
|
||||||
|
|
||||||
@ -642,6 +642,7 @@ psql_scan_slash_option(PsqlScanState state,
|
|||||||
termPQExpBuffer(&mybuf);
|
termPQExpBuffer(&mybuf);
|
||||||
return NULL;
|
return NULL;
|
||||||
case xslashwholeline:
|
case xslashwholeline:
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* In whole-line mode, we interpret semicolon = true as stripping
|
* In whole-line mode, we interpret semicolon = true as stripping
|
||||||
* trailing whitespace as well as semicolons; this gives the
|
* trailing whitespace as well as semicolons; this gives the
|
||||||
|
@ -1847,9 +1847,9 @@ isdefine(void)
|
|||||||
ptr->used = yb;
|
ptr->used = yb;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We use yy_scan_string which will copy the value, so there's
|
* We use yy_scan_string which will copy the value, so there's no
|
||||||
* no need to worry about a possible undef happening while we
|
* need to worry about a possible undef happening while we are
|
||||||
* are still scanning it.
|
* still scanning it.
|
||||||
*/
|
*/
|
||||||
yy_scan_string(ptr->value);
|
yy_scan_string(ptr->value);
|
||||||
return true;
|
return true;
|
||||||
|
@ -2723,10 +2723,11 @@ read_sql_construct(int until,
|
|||||||
if (parenlevel < 0)
|
if (parenlevel < 0)
|
||||||
yyerror("mismatched parentheses");
|
yyerror("mismatched parentheses");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* End of function definition is an error, and we don't expect to
|
* End of function definition is an error, and we don't expect to hit
|
||||||
* hit a semicolon either (unless it's the until symbol, in which
|
* a semicolon either (unless it's the until symbol, in which case we
|
||||||
* case we should have fallen out above).
|
* should have fallen out above).
|
||||||
*/
|
*/
|
||||||
if (tok == 0 || tok == ';')
|
if (tok == 0 || tok == ';')
|
||||||
{
|
{
|
||||||
@ -2983,8 +2984,8 @@ make_execsql_stmt(int firsttoken, int location, PLword *word)
|
|||||||
plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_EXPR;
|
plpgsql_IdentifierLookup = IDENTIFIER_LOOKUP_EXPR;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Scan to the end of the SQL command. Identify any INTO-variables
|
* Scan to the end of the SQL command. Identify any INTO-variables clause
|
||||||
* clause lurking within it, and parse that via read_into_target().
|
* lurking within it, and parse that via read_into_target().
|
||||||
*
|
*
|
||||||
* The end of the statement is defined by a semicolon ... except that
|
* The end of the statement is defined by a semicolon ... except that
|
||||||
* semicolons within parentheses or BEGIN/END blocks don't terminate a
|
* semicolons within parentheses or BEGIN/END blocks don't terminate a
|
||||||
@ -3006,12 +3007,12 @@ make_execsql_stmt(int firsttoken, int location, PLword *word)
|
|||||||
* but it's not very likely.
|
* but it's not very likely.
|
||||||
*
|
*
|
||||||
* 3. IMPORT FOREIGN SCHEMA ... INTO. This is not allowed in CREATE RULE
|
* 3. IMPORT FOREIGN SCHEMA ... INTO. This is not allowed in CREATE RULE
|
||||||
* or WITH, so we just check for IMPORT as the command's first token.
|
* or WITH, so we just check for IMPORT as the command's first token. (If
|
||||||
* (If IMPORT FOREIGN SCHEMA returned data someone might wish to capture
|
* IMPORT FOREIGN SCHEMA returned data someone might wish to capture with
|
||||||
* with an INTO-variables clause, we'd have to work much harder here.)
|
* an INTO-variables clause, we'd have to work much harder here.)
|
||||||
*
|
*
|
||||||
* Fortunately, INTO is a fully reserved word in the main grammar, so
|
* Fortunately, INTO is a fully reserved word in the main grammar, so at
|
||||||
* at least we need not worry about it appearing as an identifier.
|
* least we need not worry about it appearing as an identifier.
|
||||||
*
|
*
|
||||||
* Any future additional uses of INTO in the main grammar will doubtless
|
* Any future additional uses of INTO in the main grammar will doubtless
|
||||||
* break this logic again ... beware!
|
* break this logic again ... beware!
|
||||||
@ -3087,9 +3088,9 @@ make_execsql_stmt(int firsttoken, int location, PLword *word)
|
|||||||
if (have_into)
|
if (have_into)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Insert an appropriate number of spaces corresponding to the
|
* Insert an appropriate number of spaces corresponding to the INTO
|
||||||
* INTO text, so that locations within the redacted SQL statement
|
* text, so that locations within the redacted SQL statement still
|
||||||
* still line up with those in the original source text.
|
* line up with those in the original source text.
|
||||||
*/
|
*/
|
||||||
plpgsql_append_source_text(&ds, location, into_start_loc);
|
plpgsql_append_source_text(&ds, location, into_start_loc);
|
||||||
appendStringInfoSpaces(&ds, into_end_loc - into_start_loc);
|
appendStringInfoSpaces(&ds, into_end_loc - into_start_loc);
|
||||||
@ -3137,8 +3138,8 @@ read_fetch_direction(void)
|
|||||||
bool check_FROM = true;
|
bool check_FROM = true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We create the PLpgSQL_stmt_fetch struct here, but only fill in
|
* We create the PLpgSQL_stmt_fetch struct here, but only fill in the
|
||||||
* the fields arising from the optional direction clause
|
* fields arising from the optional direction clause
|
||||||
*/
|
*/
|
||||||
fetch = (PLpgSQL_stmt_fetch *) palloc0(sizeof(PLpgSQL_stmt_fetch));
|
fetch = (PLpgSQL_stmt_fetch *) palloc0(sizeof(PLpgSQL_stmt_fetch));
|
||||||
fetch->cmd_type = PLPGSQL_STMT_FETCH;
|
fetch->cmd_type = PLPGSQL_STMT_FETCH;
|
||||||
@ -3223,12 +3224,12 @@ read_fetch_direction(void)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Assume it's a count expression with no preceding keyword.
|
* Assume it's a count expression with no preceding keyword. Note: we
|
||||||
* Note: we allow this syntax because core SQL does, but it's
|
* allow this syntax because core SQL does, but it's ambiguous with
|
||||||
* ambiguous with the case of an omitted direction clause; for
|
* the case of an omitted direction clause; for instance, "MOVE n IN
|
||||||
* instance, "MOVE n IN c" will fail if n is a variable, because the
|
* c" will fail if n is a variable, because the preceding else-arm
|
||||||
* preceding else-arm will trigger. Perhaps this can be improved
|
* will trigger. Perhaps this can be improved someday, but it hardly
|
||||||
* someday, but it hardly seems worth a lot of work.
|
* seems worth a lot of work.
|
||||||
*/
|
*/
|
||||||
plpgsql_push_back_token(tok);
|
plpgsql_push_back_token(tok);
|
||||||
fetch->expr = read_sql_expression2(K_FROM, K_IN,
|
fetch->expr = read_sql_expression2(K_FROM, K_IN,
|
||||||
@ -3357,8 +3358,8 @@ make_return_stmt(int location)
|
|||||||
/*
|
/*
|
||||||
* Not (just) a variable name, so treat as expression.
|
* Not (just) a variable name, so treat as expression.
|
||||||
*
|
*
|
||||||
* Note that a well-formed expression is _required_ here;
|
* Note that a well-formed expression is _required_ here; anything
|
||||||
* anything else is a compile-time error.
|
* else is a compile-time error.
|
||||||
*/
|
*/
|
||||||
plpgsql_push_back_token(tok);
|
plpgsql_push_back_token(tok);
|
||||||
new->expr = read_sql_expression(';', ";");
|
new->expr = read_sql_expression(';', ";");
|
||||||
@ -3420,8 +3421,8 @@ make_return_next_stmt(int location)
|
|||||||
/*
|
/*
|
||||||
* Not (just) a variable name, so treat as expression.
|
* Not (just) a variable name, so treat as expression.
|
||||||
*
|
*
|
||||||
* Note that a well-formed expression is _required_ here;
|
* Note that a well-formed expression is _required_ here; anything
|
||||||
* anything else is a compile-time error.
|
* else is a compile-time error.
|
||||||
*/
|
*/
|
||||||
plpgsql_push_back_token(tok);
|
plpgsql_push_back_token(tok);
|
||||||
new->expr = read_sql_expression(';', ";");
|
new->expr = read_sql_expression(';', ";");
|
||||||
@ -3540,11 +3541,11 @@ read_into_target(PLpgSQL_variable **target, bool *strict)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Currently, a row or record variable can be the single INTO target,
|
* Currently, a row or record variable can be the single INTO target, but
|
||||||
* but not a member of a multi-target list. So we throw error if there
|
* not a member of a multi-target list. So we throw error if there is a
|
||||||
* is a comma after it, because that probably means the user tried to
|
* comma after it, because that probably means the user tried to write a
|
||||||
* write a multi-target list. If this ever gets generalized, we should
|
* multi-target list. If this ever gets generalized, we should probably
|
||||||
* probably refactor read_into_scalar_list so it handles all cases.
|
* refactor read_into_scalar_list so it handles all cases.
|
||||||
*/
|
*/
|
||||||
switch (tok)
|
switch (tok)
|
||||||
{
|
{
|
||||||
@ -3630,8 +3631,8 @@ read_into_scalar_list(char *initial_name,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We read an extra, non-comma token from yylex(), so push it
|
* We read an extra, non-comma token from yylex(), so push it back onto
|
||||||
* back onto the input stream
|
* the input stream
|
||||||
*/
|
*/
|
||||||
plpgsql_push_back_token(tok);
|
plpgsql_push_back_token(tok);
|
||||||
|
|
||||||
@ -3741,14 +3742,14 @@ plpgsql_sql_error_callback(void *arg)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* First, set up internalerrposition to point to the start of the
|
* First, set up internalerrposition to point to the start of the
|
||||||
* statement text within the function text. Note this converts
|
* statement text within the function text. Note this converts location
|
||||||
* location (a byte offset) to a character number.
|
* (a byte offset) to a character number.
|
||||||
*/
|
*/
|
||||||
parser_errposition(cbarg->location);
|
parser_errposition(cbarg->location);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If the core parser provided an error position, transpose it.
|
* If the core parser provided an error position, transpose it. Note we
|
||||||
* Note we are dealing with 1-based character numbers at this point.
|
* are dealing with 1-based character numbers at this point.
|
||||||
*/
|
*/
|
||||||
errpos = geterrposition();
|
errpos = geterrposition();
|
||||||
if (errpos > 0)
|
if (errpos > 0)
|
||||||
@ -4121,9 +4122,9 @@ make_case(int location, PLpgSQL_expr *t_expr,
|
|||||||
/*
|
/*
|
||||||
* When test expression is present, we create a var for it and then
|
* When test expression is present, we create a var for it and then
|
||||||
* convert all the WHEN expressions to "VAR IN (original_expression)".
|
* convert all the WHEN expressions to "VAR IN (original_expression)".
|
||||||
* This is a bit klugy, but okay since we haven't yet done more than
|
* This is a bit klugy, but okay since we haven't yet done more than read
|
||||||
* read the expressions as text. (Note that previous parsing won't
|
* the expressions as text. (Note that previous parsing won't have
|
||||||
* have complained if the WHEN ... THEN expression contained multiple
|
* complained if the WHEN ... THEN expression contained multiple
|
||||||
* comma-separated values.)
|
* comma-separated values.)
|
||||||
*/
|
*/
|
||||||
if (t_expr)
|
if (t_expr)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user