Skip Menu |
 

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

Report information
The Basics
Id: 65922
Status: rejected
Priority: 0/
Queue: DBD-Pg

People
Owner: Nobody in particular
Requestors: aldis [...] bsdroot.lv
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.17.2
Fixed in: (no value)



Subject: Fails to execute queries with interval
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: 474
Download (untitled) / with headers
text/plain 474b
It is not possible to correctly execute SQL query that contains interval. Currently to work around this problem you have to insert value directly in query. # works $stm = $db->prepare("SELECT interval '3 hours'"); $stm->execute(); # fails $stm = $db->prepare("SELECT interval '? hours'"); $stm->execute(3); # fails $stm = $db->prepare("SELECT interval ?"); $stm->execute('3 hours'); I came across this problem on my FreeBSD-8.1 with perl 5.10.1 and PostgreSQL 9.0.3
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-19313-1298150733-1992.65922-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 619
Download (untitled) / with headers
text/plain 619b
On Sat Feb 19 15:04:34 2011, killasmurf86 wrote: Show quoted text
> It is not possible to correctly execute SQL query that contains > interval. > > Currently to work around this problem you have to insert value directly > in query. > > # works > $stm = $db->prepare("SELECT interval '3 hours'"); > $stm->execute(); > > # fails > $stm = $db->prepare("SELECT interval '? hours'"); > $stm->execute(3); > > # fails > $stm = $db->prepare("SELECT interval ?"); > $stm->execute('3 hours');
The interval is not 3. It's "3 hours". You need to do this: $stm = $db->prepare("SELECT interval ?"); $stm->execute('3 hours'); Best, David
MIME-Version: 1.0
In-Reply-To: <rt-3.8.HEAD-19313-1298150733-1992.65922-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.427 (Entity 5.427)
Content-Disposition: inline
References: <rt-3.8.HEAD-19313-1298150733-1992.65922-0-0 [...] rt.cpan.org>
Content-Type: text/plain; charset="UTF-8"
Message-ID: <rt-3.8.HEAD-26835-1298851159-20.65922-0-0 [...] rt.cpan.org>
Content-Transfer-Encoding: binary
From: aldis [...] bsdroot.lv
X-RT-Original-Encoding: utf-8
Content-Length: 938
Download (untitled) / with headers
text/plain 938b
On Sat Feb 19 16:25:33 2011, DWHEELER wrote: Show quoted text
> On Sat Feb 19 15:04:34 2011, killasmurf86 wrote:
> > It is not possible to correctly execute SQL query that contains > > interval. > > > > Currently to work around this problem you have to insert value
directly Show quoted text
> > in query. > > > > # works > > $stm = $db->prepare("SELECT interval '3 hours'"); > > $stm->execute(); > > > > # fails > > $stm = $db->prepare("SELECT interval '? hours'"); > > $stm->execute(3); > > > > # fails > > $stm = $db->prepare("SELECT interval ?"); > > $stm->execute('3 hours');
> > The interval is not 3. It's "3 hours". You need to do this: > > $stm = $db->prepare("SELECT interval ?"); > $stm->execute('3 hours'); > > Best, > > David
Hmm, That doesn't seam to work. Just copy paste your example... it fails DBD::Pg::st execute failed: ERROR: syntax error at or near "$1" LINE 1: SELECT interval $1 ^ at ./Linx.pl line 2048.
From david [...] kineticode.com Sun Feb 27 19: 57:24 2011
MIME-Version: 1.0 (Apple Message framework v1082)
X-Spam-Status: No, score=-7.086 tagged_above=-99.9 required=10 tests=[AWL=-0.186, BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5] autolearn=ham
In-Reply-To: <rt-3.8.HEAD-26835-1298851159-699.65922-5-0 [...] rt.cpan.org>
X-Mailer: Apple Mail (2.1082)
X-Spam-Flag: NO
References: <RT-Ticket-65922 [...] rt.cpan.org> <rt-3.8.HEAD-19313-1298150733-1992.65922-5-0 [...] rt.cpan.org> <rt-3.8.HEAD-26835-1298851159-699.65922-5-0 [...] rt.cpan.org>
X-Virus-Scanned: Debian amavisd-new at bestpractical.com
Content-Type: text/plain; charset="utf-8"
Message-ID: <3BE66643-2DA1-4BF0-BB0B-C3B644DE3B64 [...] kineticode.com>
X-RT-Original-Encoding: utf-8
X-Spam-Score: -7.086
Received: from localhost (localhost [127.0.0.1]) by hipster.bestpractical.com (Postfix) with ESMTP id D5313241664 for <cpan-bug+DBD-Pg [...] hipster.bestpractical.com>; Sun, 27 Feb 2011 19:57:24 -0500 (EST)
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 7zOE+UZQoM8w for <cpan-bug+DBD-Pg [...] hipster.bestpractical.com>; Sun, 27 Feb 2011 19:57:23 -0500 (EST)
Received: from la.mx.develooper.com (x1.develooper.com [207.171.7.70]) by hipster.bestpractical.com (Postfix) with SMTP id A0CAD240EB7 for <bug-DBD-Pg [...] rt.cpan.org>; Sun, 27 Feb 2011 19:57:22 -0500 (EST)
Received: (qmail 14800 invoked by uid 103); 28 Feb 2011 00:57:21 -0000
Received: from x16.dev (10.0.100.26) by x1.dev with QMQP; 28 Feb 2011 00:57:21 -0000
Received: from host-201.commandprompt.net (HELO smtp.kineticode.com) (207.173.203.201) by 16.mx.develooper.com (qpsmtpd/0.80) with ESMTP; Sun, 27 Feb 2011 16:57:19 -0800
Received: from [10.0.1.20] (c-24-21-128-239.hsd1.or.comcast.net [24.21.128.239]) by smtp.kineticode.com (Postfix) with ESMTPSA id A6475508054 for <bug-DBD-Pg [...] rt.cpan.org>; Sun, 27 Feb 2011 16:57:16 -0800 (PST)
Delivered-To: cpan-bug+DBD-Pg [...] hipster.bestpractical.com
Subject: Re: [rt.cpan.org #65922] Fails to execute queries with interval
Return-Path: <david [...] kineticode.com>
X-Spam-Check-BY: 16.mx.develooper.com
X-Original-To: cpan-bug+DBD-Pg [...] hipster.bestpractical.com
X-RT-Mail-Extension: dbd-pg
Date: Sun, 27 Feb 2011 16:57:16 -0800
X-Spam-Level:
To: bug-DBD-Pg [...] rt.cpan.org
Content-Transfer-Encoding: 7bit
From: "David E. Wheeler" <david [...] kineticode.com>
RT-Message-ID: <rt-3.8.HEAD-26838-1298854645-149.65922-0-0 [...] rt.cpan.org>
Content-Length: 364
Download (untitled) / with headers
text/plain 364b
On Feb 27, 2011, at 3:59 PM, Aldis Berjoza via RT wrote: Show quoted text
> Hmm, That doesn't seam to work. > Just copy paste your example... it fails > > > DBD::Pg::st execute failed: ERROR: syntax error at or near "$1" > LINE 1: SELECT interval $1 > ^ at ./Linx.pl line 2048.
Try this then: $stm = $db->prepare("SELECT ?::interval"); Best, David


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.