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

Commitc82037e

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 parent8355897 commitc82037e

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
@@ -14512,10 +14512,16 @@ doNegateFloat(Value *v)
1451214512
static Node *
1451314513
makeAndExpr(Node *lexpr, Node *rexpr, int location)
1451414514
{
14515+
Node *lexp = lexpr;
14516+
14517+
/* Look through AEXPR_PAREN nodes so they don't affect flattening*/
14518+
while (IsA(lexp, A_Expr) &&
14519+
((A_Expr *) lexp)->kind == AEXPR_PAREN)
14520+
lexp = ((A_Expr *) lexp)->lexpr;
1451514521
/* Flatten "a AND b AND c ..." to a single BoolExpr on sight*/
14516-
if (IsA(lexpr, BoolExpr))
14522+
if (IsA(lexp, BoolExpr))
1451714523
{
14518-
BoolExpr *blexpr = (BoolExpr *)lexpr;
14524+
BoolExpr *blexpr = (BoolExpr *)lexp;
1451914525

1452014526
if (blexpr->boolop == AND_EXPR)
1452114527
{
@@ -14529,10 +14535,16 @@ makeAndExpr(Node *lexpr, Node *rexpr, int location)
1452914535
static Node *
1453014536
makeOrExpr(Node *lexpr, Node *rexpr, int location)
1453114537
{
14538+
Node *lexp = lexpr;
14539+
14540+
/* Look through AEXPR_PAREN nodes so they don't affect flattening*/
14541+
while (IsA(lexp, A_Expr) &&
14542+
((A_Expr *) lexp)->kind == AEXPR_PAREN)
14543+
lexp = ((A_Expr *) lexp)->lexpr;
1453214544
/* Flatten "a OR b OR c ..." to a single BoolExpr on sight*/
14533-
if (IsA(lexpr, BoolExpr))
14545+
if (IsA(lexp, BoolExpr))
1453414546
{
14535-
BoolExpr *blexpr = (BoolExpr *)lexpr;
14547+
BoolExpr *blexpr = (BoolExpr *)lexp;
1453614548

1453714549
if (blexpr->boolop == OR_EXPR)
1453814550
{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp