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

Commit4a70002

Browse files
committed
fix for index problem.
1 parent3130942 commit4a70002

File tree

9 files changed

+69
-61
lines changed

9 files changed

+69
-61
lines changed

‎src/backend/access/heap/heapam.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.32 1998/08/19 02:01:05 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.33 1998/08/20 22:07:30 momjian Exp $
1111
*
1212
*
1313
* INTERFACE ROUTINES
@@ -1274,10 +1274,10 @@ heap_delete(Relation relation, ItemPointer tid)
12741274
* ----------------
12751275
*/
12761276
int
1277-
heap_replace(Relationrelation,ItemPointerotid,HeapTupletup)
1277+
heap_replace(Relationrelation,ItemPointerotid,HeapTuplereplace_tuple)
12781278
{
12791279
ItemIdlp;
1280-
HeapTupletp;
1280+
HeapTupleold_tuple;
12811281
Pagedp;
12821282
Bufferbuffer;
12831283
HeapTupletuple;
@@ -1319,8 +1319,8 @@ heap_replace(Relation relation, ItemPointer otid, HeapTuple tup)
13191319
* ----------------
13201320
*/
13211321

1322-
tp= (HeapTuple)PageGetItem(dp,lp);
1323-
Assert(HeapTupleIsValid(tp));
1322+
old_tuple= (HeapTuple)PageGetItem(dp,lp);
1323+
Assert(HeapTupleIsValid(old_tuple));
13241324

13251325
/* -----------------
13261326
*the following test should be able to catch all non-functional
@@ -1333,7 +1333,7 @@ heap_replace(Relation relation, ItemPointer otid, HeapTuple tup)
13331333
* -----------------
13341334
*/
13351335

1336-
if (TupleUpdatedByCurXactAndCmd(tp))
1336+
if (TupleUpdatedByCurXactAndCmd(old_tuple))
13371337
{
13381338
elog(NOTICE,"Non-functional update, only first update is performed");
13391339
if (IsSystemRelationName(RelationGetRelationName(relation)->data))
@@ -1367,43 +1367,43 @@ heap_replace(Relation relation, ItemPointer otid, HeapTuple tup)
13671367
}
13681368

13691369
/* XXX order problems if not atomic assignment ??? */
1370-
tup->t_oid=tp->t_oid;
1371-
TransactionIdStore(GetCurrentTransactionId(),&(tup->t_xmin));
1372-
tup->t_cmin=GetCurrentCommandId();
1373-
StoreInvalidTransactionId(&(tup->t_xmax));
1374-
tup->t_infomask &= ~(HEAP_XACT_MASK);
1375-
tup->t_infomask |=HEAP_XMAX_INVALID;
1370+
replace_tuple->t_oid=old_tuple->t_oid;
1371+
TransactionIdStore(GetCurrentTransactionId(),&(replace_tuple->t_xmin));
1372+
replace_tuple->t_cmin=GetCurrentCommandId();
1373+
StoreInvalidTransactionId(&(replace_tuple->t_xmax));
1374+
replace_tuple->t_infomask &= ~(HEAP_XACT_MASK);
1375+
replace_tuple->t_infomask |=HEAP_XMAX_INVALID;
13761376

13771377
/* ----------------
13781378
*insert new item
13791379
* ----------------
13801380
*/
1381-
if ((unsigned)DOUBLEALIGN(tup->t_len) <=PageGetFreeSpace((Page)dp))
1382-
RelationPutHeapTuple(relation,BufferGetBlockNumber(buffer),tup);
1381+
if ((unsigned)DOUBLEALIGN(replace_tuple->t_len) <=PageGetFreeSpace((Page)dp))
1382+
RelationPutHeapTuple(relation,BufferGetBlockNumber(buffer),replace_tuple);
13831383
else
13841384
{
13851385
/* ----------------
13861386
*new item won't fit on same page as old item, have to look
13871387
*for a new place to put it.
13881388
* ----------------
13891389
*/
1390-
doinsert(relation,tup);
1390+
doinsert(relation,replace_tuple);
13911391
}
13921392

13931393
/* ----------------
13941394
*new item in place, now record transaction information
13951395
* ----------------
13961396
*/
1397-
TransactionIdStore(GetCurrentTransactionId(),&(tp->t_xmax));
1398-
tp->t_cmax=GetCurrentCommandId();
1399-
tp->t_infomask &= ~(HEAP_XMAX_COMMITTED |HEAP_XMAX_INVALID);
1397+
TransactionIdStore(GetCurrentTransactionId(),&(old_tuple->t_xmax));
1398+
old_tuple->t_cmax=GetCurrentCommandId();
1399+
old_tuple->t_infomask &= ~(HEAP_XMAX_COMMITTED |HEAP_XMAX_INVALID);
14001400

14011401
/* ----------------
14021402
*invalidate caches
14031403
* ----------------
14041404
*/
14051405
SetRefreshWhenInvalidate(ImmediateInvalidation);
1406-
RelationInvalidateHeapTuple(relation,tp);
1406+
RelationInvalidateHeapTuple(relation,old_tuple);
14071407
SetRefreshWhenInvalidate((bool) !ImmediateInvalidation);
14081408

14091409
WriteBuffer(buffer);

‎src/backend/catalog/heap.c

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.58 1998/08/19 02:01:30 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.59 1998/08/20 22:07:32 momjian Exp $
1111
*
1212
* INTERFACE ROUTINES
1313
*heap_create()- Create an uncataloged heap relation
@@ -1051,18 +1051,20 @@ DeletePgAttributeTuples(Relation rel)
10511051
*/
10521052
RelationSetLockForWrite(pg_attribute_desc);
10531053

1054-
attnum=FirstLowInvalidHeapAttributeNumber+1;/* cmax */
1055-
1056-
while (HeapTupleIsValid(tup=SearchSysCacheTupleCopy(ATTNUM,
1057-
ObjectIdGetDatum(rel->rd_att->attrs[0]->attrelid),
1058-
Int16GetDatum(attnum),
1059-
0,0)))
1054+
for (attnum=FirstLowInvalidHeapAttributeNumber+1;
1055+
attnum <=rel->rd_att->natts;
1056+
attnum++)
10601057
{
1061-
heap_delete(pg_attribute_desc,&tup->t_ctid);
1062-
pfree(tup);
1063-
attnum++;
1058+
if (HeapTupleIsValid(tup=SearchSysCacheTupleCopy(ATTNUM,
1059+
ObjectIdGetDatum(RelationGetRelid(rel)),
1060+
Int16GetDatum(attnum),
1061+
0,0)))
1062+
{
1063+
heap_delete(pg_attribute_desc,&tup->t_ctid);
1064+
pfree(tup);
1065+
}
10641066
}
1065-
1067+
10661068
/* ----------------
10671069
* Release the write lock
10681070
* ----------------
@@ -1104,8 +1106,10 @@ DeletePgTypeTuple(Relation rel)
11041106
*to this relation.
11051107
* ----------------
11061108
*/
1107-
ScanKeyEntryInitialize(&key,0,Anum_pg_type_typrelid,F_INT4EQ,
1108-
rel->rd_att->attrs[0]->attrelid);
1109+
ScanKeyEntryInitialize(&key,0,
1110+
Anum_pg_type_typrelid,
1111+
F_OIDEQ,
1112+
ObjectIdGetDatum(RelationGetRelid(rel)));
11091113

11101114
pg_type_scan=heap_beginscan(pg_type_desc,
11111115
0,
@@ -1140,7 +1144,9 @@ DeletePgTypeTuple(Relation rel)
11401144
pg_attribute_desc=heap_openr(AttributeRelationName);
11411145

11421146
ScanKeyEntryInitialize(&attkey,
1143-
0,Anum_pg_attribute_atttypid,F_INT4EQ,
1147+
0,
1148+
Anum_pg_attribute_atttypid,
1149+
F_OIDEQ,
11441150
typoid);
11451151

11461152
pg_attribute_scan=heap_beginscan(pg_attribute_desc,
@@ -1151,13 +1157,13 @@ DeletePgTypeTuple(Relation rel)
11511157

11521158
/* ----------------
11531159
*try and get a pg_attribute tuple. if we succeed it means
1154-
*wecant delete the relation because something depends on
1160+
*wecan't delete the relation because something depends on
11551161
*the schema.
11561162
* ----------------
11571163
*/
11581164
atttup=heap_getnext(pg_attribute_scan,0);
11591165

1160-
if (PointerIsValid(atttup))
1166+
if (HeapTupleIsValid(atttup))
11611167
{
11621168
Oidrelid= ((AttributeTupleForm)GETSTRUCT(atttup))->attrelid;
11631169

‎src/backend/catalog/index.c

Lines changed: 11 additions & 11 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.49 1998/08/2015:16:54 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.50 1998/08/2022:07:34 momjian Exp $
1111
*
1212
*
1313
* INTERFACE ROUTINES
@@ -1173,6 +1173,7 @@ index_destroy(Oid indexId)
11731173
{
11741174
RelationindexRelation;
11751175
RelationcatalogRelation;
1176+
RelationattributeRelation;
11761177
HeapTupletuple;
11771178
int16attnum;
11781179

@@ -1200,7 +1201,7 @@ index_destroy(Oid indexId)
12001201
* fix ATTRIBUTE relation
12011202
* ----------------
12021203
*/
1203-
catalogRelation=heap_openr(AttributeRelationName);
1204+
attributeRelation=heap_openr(AttributeRelationName);
12041205

12051206
attnum=1;/* indexes start at 1 */
12061207

@@ -1209,29 +1210,28 @@ index_destroy(Oid indexId)
12091210
Int16GetDatum(attnum),
12101211
0,0)))
12111212
{
1212-
heap_delete(catalogRelation,&tuple->t_ctid);
1213+
heap_delete(attributeRelation,&tuple->t_ctid);
12131214
pfree(tuple);
12141215
attnum++;
12151216
}
1216-
1217-
heap_close(catalogRelation);
1217+
heap_close(attributeRelation);
12181218

12191219
/* ----------------
12201220
* fix INDEX relation
12211221
* ----------------
12221222
*/
12231223
tuple=SearchSysCacheTupleCopy(INDEXRELID,
1224-
ObjectIdGetDatum(indexId),
1225-
0,0,0);
1224+
ObjectIdGetDatum(indexId),
1225+
0,0,0);
12261226

12271227
if (!HeapTupleIsValid(tuple))
1228-
{
12291228
elog(NOTICE,"IndexRelationDestroy: %s's INDEX tuple missing",
12301229
RelationGetRelationName(indexRelation));
1231-
}
1232-
heap_delete(catalogRelation,&tuple->t_ctid);
1230+
1231+
Assert(ItemPointerIsValid(&tuple->t_ctid));
1232+
1233+
heap_delete(indexRelation,&tuple->t_ctid);
12331234
pfree(tuple);
1234-
heap_close(catalogRelation);
12351235

12361236
/*
12371237
* flush cache and physically remove the file

‎src/backend/catalog/indexing.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.21 1998/08/2015:16:55 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.22 1998/08/2022:07:36 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -125,7 +125,7 @@ CatalogIndexInsert(Relation *idescs,
125125
InsertIndexResultindexRes;
126126

127127
indexDescriptor=RelationGetTupleDescriptor(idescs[i]);
128-
pgIndexTup=SearchSysCacheTuple(INDEXRELID,
128+
pgIndexTup=SearchSysCacheTupleCopy(INDEXRELID,
129129
ObjectIdGetDatum(idescs[i]->rd_id),
130130
0,0,0);
131131
Assert(pgIndexTup);
@@ -163,6 +163,7 @@ CatalogIndexInsert(Relation *idescs,
163163
&heapTuple->t_ctid,heapRelation);
164164
if (indexRes)
165165
pfree(indexRes);
166+
pfree(pgIndexTup);
166167
}
167168
}
168169

‎src/backend/catalog/pg_type.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.27 1998/08/19 02:01:38 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.28 1998/08/20 22:07:37 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -384,12 +384,12 @@ TypeCreate(char *typeName,
384384
values[i++]= (Datum)GetUserId();/* 2 */
385385
values[i++]= (Datum)internalSize;/* 3 */
386386
values[i++]= (Datum)externalSize;/* 4 */
387-
values[i++]= (Datum)passedByValue;/* 5 */
387+
values[i++]= (Datum)passedByValue;/* 5 */
388388
values[i++]= (Datum)typeType;/* 6 */
389389
values[i++]= (Datum) (bool)1;/* 7 */
390390
values[i++]= (Datum)typDelim;/* 8 */
391391
values[i++]= (Datum) (typeType=='c' ?relationOid :InvalidOid);/* 9 */
392-
values[i++]= (Datum)elementObjectId;/* 10 */
392+
values[i++]= (Datum)elementObjectId;/* 10 */
393393

394394
/*
395395
* arguments to type input and output functions must be 0
@@ -431,7 +431,7 @@ TypeCreate(char *typeName,
431431
func_error("TypeCreate",procname,1,argList,NULL);
432432
}
433433

434-
values[i++]= (Datum)tup->t_oid;/* 11 - 14 */
434+
values[i++]= (Datum)tup->t_oid;/* 11 - 14 */
435435
}
436436

437437
/* ----------------

‎src/backend/commands/vacuum.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.75 1998/08/2015:16:57 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.76 1998/08/2022:07:39 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -2217,7 +2217,7 @@ vc_mkindesc(Relation onerel, int nindices, Relation *Irel, IndDesc **Idesc)
22172217
cachetuple=SearchSysCacheTupleCopy(INDEXRELID,
22182218
ObjectIdGetDatum(RelationGetRelid(Irel[i])),
22192219
0,0,0);
2220-
Assert(tuple);
2220+
Assert(cachetuple);
22212221

22222222
/* get the buffer cache tuple */
22232223
tuple=heap_fetch(onerel,SnapshotNow,&cachetuple->t_ctid,&buffer);

‎src/backend/executor/execUtils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.35 1998/08/19 02:02:01 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.36 1998/08/20 22:07:41 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -690,7 +690,7 @@ ExecGetIndexKeyInfo(IndexTupleForm indexTuple,
690690
*the IndexCatalogInformation function in plancat.c
691691
*because IndexCatalogInformation is poorly written.
692692
*
693-
*It would be much better the functionality provided
693+
*It would be much betterifthe functionality provided
694694
*by this function and IndexCatalogInformation was
695695
*in the form of a small set of orthogonal routines..
696696
*If you are trying to understand this, I suggest you

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.13 1998/08/19 14:51:29 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.14 1998/08/20 22:07:43 momjian Exp $
1111
*
1212
* Note - this code is real crufty...
1313
*
@@ -643,6 +643,7 @@ RelationInvalidateHeapTuple(Relation relation, HeapTuple tuple)
643643
RelationIdRegisterLocalInvalid);
644644

645645
if (RefreshWhenInvalidate)
646+
/* what does this do? bjm 1998/08/20 */
646647
RelationInvalidateCatalogCacheTuple(relation,
647648
tuple,
648649
(void (*) ())NULL);

‎src/bin/initdb/initdb.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#
2727
#
2828
# IDENTIFICATION
29-
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.49 1998/08/2015:16:59 momjian Exp $
29+
# $Header: /cvsroot/pgsql/src/bin/initdb/Attic/initdb.sh,v 1.50 1998/08/2022:07:46 momjian Exp $
3030
#
3131
#-------------------------------------------------------------------------
3232

@@ -404,13 +404,13 @@ echo
404404
PGSQL_OPT="-o /dev/null -F -Q -D$PGDATA"
405405

406406
# If the COPY is first, the VACUUM generates an error, so we vacuum first
407-
echo"vacuuming template1"
407+
echo"Vacuuming template1"
408408
echo"vacuum"| postgres$PGSQL_OPT template1> /dev/null
409409

410410
echo"COPY pg_shadow TO '$PGDATA/pg_pwd' USING DELIMITERS '\\t'"| \
411411
postgres$PGSQL_OPT template1> /dev/null
412412

413-
echo"creating public pg_user view"
413+
echo"Creating public pg_user view"
414414
echo"CREATE TABLE xpg_user (\
415415
usenamename,\
416416
usesysidint4,\
@@ -436,7 +436,7 @@ echo "CREATE RULE _RETpg_user AS ON SELECT TO pg_user DO INSTEAD\
436436
echo"REVOKE ALL on pg_shadow FROM public"| \
437437
postgres$PGSQL_OPT template1> /dev/null
438438

439-
echo"loading pg_description"
439+
echo"Loading pg_description"
440440
echo"copy pg_description from '$TEMPLATE_DESCR'"| \
441441
postgres$PGSQL_OPT template1> /dev/null
442442
echo"copy pg_description from '$GLOBAL_DESCR'"| \

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp