agora inbox for pgsql-committers@postgresql.org
help / color / mirror / Atom feedpgsql: SQL Property Graph Queries (SQL/PGQ)
6+ messages / 4 participants
[nested] [flat]
* pgsql: SQL Property Graph Queries (SQL/PGQ)
@ 2026-03-16 09:20 Peter Eisentraut <peter@eisentraut.org>
2026-03-16 16:34 ` Re: pgsql: SQL Property Graph Queries (SQL/PGQ) Andrew Dunstan <andrew@dunslane.net>
2026-07-10 15:54 ` Re: pgsql: SQL Property Graph Queries (SQL/PGQ) Thom Brown <thom@linux.com>
0 siblings, 2 replies; 6+ messages in thread
From: Peter Eisentraut @ 2026-03-16 09:20 UTC (permalink / raw)
To: pgsql-committers@lists.postgresql.org
SQL Property Graph Queries (SQL/PGQ)
Implementation of SQL property graph queries, according to SQL/PGQ
standard (ISO/IEC 9075-16:2023).
This adds:
- GRAPH_TABLE table function for graph pattern matching
- DDL commands CREATE/ALTER/DROP PROPERTY GRAPH
- several new system catalogs and information schema views
- psql \dG command
- pg_get_propgraphdef() function for pg_dump and psql
A property graph is a relation with a new relkind RELKIND_PROPGRAPH.
It acts like a view in many ways. It is rewritten to a standard
relational query in the rewriter. Access privileges act similar to a
security invoker view. (The security definer variant is not currently
implemented.)
Starting documentation can be found in doc/src/sgml/ddl.sgml and
doc/src/sgml/queries.sgml.
Author: Peter Eisentraut <peter@eisentraut.org>
Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Reviewed-by: Ajay Pal <ajay.pal.k@gmail.com>
Reviewed-by: Henson Choi <assam258@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/a855795d-e697-4fa5-8698-d20122126567@eisentraut.org
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/2f094e7ac691abc9d2fe0f4dcf0feac4a6ce1d9c
Modified Files
--------------
contrib/pg_overexplain/expected/pg_overexplain.out | 54 +
contrib/pg_overexplain/pg_overexplain.c | 20 +
contrib/pg_overexplain/sql/pg_overexplain.sql | 11 +
doc/src/sgml/catalogs.sgml | 520 +++++-
doc/src/sgml/ddl.sgml | 238 +++
doc/src/sgml/features.sgml | 4 +-
doc/src/sgml/func/func-info.sgml | 15 +
doc/src/sgml/information_schema.sgml | 1092 ++++++++++++
doc/src/sgml/keywords/sql2023-16-nonreserved.txt | 27 +
doc/src/sgml/keywords/sql2023-16-reserved.txt | 12 +
doc/src/sgml/queries.sgml | 162 ++
doc/src/sgml/ref/allfiles.sgml | 3 +
doc/src/sgml/ref/alter_extension.sgml | 3 +-
doc/src/sgml/ref/alter_property_graph.sgml | 299 ++++
doc/src/sgml/ref/comment.sgml | 1 +
doc/src/sgml/ref/create_property_graph.sgml | 318 ++++
doc/src/sgml/ref/drop_property_graph.sgml | 111 ++
doc/src/sgml/ref/grant.sgml | 7 +-
doc/src/sgml/ref/psql-ref.sgml | 13 +-
doc/src/sgml/ref/revoke.sgml | 7 +
doc/src/sgml/ref/security_label.sgml | 1 +
doc/src/sgml/ref/select.sgml | 43 +
doc/src/sgml/reference.sgml | 3 +
src/backend/catalog/aclchk.c | 36 +
src/backend/catalog/dependency.c | 11 +
src/backend/catalog/information_schema.sql | 366 ++++
src/backend/catalog/objectaddress.c | 335 ++++
src/backend/catalog/pg_class.c | 2 +
src/backend/catalog/sql_features.txt | 100 ++
src/backend/commands/Makefile | 1 +
src/backend/commands/alter.c | 28 +-
src/backend/commands/dropcmds.c | 1 +
src/backend/commands/event_trigger.c | 2 +
src/backend/commands/meson.build | 1 +
src/backend/commands/propgraphcmds.c | 1882 ++++++++++++++++++++
src/backend/commands/seclabel.c | 1 +
src/backend/commands/tablecmds.c | 20 +-
src/backend/executor/execMain.c | 17 +-
src/backend/nodes/nodeFuncs.c | 71 +
src/backend/nodes/outfuncs.c | 9 +
src/backend/nodes/print.c | 4 +
src/backend/nodes/readfuncs.c | 9 +
src/backend/optimizer/path/allpaths.c | 10 +
src/backend/optimizer/prep/prepjointree.c | 8 +
src/backend/parser/Makefile | 1 +
src/backend/parser/analyze.c | 5 +-
src/backend/parser/gram.y | 713 +++++++-
src/backend/parser/meson.build | 1 +
src/backend/parser/parse_agg.c | 11 +
src/backend/parser/parse_clause.c | 136 ++
src/backend/parser/parse_collate.c | 1 +
src/backend/parser/parse_expr.c | 11 +
src/backend/parser/parse_func.c | 3 +
src/backend/parser/parse_graphtable.c | 309 ++++
src/backend/parser/parse_relation.c | 99 +-
src/backend/parser/parse_target.c | 5 +
src/backend/parser/scan.l | 13 +-
src/backend/rewrite/Makefile | 1 +
src/backend/rewrite/meson.build | 1 +
src/backend/rewrite/rewriteGraphTable.c | 1318 ++++++++++++++
src/backend/rewrite/rewriteHandler.c | 12 +
src/backend/tcop/utility.c | 34 +
src/backend/utils/adt/acl.c | 4 +
src/backend/utils/adt/ruleutils.c | 531 ++++++
src/backend/utils/cache/lsyscache.c | 38 +
src/backend/utils/cache/plancache.c | 6 +-
src/bin/pg_dump/common.c | 3 +-
src/bin/pg_dump/dumputils.c | 3 +
src/bin/pg_dump/pg_backup_archiver.c | 1 +
src/bin/pg_dump/pg_dump.c | 83 +-
src/bin/pg_dump/t/002_pg_dump.pl | 28 +
src/bin/psql/command.c | 3 +-
src/bin/psql/describe.c | 94 +-
src/bin/psql/help.c | 5 +-
src/bin/psql/tab-complete.in.c | 67 +-
src/fe_utils/psqlscan.l | 8 +-
src/include/catalog/Makefile | 7 +-
src/include/catalog/catversion.h | 2 +-
src/include/catalog/meson.build | 5 +
src/include/catalog/pg_class.h | 1 +
src/include/catalog/pg_proc.dat | 3 +
src/include/catalog/pg_propgraph_element.h | 118 ++
src/include/catalog/pg_propgraph_element_label.h | 55 +
src/include/catalog/pg_propgraph_label.h | 55 +
src/include/catalog/pg_propgraph_label_property.h | 63 +
src/include/catalog/pg_propgraph_property.h | 64 +
src/include/commands/propgraphcmds.h | 23 +
src/include/nodes/parsenodes.h | 139 ++
src/include/nodes/primnodes.h | 24 +
src/include/parser/analyze.h | 3 +
src/include/parser/kwlist.h | 9 +
src/include/parser/parse_graphtable.h | 24 +
src/include/parser/parse_node.h | 21 +
src/include/parser/parse_relation.h | 8 +
src/include/rewrite/rewriteGraphTable.h | 21 +
src/include/tcop/cmdtaglist.h | 3 +
src/include/utils/acl.h | 1 +
src/include/utils/lsyscache.h | 3 +
src/interfaces/ecpg/preproc/pgc.l | 12 +-
src/interfaces/ecpg/test/ecpg_schedule | 1 +
src/interfaces/ecpg/test/expected/sql-sqlpgq.c | 285 +++
.../ecpg/test/expected/sql-sqlpgq.stderr | 190 ++
.../ecpg/test/expected/sql-sqlpgq.stdout | 7 +
src/interfaces/ecpg/test/sql/.gitignore | 2 +
src/interfaces/ecpg/test/sql/Makefile | 1 +
src/interfaces/ecpg/test/sql/meson.build | 1 +
src/interfaces/ecpg/test/sql/sqlpgq.pgc | 105 ++
src/test/regress/expected/alter_generic.out | 51 +-
.../regress/expected/create_property_graph.out | 926 ++++++++++
src/test/regress/expected/graph_table.out | 976 ++++++++++
src/test/regress/expected/graph_table_rls.out | 774 ++++++++
src/test/regress/expected/object_address.out | 26 +-
src/test/regress/expected/oidjoins.out | 12 +
src/test/regress/expected/privileges.out | 91 +
src/test/regress/parallel_schedule | 6 +-
src/test/regress/sql/alter_generic.sql | 34 +
src/test/regress/sql/create_property_graph.sql | 365 ++++
src/test/regress/sql/graph_table.sql | 567 ++++++
src/test/regress/sql/graph_table_rls.sql | 363 ++++
src/test/regress/sql/object_address.sql | 10 +-
src/test/regress/sql/privileges.sql | 58 +
src/tools/pgindent/typedefs.list | 19 +
122 files changed, 14888 insertions(+), 72 deletions(-)
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: pgsql: SQL Property Graph Queries (SQL/PGQ)
2026-03-16 09:20 pgsql: SQL Property Graph Queries (SQL/PGQ) Peter Eisentraut <peter@eisentraut.org>
@ 2026-03-16 16:34 ` Andrew Dunstan <andrew@dunslane.net>
2026-03-17 03:10 ` Re: pgsql: SQL Property Graph Queries (SQL/PGQ) Junwang Zhao <zhjwpku@gmail.com>
1 sibling, 1 reply; 6+ messages in thread
From: Andrew Dunstan @ 2026-03-16 16:34 UTC (permalink / raw)
To: Peter Eisentraut <peter@eisentraut.org>; pgsql-committers@lists.postgresql.org
-
On 2026-03-16 Mo 5:20 AM, Peter Eisentraut wrote:
> SQL Property Graph Queries (SQL/PGQ)
>
> Implementation of SQL property graph queries, according to SQL/PGQ
> standard (ISO/IEC 9075-16:2023).
>
> This adds:
>
> - GRAPH_TABLE table function for graph pattern matching
> - DDL commands CREATE/ALTER/DROP PROPERTY GRAPH
> - several new system catalogs and information schema views
> - psql \dG command
> - pg_get_propgraphdef() function for pg_dump and psql
>
> A property graph is a relation with a new relkind RELKIND_PROPGRAPH.
> It acts like a view in many ways. It is rewritten to a standard
> relational query in the rewriter. Access privileges act similar to a
> security invoker view. (The security definer variant is not currently
> implemented.)
>
> Starting documentation can be found in doc/src/sgml/ddl.sgml and
> doc/src/sgml/queries.sgml.
>
The output of make_propgraphdef_labels() is not stable in the face of an
upgrade which will not preserve the OID sort of the labels. The explains
the failure at
<https://buildfarm.postgresql.org/cgi-bin/show_stage_log.pl?nm=crake&dt=2026-03-16%2009%3A27%3A04...;.
I think we need to sort the labels by name, along the lines of the
attached. Or else teach the binary upgrade code to use the same labels,
as we do for some other things. Not sure how possible that is, nor how
worth it.
We also need to fence the dependency check in pg_dump.c (also in the
attached patch)
cheers
andrew
--
Andrew Dunstan
EDB: https://www.enterprisedb.com
Attachments:
[text/x-patch] fix-propgraph-def.patch (5.1K, ../../afe3f099-3271-4fc4-8e32-467b5309affb@dunslane.net/2-fix-propgraph-def.patch)
download | inline diff:
diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c
index 153a92fd3ea..00990b33859 100644
--- a/src/backend/utils/adt/ruleutils.c
+++ b/src/backend/utils/adt/ruleutils.c
@@ -330,6 +330,13 @@ typedef struct
typedef void (*rsv_callback) (Node *node, deparse_context *context,
void *callback_arg);
+/* Used by make_propgraphdef_labels to sort labels by name */
+typedef struct
+{
+ const char *labelname;
+ Oid ellabelid; /* pg_propgraph_element_label OID */
+} PropGraphLabelEntry;
+
/* ----------
* Global data
@@ -368,6 +375,7 @@ static char *pg_get_indexdef_worker(Oid indexrelid, int colno,
int prettyFlags, bool missing_ok);
static void make_propgraphdef_elements(StringInfo buf, Oid pgrelid, char pgekind);
static void make_propgraphdef_labels(StringInfo buf, Oid elid, const char *elalias, Oid elrelid);
+static int labelentry_name_cmp(const void *a, const void *b);
static void make_propgraphdef_properties(StringInfo buf, Oid ellabelid, Oid elrelid);
static char *pg_get_statisticsobj_worker(Oid statextid, bool columns_only,
bool missing_ok);
@@ -1776,14 +1784,28 @@ make_propgraphdef_elements(StringInfo buf, Oid pgrelid, char pgekind)
* Generates label and properties list. Pass in the element OID, the element
* alias, and the graph relation OID. Result is appended to buf.
*/
+/*
+ * Comparison function for qsort: sort label entries by label name.
+ */
+static int
+labelentry_name_cmp(const void *a, const void *b)
+{
+ const PropGraphLabelEntry *la = (const PropGraphLabelEntry *) a;
+ const PropGraphLabelEntry *lb = (const PropGraphLabelEntry *) b;
+
+ return strcmp(la->labelname, lb->labelname);
+}
+
static void
make_propgraphdef_labels(StringInfo buf, Oid elid, const char *elalias, Oid elrelid)
{
Relation pglrel;
ScanKeyData scankey[1];
SysScanDesc scan;
- int count;
HeapTuple tup;
+ PropGraphLabelEntry *labels;
+ int nlabels = 0;
+ int maxlabels = 8;
pglrel = table_open(PropgraphElementLabelRelationId, AccessShareLock);
@@ -1792,38 +1814,48 @@ make_propgraphdef_labels(StringInfo buf, Oid elid, const char *elalias, Oid elre
BTEqualStrategyNumber, F_OIDEQ,
ObjectIdGetDatum(elid));
- count = 0;
- scan = systable_beginscan(pglrel, PropgraphElementLabelElementLabelIndexId, true, NULL, 1, scankey);
- while ((tup = systable_getnext(scan)))
- {
- count++;
- }
- systable_endscan(scan);
+ /*
+ * Collect all labels first so we can sort them by name, ensuring a
+ * deterministic output order regardless of catalog OID assignment.
+ */
+ labels = palloc(maxlabels * sizeof(PropGraphLabelEntry));
scan = systable_beginscan(pglrel, PropgraphElementLabelElementLabelIndexId, true, NULL, 1, scankey);
-
while ((tup = systable_getnext(scan)))
{
Form_pg_propgraph_element_label pgelform = (Form_pg_propgraph_element_label) GETSTRUCT(tup);
- const char *labelname;
- labelname = get_propgraph_label_name(pgelform->pgellabelid);
+ if (nlabels >= maxlabels)
+ {
+ maxlabels *= 2;
+ labels = repalloc(labels, maxlabels * sizeof(PropGraphLabelEntry));
+ }
- if (strcmp(labelname, elalias) == 0)
+ labels[nlabels].labelname = pstrdup(get_propgraph_label_name(pgelform->pgellabelid));
+ labels[nlabels].ellabelid = pgelform->oid;
+ nlabels++;
+ }
+ systable_endscan(scan);
+
+ table_close(pglrel, AccessShareLock);
+
+ qsort(labels, nlabels, sizeof(PropGraphLabelEntry), labelentry_name_cmp);
+
+ for (int i = 0; i < nlabels; i++)
+ {
+ if (strcmp(labels[i].labelname, elalias) == 0)
{
/* If the default label is the only label, don't print anything. */
- if (count != 1)
+ if (nlabels != 1)
appendStringInfo(buf, " DEFAULT LABEL");
}
else
- appendStringInfo(buf, " LABEL %s", quote_identifier(labelname));
+ appendStringInfo(buf, " LABEL %s", quote_identifier(labels[i].labelname));
- make_propgraphdef_properties(buf, pgelform->oid, elrelid);
+ make_propgraphdef_properties(buf, labels[i].ellabelid, elrelid);
}
- systable_endscan(scan);
-
- table_close(pglrel, AccessShareLock);
+ pfree(labels);
}
/*
diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c
index b41a3ae3db4..23af95027e6 100644
--- a/src/bin/pg_dump/pg_dump.c
+++ b/src/bin/pg_dump/pg_dump.c
@@ -20473,11 +20473,12 @@ getDependencies(Archive *fout)
* Translate dependencies of pg_propgraph_element entries into
* dependencies of their parent pg_class entry.
*/
- appendPQExpBufferStr(query, "UNION ALL\n"
- "SELECT 'pg_class'::regclass AS classid, pgepgid AS objid, refclassid, refobjid, deptype "
- "FROM pg_depend d, pg_propgraph_element pge "
- "WHERE deptype NOT IN ('p', 'e', 'i') AND "
- "classid = 'pg_propgraph_element'::regclass AND objid = pge.oid\n");
+ if (fout->remoteVersion >= 190000)
+ appendPQExpBufferStr(query, "UNION ALL\n"
+ "SELECT 'pg_class'::regclass AS classid, pgepgid AS objid, refclassid, refobjid, deptype "
+ "FROM pg_depend d, pg_propgraph_element pge "
+ "WHERE deptype NOT IN ('p', 'e', 'i') AND "
+ "classid = 'pg_propgraph_element'::regclass AND objid = pge.oid\n");
/* Sort the output for efficiency below */
appendPQExpBufferStr(query, "ORDER BY 1,2");
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: pgsql: SQL Property Graph Queries (SQL/PGQ)
2026-03-16 09:20 pgsql: SQL Property Graph Queries (SQL/PGQ) Peter Eisentraut <peter@eisentraut.org>
2026-03-16 16:34 ` Re: pgsql: SQL Property Graph Queries (SQL/PGQ) Andrew Dunstan <andrew@dunslane.net>
@ 2026-03-17 03:10 ` Junwang Zhao <zhjwpku@gmail.com>
2026-03-17 04:03 ` Re: pgsql: SQL Property Graph Queries (SQL/PGQ) Junwang Zhao <zhjwpku@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Junwang Zhao @ 2026-03-17 03:10 UTC (permalink / raw)
To: Andrew Dunstan <andrew@dunslane.net>; +Cc: Peter Eisentraut <peter@eisentraut.org>; pgsql-committers@lists.postgresql.org
On Tue, Mar 17, 2026 at 12:35 AM Andrew Dunstan <andrew@dunslane.net> wrote:
>
>
> -
>
>
> On 2026-03-16 Mo 5:20 AM, Peter Eisentraut wrote:
> > SQL Property Graph Queries (SQL/PGQ)
> >
> > Implementation of SQL property graph queries, according to SQL/PGQ
> > standard (ISO/IEC 9075-16:2023).
> >
> > This adds:
> >
> > - GRAPH_TABLE table function for graph pattern matching
> > - DDL commands CREATE/ALTER/DROP PROPERTY GRAPH
> > - several new system catalogs and information schema views
> > - psql \dG command
> > - pg_get_propgraphdef() function for pg_dump and psql
> >
> > A property graph is a relation with a new relkind RELKIND_PROPGRAPH.
> > It acts like a view in many ways. It is rewritten to a standard
> > relational query in the rewriter. Access privileges act similar to a
> > security invoker view. (The security definer variant is not currently
> > implemented.)
> >
> > Starting documentation can be found in doc/src/sgml/ddl.sgml and
> > doc/src/sgml/queries.sgml.
> >
>
> The output of make_propgraphdef_labels() is not stable in the face of an
> upgrade which will not preserve the OID sort of the labels. The explains
> the failure at
> <https://buildfarm.postgresql.org/cgi-bin/show_stage_log.pl?nm=crake&dt=2026-03-16%2009%3A27%3A04...;.
> I think we need to sort the labels by name, along the lines of the
> attached. Or else teach the binary upgrade code to use the same labels,
> as we do for some other things. Not sure how possible that is, nor how
> worth it.
+1 for sorting by label names, the patch LGTM.
>
> We also need to fence the dependency check in pg_dump.c (also in the
> attached patch)
+1
>
>
> cheers
>
>
> andrew
>
>
>
> --
> Andrew Dunstan
> EDB: https://www.enterprisedb.com
--
Regards
Junwang Zhao
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: pgsql: SQL Property Graph Queries (SQL/PGQ)
2026-03-16 09:20 pgsql: SQL Property Graph Queries (SQL/PGQ) Peter Eisentraut <peter@eisentraut.org>
2026-03-16 16:34 ` Re: pgsql: SQL Property Graph Queries (SQL/PGQ) Andrew Dunstan <andrew@dunslane.net>
2026-03-17 03:10 ` Re: pgsql: SQL Property Graph Queries (SQL/PGQ) Junwang Zhao <zhjwpku@gmail.com>
@ 2026-03-17 04:03 ` Junwang Zhao <zhjwpku@gmail.com>
0 siblings, 0 replies; 6+ messages in thread
From: Junwang Zhao @ 2026-03-17 04:03 UTC (permalink / raw)
To: Andrew Dunstan <andrew@dunslane.net>; +Cc: Peter Eisentraut <peter@eisentraut.org>; pgsql-committers@lists.postgresql.org
Hi Andrew,
On Tue, Mar 17, 2026 at 11:10 AM Junwang Zhao <zhjwpku@gmail.com> wrote:
>
> On Tue, Mar 17, 2026 at 12:35 AM Andrew Dunstan <andrew@dunslane.net> wrote:
> >
> >
> > -
> >
> >
> > On 2026-03-16 Mo 5:20 AM, Peter Eisentraut wrote:
> > > SQL Property Graph Queries (SQL/PGQ)
> > >
> > > Implementation of SQL property graph queries, according to SQL/PGQ
> > > standard (ISO/IEC 9075-16:2023).
> > >
> > > This adds:
> > >
> > > - GRAPH_TABLE table function for graph pattern matching
> > > - DDL commands CREATE/ALTER/DROP PROPERTY GRAPH
> > > - several new system catalogs and information schema views
> > > - psql \dG command
> > > - pg_get_propgraphdef() function for pg_dump and psql
> > >
> > > A property graph is a relation with a new relkind RELKIND_PROPGRAPH.
> > > It acts like a view in many ways. It is rewritten to a standard
> > > relational query in the rewriter. Access privileges act similar to a
> > > security invoker view. (The security definer variant is not currently
> > > implemented.)
> > >
> > > Starting documentation can be found in doc/src/sgml/ddl.sgml and
> > > doc/src/sgml/queries.sgml.
> > >
> >
> > The output of make_propgraphdef_labels() is not stable in the face of an
> > upgrade which will not preserve the OID sort of the labels. The explains
> > the failure at
> > <https://buildfarm.postgresql.org/cgi-bin/show_stage_log.pl?nm=crake&dt=2026-03-16%2009%3A27%3A04...;.
> > I think we need to sort the labels by name, along the lines of the
> > attached. Or else teach the binary upgrade code to use the same labels,
> > as we do for some other things. Not sure how possible that is, nor how
> > worth it.
>
> +1 for sorting by label names, the patch LGTM.
I just noticed that Peter and Ashutosh had a patch for the same
fix by using list_sort[1], you might want to join the discussion there.
[1] https://www.postgresql.org/message-id/CAExHW5te5O-QGVhN6YADeFYDDb2oi%3DU50u62ojRcVAiZ-AEF-g%40mail.g...
>
> >
> > We also need to fence the dependency check in pg_dump.c (also in the
> > attached patch)
>
> +1
>
> >
> >
> > cheers
> >
> >
> > andrew
> >
> >
> >
> > --
> > Andrew Dunstan
> > EDB: https://www.enterprisedb.com
>
>
>
> --
> Regards
> Junwang Zhao
--
Regards
Junwang Zhao
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: pgsql: SQL Property Graph Queries (SQL/PGQ)
2026-03-16 09:20 pgsql: SQL Property Graph Queries (SQL/PGQ) Peter Eisentraut <peter@eisentraut.org>
@ 2026-07-10 15:54 ` Thom Brown <thom@linux.com>
2026-07-17 14:09 ` Re: pgsql: SQL Property Graph Queries (SQL/PGQ) Peter Eisentraut <peter@eisentraut.org>
1 sibling, 1 reply; 6+ messages in thread
From: Thom Brown @ 2026-07-10 15:54 UTC (permalink / raw)
To: Peter Eisentraut <peter@eisentraut.org>; +Cc: pgsql-committers@lists.postgresql.org
On Mon, 16 Mar 2026 at 09:20, Peter Eisentraut <peter@eisentraut.org> wrote:
>
> SQL Property Graph Queries (SQL/PGQ)
>
> Implementation of SQL property graph queries, according to SQL/PGQ
> standard (ISO/IEC 9075-16:2023).
>
> This adds:
>
> - GRAPH_TABLE table function for graph pattern matching
> - DDL commands CREATE/ALTER/DROP PROPERTY GRAPH
> - several new system catalogs and information schema views
> - psql \dG command
> - pg_get_propgraphdef() function for pg_dump and psql
>
> A property graph is a relation with a new relkind RELKIND_PROPGRAPH.
> It acts like a view in many ways. It is rewritten to a standard
> relational query in the rewriter. Access privileges act similar to a
> security invoker view. (The security definer variant is not currently
> implemented.)
>
> Starting documentation can be found in doc/src/sgml/ddl.sgml and
> doc/src/sgml/queries.sgml.
>
> Author: Peter Eisentraut <peter@eisentraut.org>
> Author: Ashutosh Bapat <ashutosh.bapat.oss@gmail.com>
> Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
> Reviewed-by: Ajay Pal <ajay.pal.k@gmail.com>
> Reviewed-by: Henson Choi <assam258@gmail.com>
> Discussion: https://www.postgresql.org/message-id/flat/a855795d-e697-4fa5-8698-d20122126567@eisentraut.org
>
> Branch
> ------
> master
>
> Details
> -------
> https://git.postgresql.org/pg/commitdiff/2f094e7ac691abc9d2fe0f4dcf0feac4a6ce1d9c
>
> Modified Files
> --------------
> contrib/pg_overexplain/expected/pg_overexplain.out | 54 +
> contrib/pg_overexplain/pg_overexplain.c | 20 +
> contrib/pg_overexplain/sql/pg_overexplain.sql | 11 +
> doc/src/sgml/catalogs.sgml | 520 +++++-
> doc/src/sgml/ddl.sgml | 238 +++
> doc/src/sgml/features.sgml | 4 +-
> doc/src/sgml/func/func-info.sgml | 15 +
> doc/src/sgml/information_schema.sgml | 1092 ++++++++++++
> doc/src/sgml/keywords/sql2023-16-nonreserved.txt | 27 +
> doc/src/sgml/keywords/sql2023-16-reserved.txt | 12 +
> doc/src/sgml/queries.sgml | 162 ++
> doc/src/sgml/ref/allfiles.sgml | 3 +
> doc/src/sgml/ref/alter_extension.sgml | 3 +-
> doc/src/sgml/ref/alter_property_graph.sgml | 299 ++++
> doc/src/sgml/ref/comment.sgml | 1 +
> doc/src/sgml/ref/create_property_graph.sgml | 318 ++++
> doc/src/sgml/ref/drop_property_graph.sgml | 111 ++
> doc/src/sgml/ref/grant.sgml | 7 +-
> doc/src/sgml/ref/psql-ref.sgml | 13 +-
> doc/src/sgml/ref/revoke.sgml | 7 +
> doc/src/sgml/ref/security_label.sgml | 1 +
> doc/src/sgml/ref/select.sgml | 43 +
> doc/src/sgml/reference.sgml | 3 +
> src/backend/catalog/aclchk.c | 36 +
> src/backend/catalog/dependency.c | 11 +
> src/backend/catalog/information_schema.sql | 366 ++++
> src/backend/catalog/objectaddress.c | 335 ++++
> src/backend/catalog/pg_class.c | 2 +
> src/backend/catalog/sql_features.txt | 100 ++
> src/backend/commands/Makefile | 1 +
> src/backend/commands/alter.c | 28 +-
> src/backend/commands/dropcmds.c | 1 +
> src/backend/commands/event_trigger.c | 2 +
> src/backend/commands/meson.build | 1 +
> src/backend/commands/propgraphcmds.c | 1882 ++++++++++++++++++++
> src/backend/commands/seclabel.c | 1 +
> src/backend/commands/tablecmds.c | 20 +-
> src/backend/executor/execMain.c | 17 +-
> src/backend/nodes/nodeFuncs.c | 71 +
> src/backend/nodes/outfuncs.c | 9 +
> src/backend/nodes/print.c | 4 +
> src/backend/nodes/readfuncs.c | 9 +
> src/backend/optimizer/path/allpaths.c | 10 +
> src/backend/optimizer/prep/prepjointree.c | 8 +
> src/backend/parser/Makefile | 1 +
> src/backend/parser/analyze.c | 5 +-
> src/backend/parser/gram.y | 713 +++++++-
> src/backend/parser/meson.build | 1 +
> src/backend/parser/parse_agg.c | 11 +
> src/backend/parser/parse_clause.c | 136 ++
> src/backend/parser/parse_collate.c | 1 +
> src/backend/parser/parse_expr.c | 11 +
> src/backend/parser/parse_func.c | 3 +
> src/backend/parser/parse_graphtable.c | 309 ++++
> src/backend/parser/parse_relation.c | 99 +-
> src/backend/parser/parse_target.c | 5 +
> src/backend/parser/scan.l | 13 +-
> src/backend/rewrite/Makefile | 1 +
> src/backend/rewrite/meson.build | 1 +
> src/backend/rewrite/rewriteGraphTable.c | 1318 ++++++++++++++
> src/backend/rewrite/rewriteHandler.c | 12 +
> src/backend/tcop/utility.c | 34 +
> src/backend/utils/adt/acl.c | 4 +
> src/backend/utils/adt/ruleutils.c | 531 ++++++
> src/backend/utils/cache/lsyscache.c | 38 +
> src/backend/utils/cache/plancache.c | 6 +-
> src/bin/pg_dump/common.c | 3 +-
> src/bin/pg_dump/dumputils.c | 3 +
> src/bin/pg_dump/pg_backup_archiver.c | 1 +
> src/bin/pg_dump/pg_dump.c | 83 +-
> src/bin/pg_dump/t/002_pg_dump.pl | 28 +
> src/bin/psql/command.c | 3 +-
> src/bin/psql/describe.c | 94 +-
> src/bin/psql/help.c | 5 +-
> src/bin/psql/tab-complete.in.c | 67 +-
> src/fe_utils/psqlscan.l | 8 +-
> src/include/catalog/Makefile | 7 +-
> src/include/catalog/catversion.h | 2 +-
> src/include/catalog/meson.build | 5 +
> src/include/catalog/pg_class.h | 1 +
> src/include/catalog/pg_proc.dat | 3 +
> src/include/catalog/pg_propgraph_element.h | 118 ++
> src/include/catalog/pg_propgraph_element_label.h | 55 +
> src/include/catalog/pg_propgraph_label.h | 55 +
> src/include/catalog/pg_propgraph_label_property.h | 63 +
> src/include/catalog/pg_propgraph_property.h | 64 +
> src/include/commands/propgraphcmds.h | 23 +
> src/include/nodes/parsenodes.h | 139 ++
> src/include/nodes/primnodes.h | 24 +
> src/include/parser/analyze.h | 3 +
> src/include/parser/kwlist.h | 9 +
> src/include/parser/parse_graphtable.h | 24 +
> src/include/parser/parse_node.h | 21 +
> src/include/parser/parse_relation.h | 8 +
> src/include/rewrite/rewriteGraphTable.h | 21 +
> src/include/tcop/cmdtaglist.h | 3 +
> src/include/utils/acl.h | 1 +
> src/include/utils/lsyscache.h | 3 +
> src/interfaces/ecpg/preproc/pgc.l | 12 +-
> src/interfaces/ecpg/test/ecpg_schedule | 1 +
> src/interfaces/ecpg/test/expected/sql-sqlpgq.c | 285 +++
> .../ecpg/test/expected/sql-sqlpgq.stderr | 190 ++
> .../ecpg/test/expected/sql-sqlpgq.stdout | 7 +
> src/interfaces/ecpg/test/sql/.gitignore | 2 +
> src/interfaces/ecpg/test/sql/Makefile | 1 +
> src/interfaces/ecpg/test/sql/meson.build | 1 +
> src/interfaces/ecpg/test/sql/sqlpgq.pgc | 105 ++
> src/test/regress/expected/alter_generic.out | 51 +-
> .../regress/expected/create_property_graph.out | 926 ++++++++++
> src/test/regress/expected/graph_table.out | 976 ++++++++++
> src/test/regress/expected/graph_table_rls.out | 774 ++++++++
> src/test/regress/expected/object_address.out | 26 +-
> src/test/regress/expected/oidjoins.out | 12 +
> src/test/regress/expected/privileges.out | 91 +
> src/test/regress/parallel_schedule | 6 +-
> src/test/regress/sql/alter_generic.sql | 34 +
> src/test/regress/sql/create_property_graph.sql | 365 ++++
> src/test/regress/sql/graph_table.sql | 567 ++++++
> src/test/regress/sql/graph_table_rls.sql | 363 ++++
> src/test/regress/sql/object_address.sql | 10 +-
> src/test/regress/sql/privileges.sql | 58 +
> src/tools/pgindent/typedefs.list | 19 +
> 122 files changed, 14888 insertions(+), 72 deletions(-)
>
Doc fix attached. An example on the page correctly quotes the word
"order" due to it being a reserved keyword, but another example fails
to do this, almost immediately after advising users to quote such
keywords.
Regards
Thom
Attachments:
[text/x-patch] graph-example-fix.patch (492B, ../../CAA-aLv4xyAaxm8vq5LEhznh-SGphs4wUAGC6Vpas+1hHZzzD7A@mail.gmail.com/2-graph-example-fix.patch)
download | inline diff:
diff --git a/doc/src/sgml/ddl.sgml b/doc/src/sgml/ddl.sgml
index 2b08b54edf5..55e7a132259 100644
--- a/doc/src/sgml/ddl.sgml
+++ b/doc/src/sgml/ddl.sgml
@@ -5921,7 +5921,7 @@ CREATE PROPERTY GRAPH myshop
VERTEX TABLES (
products LABEL product,
customers LABEL customer LABEL person PROPERTIES (name),
- orders LABEL order,
+ orders LABEL "order",
employees LABEL employee LABEL person PROPERTIES (employee_name AS name)
)
EDGE TABLES (
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: pgsql: SQL Property Graph Queries (SQL/PGQ)
2026-03-16 09:20 pgsql: SQL Property Graph Queries (SQL/PGQ) Peter Eisentraut <peter@eisentraut.org>
2026-07-10 15:54 ` Re: pgsql: SQL Property Graph Queries (SQL/PGQ) Thom Brown <thom@linux.com>
@ 2026-07-17 14:09 ` Peter Eisentraut <peter@eisentraut.org>
0 siblings, 0 replies; 6+ messages in thread
From: Peter Eisentraut @ 2026-07-17 14:09 UTC (permalink / raw)
To: Thom Brown <thom@linux.com>; +Cc: pgsql-committers@lists.postgresql.org
On 10.07.26 17:54, Thom Brown wrote:
> Doc fix attached. An example on the page correctly quotes the word
> "order" due to it being a reserved keyword, but another example fails
> to do this, almost immediately after advising users to quote such
> keywords.
Fixed, thanks.
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2026-07-17 14:09 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-03-16 09:20 pgsql: SQL Property Graph Queries (SQL/PGQ) Peter Eisentraut <peter@eisentraut.org>
2026-03-16 16:34 ` Andrew Dunstan <andrew@dunslane.net>
2026-03-17 03:10 ` Junwang Zhao <zhjwpku@gmail.com>
2026-03-17 04:03 ` Junwang Zhao <zhjwpku@gmail.com>
2026-07-10 15:54 ` Thom Brown <thom@linux.com>
2026-07-17 14:09 ` Peter Eisentraut <peter@eisentraut.org>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox