Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wkkTg-000qvo-0x for pgsql-bugs@arkaria.postgresql.org; Fri, 17 Jul 2026 15:27:52 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.96) (envelope-from ) id 1wkkTf-000cJ8-0Y for pgsql-bugs@arkaria.postgresql.org; Fri, 17 Jul 2026 15:27:51 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1wkkTe-000cIR-2h for pgsql-bugs@lists.postgresql.org; Fri, 17 Jul 2026 15:27:50 +0000 Received: from mail1.dalibo.net ([51.159.93.128] helo=mail.dalibo.com) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.98.2) (envelope-from ) id 1wkkTc-00000000med-1s3v for pgsql-bugs@lists.postgresql.org; Fri, 17 Jul 2026 15:27:50 +0000 Received: from [192.168.74.160] (82-64-99-9.subs.proxad.net [82.64.99.9]) by mail.dalibo.com (Postfix) with ESMTPSA id 95BED260D9; Fri, 17 Jul 2026 17:27:46 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dalibo.com; s=a; t=1784302066; bh=sT4nC2VthKTSmf3cEiP7HJolj+1lfnutyZ8kW5d4UY4=; h=Date:Subject:To:References:From:In-Reply-To:From; b=qQG6/w8x6TS2aXIPk/IwRZSwrZwKn5PMh63RHmdI5DwgBQs3f4ZGDuJUOU77IS1ho r6nS0yb+m74LXWQqlDfHQJjqfSZ5Efk4+M0WFXVdyehqM1W3bUA610xP4giBX/9OIX oOm0zdVOPUbai/mr5kyGEbZdNMl2RzpJz9Xl+qes= Message-ID: Date: Fri, 17 Jul 2026 17:27:45 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: BUG #19548: Missing dependency between a graph edge and the related PK To: Ayoub Kazar , pgsql-bugs@lists.postgresql.org References: <19548-6cac2e96468d7cb8@postgresql.org> Content-Language: en-US, fr-FR From: Christophe Courtois Autocrypt: addr=christophe.courtois@dalibo.com; keydata= xsFNBFffvRkBEACz9SwjHcwUpg3Eg+UpuNeuxugWyg555J45Osi7J7m45qubSgxsK41HIgTt +bnfcpmi2x4EsygiHUB3sx5eVjr1xVL/nFECBK6uNaKmhckWuTPqiQErbo8UGQw3O3cj0sQc oO+OjPzwejh0q9zVHfJ0GcaYHx+RtwMnlQlXYHjalg6OU0YOtgfgiV96pR+ulKjsQR4PNuac ShTHwGPceBZn4/HOU5d4HI6swOBeomL3xGpkam9i/8v6rdUNfW39o4lk5NuNkuHIDyc241D0 MCEVDsjOxJUs0Z+E0Ulth4wdBnyCeH3yX1wfG5IGTZj0qazpte6zVfE97/uea0cMtShOCkyI c2faqegQokxPcWCGnIL/QSVI7fdgrQMZmHuDFI+nD7fBf+rPEuYlj+nHBZNJbzJNWVi/J7FK y/9ml9bhy9C8eaL5BEw9pxB5gLxKnMabGO1oImr5eUoaLMdDg1bhN6b135+a3DDRNK8D/DBx eTjmyv7rrVs7AC6hLGMrF4/K3uYNEsTC7Ord/xZNcUD5SQHqJYyM6ovHlbSrPL+eWIv2AYcS lTj2HOULcqyJ8KoExY8y+JnPRxll2qu2intel3F1qhnoZTG1ihUN2f4ywxAS0jHtfAIXcQMy idZBKipxOzGx/qUZMHNmmV5KPYPfo431qEM1lRMpZiSPmaMKrwARAQABzT1DaHJpc3RvcGhl IENvdXJ0b2lzIChEYWxpYm8pIDxjaHJpc3RvcGhlLmNvdXJ0b2lzQGRhbGliby5jb20+wsF4 BBMBAgAiBQJX370ZAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAAKCRB80jF0dHO1EkU+ D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Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Le 16/07/2026 à 14:13, Ayoub Kazar a écrit : > Hi Christophe, > > On Thu, Jul 16, 2026 at 12:38 PM PG Bug reporting form > > wrote: > > The following bug has been logged on the website: > > Bug reference:      19548 > Logged by:          Christophe Courtois > Email address: christophe.courtois@dalibo.com > > PostgreSQL version: 19beta1 > Operating system:   Linux Debian 13 > Description: > > Hi, > > A dependency between a graph and the PK of a relationship > seems to be missing. > > In the following example, a PK on the edge table is compulsory, > but this PK can be cascade-dropped and the graph is unchanged. > > The graph can be dropped later, > but it cannot be recreated : > ERROR:  no key specified and no suitable primary key exists for > definition > of element "family" > > I imagine that a pg_restore will fail too. > > Tested on 19~beta2-1~20260629.2015.g9cfd19bc10a.pgdg13+1 from > apt.postgresql.org > and 20devel freshly compiled. > > Full example : > > -- persons > CREATE TABLE persons ( >     id TEXT PRIMARY KEY, >     nom TEXT, >     sexe TEXT > ); > > CREATE TABLE family ( >     id TEXT PRIMARY KEY, >     spouse1 TEXT  REFERENCES persons(id), >     spouse2 TEXT  REFERENCES persons(id) > ); > > CREATE PROPERTY GRAPH wedding >     VERTEX TABLES ( >        persons  KEY (id) PROPERTIES ALL COLUMNS >     ) >     EDGE TABLES ( >         family >             SOURCE KEY      (spouse1) REFERENCES persons (id) >             DESTINATION KEY (spouse2) REFERENCES persons (id) >         ); > > -- Drop the constraint > -- CASCADE does NOT get rid if the graph > > ALTER TABLE family DROP CONSTRAINT family_pkey CASCADE ; > > -- The graph is still there > > \dG+ > > -- Recreation fails > > DROP PROPERTY GRAPH wedding ; > > CREATE PROPERTY GRAPH wedding >     VERTEX TABLES ( >        persons  KEY (id) PROPERTIES ALL COLUMNS >     ) >     EDGE TABLES ( >         family >             SOURCE KEY      (spouse1) REFERENCES persons (id) >             DESTINATION KEY (spouse2) REFERENCES persons (id) >         ); > ERROR:  no key specified and no suitable primary key exists for > definition > of element "family" > LINE 6:         family > > > > > > > > I checked with Oracle as well to see the behavior and i can confirm its > the same (its a standard thing, see below). > > The KEY, either explicit or implicit through the PK is used just at > graph definition time: the catalog just keeps the column numbers in the > relative graph element table (in your case, the family table). There's > no dependency kept. > > See: > > select * from pg_propgraph_element; >   oid  | pgepgid | pgerelid | pgealias | pgekind | pgesrcvertexid | > pgedestvertexid | pgekey | pgesrckey | pgesrcref | pgesrceqop | > pgedestkey | pgedestref | pgedesteqop > -------+---------+----------+----------+---------+---------------- > +-----------------+--------+-----------+-----------+------------ > +------------+------------+------------- >  25282 |   25281 |    25259 | persons  | v       |              0 | >           0 | {1}    |           |           |            | >  |            | >  25291 |   25281 |    25265 | family   | e       |          25282 | >       25282 | {1}    | {2}       | {1}       | {96}       | {3} >  | {1}        | {96} > (2 rows) > > > If a PK was used (your case), it's to deduce what columns uniquely > identify the edge table. What's required is either a KEY clause or an > existing PK on the element table. > > The standard itself doesn't mention keeping the dependency (i argue it > should); it only talks about the different cases of the graph element > table's key. Thanks for the explanation! In fact I can see in pg_get_propgraphdef() that the graph definition is correctly stored with a KEY (id). I should have checked the result of pg_dump/pg_restore, I would have probably found this explanation. Sorry for the noise. Yours, SELECT pg_get_propgraphdef ('wedding'::regclass); pg_get_propgraphdef ---------------------------------------------------------------------------------------------------------------------------------------------------------- CREATE PROPERTY GRAPH public.wedding + VERTEX TABLES ( + persons KEY (id) PROPERTIES (id, nom, sexe) + ) + EDGE TABLES ( + family KEY (id) SOURCE KEY (spouse1) REFERENCES persons (id) DESTINATION KEY (spouse2) REFERENCES persons (id) PROPERTIES (id, spouse1, spouse2)+ ) -- _________ ____ | || | Christophe Courtois | ||__ | Consultant DALIBO | | | | 43, rue du Faubourg Montmartre | - | / / 75009 Paris |___| |___| \/ www.dalibo.com