Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h7Ff4-0001Ep-0a for pgsql-bugs@arkaria.postgresql.org; Fri, 22 Mar 2019 08:36:22 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h7Ff2-0002Vt-MB for pgsql-bugs@arkaria.postgresql.org; Fri, 22 Mar 2019 08:36:20 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h7Ff2-0002Vc-CY for pgsql-bugs@lists.postgresql.org; Fri, 22 Mar 2019 08:36:20 +0000 Received: from feynman.df7cb.de ([195.49.152.168]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h7Fez-0007QZ-LJ for pgsql-bugs@lists.postgresql.org; Fri, 22 Mar 2019 08:36:19 +0000 Received: from msg.df7cb.de (unknown [IPv6:2003:5b:203b:100:7627:eaff:fe52:8e03]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by feynman.df7cb.de (Postfix) with ESMTPSA id 44QcSb2qZvz3F0Q; Fri, 22 Mar 2019 09:36:15 +0100 (CET) Date: Fri, 22 Mar 2019 09:36:14 +0100 From: Christoph Berg To: thomas@palan.at, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #15710: ADD COLUMN IF NOT EXISTS adds constraint anyways Message-ID: <20190322083614.GA32388@msg.df7cb.de> References: <15710-f52bad04543be4cb@postgresql.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <15710-f52bad04543be4cb@postgresql.org> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Re: PG Bug reporting form 2019-03-21 <15710-f52bad04543be4cb@postgresql.org> > CREATE TABLE test (id SERIAL PRIMARY KEY); > ALTER TABLE test ADD COLUMN IF NOT EXISTS new_column integer UNIQUE; As a workaround, you can name the constraint: ALTER TABLE test ADD COLUMN IF NOT EXISTS new_column integer CONSTRAINT id_unique UNIQUE; Then it won't get added multiple times. (It will still be executed once, though.) Christoph