Skip to content

Commit ff7b9f5

Browse files
committed
I had overlooked the fact that some fmgr-callable functions return void
--- ie, they're only called for side-effects. Add a PG_RETURN_VOID() macro and use it where appropriate. This probably doesn't change the machine code by a single bit ... it's just for documentation.
1 parent 69cd08d commit ff7b9f5

File tree

10 files changed

+41
-43
lines changed

10 files changed

+41
-43
lines changed

src/backend/access/gist/gist.c

Lines changed: 3 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/access/gist/gist.c,v 1.56 2000/06/13 07:34:27 tgl Exp $
9+
* $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.57 2000/06/14 05:24:35 tgl Exp $
1010
*
1111
*-------------------------------------------------------------------------
1212
*/
@@ -303,7 +303,7 @@ gistbuild(PG_FUNCTION_ARGS)
303303
pfree(nulls);
304304
pfree(d);
305305

306-
PG_RETURN_POINTER(NULL); /* no real return value */
306+
PG_RETURN_VOID();
307307
}
308308

309309
/*
@@ -1149,7 +1149,7 @@ gistdelete(PG_FUNCTION_ARGS)
11491149

11501150
WriteBuffer(buf);
11511151

1152-
PG_RETURN_POINTER(NULL); /* no real return value */
1152+
PG_RETURN_VOID();
11531153
}
11541154

11551155
void

src/backend/access/gist/gistscan.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ gistrescan(PG_FUNCTION_ARGS)
154154
}
155155
}
156156

157-
PG_RETURN_POINTER(NULL); /* no real return value */
157+
PG_RETURN_VOID();
158158
}
159159

160160
Datum
@@ -190,7 +190,7 @@ gistmarkpos(PG_FUNCTION_ARGS)
190190
gistfreestack(p->s_markstk);
191191
p->s_markstk = o;
192192

193-
PG_RETURN_POINTER(NULL); /* no real return value */
193+
PG_RETURN_VOID();
194194
}
195195

196196
Datum
@@ -226,7 +226,7 @@ gistrestrpos(PG_FUNCTION_ARGS)
226226
gistfreestack(p->s_stack);
227227
p->s_stack = o;
228228

229-
PG_RETURN_POINTER(NULL); /* no real return value */
229+
PG_RETURN_VOID();
230230
}
231231

232232
Datum
@@ -247,7 +247,7 @@ gistendscan(PG_FUNCTION_ARGS)
247247
gistdropscan(s);
248248
/* XXX don't unset read lock -- two-phase locking */
249249

250-
PG_RETURN_POINTER(NULL); /* no real return value */
250+
PG_RETURN_VOID();
251251
}
252252

253253
static void

src/backend/access/hash/hash.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.38 2000/06/13 07:34:28 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.39 2000/06/14 05:24:35 tgl Exp $
1212
*
1313
* NOTES
1414
* This file contains only the public interface routines.
@@ -266,7 +266,7 @@ hashbuild(PG_FUNCTION_ARGS)
266266
/* all done */
267267
BuildingHash = false;
268268

269-
PG_RETURN_POINTER(NULL); /* no real return value */
269+
PG_RETURN_VOID();
270270
}
271271

272272
/*
@@ -396,7 +396,7 @@ hashrescan(PG_FUNCTION_ARGS)
396396
scan->numberOfKeys * sizeof(ScanKeyData));
397397
}
398398

399-
PG_RETURN_POINTER(NULL); /* no real return value */
399+
PG_RETURN_VOID();
400400
}
401401

402402
/*
@@ -433,7 +433,7 @@ hashendscan(PG_FUNCTION_ARGS)
433433
/* be tidy */
434434
pfree(scan->opaque);
435435

436-
PG_RETURN_POINTER(NULL); /* no real return value */
436+
PG_RETURN_VOID();
437437
}
438438

439439
/*
@@ -466,7 +466,7 @@ hashmarkpos(PG_FUNCTION_ARGS)
466466
scan->currentMarkData = scan->currentItemData;
467467
}
468468

469-
PG_RETURN_POINTER(NULL); /* no real return value */
469+
PG_RETURN_VOID();
470470
}
471471

472472
/*
@@ -499,7 +499,7 @@ hashrestrpos(PG_FUNCTION_ARGS)
499499
scan->currentItemData = scan->currentMarkData;
500500
}
501501

502-
PG_RETURN_POINTER(NULL); /* no real return value */
502+
PG_RETURN_VOID();
503503
}
504504

505505
/* stubs */
@@ -515,5 +515,5 @@ hashdelete(PG_FUNCTION_ARGS)
515515
/* delete the data from the page */
516516
_hash_pagedel(rel, tid);
517517

518-
PG_RETURN_POINTER(NULL); /* no real return value */
518+
PG_RETURN_VOID();
519519
}

src/backend/access/nbtree/nbtree.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
1414
* IDENTIFICATION
15-
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.56 2000/06/13 07:34:38 tgl Exp $
15+
* $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.57 2000/06/14 05:24:37 tgl Exp $
1616
*
1717
*-------------------------------------------------------------------------
1818
*/
@@ -336,7 +336,7 @@ btbuild(PG_FUNCTION_ARGS)
336336
/* all done */
337337
BuildingBtree = false;
338338

339-
PG_RETURN_POINTER(NULL); /* no real return value */
339+
PG_RETURN_VOID();
340340
}
341341

342342
/*
@@ -502,7 +502,7 @@ btrescan(PG_FUNCTION_ARGS)
502502
so->numberOfKeys * sizeof(ScanKeyData));
503503
}
504504

505-
PG_RETURN_POINTER(NULL); /* no real return value */
505+
PG_RETURN_VOID();
506506
}
507507

508508
void
@@ -560,7 +560,7 @@ btendscan(PG_FUNCTION_ARGS)
560560

561561
_bt_dropscan(scan);
562562

563-
PG_RETURN_POINTER(NULL); /* no real return value */
563+
PG_RETURN_VOID();
564564
}
565565

566566
/*
@@ -592,7 +592,7 @@ btmarkpos(PG_FUNCTION_ARGS)
592592
so->mrkHeapIptr = so->curHeapIptr;
593593
}
594594

595-
PG_RETURN_POINTER(NULL); /* no real return value */
595+
PG_RETURN_VOID();
596596
}
597597

598598
/*
@@ -625,7 +625,7 @@ btrestrpos(PG_FUNCTION_ARGS)
625625
so->curHeapIptr = so->mrkHeapIptr;
626626
}
627627

628-
PG_RETURN_POINTER(NULL); /* no real return value */
628+
PG_RETURN_VOID();
629629
}
630630

631631
/* stubs */
@@ -641,7 +641,7 @@ btdelete(PG_FUNCTION_ARGS)
641641
/* delete the data from the page */
642642
_bt_pagedel(rel, tid);
643643

644-
PG_RETURN_POINTER(NULL); /* no real return value */
644+
PG_RETURN_VOID();
645645
}
646646

647647
static void

src/backend/access/rtree/rtproc.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.26 2000/06/13 07:34:49 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.27 2000/06/14 05:24:43 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -18,8 +18,7 @@
1818
#include "utils/builtins.h"
1919

2020

21-
BOX
22-
*
21+
BOX *
2322
rt_box_union(BOX *a, BOX *b)
2423
{
2524
BOX *n;
@@ -123,7 +122,7 @@ rt_poly_size(PG_FUNCTION_ARGS)
123122
*size = (float) (xdim * ydim);
124123
}
125124

126-
PG_RETURN_POINTER(NULL); /* no real return value */
125+
PG_RETURN_VOID();
127126
}
128127

129128
POLYGON *

src/backend/access/rtree/rtree.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.48 2000/06/13 07:34:49 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.49 2000/06/14 05:24:43 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -281,7 +281,7 @@ rtbuild(PG_FUNCTION_ARGS)
281281
pfree(nulls);
282282
pfree(d);
283283

284-
PG_RETURN_POINTER(NULL); /* no real return value */
284+
PG_RETURN_VOID();
285285
}
286286

287287
/*
@@ -1025,7 +1025,7 @@ rtdelete(PG_FUNCTION_ARGS)
10251025

10261026
WriteBuffer(buf);
10271027

1028-
PG_RETURN_POINTER(NULL); /* no real return value */
1028+
PG_RETURN_VOID();
10291029
}
10301030

10311031
static void

src/backend/access/rtree/rtscan.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.33 2000/06/13 07:34:49 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.34 2000/06/14 05:24:43 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -156,7 +156,7 @@ rtrescan(PG_FUNCTION_ARGS)
156156
}
157157
}
158158

159-
PG_RETURN_POINTER(NULL); /* no real return value */
159+
PG_RETURN_VOID();
160160
}
161161

162162
Datum
@@ -192,7 +192,7 @@ rtmarkpos(PG_FUNCTION_ARGS)
192192
freestack(p->s_markstk);
193193
p->s_markstk = o;
194194

195-
PG_RETURN_POINTER(NULL); /* no real return value */
195+
PG_RETURN_VOID();
196196
}
197197

198198
Datum
@@ -228,7 +228,7 @@ rtrestrpos(PG_FUNCTION_ARGS)
228228
freestack(p->s_stack);
229229
p->s_stack = o;
230230

231-
PG_RETURN_POINTER(NULL); /* no real return value */
231+
PG_RETURN_VOID();
232232
}
233233

234234
Datum
@@ -249,7 +249,7 @@ rtendscan(PG_FUNCTION_ARGS)
249249
rtdropscan(s);
250250
/* XXX don't unset read lock -- two-phase locking */
251251

252-
PG_RETURN_POINTER(NULL); /* no real return value */
252+
PG_RETURN_VOID();
253253
}
254254

255255
static void

src/backend/utils/adt/arrayfuncs.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.57 2000/06/13 07:35:03 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.58 2000/06/14 05:24:48 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -187,7 +187,7 @@ array_in(PG_FUNCTION_ARGS)
187187
retval = (ArrayType *) palloc(sizeof(ArrayType));
188188
MemSet(retval, 0, sizeof(ArrayType));
189189
*(int32 *) retval = sizeof(ArrayType);
190-
return PointerGetDatum(retval);
190+
PG_RETURN_POINTER(retval);
191191
}
192192

193193
if (*p == '{')
@@ -238,7 +238,7 @@ array_in(PG_FUNCTION_ARGS)
238238
PG_RETURN_NULL();
239239
}
240240
pfree(string_save);
241-
return PointerGetDatum(retval);
241+
PG_RETURN_POINTER(retval);
242242
}
243243

244244
/*-----------------------------------------------------------------------------
@@ -622,9 +622,6 @@ array_out(PG_FUNCTION_ARGS)
622622
int ndim,
623623
*dim;
624624

625-
if (v == (ArrayType *) NULL)
626-
PG_RETURN_CSTRING((char *) NULL);
627-
628625
if (ARR_IS_LO(v) == true)
629626
{
630627
text *p;

src/backend/utils/adt/selfuncs.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*
1616
*
1717
* IDENTIFICATION
18-
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.70 2000/06/09 01:11:09 tgl Exp $
18+
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.71 2000/06/14 05:24:49 tgl Exp $
1919
*
2020
*-------------------------------------------------------------------------
2121
*/
@@ -1934,8 +1934,7 @@ genericcostestimate(PG_FUNCTION_ARGS)
19341934
*indexTotalCost = numIndexPages +
19351935
(cpu_index_tuple_cost + cost_qual_eval(indexQuals)) * numIndexTuples;
19361936

1937-
/* No real return value ... */
1938-
PG_RETURN_POINTER(NULL);
1937+
PG_RETURN_VOID();
19391938
}
19401939

19411940
/*

src/include/fmgr.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
1212
* Portions Copyright (c) 1994, Regents of the University of California
1313
*
14-
* $Id: fmgr.h,v 1.5 2000/06/13 07:35:23 tgl Exp $
14+
* $Id: fmgr.h,v 1.6 2000/06/14 05:24:50 tgl Exp $
1515
*
1616
*-------------------------------------------------------------------------
1717
*/
@@ -147,6 +147,9 @@ extern void fmgr_info(Oid functionId, FmgrInfo *finfo);
147147
#define PG_RETURN_NULL() \
148148
do { fcinfo->isnull = true; return (Datum) 0; } while (0)
149149

150+
/* A few internal functions return void (which is not the same as NULL!) */
151+
#define PG_RETURN_VOID() return (Datum) 0
152+
150153
/* Macros for returning results of standard types */
151154

152155
#define PG_RETURN_INT32(x) return Int32GetDatum(x)

0 commit comments

Comments
 (0)