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

Commitdd34cbf

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 parentebbdaf1 commitdd34cbf

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
@@ -6715,6 +6715,8 @@ ATExecAddColumn(List **wqueue, AlteredTableInfo *tab, Relation rel,
67156715
if (!missingIsNull)
67166716
{
67176717
StoreAttrMissingVal(rel, attribute.attnum, missingval);
6718+
/* Make the additional catalog change visible */
6719+
CommandCounterIncrement();
67186720
has_missing = true;
67196721
}
67206722
FreeExecutorState(estate);

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1068,17 +1068,30 @@ CREATE TABLE inhta ();
10681068
CREATE TABLE inhtb () INHERITS (inhta);
10691069
CREATE TABLE inhtc () INHERITS (inhtb);
10701070
CREATE TABLE inhtd () INHERITS (inhta, inhtb, inhtc);
1071-
ALTER TABLE inhta ADD COLUMN i int;
1071+
ALTER TABLE inhta ADD COLUMN i int, ADD COLUMN j bigint DEFAULT 1;
10721072
NOTICE: merging definition of column "i" for child "inhtd"
10731073
NOTICE: merging definition of column "i" for child "inhtd"
1074+
NOTICE: merging definition of column "j" for child "inhtd"
1075+
NOTICE: merging definition of column "j" for child "inhtd"
10741076
\d+ inhta
10751077
Table "public.inhta"
10761078
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
10771079
--------+---------+-----------+----------+---------+---------+--------------+-------------
10781080
i | integer | | | | plain | |
1081+
j | bigint | | | 1 | plain | |
10791082
Child tables: inhtb,
10801083
inhtd
10811084

1085+
\d+ inhtd
1086+
Table "public.inhtd"
1087+
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
1088+
--------+---------+-----------+----------+---------+---------+--------------+-------------
1089+
i | integer | | | | plain | |
1090+
j | bigint | | | 1 | plain | |
1091+
Inherits: inhta,
1092+
inhtb,
1093+
inhtc
1094+
10821095
DROP TABLE inhta, inhtb, inhtc, inhtd;
10831096
-- Test for renaming in diamond inheritance
10841097
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
@@ -358,8 +358,9 @@ CREATE TABLE inhta ();
358358
CREATETABLEinhtb () INHERITS (inhta);
359359
CREATETABLEinhtc () INHERITS (inhtb);
360360
CREATETABLEinhtd () INHERITS (inhta, inhtb, inhtc);
361-
ALTERTABLE inhta ADD COLUMN iint;
361+
ALTERTABLE inhta ADD COLUMN iint, ADD COLUMN jbigint DEFAULT1;
362362
\d+ inhta
363+
\d+ inhtd
363364
DROPTABLE inhta, inhtb, inhtc, inhtd;
364365

365366
-- Test for renaming in diamond inheritance

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp