Skip to content

Commit 1ea0172

Browse files
committed
heapattr functions now return a Datum, not char *.
1 parent 6e04b4b commit 1ea0172

File tree

28 files changed

+177
-188
lines changed

28 files changed

+177
-188
lines changed

src/backend/access/common/heaptuple.c

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.24 1997/09/08 21:40:18 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.25 1997/09/12 04:07:06 momjian Exp $
1212
*
1313
* NOTES
1414
* The old interface functions have been converted to macros
@@ -372,25 +372,25 @@ heap_sysattrbyval(AttrNumber attno)
372372
* heap_getsysattr
373373
* ----------------
374374
*/
375-
char *
375+
Datum
376376
heap_getsysattr(HeapTuple tup, Buffer b, int attnum)
377377
{
378378
switch (attnum)
379379
{
380380
case SelfItemPointerAttributeNumber:
381-
return ((char *) &tup->t_ctid);
381+
return ((Datum) &tup->t_ctid);
382382
case ObjectIdAttributeNumber:
383-
return ((char *) (long) tup->t_oid);
383+
return ((Datum) (long) tup->t_oid);
384384
case MinTransactionIdAttributeNumber:
385-
return ((char *) (long) tup->t_xmin);
385+
return ((Datum) (long) tup->t_xmin);
386386
case MinCommandIdAttributeNumber:
387-
return ((char *) (long) tup->t_cmin);
387+
return ((Datum) (long) tup->t_cmin);
388388
case MaxTransactionIdAttributeNumber:
389-
return ((char *) (long) tup->t_xmax);
389+
return ((Datum) (long) tup->t_xmax);
390390
case MaxCommandIdAttributeNumber:
391-
return ((char *) (long) tup->t_cmax);
391+
return ((Datum) (long) tup->t_cmax);
392392
case ChainItemPointerAttributeNumber:
393-
return ((char *) &tup->t_chain);
393+
return ((Datum) &tup->t_chain);
394394
case AnchorItemPointerAttributeNumber:
395395
elog(WARN, "heap_getsysattr: t_anchor does not exist!");
396396
break;
@@ -409,7 +409,7 @@ heap_getsysattr(HeapTuple tup, Buffer b, int attnum)
409409
if (!AbsoluteTimeIsBackwardCompatiblyValid(tup->t_tmin) &&
410410
TransactionIdDidCommit(tup->t_xmin))
411411
tup->t_tmin = TransactionIdGetCommitTime(tup->t_xmin);
412-
return ((char *) (long) tup->t_tmin);
412+
return ((Datum) (long) tup->t_tmin);
413413
case MaxAbsoluteTimeAttributeNumber:
414414
if (!AbsoluteTimeIsBackwardCompatiblyReal(tup->t_tmax))
415415
{
@@ -418,9 +418,9 @@ heap_getsysattr(HeapTuple tup, Buffer b, int attnum)
418418
else
419419
tup->t_tmax = CURRENT_ABSTIME;
420420
}
421-
return ((char *) (long) tup->t_tmax);
421+
return ((Datum) (long) tup->t_tmax);
422422
case VersionTypeAttributeNumber:
423-
return ((char *) (long) tup->t_vtype);
423+
return ((Datum) (long) tup->t_vtype);
424424
default:
425425
elog(WARN, "heap_getsysattr: undefined attnum %d", attnum);
426426
}
@@ -444,7 +444,7 @@ heap_getsysattr(HeapTuple tup, Buffer b, int attnum)
444444
* the same attribute descriptor will go much quicker. -cim 5/4/91
445445
* ----------------
446446
*/
447-
char *
447+
Datum
448448
fastgetattr(HeapTuple tup,
449449
int attnum,
450450
TupleDesc tupleDesc,
@@ -479,7 +479,7 @@ fastgetattr(HeapTuple tup,
479479
attnum--;
480480
if (att[attnum]->attcacheoff > 0)
481481
{
482-
return (char *)
482+
return (Datum)
483483
fetchatt(&(att[attnum]),
484484
(char *) tup + tup->t_hoff + att[attnum]->attcacheoff);
485485
}
@@ -489,7 +489,7 @@ fastgetattr(HeapTuple tup,
489489
/*
490490
* first attribute is always at position zero
491491
*/
492-
return ((char *) fetchatt(&(att[0]), (char *) tup + tup->t_hoff));
492+
return ((Datum) fetchatt(&(att[0]), (char *) tup + tup->t_hoff));
493493
}
494494

495495
tp = (char *) tup + tup->t_hoff;
@@ -543,13 +543,13 @@ fastgetattr(HeapTuple tup,
543543
{
544544
if (att[attnum]->attcacheoff > 0)
545545
{
546-
return (char *)
546+
return (Datum)
547547
fetchatt(&(att[attnum]),
548548
tp + att[attnum]->attcacheoff);
549549
}
550550
else if (attnum == 0)
551551
{
552-
return (char *)
552+
return (Datum)
553553
fetchatt(&(att[0]), (char *) tup + tup->t_hoff);
554554
}
555555
else if (!HeapTupleAllFixed(tup))
@@ -618,7 +618,7 @@ fastgetattr(HeapTuple tup,
618618
}
619619

620620
return
621-
(char *) fetchatt(&(att[attnum]), tp + att[attnum]->attcacheoff);
621+
(Datum) fetchatt(&(att[attnum]), tp + att[attnum]->attcacheoff);
622622
}
623623
else
624624
{
@@ -729,7 +729,7 @@ fastgetattr(HeapTuple tup,
729729
off = LONGALIGN(off);
730730
break;
731731
}
732-
return ((char *) fetchatt(&(att[attnum]), tp + off));
732+
return ((Datum) fetchatt(&(att[attnum]), tp + off));
733733
}
734734
}
735735

@@ -782,11 +782,11 @@ heap_deformtuple(HeapTuple tuple,
782782
{
783783
bool isnull;
784784

785-
values[i] = (Datum) heap_getattr(tuple,
786-
InvalidBuffer,
787-
i + 1,
788-
tdesc,
789-
&isnull);
785+
values[i] = heap_getattr(tuple,
786+
InvalidBuffer,
787+
i + 1,
788+
tdesc,
789+
&isnull);
790790
if (isnull)
791791
nulls[i] = 'n';
792792
else
@@ -936,15 +936,12 @@ heap_modifytuple(HeapTuple tuple,
936936

937937
if (repl[attoff] == ' ')
938938
{
939-
char *attr;
940-
941-
attr =
939+
value[attoff] =
942940
heap_getattr(tuple,
943941
InvalidBuffer,
944942
AttrOffsetGetAttrNumber(attoff),
945943
RelationGetTupleDescriptor(relation),
946944
&isNull);
947-
value[attoff] = PointerGetDatum(attr);
948945
nulls[attoff] = (isNull) ? 'n' : ' ';
949946

950947
}

src/backend/access/common/heapvalid.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/common/Attic/heapvalid.c,v 1.18 1997/09/08 02:19:51 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/common/Attic/heapvalid.c,v 1.19 1997/09/12 04:07:09 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -42,10 +42,10 @@ heap_keytest(HeapTuple t,
4242

4343
for (; nkeys--; keys++)
4444
{
45-
atp = (Datum) heap_getattr(t, InvalidBuffer,
46-
keys->sk_attno,
47-
tupdesc,
48-
&isnull);
45+
atp = heap_getattr(t, InvalidBuffer,
46+
keys->sk_attno,
47+
tupdesc,
48+
&isnull);
4949

5050
if (isnull)
5151
/* XXX eventually should check if SK_ISNULL */

src/backend/access/common/printtup.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.17 1997/09/08 02:19:56 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.18 1997/09/12 04:07:12 momjian Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -76,8 +76,8 @@ printtup(HeapTuple tuple, TupleDesc typeinfo)
7676
int i,
7777
j,
7878
k;
79-
char *outputstr,
80-
*attr;
79+
char *outputstr;
80+
Datum attr;
8181
bool isnull;
8282
Oid typoutput;
8383

@@ -176,8 +176,8 @@ void
176176
debugtup(HeapTuple tuple, TupleDesc typeinfo)
177177
{
178178
register int i;
179-
char *attr,
180-
*value;
179+
Datum attr;
180+
char *value;
181181
bool isnull;
182182
Oid typoutput;
183183

@@ -212,7 +212,7 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo)
212212
int i,
213213
j,
214214
k;
215-
char *attr;
215+
Datum attr;
216216
bool isnull;
217217

218218
/* ----------------
@@ -308,9 +308,10 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo)
308308
else
309309
{
310310
pq_putint(len, sizeof(int32));
311-
pq_putnchar(attr, len);
311+
pq_putnchar(DatumGetPointer(attr), len);
312312
#ifdef IPORTAL_DEBUG
313-
fprintf(stderr, "byref length %d data %x\n", len, attr);
313+
fprintf(stderr, "byref length %d data %x\n", len,
314+
DatumGetPointer(attr));
314315
#endif
315316
}
316317
}

src/backend/access/index/indexam.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.16 1997/09/08 21:41:06 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.17 1997/09/12 04:07:15 momjian Exp $
1111
*
1212
* INTERFACE ROUTINES
1313
* index_open - open an index relation by relationId
@@ -385,11 +385,11 @@ GetIndexValue(HeapTuple tuple,
385385

386386
for (i = 0; i < FIgetnArgs(fInfo); i++)
387387
{
388-
attData[i] = (Datum) heap_getattr(tuple,
389-
buffer,
390-
attrNums[i],
391-
hTupDesc,
392-
attNull);
388+
attData[i] = heap_getattr(tuple,
389+
buffer,
390+
attrNums[i],
391+
hTupDesc,
392+
attNull);
393393
}
394394
returnVal = (Datum) fmgr_array_args(FIgetProcOid(fInfo),
395395
FIgetnArgs(fInfo),
@@ -400,8 +400,8 @@ GetIndexValue(HeapTuple tuple,
400400
}
401401
else
402402
{
403-
returnVal = (Datum) heap_getattr(tuple, buffer, attrNums[attOff],
404-
hTupDesc, attNull);
403+
returnVal = heap_getattr(tuple, buffer, attrNums[attOff],
404+
hTupDesc, attNull);
405405
}
406406
return returnVal;
407407
}

src/backend/commands/async.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
*
88
*
99
* IDENTIFICATION
10-
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.19 1997/09/08 02:21:54 momjian Exp $
10+
* $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.20 1997/09/12 04:07:20 momjian Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -216,8 +216,8 @@ Async_Notify(char *relname)
216216

217217
while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0, &b)))
218218
{
219-
d = (Datum) heap_getattr(lTuple, b, Anum_pg_listener_notify,
220-
tdesc, &isnull);
219+
d = heap_getattr(lTuple, b, Anum_pg_listener_notify,
220+
tdesc, &isnull);
221221
if (!DatumGetInt32(d))
222222
{
223223
rTuple = heap_modifytuple(lTuple, b, lRel, value, nulls, repl);
@@ -293,13 +293,13 @@ Async_NotifyAtCommit()
293293

294294
while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0, &b)))
295295
{
296-
d = (Datum) heap_getattr(lTuple, b, Anum_pg_listener_relname,
297-
tdesc, &isnull);
296+
d = heap_getattr(lTuple, b, Anum_pg_listener_relname,
297+
tdesc, &isnull);
298298

299299
if (AsyncExistsPendingNotify((char *) DatumGetPointer(d)))
300300
{
301-
d = (Datum) heap_getattr(lTuple, b, Anum_pg_listener_pid,
302-
tdesc, &isnull);
301+
d = heap_getattr(lTuple, b, Anum_pg_listener_pid,
302+
tdesc, &isnull);
303303

304304
if (ourpid == DatumGetInt32(d))
305305
{
@@ -444,12 +444,12 @@ Async_Listen(char *relname, int pid)
444444
s = heap_beginscan(lDesc, 0, NowTimeQual, 0, (ScanKey) NULL);
445445
while (HeapTupleIsValid(htup = heap_getnext(s, 0, &b)))
446446
{
447-
d = (Datum) heap_getattr(htup, b, Anum_pg_listener_relname, tdesc,
448-
&isnull);
447+
d = heap_getattr(htup, b, Anum_pg_listener_relname, tdesc,
448+
&isnull);
449449
relnamei = DatumGetPointer(d);
450450
if (!strncmp(relnamei, relname, NAMEDATALEN))
451451
{
452-
d = (Datum) heap_getattr(htup, b, Anum_pg_listener_pid, tdesc, &isnull);
452+
d = heap_getattr(htup, b, Anum_pg_listener_pid, tdesc, &isnull);
453453
pid = DatumGetInt32(d);
454454
if (pid == ourPid)
455455
{
@@ -609,8 +609,8 @@ Async_NotifyFrontEnd()
609609

610610
while (HeapTupleIsValid(lTuple = heap_getnext(sRel, 0, &b)))
611611
{
612-
d = (Datum) heap_getattr(lTuple, b, Anum_pg_listener_relname,
613-
tdesc, &isnull);
612+
d = heap_getattr(lTuple, b, Anum_pg_listener_relname,
613+
tdesc, &isnull);
614614
rTuple = heap_modifytuple(lTuple, b, lRel, value, nulls, repl);
615615
heap_replace(lRel, &lTuple->t_ctid, rTuple);
616616

src/backend/commands/copy.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
*
88
* IDENTIFICATION
9-
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.33 1997/09/08 21:42:30 momjian Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.34 1997/09/12 04:07:25 momjian Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -270,8 +270,7 @@ CopyTo(Relation rel, bool binary, bool oids, FILE *fp, char *delim)
270270

271271
for (i = 0; i < attr_count; i++)
272272
{
273-
value = (Datum)
274-
heap_getattr(tuple, InvalidBuffer, i + 1, tupDesc, &isnull);
273+
value = heap_getattr(tuple, InvalidBuffer, i + 1, tupDesc, &isnull);
275274
if (!binary)
276275
{
277276
if (!isnull)

0 commit comments

Comments
 (0)