From: | Boszormenyi Zoltan <zb(at)cybertec(dot)at> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | Magnus Hagander <magnus(at)hagander(dot)net>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>, Michael Meskes <meskes(at)postgresql(dot)org> |
Subject: | Re: ECPG patch causes warning |
Date: | 2010-01-10 18:16:59 |
Message-ID: | 4B4A199B.7010900@cybertec.at |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Tom Lane írta:
> Boszormenyi Zoltan <zb(at)cybertec(dot)at> writes:
>
>> Tom Lane írta:
>>
>>> I think that the compiler has caught an actual mistake here.
>>>
>
>
>> Yes, it's a mistake, but not an actual bug.
>> The intent was to be able to catch unhandled
>> cases in the application, just as in ecpg_dynamic_type().
>> The fix for sqlda_dynamic_type() is to use the same cast:
>>
>
>
>> return -(int) type;
>>
>
>
>> Should I send a patch for this?
>>
>
> You should send a patch to *get rid of it*. Putting in a cast only
> hides the fact that this logic will break on OIDs above 2G.
>
As would ecpg_dynamic_type(), then. :-(
You wrote previously:
> Perhaps InvalidOid is the thing
> to use here?
Perhaps InvalidOid wouldn't be the best choice to return,
because this function returns int, not Oid. InvalidOid equals
to ECPGt_char. Hm... it would be hiding the failure in
a good way, as the type returned couldn't be mapped to
any ECPGt_* type, and the value would be returned in
a string anyway. We can use ECPGt_char for the unhandled case.
Another way (to lose only twenty-something values from 4GB)
would be to introduce ECPGt_max and
return (ECPGt_max + type)
to have mapping for a large amount of type Oids.
There would be a drawback in this case, when
a new type might get added to ECPG, and the value of
ECPGt_max changes. An Oid -> int mapping has the
advantage of being able to catch non-standard types,
but libecpg and the app may have different opinion about
the value of ECPGt_max, as the app may be compiled
against a different version of libecpg in a theoretical future.
I think that leaves the first choice.
Patch is attached.
Best regards,
Zoltán Böszörményi
--
Bible has answers for everything. Proof:
"But let your communication be, Yea, yea; Nay, nay: for whatsoever is more
than these cometh of evil." (Matthew 5:37) - basics of digital technology.
"May your kingdom come" - superficial description of plate tectonics
----------------------------------
Zoltán Böszörményi
Cybertec Schönig & Schönig GmbH
http://www.postgresql.at/
Attachment | Content-Type | Size |
---|---|---|
fix-sqlda-unhandled-type.patch | text/x-patch | 524 bytes |
From | Date | Subject | |
---|---|---|---|
Next Message | David Fetter | 2010-01-10 18:42:49 | Re: Congrats Alvaro! |
Previous Message | Tom Lane | 2010-01-10 18:11:11 | Re: Initial refactoring of plperl.c - updated |