Subject: | Support binding of integers so they are returned as IVs |
It would be really nice if DBD::Oracle allowed the binding of integers
such that bind_col($n, undef, { TYPE => SQL_INTEGER }) actually returned
an IV instead of a PV. Here is my specific case:
The query I am executing returns a mix of strings and integers which are
fetched with fetchall_arrayref. The returned data is then fed into
JSON::XS to produce a JSON string. JSON::XS encodes strings as "string"
and numbers as number (no quotes) but it detects numbers using:
if (SvPOKp (sv))
{
STRLEN len;
char *str = SvPV (sv, len);
encode_ch (enc, '"');
encode_str (enc, str, len, SvUTF8 (sv));
encode_ch (enc, '"');
}
else if (SvNOKp (sv))
{
// trust that perl will do the right thing w.r.t. JSON syntax.
need (enc, NV_DIG + 32);
Gconvert (SvNVX (sv), NV_DIG, 0, enc->cur);
enc->cur += strlen (enc->cur);
}
else if (SvIOKp (sv))
{
// we assume we can always read an IV as a UV and vice versa
// we assume two's complement
// we assume no aliasing issues in the union
My query returns 209 thousand rows and the JSON encoded data is over
21Mb. 3 of the fields are really numbers so if they are encoded as
numbers we lose 2 " around each of the numbers vastly reducing the size
of the encoded data. As DBD::Oracle does not support returning columns
as integers I have to loop through all 209000 rows adding 0 to each
field which is a number to make it an IV - this takes a lot of time -
believe me, I've Devel::NYTProf'ed it.
I'm sure this would be of general usefulness, I only cite my specific
example to help explain why this would be good.
Martin
--
Martin J. Evans
Wetherby, UK