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

Commit4f981df

Browse files
committed
Report a more useful error for reloptions on a partitioned table.
Previously, trying to set storage parameters on a partitioned tablealways led to "unrecognized parameter foo", because the code expectedthere might be some valid parameters; but there aren't any. The docsmake clear that it's intended that there never will be any, so let'sreplace this useless search with a more to-the-point message.Simon Riggs and Karina LitskevichDiscussion:https://postgr.es/m/CANbhV-H=eZ9kTR9mUgKGK0Qv9uXP=U+dQg3rinQHfTdFMhBA2A@mail.gmail.com
1 parente613ace commit4f981df

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

‎src/backend/access/common/reloptions.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1984,13 +1984,12 @@ build_local_reloptions(local_relopts *relopts, Datum options, bool validate)
19841984
bytea*
19851985
partitioned_table_reloptions(Datumreloptions,boolvalidate)
19861986
{
1987-
/*
1988-
* There are no options for partitioned tables yet, but this is able to do
1989-
* some validation.
1990-
*/
1991-
return (bytea*)build_reloptions(reloptions,validate,
1992-
RELOPT_KIND_PARTITIONED,
1993-
0,NULL,0);
1987+
if (validate&&reloptions)
1988+
ereport(ERROR,
1989+
errcode(ERRCODE_WRONG_OBJECT_TYPE),
1990+
errmsg("cannot specify storage parameters for a partitioned table"),
1991+
errhint("Specify storage parameters for its leaf partitions, instead."));
1992+
returnNULL;
19941993
}
19951994

19961995
/*

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3801,6 +3801,10 @@ ALTER TABLE partitioned DROP COLUMN b;
38013801
ERROR: cannot drop column "b" because it is part of the partition key of relation "partitioned"
38023802
ALTER TABLE partitioned ALTER COLUMN b TYPE char(5);
38033803
ERROR: cannot alter column "b" because it is part of the partition key of relation "partitioned"
3804+
-- specifying storage parameters for partitioned tables is not supported
3805+
ALTER TABLE partitioned SET (fillfactor=100);
3806+
ERROR: cannot specify storage parameters for a partitioned table
3807+
HINT: Specify storage parameters for its leaf partitions, instead.
38043808
-- partitioned table cannot participate in regular inheritance
38053809
CREATE TABLE nonpartitioned (
38063810
a int,

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,10 @@ Partition key: LIST (a)
987987
Number of partitions: 0
988988

989989
DROP TABLE parted_col_comment;
990+
-- specifying storage parameters for partitioned tables is not supported
991+
CREATE TABLE parted_col_comment (a int, b text) PARTITION BY LIST (a) WITH (fillfactor=100);
992+
ERROR: cannot specify storage parameters for a partitioned table
993+
HINT: Specify storage parameters for its leaf partitions, instead.
990994
-- list partitioning on array type column
991995
CREATE TABLE arrlp (a int[]) PARTITION BY LIST (a);
992996
CREATE TABLE arrlp12 PARTITION OF arrlp FOR VALUES IN ('{1}', '{2}');

‎src/test/regress/sql/alter_table.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2325,6 +2325,9 @@ ALTER TABLE partitioned ALTER COLUMN a TYPE char(5);
23252325
ALTERTABLE partitioned DROP COLUMN b;
23262326
ALTERTABLE partitioned ALTER COLUMN b TYPEchar(5);
23272327

2328+
-- specifying storage parameters for partitioned tables is not supported
2329+
ALTERTABLE partitionedSET (fillfactor=100);
2330+
23282331
-- partitioned table cannot participate in regular inheritance
23292332
CREATETABLEnonpartitioned (
23302333
aint,

‎src/test/regress/sql/create_table.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,9 @@ SELECT obj_description('parted_col_comment'::regclass);
652652
\d+ parted_col_comment
653653
DROPTABLE parted_col_comment;
654654

655+
-- specifying storage parameters for partitioned tables is not supported
656+
CREATETABLEparted_col_comment (aint, btext) PARTITION BY LIST (a) WITH (fillfactor=100);
657+
655658
-- list partitioning on array type column
656659
CREATETABLEarrlp (aint[]) PARTITION BY LIST (a);
657660
CREATETABLEarrlp12 PARTITION OF arrlp FORVALUESIN ('{1}','{2}');

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp