Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dwvzh-0006tn-CF for pgsql-bugs@arkaria.postgresql.org; Tue, 26 Sep 2017 19:58:13 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1dwvzg-0002u4-E1 for pgsql-bugs@arkaria.postgresql.org; Tue, 26 Sep 2017 19:58:12 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dwvyy-0001ed-Jj for pgsql-bugs@postgresql.org; Tue, 26 Sep 2017 19:57:28 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1dwvyv-000560-0k for pgsql-bugs@postgresql.org; Tue, 26 Sep 2017 19:57:28 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id v8QJvMJT012401; Tue, 26 Sep 2017 15:57:22 -0400 From: Tom Lane To: fabriziomello@gmail.com cc: hvisage@gmail.com, pgsql-bugs@postgresql.org Subject: Re: BUG #14827: "ALTER TABLE... IF NOT EXISTS...ADD.. BIGSERIAL" leaves extra sequences In-reply-to: References: <20170925084522.1442.32786@wrigleys.postgresql.org> Comments: In-reply-to =?UTF-8?Q?Fabr=C3=ADzio_de_Royes_Mello?= message dated "Tue, 26 Sep 2017 16:30:13 -0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <12399.1506455842.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Tue, 26 Sep 2017 15:57:22 -0400 Message-ID: <12400.1506455842@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org =3D?UTF-8?Q?Fabr=3DC3=3DADzio_de_Royes_Mello?=3D = writes: > I didn't came with better solution, but for now what I did is inside > transformaAlterTableStmt when calling transformColumnDefinition now we pa= ss > down "AlterTableStmt->missing_ok" to check and skip CREATE SEQUENCE > statements when use SERIAL pseudo-types. > It's not an elegant solution because during ATExecAddColumn we check it > again by calling check_for_column_name_collision... Ideas are very welcom= e? I do not think this is a solution at all. It doesn't address the fundamental problem that we decide whether to make a serial sequence before determining whether we're going to make a column default depending on it. What it does do is introduce a different set of failure conditions, basically race conditions around the discrepancy between parse-time and execution-time state. I don't feel like this is exactly a "must fix" problem, and it certainly isn't one that we should fix by introducing different oddities of behavior. We could maybe fix things by arranging to create the sequence only after we've made the column successfully, but that would be messy. I'm also not clear on how to document it. The documentation right now is quite clear, and accurate, about what SERIAL does: https://www.postgresql.org/docs/devel/static/datatype-numeric.html#datatype= -serial This patch falsifies that, and so would any other conditional creation of the sequence. regards, tom lane --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs