From 8d2beee027af41a6b66c670b6a595895f24a1bb0 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sat, 18 Jul 2026 12:57:42 -0400 Subject: [PATCH] Restore the ability to use | and -> as prefix operators. 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 Author: Pierre Forstmann Reviewed-by: Tom Lane Discussion: https://postgr.es/m/19558-ad1fca59a3a471a0@postgresql.org Backpatch-through: 19 --- src/backend/parser/gram.y | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/backend/parser/gram.y b/src/backend/parser/gram.y index e1e65c414db..4b152c294ca 100644 --- a/src/backend/parser/gram.y +++ b/src/backend/parser/gram.y @@ -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