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

Commit6fe27ca

Browse files
committed
Fix some operator-precedence problems. New constructs IS DISTINCT FRM
and IS [NOT] OF were not being parsed consistently with other IS forms.Also, make the world a little safer for functions named LEFT, RIGHT, etc.
1 parente06f4c6 commit6fe27ca

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

‎src/backend/parser/gram.y

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
*
1212
*
1313
* IDENTIFICATION
14-
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.365 2002/09/02 02:13:01 tgl Exp $
14+
* $Header: /cvsroot/pgsql/src/backend/parser/gram.y,v 2.366 2002/09/05 22:52:48 tgl Exp $
1515
*
1616
* HISTORY
1717
* AUTHORDATEMAJOR EVENT
@@ -416,7 +416,6 @@ static void doNegateFloat(Value *v);
416416
/* precedence: lowest to highest*/
417417
%leftUNIONEXCEPT
418418
%leftINTERSECT
419-
%leftJOINUNIONJOINCROSSLEFTFULLRIGHTINNER_PNATURAL
420419
%leftOR
421420
%leftAND
422421
%rightNOT
@@ -425,7 +424,7 @@ static void doNegateFloat(Value *v);
425424
%nonassocLIKEILIKESIMILAR
426425
%nonassocESCAPE
427426
%nonassocOVERLAPS
428-
%nonassocBETWEENDISTINCT
427+
%nonassocBETWEEN
429428
%nonassocIN_P
430429
%leftPOSTFIXOP/* dummy for postfix Op rules*/
431430
%leftOpOPERATOR/* multi-character ops and user-defined operators*/
@@ -443,6 +442,14 @@ static void doNegateFloat(Value *v);
443442
%leftCOLLATE
444443
%leftTYPECAST
445444
%left'.'
445+
/*
446+
* These might seem to be low-precedence, but actually they are not part
447+
* of the arithmetic hierarchy at all in their use as JOIN operators.
448+
* We make them high-precedence to support their use as function names.
449+
* They wouldn't be given a precedence at all, were it not that we need
450+
* left-associativity among the JOIN rules themselves.
451+
*/
452+
%leftJOINUNIONJOINCROSSLEFTFULLRIGHTINNER_PNATURAL
446453
%%
447454

448455
/*
@@ -5419,6 +5426,7 @@ r_expr: row IN_P select_with_parens
54195426
$$ = (Node *)makeOverlaps($1,$3);
54205427
}
54215428
| row IS DISTINCT FROM row
5429+
%prec IS
54225430
{
54235431
/* IS DISTINCT FROM has the following rules for non-array types:
54245432
* a) the row lengths must be equal
@@ -5736,13 +5744,13 @@ a_expr:c_expr{ $$ = $1; }
57365744
b->booltesttype = IS_NOT_UNKNOWN;
57375745
$$ = (Node *)b;
57385746
}
5739-
| a_expr IS DISTINCT FROM a_expr%precDISTINCT
5747+
| a_expr IS DISTINCT FROM a_expr%precIS
57405748
{$$ = (Node *) makeSimpleA_Expr(DISTINCT,"=",$1,$5); }
5741-
| a_expr IS OF'(' type_list')'
5749+
| a_expr IS OF'(' type_list')'%prec IS
57425750
{
57435751
$$ = (Node *) makeSimpleA_Expr(OF,"=",$1, (Node *)$5);
57445752
}
5745-
| a_expr IS NOT OF'(' type_list')'
5753+
| a_expr IS NOT OF'(' type_list')'%prec IS
57465754
{
57475755
$$ = (Node *) makeSimpleA_Expr(OF,"!=",$1, (Node *)$6);
57485756
}
@@ -5890,13 +5898,13 @@ b_expr:c_expr
58905898
{$$ = (Node *) makeA_Expr(OP,$1,NULL,$2); }
58915899
| b_expr qual_Op%prec POSTFIXOP
58925900
{$$ = (Node *) makeA_Expr(OP,$2,$1,NULL); }
5893-
| b_expr IS DISTINCT FROM b_expr%precOp
5901+
| b_expr IS DISTINCT FROM b_expr%precIS
58945902
{$$ = (Node *) makeSimpleA_Expr(DISTINCT,"=",$1,$5); }
5895-
| b_expr IS OF'(' type_list')'
5903+
| b_expr IS OF'(' type_list')'%prec IS
58965904
{
58975905
$$ = (Node *) makeSimpleA_Expr(OF,"=",$1, (Node *)$5);
58985906
}
5899-
| b_expr IS NOT OF'(' type_list')'
5907+
| b_expr IS NOT OF'(' type_list')'%prec IS
59005908
{
59015909
$$ = (Node *) makeSimpleA_Expr(OF,"!=",$1, (Node *)$6);
59025910
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp