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

Commit04abb54

Browse files
committed
Fix for indexing problem (?): heap tuple was pfree-d before CatalogIndexInsert()...
1 parentb5ed4be commit04abb54

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

‎src/backend/catalog/index.c

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.61 1998/09/07 05:35:37 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.62 1998/09/09 03:42:52 vadim Exp $
1111
*
1212
*
1313
* INTERFACE ROUTINES
@@ -64,19 +64,21 @@
6464
#defineNTUPLES_PER_PAGE(natts) (BLCKSZ/((natts)*AVG_TUPLE_SIZE))
6565

6666
/* non-export function prototypes */
67-
staticOidRelationNameGetObjectId(char*relationName,Relationpg_class);
67+
staticOid
68+
RelationNameGetObjectId(char*relationName,Relationpg_class);
6869
staticOidGetHeapRelationOid(char*heapRelationName,char*indexRelationName);
6970
staticTupleDescBuildFuncTupleDesc(FuncIndexInfo*funcInfo);
7071
staticTupleDescConstructTupleDescriptor(Oidheapoid,RelationheapRelation,
7172
List*attributeList,
7273
intnumatts,AttrNumber*attNums);
7374

7475
staticvoidConstructIndexReldesc(RelationindexRelation,Oidamoid);
75-
staticOidUpdateRelationRelation(RelationindexRelation);
76+
staticOidUpdateRelationRelation(RelationindexRelation);
7677
staticvoidInitializeAttributeOids(RelationindexRelation,
7778
intnumatts,
7879
Oidindexoid);
79-
staticvoidAppendAttributeTuples(RelationindexRelation,intnumatts);
80+
staticvoid
81+
AppendAttributeTuples(RelationindexRelation,intnumatts);
8082
staticvoidUpdateIndexRelation(Oidindexoid,Oidheapoid,
8183
FuncIndexInfo*funcInfo,intnatts,
8284
AttrNumber*attNums,Oid*classOids,Node*predicate,
@@ -550,9 +552,11 @@ UpdateRelationRelation(Relation indexRelation)
550552
sizeof(*indexRelation->rd_rel),
551553
(char*)indexRelation->rd_rel);
552554

553-
/*
554-
*The new tuple must have the same oid as the heap_create() we just
555-
*did.
555+
/* ----------------
556+
*the new tuple must have the same oid as the relcache entry for the
557+
*index.sure would be embarassing to do this sort of thing in polite
558+
*company.
559+
* ----------------
556560
*/
557561
tuple->t_oid=RelationGetRelid(indexRelation);
558562
heap_insert(pg_class,tuple);
@@ -1074,7 +1078,7 @@ index_create(char *heapRelationName,
10741078

10751079
/* ----------------
10761080
* add index to catalogs
1077-
* (INSERT pg_class tuple)
1081+
* (append RELATION tuple)
10781082
* ----------------
10791083
*/
10801084
indexoid=UpdateRelationRelation(indexRelation);
@@ -1260,7 +1264,8 @@ FormIndexDatum(int numberOfAttributes,
12601264
char*nullv,
12611265
FuncIndexInfoPtrfInfo)
12621266
{
1263-
AttrNumberattOff;
1267+
AttrNumberi;
1268+
intoffset;
12641269
boolisNull;
12651270

12661271
/* ----------------
@@ -1270,16 +1275,18 @@ FormIndexDatum(int numberOfAttributes,
12701275
* ----------------
12711276
*/
12721277

1273-
for (attOff=0;attOff<numberOfAttributes;attOff++)
1278+
for (i=1;i <=numberOfAttributes;i++)
12741279
{
1275-
datum[attOff]=PointerGetDatum(GetIndexValue(heapTuple,
1280+
offset=AttrNumberGetAttrOffset(i);
1281+
1282+
datum[offset]=PointerGetDatum(GetIndexValue(heapTuple,
12761283
heapDescriptor,
1277-
attOff,
1284+
offset,
12781285
attributeNumber,
12791286
fInfo,
12801287
&isNull));
12811288

1282-
nullv[attOff]= (isNull) ?'n' :' ';
1289+
nullv[offset]= (isNull) ?'n' :' ';
12831290
}
12841291
}
12851292

@@ -1417,10 +1424,10 @@ UpdateStats(Oid relid, long reltuples, bool hasindex)
14171424

14181425
newtup=heap_modifytuple(tuple,pg_class,values,nulls,replace);
14191426
heap_replace(pg_class,&tuple->t_ctid,newtup);
1420-
pfree(newtup);
14211427
CatalogOpenIndices(Num_pg_class_indices,Name_pg_class_indices,idescs);
14221428
CatalogIndexInsert(idescs,Num_pg_class_indices,pg_class,newtup);
14231429
CatalogCloseIndices(Num_pg_class_indices,idescs);
1430+
pfree(newtup);
14241431
}
14251432

14261433
if (!IsBootstrapProcessingMode())

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp