From: | Joe Conway <mail(at)joeconway(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | pgsql-patches(at)postgresql(dot)org |
Subject: | Re: [HACKERS] revised sample SRF C function; proposed SRF API |
Date: | 2002-06-07 23:11:20 |
Message-ID: | 3D013D98.7060108@joeconway.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers pgsql-patches |
Tom Lane wrote:
> Definitely better. I'd suggest also thinking about whether the
> same/similar macros can support functions that return a set of a
> scalar (non-tuple) datatype. In my mind, the cleanest design would
> be some base macros that support functions-returning-set (of anything),
> and if you want to return a set of scalar then you just use these
> directly (handing a Datum to FUNC_RETURN_NEXT). If you want to return
> a set of tuples then there are a couple extra steps that you need to
> do to build a tupdesc, build a tuple, and convert the tuple to Datum
> (which at the moment you do by putting it into a slot, but I think we
> ought to change that soon). If it were really clean then the macros
> supporting these extra steps would also work without the SRF macros,
> so that you could use 'em in a function returning a single tuple.
As promised on HACKERS, here's the Composite and SRF function API patch.
Included is a new builtin guc function, exported as show_all_vars(). In
order to avoid creating a new bootstrapped relation, I made the pg_proc
entry specify 0 as the function return type, and then fixed it in
initdb.sh as follows:
$ECHO_N "setting return type for composite returning functions... "$ECHO_C
"$PGPATH"/postgres $PGSQL_OPT template1 >/dev/null <<EOF
CREATE VIEW pg__guc AS \
SELECT \
''::text as varname, \
''::text as varval;
UPDATE pg_proc SET \
prorettype = (SELECT oid FROM pg_type WHERE typname = 'pg__guc') \
WHERE \
proname = 'show_all_vars';
EOF
if [ "$?" -ne 0 ]; then
exit_nicely
fi
echo "ok"
Any concerns with this approach? Is it too much of a hack, or
preferrable to adding new bootstrapped relations solely for this purpose?
Thanks,
Joe
Attachment | Content-Type | Size |
---|---|---|
funcapi.2002.06.07.1.patch | text/plain | 34.1 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Rachit Siamwalla | 2002-06-07 23:26:34 | Question whether this is a known problem in 7.1.2 |
Previous Message | Joe Conway | 2002-06-07 23:05:19 | Re: revised sample SRF C function; proposed SRF API |
From | Date | Subject | |
---|---|---|---|
Next Message | Bruce Momjian | 2002-06-07 23:42:16 | Re: Make factorial(0::int2) return 1, as per spec. |
Previous Message | Ron Snyder | 2002-06-07 23:05:48 | Re: guc.c and postgresql.conf.sample constistency check |