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

Commit1d617a2

Browse files
committed
Change one loop in ATRewriteTable to use 1-based attnums
All TupleDescAttr() calls in tablecmds.c that aren't in loops across allattributes use AttrNumber-style indexes (1-based); there was only oneplace in ATRewriteTable that was stashing 0-based indexes in a list forlater processing. Switch that to use attnums for consistency.Author: jian he <jian.universality@gmail.com>Discussion:https://postgr.es/m/CACJufxEoYA5ScUr2=CmA1xcpaS_1ixneDbEkVU77X1ctGxY2mA@mail.gmail.com
1 parentce1a75c commit1d617a2

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

‎src/backend/commands/tablecmds.c

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6189,7 +6189,7 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
61896189
Form_pg_attribute attr = TupleDescAttr(newTupDesc, i);
61906190

61916191
if (attr->attnotnull && !attr->attisdropped)
6192-
notnull_attrs = lappend_int(notnull_attrs,i);
6192+
notnull_attrs = lappend_int(notnull_attrs,attr->attnum);
61936193
}
61946194
if (notnull_attrs)
61956195
needscan = true;
@@ -6370,20 +6370,18 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
63706370
/* Now check any constraints on the possibly-changed tuple */
63716371
econtext->ecxt_scantuple = insertslot;
63726372

6373-
foreach(l, notnull_attrs)
6373+
foreach_int(attn, notnull_attrs)
63746374
{
6375-
intattn = lfirst_int(l);
6376-
6377-
if (slot_attisnull(insertslot, attn + 1))
6375+
if (slot_attisnull(insertslot, attn))
63786376
{
6379-
Form_pg_attribute attr = TupleDescAttr(newTupDesc, attn);
6377+
Form_pg_attribute attr = TupleDescAttr(newTupDesc, attn - 1);
63806378

63816379
ereport(ERROR,
63826380
(errcode(ERRCODE_NOT_NULL_VIOLATION),
63836381
errmsg("column \"%s\" of relation \"%s\" contains null values",
63846382
NameStr(attr->attname),
63856383
RelationGetRelationName(oldrel)),
6386-
errtablecol(oldrel, attn + 1)));
6384+
errtablecol(oldrel, attn)));
63876385
}
63886386
}
63896387

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp