pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: fabriziomello@gmail.com
Cc: hvisage@gmail.com
Cc: pgsql-bugs@postgresql.org
Subject: Re: BUG #14827: "ALTER TABLE... IF NOT EXISTS...ADD.. BIGSERIAL" leaves extra sequences
Date: Tue, 26 Sep 2017 15:57:22 -0400
Message-ID: <12400.1506455842@sss.pgh.pa.us> (raw)
In-Reply-To: <CAFcNs+o6j69NkY4uYNaxNJVQ9Oe7Sz-3Gg5FDz_WApeZG5rOjQ@mail.gmail.com>
References: <20170925084522.1442.32786@wrigleys.postgresql.org>
	<CAFcNs+qk1voEB7XO=OViFhD6ATopWJ2MXHd9W4RZ6DgTyL8eeA@mail.gmail.com>
	<CAFcNs+o6j69NkY4uYNaxNJVQ9Oe7Sz-3Gg5FDz_WApeZG5rOjQ@mail.gmail.com>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

=?UTF-8?Q?Fabr=C3=ADzio_de_Royes_Mello?= <fabriziomello@gmail.com> writes:
> I didn't came with better solution, but for now what I did is inside
> transformaAlterTableStmt when calling transformColumnDefinition now we pass
> 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 welcome?

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


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (8+ messages)  latest in thread

Message-ID: <12400.1506455842@sss.pgh.pa.us>
Permalink:  ../12400.1506455842@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/12400.1506455842@sss.pgh.pa.us

 · 

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-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, fabriziomello@gmail.com, hvisage@gmail.com
  Subject: Re: BUG #14827: "ALTER TABLE... IF NOT EXISTS...ADD.. BIGSERIAL" leaves extra sequences
  In-Reply-To: <12400.1506455842@sss.pgh.pa.us>
  References: <20170925084522.1442.32786@wrigleys.postgresql.org> <CAFcNs+qk1voEB7XO=OViFhD6ATopWJ2MXHd9W4RZ6DgTyL8eeA@mail.gmail.com> <CAFcNs+o6j69NkY4uYNaxNJVQ9Oe7Sz-3Gg5FDz_WApeZG5rOjQ@mail.gmail.com> <12400.1506455842@sss.pgh.pa.us>

* 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