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

Commit05104f6

Browse files
committed
Fix grammar's AND/OR flattening to work with operator_precedence_warning.
It'd be good for "(x AND y) AND z" to produce a three-child AND nodewhether or not operator_precedence_warning is on, but that failed tohappen when it's on because makeAndExpr() didn't look through the addedAEXPR_PAREN node. This has no effect on generated plans because prepqual.cwould flatten the AND nest anyway; but it does affect the number of parensprinted in ruleutils.c, for example. I'd already fixed some similarhazards in parse_expr.c in commitabb1646, but didn't think to searchgram.y for problems of this ilk. Per gripe from Jean-Pierre Pelletier.Report: <fa0535ec6d6428cfec40c7e8a6d11156@mail.gmail.com>
1 parentd50183c commit05104f6

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

‎src/backend/parser/gram.y

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14643,10 +14643,16 @@ doNegateFloat(Value *v)
1464314643
static Node *
1464414644
makeAndExpr(Node *lexpr, Node *rexpr, int location)
1464514645
{
14646+
Node *lexp = lexpr;
14647+
14648+
/* Look through AEXPR_PAREN nodes so they don't affect flattening*/
14649+
while (IsA(lexp, A_Expr) &&
14650+
((A_Expr *) lexp)->kind == AEXPR_PAREN)
14651+
lexp = ((A_Expr *) lexp)->lexpr;
1464614652
/* Flatten "a AND b AND c ..." to a single BoolExpr on sight*/
14647-
if (IsA(lexpr, BoolExpr))
14653+
if (IsA(lexp, BoolExpr))
1464814654
{
14649-
BoolExpr *blexpr = (BoolExpr *)lexpr;
14655+
BoolExpr *blexpr = (BoolExpr *)lexp;
1465014656

1465114657
if (blexpr->boolop == AND_EXPR)
1465214658
{
@@ -14660,10 +14666,16 @@ makeAndExpr(Node *lexpr, Node *rexpr, int location)
1466014666
static Node *
1466114667
makeOrExpr(Node *lexpr, Node *rexpr, int location)
1466214668
{
14669+
Node *lexp = lexpr;
14670+
14671+
/* Look through AEXPR_PAREN nodes so they don't affect flattening*/
14672+
while (IsA(lexp, A_Expr) &&
14673+
((A_Expr *) lexp)->kind == AEXPR_PAREN)
14674+
lexp = ((A_Expr *) lexp)->lexpr;
1466314675
/* Flatten "a OR b OR c ..." to a single BoolExpr on sight*/
14664-
if (IsA(lexpr, BoolExpr))
14676+
if (IsA(lexp, BoolExpr))
1466514677
{
14666-
BoolExpr *blexpr = (BoolExpr *)lexpr;
14678+
BoolExpr *blexpr = (BoolExpr *)lexp;
1466714679

1466814680
if (blexpr->boolop == OR_EXPR)
1466914681
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp