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

Commite28b115

Browse files
committed
Don't disallow dropping NOT NULL for a list partition key.
Range partitioning doesn't support nulls in the partitioning columns,but list partitioning does.Amit Langote, per a complaint from Amul Sul
1 parent8d396a0 commite28b115

File tree

3 files changed

+22
-9
lines changed

3 files changed

+22
-9
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5593,18 +5593,22 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
55935593
if (rel->rd_rel->relkind==RELKIND_PARTITIONED_TABLE)
55945594
{
55955595
PartitionKeykey=RelationGetPartitionKey(rel);
5596-
intpartnatts=get_partition_natts(key),
5597-
i;
55985596

5599-
for (i=0;i<partnatts;i++)
5597+
if (get_partition_strategy(key)==PARTITION_STRATEGY_RANGE)
56005598
{
5601-
AttrNumberpartattnum=get_partition_col_attnum(key,i);
5599+
intpartnatts=get_partition_natts(key),
5600+
i;
56025601

5603-
if (partattnum==attnum)
5604-
ereport(ERROR,
5605-
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
5606-
errmsg("column \"%s\" is in range partition key",
5607-
colName)));
5602+
for (i=0;i<partnatts;i++)
5603+
{
5604+
AttrNumberpartattnum=get_partition_col_attnum(key,i);
5605+
5606+
if (partattnum==attnum)
5607+
ereport(ERROR,
5608+
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
5609+
errmsg("column \"%s\" is in range partition key",
5610+
colName)));
5611+
}
56085612
}
56095613
}
56105614

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3029,6 +3029,10 @@ ERROR: cannot alter type of column referenced in partition key expression
30293029
-- cannot drop NOT NULL on columns in the range partition key
30303030
ALTER TABLE partitioned ALTER COLUMN a DROP NOT NULL;
30313031
ERROR: column "a" is in range partition key
3032+
-- it's fine however to drop one on the list partition key column
3033+
CREATE TABLE list_partitioned (a int not null) partition by list (a);
3034+
ALTER TABLE list_partitioned ALTER a DROP NOT NULL;
3035+
DROP TABLE list_partitioned;
30323036
-- partitioned table cannot participate in regular inheritance
30333037
CREATE TABLE foo (
30343038
a int,

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,6 +1917,11 @@ ALTER TABLE partitioned ALTER COLUMN b TYPE char(5);
19171917
-- cannot drop NOT NULL on columns in the range partition key
19181918
ALTERTABLE partitioned ALTER COLUMN a DROPNOT NULL;
19191919

1920+
-- it's fine however to drop one on the list partition key column
1921+
CREATETABLElist_partitioned (aintnot null) partition by list (a);
1922+
ALTERTABLE list_partitioned ALTER a DROPNOT NULL;
1923+
DROPTABLE list_partitioned;
1924+
19201925
-- partitioned table cannot participate in regular inheritance
19211926
CREATETABLEfoo (
19221927
aint,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp