]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Restore the ability to use | and -> as prefix operators.
authorTom Lane <tgl@sss.pgh.pa.us>
Sat, 18 Jul 2026 16:57:42 +0000 (12:57 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Sat, 18 Jul 2026 16:57:42 +0000 (12:57 -0400)
Commit 2f094e7ac changed the parser to treat these as built-in
operator names, where before they were just generic Op.  While
it correctly gave them the same precedence as Op and added new
productions to allow them to still be used as infix operators,
it missed allowing them to still be used as prefix operators.
At least one extension expects to be able to do that, so add
the necessary productions.

Bug: #19558
Reported-by: Pierre Senellart <pierre@senellart.com>
Author: Pierre Forstmann <pierre.forstmann@gmail.com>
Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/19558-ad1fca59a3a471a0@postgresql.org
Backpatch-through: 19

src/backend/parser/gram.y

index e1e65c414db944edeac0d0f59ed52606535c60fa..4b152c294ca17be949eb778b1dd792d8c1365a93 100644 (file)
@@ -15884,6 +15884,10 @@ a_expr:                c_expr                                                                  { $$ = $1; }
                                { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, ">=", $1, $3, @2); }
                        | a_expr NOT_EQUALS a_expr
                                { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "<>", $1, $3, @2); }
+                       | RIGHT_ARROW a_expr
+                               { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "->", NULL, $2, @1); }
+                       | '|' a_expr
+                               { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "|", NULL, $2, @1); }
                        | a_expr RIGHT_ARROW a_expr
                                { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "->", $1, $3, @2); }
                        | a_expr '|' a_expr
@@ -16368,6 +16372,10 @@ b_expr:                c_expr
                                { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, ">=", $1, $3, @2); }
                        | b_expr NOT_EQUALS b_expr
                                { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "<>", $1, $3, @2); }
+                       | RIGHT_ARROW b_expr
+                               { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "->", NULL, $2, @1); }
+                       | '|' b_expr
+                               { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "|", NULL, $2, @1); }
                        | b_expr RIGHT_ARROW b_expr
                                { $$ = (Node *) makeSimpleA_Expr(AEXPR_OP, "->", $1, $3, @2); }
                        | b_expr '|' b_expr