| From: | Ewan Young <kdbase(dot)hack(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | Peter Eisentraut <peter(at)eisentraut(dot)org>, Ashutosh Bapat <ashutosh(dot)bapat(dot)oss(at)gmail(dot)com> |
| Subject: | GRAPH_TABLE pattern WHERE clause is not coerced to boolean |
| Date: | 2026-08-31 07:32:50 |
| Message-ID: | CAON2xHNZUS8ZwzVEJFeRirsC_-7EJvdbwABSzdGaJ_DF9DvHoQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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
| Attachment | Content-Type | Size |
|---|---|---|
| v1-0001-Coerce-GRAPH_TABLE-pattern-WHERE-clauses-to-boolean.patch | application/octet-stream | 4.9 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2026-08-31 07:38:07 | Re: WAIT FOR command should do some query jumbling |
| Previous Message | Richard Guo | 2026-08-31 07:32:02 | Re: remove_useless_joins vs. bug #19560 |