mirror of
https://github.com/postgres/postgres.git
synced 2025-06-08 22:02:03 +03:00
Fix code related to partitioning schemes for dropped columns.
The entry in appinfo->translated_vars can be NULL; if so, we must avoid dereferencing it. Ashutosh Bapat Discussion: http://postgr.es/m/CAFjFpReL7+1ien=-21rhjpO3bV7aAm1rQ8XgLVk2csFagSzpZQ@mail.gmail.com
This commit is contained in:
parent
35f059e9bd
commit
cf7ab13bfb
@ -950,6 +950,18 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
|
|||||||
attno - 1);
|
attno - 1);
|
||||||
int child_index;
|
int child_index;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ignore any column dropped from the parent.
|
||||||
|
* Corresponding Var won't have any translation. It won't
|
||||||
|
* have attr_needed information, since it can not be
|
||||||
|
* referenced in the query.
|
||||||
|
*/
|
||||||
|
if (var == NULL)
|
||||||
|
{
|
||||||
|
Assert(attr_needed == NULL);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
child_index = var->varattno - childrel->min_attr;
|
child_index = var->varattno - childrel->min_attr;
|
||||||
childrel->attr_needed[child_index] = attr_needed;
|
childrel->attr_needed[child_index] = attr_needed;
|
||||||
}
|
}
|
||||||
|
@ -3706,6 +3706,13 @@ ALTER TABLE list_parted2 DROP COLUMN b;
|
|||||||
ERROR: cannot drop column named in partition key
|
ERROR: cannot drop column named in partition key
|
||||||
ALTER TABLE list_parted2 ALTER COLUMN b TYPE text;
|
ALTER TABLE list_parted2 ALTER COLUMN b TYPE text;
|
||||||
ERROR: cannot alter type of column named in partition key
|
ERROR: cannot alter type of column named in partition key
|
||||||
|
-- dropping non-partition key columns should be allowed on the parent table.
|
||||||
|
ALTER TABLE list_parted DROP COLUMN b;
|
||||||
|
SELECT * FROM list_parted;
|
||||||
|
a
|
||||||
|
---
|
||||||
|
(0 rows)
|
||||||
|
|
||||||
-- cleanup
|
-- cleanup
|
||||||
DROP TABLE list_parted, list_parted2, range_parted;
|
DROP TABLE list_parted, list_parted2, range_parted;
|
||||||
DROP TABLE fail_def_part;
|
DROP TABLE fail_def_part;
|
||||||
|
@ -2418,6 +2418,10 @@ ALTER TABLE part_2 INHERIT inh_test;
|
|||||||
ALTER TABLE list_parted2 DROP COLUMN b;
|
ALTER TABLE list_parted2 DROP COLUMN b;
|
||||||
ALTER TABLE list_parted2 ALTER COLUMN b TYPE text;
|
ALTER TABLE list_parted2 ALTER COLUMN b TYPE text;
|
||||||
|
|
||||||
|
-- dropping non-partition key columns should be allowed on the parent table.
|
||||||
|
ALTER TABLE list_parted DROP COLUMN b;
|
||||||
|
SELECT * FROM list_parted;
|
||||||
|
|
||||||
-- cleanup
|
-- cleanup
|
||||||
DROP TABLE list_parted, list_parted2, range_parted;
|
DROP TABLE list_parted, list_parted2, range_parted;
|
||||||
DROP TABLE fail_def_part;
|
DROP TABLE fail_def_part;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user