From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
Cc: | Zoltan Boszormenyi <zb(at)cybertec(dot)at>, Gregory Stark <stark(at)enterprisedb(dot)com>, pgsql-patches(at)postgresql(dot)org, Hans-Juergen Schoenig <hs(at)cybertec(dot)at>, Magnus Hagander <magnus(at)hagander(dot)net> |
Subject: | Re: float4/float8/int64 passed by value with tsearch fixup |
Date: | 2008-04-18 20:09:26 |
Message-ID: | 17697.1208549366@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-patches |
Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
> Alvaro Herrera <alvherre(at)commandprompt(dot)com> writes:
>> Tom Lane wrote:
>>> Since they're v0, they'd have to explicitly know about the pass-by-ref
>>> status of float4.
>> Well, the previous code was doing some pallocs, and the new code is not:
>> http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/contrib/seg/seg.c.diff?r1=1.20;r2=1.21
> [ shrug... ] So, you missed something.
Specifically, I think what you missed is that on some platforms C
functions pass or return float values differently from similar-sized
integer or pointer values (typically, the float values get passed in
floating-point registers). On such platforms it is essentially
impossible for a v0 function to work with pass-by-val float4 ---
since fmgr_oldstyle thinks it's passing integers and getting back
pointers, the values are being transferred in the wrong registers.
The only way to make it work would be to mangle the function
declarations and then play union tricks like those in
Float4GetDatum/DatumGetFloat4, which is certainly not very practical.
It'd be less ugly to convert to v1 calling convention.
(This very likely explains why the Berkeley folk made float4 pass-by-ref
in the first place, a decision that doesn't make a lot of sense if
you don't know about this problem.)
So I think we really do need to offer that compile-time option.
Failing to do so will be tantamount to desupporting v0 functions
altogether, which I don't think we're prepared to do.
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2008-04-18 20:19:24 | Re: float4/float8/int64 passed by value with tsearch fixup |
Previous Message | Tom Lane | 2008-04-18 19:41:28 | Re: float4/float8/int64 passed by value with tsearch fixup |