mirror of
https://github.com/postgres/postgres.git
synced 2025-06-14 18:42:34 +03:00
2nd try for the index tuple toast hack. This time as suggested
by Tom. Jan
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.81 2000/07/21 11:18:51 wieck Exp $
|
||||
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.82 2000/07/22 11:18:46 wieck Exp $
|
||||
*
|
||||
*
|
||||
* INTERFACE ROUTINES
|
||||
@ -1274,10 +1274,6 @@ Oid
|
||||
heap_insert(Relation relation, HeapTuple tup)
|
||||
{
|
||||
Buffer buffer;
|
||||
#ifndef TOAST_INDICES
|
||||
HeapTupleHeader plaintdata = NULL;
|
||||
int32 plaintlen = 0;
|
||||
#endif
|
||||
|
||||
/* increment access statistics */
|
||||
tup->tableOid = relation->rd_id;
|
||||
@ -1313,11 +1309,7 @@ heap_insert(Relation relation, HeapTuple tup)
|
||||
*/
|
||||
if (HeapTupleHasExtended(tup) ||
|
||||
(MAXALIGN(tup->t_len) > (MaxTupleSize / 4)))
|
||||
#ifdef TOAST_INDICES
|
||||
heap_tuple_toast_attrs(relation, tup, NULL);
|
||||
#else
|
||||
heap_tuple_toast_attrs(relation, tup, NULL, &plaintdata, &plaintlen);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Find buffer for this tuple */
|
||||
@ -1355,20 +1347,6 @@ heap_insert(Relation relation, HeapTuple tup)
|
||||
if (IsSystemRelationName(RelationGetRelationName(relation)))
|
||||
RelationMark4RollbackHeapTuple(relation, tup);
|
||||
|
||||
#ifndef TOAST_INDICES
|
||||
if (plaintdata != NULL && tup->t_data != plaintdata)
|
||||
{
|
||||
if (tup->t_datamcxt != NULL && (char *) (tup->t_data) !=
|
||||
((char *) tup + HEAPTUPLESIZE))
|
||||
{
|
||||
MemoryContext oldcxt = MemoryContextSwitchTo(tup->t_datamcxt);
|
||||
pfree(tup->t_data);
|
||||
MemoryContextSwitchTo(oldcxt);
|
||||
}
|
||||
tup->t_data = plaintdata;
|
||||
tup->t_len = plaintlen;
|
||||
}
|
||||
#endif
|
||||
return tup->t_data->t_oid;
|
||||
}
|
||||
|
||||
@ -1483,11 +1461,7 @@ l1:
|
||||
* ----------
|
||||
*/
|
||||
if (HeapTupleHasExtended(&tp))
|
||||
#ifdef TOAST_INDICES
|
||||
heap_tuple_toast_attrs(relation, NULL, &(tp));
|
||||
#else
|
||||
heap_tuple_toast_attrs(relation, NULL, &(tp), NULL, NULL);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
LockBuffer(buffer, BUFFER_LOCK_UNLOCK);
|
||||
@ -1512,10 +1486,6 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
|
||||
PageHeader dp;
|
||||
Buffer buffer, newbuf;
|
||||
int result;
|
||||
#ifndef TOAST_INDICES
|
||||
HeapTupleHeader plaintdata = NULL;
|
||||
int32 plaintlen = 0;
|
||||
#endif
|
||||
|
||||
newtup->tableOid = relation->rd_id;
|
||||
/* increment access statistics */
|
||||
@ -1604,11 +1574,7 @@ l2:
|
||||
if (HeapTupleHasExtended(&oldtup) ||
|
||||
HeapTupleHasExtended(newtup) ||
|
||||
(MAXALIGN(newtup->t_len) > (MaxTupleSize / 4)))
|
||||
#ifdef TOAST_INDICES
|
||||
heap_tuple_toast_attrs(relation, newtup, &oldtup);
|
||||
#else
|
||||
heap_tuple_toast_attrs(relation, newtup, &oldtup, &plaintdata, &plaintlen);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Find buffer for new tuple */
|
||||
@ -1671,21 +1637,6 @@ l2:
|
||||
RelationInvalidateHeapTuple(relation, &oldtup);
|
||||
RelationMark4RollbackHeapTuple(relation, newtup);
|
||||
|
||||
#ifndef TOAST_INDICES
|
||||
if (plaintdata != NULL && newtup->t_data != plaintdata)
|
||||
{
|
||||
if (newtup->t_datamcxt != NULL && (char *) (newtup->t_data) !=
|
||||
((char *) newtup + HEAPTUPLESIZE))
|
||||
{
|
||||
MemoryContext oldcxt = MemoryContextSwitchTo(newtup->t_datamcxt);
|
||||
pfree(newtup->t_data);
|
||||
MemoryContextSwitchTo(oldcxt);
|
||||
}
|
||||
newtup->t_data = plaintdata;
|
||||
newtup->t_len = plaintlen;
|
||||
}
|
||||
#endif
|
||||
|
||||
return HeapTupleMayBeUpdated;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user