Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the DBD-Oracle CPAN distribution.

Report information
The Basics
Id: 74753
Status: resolved
Priority: 0/
Queue: DBD-Oracle

People
Owner: Nobody in particular
Requestors: steve.baldwin [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 1.38
Fixed in: 1.42



Subject: PL/SQL OUT values are not utf8 encoded
As you will see by running the attached script, DBD::Oracle correctly encodes values returned from a SELECT statement - no surprise there. However executing effectively the same select in a PL/SQL block and returning the value via bind_param_inout does not result in a valid utf8 string. I have confirmed with Martin Evans that this issue exists in the latest svn trunk (as of 08-Feb- 12). He suggested the following patch : Index: dbdimp.c ========================================================= ========== --- dbdimp.c (revision 15130) +++ dbdimp.c (working copy) @@ -3197,7 +3197,14 @@ if (SvPVX(sv)) { SvCUR_set(sv, phs->alen); *SvEND(sv) = '\0'; - SvPOK_only_UTF8(sv); + SvPOK_only_UTF8(sv); + if (CSFORM_IMPLIES_UTF8(SQLCS_IMPLICIT)) { +#ifdef sv_utf8_decode + sv_utf8_decode(sv); +#else + SvUTF8_on(sv); +#endif + } } else { /* shouldn't happen */ debug = 2; Thanks, Steve
Subject: sb2.plx
Download sb2.plx
application/octet-stream 1.1k

Message body not shown because it is not plain text.

From: steve.baldwin [...] gmail.com
Sorry, attached the wrong version of the test script. The correct version is attached to this message.
Subject: sb2.plx
Download sb2.plx
application/octet-stream 1.3k

Message body not shown because it is not plain text.

Subject: Re: [rt.cpan.org #74753] PL/SQL OUT values are not utf8 encoded
Date: Wed, 08 Feb 2012 15:50:34 -0500
To: bug-DBD-Oracle [...] rt.cpan.org
From: Yanick Champoux <champoux [...] pythian.com>
Patch added on master, with test. Thanks! -- Pythian proud winner of Oracle North America Titan Award for Exadata Solution...watch the video on pythian.com
On Wed Feb 08 15:50:53 2012, PYTHIAN wrote: Show quoted text
> Patch added on master, with test. > > Thanks! > > > > -- > Pythian proud winner of Oracle North America Titan Award for Exadata > Solution...watch the video on pythian.com >
Yanick, I think the same change needs applying a little further down where the next SvPOK_only_UTF8 is called for a truncated parameter. The test would be to change the select statement to return multiple Euros concatenated together and then change the bind_param_inout to specify a length too short for the output parameter (try 1 instead of 100). Martin -- Martin J. Evans Wetherby, UK
From: steve.baldwin [...] gmail.com
I can confirm that so far my testing has found that the patch has resolved the bug. As Martin suggested, I applied the patch to two places. Thanks very much for such a quick solution.
Subject: Re: [rt.cpan.org #74753] PL/SQL OUT values are not utf8 encoded
Date: Fri, 10 Feb 2012 14:13:11 -0500
To: bug-DBD-Oracle [...] rt.cpan.org
From: Yanick Champoux <champoux [...] pythian.com>
On 02/08/12 16:05, Martin J Evans via RT wrote: Show quoted text
> Yanick, I think the same change needs applying a little further down > where the next SvPOK_only_UTF8 is called for a truncated parameter. > > The test would be to change the select statement to return multiple > Euros concatenated together and then change the bind_param_inout to > specify a length too short for the output parameter (try 1 instead of 100).
Patch applied to master (will be percolated to trunk in a few minutes). For the test, though, I just learned the hard way that DBD::Oracle doesn't heed the max_length argument of bind_param_inout. Is there any other easy way to test that the truncating logic work? Joy, `/anick -- Yanick Champoux, Senior Perl Developer The Pythian Group - love your data http://www.pythian.com -- -- Many may love your charm or riches, but the truest loves your data. Happy Valentine's Day from Pythian.
On Fri Feb 10 14:13:24 2012, PYTHIAN wrote: Show quoted text
> On 02/08/12 16:05, Martin J Evans via RT wrote:
> > Yanick, I think the same change needs applying a little further
> down
> > where the next SvPOK_only_UTF8 is called for a truncated parameter. > > > > The test would be to change the select statement to return multiple > > Euros concatenated together and then change the bind_param_inout to > > specify a length too short for the output parameter (try 1 instead
> of 100). > > Patch applied to master (will be percolated to trunk in a few > minutes). > > For the test, though, I just learned the hard way that > DBD::Oracle > doesn't heed the max_length argument of bind_param_inout. Is there any > other easy way to test that the truncating logic work? > > Joy, > `/anick
I didn't write that code - I just looked at it and it seemed it was attempting to handle the case where the buffer for the out parameter was not big enough. If DBD::Oracle pays no attention to the buffer length there seems no reason for that part of the else branch. I'll re-read it and try and work out what the person who wrote it was trying to cope with. All the same, I don't think the change to the truncated code will hurt and the other change is already verified as working by the reporter. I'm a bit short on time but by all means bug me to look at the truncated bit again. Martin -- Martin J. Evans Wetherby, UK
Subject: Re: [rt.cpan.org #74753] PL/SQL OUT values are not utf8 encoded
Date: Thu, 16 Feb 2012 11:37:32 -0500
To: bug-DBD-Oracle [...] rt.cpan.org
From: Yanick Champoux <champoux [...] pythian.com>
On 02/10/12 17:26, Martin J Evans via RT wrote: Show quoted text
> I didn't write that code - I just looked at it and it seemed it was > attempting to handle the case where the buffer for the out parameter was > not big enough. If DBD::Oracle pays no attention to the buffer length > there seems no reason for that part of the else branch. I'll re-read it > and try and work out what the person who wrote it was trying to cope with.
That's how I interpreted it too. But as I was trying to trigger the bad behavior for this code path (and failing), I came across that line in DBD::Oracle's pod: 2) The third parameter of bind_param_inout_array, (0 in the example), "maxlen" is required by DBI but not used by DBD::Oracle Now, it's perfectly possible that the pod is wrong, or that I misunderstand the use of the function, but from my current point of view, it seems to indicate that the truncation code path is not used. But, then again, I'm only guessing here. :-) Show quoted text
> > All the same, I don't think the change to the truncated code will hurt > and the other change is already verified as working by the reporter.
I totally agree. Show quoted text
> > I'm a bit short on time but by all means bug me to look at the truncated > bit again.
Okie. But there is no rush. I'll let you breath a wee bit. And then I'll poke you. :-) Joy, `/anick -- Yanick Champoux, Senior Perl Developer The Pythian Group - love your data http://www.pythian.com -- -- Catch Pythian at RMOUG and Tweet us hello @Pythian if you’re there. For speaker details visit bit .ly /pythianRMOUG12
Subject: Re: [rt.cpan.org #74753] PL/SQL OUT values are not utf8 encoded
Date: Thu, 16 Feb 2012 20:06:13 +0000
To: bug-DBD-Oracle [...] rt.cpan.org
From: "Martin J. Evans" <bohica [...] ntlworld.com>
On 16/02/2012 16:37, Pythian Remote DBA via RT wrote: Show quoted text
> Queue: DBD-Oracle > Ticket<URL: https://rt.cpan.org/Ticket/Display.html?id=74753> > > On 02/10/12 17:26, Martin J Evans via RT wrote:
>> I didn't write that code - I just looked at it and it seemed it was >> attempting to handle the case where the buffer for the out parameter was >> not big enough. If DBD::Oracle pays no attention to the buffer length >> there seems no reason for that part of the else branch. I'll re-read it >> and try and work out what the person who wrote it was trying to cope with.
> > That's how I interpreted it too. But as I was trying to trigger the > bad behavior for this code path (and failing), I came across > that line in DBD::Oracle's pod: > > 2) The third parameter of bind_param_inout_array, (0 in the example), > "maxlen" is required by DBI but not used by DBD::Oracle
hmm, as we suspected, it is perhaps never hit. Show quoted text
> Now, it's perfectly possible that the pod is wrong, or that I > misunderstand the use of the function, but from my current point of > view, it seems to indicate that the truncation code path is not used. > But, then again, I'm only guessing here. :-)
Show quoted text
>> >> All the same, I don't think the change to the truncated code will hurt >> and the other change is already verified as working by the reporter.
> > I totally agree.
Would you make the same change to the truncate path and add a comment saying we are not sure it is ever used and I'll try and make time this weekend to have another go at working out whether it is really used or not. Past experience suggests applying the fix and leaving the code in is a safer bet than ripping it out. Show quoted text
>
>> >> I'm a bit short on time but by all means bug me to look at the truncated >> bit again.
> > Okie. But there is no rush. I'll let you breath a wee bit. And then > I'll poke you. :-) > > > Joy, > `/anick >
Martin -- Martin J. Evans Wetherby, UK
changes applied to master, both for the first item reported and for the truncation case.