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

Commitbd17896

Browse files
committed
Need to do CommandCounterIncrement after StoreAttrMissingVal.
Without this, an additional change to the same pg_attribute rowwithin the same command will fail. This is possible at least withALTER TABLE ADD COLUMN on a multiple-inheritance-pathway structure.(Another potential hazard is that immediately-following operationsmight not see the missingval.)Introduced by95f6506, which split the former coding thatused a single pg_attribute update to change both atthasdef andatthasmissing/attmissingval into two updates, but missed thatthis should entail two CommandCounterIncrements as well. Likethat fix, back-patch through v13.Reported-by: Alexander Lakhin <exclusion@gmail.com>Author: Tender Wang <tndrwang@gmail.com>Reviewed-by: Tom Lane <tgl@sss.pgh.pa.us>Discussion:https://postgr.es/m/025a3ffa-5eff-4a88-97fb-8f583b015965@gmail.comBackpatch-through: 13
1 parentb057512 commitbd17896

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

‎src/backend/commands/tablecmds.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7533,6 +7533,8 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
75337533
if (!missingIsNull)
75347534
{
75357535
StoreAttrMissingVal(rel, attribute->attnum, missingval);
7536+
/* Make the additional catalog change visible */
7537+
CommandCounterIncrement();
75367538
has_missing = true;
75377539
}
75387540
FreeExecutorState(estate);

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1096,17 +1096,30 @@ CREATE TABLE inhta ();
10961096
CREATE TABLE inhtb () INHERITS (inhta);
10971097
CREATE TABLE inhtc () INHERITS (inhtb);
10981098
CREATE TABLE inhtd () INHERITS (inhta, inhtb, inhtc);
1099-
ALTER TABLE inhta ADD COLUMN i int;
1099+
ALTER TABLE inhta ADD COLUMN i int, ADD COLUMN j bigint DEFAULT 1;
11001100
NOTICE: merging definition of column "i" for child "inhtd"
11011101
NOTICE: merging definition of column "i" for child "inhtd"
1102+
NOTICE: merging definition of column "j" for child "inhtd"
1103+
NOTICE: merging definition of column "j" for child "inhtd"
11021104
\d+ inhta
11031105
Table "public.inhta"
11041106
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
11051107
--------+---------+-----------+----------+---------+---------+--------------+-------------
11061108
i | integer | | | | plain | |
1109+
j | bigint | | | 1 | plain | |
11071110
Child tables: inhtb,
11081111
inhtd
11091112

1113+
\d+ inhtd
1114+
Table "public.inhtd"
1115+
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
1116+
--------+---------+-----------+----------+---------+---------+--------------+-------------
1117+
i | integer | | | | plain | |
1118+
j | bigint | | | 1 | plain | |
1119+
Inherits: inhta,
1120+
inhtb,
1121+
inhtc
1122+
11101123
DROP TABLE inhta, inhtb, inhtc, inhtd;
11111124
-- Test for renaming in diamond inheritance
11121125
CREATE TABLE inht2 (x int) INHERITS (inht1);

‎src/test/regress/sql/inherit.sql‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,8 +380,9 @@ CREATE TABLE inhta ();
380380
CREATETABLEinhtb () INHERITS (inhta);
381381
CREATETABLEinhtc () INHERITS (inhtb);
382382
CREATETABLEinhtd () INHERITS (inhta, inhtb, inhtc);
383-
ALTERTABLE inhta ADD COLUMN iint;
383+
ALTERTABLE inhta ADD COLUMN iint, ADD COLUMN jbigint DEFAULT1;
384384
\d+ inhta
385+
\d+ inhtd
385386
DROPTABLE inhta, inhtb, inhtc, inhtd;
386387

387388
-- Test for renaming in diamond inheritance

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp