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: 76410
Status: resolved
Priority: 0/
Queue: DBD-Oracle

People
Owner: Nobody in particular
Requestors: DAMI [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.42
Fixed in: 1.45_00



Subject: misbehaviour of scrollable cursors
MIME-Version: 1.0
Content-Type: text/plain; charset="UTF-8"
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 950
Download (untitled) / with headers
text/plain 950b
Two problems with scrollable cursors (with DBD::Oracle v1.42, OCI version 11.2.0.2) Given the following : my $sql = "SELECT table_name FROM all_tables ORDER BY table_name "; my $sth = $dbh->prepare($sql, {ora_exe_mode => OCI_STMT_SCROLLABLE_READONLY}); $sth->execute; Problem 1 : $sth->ora_fetch_scroll(OCI_FETCH_ABSOLUTE, $some_offset); my $r1 = $sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0); my $r2 = $sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0); $r2 is a different reference from $r1, but the content of @$r1 is overwritten with the content of @$r2 ! Problem 2 : $sth->ora_fetch_scroll(OCI_FETCH_ABSOLUTE, $some_offset); my $r1 = $sth->fetch; my $r2 = $sth->fetch; ... Every successive call to the ->fetch() method always returns the same record. And of course, if you try $sth->fetchall_arrayref(), you get into an infinite loop. However, if you do one single OCI_FETCH_NEXT after the ABSOLUTE, then the behaviour of ->fetch() seems to be OK.
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-18070-1333971261-781.76410-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
From: byterock [...] hotmail.com
X-RT-Original-Encoding: utf-8
Content-Length: 1261
Download (untitled) / with headers
text/plain 1.2k
On Sun Apr 08 12:19:50 2012, DAMI wrote: Show quoted text
> Two problems with scrollable cursors (with DBD::Oracle v1.42, OCI > version 11.2.0.2) > > Given the following : > > my $sql = "SELECT table_name FROM all_tables ORDER BY table_name "; > my $sth = $dbh->prepare($sql, {ora_exe_mode => > OCI_STMT_SCROLLABLE_READONLY}); > $sth->execute; > > > Problem 1 : > $sth->ora_fetch_scroll(OCI_FETCH_ABSOLUTE, $some_offset); > my $r1 = $sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0); > my $r2 = $sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0); > $r2 is a different reference from $r1, but the content of @$r1 > is overwritten with the content of @$r2 ! >
Actully the are exatly the same A referace to '$sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0);' which would be the next fetch. I think you are just getting into a circular referace here Just my first though. Show quoted text
> Problem 2 : > $sth->ora_fetch_scroll(OCI_FETCH_ABSOLUTE, $some_offset); > my $r1 = $sth->fetch; > my $r2 = $sth->fetch; > ... > Every successive call to the ->fetch() method always returns the same > record. And of course, if you try $sth->fetchall_arrayref(), you get > into an infinite loop. However, if you do one single OCI_FETCH_NEXT > after the ABSOLUTE, then the behaviour of ->fetch() seems to be OK. >
From champoux [...] pythian.com Mon Apr 9 12: 02:48 2012
MIME-Version: 1.0
X-Spam-Status: No, score=-1.89 tagged_above=-99.9 required=10 tests=[AWL=-0.769, BAYES_00=-1.9, SPF_NEUTRAL=0.779] autolearn=no
In-Reply-To: <rt-3.8.HEAD-18069-1333901990-1900.76410-4-0 [...] rt.cpan.org>
X-Spam-Flag: NO
References: <RT-Ticket-76410 [...] rt.cpan.org> <rt-3.8.HEAD-18069-1333901990-1900.76410-4-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Message-ID: <4F83081D.5020201 [...] pythian.com>
Content-Type: text/plain; charset="utf-8"; format="flowed"
X-RT-Original-Encoding: utf-8
X-Spam-Score: -1.89
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id 357CA2401BF for <cpan-bug+DBD-Oracle [...] hipster.bestpractical.com>; Mon, 9 Apr 2012 12:02:48 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id h1xiox4KBAzq for <cpan-bug+DBD-Oracle [...] hipster.bestpractical.com>; Mon, 9 Apr 2012 12:02:47 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id A161824014A for <bug-DBD-Oracle [...] rt.cpan.org>; Mon, 9 Apr 2012 12:02:46 -0400 (EDT)
Received: (qmail 12693 invoked by uid 103); 9 Apr 2012 16:02:45 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 9 Apr 2012 16:02:45 -0000
Received: from na3sys009aog135.obsmtp.com (HELO psmtp.com) (74.125.149.84) by 16.mx.develooper.com (qpsmtpd/0.80/v0.80-19-gf52d165) with SMTP; Mon, 09 Apr 2012 09:02:42 -0700
Received: from mail-ob0-f171.google.com ([209.85.214.171]) (using TLSv1) by na3sys009aob135.postini.com ([74.125.148.12]) with SMTP ID DSNKT4MIH0th3E9NGLyxQZILspIaKPfhZhmt [...] postini.com; Mon, 09 Apr 2012 09:02:42 PDT
Received: by obbwd18 with SMTP id wd18so7649658obb.30 for <bug-DBD-Oracle [...] rt.cpan.org>; Mon, 09 Apr 2012 09:02:39 -0700 (PDT)
Received: by 10.182.7.4 with SMTP id f4mr11173602oba.57.1333987359249; Mon, 09 Apr 2012 09:02:39 -0700 (PDT)
Received: by 10.182.7.4 with SMTP id f4mr11173587oba.57.1333987359116; Mon, 09 Apr 2012 09:02:39 -0700 (PDT)
Received: from [10.237.236.207] (host7.pythian.com. [209.217.100.70]) by mx.google.com with ESMTPS id m3sm13009161oem.7.2012.04.09.09.02.37 (version=SSLv3 cipher=OTHER); Mon, 09 Apr 2012 09:02:38 -0700 (PDT)
Delivered-To: cpan-bug+DBD-Oracle [...] hipster.bestpractical.com
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:11.0) Gecko/20120312 Thunderbird/11.0
Subject: Re: [rt.cpan.org #76410] misbehaviour of scrollable cursors
Return-Path: <champoux [...] pythian.com>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: cpan-bug+DBD-Oracle [...] hipster.bestpractical.com
X-RT-Mail-Extension: dbd-oracle
X-Google-Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:x-gm-message-state; bh=6c7ZLsReRCGjLwu35QkUJno0+Tgs8AhppdV4P0wGI4M=; b=FiAXwvAAwAMx14ggvk/yz8VcNxe6AsDeoAeChYNafEAG0hYSnNDcVCnGNm4DhOI4mH qDpJL8aZhypIxaoIWU0DOmQHuEr8NCi5MmqK63KUs5fm6bBcMJrggpeMNGv0PrR0+mli MBjU76XdMvKr9D1kkNHqAIP+ovpi2gEOpv78vVfEP8X/uZjUYvB7CwtXQdAoJeAcNE5z wNtUpERmWWeBAId8Csqnz1KHFGsLvKt0q1iKm13OPcekJ9N+vCczw870SBTdsElmdZbU Pl4Xm69j+lxmxFdNhUZj0AZomiXXnpiSbeNfNVQi7cfp5P8bDwtVkhwYqaKLSt362pVi aAtA==
Date: Mon, 09 Apr 2012 12:02:37 -0400
X-Spam-Level:
To: bug-DBD-Oracle [...] rt.cpan.org
From: Yanick Champoux <champoux [...] pythian.com>
X-GM-Message-State: ALoCoQnkvt2ArZqPCsbRIBD6njUsVNKlnSKQIgVc+/LVkSF79frdCynJHcERktG6oJsgdNsxRShGsHAhlpu4uBrUW5RQc9GKpA==
RT-Message-ID: <rt-3.8.HEAD-18072-1333987369-1373.76410-0-0 [...] rt.cpan.org>
Content-Length: 1634
Download (untitled) / with headers
text/plain 1.5k
Hi Laurent, Huge caveat: I'm not overly familiar with ora_fetch_scroll, so take the following with a grain of salt. :-) On 12-04-08 12:19 PM, Laurent Dami via RT wrote: Show quoted text
> > Problem 1 : > $sth->ora_fetch_scroll(OCI_FETCH_ABSOLUTE, $some_offset); > my $r1 = $sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0); > my $r2 = $sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0); > $r2 is a different reference from $r1, but the content of @$r1 > is overwritten with the content of @$r2 !
That sounds... vicious. It'll double-check the docs to make sure it's not meant to be that way. From your report, it sounds like all 'ora_fetch_scroll' calls use the same underlying array. Show quoted text
> > Problem 2 : > $sth->ora_fetch_scroll(OCI_FETCH_ABSOLUTE, $some_offset); > my $r1 = $sth->fetch; > my $r2 = $sth->fetch; > ... > Every successive call to the ->fetch() method always returns the same > record.
Are you hitting the last row? The doc says of OCI_FETCH_ABSOLUTE: "[..] and a fetch offset value that is greater than the number of records in the record set, does not change current_positon attribute, it is equivalent to a OCI_FETCH_CURRENT." Which might explain the symptoms you're seeing. Joy, `/anick Show quoted text
> And of course, if you try $sth->fetchall_arrayref(), you get > into an infinite loop. However, if you do one single OCI_FETCH_NEXT > after the ABSOLUTE, then the behaviour of ->fetch() seems to be OK. > >
-- Yanick Champoux, Senior Perl Developer The Pythian Group - love your data http://www.pythian.com -- -- Pythian proud winner of Oracle North America Titan Award for Exadata Solution...watch the video on pythian.com
From champoux [...] pythian.com Mon Apr 9 14: 49:41 2012
MIME-Version: 1.0
X-Spam-Status: No, score=-1.835 tagged_above=-99.9 required=10 tests=[AWL=-0.714, BAYES_00=-1.9, SPF_NEUTRAL=0.779] autolearn=no
In-Reply-To: <rt-3.8.HEAD-18069-1333901990-1900.76410-4-0 [...] rt.cpan.org>
X-Spam-Flag: NO
References: <RT-Ticket-76410 [...] rt.cpan.org> <rt-3.8.HEAD-18069-1333901990-1900.76410-4-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Message-ID: <4F832F35.6090605 [...] pythian.com>
Content-Type: text/plain; charset="utf-8"; format="flowed"
X-RT-Original-Encoding: utf-8
X-Spam-Score: -1.835
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id CC9BF2401C8 for <cpan-bug+DBD-Oracle [...] hipster.bestpractical.com>; Mon, 9 Apr 2012 14:49:41 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AMbuzJsUntyH for <cpan-bug+DBD-Oracle [...] hipster.bestpractical.com>; Mon, 9 Apr 2012 14:49:40 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id 213BA2401BF for <bug-DBD-Oracle [...] rt.cpan.org>; Mon, 9 Apr 2012 14:49:39 -0400 (EDT)
Received: (qmail 26652 invoked by uid 103); 9 Apr 2012 18:49:39 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 9 Apr 2012 18:49:39 -0000
Received: from na3sys009aog137.obsmtp.com (HELO psmtp.com) (74.125.149.18) by 16.mx.develooper.com (qpsmtpd/0.80/v0.80-19-gf52d165) with SMTP; Mon, 09 Apr 2012 11:49:31 -0700
Received: from mail-ob0-f169.google.com ([209.85.214.169]) (using TLSv1) by na3sys009aob137.postini.com ([74.125.148.12]) with SMTP ID DSNKT4MvOB5aYk04WCFn8TX5yU0uoGd1bEX7 [...] postini.com; Mon, 09 Apr 2012 11:49:31 PDT
Received: by obbta14 with SMTP id ta14so6436490obb.28 for <bug-DBD-Oracle [...] rt.cpan.org>; Mon, 09 Apr 2012 11:49:28 -0700 (PDT)
Received: by 10.182.136.41 with SMTP id px9mr11927459obb.21.1333997368393; Mon, 09 Apr 2012 11:49:28 -0700 (PDT)
Received: by 10.182.136.41 with SMTP id px9mr11927449obb.21.1333997368229; Mon, 09 Apr 2012 11:49:28 -0700 (PDT)
Received: from [10.237.236.207] (host7.pythian.com. [209.217.100.70]) by mx.google.com with ESMTPS id d9sm17146397obq.0.2012.04.09.11.49.26 (version=SSLv3 cipher=OTHER); Mon, 09 Apr 2012 11:49:27 -0700 (PDT)
Delivered-To: cpan-bug+DBD-Oracle [...] hipster.bestpractical.com
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:11.0) Gecko/20120312 Thunderbird/11.0
Subject: Re: [rt.cpan.org #76410] misbehaviour of scrollable cursors
Return-Path: <champoux [...] pythian.com>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: cpan-bug+DBD-Oracle [...] hipster.bestpractical.com
X-RT-Mail-Extension: dbd-oracle
X-Google-Dkim-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:content-type:content-transfer-encoding :x-gm-message-state; bh=RJTfOeGJAu/SEGmK/Mga5QQ+IM9Aod8k8bOuP4UySAU=; b=buvrP2OretxArBIf3DDf1bH///qBBU9AmGpSM+hD0VWNvKoDRSsfthAeyQ5SxPM0Fb 8KL+OwaJ0YSrh+rYdkiwxtFdAA9BlbASeXMvdJFvuQXn5iMBsYEascSPIx789NTyb85Y I9Sk7E5DHu5GkfxE83KwvDoA5r3Tqt24fnzQd9Tc0z9NMwiNqKutE8B2LSTw3fd1mcj/ zYZeY7qwjp40DFzs4v2cxEyzIR6XbnEW0UzyJPFGSCYBH3ykcVdDuZlmKrMNNJ4Dg3k3 aM7vMGa81bLeJdxgfIawLYKtZDRH3Mooy1UpHm7hunmhyJZpQNTdNeWHRIqo83AgYVpa O6Fg==
Date: Mon, 09 Apr 2012 14:49:25 -0400
X-Spam-Level:
To: bug-DBD-Oracle [...] rt.cpan.org
Content-Transfer-Encoding: quoted-printable
From: Yanick Champoux <champoux [...] pythian.com>
X-GM-Message-State: ALoCoQl4EshvFzE2nQpU7TJWWowyP+ymhzwVvbzUL8UTv51uktq1iZ2NB2uAeoy32CCRfG71tNxR+tRK76Ox2ivMaaQ0ppjDNg==
RT-Message-ID: <rt-3.8.HEAD-18069-1333997382-874.76410-0-0 [...] rt.cpan.org>
Content-Length: 1148
Download (untitled) / with headers
text/plain 1.1k
On 12-04-08 12:19 PM, Laurent Dami via RT wrote: Show quoted text
> Problem 1 : > $sth->ora_fetch_scroll(OCI_FETCH_ABSOLUTE, $some_offset); > my $r1 = $sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0); > my $r2 = $sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0); > $r2 is a different reference from $r1, but the content of @$r1 > is overwritten with the content of @$r2 !
The undesired behavior is captured in a test at https://github.com/yanick/DBD-Oracle/tree/rt76410-scroll-misbehave The jury is still out as to if that's the way it should be. In the meantime, to ensure that your next call to the function doesn't mess with your results, you can do: my $r1 = \@{$sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0)}; my $r2 = \@{$sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0)}; It's slightly silly, granted, but until/if we correct the behavior, it's duct-tape that should get you going. :-) Cheers, `/anick -- Yanick Champoux, Senior Perl Developer The Pythian Group - love your data http://www.pythian.com -- -- Discover the latest MySQL tips and tricks from Pythian’s top talent at this year’s MySQL Conference April 10-12. Details at pythian.com/news
From laurent.dami [...] free.fr Sun Apr 15 21: 15:34 2012
MIME-Version: 1.0
X-Spam-Status: No, score=-1.899 tagged_above=-99.9 required=10 tests=[BAYES_00=-1.9, FREEMAIL_FROM=0.001] autolearn=ham
In-Reply-To: <rt-3.8.HEAD-18072-1333987369-1825.76410-6-0 [...] rt.cpan.org>
X-Spam-Flag: NO
References: <RT-Ticket-76410 [...] rt.cpan.org> <rt-3.8.HEAD-18069-1333901990-1900.76410-4-0 [...] rt.cpan.org> <4F83081D.5020201 [...] pythian.com> <rt-3.8.HEAD-18072-1333987369-1825.76410-6-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Message-ID: <4F8B72B7.9010109 [...] free.fr>
Content-Type: text/plain; charset=UTF-8; format=flowed
X-RT-Original-Encoding: utf-8
X-Spam-Score: -1.899
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id B18F924020E for <cpan-bug+DBD-Oracle [...] hipster.bestpractical.com>; Sun, 15 Apr 2012 21:15:34 -0400 (EDT)
Received: from hipster.bestpractical.com ([127.0.0.1]) by localhost (hipster.bestpractical.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id WbYebjd2KBqR for <cpan-bug+DBD-Oracle [...] hipster.bestpractical.com>; Sun, 15 Apr 2012 21:15:33 -0400 (EDT)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id BD56524016D for <bug-DBD-Oracle [...] rt.cpan.org>; Sun, 15 Apr 2012 21:15:32 -0400 (EDT)
Received: (qmail 786 invoked by uid 103); 16 Apr 2012 01:15:31 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 16 Apr 2012 01:15:31 -0000
Received: from smtp2.infomaniak.ch (HELO smtp2.infomaniak.ch) (84.16.68.90) by 16.mx.develooper.com (qpsmtpd/0.80/v0.80-19-gf52d165) with ESMTP; Sun, 15 Apr 2012 18:15:29 -0700
Received: from [192.168.1.33] (237-123.62-81.cust.bluewin.ch [81.62.123.237]) (authenticated bits=0) by smtp2.infomaniak.ch (8.14.2/8.14.2) with ESMTP id q3G1FOQP008667 for <bug-DBD-Oracle [...] rt.cpan.org>; Mon, 16 Apr 2012 03:15:24 +0200
Delivered-To: cpan-bug+DBD-Oracle [...] hipster.bestpractical.com
User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:11.0) Gecko/20120327 Thunderbird/11.0.1
Subject: Re: [rt.cpan.org #76410] misbehaviour of scrollable cursors
Return-Path: <laurent.dami [...] free.fr>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: cpan-bug+DBD-Oracle [...] hipster.bestpractical.com
X-RT-Mail-Extension: dbd-oracle
Date: Mon, 16 Apr 2012 03:15:35 +0200
X-Spam-Level:
To: bug-DBD-Oracle [...] rt.cpan.org
Content-Transfer-Encoding: 8bit
From: laurent dami <laurent.dami [...] free.fr>
RT-Message-ID: <rt-3.8.HEAD-30929-1334538935-1272.76410-0-0 [...] rt.cpan.org>
Content-Length: 1203
Download (untitled) / with headers
text/plain 1.1k
Le 09.04.2012 18:02, Pythian Remote DBA via RT a écrit : Show quoted text
>> Problem 2 : >> $sth->ora_fetch_scroll(OCI_FETCH_ABSOLUTE, $some_offset); >> my $r1 = $sth->fetch; >> my $r2 = $sth->fetch; >> ... >> Every successive call to the ->fetch() method always returns the same >> record.
> Are you hitting the last row? The doc says of OCI_FETCH_ABSOLUTE: > "[..] and a fetch offset value that is greater than the number of > records in the record set, does not change current_positon attribute, it > is equivalent to a OCI_FETCH_CURRENT." Which might explain the symptoms > you're seeing. > > >
No I'm not at the last row. The value of $some_offset is right in the middle of the result set. Since the doc says "When the statement is executed you will then be able to use 'ora_fetch_scroll' method to get a row or you can still use any of the other fetch methods", one would expect to be able to freely mix calls to ->fetch() and calls to ->ora_fetch_scroll(), but this is not the observed behaviour. Something like this snippet works correctly : $sth->ora_fetch_scroll(OCI_FETCH_ABSOLUTE, $some_offset- 1); $sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0); my $r1 = $sth->fetch; my $r2 = $sth->fetch; ...
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-30928-1335082875-1801.76410-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 909
Download (untitled) / with headers
text/plain 909b
On Sun Apr 08 12:19:50 2012, DAMI wrote: Show quoted text
> Two problems with scrollable cursors (with DBD::Oracle v1.42, OCI > version 11.2.0.2) > > Given the following : > > my $sql = "SELECT table_name FROM all_tables ORDER BY table_name "; > my $sth = $dbh->prepare($sql, {ora_exe_mode => > OCI_STMT_SCROLLABLE_READONLY}); > $sth->execute; > > > Problem 1 : > $sth->ora_fetch_scroll(OCI_FETCH_ABSOLUTE, $some_offset); > my $r1 = $sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0); > my $r2 = $sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0); > $r2 is a different reference from $r1, but the content of @$r1 > is overwritten with the content of @$r2 !
That is not quite as easy to fix as the other part of this rt. Show quoted text
> Problem 2 : > $sth->ora_fetch_scroll(OCI_FETCH_ABSOLUTE, $some_offset); > my $r1 = $sth->fetch; > my $r2 = $sth->fetch; > ...
This should be fixed in subversion trunk now. Martin -- Martin J. Evans Wetherby, UK
MIME-Version: 1.0
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-30929-1335084104-754.76410-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 1962
Download (untitled) / with headers
text/plain 1.9k
On Sun Apr 08 12:19:50 2012, DAMI wrote: Show quoted text
> Two problems with scrollable cursors (with DBD::Oracle v1.42, OCI > version 11.2.0.2) > > Given the following : > > my $sql = "SELECT table_name FROM all_tables ORDER BY table_name "; > my $sth = $dbh->prepare($sql, {ora_exe_mode => > OCI_STMT_SCROLLABLE_READONLY}); > $sth->execute; > > > Problem 1 : > $sth->ora_fetch_scroll(OCI_FETCH_ABSOLUTE, $some_offset); > my $r1 = $sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0); > my $r2 = $sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0); > $r2 is a different reference from $r1, but the content of @$r1 > is overwritten with the content of @$r2 !
Strange, I don't get that, I get the same ref in each case. # rt 76410 - fetch next twice returns different references but the # contents of the first are overwritten by the contents of the second $value = $sth->ora_fetch_scroll(OCI_FETCH_ABSOLUTE, 1); is($value->[0], 1, "... we should get the 1st row rt76410_1"); my $v1 = $sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0); is($v1->[0], 2, "... we should get the 2nd row rt76410_1"); my $v2 = $sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0); is($v2->[0], 3, "... we should get the 3rd row rt76410_1"); ok($v1 != $v2, "... two row references are different rt76410_1") or diag("$v1, $v2"); isnt($v1->[0], $v2->[0], "... 1st fetched row should not change rt76410_1"); ok 37 - ... we should get the 1st row rt76410_1 ok 38 - ... we should get the 2nd row rt76410_1 ok 39 - ... we should get the 3rd row rt76410_1 not ok 40 - ... two row references are different rt76410_1 # Failed test '... two row references are different rt76410_1' # at t/51scroll.t line 139. # ARRAY(0x9edd870), ARRAY(0x9edd870) not ok 41 - ... 1st fetched row should not change rt76410_1 # Failed test '... 1st fetched row should not change rt76410_1' # at t/51scroll.t line 140. # got: '3' # expected: anything else I don't think the other fixes affect this. Martin -- Martin J. Evans Wetherby, UK
MIME-Version: 1.0
In-Reply-To: <rt-3.8.HEAD-30929-1335084104-754.76410-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <rt-3.8.HEAD-30929-1335084104-754.76410-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-30923-1335085393-351.76410-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 2563
Download (untitled) / with headers
text/plain 2.5k
On Sun Apr 22 04:41:44 2012, MJEVANS wrote: Show quoted text
> On Sun Apr 08 12:19:50 2012, DAMI wrote:
> > Two problems with scrollable cursors (with DBD::Oracle v1.42, OCI > > version 11.2.0.2) > > > > Given the following : > > > > my $sql = "SELECT table_name FROM all_tables ORDER BY table_name "; > > my $sth = $dbh->prepare($sql, {ora_exe_mode => > > OCI_STMT_SCROLLABLE_READONLY}); > > $sth->execute; > > > > > > Problem 1 : > > $sth->ora_fetch_scroll(OCI_FETCH_ABSOLUTE, $some_offset); > > my $r1 = $sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0); > > my $r2 = $sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0); > > $r2 is a different reference from $r1, but the content of @$r1 > > is overwritten with the content of @$r2 !
> > Strange, I don't get that, I get the same ref in each case. > > # rt 76410 - fetch next twice returns different references but the > # contents of the first are overwritten by the contents of the second > $value = $sth->ora_fetch_scroll(OCI_FETCH_ABSOLUTE, 1); > is($value->[0], 1, "... we should get the 1st row rt76410_1"); > my $v1 = $sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0); > is($v1->[0], 2, "... we should get the 2nd row rt76410_1"); > my $v2 = $sth->ora_fetch_scroll(OCI_FETCH_NEXT, 0); > is($v2->[0], 3, "... we should get the 3rd row rt76410_1"); > ok($v1 != $v2, "... two row references are different rt76410_1") or > diag("$v1, $v2"); > isnt($v1->[0], $v2->[0], "... 1st fetched row should not change
rt76410_1"); Show quoted text
> > ok 37 - ... we should get the 1st row rt76410_1 > ok 38 - ... we should get the 2nd row rt76410_1 > ok 39 - ... we should get the 3rd row rt76410_1 > not ok 40 - ... two row references are different rt76410_1 > > # Failed test '... two row references are different rt76410_1' > # at t/51scroll.t line 139. > # ARRAY(0x9edd870), ARRAY(0x9edd870) > not ok 41 - ... 1st fetched row should not change rt76410_1 > > # Failed test '... 1st fetched row should not change rt76410_1' > # at t/51scroll.t line 140. > # got: '3' > # expected: anything else > > I don't think the other fixes affect this. > > Martin
From the DBD::Oracle pod http://search.cpan.org/~pythian/DBD-Oracle-1.42/lib/DBD/Oracle.pm#Scrollable_Cursor_Methods ora_fetch_scroll "Works the same as fetchrow_arrayref" From the DBI pod http://search.cpan.org/~timb/DBI-1.618/DBI.pm#fetchrow_arrayref Note that the same array reference is returned for each fetch, so don't store the reference and then use it after a later fetch. So the first part of this rt is working as per documented. Martin -- Martin J. Evans Wetherby, UK


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.