mirror of
https://github.com/postgres/postgres.git
synced 2025-08-30 06:01:21 +03:00
New HeapTuple structure/interface.
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.41 1998/10/06 02:39:59 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.42 1998/11/27 19:51:53 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -321,7 +321,7 @@ Async_Unlisten(char *relname, int pid)
|
||||
{
|
||||
lRel = heap_openr(ListenerRelationName);
|
||||
RelationSetLockForWrite(lRel);
|
||||
heap_delete(lRel, &lTuple->t_ctid);
|
||||
heap_delete(lRel, &lTuple->t_self);
|
||||
RelationUnsetLockForWrite(lRel);
|
||||
heap_close(lRel);
|
||||
}
|
||||
@@ -369,7 +369,7 @@ Async_UnlistenAll()
|
||||
sRel = heap_beginscan(lRel, 0, SnapshotNow, 1, key);
|
||||
|
||||
while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0)))
|
||||
heap_delete(lRel, &lTuple->t_ctid);
|
||||
heap_delete(lRel, &lTuple->t_self);
|
||||
|
||||
heap_endscan(sRel);
|
||||
RelationUnsetLockForWrite(lRel);
|
||||
@@ -516,7 +516,7 @@ AtCommit_Notify()
|
||||
* but as far as I can see we should just do it for any
|
||||
* failure (certainly at least for EPERM too...)
|
||||
*/
|
||||
heap_delete(lRel, &lTuple->t_ctid);
|
||||
heap_delete(lRel, &lTuple->t_self);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
@@ -527,7 +527,7 @@ AtCommit_Notify()
|
||||
{
|
||||
rTuple = heap_modifytuple(lTuple, lRel,
|
||||
value, nulls, repl);
|
||||
heap_replace(lRel, &lTuple->t_ctid, rTuple);
|
||||
heap_replace(lRel, &lTuple->t_self, rTuple);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -772,7 +772,7 @@ ProcessIncomingNotify(void)
|
||||
NotifyMyFrontEnd(relname, sourcePID);
|
||||
/* Rewrite the tuple with 0 in notification column */
|
||||
rTuple = heap_modifytuple(lTuple, lRel, value, nulls, repl);
|
||||
heap_replace(lRel, &lTuple->t_ctid, rTuple);
|
||||
heap_replace(lRel, &lTuple->t_self, rTuple);
|
||||
}
|
||||
}
|
||||
heap_endscan(sRel);
|
||||
|
@@ -14,7 +14,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.32 1998/09/23 04:22:01 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.33 1998/11/27 19:51:54 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -330,15 +330,14 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap)
|
||||
static void
|
||||
rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex)
|
||||
{
|
||||
Relation LocalNewHeap,
|
||||
LocalOldHeap,
|
||||
LocalOldIndex;
|
||||
IndexScanDesc ScanDesc;
|
||||
RetrieveIndexResult ScanResult;
|
||||
ItemPointer HeapTid;
|
||||
HeapTuple LocalHeapTuple;
|
||||
Buffer LocalBuffer;
|
||||
Oid OIDNewHeapInsert;
|
||||
Relation LocalNewHeap,
|
||||
LocalOldHeap,
|
||||
LocalOldIndex;
|
||||
IndexScanDesc ScanDesc;
|
||||
RetrieveIndexResult ScanResult;
|
||||
HeapTupleData LocalHeapTuple;
|
||||
Buffer LocalBuffer;
|
||||
Oid OIDNewHeapInsert;
|
||||
|
||||
/*
|
||||
* Open the relations I need. Scan through the OldHeap on the OldIndex
|
||||
@@ -353,10 +352,10 @@ rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex)
|
||||
while ((ScanResult = index_getnext(ScanDesc, ForwardScanDirection)) != NULL)
|
||||
{
|
||||
|
||||
HeapTid = &ScanResult->heap_iptr;
|
||||
LocalHeapTuple = heap_fetch(LocalOldHeap, SnapshotNow, HeapTid, &LocalBuffer);
|
||||
LocalHeapTuple.t_self = ScanResult->heap_iptr;
|
||||
heap_fetch(LocalOldHeap, SnapshotNow, &LocalHeapTuple, &LocalBuffer);
|
||||
OIDNewHeapInsert =
|
||||
heap_insert(LocalNewHeap, LocalHeapTuple);
|
||||
heap_insert(LocalNewHeap, &LocalHeapTuple);
|
||||
pfree(ScanResult);
|
||||
ReleaseBuffer(LocalBuffer);
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.32 1998/09/01 04:27:46 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.33 1998/11/27 19:51:54 vadim Exp $
|
||||
*
|
||||
* NOTES
|
||||
* The PortalExecutorHeapMemory crap needs to be eliminated
|
||||
@@ -405,7 +405,7 @@ PerformAddAttribute(char *relationName,
|
||||
if (hasindex)
|
||||
CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, idescs);
|
||||
|
||||
attributeD.attrelid = reltup->t_oid;
|
||||
attributeD.attrelid = reltup->t_data->t_oid;
|
||||
|
||||
attributeTuple = heap_addheader(Natts_pg_attribute,
|
||||
sizeof attributeD,
|
||||
@@ -422,7 +422,7 @@ PerformAddAttribute(char *relationName,
|
||||
int attnelems;
|
||||
|
||||
tup = SearchSysCacheTuple(ATTNAME,
|
||||
ObjectIdGetDatum(reltup->t_oid),
|
||||
ObjectIdGetDatum(reltup->t_data->t_oid),
|
||||
PointerGetDatum(colDef->colname),
|
||||
0, 0);
|
||||
|
||||
@@ -456,7 +456,7 @@ PerformAddAttribute(char *relationName,
|
||||
if (!HeapTupleIsValid(typeTuple))
|
||||
elog(ERROR, "Add: type \"%s\" nonexistent", typename);
|
||||
namestrcpy(&(attribute->attname), colDef->colname);
|
||||
attribute->atttypid = typeTuple->t_oid;
|
||||
attribute->atttypid = typeTuple->t_data->t_oid;
|
||||
attribute->attlen = form->typlen;
|
||||
attributeD.attdisbursion = 0;
|
||||
attribute->attcacheoff = -1;
|
||||
@@ -482,7 +482,7 @@ PerformAddAttribute(char *relationName,
|
||||
heap_close(attrdesc);
|
||||
|
||||
((Form_pg_class) GETSTRUCT(reltup))->relnatts = maxatts;
|
||||
heap_replace(rel, &reltup->t_ctid, reltup);
|
||||
heap_replace(rel, &reltup->t_self, reltup);
|
||||
|
||||
/* keep catalog indices current */
|
||||
CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs);
|
||||
|
@@ -6,7 +6,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.63 1998/10/26 00:59:21 tgl Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.64 1998/11/27 19:51:54 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -277,7 +277,7 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
|
||||
|
||||
if (oids && !binary)
|
||||
{
|
||||
fputs(oidout(tuple->t_oid), fp);
|
||||
fputs(oidout(tuple->t_data->t_oid), fp);
|
||||
fputc(delim[0], fp);
|
||||
}
|
||||
|
||||
@@ -331,10 +331,10 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
|
||||
null_ct++;
|
||||
}
|
||||
|
||||
length = tuple->t_len - tuple->t_hoff;
|
||||
length = tuple->t_len - tuple->t_data->t_hoff;
|
||||
fwrite(&length, sizeof(int32), 1, fp);
|
||||
if (oids)
|
||||
fwrite((char *) &tuple->t_oid, sizeof(int32), 1, fp);
|
||||
fwrite((char *) &tuple->t_data->t_oid, sizeof(int32), 1, fp);
|
||||
|
||||
fwrite(&null_ct, sizeof(int32), 1, fp);
|
||||
if (null_ct > 0)
|
||||
@@ -348,7 +348,8 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
|
||||
}
|
||||
}
|
||||
}
|
||||
fwrite((char *) tuple + tuple->t_hoff, length, 1, fp);
|
||||
fwrite((char *) tuple->t_data + tuple->t_data->t_hoff,
|
||||
length, 1, fp);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -678,7 +679,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
|
||||
*/
|
||||
tuple = heap_formtuple(tupDesc, values, nulls);
|
||||
if (oids)
|
||||
tuple->t_oid = loaded_oid;
|
||||
tuple->t_data->t_oid = loaded_oid;
|
||||
|
||||
skip_tuple = false;
|
||||
/* BEFORE ROW INSERT Triggers */
|
||||
@@ -706,17 +707,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
|
||||
*/
|
||||
|
||||
if (rel->rd_att->constr)
|
||||
{
|
||||
HeapTuple newtuple;
|
||||
|
||||
newtuple = ExecConstraints("CopyFrom", rel, tuple);
|
||||
|
||||
if (newtuple != tuple)
|
||||
{
|
||||
pfree(tuple);
|
||||
tuple = newtuple;
|
||||
}
|
||||
}
|
||||
ExecConstraints("CopyFrom", rel, tuple);
|
||||
|
||||
heap_insert(rel, tuple);
|
||||
|
||||
@@ -746,7 +737,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
|
||||
index_nulls,
|
||||
finfoP[i]);
|
||||
indexRes = index_insert(index_rels[i], idatum, index_nulls,
|
||||
&(tuple->t_ctid), rel);
|
||||
&(tuple->t_self), rel);
|
||||
if (indexRes)
|
||||
pfree(indexRes);
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.35 1998/10/01 22:45:29 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.36 1998/11/27 19:51:55 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -409,11 +409,11 @@ StoreCatalogInheritance(Oid relationId, List *supers)
|
||||
/*
|
||||
* build idList for use below
|
||||
*/
|
||||
idList = lappendi(idList, tuple->t_oid);
|
||||
idList = lappendi(idList, tuple->t_data->t_oid);
|
||||
|
||||
datum[0] = ObjectIdGetDatum(relationId); /* inhrel */
|
||||
datum[1] = ObjectIdGetDatum(tuple->t_oid); /* inhparent */
|
||||
datum[2] = Int16GetDatum(seqNumber); /* inhseqno */
|
||||
datum[0] = ObjectIdGetDatum(relationId); /* inhrel */
|
||||
datum[1] = ObjectIdGetDatum(tuple->t_data->t_oid); /* inhparent */
|
||||
datum[2] = Int16GetDatum(seqNumber); /* inhseqno */
|
||||
|
||||
nullarr[0] = ' ';
|
||||
nullarr[1] = ' ';
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.25 1998/10/05 02:49:36 thomas Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.26 1998/11/27 19:51:56 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -251,7 +251,7 @@ check_permissions(char *command,
|
||||
Anum_pg_database_datdba,
|
||||
RelationGetDescr(dbrel),
|
||||
(char *) NULL);
|
||||
*dbIdP = dbtup->t_oid;
|
||||
*dbIdP = dbtup->t_data->t_oid;
|
||||
dbtext = (text *) heap_getattr(dbtup,
|
||||
Anum_pg_database_datpath,
|
||||
RelationGetDescr(dbrel),
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.27 1998/09/23 04:22:03 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.28 1998/11/27 19:51:56 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -105,7 +105,7 @@ DefineIndex(char *heapRelationName,
|
||||
elog(ERROR, "DefineIndex: %s relation not found",
|
||||
heapRelationName);
|
||||
}
|
||||
relationId = tuple->t_oid;
|
||||
relationId = tuple->t_data->t_oid;
|
||||
|
||||
if (unique && strcmp(accessMethodName, "btree") != 0)
|
||||
elog(ERROR, "DefineIndex: unique indices are only available with the btree access method");
|
||||
@@ -124,7 +124,7 @@ DefineIndex(char *heapRelationName,
|
||||
elog(ERROR, "DefineIndex: %s access method not found",
|
||||
accessMethodName);
|
||||
}
|
||||
accessMethodId = tuple->t_oid;
|
||||
accessMethodId = tuple->t_data->t_oid;
|
||||
|
||||
|
||||
/*
|
||||
@@ -250,7 +250,7 @@ ExtendIndex(char *indexRelationName, Expr *predicate, List *rangetable)
|
||||
elog(ERROR, "ExtendIndex: %s index not found",
|
||||
indexRelationName);
|
||||
}
|
||||
indexId = tuple->t_oid;
|
||||
indexId = tuple->t_data->t_oid;
|
||||
accessMethodId = ((Form_pg_class) GETSTRUCT(tuple))->relam;
|
||||
|
||||
/*
|
||||
@@ -336,7 +336,7 @@ ExtendIndex(char *indexRelationName, Expr *predicate, List *rangetable)
|
||||
namecpy(&(funcInfo->funcName),
|
||||
&(((Form_pg_proc) GETSTRUCT(tuple))->proname));
|
||||
|
||||
FIsetProcOid(funcInfo, tuple->t_oid);
|
||||
FIsetProcOid(funcInfo, tuple->t_data->t_oid);
|
||||
}
|
||||
|
||||
heapRelation = heap_open(relationId);
|
||||
@@ -429,7 +429,7 @@ FuncIndexArgs(IndexElem *funcIndex,
|
||||
elog(ERROR, "DefineIndex: %s class not found",
|
||||
funcIndex->class);
|
||||
}
|
||||
*opOidP = tuple->t_oid;
|
||||
*opOidP = tuple->t_data->t_oid;
|
||||
|
||||
MemSet(argTypes, 0, 8 * sizeof(Oid));
|
||||
|
||||
@@ -531,7 +531,7 @@ NormIndexAttrs(List *attList, /* list of IndexElem's */
|
||||
elog(ERROR, "DefineIndex: %s class not found",
|
||||
attribute->class);
|
||||
}
|
||||
*classOidP++ = tuple->t_oid;
|
||||
*classOidP++ = tuple->t_data->t_oid;
|
||||
pfree(atttuple);
|
||||
}
|
||||
}
|
||||
@@ -578,5 +578,5 @@ RemoveIndex(char *name)
|
||||
((Form_pg_class) GETSTRUCT(tuple))->relkind);
|
||||
}
|
||||
|
||||
index_destroy(tuple->t_oid);
|
||||
index_destroy(tuple->t_data->t_oid);
|
||||
}
|
||||
|
@@ -118,7 +118,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
|
||||
values[i++] = PointerGetDatum(languageName);
|
||||
values[i++] = Int8GetDatum((bool) 1);
|
||||
values[i++] = Int8GetDatum(stmt->pltrusted);
|
||||
values[i++] = ObjectIdGetDatum(procTup->t_oid);
|
||||
values[i++] = ObjectIdGetDatum(procTup->t_data->t_oid);
|
||||
values[i++] = (Datum) fmgr(F_TEXTIN, stmt->plcompiler);
|
||||
|
||||
rel = heap_openr(LanguageRelationName);
|
||||
@@ -174,7 +174,7 @@ DropProceduralLanguage(DropPLangStmt *stmt)
|
||||
}
|
||||
|
||||
rel = heap_openr(LanguageRelationName);
|
||||
heap_delete(rel, &langTup->t_ctid);
|
||||
heap_delete(rel, &langTup->t_self);
|
||||
|
||||
pfree(langTup);
|
||||
heap_close(rel);
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.29 1998/09/01 04:27:57 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.30 1998/11/27 19:51:57 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -97,12 +97,12 @@ RemoveOperator(char *operatorName, /* operator name */
|
||||
#ifndef NO_SECURITY
|
||||
userName = GetPgUserName();
|
||||
if (!pg_ownercheck(userName,
|
||||
(char *) ObjectIdGetDatum(tup->t_oid),
|
||||
(char *) ObjectIdGetDatum(tup->t_data->t_oid),
|
||||
OPROID))
|
||||
elog(ERROR, "RemoveOperator: operator '%s': permission denied",
|
||||
operatorName);
|
||||
#endif
|
||||
heap_delete(relation, &tup->t_ctid);
|
||||
heap_delete(relation, &tup->t_self);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -157,7 +157,7 @@ SingleOpOperatorRemove(Oid typeOid)
|
||||
key[0].sk_attno = attnums[i];
|
||||
scan = heap_beginscan(rel, 0, SnapshotNow, 1, key);
|
||||
while (HeapTupleIsValid(tup = heap_getnext(scan, 0)))
|
||||
heap_delete(rel, &tup->t_ctid);
|
||||
heap_delete(rel, &tup->t_self);
|
||||
heap_endscan(scan);
|
||||
}
|
||||
heap_close(rel);
|
||||
@@ -267,8 +267,8 @@ RemoveType(char *typeName) /* type name to be removed */
|
||||
}
|
||||
|
||||
relation = heap_openr(TypeRelationName);
|
||||
typeOid = tup->t_oid;
|
||||
heap_delete(relation, &tup->t_ctid);
|
||||
typeOid = tup->t_data->t_oid;
|
||||
heap_delete(relation, &tup->t_self);
|
||||
|
||||
/* Now, Delete the "array of" that type */
|
||||
shadow_type = makeArrayTypeName(typeName);
|
||||
@@ -281,8 +281,8 @@ RemoveType(char *typeName) /* type name to be removed */
|
||||
elog(ERROR, "RemoveType: type '%s' does not exist", typeName);
|
||||
}
|
||||
|
||||
typeOid = tup->t_oid;
|
||||
heap_delete(relation, &tup->t_ctid);
|
||||
typeOid = tup->t_data->t_oid;
|
||||
heap_delete(relation, &tup->t_self);
|
||||
|
||||
heap_close(relation);
|
||||
}
|
||||
@@ -325,7 +325,7 @@ RemoveFunction(char *functionName, /* function name to be removed */
|
||||
|
||||
if (!HeapTupleIsValid(tup))
|
||||
elog(ERROR, "RemoveFunction: type '%s' not found", typename);
|
||||
argList[i] = tup->t_oid;
|
||||
argList[i] = tup->t_data->t_oid;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -357,7 +357,7 @@ RemoveFunction(char *functionName, /* function name to be removed */
|
||||
elog(ERROR, "RemoveFunction: function \"%s\" is built-in", functionName);
|
||||
}
|
||||
|
||||
heap_delete(relation, &tup->t_ctid);
|
||||
heap_delete(relation, &tup->t_self);
|
||||
|
||||
heap_close(relation);
|
||||
}
|
||||
@@ -428,7 +428,7 @@ RemoveAggregate(char *aggName, char *aggType)
|
||||
aggName);
|
||||
}
|
||||
}
|
||||
heap_delete(relation, &tup->t_ctid);
|
||||
heap_delete(relation, &tup->t_self);
|
||||
|
||||
heap_close(relation);
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.17 1998/09/01 04:27:59 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.18 1998/11/27 19:51:57 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -113,7 +113,7 @@ renameatt(char *relname,
|
||||
if (!HeapTupleIsValid(reltup))
|
||||
elog(ERROR, "renameatt: unknown relation: \"%s\"", relname);
|
||||
|
||||
myrelid = reltup->t_oid;
|
||||
myrelid = reltup->t_data->t_oid;
|
||||
|
||||
/* this routine is actually in the planner */
|
||||
children = find_all_inheritors(lconsi(myrelid, NIL), NIL);
|
||||
@@ -153,7 +153,7 @@ renameatt(char *relname,
|
||||
if (!HeapTupleIsValid(reltup))
|
||||
elog(ERROR, "renameatt: relation \"%s\" nonexistent", relname);
|
||||
|
||||
relid = reltup->t_oid;
|
||||
relid = reltup->t_data->t_oid;
|
||||
|
||||
oldatttup = SearchSysCacheTupleCopy(ATTNAME,
|
||||
ObjectIdGetDatum(relid),
|
||||
@@ -180,7 +180,7 @@ renameatt(char *relname,
|
||||
newattname, NAMEDATALEN);
|
||||
|
||||
attrelation = heap_openr(AttributeRelationName);
|
||||
heap_replace(attrelation, &oldatttup->t_ctid, oldatttup);
|
||||
heap_replace(attrelation, &oldatttup->t_self, oldatttup);
|
||||
|
||||
/* keep system catalog indices current */
|
||||
CatalogOpenIndices(Num_pg_attr_indices, Name_pg_attr_indices, irelations);
|
||||
@@ -248,7 +248,7 @@ renamerel(char *oldrelname, char *newrelname)
|
||||
|
||||
/* insert fixed rel tuple */
|
||||
relrelation = heap_openr(RelationRelationName);
|
||||
heap_replace(relrelation, &oldreltup->t_ctid, oldreltup);
|
||||
heap_replace(relrelation, &oldreltup->t_self, oldreltup);
|
||||
|
||||
/* keep the system catalog indices current */
|
||||
CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, irelations);
|
||||
|
@@ -368,7 +368,7 @@ read_info(char *caller, SeqTable elm, Buffer *buf)
|
||||
ItemPointerData iptr;
|
||||
PageHeader page;
|
||||
ItemId lp;
|
||||
HeapTuple tuple;
|
||||
HeapTupleData tuple;
|
||||
sequence_magic *sm;
|
||||
Form_pg_sequence seq;
|
||||
|
||||
@@ -391,9 +391,9 @@ read_info(char *caller, SeqTable elm, Buffer *buf)
|
||||
|
||||
lp = PageGetItemId(page, FirstOffsetNumber);
|
||||
Assert(ItemIdIsUsed(lp));
|
||||
tuple = (HeapTuple) PageGetItem((Page) page, lp);
|
||||
tuple.t_data = (HeapTupleHeader) PageGetItem((Page) page, lp);
|
||||
|
||||
seq = (Form_pg_sequence) GETSTRUCT(tuple);
|
||||
seq = (Form_pg_sequence) GETSTRUCT(&tuple);
|
||||
|
||||
elm->increment = seq->increment_by;
|
||||
|
||||
|
@@ -159,7 +159,7 @@ CreateTrigger(CreateTrigStmt *stmt)
|
||||
|
||||
values[Anum_pg_trigger_tgrelid - 1] = ObjectIdGetDatum(RelationGetRelid(rel));
|
||||
values[Anum_pg_trigger_tgname - 1] = NameGetDatum(namein(stmt->trigname));
|
||||
values[Anum_pg_trigger_tgfoid - 1] = ObjectIdGetDatum(tuple->t_oid);
|
||||
values[Anum_pg_trigger_tgfoid - 1] = ObjectIdGetDatum(tuple->t_data->t_oid);
|
||||
values[Anum_pg_trigger_tgtype - 1] = Int16GetDatum(tgtype);
|
||||
if (stmt->args)
|
||||
{
|
||||
@@ -227,7 +227,7 @@ CreateTrigger(CreateTrigStmt *stmt)
|
||||
pgrel = heap_openr(RelationRelationName);
|
||||
((Form_pg_class) GETSTRUCT(tuple))->reltriggers = found + 1;
|
||||
RelationInvalidateHeapTuple(pgrel, tuple);
|
||||
heap_replace(pgrel, &tuple->t_ctid, tuple);
|
||||
heap_replace(pgrel, &tuple->t_self, tuple);
|
||||
CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs);
|
||||
CatalogIndexInsert(ridescs, Num_pg_class_indices, pgrel, tuple);
|
||||
CatalogCloseIndices(Num_pg_class_indices, ridescs);
|
||||
@@ -280,7 +280,7 @@ DropTrigger(DropTrigStmt *stmt)
|
||||
|
||||
if (namestrcmp(&(pg_trigger->tgname), stmt->trigname) == 0)
|
||||
{
|
||||
heap_delete(tgrel, &tuple->t_ctid);
|
||||
heap_delete(tgrel, &tuple->t_self);
|
||||
tgfound++;
|
||||
}
|
||||
else
|
||||
@@ -306,7 +306,7 @@ DropTrigger(DropTrigStmt *stmt)
|
||||
pgrel = heap_openr(RelationRelationName);
|
||||
((Form_pg_class) GETSTRUCT(tuple))->reltriggers = found;
|
||||
RelationInvalidateHeapTuple(pgrel, tuple);
|
||||
heap_replace(pgrel, &tuple->t_ctid, tuple);
|
||||
heap_replace(pgrel, &tuple->t_self, tuple);
|
||||
CatalogOpenIndices(Num_pg_class_indices, Name_pg_class_indices, ridescs);
|
||||
CatalogIndexInsert(ridescs, Num_pg_class_indices, pgrel, tuple);
|
||||
CatalogCloseIndices(Num_pg_class_indices, ridescs);
|
||||
@@ -340,7 +340,7 @@ RelationRemoveTriggers(Relation rel)
|
||||
tgscan = heap_beginscan(tgrel, 0, SnapshotNow, 1, &key);
|
||||
|
||||
while (HeapTupleIsValid(tup = heap_getnext(tgscan, 0)))
|
||||
heap_delete(tgrel, &tup->t_ctid);
|
||||
heap_delete(tgrel, &tup->t_self);
|
||||
|
||||
heap_endscan(tgscan);
|
||||
RelationUnsetLockForWrite(tgrel);
|
||||
@@ -359,11 +359,10 @@ RelationBuildTriggers(Relation relation)
|
||||
Form_pg_trigger pg_trigger;
|
||||
Relation irel;
|
||||
ScanKeyData skey;
|
||||
HeapTuple tuple;
|
||||
IndexScanDesc sd;
|
||||
RetrieveIndexResult indexRes;
|
||||
HeapTupleData tuple;
|
||||
IndexScanDesc sd;
|
||||
RetrieveIndexResult indexRes;
|
||||
Buffer buffer;
|
||||
ItemPointer iptr;
|
||||
struct varlena *val;
|
||||
bool isnull;
|
||||
int found;
|
||||
@@ -387,16 +386,16 @@ RelationBuildTriggers(Relation relation)
|
||||
if (!indexRes)
|
||||
break;
|
||||
|
||||
iptr = &indexRes->heap_iptr;
|
||||
tuple = heap_fetch(tgrel, SnapshotNow, iptr, &buffer);
|
||||
tuple.t_self = indexRes->heap_iptr;
|
||||
heap_fetch(tgrel, SnapshotNow, &tuple, &buffer);
|
||||
pfree(indexRes);
|
||||
if (!HeapTupleIsValid(tuple))
|
||||
if (!tuple.t_data)
|
||||
continue;
|
||||
if (found == ntrigs)
|
||||
elog(ERROR, "RelationBuildTriggers: unexpected record found for rel %.*s",
|
||||
NAMEDATALEN, relation->rd_rel->relname.data);
|
||||
|
||||
pg_trigger = (Form_pg_trigger) GETSTRUCT(tuple);
|
||||
pg_trigger = (Form_pg_trigger) GETSTRUCT(&tuple);
|
||||
|
||||
if (triggers == NULL)
|
||||
triggers = (Trigger *) palloc(sizeof(Trigger));
|
||||
@@ -410,7 +409,7 @@ RelationBuildTriggers(Relation relation)
|
||||
build->tgtype = pg_trigger->tgtype;
|
||||
build->tgnargs = pg_trigger->tgnargs;
|
||||
memcpy(build->tgattr, &(pg_trigger->tgattr), 8 * sizeof(int16));
|
||||
val = (struct varlena *) fastgetattr(tuple,
|
||||
val = (struct varlena *) fastgetattr(&tuple,
|
||||
Anum_pg_trigger_tgargs,
|
||||
tgrel->rd_att, &isnull);
|
||||
if (isnull)
|
||||
@@ -421,7 +420,7 @@ RelationBuildTriggers(Relation relation)
|
||||
char *p;
|
||||
int i;
|
||||
|
||||
val = (struct varlena *) fastgetattr(tuple,
|
||||
val = (struct varlena *) fastgetattr(&tuple,
|
||||
Anum_pg_trigger_tgargs,
|
||||
tgrel->rd_att, &isnull);
|
||||
if (isnull)
|
||||
@@ -792,10 +791,11 @@ ExecARUpdateTriggers(Relation rel, ItemPointer tupleid, HeapTuple newtuple)
|
||||
static HeapTuple
|
||||
GetTupleForTrigger(Relation relation, ItemPointer tid, bool before)
|
||||
{
|
||||
ItemId lp;
|
||||
HeapTuple tuple;
|
||||
PageHeader dp;
|
||||
Buffer b;
|
||||
ItemId lp;
|
||||
HeapTupleData tuple;
|
||||
HeapTuple result;
|
||||
PageHeader dp;
|
||||
Buffer b;
|
||||
|
||||
b = ReadBuffer(relation, ItemPointerGetBlockNumber(tid));
|
||||
|
||||
@@ -807,28 +807,30 @@ GetTupleForTrigger(Relation relation, ItemPointer tid, bool before)
|
||||
|
||||
Assert(ItemIdIsUsed(lp));
|
||||
|
||||
tuple = (HeapTuple) PageGetItem((Page) dp, lp);
|
||||
tuple.t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
|
||||
tuple.t_len = ItemIdGetLength(lp);
|
||||
tuple.t_self = *tid;
|
||||
|
||||
if (before)
|
||||
{
|
||||
if (TupleUpdatedByCurXactAndCmd(tuple))
|
||||
if (TupleUpdatedByCurXactAndCmd(&tuple))
|
||||
{
|
||||
elog(NOTICE, "GetTupleForTrigger: Non-functional delete/update");
|
||||
ReleaseBuffer(b);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
HeapTupleSatisfies(lp, relation, b, dp,
|
||||
false, 0, (ScanKey) NULL, tuple);
|
||||
if (!tuple)
|
||||
HeapTupleSatisfies(&tuple, relation, b, dp,
|
||||
false, 0, (ScanKey) NULL);
|
||||
if (!tuple.t_data)
|
||||
{
|
||||
ReleaseBuffer(b);
|
||||
elog(ERROR, "GetTupleForTrigger: (am)invalid tid");
|
||||
}
|
||||
}
|
||||
|
||||
tuple = heap_copytuple(tuple);
|
||||
result = heap_copytuple(&tuple);
|
||||
ReleaseBuffer(b);
|
||||
|
||||
return tuple;
|
||||
return result;
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.90 1998/10/23 16:49:24 momjian Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.91 1998/11/27 19:51:58 vadim Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -327,7 +327,7 @@ vc_getrels(NameData *VacRelP)
|
||||
}
|
||||
MemoryContextSwitchTo(old);
|
||||
|
||||
cur->vrl_relid = tuple->t_oid;
|
||||
cur->vrl_relid = tuple->t_data->t_oid;
|
||||
cur->vrl_next = (VRelList) NULL;
|
||||
}
|
||||
if (found == false)
|
||||
@@ -577,9 +577,8 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
|
||||
int nblocks,
|
||||
blkno;
|
||||
ItemId itemid;
|
||||
ItemPointer itemptr;
|
||||
Buffer buf;
|
||||
HeapTuple tuple;
|
||||
HeapTupleData tuple;
|
||||
Page page,
|
||||
tempPage = NULL;
|
||||
OffsetNumber offnum,
|
||||
@@ -675,23 +674,25 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
|
||||
continue;
|
||||
}
|
||||
|
||||
tuple = (HeapTuple) PageGetItem(page, itemid);
|
||||
tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
|
||||
tuple.t_len = ItemIdGetLength(itemid);
|
||||
ItemPointerSet(&(tuple.t_self), blkno, offnum);
|
||||
tupgone = false;
|
||||
|
||||
if (!(tuple->t_infomask & HEAP_XMIN_COMMITTED))
|
||||
if (!(tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED))
|
||||
{
|
||||
if (tuple->t_infomask & HEAP_XMIN_INVALID)
|
||||
if (tuple.t_data->t_infomask & HEAP_XMIN_INVALID)
|
||||
tupgone = true;
|
||||
else
|
||||
{
|
||||
if (TransactionIdDidAbort(tuple->t_xmin))
|
||||
if (TransactionIdDidAbort(tuple.t_data->t_xmin))
|
||||
tupgone = true;
|
||||
else if (TransactionIdDidCommit(tuple->t_xmin))
|
||||
else if (TransactionIdDidCommit(tuple.t_data->t_xmin))
|
||||
{
|
||||
tuple->t_infomask |= HEAP_XMIN_COMMITTED;
|
||||
tuple.t_data->t_infomask |= HEAP_XMIN_COMMITTED;
|
||||
pgchanged = true;
|
||||
}
|
||||
else if (!TransactionIdIsInProgress(tuple->t_xmin))
|
||||
else if (!TransactionIdIsInProgress(tuple.t_data->t_xmin))
|
||||
{
|
||||
|
||||
/*
|
||||
@@ -704,7 +705,7 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
|
||||
else
|
||||
{
|
||||
elog(NOTICE, "Rel %s: TID %u/%u: InsertTransactionInProgress %u - can't shrink relation",
|
||||
relname, blkno, offnum, tuple->t_xmin);
|
||||
relname, blkno, offnum, tuple.t_data->t_xmin);
|
||||
do_shrinking = false;
|
||||
}
|
||||
}
|
||||
@@ -714,60 +715,40 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
|
||||
* here we are concerned about tuples with xmin committed and
|
||||
* xmax unknown or committed
|
||||
*/
|
||||
if (tuple->t_infomask & HEAP_XMIN_COMMITTED &&
|
||||
!(tuple->t_infomask & HEAP_XMAX_INVALID))
|
||||
if (tuple.t_data->t_infomask & HEAP_XMIN_COMMITTED &&
|
||||
!(tuple.t_data->t_infomask & HEAP_XMAX_INVALID))
|
||||
{
|
||||
if (tuple->t_infomask & HEAP_XMAX_COMMITTED)
|
||||
if (tuple.t_data->t_infomask & HEAP_XMAX_COMMITTED)
|
||||
tupgone = true;
|
||||
else if (TransactionIdDidAbort(tuple->t_xmax))
|
||||
else if (TransactionIdDidAbort(tuple.t_data->t_xmax))
|
||||
{
|
||||
tuple->t_infomask |= HEAP_XMAX_INVALID;
|
||||
tuple.t_data->t_infomask |= HEAP_XMAX_INVALID;
|
||||
pgchanged = true;
|
||||
}
|
||||
else if (TransactionIdDidCommit(tuple->t_xmax))
|
||||
else if (TransactionIdDidCommit(tuple.t_data->t_xmax))
|
||||
tupgone = true;
|
||||
else if (!TransactionIdIsInProgress(tuple->t_xmax))
|
||||
else if (!TransactionIdIsInProgress(tuple.t_data->t_xmax))
|
||||
{
|
||||
|
||||
/*
|
||||
* Not Aborted, Not Committed, Not in Progress - so it
|
||||
* from crashed process. - vadim 06/02/97
|
||||
*/
|
||||
tuple->t_infomask |= HEAP_XMAX_INVALID;;
|
||||
tuple.t_data->t_infomask |= HEAP_XMAX_INVALID;;
|
||||
pgchanged = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
elog(NOTICE, "Rel %s: TID %u/%u: DeleteTransactionInProgress %u - can't shrink relation",
|
||||
relname, blkno, offnum, tuple->t_xmax);
|
||||
relname, blkno, offnum, tuple.t_data->t_xmax);
|
||||
do_shrinking = false;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* It's possibly! But from where it comes ? And should we fix
|
||||
* it ? - vadim 11/28/96
|
||||
*/
|
||||
itemptr = &(tuple->t_ctid);
|
||||
if (!ItemPointerIsValid(itemptr) ||
|
||||
BlockIdGetBlockNumber(&(itemptr->ip_blkid)) != blkno)
|
||||
{
|
||||
elog(NOTICE, "Rel %s: TID %u/%u: TID IN TUPLEHEADER %u/%u IS NOT THE SAME. TUPGONE %d.",
|
||||
relname, blkno, offnum,
|
||||
BlockIdGetBlockNumber(&(itemptr->ip_blkid)),
|
||||
itemptr->ip_posid, tupgone);
|
||||
}
|
||||
|
||||
/*
|
||||
* Other checks...
|
||||
*/
|
||||
if (tuple->t_len != itemid->lp_len)
|
||||
{
|
||||
elog(NOTICE, "Rel %s: TID %u/%u: TUPLE_LEN IN PAGEHEADER %u IS NOT THE SAME AS IN TUPLEHEADER %u. TUPGONE %d.",
|
||||
relname, blkno, offnum,
|
||||
itemid->lp_len, tuple->t_len, tupgone);
|
||||
}
|
||||
if (!OidIsValid(tuple->t_oid))
|
||||
if (!OidIsValid(tuple.t_data->t_oid))
|
||||
{
|
||||
elog(NOTICE, "Rel %s: TID %u/%u: OID IS INVALID. TUPGONE %d.",
|
||||
relname, blkno, offnum, tupgone);
|
||||
@@ -799,11 +780,11 @@ vc_scanheap(VRelStats *vacrelstats, Relation onerel,
|
||||
{
|
||||
num_tuples++;
|
||||
notup = false;
|
||||
if (tuple->t_len < min_tlen)
|
||||
min_tlen = tuple->t_len;
|
||||
if (tuple->t_len > max_tlen)
|
||||
max_tlen = tuple->t_len;
|
||||
vc_attrstats(onerel, vacrelstats, tuple);
|
||||
if (tuple.t_len < min_tlen)
|
||||
min_tlen = tuple.t_len;
|
||||
if (tuple.t_len > max_tlen)
|
||||
max_tlen = tuple.t_len;
|
||||
vc_attrstats(onerel, vacrelstats, &tuple);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -916,8 +897,8 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
|
||||
max_offset;
|
||||
ItemId itemid,
|
||||
newitemid;
|
||||
HeapTuple tuple,
|
||||
newtup;
|
||||
HeapTupleData tuple,
|
||||
newtup;
|
||||
TupleDesc tupdesc = NULL;
|
||||
Datum *idatum = NULL;
|
||||
char *inulls = NULL;
|
||||
@@ -1034,8 +1015,9 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
|
||||
if (!ItemIdIsUsed(itemid))
|
||||
continue;
|
||||
|
||||
tuple = (HeapTuple) PageGetItem(page, itemid);
|
||||
tuple_len = tuple->t_len;
|
||||
tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
|
||||
tuple_len = tuple.t_len = ItemIdGetLength(itemid);
|
||||
ItemPointerSet(&(tuple.t_self), blkno, offnum);
|
||||
|
||||
/* try to find new page for this tuple */
|
||||
if (cur_buffer == InvalidBuffer ||
|
||||
@@ -1081,21 +1063,20 @@ vc_rpfheap(VRelStats *vacrelstats, Relation onerel,
|
||||
}
|
||||
|
||||
/* copy tuple */
|
||||
newtup = (HeapTuple) palloc(tuple_len);
|
||||
memmove((char *) newtup, (char *) tuple, tuple_len);
|
||||
heap_copytuple_with_tuple(&tuple, &newtup);
|
||||
|
||||
RelationInvalidateHeapTuple(onerel, tuple);
|
||||
RelationInvalidateHeapTuple(onerel, &tuple);
|
||||
|
||||
/* store transaction information */
|
||||
TransactionIdStore(myXID, &(newtup->t_xmin));
|
||||
newtup->t_cmin = myCID;
|
||||
StoreInvalidTransactionId(&(newtup->t_xmax));
|
||||
TransactionIdStore(myXID, &(newtup.t_data->t_xmin));
|
||||
newtup.t_data->t_cmin = myCID;
|
||||
StoreInvalidTransactionId(&(newtup.t_data->t_xmax));
|
||||
/* set xmin to unknown and xmax to invalid */
|
||||
newtup->t_infomask &= ~(HEAP_XACT_MASK);
|
||||
newtup->t_infomask |= HEAP_XMAX_INVALID;
|
||||
newtup.t_data->t_infomask &= ~(HEAP_XACT_MASK);
|
||||
newtup.t_data->t_infomask |= HEAP_XMAX_INVALID;
|
||||
|
||||
/* add tuple to the page */
|
||||
newoff = PageAddItem(ToPage, (Item) newtup, tuple_len,
|
||||
newoff = PageAddItem(ToPage, (Item) newtup.t_data, tuple_len,
|
||||
InvalidOffsetNumber, LP_USED);
|
||||
if (newoff == InvalidOffsetNumber)
|
||||
{
|
||||
@@ -1105,15 +1086,16 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
|
||||
cur_page->vpd_offsets_used, cur_page->vpd_offsets_free);
|
||||
}
|
||||
newitemid = PageGetItemId(ToPage, newoff);
|
||||
pfree(newtup);
|
||||
newtup = (HeapTuple) PageGetItem(ToPage, newitemid);
|
||||
ItemPointerSet(&(newtup->t_ctid), cur_page->vpd_blkno, newoff);
|
||||
pfree(newtup.t_data);
|
||||
newtup.t_data = (HeapTupleHeader) PageGetItem(ToPage, newitemid);
|
||||
ItemPointerSet(&(newtup.t_data->t_ctid), cur_page->vpd_blkno, newoff);
|
||||
newtup.t_self = newtup.t_data->t_ctid;
|
||||
|
||||
/* now logically delete end-tuple */
|
||||
TransactionIdStore(myXID, &(tuple->t_xmax));
|
||||
tuple->t_cmax = myCID;
|
||||
TransactionIdStore(myXID, &(tuple.t_data->t_xmax));
|
||||
tuple.t_data->t_cmax = myCID;
|
||||
/* set xmax to unknown */
|
||||
tuple->t_infomask &= ~(HEAP_XMAX_INVALID | HEAP_XMAX_COMMITTED);
|
||||
tuple.t_data->t_infomask &= ~(HEAP_XMAX_INVALID | HEAP_XMAX_COMMITTED);
|
||||
|
||||
cur_page->vpd_offsets_used++;
|
||||
num_moved++;
|
||||
@@ -1127,7 +1109,7 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
|
||||
{
|
||||
FormIndexDatum(idcur->natts,
|
||||
(AttrNumber *) &(idcur->tform->indkey[0]),
|
||||
newtup,
|
||||
&newtup,
|
||||
tupdesc,
|
||||
idatum,
|
||||
inulls,
|
||||
@@ -1135,7 +1117,7 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
|
||||
iresult = index_insert(Irel[i],
|
||||
idatum,
|
||||
inulls,
|
||||
&newtup->t_ctid,
|
||||
&newtup.t_self,
|
||||
onerel);
|
||||
if (iresult)
|
||||
pfree(iresult);
|
||||
@@ -1213,10 +1195,10 @@ failed to add item with len = %u to page %u (free space %u, nusd %u, noff %u)",
|
||||
itemid = PageGetItemId(page, newoff);
|
||||
if (!ItemIdIsUsed(itemid))
|
||||
continue;
|
||||
tuple = (HeapTuple) PageGetItem(page, itemid);
|
||||
if (TransactionIdEquals((TransactionId) tuple->t_xmin, myXID))
|
||||
tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
|
||||
if (TransactionIdEquals((TransactionId) tuple.t_data->t_xmin, myXID))
|
||||
{
|
||||
tuple->t_infomask |= HEAP_XMIN_COMMITTED;
|
||||
tuple.t_data->t_infomask |= HEAP_XMIN_COMMITTED;
|
||||
num_tuples++;
|
||||
}
|
||||
}
|
||||
@@ -1276,8 +1258,8 @@ Elapsed %u/%u sec.",
|
||||
itemid = PageGetItemId(page, offnum);
|
||||
if (!ItemIdIsUsed(itemid))
|
||||
continue;
|
||||
tuple = (HeapTuple) PageGetItem(page, itemid);
|
||||
Assert(TransactionIdEquals((TransactionId) tuple->t_xmax, myXID));
|
||||
tuple.t_data = (HeapTupleHeader) PageGetItem(page, itemid);
|
||||
Assert(TransactionIdEquals((TransactionId) tuple.t_data->t_xmax, myXID));
|
||||
itemid->lp_flags &= ~LP_USED;
|
||||
num_tuples++;
|
||||
}
|
||||
@@ -1718,18 +1700,18 @@ vc_bucketcpy(Form_pg_attribute attr, Datum value, Datum *bucket, int16 *bucket_l
|
||||
static void
|
||||
vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *vacrelstats)
|
||||
{
|
||||
Relation rd,
|
||||
ad,
|
||||
sd;
|
||||
HeapScanDesc scan;
|
||||
HeapTuple rtup,
|
||||
ctup,
|
||||
atup,
|
||||
stup;
|
||||
Form_pg_class pgcform;
|
||||
ScanKeyData askey;
|
||||
Form_pg_attribute attp;
|
||||
Buffer buffer;
|
||||
Relation rd,
|
||||
ad,
|
||||
sd;
|
||||
HeapScanDesc scan;
|
||||
HeapTupleData rtup;
|
||||
HeapTuple ctup,
|
||||
atup,
|
||||
stup;
|
||||
Form_pg_class pgcform;
|
||||
ScanKeyData askey;
|
||||
Form_pg_attribute attp;
|
||||
Buffer buffer;
|
||||
|
||||
/*
|
||||
* update number of tuples and number of pages in pg_class
|
||||
@@ -1744,12 +1726,13 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
|
||||
rd = heap_openr(RelationRelationName);
|
||||
|
||||
/* get the buffer cache tuple */
|
||||
rtup = heap_fetch(rd, SnapshotNow, &ctup->t_ctid, &buffer);
|
||||
rtup.t_self = ctup->t_self;
|
||||
heap_fetch(rd, SnapshotNow, &rtup, &buffer);
|
||||
pfree(ctup);
|
||||
|
||||
/* overwrite the existing statistics in the tuple */
|
||||
vc_setpagelock(rd, ItemPointerGetBlockNumber(&rtup->t_ctid));
|
||||
pgcform = (Form_pg_class) GETSTRUCT(rtup);
|
||||
vc_setpagelock(rd, ItemPointerGetBlockNumber(&(rtup.t_self)));
|
||||
pgcform = (Form_pg_class) GETSTRUCT(&rtup);
|
||||
pgcform->reltuples = num_tuples;
|
||||
pgcform->relpages = num_pages;
|
||||
pgcform->relhasindex = hasindex;
|
||||
@@ -1792,15 +1775,9 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
|
||||
/* overwrite the existing statistics in the tuple */
|
||||
if (VacAttrStatsEqValid(stats))
|
||||
{
|
||||
Buffer abuffer;
|
||||
Buffer abuffer = scan->rs_cbuf;
|
||||
|
||||
/*
|
||||
* We manipulate the heap tuple in the
|
||||
* buffer, so we fetch it to get the
|
||||
* buffer number
|
||||
*/
|
||||
atup = heap_fetch(ad, SnapshotNow, &atup->t_ctid, &abuffer);
|
||||
vc_setpagelock(ad, ItemPointerGetBlockNumber(&atup->t_ctid));
|
||||
vc_setpagelock(ad, ItemPointerGetBlockNumber(&atup->t_self));
|
||||
attp = (Form_pg_attribute) GETSTRUCT(atup);
|
||||
|
||||
if (stats->nonnull_cnt + stats->null_cnt == 0 ||
|
||||
@@ -1837,7 +1814,6 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
|
||||
*/
|
||||
RelationInvalidateHeapTuple(ad, atup);
|
||||
WriteNoReleaseBuffer(abuffer);
|
||||
ReleaseBuffer(abuffer);
|
||||
|
||||
/* DO PG_STATISTIC INSERTS */
|
||||
|
||||
@@ -1894,7 +1870,7 @@ vc_updstats(Oid relid, int num_pages, int num_tuples, bool hasindex, VRelStats *
|
||||
* Invalidate the cached pg_class tuple and
|
||||
* write the buffer
|
||||
*/
|
||||
RelationInvalidateHeapTuple(rd, rtup);
|
||||
RelationInvalidateHeapTuple(rd, &rtup);
|
||||
|
||||
WriteNoReleaseBuffer(buffer);
|
||||
|
||||
@@ -1942,7 +1918,7 @@ vc_delhilowstats(Oid relid, int attcnt, int *attnums)
|
||||
if (i >= attcnt)
|
||||
continue; /* don't delete it */
|
||||
}
|
||||
heap_delete(pgstatistic, &tuple->t_ctid);
|
||||
heap_delete(pgstatistic, &tuple->t_self);
|
||||
}
|
||||
|
||||
heap_endscan(scan);
|
||||
|
Reference in New Issue
Block a user