Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit19d66ab

Browse files
committed
Remove broken code that tried to handle OVERLAPS with a single argument.
The SQL standard says that OVERLAPS should have a two-element rowconstructor on each side. The original coding of OVERLAPS support inour grammar attempted to extend that by allowing a single-element rowconstructor, which it internally duplicated ... or tried to, anyway.But that code has certainly not worked since our List infrastructure wasrewritten in 2004, and I'm none too sure it worked before that. As itstands, it ends up building a List that includes itself, leading toassorted undesirable behaviors later in the parser.Even if it worked as intended, it'd be a bit evil because of thepossibility of duplicate evaluation of a volatile function that the userhad written only once. Given the lack of documentation, test cases, orcomplaints, let's just get rid of the idea and only support the standardsyntax.While we're at it, improve the error cursor positioning for thewrong-number-of-arguments errors, and inline the makeOverlaps() functionsince it's only called in one place anyway.Per bug #9227 from Joshua Yanovski. Initial patch by Joshua Yanovski,extended a bit by me.
1 parent54cc94b commit19d66ab

File tree

1 file changed

+20
-36
lines changed

1 file changed

+20
-36
lines changed

‎src/backend/parser/gram.y

Lines changed: 20 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,6 @@ static Node *makeBitStringConst(char *str, int location);
111111
static Node *makeNullAConst(int location);
112112
static Node *makeAConst(Value *v,int location);
113113
static Node *makeBoolAConst(bool state,int location);
114-
static FuncCall *makeOverlaps(List *largs, List *rargs,
115-
int location,core_yyscan_t yyscanner);
116114
staticvoidcheck_qualified_name(List *names,core_yyscan_t yyscanner);
117115
static List *check_func_name(List *names,core_yyscan_t yyscanner);
118116
static List *check_indirection(List *indirection,core_yyscan_t yyscanner);
@@ -8938,7 +8936,26 @@ a_expr:c_expr{ $$ = $1; }
89388936
}
89398937
| row OVERLAPS row
89408938
{
8941-
$$ = (Node *)makeOverlaps($1,$3,@2, yyscanner);
8939+
FuncCall *n = makeNode(FuncCall);
8940+
n->funcname = SystemFuncName("overlaps");
8941+
if (list_length($1) !=2)
8942+
ereport(ERROR,
8943+
(errcode(ERRCODE_SYNTAX_ERROR),
8944+
errmsg("wrong number of parameters on left side of OVERLAPS expression"),
8945+
parser_errposition(@1)));
8946+
if (list_length($3) !=2)
8947+
ereport(ERROR,
8948+
(errcode(ERRCODE_SYNTAX_ERROR),
8949+
errmsg("wrong number of parameters on right side of OVERLAPS expression"),
8950+
parser_errposition(@3)));
8951+
n->args = list_concat($1,$3);
8952+
n->agg_order = NIL;
8953+
n->agg_star =FALSE;
8954+
n->agg_distinct =FALSE;
8955+
n->func_variadic =FALSE;
8956+
n->over =NULL;
8957+
n->location =@2;
8958+
$$ = (Node *)n;
89428959
}
89438960
| a_expr IS TRUE_P
89448961
{
@@ -11462,39 +11479,6 @@ makeBoolAConst(bool state, int location)
1146211479
return makeTypeCast((Node *)n, SystemTypeName("bool"), -1);
1146311480
}
1146411481

11465-
/* makeOverlaps()
11466-
* Create and populate a FuncCall node to support the OVERLAPS operator.
11467-
*/
11468-
static FuncCall *
11469-
makeOverlaps(List *largs, List *rargs, int location, core_yyscan_t yyscanner)
11470-
{
11471-
FuncCall *n = makeNode(FuncCall);
11472-
11473-
n->funcname = SystemFuncName("overlaps");
11474-
if (list_length(largs) == 1)
11475-
largs = lappend(largs, largs);
11476-
else if (list_length(largs) != 2)
11477-
ereport(ERROR,
11478-
(errcode(ERRCODE_SYNTAX_ERROR),
11479-
errmsg("wrong number of parameters on left side of OVERLAPS expression"),
11480-
parser_errposition(location)));
11481-
if (list_length(rargs) == 1)
11482-
rargs = lappend(rargs, rargs);
11483-
else if (list_length(rargs) != 2)
11484-
ereport(ERROR,
11485-
(errcode(ERRCODE_SYNTAX_ERROR),
11486-
errmsg("wrong number of parameters on right side of OVERLAPS expression"),
11487-
parser_errposition(location)));
11488-
n->args = list_concat(largs, rargs);
11489-
n->agg_order = NIL;
11490-
n->agg_star = FALSE;
11491-
n->agg_distinct = FALSE;
11492-
n->func_variadic = FALSE;
11493-
n->over = NULL;
11494-
n->location = location;
11495-
return n;
11496-
}
11497-
1149811482
/* check_qualified_name --- check the result of qualified_name production
1149911483
*
1150011484
* It's easiest to let the grammar production for qualified_name allow

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp