pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Andreas Kretschmer <andreas@a-kretschmer.de>
To: pgsql-general@lists.postgresql.org
Subject: Re: TR: redundant constraint_schema
Date: Sat, 1 Sep 2018 09:41:51 -0700
Message-ID: <7198a5db-7c18-47bc-0ecb-0fad67ebce59@aklaver.com> (raw)
In-Reply-To: <a98b774f-2646-9a20-6980-505b5b38fd75@a-kretschmer.de>
References: <5b8ab54c.1c69fb81.1566e.43f0@mx.google.com>
	<a98b774f-2646-9a20-6980-505b5b38fd75@a-kretschmer.de>

On 09/01/2018 09:27 AM, Andreas Kretschmer wrote:
> 
> 
> Am 01.09.2018 um 17:50 schrieb Olivier LeprĂȘtre:
>> I notice that a new constraint "table1_col2_fkeyxxx" is created each 
>> time the previous ALTER TABLE ADD COLUMN is called
> 
> smells like a bug.

Yeah, a quick test on a database where I have an event trigger:

create table fk_parent(col2 varchar primary key);
NOTICE:  Table public.fk_parent created
NOTICE:  caught CREATE TABLE event on 'public.fk_parent'
NOTICE:  caught CREATE INDEX event on 'public.fk_parent_pkey'


create table fk_child(col1 varchar references fk_parent(col2));
NOTICE:  Table public.fk_child created
NOTICE:  caught CREATE TABLE event on 'public.fk_child'
NOTICE:  caught ALTER TABLE event on 'public.fk_child'

\d fk_child
                    Table "public.fk_child"
  Column |       Type        | Collation | Nullable | Default
--------+-------------------+-----------+----------+---------
  col1   | character varying |           |          |
Foreign-key constraints:
     "fk_child_col1_fkey" FOREIGN KEY (col1) REFERENCES fk_parent(col2)

alter table fk_child add column if not exists col1 varchar references 
fk_parent(col2); 

NOTICE:  column "col1" of relation "fk_child" already exists, skipping 
 

NOTICE:  caught ALTER TABLE event on 'public.fk_child' 
 

ALTER TABLE

  \d fk_child
                    Table "public.fk_child" 
 

  Column |       Type        | Collation | Nullable | Default 
 

--------+-------------------+-----------+----------+--------- 
 

  col1   | character varying |           |          | 
 

Foreign-key constraints: 
 

     "fk_child_col1_fkey" FOREIGN KEY (col1) REFERENCES fk_parent(col2) 
 

     "fk_child_col1_fkey1" FOREIGN KEY (col1) REFERENCES fk_parent(col2) 



> 
> Regards, Andreas
> 


-- 
Adrian Klaver
adrian.klaver@aklaver.com




view thread (9+ messages)  latest in thread

Message-ID: <7198a5db-7c18-47bc-0ecb-0fad67ebce59@aklaver.com>
Permalink:  ../7198a5db-7c18-47bc-0ecb-0fad67ebce59@aklaver.com/
Also on:    postgresql.org/message-id/7198a5db-7c18-47bc-0ecb-0fad67ebce59@aklaver.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: adrian.klaver@aklaver.com, andreas@a-kretschmer.de
  Subject: Re: TR: redundant constraint_schema
  In-Reply-To: <7198a5db-7c18-47bc-0ecb-0fad67ebce59@aklaver.com>
  References: <5b8ab54c.1c69fb81.1566e.43f0@mx.google.com> <a98b774f-2646-9a20-6980-505b5b38fd75@a-kretschmer.de> <7198a5db-7c18-47bc-0ecb-0fad67ebce59@aklaver.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox