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

Commitcf7ab13

Browse files
committed
Fix code related to partitioning schemes for dropped columns.
The entry in appinfo->translated_vars can be NULL; if so, we must avoiddereferencing it.Ashutosh BapatDiscussion:http://postgr.es/m/CAFjFpReL7+1ien=-21rhjpO3bV7aAm1rQ8XgLVk2csFagSzpZQ@mail.gmail.com
1 parent35f059e commitcf7ab13

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

‎src/backend/optimizer/path/allpaths.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -950,6 +950,18 @@ set_append_rel_size(PlannerInfo *root, RelOptInfo *rel,
950950
attno-1);
951951
intchild_index;
952952

953+
/*
954+
* Ignore any column dropped from the parent.
955+
* Corresponding Var won't have any translation. It won't
956+
* have attr_needed information, since it can not be
957+
* referenced in the query.
958+
*/
959+
if (var==NULL)
960+
{
961+
Assert(attr_needed==NULL);
962+
continue;
963+
}
964+
953965
child_index=var->varattno-childrel->min_attr;
954966
childrel->attr_needed[child_index]=attr_needed;
955967
}

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3706,6 +3706,13 @@ ALTER TABLE list_parted2 DROP COLUMN b;
37063706
ERROR: cannot drop column named in partition key
37073707
ALTER TABLE list_parted2 ALTER COLUMN b TYPE text;
37083708
ERROR: cannot alter type of column named in partition key
3709+
-- dropping non-partition key columns should be allowed on the parent table.
3710+
ALTER TABLE list_parted DROP COLUMN b;
3711+
SELECT * FROM list_parted;
3712+
a
3713+
---
3714+
(0 rows)
3715+
37093716
-- cleanup
37103717
DROP TABLE list_parted, list_parted2, range_parted;
37113718
DROP TABLE fail_def_part;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2418,6 +2418,10 @@ ALTER TABLE part_2 INHERIT inh_test;
24182418
ALTERTABLE list_parted2 DROP COLUMN b;
24192419
ALTERTABLE list_parted2 ALTER COLUMN b TYPEtext;
24202420

2421+
-- dropping non-partition key columns should be allowed on the parent table.
2422+
ALTERTABLE list_parted DROP COLUMN b;
2423+
SELECT*FROM list_parted;
2424+
24212425
-- cleanup
24222426
DROPTABLE list_parted, list_parted2, range_parted;
24232427
DROPTABLE fail_def_part;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp