pg.ddx.io pgsql-committers@postgresql.org mailing list archive
help / color / mirror / Atom feedpgsql: Identity columns
5+ messages / 4 participants
[nested] [flat]
* pgsql: Identity columns
@ 2017-04-06 12:44 Peter Eisentraut <peter_e@gmx.net>
0 siblings, 2 replies; 5+ messages in thread
From: Peter Eisentraut @ 2017-04-06 12:44 UTC (permalink / raw)
To: pgsql-committers
Identity columns
This is the SQL standard-conforming variant of PostgreSQL's serial
columns. It fixes a few usability issues that serial columns have:
- CREATE TABLE / LIKE copies default but refers to same sequence
- cannot add/drop serialness with ALTER TABLE
- dropping default does not drop sequence
- need to grant separate privileges to sequence
- other slight weirdnesses because serial is some kind of special macro
Reviewed-by: Vitaly Burovoy <vitaly.burovoy@gmail.com>
Branch
------
master
Details
-------
http://git.postgresql.org/pg/commitdiff/3217327053638085d24dd4d276e7c1f7ac2c4c6b
Modified Files
--------------
doc/src/sgml/catalogs.sgml | 11 +
doc/src/sgml/information_schema.sgml | 11 +-
doc/src/sgml/ref/alter_table.sgml | 47 +++-
doc/src/sgml/ref/copy.sgml | 7 +
doc/src/sgml/ref/create_table.sgml | 65 ++++-
doc/src/sgml/ref/insert.sgml | 41 +++
src/backend/access/common/tupdesc.c | 6 +
src/backend/catalog/dependency.c | 7 +
src/backend/catalog/genbki.pl | 7 +-
src/backend/catalog/heap.c | 15 +-
src/backend/catalog/index.c | 1 +
src/backend/catalog/information_schema.sql | 17 +-
src/backend/catalog/pg_depend.c | 52 ++--
src/backend/catalog/sql_features.txt | 12 +-
src/backend/commands/sequence.c | 101 +++++--
src/backend/commands/tablecmds.c | 295 ++++++++++++++++++-
src/backend/executor/execExpr.c | 12 +
src/backend/executor/execExprInterp.c | 23 ++
src/backend/nodes/copyfuncs.c | 23 ++
src/backend/nodes/equalfuncs.c | 18 ++
src/backend/nodes/nodeFuncs.c | 11 +
src/backend/nodes/outfuncs.c | 9 +
src/backend/nodes/readfuncs.c | 1 +
src/backend/parser/analyze.c | 2 +
src/backend/parser/gram.y | 134 ++++++++-
src/backend/parser/parse_utilcmd.c | 360 +++++++++++++++++++-----
src/backend/rewrite/rewriteHandler.c | 56 +++-
src/backend/utils/adt/ruleutils.c | 8 +
src/backend/utils/cache/lsyscache.c | 32 +++
src/backend/utils/cache/relcache.c | 1 +
src/backend/utils/errcodes.txt | 1 +
src/bin/pg_dump/pg_dump.c | 95 ++++++-
src/bin/pg_dump/pg_dump.h | 3 +
src/bin/pg_dump/t/002_pg_dump.pl | 87 ++++++
src/bin/psql/describe.c | 27 +-
src/bin/psql/tab-complete.c | 18 +-
src/include/catalog/catversion.h | 2 +-
src/include/catalog/dependency.h | 8 +-
src/include/catalog/pg_attribute.h | 24 +-
src/include/catalog/pg_class.h | 2 +-
src/include/commands/sequence.h | 2 +
src/include/executor/execExpr.h | 8 +
src/include/nodes/nodes.h | 1 +
src/include/nodes/parsenodes.h | 27 +-
src/include/nodes/primnodes.h | 14 +
src/include/parser/kwlist.h | 2 +
src/include/utils/lsyscache.h | 1 +
src/test/regress/expected/create_table_like.out | 47 ++++
src/test/regress/expected/identity.out | 322 +++++++++++++++++++++
src/test/regress/expected/sequence.out | 4 +-
src/test/regress/expected/truncate.out | 30 ++
src/test/regress/parallel_schedule | 5 +
src/test/regress/serial_schedule | 1 +
src/test/regress/sql/create_table_like.sql | 14 +
src/test/regress/sql/identity.sql | 192 +++++++++++++
src/test/regress/sql/sequence.sql | 2 +-
src/test/regress/sql/truncate.sql | 18 ++
57 files changed, 2140 insertions(+), 202 deletions(-)
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: pgsql: Identity columns
@ 2017-04-06 14:24 Tom Lane <tgl@sss.pgh.pa.us>
parent: Peter Eisentraut <peter_e@gmx.net>
1 sibling, 1 reply; 5+ messages in thread
From: Tom Lane @ 2017-04-06 14:24 UTC (permalink / raw)
To: Peter Eisentraut <peter_e@gmx.net>; +Cc: pgsql-committers
Peter Eisentraut <peter_e@gmx.net> writes:
> Identity columns
This commit is causing a compiler warning for me:
tablecmds.c: In function 'ATExecSetIdentity':
tablecmds.c:5936: warning: 'address.objectSubId' may be used uninitialized in this function
tablecmds.c:5936: warning: 'address.objectId' may be used uninitialized in this function
I'm not sure why it's not complaining about all three fields, because
AFAICS, the function returns a totally undefined ObjectAddress when
generatedEl is not set. What is the intention there? (If the function
were adequately documented, maybe I could divine that for myself, but
heaven help the reader who would like to know what this function is
supposed to do.)
regards, tom lane
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: pgsql: Identity columns
@ 2017-04-06 15:19 Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
parent: Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 5+ messages in thread
From: Peter Eisentraut @ 2017-04-06 15:19 UTC (permalink / raw)
To: Tom Lane <tgl@sss.pgh.pa.us>; +Cc: pgsql-committers
On 4/6/17 10:24, Tom Lane wrote:
> This commit is causing a compiler warning for me:
>
> tablecmds.c: In function 'ATExecSetIdentity':
> tablecmds.c:5936: warning: 'address.objectSubId' may be used uninitialized in this function
> tablecmds.c:5936: warning: 'address.objectId' may be used uninitialized in this function
>
> I'm not sure why it's not complaining about all three fields, because
> AFAICS, the function returns a totally undefined ObjectAddress when
> generatedEl is not set.
Yeah, that was an oversight. It's depressing that not more compilers
warn about an obvious case like this. I have pushed a fix.
> What is the intention there? (If the function
> were adequately documented, maybe I could divine that for myself, but
> heaven help the reader who would like to know what this function is
> supposed to do.)
Added some comments, too.
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: pgsql: Identity columns
@ 2017-04-07 03:13 David Rowley <david.rowley@2ndquadrant.com>
parent: Peter Eisentraut <peter_e@gmx.net>
1 sibling, 1 reply; 5+ messages in thread
From: David Rowley @ 2017-04-07 03:13 UTC (permalink / raw)
To: Peter Eisentraut <peter_e@gmx.net>; +Cc: pgsql-committers
On 7 April 2017 at 00:44, Peter Eisentraut <peter_e@gmx.net> wrote:
> Identity columns
>
> This is the SQL standard-conforming variant of PostgreSQL's serial
> columns. It fixes a few usability issues that serial columns have:
>
> - CREATE TABLE / LIKE copies default but refers to same sequence
> - cannot add/drop serialness with ALTER TABLE
> - dropping default does not drop sequence
> - need to grant separate privileges to sequence
> - other slight weirdnesses because serial is some kind of special macro
Attached is a small patch which fixes up a warning for compilers not
smart enough to know the elog(ERROR) does not return.
--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
Attachments:
identity_columns_warning_fix.patch (application/octet-stream, 690B) download
diff --git a/src/backend/catalog/pg_depend.c b/src/backend/catalog/pg_depend.c
index aae879e..0a3edfc 100644
--- a/src/backend/catalog/pg_depend.c
+++ b/src/backend/catalog/pg_depend.c
@@ -606,12 +606,14 @@ getOwnedSequence(Oid relid, AttrNumber attnum)
{
List *seqlist = getOwnedSequences(relid, attnum);
+ if (list_length(seqlist) == 1)
+ return linitial_oid(seqlist);
+
if (list_length(seqlist) > 1)
elog(ERROR, "more than one owned sequence found");
- else if (list_length(seqlist) < 1)
- elog(ERROR, "no owned sequence found");
- else
- return linitial_oid(seqlist);
+
+ elog(ERROR, "no owned sequence found");
+ return InvalidOid; /* keep compiler quiet */
}
/*
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: pgsql: Identity columns
@ 2017-04-07 21:39 Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
parent: David Rowley <david.rowley@2ndquadrant.com>
0 siblings, 0 replies; 5+ messages in thread
From: Peter Eisentraut @ 2017-04-07 21:39 UTC (permalink / raw)
To: David Rowley <david.rowley@2ndquadrant.com>; +Cc: pgsql-committers
On 4/6/17 23:13, David Rowley wrote:
> On 7 April 2017 at 00:44, Peter Eisentraut <peter_e@gmx.net> wrote:
>> Identity columns
>>
>> This is the SQL standard-conforming variant of PostgreSQL's serial
>> columns. It fixes a few usability issues that serial columns have:
>>
>> - CREATE TABLE / LIKE copies default but refers to same sequence
>> - cannot add/drop serialness with ALTER TABLE
>> - dropping default does not drop sequence
>> - need to grant separate privileges to sequence
>> - other slight weirdnesses because serial is some kind of special macro
>
> Attached is a small patch which fixes up a warning for compilers not
> smart enough to know the elog(ERROR) does not return.
fixed
--
Peter Eisentraut http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
--
Sent via pgsql-committers mailing list (pgsql-committers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-committers
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2017-04-07 21:39 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2017-04-06 12:44 pgsql: Identity columns Peter Eisentraut <peter_e@gmx.net>
2017-04-06 14:24 ` Tom Lane <tgl@sss.pgh.pa.us>
2017-04-06 15:19 ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
2017-04-07 03:13 ` David Rowley <david.rowley@2ndquadrant.com>
2017-04-07 21:39 ` Peter Eisentraut <peter.eisentraut@2ndquadrant.com>
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