Skip to content

Commit 21e1e66

Browse files
committed
Minor cleanup of tableOid-related coding.
1 parent b0d243e commit 21e1e66

File tree

4 files changed

+27
-56
lines changed

4 files changed

+27
-56
lines changed

src/backend/access/common/heaptuple.c

Lines changed: 16 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
*
1010
*
1111
* IDENTIFICATION
12-
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.65 2000/07/04 02:40:56 tgl Exp $
12+
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.66 2000/11/14 21:04:32 tgl Exp $
1313
*
1414
* NOTES
1515
* The old interface functions have been converted to macros
@@ -275,38 +275,6 @@ heap_sysattrbyval(AttrNumber attno)
275275
return byval;
276276
}
277277

278-
#ifdef NOT_USED
279-
/* ----------------
280-
* heap_getsysattr
281-
* ----------------
282-
*/
283-
Datum
284-
heap_getsysattr(HeapTuple tup, Buffer b, int attnum)
285-
{
286-
switch (attnum)
287-
{
288-
case TableOidAttributeNumber:
289-
return (Datum) &tup->t_tableoid;
290-
case SelfItemPointerAttributeNumber:
291-
return (Datum) &tup->t_ctid;
292-
case ObjectIdAttributeNumber:
293-
return (Datum) (long) tup->t_oid;
294-
case MinTransactionIdAttributeNumber:
295-
return (Datum) (long) tup->t_xmin;
296-
case MinCommandIdAttributeNumber:
297-
return (Datum) (long) tup->t_cmin;
298-
case MaxTransactionIdAttributeNumber:
299-
return (Datum) (long) tup->t_xmax;
300-
case MaxCommandIdAttributeNumber:
301-
return (Datum) (long) tup->t_cmax;
302-
default:
303-
elog(ERROR, "heap_getsysattr: undefined attnum %d", attnum);
304-
}
305-
return (Datum) NULL;
306-
}
307-
308-
#endif
309-
310278
/* ----------------
311279
* nocachegetattr
312280
*
@@ -563,6 +531,9 @@ nocachegetattr(HeapTuple tuple,
563531
* heap_copytuple
564532
*
565533
* returns a copy of an entire tuple
534+
*
535+
* The HeapTuple struct, tuple header, and tuple data are all allocated
536+
* as a single palloc() block.
566537
* ----------------
567538
*/
568539
HeapTuple
@@ -576,17 +547,17 @@ heap_copytuple(HeapTuple tuple)
576547
newTuple = (HeapTuple) palloc(HEAPTUPLESIZE + tuple->t_len);
577548
newTuple->t_len = tuple->t_len;
578549
newTuple->t_self = tuple->t_self;
550+
newTuple->t_tableOid = tuple->t_tableOid;
579551
newTuple->t_datamcxt = CurrentMemoryContext;
580552
newTuple->t_data = (HeapTupleHeader) ((char *) newTuple + HEAPTUPLESIZE);
581-
memmove((char *) newTuple->t_data,
582-
(char *) tuple->t_data, tuple->t_len);
553+
memcpy((char *) newTuple->t_data, (char *) tuple->t_data, tuple->t_len);
583554
return newTuple;
584555
}
585556

586557
/* ----------------
587558
* heap_copytuple_with_tuple
588559
*
589-
* returns a copy of an tuple->t_data
560+
* copy a tuple into a caller-supplied HeapTuple management struct
590561
* ----------------
591562
*/
592563
void
@@ -600,11 +571,10 @@ heap_copytuple_with_tuple(HeapTuple src, HeapTuple dest)
600571

601572
dest->t_len = src->t_len;
602573
dest->t_self = src->t_self;
574+
dest->t_tableOid = src->t_tableOid;
603575
dest->t_datamcxt = CurrentMemoryContext;
604576
dest->t_data = (HeapTupleHeader) palloc(src->t_len);
605-
memmove((char *) dest->t_data,
606-
(char *) src->t_data, src->t_len);
607-
return;
577+
memcpy((char *) dest->t_data, (char *) src->t_data, src->t_len);
608578
}
609579

610580
#ifdef NOT_USED
@@ -705,6 +675,7 @@ heap_formtuple(TupleDesc tupleDescriptor,
705675

706676
tuple->t_len = len;
707677
ItemPointerSetInvalid(&(tuple->t_self));
678+
tuple->t_tableOid = InvalidOid;
708679
td->t_natts = numberOfAttributes;
709680
td->t_hoff = hoff;
710681

@@ -805,6 +776,7 @@ heap_modifytuple(HeapTuple tuple,
805776
newTuple->t_data->t_infomask = infomask;
806777
newTuple->t_data->t_natts = numberOfAttributes;
807778
newTuple->t_self = tuple->t_self;
779+
newTuple->t_tableOid = tuple->t_tableOid;
808780

809781
return newTuple;
810782
}
@@ -851,17 +823,19 @@ heap_addheader(uint32 natts, /* max domain index */
851823
tuple->t_datamcxt = CurrentMemoryContext;
852824
td = tuple->t_data = (HeapTupleHeader) ((char *) tuple + HEAPTUPLESIZE);
853825

854-
MemSet((char *) td, 0, len);
855-
856826
tuple->t_len = len;
857827
ItemPointerSetInvalid(&(tuple->t_self));
828+
tuple->t_tableOid = InvalidOid;
829+
830+
MemSet((char *) td, 0, len);
831+
858832
td->t_hoff = hoff;
859833
td->t_natts = natts;
860834
td->t_infomask = 0;
861835
td->t_infomask |= HEAP_XMAX_INVALID;
862836

863837
if (structlen > 0)
864-
memmove((char *) td + hoff, structure, (size_t) structlen);
838+
memcpy((char *) td + hoff, structure, (size_t) structlen);
865839

866840
return tuple;
867841
}

src/backend/access/heap/heapam.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.93 2000/11/08 22:09:54 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.94 2000/11/14 21:04:31 tgl Exp $
1212
*
1313
*
1414
* INTERFACE ROUTINES
@@ -255,9 +255,7 @@ heapgettup(Relation relation,
255255
OffsetNumber lineoff;
256256
int linesleft;
257257
ItemPointer tid = (tuple->t_data == NULL) ?
258-
(ItemPointer) NULL : &(tuple->t_self);
259-
260-
tuple->tableOid = relation->rd_id;
258+
(ItemPointer) NULL : &(tuple->t_self);
261259

262260
/* ----------------
263261
* increment access statistics
@@ -294,6 +292,8 @@ heapgettup(Relation relation,
294292

295293
if (!ItemPointerIsValid(tid))
296294
Assert(!PointerIsValid(tid));
295+
296+
tuple->t_tableOid = relation->rd_id;
297297

298298
/* ----------------
299299
* return null immediately if relation is empty
@@ -1145,7 +1145,6 @@ heap_fetch(Relation relation,
11451145
ItemPointer tid = &(tuple->t_self);
11461146
OffsetNumber offnum;
11471147

1148-
tuple->tableOid = relation->rd_id;
11491148
/* ----------------
11501149
* increment access statistics
11511150
* ----------------
@@ -1193,6 +1192,7 @@ heap_fetch(Relation relation,
11931192
tuple->t_datamcxt = NULL;
11941193
tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
11951194
tuple->t_len = ItemIdGetLength(lp);
1195+
tuple->t_tableOid = relation->rd_id;
11961196

11971197
/* ----------------
11981198
* check time qualification of tid
@@ -1241,7 +1241,6 @@ heap_get_latest_tid(Relation relation,
12411241
bool invalidBlock,
12421242
linkend;
12431243

1244-
tp.tableOid = relation->rd_id;
12451244
/* ----------------
12461245
* get the buffer from the relation descriptor
12471246
* Note that this does a buffer pin.
@@ -1333,7 +1332,6 @@ heap_insert(Relation relation, HeapTuple tup)
13331332
Buffer buffer;
13341333

13351334
/* increment access statistics */
1336-
tup->tableOid = relation->rd_id;
13371335
IncrHeapAccessStat(local_insert);
13381336
IncrHeapAccessStat(global_insert);
13391337

@@ -1357,6 +1355,7 @@ heap_insert(Relation relation, HeapTuple tup)
13571355
StoreInvalidTransactionId(&(tup->t_data->t_xmax));
13581356
tup->t_data->t_infomask &= ~(HEAP_XACT_MASK);
13591357
tup->t_data->t_infomask |= HEAP_XMAX_INVALID;
1358+
tup->t_tableOid = relation->rd_id;
13601359

13611360
#ifdef TUPLE_TOASTER_ACTIVE
13621361
/* ----------
@@ -1420,7 +1419,6 @@ heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid)
14201419
Buffer buffer;
14211420
int result;
14221421

1423-
tp.tableOid = relation->rd_id;
14241422
/* increment access statistics */
14251423
IncrHeapAccessStat(local_delete);
14261424
IncrHeapAccessStat(global_delete);
@@ -1440,6 +1438,7 @@ heap_delete(Relation relation, ItemPointer tid, ItemPointer ctid)
14401438
tp.t_data = (HeapTupleHeader) PageGetItem((Page) dp, lp);
14411439
tp.t_len = ItemIdGetLength(lp);
14421440
tp.t_self = *tid;
1441+
tp.t_tableOid = relation->rd_id;
14431442

14441443
l1:
14451444
result = HeapTupleSatisfiesUpdate(&tp);
@@ -1546,7 +1545,6 @@ heap_update(Relation relation, ItemPointer otid, HeapTuple newtup,
15461545
Buffer buffer, newbuf;
15471546
int result;
15481547

1549-
newtup->tableOid = relation->rd_id;
15501548
/* increment access statistics */
15511549
IncrHeapAccessStat(local_replace);
15521550
IncrHeapAccessStat(global_replace);
@@ -1733,7 +1731,6 @@ heap_mark4update(Relation relation, HeapTuple tuple, Buffer *buffer)
17331731
PageHeader dp;
17341732
int result;
17351733

1736-
tuple->tableOid = relation->rd_id;
17371734
/* increment access statistics */
17381735
IncrHeapAccessStat(local_mark4update);
17391736
IncrHeapAccessStat(global_mark4update);

src/include/access/heapam.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: heapam.h,v 1.56 2000/08/03 19:19:38 tgl Exp $
10+
* $Id: heapam.h,v 1.57 2000/11/14 21:04:32 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -191,7 +191,7 @@ fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc,
191191
: \
192192
(((attnum) == TableOidAttributeNumber) ? \
193193
( \
194-
(Datum)((tup)->tableOid) \
194+
(Datum)((tup)->t_tableOid) \
195195
) \
196196
: \
197197
( \

src/include/access/htup.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: htup.h,v 1.38 2000/11/14 20:47:34 tgl Exp $
10+
* $Id: htup.h,v 1.39 2000/11/14 21:04:32 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -188,7 +188,7 @@ typedef struct HeapTupleData
188188
{
189189
uint32 t_len; /* length of *t_data */
190190
ItemPointerData t_self; /* SelfItemPointer */
191-
Oid tableOid; /* table the tuple came from */
191+
Oid t_tableOid; /* table the tuple came from */
192192
MemoryContext t_datamcxt; /* mcxt in which allocated */
193193
HeapTupleHeader t_data; /* -> tuple header and data */
194194
} HeapTupleData;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy