Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fw8yN-0007w0-6M for pgsql-general@arkaria.postgresql.org; Sat, 01 Sep 2018 16:42:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fw8yK-0006mQ-R1 for pgsql-general@arkaria.postgresql.org; Sat, 01 Sep 2018 16:42:04 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fw8yJ-0006mJ-58 for pgsql-general@lists.postgresql.org; Sat, 01 Sep 2018 16:42:04 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fw8yB-0004Xb-4R for pgsql-general@lists.postgresql.org; Sat, 01 Sep 2018 16:42:02 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 1A34F21D39; Sat, 1 Sep 2018 12:41:54 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Sat, 01 Sep 2018 12:41:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=TirT+i1sN/D1eqXT1BTM9lPH1B1pl mlOmOS78Z1zbkE=; b=QvPZBl4kgdazk+tyPP0QbfSJk6ALWS1zU66a5HC11s9GR fCw+mmMpPljHVLWOhOHiPV+KXUxRD/hj7gcf6L1KNZkWb8q0tdgqZnE9gJ+guPGj uxZpVE5vJZ1Lrz4k0XDYEBiJNiljpakaG9hKzren9JYy7aeAwzfOPprLkpJBj+EZ MioRuFI8wqVExWAYUrAIzQ5vpB9U4LZwgNKpyi+2yKVpFvmJ7ME5vnLHuMfbjK6y TPaOPzjkdFcV7RPejFup0zc4SrrU5ikEwRqa343x0ii/TCnKbLKUU3vEfL1NRF65 ycAiOamadboihtcHpPPOMMuQspC7se+aBWUrIn2xA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=TirT+i 1sN/D1eqXT1BTM9lPH1B1plmlOmOS78Z1zbkE=; b=OStqvRt8s/qIPxelyA/4Oy 1US3m/d/SJ4ZTLPV4U3VvY7LGLa9/ZSDN6WxIZFS8OjEx42z80YDXajfbHlKzjXN uOlIziaSZf4QM05yKyE76IqFYWTD5oBPUU/FWj0P1XXRKqq/9oK+o/YZlE+PW6Z2 8sLlipIjnl3I2PeUKplretmDYqpXn9nEHzVSW3ovbX7XbkjkaQMcw8nD1DTc+zpK XsiyTZSZHqupEdnOlRqIkKHZtgf4UpLa85+SJfmVQaUE9LWwo1QU1vGfsVZirDY9 2vzqRfMM8GjvJXVxsr5VoHrgbP+49IiuRQihCjb+jwAWWmSPGIMQSMRs9oa6QKSw == X-ME-Proxy: X-ME-Sender: Received: from [192.168.1.3] (unknown [71.212.134.3]) by mail.messagingengine.com (Postfix) with ESMTPA id 110C710293; Sat, 1 Sep 2018 12:41:52 -0400 (EDT) Subject: Re: TR: redundant constraint_schema To: Andreas Kretschmer , pgsql-general@lists.postgresql.org References: <5b8ab54c.1c69fb81.1566e.43f0@mx.google.com> From: Adrian Klaver Message-ID: <7198a5db-7c18-47bc-0ecb-0fad67ebce59@aklaver.com> Date: Sat, 1 Sep 2018 09:41:51 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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