diff options
Diffstat (limited to 'src/include/fmgr.h')
| -rw-r--r-- | src/include/fmgr.h | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/include/fmgr.h b/src/include/fmgr.h index b0aea5df09..03d13e3d4e 100644 --- a/src/include/fmgr.h +++ b/src/include/fmgr.h @@ -11,7 +11,7 @@ * Portions Copyright (c) 1996-2000, PostgreSQL, Inc * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: fmgr.h,v 1.7 2000/07/06 05:48:17 tgl Exp $ + * $Id: fmgr.h,v 1.8 2000/07/12 02:37:25 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -119,6 +119,21 @@ extern struct varlena * pg_detoast_datum_copy(struct varlena * datum); #define PG_DETOAST_DATUM_COPY(datum) \ pg_detoast_datum_copy((struct varlena *) DatumGetPointer(datum)) +/* + * Support for cleaning up detoasted copies of inputs. This must only + * be used for pass-by-ref datatypes, and normally would only be used + * for toastable types. If the given pointer is different from the + * original argument, assume it's a palloc'd detoasted copy, and pfree it. + * NOTE: most functions on toastable types do not have to worry about this, + * but we currently require that support functions for indexes not leak + * memory. + */ +#define PG_FREE_IF_COPY(ptr,n) \ + do { \ + if ((Pointer) (ptr) != PG_GETARG_POINTER(n)) \ + pfree(ptr); \ + } while (0) + /* Macros for fetching arguments of standard types */ #define PG_GETARG_DATUM(n) (fcinfo->arg[n]) |
