aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/adt/varchar.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2000-05-29 21:02:32 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2000-05-29 21:02:32 +0000
commit6ed00fee535018b1966a61491a4af07f078b4c68 (patch)
treeb0b7ce559ce8335950bfc49f5d577d11f75cb55c /src/backend/utils/adt/varchar.c
parent747527e5458b9454ab904a2706ffe22a25094571 (diff)
downloadpostgresql-6ed00fee535018b1966a61491a4af07f078b4c68.tar.gz
postgresql-6ed00fee535018b1966a61491a4af07f078b4c68.zip
Convert array_map to use new fmgr interface.
Diffstat (limited to 'src/backend/utils/adt/varchar.c')
-rw-r--r--src/backend/utils/adt/varchar.c45
1 files changed, 42 insertions, 3 deletions
diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c
index 0837b8b63a1..67ff10cc073 100644
--- a/src/backend/utils/adt/varchar.c
+++ b/src/backend/utils/adt/varchar.c
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
- * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.60 2000/04/12 17:15:52 momjian Exp $
+ * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.61 2000/05/29 21:02:32 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -17,6 +17,7 @@
#include "access/htup.h"
#include "catalog/pg_type.h"
#include "utils/builtins.h"
+#include "utils/fmgroids.h"
#ifdef MULTIBYTE
#include "mb/pg_wchar.h"
@@ -206,7 +207,26 @@ bpchar(char *s, int32 len)
ArrayType *
_bpchar(ArrayType *v, int32 len)
{
- return array_map(v, BPCHAROID, bpchar, BPCHAROID, 1, len);
+ FunctionCallInfoData locfcinfo;
+ Datum result;
+ /* Since bpchar() is a built-in function, we should only need to
+ * look it up once per run.
+ */
+ static FmgrInfo bpchar_finfo;
+
+ if (bpchar_finfo.fn_oid == InvalidOid)
+ fmgr_info(F_BPCHAR, &bpchar_finfo);
+
+ MemSet(&locfcinfo, 0, sizeof(locfcinfo));
+ locfcinfo.flinfo = &bpchar_finfo;
+ locfcinfo.nargs = 2;
+ /* We assume we are "strict" and need not worry about null inputs */
+ locfcinfo.arg[0] = PointerGetDatum(v);
+ locfcinfo.arg[1] = Int32GetDatum(len);
+
+ result = array_map(&locfcinfo, BPCHAROID, BPCHAROID);
+
+ return (ArrayType *) DatumGetPointer(result);
}
@@ -409,7 +429,26 @@ varchar(char *s, int32 slen)
ArrayType *
_varchar(ArrayType *v, int32 len)
{
- return array_map(v, VARCHAROID, varchar, VARCHAROID, 1, len);
+ FunctionCallInfoData locfcinfo;
+ Datum result;
+ /* Since varchar() is a built-in function, we should only need to
+ * look it up once per run.
+ */
+ static FmgrInfo varchar_finfo;
+
+ if (varchar_finfo.fn_oid == InvalidOid)
+ fmgr_info(F_VARCHAR, &varchar_finfo);
+
+ MemSet(&locfcinfo, 0, sizeof(locfcinfo));
+ locfcinfo.flinfo = &varchar_finfo;
+ locfcinfo.nargs = 2;
+ /* We assume we are "strict" and need not worry about null inputs */
+ locfcinfo.arg[0] = PointerGetDatum(v);
+ locfcinfo.arg[1] = Int32GetDatum(len);
+
+ result = array_map(&locfcinfo, VARCHAROID, VARCHAROID);
+
+ return (ArrayType *) DatumGetPointer(result);
}