BUG #19558: User-defined prefix operators "|" and "->" no longer parse in 19beta2 (SQL/PGQ grammar change)

From: PG Bug reporting form <noreply(at)postgresql(dot)org>
To: pgsql-bugs(at)lists(dot)postgresql(dot)org
Cc: pierre(at)senellart(dot)com
Subject: BUG #19558: User-defined prefix operators "|" and "->" no longer parse in 19beta2 (SQL/PGQ grammar change)
Date: 2026-07-18 08:39:10
Message-ID: 19558-ad1fca59a3a471a0@postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 19558
Logged by: Pierre Senellart
Email address: pierre(at)senellart(dot)com
PostgreSQL version: 19beta2
Operating system: Linux
Description:

The following works on PostgreSQL <= 18 but raises a syntax error on
19beta1/19beta2 (tested: PostgreSQL 19beta2, Ubuntu package
19~beta2-1.pgdg26.04+1, x86_64-linux):

CREATE FUNCTION identity_int(int) RETURNS int
LANGUAGE sql IMMUTABLE AS 'SELECT $1';
CREATE OPERATOR | (RIGHTARG = int, FUNCTION = identity_int);
CREATE OPERATOR -> (RIGHTARG = int, FUNCTION = identity_int);

SELECT | 5; -- 18: returns 5; 19beta2: syntax error at or near "|"
SELECT -> 5; -- 18: returns 5; 19beta2: syntax error at or near "->"

Cause: the SQL/PGQ property graph patch turned "|" and "->" into dedicated
grammar tokens (RIGHT_ARROW), declared in the precedence list alongside Op.
Explicit binary productions (a_expr '|' a_expr, a_expr RIGHT_ARROW a_expr)
preserve infix use, and both tokens were added to the operator-name
productions, so binary use and the OPERATOR() syntax still work:

SELECT OPERATOR(public.|) 5; -- still returns 5 on 19beta2
SELECT OPERATOR(public.->) 5; -- still returns 5 on 19beta2

But no unary counterparts of these productions were added, so a user-defined
*prefix* operator spelled exactly "|" or "->" can no longer be invoked by
its bare name. Note the inconsistency: CREATE OPERATOR still accepts both
names for prefix operators; the resulting operator just cannot be called
except through OPERATOR().

If the tokenization is here to stay, could unary productions ('|' a_expr,
RIGHT_ARROW a_expr) be added to restore the pre-19 behaviour? Failing that,
this seems worth an entry in the release notes' incompatibilities section,
since nothing currently documents it.

Motivation: https://pgxn.org/dist/provsql/ which I am developing uses prefix
| as a probabilistic “given” operator. This works on all PostgreSQL versions
from 10 to 18, but fails on 19beta2.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2026-07-18 11:21:30 BUG #19559: ALTER TABLE SET EXPRESSION / ALTER TYPE fails on columns referenced by a property graph
Previous Message Richard Guo 2026-07-18 01:40:28 Re: BUG #19553: Wrong results from nested LEFT JOINs over an empty subquery (regression since v16)