On 04.10.22 09:41, Peter Eisentraut wrote:
Attached is a demo patch how the implementation of this change would look like. This creates a bunch of regression test failures, but AFAICT, those are mainly display differences and some very peculiar test setups that are intentionally examining some edge cases. These would need to be investigated in more detail, of course.
The feedback was pretty positive, so I dug through all the tests to at least get to the point where I could see the end of it. The attached patch 0001 is the actual code and documentation changes. The 0002 patch is just tests randomly updated or disabled to make the whole suite pass. This reveals that there are a few things that would warrant further investigation, in particular around extensions and partitioning. To be continued.
From c3c322c277e58205b7074bbc504f94029f98a0bd Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <pe...@eisentraut.org> Date: Tue, 11 Oct 2022 08:24:34 +0200 Subject: [PATCH v2 1/2] WIP: Change serial types to map to identity columns This changes serial types to convert internally to identity columns, instead of the custom construction involving nextval defaults that they previously did. --- contrib/test_decoding/expected/ddl.out | 50 ++++++------- doc/src/sgml/datatype.sgml | 37 +++------ doc/src/sgml/extend.sgml | 10 +-- doc/src/sgml/func.sgml | 12 +-- src/backend/parser/parse_utilcmd.c | 75 +++---------------- src/test/regress/expected/publication.out | 30 ++++---- .../regress/expected/replica_identity.out | 30 ++++---- 7 files changed, 80 insertions(+), 164 deletions(-) diff --git a/contrib/test_decoding/expected/ddl.out b/contrib/test_decoding/expected/ddl.out index 9a28b5ddc5aa..9363d140d2af 100644 --- a/contrib/test_decoding/expected/ddl.out +++ b/contrib/test_decoding/expected/ddl.out @@ -484,12 +484,12 @@ CREATE TABLE replication_metadata ( WITH (user_catalog_table = true) ; \d+ replication_metadata - Table "public.replication_metadata" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description -----------+---------+-----------+----------+--------------------------------------------------+----------+--------------+------------- - id | integer | | not null | nextval('replication_metadata_id_seq'::regclass) | plain | | - relation | name | | not null | | plain | | - options | text[] | | | | extended | | + Table "public.replication_metadata" + Column | Type | Collation | Nullable | Default | Storage | Stats target | Description +----------+---------+-----------+----------+----------------------------------+----------+--------------+------------- + id | integer | | not null | generated by default as identity | plain | | + relation | name | | not null | | plain | | + options | text[] | | | | extended | | Indexes: "replication_metadata_pkey" PRIMARY KEY, btree (id) Options: user_catalog_table=true @@ -498,12 +498,12 @@ INSERT INTO replication_metadata(relation, options) VALUES ('foo', ARRAY['a', 'b']); ALTER TABLE replication_metadata RESET (user_catalog_table); \d+ replication_metadata - Table "public.replication_metadata" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description -----------+---------+-----------+----------+--------------------------------------------------+----------+--------------+------------- - id | integer | | not null | nextval('replication_metadata_id_seq'::regclass) | plain | | - relation | name | | not null | | plain | | - options | text[] | | | | extended | | + Table "public.replication_metadata" + Column | Type | Collation | Nullable | Default | Storage | Stats target | Description +----------+---------+-----------+----------+----------------------------------+----------+--------------+------------- + id | integer | | not null | generated by default as identity | plain | | + relation | name | | not null | | plain | | + options | text[] | | | | extended | | Indexes: "replication_metadata_pkey" PRIMARY KEY, btree (id) @@ -511,12 +511,12 @@ INSERT INTO replication_metadata(relation, options) VALUES ('bar', ARRAY['a', 'b']); ALTER TABLE replication_metadata SET (user_catalog_table = true); \d+ replication_metadata - Table "public.replication_metadata" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description -----------+---------+-----------+----------+--------------------------------------------------+----------+--------------+------------- - id | integer | | not null | nextval('replication_metadata_id_seq'::regclass) | plain | | - relation | name | | not null | | plain | | - options | text[] | | | | extended | | + Table "public.replication_metadata" + Column | Type | Collation | Nullable | Default | Storage | Stats target | Description +----------+---------+-----------+----------+----------------------------------+----------+--------------+------------- + id | integer | | not null | generated by default as identity | plain | | + relation | name | | not null | | plain | | + options | text[] | | | | extended | | Indexes: "replication_metadata_pkey" PRIMARY KEY, btree (id) Options: user_catalog_table=true @@ -529,13 +529,13 @@ ALTER TABLE replication_metadata ALTER COLUMN rewritemeornot TYPE text; ERROR: cannot rewrite table "replication_metadata" used as a catalog table ALTER TABLE replication_metadata SET (user_catalog_table = false); \d+ replication_metadata - Table "public.replication_metadata" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description -----------------+---------+-----------+----------+--------------------------------------------------+----------+--------------+------------- - id | integer | | not null | nextval('replication_metadata_id_seq'::regclass) | plain | | - relation | name | | not null | | plain | | - options | text[] | | | | extended | | - rewritemeornot | integer | | | | plain | | + Table "public.replication_metadata" + Column | Type | Collation | Nullable | Default | Storage | Stats target | Description +----------------+---------+-----------+----------+----------------------------------+----------+--------------+------------- + id | integer | | not null | generated by default as identity | plain | | + relation | name | | not null | | plain | | + options | text[] | | | | extended | | + rewritemeornot | integer | | | | plain | | Indexes: "replication_metadata_pkey" PRIMARY KEY, btree (id) Options: user_catalog_table=false diff --git a/doc/src/sgml/datatype.sgml b/doc/src/sgml/datatype.sgml index b030b36002f4..7c5c0a002c24 100644 --- a/doc/src/sgml/datatype.sgml +++ b/doc/src/sgml/datatype.sgml @@ -951,21 +951,11 @@ <title>Serial Types</title> <secondary>and serial type</secondary> </indexterm> - <note> - <para> - This section describes a PostgreSQL-specific way to create an - autoincrementing column. Another way is to use the SQL-standard - identity column feature, described at <xref linkend="sql-createtable"/>. - </para> - </note> - <para> The data types <type>smallserial</type>, <type>serial</type> and <type>bigserial</type> are not true types, but merely - a notational convenience for creating unique identifier columns - (similar to the <literal>AUTO_INCREMENT</literal> property - supported by some other databases). In the current - implementation, specifying: + a notational convenience for creating unique identifier columns. + In the current implementation, specifying: <programlisting> CREATE TABLE <replaceable class="parameter">tablename</replaceable> ( @@ -976,21 +966,17 @@ <title>Serial Types</title> is equivalent to specifying: <programlisting> -CREATE SEQUENCE <replaceable class="parameter">tablename</replaceable>_<replaceable class="parameter">colname</replaceable>_seq AS integer; CREATE TABLE <replaceable class="parameter">tablename</replaceable> ( - <replaceable class="parameter">colname</replaceable> integer NOT NULL DEFAULT nextval('<replaceable class="parameter">tablename</replaceable>_<replaceable class="parameter">colname</replaceable>_seq') + <replaceable class="parameter">colname</replaceable> integer GENERATED BY DEFAULT AS IDENTITY ); -ALTER SEQUENCE <replaceable class="parameter">tablename</replaceable>_<replaceable class="parameter">colname</replaceable>_seq OWNED BY <replaceable class="parameter">tablename</replaceable>.<replaceable class="parameter">colname</replaceable>; </programlisting> - Thus, we have created an integer column and arranged for its default - values to be assigned from a sequence generator. A <literal>NOT NULL</literal> - constraint is applied to ensure that a null value cannot be - inserted. (In most cases you would also want to attach a - <literal>UNIQUE</literal> or <literal>PRIMARY KEY</literal> constraint to prevent - duplicate values from being inserted by accident, but this is - not automatic.) Lastly, the sequence is marked as <quote>owned by</quote> - the column, so that it will be dropped if the column or table is dropped. + Thus, we have created an integer column and arranged for its values to be + assigned from a sequence generator by default. (In most cases you would + also want to attach a <literal>UNIQUE</literal> or <literal>PRIMARY + KEY</literal> constraint to prevent duplicate values from being inserted + by accident, but this is not automatic.) See <xref + linkend="sql-createtable"/> for more details about this syntax. </para> <note> @@ -1031,8 +1017,9 @@ <title>Serial Types</title> <para> The sequence created for a <type>serial</type> column is automatically dropped when the owning column is dropped. - You can drop the sequence without dropping the column, but this - will force removal of the column default expression. + You cannot drop the sequence directly, but this can be done using the + command <literal>ALTER TABLE ... ALTER COLUMN .... DROP + IDENTITY</literal>. </para> </sect2> </sect1> diff --git a/doc/src/sgml/extend.sgml b/doc/src/sgml/extend.sgml index 46e873a1661b..d0b0d42c776a 100644 --- a/doc/src/sgml/extend.sgml +++ b/doc/src/sgml/extend.sgml @@ -1003,9 +1003,7 @@ <title>Extension Configuration Tables</title> SELECT pg_catalog.pg_extension_config_dump('my_config', ''); SELECT pg_catalog.pg_extension_config_dump('my_config_seq', ''); </programlisting> - Any number of tables or sequences can be marked this way. Sequences - associated with <type>serial</type> or <type>bigserial</type> columns can - be marked as well. + Any number of tables or sequences can be marked this way. </para> <para> @@ -1055,12 +1053,6 @@ <title>Extension Configuration Tables</title> out but the dump will not be able to be restored directly and user intervention will be required. </para> - - <para> - Sequences associated with <type>serial</type> or <type>bigserial</type> columns - need to be directly marked to dump their state. Marking their parent - relation is not enough for this purpose. - </para> </sect2> <sect2> diff --git a/doc/src/sgml/func.sgml b/doc/src/sgml/func.sgml index b2bdbc7d1ccd..15e22867cd02 100644 --- a/doc/src/sgml/func.sgml +++ b/doc/src/sgml/func.sgml @@ -23746,15 +23746,9 @@ <title>System Catalog Information Functions</title> or NULL if no sequence is associated with the column. If the column is an identity column, the associated sequence is the sequence internally created for that column. - For columns created using one of the serial types - (<type>serial</type>, <type>smallserial</type>, <type>bigserial</type>), - it is the sequence created for that serial column definition. - In the latter case, the association can be modified or removed - with <command>ALTER SEQUENCE OWNED BY</command>. - (This function probably should have been - called <function>pg_get_owned_sequence</function>; its current name - reflects the fact that it has historically been used with serial-type - columns.) The first parameter is a table name with optional + For sequences associated with a column by with <command>ALTER SEQUENCE + OWNED BY</command>, it is that sequence. + The first parameter is a table name with optional schema, and the second parameter is a column name. Because the first parameter potentially contains both schema and table names, it is parsed per usual SQL rules, meaning it is lower-cased by default. diff --git a/src/backend/parser/parse_utilcmd.c b/src/backend/parser/parse_utilcmd.c index bd068bba05e4..f29a48060755 100644 --- a/src/backend/parser/parse_utilcmd.c +++ b/src/backend/parser/parse_utilcmd.c @@ -361,15 +361,12 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString) * Generate CREATE SEQUENCE and ALTER SEQUENCE ... OWNED BY statements * to create the sequence for a serial or identity column. * - * This includes determining the name the sequence will have. The caller - * can ask to get back the name components by passing non-null pointers - * for snamespace_p and sname_p. + * This includes determining the name the sequence will have. */ static void generateSerialExtraStmts(CreateStmtContext *cxt, ColumnDef *column, Oid seqtypid, List *seqoptions, - bool for_identity, bool col_exists, - char **snamespace_p, char **sname_p) + bool col_exists) { ListCell *option; DefElem *nameEl = NULL; @@ -453,7 +450,7 @@ generateSerialExtraStmts(CreateStmtContext *cxt, ColumnDef *column, * it to the list of things to be done before this CREATE/ALTER TABLE. */ seqstmt = makeNode(CreateSeqStmt); - seqstmt->for_identity = for_identity; + seqstmt->for_identity = true; seqstmt->sequence = makeRangeVar(snamespace, sname, -1); seqstmt->sequence->relpersistence = cxt->relation->relpersistence; seqstmt->options = seqoptions; @@ -508,17 +505,12 @@ generateSerialExtraStmts(CreateStmtContext *cxt, ColumnDef *column, makeString(column->colname)); altseqstmt->options = list_make1(makeDefElem("owned_by", (Node *) attnamelist, -1)); - altseqstmt->for_identity = for_identity; + altseqstmt->for_identity = true; if (col_exists) cxt->blist = lappend(cxt->blist, altseqstmt); else cxt->alist = lappend(cxt->alist, altseqstmt); - - if (snamespace_p) - *snamespace_p = snamespace; - if (sname_p) - *sname_p = sname; } /* @@ -588,51 +580,11 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column) /* Special actions for SERIAL pseudo-types */ if (is_serial) { - char *snamespace; - char *sname; - char *qstring; - A_Const *snamenode; - TypeCast *castnode; - FuncCall *funccallnode; Constraint *constraint; - generateSerialExtraStmts(cxt, column, - column->typeName->typeOid, NIL, - false, false, - &snamespace, &sname); - - /* - * Create appropriate constraints for SERIAL. We do this in full, - * rather than shortcutting, so that we will detect any conflicting - * constraints the user wrote (like a different DEFAULT). - * - * Create an expression tree representing the function call - * nextval('sequencename'). We cannot reduce the raw tree to cooked - * form until after the sequence is created, but there's no need to do - * so. - */ - qstring = quote_qualified_identifier(snamespace, sname); - snamenode = makeNode(A_Const); - snamenode->val.node.type = T_String; - snamenode->val.sval.sval = qstring; - snamenode->location = -1; - castnode = makeNode(TypeCast); - castnode->typeName = SystemTypeName("regclass"); - castnode->arg = (Node *) snamenode; - castnode->location = -1; - funccallnode = makeFuncCall(SystemFuncName("nextval"), - list_make1(castnode), - COERCE_EXPLICIT_CALL, - -1); - constraint = makeNode(Constraint); - constraint->contype = CONSTR_DEFAULT; - constraint->location = -1; - constraint->raw_expr = (Node *) funccallnode; - constraint->cooked_expr = NULL; - column->constraints = lappend(column->constraints, constraint); - constraint = makeNode(Constraint); - constraint->contype = CONSTR_NOTNULL; + constraint->contype = CONSTR_IDENTITY; + constraint->generated_when = ATTRIBUTE_IDENTITY_BY_DEFAULT; constraint->location = -1; column->constraints = lappend(column->constraints, constraint); } @@ -714,10 +666,7 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column) parser_errposition(cxt->pstate, constraint->location))); - generateSerialExtraStmts(cxt, column, - typeOid, constraint->options, - true, false, - NULL, NULL); + generateSerialExtraStmts(cxt, column, typeOid, constraint->options, false); column->identity = constraint->generated_when; saw_identity = true; @@ -1082,10 +1031,7 @@ transformTableLikeClause(CreateStmtContext *cxt, TableLikeClause *table_like_cla */ seq_relid = getIdentitySequence(RelationGetRelid(relation), attribute->attnum, false); seq_options = sequence_options(seq_relid); - generateSerialExtraStmts(cxt, def, - InvalidOid, seq_options, - true, false, - NULL, NULL); + generateSerialExtraStmts(cxt, def, InvalidOid, seq_options, false); def->identity = attribute->attidentity; } @@ -3468,10 +3414,7 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt, errmsg("column \"%s\" of relation \"%s\" does not exist", cmd->name, RelationGetRelationName(rel)))); - generateSerialExtraStmts(&cxt, newdef, - get_atttype(relid, attnum), - def->options, true, true, - NULL, NULL); + generateSerialExtraStmts(&cxt, newdef, get_atttype(relid, attnum), def->options, true); newcmds = lappend(newcmds, cmd); break; diff --git a/src/test/regress/expected/publication.out b/src/test/regress/expected/publication.out index 427f87ea0771..0011f8e2e3c3 100644 --- a/src/test/regress/expected/publication.out +++ b/src/test/regress/expected/publication.out @@ -175,11 +175,11 @@ SELECT pubname, puballtables FROM pg_publication WHERE pubname = 'testpub_forall (1 row) \d+ testpub_tbl2 - Table "public.testpub_tbl2" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+---------+-----------+----------+------------------------------------------+----------+--------------+------------- - id | integer | | not null | nextval('testpub_tbl2_id_seq'::regclass) | plain | | - data | text | | | | extended | | + Table "public.testpub_tbl2" + Column | Type | Collation | Nullable | Default | Storage | Stats target | Description +--------+---------+-----------+----------+----------------------------------+----------+--------------+------------- + id | integer | | not null | generated by default as identity | plain | | + data | text | | | | extended | | Indexes: "testpub_tbl2_pkey" PRIMARY KEY, btree (id) Publications: @@ -1127,11 +1127,11 @@ Publications: "testpub_fortbl" \d+ testpub_tbl1 - Table "public.testpub_tbl1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+---------+-----------+----------+------------------------------------------+----------+--------------+------------- - id | integer | | not null | nextval('testpub_tbl1_id_seq'::regclass) | plain | | - data | text | | | | extended | | + Table "public.testpub_tbl1" + Column | Type | Collation | Nullable | Default | Storage | Stats target | Description +--------+---------+-----------+----------+----------------------------------+----------+--------------+------------- + id | integer | | not null | generated by default as identity | plain | | + data | text | | | | extended | | Indexes: "testpub_tbl1_pkey" PRIMARY KEY, btree (id) Publications: @@ -1153,11 +1153,11 @@ ALTER PUBLICATION testpub_default DROP TABLE testpub_tbl1, pub_test.testpub_nopk ALTER PUBLICATION testpub_default DROP TABLE pub_test.testpub_nopk; ERROR: relation "testpub_nopk" is not part of the publication \d+ testpub_tbl1 - Table "public.testpub_tbl1" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+---------+-----------+----------+------------------------------------------+----------+--------------+------------- - id | integer | | not null | nextval('testpub_tbl1_id_seq'::regclass) | plain | | - data | text | | | | extended | | + Table "public.testpub_tbl1" + Column | Type | Collation | Nullable | Default | Storage | Stats target | Description +--------+---------+-----------+----------+----------------------------------+----------+--------------+------------- + id | integer | | not null | generated by default as identity | plain | | + data | text | | | | extended | | Indexes: "testpub_tbl1_pkey" PRIMARY KEY, btree (id) Publications: diff --git a/src/test/regress/expected/replica_identity.out b/src/test/regress/expected/replica_identity.out index e25ec06a8424..15cebeab62d6 100644 --- a/src/test/regress/expected/replica_identity.out +++ b/src/test/regress/expected/replica_identity.out @@ -75,10 +75,10 @@ SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass; (1 row) \d test_replica_identity - Table "public.test_replica_identity" - Column | Type | Collation | Nullable | Default ---------+---------+-----------+----------+--------------------------------------------------- - id | integer | | not null | nextval('test_replica_identity_id_seq'::regclass) + Table "public.test_replica_identity" + Column | Type | Collation | Nullable | Default +--------+---------+-----------+----------+---------------------------------- + id | integer | | not null | generated by default as identity keya | text | | not null | keyb | text | | not null | nonkey | text | | | @@ -105,10 +105,10 @@ SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass; (1 row) \d test_replica_identity - Table "public.test_replica_identity" - Column | Type | Collation | Nullable | Default ---------+---------+-----------+----------+--------------------------------------------------- - id | integer | | not null | nextval('test_replica_identity_id_seq'::regclass) + Table "public.test_replica_identity" + Column | Type | Collation | Nullable | Default +--------+---------+-----------+----------+---------------------------------- + id | integer | | not null | generated by default as identity keya | text | | not null | keyb | text | | not null | nonkey | text | | | @@ -153,13 +153,13 @@ SELECT relreplident FROM pg_class WHERE oid = 'test_replica_identity'::regclass; (1 row) \d+ test_replica_identity - Table "public.test_replica_identity" - Column | Type | Collation | Nullable | Default | Storage | Stats target | Description ---------+---------+-----------+----------+---------------------------------------------------+----------+--------------+------------- - id | integer | | not null | nextval('test_replica_identity_id_seq'::regclass) | plain | | - keya | text | | not null | | extended | | - keyb | text | | not null | | extended | | - nonkey | text | | | | extended | | + Table "public.test_replica_identity" + Column | Type | Collation | Nullable | Default | Storage | Stats target | Description +--------+---------+-----------+----------+----------------------------------+----------+--------------+------------- + id | integer | | not null | generated by default as identity | plain | | + keya | text | | not null | | extended | | + keyb | text | | not null | | extended | | + nonkey | text | | | | extended | | Indexes: "test_replica_identity_pkey" PRIMARY KEY, btree (id) "test_replica_identity_expr" UNIQUE, btree (keya, keyb, (3)) -- 2.37.3
From b077112e86af3a9afcfb818f4fd680751e44fe33 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <pe...@eisentraut.org> Date: Tue, 11 Oct 2022 09:51:29 +0200 Subject: [PATCH v2 2/2] FIXME various tests that still need to be looked at --- src/bin/pg_dump/t/002_pg_dump.pl | 70 ++++++++++--------- .../test_ddl_deparse/expected/alter_table.out | 20 ++---- src/test/modules/test_pg_dump/t/001_base.pl | 56 ++++++++------- src/test/regress/expected/alter_table.out | 38 +++++----- src/test/regress/expected/event_trigger.out | 2 - src/test/regress/expected/identity.out | 7 +- src/test/regress/expected/inherit.out | 40 +++++------ src/test/regress/expected/psql.out | 30 ++++---- src/test/regress/expected/rules.out | 36 +++++----- src/test/regress/expected/sequence.out | 45 +++++------- src/test/regress/expected/spgist.out | 2 + src/test/regress/sql/spgist.sql | 2 + 12 files changed, 170 insertions(+), 178 deletions(-) diff --git a/src/bin/pg_dump/t/002_pg_dump.pl b/src/bin/pg_dump/t/002_pg_dump.pl index a869321cdfc3..d160dd5c6743 100644 --- a/src/bin/pg_dump/t/002_pg_dump.pl +++ b/src/bin/pg_dump/t/002_pg_dump.pl @@ -745,21 +745,22 @@ unlike => { defaults_public_owner => 1 }, }, - 'ALTER SEQUENCE test_table_col1_seq' => { - regexp => qr/^ - \QALTER SEQUENCE dump_test.test_table_col1_seq OWNED BY dump_test.test_table.col1;\E - /xm, - like => { - %full_runs, - %dump_test_schema_runs, - only_dump_test_table => 1, - section_pre_data => 1, - }, - unlike => { - exclude_dump_test_schema => 1, - exclude_test_table => 1, - }, - }, +# FIXME +# 'ALTER SEQUENCE test_table_col1_seq' => { +# regexp => qr/^ +# \QALTER SEQUENCE dump_test.test_table_col1_seq OWNED BY dump_test.test_table.col1;\E +# /xm, +# like => { +# %full_runs, +# %dump_test_schema_runs, +# only_dump_test_table => 1, +# section_pre_data => 1, +# }, +# unlike => { +# exclude_dump_test_schema => 1, +# exclude_test_table => 1, +# }, +# }, 'ALTER TABLE ONLY test_table ADD CONSTRAINT ... PRIMARY KEY' => { regexp => qr/^ @@ -2752,7 +2753,7 @@ FOR VALUES FROM (\'2006-02-01\') TO (\'2006-03-01\');', regexp => qr/^ \QCREATE TABLE dump_test_second_schema.measurement_y2006m2 (\E\n - \s+\Qcity_id integer DEFAULT nextval('dump_test.measurement_city_id_seq'::regclass) NOT NULL,\E\n + \s+\Qcity_id integer NOT NULL,\E\n \s+\Qlogdate date NOT NULL,\E\n \s+\Qpeaktemp integer,\E\n \s+\Qunitsales integer DEFAULT 0,\E\n @@ -3145,24 +3146,25 @@ unlike => { exclude_dump_test_schema => 1, }, }, - 'CREATE SEQUENCE test_table_col1_seq' => { - regexp => qr/^ - \QCREATE SEQUENCE dump_test.test_table_col1_seq\E - \n\s+\QAS integer\E - \n\s+\QSTART WITH 1\E - \n\s+\QINCREMENT BY 1\E - \n\s+\QNO MINVALUE\E - \n\s+\QNO MAXVALUE\E - \n\s+\QCACHE 1;\E - /xm, - like => { - %full_runs, - %dump_test_schema_runs, - only_dump_test_table => 1, - section_pre_data => 1, - }, - unlike => { exclude_dump_test_schema => 1, }, - }, +# FIXME +# 'CREATE SEQUENCE test_table_col1_seq' => { +# regexp => qr/^ +# \QCREATE SEQUENCE dump_test.test_table_col1_seq\E +# \n\s+\QAS integer\E +# \n\s+\QSTART WITH 1\E +# \n\s+\QINCREMENT BY 1\E +# \n\s+\QNO MINVALUE\E +# \n\s+\QNO MAXVALUE\E +# \n\s+\QCACHE 1;\E +# /xm, +# like => { +# %full_runs, +# %dump_test_schema_runs, +# only_dump_test_table => 1, +# section_pre_data => 1, +# }, +# unlike => { exclude_dump_test_schema => 1, }, +# }, 'CREATE INDEX ON ONLY measurement' => { create_order => 92, diff --git a/src/test/modules/test_ddl_deparse/expected/alter_table.out b/src/test/modules/test_ddl_deparse/expected/alter_table.out index 87a1ab7aabce..30e3dbb8d08a 100644 --- a/src/test/modules/test_ddl_deparse/expected/alter_table.out +++ b/src/test/modules/test_ddl_deparse/expected/alter_table.out @@ -25,12 +25,9 @@ NOTICE: DDL test: type simple, tag CREATE TABLE CREATE TABLE grandchild () INHERITS (child); NOTICE: DDL test: type simple, tag CREATE TABLE ALTER TABLE parent ADD COLUMN b serial; -NOTICE: DDL test: type simple, tag CREATE SEQUENCE -NOTICE: DDL test: type alter table, tag ALTER TABLE -NOTICE: subcommand: type ADD COLUMN (and recurse) desc column b of table parent -NOTICE: DDL test: type simple, tag ALTER SEQUENCE +ERROR: cannot recursively add identity column to table that has child tables ALTER TABLE parent RENAME COLUMN b TO c; -NOTICE: DDL test: type simple, tag ALTER TABLE +ERROR: column "b" does not exist -- Constraint, no recursion ALTER TABLE ONLY grandchild ADD CONSTRAINT a_pos CHECK (a > 0); NOTICE: DDL test: type alter table, tag ALTER TABLE @@ -110,18 +107,11 @@ ALTER TABLE parent DISABLE ROW LEVEL SECURITY; NOTICE: DDL test: type alter table, tag ALTER TABLE NOTICE: subcommand: type DISABLE ROW SECURITY desc <NULL> CREATE STATISTICS parent_stat (dependencies) ON a, c FROM parent; -NOTICE: DDL test: type simple, tag CREATE STATISTICS +ERROR: column "c" does not exist ALTER TABLE parent ALTER COLUMN c TYPE numeric; -NOTICE: DDL test: type alter table, tag ALTER TABLE -NOTICE: subcommand: type ALTER COLUMN SET TYPE desc column c of table parent -NOTICE: subcommand: type ALTER COLUMN SET TYPE desc column c of table child -NOTICE: subcommand: type ALTER COLUMN SET TYPE desc column c of table grandchild -NOTICE: subcommand: type (re) ADD STATS desc statistics object parent_stat +ERROR: column "c" of relation "parent" does not exist ALTER TABLE parent ALTER COLUMN c SET DEFAULT 0; -NOTICE: DDL test: type alter table, tag ALTER TABLE -NOTICE: subcommand: type ALTER COLUMN SET DEFAULT desc column c of table parent -NOTICE: subcommand: type ALTER COLUMN SET DEFAULT desc column c of table child -NOTICE: subcommand: type ALTER COLUMN SET DEFAULT desc column c of table grandchild +ERROR: column "c" of relation "parent" does not exist CREATE TABLE tbl ( a int generated always as (b::int * 2) stored, b text diff --git a/src/test/modules/test_pg_dump/t/001_base.pl b/src/test/modules/test_pg_dump/t/001_base.pl index f5da6bf46d65..1f3b00b3de8d 100644 --- a/src/test/modules/test_pg_dump/t/001_base.pl +++ b/src/test/modules/test_pg_dump/t/001_base.pl @@ -356,18 +356,19 @@ }, }, - 'CREATE SEQUENCE regress_pg_dump_table_col1_seq' => { - regexp => qr/^ - \QCREATE SEQUENCE public.regress_pg_dump_table_col1_seq\E - \n\s+\QAS integer\E - \n\s+\QSTART WITH 1\E - \n\s+\QINCREMENT BY 1\E - \n\s+\QNO MINVALUE\E - \n\s+\QNO MAXVALUE\E - \n\s+\QCACHE 1;\E - \n/xm, - like => { binary_upgrade => 1, }, - }, +# FIXME +# 'CREATE SEQUENCE regress_pg_dump_table_col1_seq' => { +# regexp => qr/^ +# \QCREATE SEQUENCE public.regress_pg_dump_table_col1_seq\E +# \n\s+\QAS integer\E +# \n\s+\QSTART WITH 1\E +# \n\s+\QINCREMENT BY 1\E +# \n\s+\QNO MINVALUE\E +# \n\s+\QNO MAXVALUE\E +# \n\s+\QCACHE 1;\E +# \n/xm, +# like => { binary_upgrade => 1, }, +# }, 'CREATE TABLE regress_pg_dump_table_added' => { create_order => 7, @@ -553,21 +554,22 @@ unlike => { no_privs => 1, without_extension => 1 }, }, - 'GRANT USAGE ON regress_pg_dump_table_col1_seq TO regress_dump_test_role' - => { - create_order => 5, - create_sql => 'GRANT USAGE ON SEQUENCE regress_pg_dump_table_col1_seq - TO regress_dump_test_role;', - regexp => qr/^ - \QGRANT USAGE ON SEQUENCE public.regress_pg_dump_table_col1_seq TO regress_dump_test_role;\E - \n/xm, - like => { - %full_runs, - schema_only => 1, - section_pre_data => 1, - }, - unlike => { no_privs => 1, without_extension => 1, }, - }, +# FIXME +# 'GRANT USAGE ON regress_pg_dump_table_col1_seq TO regress_dump_test_role' +# => { +# create_order => 5, +# create_sql => 'GRANT USAGE ON SEQUENCE regress_pg_dump_table_col1_seq +# TO regress_dump_test_role;', +# regexp => qr/^ +# \QGRANT USAGE ON SEQUENCE public.regress_pg_dump_table_col1_seq TO regress_dump_test_role;\E +# \n/xm, +# like => { +# %full_runs, +# schema_only => 1, +# section_pre_data => 1, +# }, +# unlike => { no_privs => 1, without_extension => 1, }, +# }, 'GRANT USAGE ON regress_pg_dump_seq TO regress_dump_test_role' => { regexp => qr/^ diff --git a/src/test/regress/expected/alter_table.out b/src/test/regress/expected/alter_table.out index 346f594ad026..0a980d1603c5 100644 --- a/src/test/regress/expected/alter_table.out +++ b/src/test/regress/expected/alter_table.out @@ -1910,11 +1910,9 @@ select * from anothertab; (2 rows) alter table anothertab alter column atcol1 type boolean; -- fails -ERROR: column "atcol1" cannot be cast automatically to type boolean -HINT: You might need to specify "USING atcol1::boolean". +ERROR: identity column type must be smallint, integer, or bigint alter table anothertab alter column atcol1 type boolean using atcol1::int; -- fails -ERROR: result of USING clause for column "atcol1" cannot be cast automatically to type boolean -HINT: You might need to add an explicit cast. +ERROR: identity column type must be smallint, integer, or bigint alter table anothertab alter column atcol1 type integer; select * from anothertab; atcol1 | atcol2 @@ -1949,12 +1947,13 @@ select * from anothertab; alter table anothertab alter column atcol1 type boolean using case when atcol1 % 2 = 0 then true else false end; -- fails -ERROR: default for column "atcol1" cannot be cast automatically to type boolean +ERROR: identity column type must be smallint, integer, or bigint alter table anothertab alter column atcol1 drop default; +ERROR: column "atcol1" of relation "anothertab" is an identity column +HINT: Use ALTER TABLE ... ALTER COLUMN ... DROP IDENTITY instead. alter table anothertab alter column atcol1 type boolean using case when atcol1 % 2 = 0 then true else false end; -- fails -ERROR: operator does not exist: boolean <= integer -HINT: No operator matches the given name and argument types. You might need to add explicit type casts. +ERROR: identity column type must be smallint, integer, or bigint alter table anothertab drop constraint anothertab_chk; alter table anothertab drop constraint anothertab_chk; -- fails ERROR: constraint "anothertab_chk" of relation "anothertab" does not exist @@ -1962,12 +1961,13 @@ alter table anothertab drop constraint IF EXISTS anothertab_chk; -- succeeds NOTICE: constraint "anothertab_chk" of relation "anothertab" does not exist, skipping alter table anothertab alter column atcol1 type boolean using case when atcol1 % 2 = 0 then true else false end; +ERROR: identity column type must be smallint, integer, or bigint select * from anothertab; atcol1 | atcol2 --------+-------------- - f | IT WAS TRUE - t | IT WAS FALSE - f | IT WAS NULL! + 1 | IT WAS TRUE + 2 | IT WAS FALSE + 3 | IT WAS NULL! (3 rows) drop table anothertab; @@ -3665,14 +3665,14 @@ Referenced by: ALTER TABLE test_add_column ADD COLUMN IF NOT EXISTS c5 SERIAL CHECK (c5 > 8); \d test_add_column - Table "public.test_add_column" - Column | Type | Collation | Nullable | Default ---------+---------+-----------+----------+--------------------------------------------- + Table "public.test_add_column" + Column | Type | Collation | Nullable | Default +--------+---------+-----------+----------+---------------------------------- c1 | integer | | | c2 | integer | | | c3 | integer | | not null | c4 | integer | | | - c5 | integer | | not null | nextval('test_add_column_c5_seq'::regclass) + c5 | integer | | not null | generated by default as identity Indexes: "test_add_column_pkey" PRIMARY KEY, btree (c3) Check constraints: @@ -3686,14 +3686,14 @@ ALTER TABLE test_add_column ADD COLUMN IF NOT EXISTS c5 SERIAL CHECK (c5 > 10); NOTICE: column "c5" of relation "test_add_column" already exists, skipping \d test_add_column* - Table "public.test_add_column" - Column | Type | Collation | Nullable | Default ---------+---------+-----------+----------+--------------------------------------------- + Table "public.test_add_column" + Column | Type | Collation | Nullable | Default +--------+---------+-----------+----------+---------------------------------- c1 | integer | | | c2 | integer | | | c3 | integer | | not null | c4 | integer | | | - c5 | integer | | not null | nextval('test_add_column_c5_seq'::regclass) + c5 | integer | | not null | generated by default as identity Indexes: "test_add_column_pkey" PRIMARY KEY, btree (c3) Check constraints: @@ -3707,7 +3707,7 @@ Referenced by: Type | Start | Minimum | Maximum | Increment | Cycles? | Cache ---------+-------+---------+------------+-----------+---------+------- integer | 1 | 1 | 2147483647 | 1 | no | 1 -Owned by: public.test_add_column.c5 +Sequence for identity column: public.test_add_column.c5 Index "public.test_add_column_pkey" Column | Type | Key? | Definition diff --git a/src/test/regress/expected/event_trigger.out b/src/test/regress/expected/event_trigger.out index 5a10958df529..679d0bc5bbc7 100644 --- a/src/test/regress/expected/event_trigger.out +++ b/src/test/regress/expected/event_trigger.out @@ -447,7 +447,6 @@ NOTICE: NORMAL: orig=t normal=f istemp=f type=table constraint identity=one_pke NOTICE: END: command_tag=ALTER TABLE type=table identity=evttrig.one ALTER TABLE evttrig.one DROP COLUMN col_c; NOTICE: NORMAL: orig=t normal=f istemp=f type=table column identity=evttrig.one.col_c name={evttrig,one,col_c} args={} -NOTICE: NORMAL: orig=f normal=t istemp=f type=default value identity=for evttrig.one.col_c name={evttrig,one,col_c} args={} NOTICE: END: command_tag=ALTER TABLE type=table identity=evttrig.one ALTER TABLE evttrig.id ALTER COLUMN col_d SET DATA TYPE bigint; NOTICE: END: command_tag=ALTER SEQUENCE type=sequence identity=evttrig.id_col_d_seq @@ -466,7 +465,6 @@ drop cascades to table evttrig.parted NOTICE: NORMAL: orig=t normal=f istemp=f type=schema identity=evttrig name={evttrig} args={} NOTICE: NORMAL: orig=f normal=t istemp=f type=table identity=evttrig.one name={evttrig,one} args={} NOTICE: NORMAL: orig=f normal=t istemp=f type=sequence identity=evttrig.one_col_a_seq name={evttrig,one_col_a_seq} args={} -NOTICE: NORMAL: orig=f normal=t istemp=f type=default value identity=for evttrig.one.col_a name={evttrig,one,col_a} args={} NOTICE: NORMAL: orig=f normal=t istemp=f type=table identity=evttrig.two name={evttrig,two} args={} NOTICE: NORMAL: orig=f normal=t istemp=f type=table identity=evttrig.id name={evttrig,id} args={} NOTICE: NORMAL: orig=f normal=t istemp=f type=table identity=evttrig.parted name={evttrig,parted} args={} diff --git a/src/test/regress/expected/identity.out b/src/test/regress/expected/identity.out index 5f03d8e14fb4..bbfa567fb875 100644 --- a/src/test/regress/expected/identity.out +++ b/src/test/regress/expected/identity.out @@ -67,7 +67,7 @@ LINE 1: CREATE TABLE itest_err_3 (a int default 5 generated by defau... ^ -- cannot combine serial and identity CREATE TABLE itest_err_4 (a serial generated by default as identity); -ERROR: both default and identity specified for column "a" of table "itest_err_4" +ERROR: multiple identity specifications for column "a" of table "itest_err_4" INSERT INTO itest1 DEFAULT VALUES; INSERT INTO itest1 DEFAULT VALUES; INSERT INTO itest2 DEFAULT VALUES; @@ -348,7 +348,7 @@ ERROR: column "a" of relation "itest1" is an identity column -- fail, not allowed, already has a default CREATE TABLE itest5 (a serial, b text); ALTER TABLE itest5 ALTER COLUMN a ADD GENERATED ALWAYS AS IDENTITY; -ERROR: column "a" of relation "itest5" already has a default value +ERROR: column "a" of relation "itest5" is already an identity column ALTER TABLE itest3 ALTER COLUMN a TYPE int; SELECT seqtypid::regtype FROM pg_sequence WHERE seqrelid = 'itest3_a_seq'::regclass; seqtypid @@ -545,7 +545,10 @@ DROP TABLE itest_parent; -- test that sequence of half-dropped serial column is properly ignored CREATE TABLE itest14 (id serial); ALTER TABLE itest14 ALTER id DROP DEFAULT; +ERROR: column "id" of relation "itest14" is an identity column +HINT: Use ALTER TABLE ... ALTER COLUMN ... DROP IDENTITY instead. ALTER TABLE itest14 ALTER id ADD GENERATED BY DEFAULT AS IDENTITY; +ERROR: column "id" of relation "itest14" is already an identity column INSERT INTO itest14 (id) VALUES (DEFAULT); -- Identity columns must be NOT NULL (cf bug #16913) CREATE TABLE itest15 (id integer GENERATED ALWAYS AS IDENTITY NULL); -- fail diff --git a/src/test/regress/expected/inherit.out b/src/test/regress/expected/inherit.out index 2d49e765de8c..a7d2e304123d 100644 --- a/src/test/regress/expected/inherit.out +++ b/src/test/regress/expected/inherit.out @@ -1396,11 +1396,23 @@ create index matest1i on matest1 ((1-id)); -- create index matest2i on matest2 ((1-id)); -- intentionally missing create index matest3i on matest3 ((1-id)); insert into matest1 (name) values ('Test 1'); +ERROR: null value in column "id" of relation "matest1" violates not-null constraint +DETAIL: Failing row contains (null, Test 1). insert into matest1 (name) values ('Test 2'); +ERROR: null value in column "id" of relation "matest1" violates not-null constraint +DETAIL: Failing row contains (null, Test 2). insert into matest2 (name) values ('Test 3'); +ERROR: null value in column "id" of relation "matest2" violates not-null constraint +DETAIL: Failing row contains (null, Test 3). insert into matest2 (name) values ('Test 4'); +ERROR: null value in column "id" of relation "matest2" violates not-null constraint +DETAIL: Failing row contains (null, Test 4). insert into matest3 (name) values ('Test 5'); +ERROR: null value in column "id" of relation "matest3" violates not-null constraint +DETAIL: Failing row contains (null, Test 5). insert into matest3 (name) values ('Test 6'); +ERROR: null value in column "id" of relation "matest3" violates not-null constraint +DETAIL: Failing row contains (null, Test 6). set enable_indexscan = off; -- force use of seqscan/sort, so no merge explain (verbose, costs off) select * from matest0 order by 1-id; QUERY PLAN @@ -1422,15 +1434,9 @@ explain (verbose, costs off) select * from matest0 order by 1-id; (14 rows) select * from matest0 order by 1-id; - id | name -----+-------- - 6 | Test 6 - 5 | Test 5 - 4 | Test 4 - 3 | Test 3 - 2 | Test 2 - 1 | Test 1 -(6 rows) + id | name +----+------ +(0 rows) explain (verbose, costs off) select min(1-id) from matest0; QUERY PLAN @@ -1451,7 +1457,7 @@ explain (verbose, costs off) select min(1-id) from matest0; select min(1-id) from matest0; min ----- - -5 + (1 row) reset enable_indexscan; @@ -1476,15 +1482,9 @@ explain (verbose, costs off) select * from matest0 order by 1-id; (13 rows) select * from matest0 order by 1-id; - id | name -----+-------- - 6 | Test 6 - 5 | Test 5 - 4 | Test 4 - 3 | Test 3 - 2 | Test 2 - 1 | Test 1 -(6 rows) + id | name +----+------ +(0 rows) explain (verbose, costs off) select min(1-id) from matest0; QUERY PLAN @@ -1519,7 +1519,7 @@ explain (verbose, costs off) select min(1-id) from matest0; select min(1-id) from matest0; min ----- - -5 + (1 row) reset enable_seqscan; diff --git a/src/test/regress/expected/psql.out b/src/test/regress/expected/psql.out index a7f5700edc12..5dd45ac9dd87 100644 --- a/src/test/regress/expected/psql.out +++ b/src/test/regress/expected/psql.out @@ -2688,7 +2688,7 @@ create table psql_serial_tab (id serial); Type | Start | Minimum | Maximum | Increment | Cycles? | Cache ---------+-------+---------+------------+-----------+---------+------- integer | 1 | 1 | 2147483647 | 1 | no | 1 -Owned by: public.psql_serial_tab.id +Sequence for identity column: public.psql_serial_tab.id \pset tuples_only true \df exp @@ -2708,7 +2708,7 @@ Increment | 1 Cycles? | no Cache | 1 -Owned by: public.psql_serial_tab.id +Sequence for identity column: public.psql_serial_tab.id \pset tuples_only true \df exp @@ -2735,7 +2735,7 @@ select 1 where false; Sequence "public.psql_serial_tab_id_seq" Type|Start|Minimum|Maximum|Increment|Cycles?|Cache integer|1|1|2147483647|1|no|1 -Owned by: public.psql_serial_tab.id +Sequence for identity column: public.psql_serial_tab.id \pset tuples_only true \df exp pg_catalog|exp|double precision|double precision|func @@ -2753,7 +2753,7 @@ Increment|1 Cycles?|no Cache|1 -Owned by: public.psql_serial_tab.id +Sequence for identity column: public.psql_serial_tab.id \pset tuples_only true \df exp Schema|pg_catalog @@ -2775,7 +2775,7 @@ Type|func Type | Start | Minimum | Maximum | Increment | Cycles? | Cache ---------+-------+---------+------------+-----------+---------+------- integer | 1 | 1 | 2147483647 | 1 | no | 1 -Owned by: public.psql_serial_tab.id +Sequence for identity column: public.psql_serial_tab.id \pset tuples_only true \df exp @@ -2795,7 +2795,7 @@ Increment | 1 Cycles? | no Cache | 1 -Owned by: public.psql_serial_tab.id +Sequence for identity column: public.psql_serial_tab.id \pset tuples_only true \df exp @@ -2940,7 +2940,7 @@ from generate_series(0,3) n; |==== .... -Owned by: public.psql_serial_tab.id +Sequence for identity column: public.psql_serial_tab.id .... \pset tuples_only true \df exp @@ -2968,7 +2968,7 @@ Owned by: public.psql_serial_tab.id |==== .... -Owned by: public.psql_serial_tab.id +Sequence for identity column: public.psql_serial_tab.id .... \pset tuples_only true \df exp @@ -3190,7 +3190,7 @@ select '\' as d1, '' as d2; <td align="right">1</td> </tr> </table> -<p>Owned by: public.psql_serial_tab.id<br /> +<p>Sequence for identity column: public.psql_serial_tab.id<br /> </p> \pset tuples_only true \df exp @@ -3247,7 +3247,7 @@ select '\' as d1, '' as d2; <td align="right">1</td> </tr> </table> -<p>Owned by: public.psql_serial_tab.id<br /> +<p>Sequence for identity column: public.psql_serial_tab.id<br /> </p> \pset tuples_only true \df exp @@ -3530,7 +3530,7 @@ Sequence "public.psql\_serial\_tab\_id\_seq" integer & 1 & 1 & 2147483647 & 1 & no & 1 \\ \end{tabular} -\noindent Owned by: public.psql\_serial\_tab.id \\ +\noindent Sequence for identity column: public.psql\_serial\_tab.id \\ \pset tuples_only true \df exp @@ -3559,7 +3559,7 @@ Cycles? & no \\ Cache & 1 \\ \end{tabular} -\noindent Owned by: public.psql\_serial\_tab.id \\ +\noindent Sequence for identity column: public.psql\_serial\_tab.id \\ \pset tuples_only true \df exp @@ -3783,7 +3783,7 @@ Cycles? & no \\ Cache & 1 \\ \end{tabular} -\noindent Owned by: public.psql\_serial\_tab.id \\ +\noindent Sequence for identity column: public.psql\_serial\_tab.id \\ \pset tuples_only true \df exp @@ -4068,7 +4068,7 @@ _ integer 1 1 2147483647 1 no 1 .TE .DS L -Owned by: public.psql_serial_tab.id +Sequence for identity column: public.psql_serial_tab.id .DE \pset tuples_only true \df exp @@ -4105,7 +4105,7 @@ Cycles? no Cache 1 .TE .DS L -Owned by: public.psql_serial_tab.id +Sequence for identity column: public.psql_serial_tab.id .DE \pset tuples_only true \df exp diff --git a/src/test/regress/expected/rules.out b/src/test/regress/expected/rules.out index 9dd137415e86..a14f8dc34961 100644 --- a/src/test/regress/expected/rules.out +++ b/src/test/regress/expected/rules.out @@ -2754,38 +2754,38 @@ NOTICE: merging column "id" with inherited definition create table test_3 (id integer primary key) inherits (id); NOTICE: merging column "id" with inherited definition insert into test_1 (name) values ('Test 1'); +ERROR: null value in column "id" of relation "test_1" violates not-null constraint +DETAIL: Failing row contains (null, Test 1). insert into test_1 (name) values ('Test 2'); +ERROR: null value in column "id" of relation "test_1" violates not-null constraint +DETAIL: Failing row contains (null, Test 2). insert into test_2 (name) values ('Test 3'); +ERROR: null value in column "id" of relation "test_2" violates not-null constraint +DETAIL: Failing row contains (null, Test 3). insert into test_2 (name) values ('Test 4'); +ERROR: null value in column "id" of relation "test_2" violates not-null constraint +DETAIL: Failing row contains (null, Test 4). insert into test_3 (name) values ('Test 5'); +ERROR: null value in column "id" of relation "test_3" violates not-null constraint +DETAIL: Failing row contains (null, Test 5). insert into test_3 (name) values ('Test 6'); +ERROR: null value in column "id" of relation "test_3" violates not-null constraint +DETAIL: Failing row contains (null, Test 6). create view id_ordered as select * from id order by id; create rule update_id_ordered as on update to id_ordered do instead update id set name = new.name where id = old.id; select * from id_ordered; - id | name -----+-------- - 1 | Test 1 - 2 | Test 2 - 3 | Test 3 - 4 | Test 4 - 5 | Test 5 - 6 | Test 6 -(6 rows) + id | name +----+------ +(0 rows) update id_ordered set name = 'update 2' where id = 2; update id_ordered set name = 'update 4' where id = 4; update id_ordered set name = 'update 5' where id = 5; select * from id_ordered; - id | name -----+---------- - 1 | Test 1 - 2 | update 2 - 3 | Test 3 - 4 | update 4 - 5 | update 5 - 6 | Test 6 -(6 rows) + id | name +----+------ +(0 rows) drop table id cascade; NOTICE: drop cascades to 4 other objects diff --git a/src/test/regress/expected/sequence.out b/src/test/regress/expected/sequence.out index 7cb2f7cc02b8..0507d2d7a50e 100644 --- a/src/test/regress/expected/sequence.out +++ b/src/test/regress/expected/sequence.out @@ -291,9 +291,8 @@ CREATE TEMP TABLE t1 ( ); -- Both drops should fail, but with different error messages: DROP SEQUENCE t1_f1_seq; -ERROR: cannot drop sequence t1_f1_seq because other objects depend on it -DETAIL: default value for column f1 of table t1 depends on sequence t1_f1_seq -HINT: Use DROP ... CASCADE to drop the dependent objects too. +ERROR: cannot drop sequence t1_f1_seq because column f1 of table t1 requires it +HINT: You can drop column f1 of table t1 instead. DROP SEQUENCE myseq2; ERROR: cannot drop sequence myseq2 because other objects depend on it DETAIL: default value for column f2 of table t1 depends on sequence myseq2 @@ -478,28 +477,22 @@ CREATE SEQUENCE sequence_test3; -- not read from, to test is_called SELECT * FROM information_schema.sequences WHERE sequence_name ~ ANY(ARRAY['sequence_test', 'serialtest']) ORDER BY sequence_name ASC; - sequence_catalog | sequence_schema | sequence_name | data_type | numeric_precision | numeric_precision_radix | numeric_scale | start_value | minimum_value | maximum_value | increment | cycle_option -------------------+-----------------+--------------------+-----------+-------------------+-------------------------+---------------+-------------+----------------------+---------------------+-----------+-------------- - regression | public | sequence_test10 | smallint | 16 | 2 | 0 | 1 | -20000 | 32767 | 1 | NO - regression | public | sequence_test11 | integer | 32 | 2 | 0 | 1 | 1 | 2147483647 | 1 | NO - regression | public | sequence_test12 | integer | 32 | 2 | 0 | -1 | -2147483648 | -1 | -1 | NO - regression | public | sequence_test13 | integer | 32 | 2 | 0 | -32768 | -2147483648 | 2147483647 | 1 | NO - regression | public | sequence_test14 | integer | 32 | 2 | 0 | 32767 | -2147483648 | 2147483647 | -1 | NO - regression | public | sequence_test2 | bigint | 64 | 2 | 0 | 32 | 5 | 36 | 4 | YES - regression | public | sequence_test3 | bigint | 64 | 2 | 0 | 1 | 1 | 9223372036854775807 | 1 | NO - regression | public | sequence_test4 | bigint | 64 | 2 | 0 | -1 | -9223372036854775808 | -1 | -1 | NO - regression | public | sequence_test5 | smallint | 16 | 2 | 0 | 1 | 1 | 32767 | 1 | NO - regression | public | sequence_test6 | smallint | 16 | 2 | 0 | 1 | 1 | 32767 | 1 | NO - regression | public | sequence_test7 | bigint | 64 | 2 | 0 | 1 | 1 | 9223372036854775807 | 1 | NO - regression | public | sequence_test8 | smallint | 16 | 2 | 0 | 1 | 1 | 20000 | 1 | NO - regression | public | sequence_test9 | smallint | 16 | 2 | 0 | -1 | -32768 | -1 | -1 | NO - regression | public | serialtest1_f2_foo | integer | 32 | 2 | 0 | 1 | 1 | 2147483647 | 1 | NO - regression | public | serialtest2_f2_seq | integer | 32 | 2 | 0 | 1 | 1 | 2147483647 | 1 | NO - regression | public | serialtest2_f3_seq | smallint | 16 | 2 | 0 | 1 | 1 | 32767 | 1 | NO - regression | public | serialtest2_f4_seq | smallint | 16 | 2 | 0 | 1 | 1 | 32767 | 1 | NO - regression | public | serialtest2_f5_seq | bigint | 64 | 2 | 0 | 1 | 1 | 9223372036854775807 | 1 | NO - regression | public | serialtest2_f6_seq | bigint | 64 | 2 | 0 | 1 | 1 | 9223372036854775807 | 1 | NO -(19 rows) + sequence_catalog | sequence_schema | sequence_name | data_type | numeric_precision | numeric_precision_radix | numeric_scale | start_value | minimum_value | maximum_value | increment | cycle_option +------------------+-----------------+-----------------+-----------+-------------------+-------------------------+---------------+-------------+----------------------+---------------------+-----------+-------------- + regression | public | sequence_test10 | smallint | 16 | 2 | 0 | 1 | -20000 | 32767 | 1 | NO + regression | public | sequence_test11 | integer | 32 | 2 | 0 | 1 | 1 | 2147483647 | 1 | NO + regression | public | sequence_test12 | integer | 32 | 2 | 0 | -1 | -2147483648 | -1 | -1 | NO + regression | public | sequence_test13 | integer | 32 | 2 | 0 | -32768 | -2147483648 | 2147483647 | 1 | NO + regression | public | sequence_test14 | integer | 32 | 2 | 0 | 32767 | -2147483648 | 2147483647 | -1 | NO + regression | public | sequence_test2 | bigint | 64 | 2 | 0 | 32 | 5 | 36 | 4 | YES + regression | public | sequence_test3 | bigint | 64 | 2 | 0 | 1 | 1 | 9223372036854775807 | 1 | NO + regression | public | sequence_test4 | bigint | 64 | 2 | 0 | -1 | -9223372036854775808 | -1 | -1 | NO + regression | public | sequence_test5 | smallint | 16 | 2 | 0 | 1 | 1 | 32767 | 1 | NO + regression | public | sequence_test6 | smallint | 16 | 2 | 0 | 1 | 1 | 32767 | 1 | NO + regression | public | sequence_test7 | bigint | 64 | 2 | 0 | 1 | 1 | 9223372036854775807 | 1 | NO + regression | public | sequence_test8 | smallint | 16 | 2 | 0 | 1 | 1 | 20000 | 1 | NO + regression | public | sequence_test9 | smallint | 16 | 2 | 0 | -1 | -32768 | -1 | -1 | NO +(13 rows) SELECT schemaname, sequencename, start_value, min_value, max_value, increment_by, cycle, cache_size, last_value FROM pg_sequences @@ -545,7 +538,7 @@ SELECT * FROM pg_sequence_parameters('sequence_test4'::regclass); Type | Start | Minimum | Maximum | Increment | Cycles? | Cache ---------+-------+---------+------------+-----------+---------+------- integer | 1 | 1 | 2147483647 | 1 | no | 1 -Owned by: public.serialtest2.f2 +Sequence for identity column: public.serialtest2.f2 -- Test comments COMMENT ON SEQUENCE asdf IS 'won''t work'; diff --git a/src/test/regress/expected/spgist.out b/src/test/regress/expected/spgist.out index 2e9112856000..7c02d56341ba 100644 --- a/src/test/regress/expected/spgist.out +++ b/src/test/regress/expected/spgist.out @@ -94,3 +94,5 @@ select box(point(i,j)) from generate_series(1,100,5) i, generate_series(1,10,5) j; -- leave this table around, to help in testing dump/restore +-- FIXME +drop table spgist_unlogged_tbl; diff --git a/src/test/regress/sql/spgist.sql b/src/test/regress/sql/spgist.sql index 4828ede68c3d..bd732854df63 100644 --- a/src/test/regress/sql/spgist.sql +++ b/src/test/regress/sql/spgist.sql @@ -89,3 +89,5 @@ from generate_series(1,100,5) i, generate_series(1,10,5) j; -- leave this table around, to help in testing dump/restore +-- FIXME +drop table spgist_unlogged_tbl; -- 2.37.3