1
0
mirror of https://github.com/postgres/postgres.git synced 2025-06-16 06:01:02 +03:00

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
This commit is contained in:
Robert Haas
2017-02-14 12:12:34 -05:00
parent 8d396a0a70
commit e28b115612
3 changed files with 22 additions and 9 deletions

View File

@ -5593,18 +5593,22 @@ ATExecDropNotNull(Relation rel, const char *colName, LOCKMODE lockmode)
if (rel->rd_rel->relkind == RELKIND_PARTITIONED_TABLE)
{
PartitionKey key = RelationGetPartitionKey(rel);
int partnatts = get_partition_natts(key),
i;
for (i = 0; i < partnatts; i++)
if (get_partition_strategy(key) == PARTITION_STRATEGY_RANGE)
{
AttrNumber partattnum = get_partition_col_attnum(key, i);
int partnatts = get_partition_natts(key),
i;
if (partattnum == attnum)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("column \"%s\" is in range partition key",
colName)));
for (i = 0; i < partnatts; i++)
{
AttrNumber partattnum = get_partition_col_attnum(key, i);
if (partattnum == attnum)
ereport(ERROR,
(errcode(ERRCODE_INVALID_TABLE_DEFINITION),
errmsg("column \"%s\" is in range partition key",
colName)));
}
}
}