MySQL IV vs PV

Is there anything in a db handle or statement handle one use to know
whether the running instance of DBD::MySQL will return integer columns
as IV?

I'm adding some code to a layer atop DBI which will force IV (via +=0),
but want to avoid doing that were it is not required.

The particular code path serializes the returned rows via JSON::XS,
hense the need.

-JimC
-- 
James Cloos <cloos@jhcloos.com>         OpenPGP: 0x997A9F17ED7DAEA6
0
cloos
11/13/2017 5:43:10 PM
perl.dbi.users 11044 articles. 1 followers. Follow

1 Replies
2 Views

Similar Articles

[PageSpeed] 57

On 13/11/17 17:43, James Cloos wrote:
> Is there anything in a db handle or statement handle one use to know
> whether the running instance of DBD::MySQL will return integer columns
> as IV?
> 
> I'm adding some code to a layer atop DBI which will force IV (via +=0),
> but want to avoid doing that were it is not required.
> 
> The particular code path serializes the returned rows via JSON::XS,
> hense the need.
> 
> -JimC
> 

See

http://search.cpan.org/~timb/DBI-1.637/DBI.pm#sql_type_cast
http://search.cpan.org/~mjevans/DBD-ODBC-1.56/ODBC.pm#DiscardString
http://search.cpan.org/~mjevans/DBD-ODBC-1.56/ODBC.pm#StrictlyTyped

These attributes are implemented in DBD::Oracle and DBD::ODBC and allow the caller of bind_param to stipulate it wants an integer instead of a string.

They were originally implemented by me (with Tim's help) when I was retrieving result-sets which I wanted to convert to JSON. JSON treats numbers and string differently and I required numbers to be numbers and not strings.

There is of course, the type argument to bind_param as well.

Best of luck.

Martin
0
dbi
11/14/2017 9:08:28 AM
Reply: