pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: hvisage@gmail.com
To: pgsql-bugs@postgresql.org
Cc: hvisage@gmail.com
Subject: BUG #14827: "ALTER TABLE... IF NOT EXISTS...ADD.. BIGSERIAL" leaves extra sequences
Date: Mon, 25 Sep 2017 08:45:22 +0000
Message-ID: <20170925084522.1442.32786@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

The following bug has been logged on the website:

Bug reference:      14827
Logged by:          Hendrik Visage
Email address:      hvisage@gmail.com
PostgreSQL version: 9.6.5
Operating system:   Debian 9
Description:        

Goodday,
 With an alter table to add an UID field if it doesn't exist, the process
creates a sequence, but when the column does exist, the created sequence,
that isn't used, is just left there, and subsequent runs keeps adding extra
sequences.

postgres@tracsdbhvt01:~$ cat test-serial.sql
create database test;
\c test
create table test_serial ( teststring varchar(5));
alter table test_serial add column if not exists uid BIGSERIAL;
alter table test_serial add column if not exists uid BIGSERIAL;
\d
\d test_serial
postgres@tracsdbhvt01:~$ psql -p 5433 < test-serial.sql
CREATE DATABASE
You are now connected to database "test" as user "postgres".
CREATE TABLE
ALTER TABLE
NOTICE:  column "uid" of relation "test_serial" already exists, skipping
ALTER TABLE
                  List of relations
 Schema |         Name         |   Type   |  Owner
--------+----------------------+----------+----------
 public | test_serial          | table    | postgres
 public | test_serial_uid_seq  | sequence | postgres
 public | test_serial_uid_seq1 | sequence | postgres
(3 rows)

                                  Table "public.test_serial"
   Column   |         Type         |                         Modifiers
------------+----------------------+-----------------------------------------------------------
 teststring | character varying(5) |
 uid        | bigint               | not null default
nextval('test_serial_uid_seq'::regclass)

postgres@tracsdbhvt01:~$



-- 
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: <20170925084522.1442.32786@wrigleys.postgresql.org>
Permalink:  ../20170925084522.1442.32786@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/20170925084522.1442.32786@wrigleys.postgresql.org

 · 

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: hvisage@gmail.com
  Subject: Re: BUG #14827: "ALTER TABLE... IF NOT EXISTS...ADD.. BIGSERIAL" leaves extra sequences
  In-Reply-To: <20170925084522.1442.32786@wrigleys.postgresql.org>
  References: <20170925084522.1442.32786@wrigleys.postgresql.org>

* 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