Re: SQL Property Graph Queries (SQL/PGQ)
Junwang Zhao <zhjwpku@gmail.com>
From: Junwang Zhao <zhjwpku@gmail.com>
To: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Cc: Vik Fearing <vik@postgresfriends.org>, Ajay Pal <ajay.pal.k@gmail.com>, Imran Zaheer <imran.zhir@gmail.com>, Peter Eisentraut <peter@eisentraut.org>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-02-26T14:34:38Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Fix some typos and make small stylistic improvements
- 5282bf535e47 19 (unreleased) landed
-
Cleanup users and roles in graph_table_rls test
- 040a56be4bcc 19 (unreleased) landed
-
Dump labels in reproducible order
- c9babbc8816a 19 (unreleased) landed
-
SQL Property Graph Queries (SQL/PGQ)
- 2f094e7ac691 19 (unreleased) landed
-
Factor out constructSetOpTargetlist() from transformSetOperationTree()
- 8c2b30487cc7 19 (unreleased) landed
-
Sort out table_open vs. relation_open in rewriter
- d537f59fbbfc 19 (unreleased) landed
-
Rename grammar nonterminal to simplify reuse
- 8080f44f96a9 19 (unreleased) landed
-
Make ecpg parse.pl more robust with braces
- 7f88553ceaca 19 (unreleased) landed
-
Don't lock partitions pruned by initial pruning
- 525392d5727f 18.0 cited
-
Remove pg_regex_collation
- 792b2c7e6d92 18.0 cited
-
Use auxv to check for CRC32 instructions on ARM.
- aac831cafa6f 18.0 cited
-
Fix inappropriate uses of atol()
- f5a1311fccd2 18.0 cited
-
Remove unnecessary array object_classes[] in dependency.c
- ef5e2e90859a 17.0 cited
Attachments
- v12-0010-adapt-property-graph-to-more-intuitive-titles.patch (application/octet-stream) patch v12-0010
- v12-0013-refactor-insert_property_record-and-reduce-call-.patch (application/octet-stream) patch v12-0013
- v12-0011-do-not-use-default-COLLATE.patch (application/octet-stream) patch v12-0011
- v12-0012-trivial-refactor-of-property-graph-object-addres.patch (application/octet-stream) patch v12-0012
- v12-0014-lock-graph-table.patch (application/octet-stream) patch v12-0014
- v12-0008-Document-fixes.patch (application/octet-stream) patch v12-0008
- v12-0007-RLS-tests.patch (application/octet-stream) patch v12-0007
- v12-0009-WIP-Do-not-print-empty-columns-table-for-a-prope.patch (application/octet-stream) patch v12-0009
- v12-0005-Access-permissions-on-property-graph.patch (application/octet-stream) patch v12-0005
- v12-0006-Property-collation-and-edge-vertex-link-support.patch (application/octet-stream) patch v12-0006
- v12-0002-support-WHERE-clause-in-graph-pattern.patch (application/octet-stream) patch v12-0002
- v12-0004-Fixes-following-issues.patch (application/octet-stream) patch v12-0004
- v12-0003-Support-cyclic-path-pattern.patch (application/octet-stream) patch v12-0003
- v12-0001-WIP-SQL-Property-Graph-Queries-SQL-PGQ.patch (application/octet-stream) patch v12-0001
On Sun, Feb 23, 2025 at 8:54 PM Junwang Zhao <zhjwpku@gmail.com> wrote:
>
> On Mon, Feb 10, 2025 at 11:00 PM Junwang Zhao <zhjwpku@gmail.com> wrote:
> >
> > Hi Ashutosh,
> >
> > On Mon, Feb 10, 2025 at 2:14 PM Ashutosh Bapat
> > <ashutosh.bapat.oss@gmail.com> wrote:
> > >
> > > On Thu, Feb 6, 2025 at 8:22 PM Junwang Zhao <zhjwpku@gmail.com> wrote:
> > > > > >
> > > > >
> > > > > I see you have added some negative tests - object not found tests, but
> > > > > I didn't see positive tests. Hence I haven't added those changes in
> > > > > the attached patchset. But we certainly need those changes. You may
> > > > > want to submit a patch with positive tests. That code needs to be
> > > > > fixed before committing anyway.
> > > >
> > > > The attached file adds the positive tests.
> > >
> > > Hi Junwang,
> > > Thanks for the patch, but please post it as a separate patch in the
> > > full patch-set, otherwise CFBot gets confused.
> >
> > Ok, see the attached.
> >
> > 0001-0009 are the original patches of 20250127 with rebase of master
> > 0010 fix ci error due to `Show more-intuitive titles for psql
> > commands`, see a14707da564e
> > 0011 fix ci error due to unstable collation tests, we should not
> > depend on pg_catalog."default", I observed 002_pg_upgrade.pl failure
> > caused by this.
> > 0012 trivial refactor of property graph object address
> >
> > >
> > > --
> > > Best Wishes,
> > > Ashutosh Bapat
> >
> >
> >
> > --
> > Regards
> > Junwang Zhao
>
> Here is v11 with another trivial refactor, I add a seperate patch file 0013, in
> insert_property_record, there is no need to check `type`, `typmode` and
> `collation` if the property doesn't exists before, in AlterPropGraph, there is
> no need to call `check_all_labels_properties` for each added vertex or edge.
>
> Other files remain unchanged except I’ve added some missing document and
> typo fix we discussed in the list but not included in the previous
> patch, I included
> them in 0008.
>
> --
> Regards
> Junwang Zhao
Current patch set failed the cfbot, I did some analysis on this, the reason for
the failure is that backend has a core dump, I extract some queries from
graph_table.sql to reproduce the issue:
----------------- queries begin -----------------
CREATE SCHEMA graph_table_tests;
GRANT USAGE ON SCHEMA graph_table_tests TO PUBLIC;
SET search_path = graph_table_tests;
CREATE TABLE products (
product_no integer PRIMARY KEY,
name varchar,
price numeric
);
CREATE TABLE customers (
customer_id integer PRIMARY KEY,
name varchar,
address varchar
);
CREATE TABLE orders (
order_id integer PRIMARY KEY,
ordered_when date
);
CREATE TABLE order_items (
order_items_id integer PRIMARY KEY,
order_id integer REFERENCES orders (order_id),
product_no integer REFERENCES products (product_no),
quantity integer
);
CREATE TABLE customer_orders (
customer_orders_id integer PRIMARY KEY,
customer_id integer REFERENCES customers (customer_id),
order_id integer REFERENCES orders (order_id)
);
CREATE VIEW customers_view AS SELECT customer_id, 'redacted' ||
customer_id AS name_redacted, address FROM customers;
CREATE PROPERTY GRAPH myshop2
VERTEX TABLES (
products,
customers_view KEY (customer_id) LABEL customers,
orders
)
EDGE TABLES (
order_items KEY (order_items_id)
SOURCE KEY (order_id) REFERENCES orders (order_id)
DESTINATION KEY (product_no) REFERENCES products (product_no),
customer_orders KEY (customer_orders_id)
SOURCE KEY (customer_id) REFERENCES customers_view (customer_id)
DESTINATION KEY (order_id) REFERENCES orders (order_id)
);
CREATE VIEW customers_us_redacted AS SELECT * FROM GRAPH_TABLE
(myshop2 MATCH (c IS customers WHERE c.address = 'US')-[IS
customer_orders]->(o IS orders) COLUMNS (c.name_redacted AS
customer_name_redacted));
SELECT * FROM customers_us_redacted; <----- abort on this query
----------------- queries end -----------------
The backend aborted in ExecCheckPermissions, a recent commit 525392d57
add the following check:
----------------- code begin -----------------
/*
* Ensure that we have at least an AccessShareLock on relations
* whose permissions need to be checked.
*
* Skip this check in a parallel worker because locks won't be
* taken until ExecInitNode() performs plan initialization.
*
* XXX: ExecCheckPermissions() in a parallel worker may be
* redundant with the checks done in the leader process, so this
* should be reviewed to ensure it’s necessary.
*/
Assert(IsParallelWorker() ||
CheckRelationOidLockedByMe(rte->relid, AccessShareLock,
true));
----------------- code end -----------------
The query causing the core dump doesn't call transformRangeGraphTable
because the graph table is not in the `from` lists, so the graph table
is not locked.
I added a trivial fix(v12-0014) that called table_open/table_close in
rewriteGraphTable, it now passed the regression test and cirrus ci test,
but I'm not sure it's the correct fix.
I hope Ashutosh can chime in and take a look at this problem.
--
Regards
Junwang Zhao