From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Ken Tanzer <ken.tanzer@gmail.com>
Cc: Rich Shepard <rshepard@appl-ecosys.com>
Cc: pgsql-generallists.postgresql.org <pgsql-general@lists.postgresql.org>
Subject: Re: Primary key data type: integer vs identity
Date: Fri, 19 Apr 2019 12:50:38 -0700
Message-ID: <2752f2d1-2cec-1df4-21f7-b0b004f8e500@aklaver.com> (raw)
In-Reply-To: <CAD3a31UV8VxLWLFfDop4W_PUyMrKf6RGsQF7XkpdpV3Xc=sARw@mail.gmail.com>
References: <alpine.LNX.2.20.1904191050120.24219@salmo.appl-ecosys.com>
<c1df337c-8819-711b-496e-459e7fb88408@aklaver.com>
<alpine.LNX.2.20.1904191112120.24219@salmo.appl-ecosys.com>
<b0da4cc6-be57-ddaf-f762-ac4455569417@aklaver.com>
<CAD3a31VyBMjZUM7aXLfCEdkP_gQ4Agw9-vMFm6nB_eV7sOa3OA@mail.gmail.com>
<4d387c8e-a261-0734-a10f-dfde7ce538f0@aklaver.com>
<CAD3a31UV8VxLWLFfDop4W_PUyMrKf6RGsQF7XkpdpV3Xc=sARw@mail.gmail.com>
On 4/19/19 12:35 PM, Ken Tanzer wrote:
>
> Thanks Adrian. You are as usual correct. (I had a bunch of tables
> created by a function that I assumed were serial, but were not.)
> Identity columns still seem tidier and more manageable. Can you tell if
> the function I referenced would change the ownership or not?
I believe in 'when it doubt try it, whats the worst that can happen?:)':
<NOTE> I needed to be a superuser to run due to this:
ERROR: permission denied for table pg_depend
CONTEXT: SQL statement "UPDATE pg_depend
SET deptype = 'i'
WHERE (classid, objid, objsubid) = ('pg_class'::regclass, seqid, 0)
AND deptype = 'a'"
PL/pgSQL function upgrade_serial_to_identity(regclass,name) line 31 at
SQL statement
test=# create table serial_test(id serial, fld_1 text);
CREATE TABLE
test=# \dp serial_test
Access privileges
Schema | Name | Type | Access privileges | Column privileges |
Policies
--------+-------------+-------+-------------------+-------------------+----------
public | serial_test | table | | |
(1 row)
test=# select upgrade_serial_to_identity('serial_test', 'id');
upgrade_serial_to_identity
----------------------------
(1 row)
test=# \d serial_test
Table "public.serial_test"
Column | Type | Collation | Nullable | Default
--------+---------+-----------+----------+----------------------------------
id | integer | | not null | generated by default as identity
fld_1 | text | | |
test=# \dp+ serial_test
Access privileges
Schema | Name | Type | Access privileges | Column privileges |
Policies
--------+-------------+-------+-------------------+-------------------+----------
public | serial_test | table | | |
(1 row)
>
> Cheers,
> Ken
>
--
Adrian Klaver
adrian.klaver@aklaver.com
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-general@postgresql.org
Cc: adrian.klaver@aklaver.com, ken.tanzer@gmail.com, rshepard@appl-ecosys.com
Subject: Re: Primary key data type: integer vs identity
In-Reply-To: <2752f2d1-2cec-1df4-21f7-b0b004f8e500@aklaver.com>
References: <alpine.LNX.2.20.1904191050120.24219@salmo.appl-ecosys.com> <c1df337c-8819-711b-496e-459e7fb88408@aklaver.com> <alpine.LNX.2.20.1904191112120.24219@salmo.appl-ecosys.com> <b0da4cc6-be57-ddaf-f762-ac4455569417@aklaver.com> <CAD3a31VyBMjZUM7aXLfCEdkP_gQ4Agw9-vMFm6nB_eV7sOa3OA@mail.gmail.com> <4d387c8e-a261-0734-a10f-dfde7ce538f0@aklaver.com> <CAD3a31UV8VxLWLFfDop4W_PUyMrKf6RGsQF7XkpdpV3Xc=sARw@mail.gmail.com> <2752f2d1-2cec-1df4-21f7-b0b004f8e500@aklaver.com>
* 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