From: Chao Li <li.evan.chao@gmail.com>
To: Ewan Young <kdbase.hack@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Peter Eisentraut <peter@eisentraut.org>
Cc: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Subject: Re: GRAPH_TABLE pattern WHERE clause is not coerced to boolean
Date: Mon, 31 Aug 2026 19:26:50 +0800
Message-ID: <3AE204BD-2682-4893-A100-88719E5CCDBB@gmail.com> (raw)
In-Reply-To: <CAON2xHMP062_QSczXTJb_7fG3xRKzunft+tcwFD8dGqgFBS-Jg@mail.gmail.com>
References: <CAON2xHNZUS8ZwzVEJFeRirsC_-7EJvdbwABSzdGaJ_DF9DvHoQ@mail.gmail.com>
<6CC41338-C5EC-4AA0-8D8E-7C61DE8C768F@gmail.com>
<CAON2xHMP062_QSczXTJb_7fG3xRKzunft+tcwFD8dGqgFBS-Jg@mail.gmail.com>
> On Aug 31, 2026, at 18:08, Ewan Young <kdbase.hack@gmail.com> wrote:
>
> Thanks for the review!
>
> On Mon, Aug 31, 2026 at 4:38 PM Chao Li <li.evan.chao@gmail.com> wrote:
>>
>>
>>
>>> On Aug 31, 2026, at 15:32, Ewan Young <kdbase.hack@gmail.com> wrote:
>>>
>>> Hi
>>>
>>> The WHERE clauses inside a GRAPH_TABLE pattern -- both the element-level
>>> one (MATCH (c IS customers WHERE ...)) and the graph-pattern-level one
>>> (MATCH ... WHERE ...) -- are transformed with a bare transformExpr()
>>> and never go through coerce_to_boolean(). So a WHERE clause of any
>>> type is accepted, and its raw datum is used as the qual:
>>>
>>> create table customers (id int primary key, name text);
>>> insert into customers values (1,'alice'),(2,null),(3,'carol');
>>> create property graph g
>>> vertex tables (customers key (id) label customer properties (id, name));
>>>
>>> select * from graph_table (g match (c is customer where c.name)
>>> columns (c.id));
>>> id
>>> ----
>>> 1
>>> 3
>>> (2 rows)
>>>
>>> EXPLAIN shows "Filter: name". The never-null text pointer is always
>>> taken as true, so the condition silently degenerates to roughly
>>> "name IS NOT NULL": the NULL-name row disappears with no error.
>>> Numeric quals are evaluated by bit pattern ("WHERE 1" is true,
>>> "WHERE 0" is false), and even "WHERE row(1,2)" is accepted. The same
>>> clause outside GRAPH_TABLE gives the usual
>>>
>>> ERROR: argument of WHERE must be type boolean, not type text
>>>
>>> The attached patch routes both sites through transformWhereClause(),
>>> like every other WHERE clause, and adds regression tests for the
>>> element-level and pattern-level cases. make check passes. The code is
>>> the same in REL_19_STABLE, so v19 is affected as well.
>>>
>>> --
>>> Regards,
>>> Ewan Young
>>> <v1-0001-Coerce-GRAPH_TABLE-pattern-WHERE-clauses-to-boolean.patch>
>>
>> The patch looks good to me. As this is a v19 bug, it might be worth noting in the Open Items list.
>
> Agreed -- I don't have wiki edit access though; could someone add it
> under "Open Issues"?
>
I just helped add the item.
Best regards,
--
Chao Li (Evan)
HighGo Software Co., Ltd.
https://www.highgo.com/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-hackers@postgresql.org
Cc: li.evan.chao@gmail.com, kdbase.hack@gmail.com, peter@eisentraut.org, ashutosh.bapat.oss@gmail.com
Subject: Re: GRAPH_TABLE pattern WHERE clause is not coerced to boolean
In-Reply-To: <3AE204BD-2682-4893-A100-88719E5CCDBB@gmail.com>
References: <CAON2xHNZUS8ZwzVEJFeRirsC_-7EJvdbwABSzdGaJ_DF9DvHoQ@mail.gmail.com> <6CC41338-C5EC-4AA0-8D8E-7C61DE8C768F@gmail.com> <CAON2xHMP062_QSczXTJb_7fG3xRKzunft+tcwFD8dGqgFBS-Jg@mail.gmail.com> <3AE204BD-2682-4893-A100-88719E5CCDBB@gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox