mirror of
https://github.com/postgres/postgres.git
synced 2026-10-23 13:29:09 +03:00
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
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user