Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit005ac29

Browse files
committed
Prohibit identity columns on typed tables and partitions
Those cases currently crash and supporting them is more work thenoriginally thought, so we'll just prohibit these scenarios for now.Author: Michael Paquier <michael.paquier@gmail.com>Reviewed-by: Amit Langote <Langote_Amit_f8@lab.ntt.co.jp>Reported-by: Мансур Галиев <gomer94@yandex.ru>Bug: #14866
1 parentaf9f8b7 commit005ac29

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

‎src/backend/parser/parse_utilcmd.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ typedef struct
9292
IndexStmt*pkey;/* PRIMARY KEY index, if any */
9393
boolispartitioned;/* true if table is partitioned */
9494
PartitionBoundSpec*partbound;/* transformed FOR VALUES */
95+
boolofType;/* true if statement contains OF typename */
9596
}CreateStmtContext;
9697

9798
/* State shared by transformCreateSchemaStmt and its subroutines */
@@ -240,6 +241,8 @@ transformCreateStmt(CreateStmt *stmt, const char *queryString)
240241
cxt.alist=NIL;
241242
cxt.pkey=NULL;
242243
cxt.ispartitioned=stmt->partspec!=NULL;
244+
cxt.partbound=stmt->partbound;
245+
cxt.ofType= (stmt->ofTypename!=NULL);
243246

244247
/*
245248
* Notice that we allow OIDs here only for plain tables, even though
@@ -662,6 +665,15 @@ transformColumnDefinition(CreateStmtContext *cxt, ColumnDef *column)
662665
Typectype;
663666
OidtypeOid;
664667

668+
if (cxt->ofType)
669+
ereport(ERROR,
670+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
671+
errmsg("identity colums are not supported on typed tables")));
672+
if (cxt->partbound)
673+
ereport(ERROR,
674+
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
675+
errmsg("identify columns are not supported on partitions")));
676+
665677
ctype=typenameType(cxt->pstate,column->typeName,NULL);
666678
typeOid=HeapTupleGetOid(ctype);
667679
ReleaseSysCache(ctype);
@@ -2697,6 +2709,7 @@ transformAlterTableStmt(Oid relid, AlterTableStmt *stmt,
26972709
cxt.pkey=NULL;
26982710
cxt.ispartitioned= (rel->rd_rel->relkind==RELKIND_PARTITIONED_TABLE);
26992711
cxt.partbound=NULL;
2712+
cxt.ofType= false;
27002713

27012714
/*
27022715
* The only subtypes that currently require parse transformation handling

‎src/test/regress/expected/identity.out

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,3 +346,15 @@ SELECT * FROM itest8;
346346
RESET ROLE;
347347
DROP TABLE itest8;
348348
DROP USER regress_user1;
349+
-- typed tables (currently not supported)
350+
CREATE TYPE itest_type AS (f1 integer, f2 text, f3 bigint);
351+
CREATE TABLE itest12 OF itest_type (f1 WITH OPTIONS GENERATED ALWAYS AS IDENTITY); -- error
352+
ERROR: identity colums are not supported on typed tables
353+
DROP TYPE itest_type CASCADE;
354+
-- table partitions (currently not supported)
355+
CREATE TABLE itest_parent (f1 date NOT NULL, f2 text, f3 bigint) PARTITION BY RANGE (f1);
356+
CREATE TABLE itest_child PARTITION OF itest_parent (
357+
f3 WITH OPTIONS GENERATED ALWAYS AS IDENTITY
358+
) FOR VALUES FROM ('2016-07-01') TO ('2016-08-01'); -- error
359+
ERROR: identify columns are not supported on partitions
360+
DROP TABLE itest_parent;

‎src/test/regress/sql/identity.sql

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,3 +211,19 @@ SELECT * FROM itest8;
211211
RESET ROLE;
212212
DROPTABLE itest8;
213213
DROPUSER regress_user1;
214+
215+
216+
-- typed tables (currently not supported)
217+
218+
CREATETYPEitest_typeAS (f1integer, f2text, f3bigint);
219+
CREATETABLEitest12 OF itest_type (f1 WITH OPTIONS GENERATED ALWAYSAS IDENTITY);-- error
220+
DROPTYPE itest_type CASCADE;
221+
222+
223+
-- table partitions (currently not supported)
224+
225+
CREATETABLEitest_parent (f1dateNOT NULL, f2text, f3bigint) PARTITION BY RANGE (f1);
226+
CREATETABLEitest_child PARTITION OF itest_parent (
227+
f3 WITH OPTIONS GENERATED ALWAYSAS IDENTITY
228+
) FORVALUESFROM ('2016-07-01') TO ('2016-08-01');-- error
229+
DROPTABLE itest_parent;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp