postgres.git / summary / log / commit / refs

commit    58af2138740b3da0c866f1e20045c43bb7bacc0b
Author:   Peter Eisentraut <peter@eisentraut.org>
Date:     Thu Aug 27 08:42:14 2026 +0000

    Fix inferred property graph keys with INCLUDE columns
    
    Inferred property graph keys used all attributes stored in the primary
    key index, causing non-key INCLUDE columns to become part of the graph
    key. Use only the index's key attributes.
    
    Author: Muhammad Taha Naveed <m.taha.naveed27@gmail.com>
    Discussion: https://www.postgresql.org/message-id/flat/CAPTqav%2BVUjYgm1jZy0Scy%3D1-PfdgznVj2%3DPwH8disiXF76HEow%40mail.gmail.com


src/backend/commands/propgraphcmds.c | 3 ++- src/test/regress/expected/create_property_graph.out | 3 ++- src/test/regress/sql/create_property_graph.sql | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/backend/commands/propgraphcmds.c b/src/backend/commands/propgraphcmds.c index 076005226f2..2bdce331c49 100644 --- a/src/backend/commands/propgraphcmds.c +++ b/src/backend/commands/propgraphcmds.c @@ -342,7 +342,8 @@ propgraph_element_get_key(ParseState *pstate, const List *key_clause, Relation e Relation indexDesc; indexDesc = index_open(pkidx, AccessShareLock); - a = array_from_attnums(indexDesc->rd_index->indkey.dim1, indexDesc->rd_index->indkey.values); + a = array_from_attnums(IndexRelationGetNumberOfKeyAttributes(indexDesc), + indexDesc->rd_index->indkey.values); index_close(indexDesc, NoLock); } } diff --git a/src/test/regress/expected/create_property_graph.out b/src/test/regress/expected/create_property_graph.out index 646e5fed5e2..5bbd6477ed6 100644 --- a/src/test/regress/expected/create_property_graph.out +++ b/src/test/regress/expected/create_property_graph.out @@ -12,7 +12,8 @@ ERROR: relation "g1" already exists CREATE TABLE t1 (a int, b text); CREATE TABLE t2 (i int PRIMARY KEY, j int, k int); CREATE TABLE t3 (x int, y text, z text); -CREATE TABLE e1 (a int, i int, t text, PRIMARY KEY (a, i)); +-- INCLUDE column must not become part of the inferred element key +CREATE TABLE e1 (a int, i int, t text, PRIMARY KEY (a, i) INCLUDE (t)); CREATE TABLE e2 (a int, x int, t text); CREATE PROPERTY GRAPH g2 VERTEX TABLES (t1 KEY (a), t2 DEFAULT LABEL, t3 KEY (x) LABEL t3l1 LABEL t3l2) diff --git a/src/test/regress/sql/create_property_graph.sql b/src/test/regress/sql/create_property_graph.sql index b1a8d12a040..2b8269d66ec 100644 --- a/src/test/regress/sql/create_property_graph.sql +++ b/src/test/regress/sql/create_property_graph.sql @@ -17,7 +17,8 @@ CREATE TABLE t1 (a int, b text); CREATE TABLE t2 (i int PRIMARY KEY, j int, k int); CREATE TABLE t3 (x int, y text, z text); -CREATE TABLE e1 (a int, i int, t text, PRIMARY KEY (a, i)); +-- INCLUDE column must not become part of the inferred element key +CREATE TABLE e1 (a int, i int, t text, PRIMARY KEY (a, i) INCLUDE (t)); CREATE TABLE e2 (a int, x int, t text); CREATE PROPERTY GRAPH g2 [parent: 3e8bcc8644fe]