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

Commit02a8d0c

Browse files
committed
Remove pg_attribute.attcacheoff column
The column is no longer needed as the offset is now cached in theCompactAttribute struct per commit5983a4c.Author: David RowleyReviewed-by: Andres Freund, Victor YegorovDiscussion:https://postgr.es/m/CAApHDvrBztXP3yx=NKNmo3xwFAFhEdyPnvrDg3=M0RhDs+4vYw@mail.gmail.com
1 parent5463715 commit02a8d0c

File tree

10 files changed

+9
-71
lines changed

10 files changed

+9
-71
lines changed

‎doc/src/sgml/catalogs.sgml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,17 +1186,6 @@
11861186
</para></entry>
11871187
</row>
11881188

1189-
<row>
1190-
<entry role="catalog_table_entry"><para role="column_definition">
1191-
<structfield>attcacheoff</structfield> <type>int4</type>
1192-
</para>
1193-
<para>
1194-
Always -1 in storage, but when loaded into a row descriptor
1195-
in memory this might be updated to cache the offset of the attribute
1196-
within the row
1197-
</para></entry>
1198-
</row>
1199-
12001189
<row>
12011190
<entry role="catalog_table_entry"><para role="column_definition">
12021191
<structfield>atttypmod</structfield> <type>int4</type>

‎src/backend/access/common/tupdesc.c

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -388,17 +388,7 @@ TupleDescCopyEntry(TupleDesc dst, AttrNumber dstAttno,
388388

389389
memcpy(dstAtt,srcAtt,ATTRIBUTE_FIXED_PART_SIZE);
390390

391-
/*
392-
* Aside from updating the attno, we'd better reset attcacheoff.
393-
*
394-
* XXX Actually, to be entirely safe we'd need to reset the attcacheoff of
395-
* all following columns in dst as well. Current usage scenarios don't
396-
* require that though, because all following columns will get initialized
397-
* by other uses of this function or TupleDescInitEntry. So we cheat a
398-
* bit to avoid a useless O(N^2) penalty.
399-
*/
400391
dstAtt->attnum=dstAttno;
401-
dstAtt->attcacheoff=-1;
402392

403393
/* since we're not copying constraints or defaults, clear these */
404394
dstAtt->attnotnull= false;
@@ -528,9 +518,8 @@ equalTupleDescs(TupleDesc tupdesc1, TupleDesc tupdesc2)
528518
* them (since atttypid will be zero for all dropped columns) and in
529519
* general it seems safer to check them always.
530520
*
531-
* attcacheoff must NOT be checked since it's possibly not set in both
532-
* copies. We also intentionally ignore atthasmissing, since that's
533-
* not very relevant in tupdescs, which lack the attmissingval field.
521+
* We intentionally ignore atthasmissing, since that's not very
522+
* relevant in tupdescs, which lack the attmissingval field.
534523
*/
535524
if (strcmp(NameStr(attr1->attname),NameStr(attr2->attname))!=0)
536525
return false;
@@ -771,7 +760,6 @@ TupleDescInitEntry(TupleDesc desc,
771760
elseif (attributeName!=NameStr(att->attname))
772761
namestrcpy(&(att->attname),attributeName);
773762

774-
att->attcacheoff=-1;
775763
att->atttypmod=typmod;
776764

777765
att->attnum=attributeNumber;
@@ -835,7 +823,6 @@ TupleDescInitBuiltinEntry(TupleDesc desc,
835823
Assert(attributeName!=NULL);
836824
namestrcpy(&(att->attname),attributeName);
837825

838-
att->attcacheoff=-1;
839826
att->atttypmod=typmod;
840827

841828
att->attnum=attributeNumber;

‎src/backend/bootstrap/bootstrap.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,6 @@ DefineAttr(char *name, char *type, int attnum, int nullness)
580580
if (OidIsValid(attrtypes[attnum]->attcollation))
581581
attrtypes[attnum]->attcollation=C_COLLATION_OID;
582582

583-
attrtypes[attnum]->attcacheoff=-1;
584583
attrtypes[attnum]->atttypmod=-1;
585584
attrtypes[attnum]->attislocal= true;
586585

‎src/backend/catalog/heap.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@ static const FormData_pg_attribute a1 = {
144144
.atttypid=TIDOID,
145145
.attlen=sizeof(ItemPointerData),
146146
.attnum=SelfItemPointerAttributeNumber,
147-
.attcacheoff=-1,
148147
.atttypmod=-1,
149148
.attbyval= false,
150149
.attalign=TYPALIGN_SHORT,
@@ -158,7 +157,6 @@ static const FormData_pg_attribute a2 = {
158157
.atttypid=XIDOID,
159158
.attlen=sizeof(TransactionId),
160159
.attnum=MinTransactionIdAttributeNumber,
161-
.attcacheoff=-1,
162160
.atttypmod=-1,
163161
.attbyval= true,
164162
.attalign=TYPALIGN_INT,
@@ -172,7 +170,6 @@ static const FormData_pg_attribute a3 = {
172170
.atttypid=CIDOID,
173171
.attlen=sizeof(CommandId),
174172
.attnum=MinCommandIdAttributeNumber,
175-
.attcacheoff=-1,
176173
.atttypmod=-1,
177174
.attbyval= true,
178175
.attalign=TYPALIGN_INT,
@@ -186,7 +183,6 @@ static const FormData_pg_attribute a4 = {
186183
.atttypid=XIDOID,
187184
.attlen=sizeof(TransactionId),
188185
.attnum=MaxTransactionIdAttributeNumber,
189-
.attcacheoff=-1,
190186
.atttypmod=-1,
191187
.attbyval= true,
192188
.attalign=TYPALIGN_INT,
@@ -200,7 +196,6 @@ static const FormData_pg_attribute a5 = {
200196
.atttypid=CIDOID,
201197
.attlen=sizeof(CommandId),
202198
.attnum=MaxCommandIdAttributeNumber,
203-
.attcacheoff=-1,
204199
.atttypmod=-1,
205200
.attbyval= true,
206201
.attalign=TYPALIGN_INT,
@@ -220,7 +215,6 @@ static const FormData_pg_attribute a6 = {
220215
.atttypid=OIDOID,
221216
.attlen=sizeof(Oid),
222217
.attnum=TableOidAttributeNumber,
223-
.attcacheoff=-1,
224218
.atttypmod=-1,
225219
.attbyval= true,
226220
.attalign=TYPALIGN_INT,
@@ -684,11 +678,10 @@ CheckAttributeType(const char *attname,
684678
*Construct and insert a set of tuples in pg_attribute.
685679
*
686680
* Caller has already opened and locked pg_attribute. tupdesc contains the
687-
* attributes to insert. attcacheoff is always initialized to -1.
688-
* tupdesc_extra supplies the values for certain variable-length/nullable
689-
* pg_attribute fields and must contain the same number of elements as tupdesc
690-
* or be NULL. The other variable-length fields of pg_attribute are always
691-
* initialized to null values.
681+
* attributes to insert. tupdesc_extra supplies the values for certain
682+
* variable-length/nullable pg_attribute fields and must contain the same
683+
* number of elements as tupdesc or be NULL. The other variable-length fields
684+
* of pg_attribute are always initialized to null values.
692685
*
693686
* indstate is the index state for CatalogTupleInsertWithInfo. It can be
694687
* passed as NULL, in which case we'll fetch the necessary info. (Don't do
@@ -740,7 +733,6 @@ InsertPgAttributeTuples(Relation pg_attribute_rel,
740733
slot[slotCount]->tts_values[Anum_pg_attribute_atttypid-1]=ObjectIdGetDatum(attrs->atttypid);
741734
slot[slotCount]->tts_values[Anum_pg_attribute_attlen-1]=Int16GetDatum(attrs->attlen);
742735
slot[slotCount]->tts_values[Anum_pg_attribute_attnum-1]=Int16GetDatum(attrs->attnum);
743-
slot[slotCount]->tts_values[Anum_pg_attribute_attcacheoff-1]=Int32GetDatum(-1);
744736
slot[slotCount]->tts_values[Anum_pg_attribute_atttypmod-1]=Int32GetDatum(attrs->atttypmod);
745737
slot[slotCount]->tts_values[Anum_pg_attribute_attndims-1]=Int16GetDatum(attrs->attndims);
746738
slot[slotCount]->tts_values[Anum_pg_attribute_attbyval-1]=BoolGetDatum(attrs->attbyval);

‎src/backend/catalog/index.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,6 @@ ConstructTupleDescriptor(Relation heapRelation,
320320

321321
MemSet(to,0,ATTRIBUTE_FIXED_PART_SIZE);
322322
to->attnum=i+1;
323-
to->attcacheoff=-1;
324323
to->attislocal= true;
325324
to->attcollation= (i<numkeyatts) ?collationIds[i] :InvalidOid;
326325

‎src/backend/utils/cache/relcache.c

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -661,19 +661,6 @@ RelationBuildTupleDesc(Relation relation)
661661
elog(ERROR,"pg_attribute catalog is missing %d attribute(s) for relation OID %u",
662662
need,RelationGetRelid(relation));
663663

664-
/*
665-
* The attcacheoff values we read from pg_attribute should all be -1
666-
* ("unknown"). Verify this if assert checking is on.
667-
*/
668-
#ifdefUSE_ASSERT_CHECKING
669-
{
670-
inti;
671-
672-
for (i=0;i<RelationGetNumberOfAttributes(relation);i++)
673-
Assert(TupleDescAttr(relation->rd_att,i)->attcacheoff==-1);
674-
}
675-
#endif
676-
677664
/*
678665
* We can easily set the attcacheoff value for the first attribute: it
679666
* must be zero. This eliminates the need for special cases for attnum=1
@@ -1964,8 +1951,6 @@ formrdesc(const char *relationName, Oid relationReltype,
19641951
&attrs[i],
19651952
ATTRIBUTE_FIXED_PART_SIZE);
19661953
has_not_null |=attrs[i].attnotnull;
1967-
/* make sure attcacheoff is valid */
1968-
TupleDescAttr(relation->rd_att,i)->attcacheoff=-1;
19691954

19701955
populate_compact_attribute(relation->rd_att,i);
19711956
}
@@ -4401,8 +4386,6 @@ BuildHardcodedDescriptor(int natts, const FormData_pg_attribute *attrs)
44014386
for (i=0;i<natts;i++)
44024387
{
44034388
memcpy(TupleDescAttr(result,i),&attrs[i],ATTRIBUTE_FIXED_PART_SIZE);
4404-
/* make sure attcacheoff is valid */
4405-
TupleDescAttr(result,i)->attcacheoff=-1;
44064389

44074390
populate_compact_attribute(result,i);
44084391
}

‎src/include/catalog/catversion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,6 @@
5757
*/
5858

5959
/*yyyymmddN */
60-
#defineCATALOG_VERSION_NO202412191
60+
#defineCATALOG_VERSION_NO202412201
6161

6262
#endif

‎src/include/catalog/pg_attribute.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,6 @@ CATALOG(pg_attribute,1249,AttributeRelationId) BKI_BOOTSTRAP BKI_ROWTYPE_OID(75,
7373
*/
7474
int16attnum;
7575

76-
/*
77-
* fastgetattr() uses attcacheoff to cache byte offsets of attributes in
78-
* heap tuples. The value actually stored in pg_attribute (-1) indicates
79-
* no cached value. But when we copy these tuples into a tuple
80-
* descriptor, we may then update attcacheoff in the copies. This speeds
81-
* up the attribute walking process.
82-
*/
83-
int32attcacheoffBKI_DEFAULT(-1);
84-
8576
/*
8677
* atttypmod records type-specific data supplied at table creation time
8778
* (for example, the max length of a varchar field). It is passed to

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -550,8 +550,7 @@ WHERE pc.relkind IN ('r', 't', 'm') and
550550
SELECT a1.attrelid, a1.attname
551551
FROM pg_attribute as a1
552552
WHERE a1.attrelid = 0 OR a1.atttypid = 0 OR a1.attnum = 0 OR
553-
a1.attcacheoff != -1 OR a1.attinhcount < 0 OR
554-
(a1.attinhcount = 0 AND NOT a1.attislocal);
553+
a1.attinhcount < 0 OR (a1.attinhcount = 0 AND NOT a1.attislocal);
555554
attrelid | attname
556555
----------+---------
557556
(0 rows)

‎src/test/regress/sql/type_sanity.sql

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,7 @@ WHERE pc.relkind IN ('r', 't', 'm') and
397397
SELECTa1.attrelid,a1.attname
398398
FROM pg_attributeas a1
399399
WHEREa1.attrelid=0ORa1.atttypid=0ORa1.attnum=0OR
400-
a1.attcacheoff!=-1ORa1.attinhcount<0OR
401-
(a1.attinhcount=0AND NOTa1.attislocal);
400+
a1.attinhcount<0OR (a1.attinhcount=0AND NOTa1.attislocal);
402401

403402
-- Cross-check attnum against parent relation
404403

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp