Date: | Tue, 10 Jan 2006 11:06:20 +0100 (CET) |
From: | Sebastiaan Hoogeveen <sebastiaan [...] kantoor.nederhost.nl> |
To: | bug-dbd-pg [...] rt.cpan.org |
Subject: | Syntax error when binding parameter to the argument of the INTERVAL keyword |
Hi,
When doing the following on one of our machines with PostgreSQL 8.1.1:
SQL:
CREATE TABLE some_fields ( datum DATE );
Perl:
my $sth_interval = $dbh->prepare ( 'SELECT * FROM some_fields WHERE datum < now() - interval ?' );
$sth_interval->execute ( '5 days' );
I receive the following error:
DBD::Pg::st execute failed: ERROR: syntax error at or near "$1" at
character 58
I have confirmed this problem not to occur when using placeholders to
quote dates, texts of strings in regular field matches. The problem does
not occur if I do $dbh->{pg_server_prepare} = 0.
I know this problem occurred in earlier DBD::Pg versions and is supposed
to be fixed. I use DBD::Pg 1.43 with DBI 1.50. We have two machines, each
with a (supposedly) identical PostgreSQL 8.1.1 and Perl 5.8.7 install. The
system with an ancient Slackware installation and gcc 2 does NOT have
this problem. The system with Gentoo and gcc 3.3.6 DOES have the problem.
First follows the configuration details of the machine on which this bug
occurs:
----
DBD::Pg make test output:
PERL_DL_NONLAZY=1 /home/website/bin/perl "-MExtUtils::Command::MM" "-e"
"test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00basic...........ok
t/01connect.........#
# Program Version
# Perl 5.8.7 (linux)
# DBD::Pg 1.43
# PostgreSQL (compiled) 80101
# PostgreSQL (target) 80101
# PostgreSQL (reported) PostgreSQL 8.1.1 on i686-pc-linux-gnu, compiled by
GCC gcc (GCC) 3.3.6 (Gentoo 3.3.6, ssp-3.3.6-1.0, pie-8.7.8)
# DBI 1.50
# DBI_DSN DBI:Pg:dbname=sql_test
t/01connect.........ok
t/01constants.......ok
t/01setup...........ok
t/02attribs.........ok
t/03dbmethod........ok
t/03smethod.........ok
t/04misc............ok
t/05arrays..........ok
15/17 skipped: Array support not implemented
t/06bytea...........ok
t/07copy............ok
t/12placeholders....ok
t/20savepoints......ok
t/99_pod............skipped
all skipped: Test::Pod 0.95 required for testing POD
t/99cleanup.........ok
All tests successful, 1 test and 15 subtests skipped.
Files=15, Tests=417, 3 wallclock secs ( 2.15 cusr + 0.18 csys = 2.33
CPU)
----
----
Perl version and configuration information:
Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
Platform:
osname=linux, osvers=2.6.11.6, archname=i686-linux
uname='linux chef 2.6.11.6 #1 fri apr 1 18:10:11 cest 2005 i686
intel(r) celeron(r) cpu 2.40ghz genuineintel gnulinux '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-strict-aliasing -pipe -D_LARGEFILE_SOURCE
-D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing -pipe'
ccversion='', gccversion='3.3.6 (Gentoo 3.3.6, ssp-3.3.6-1.0,
pie-8.7.8)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lndbm -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.3.5.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.3.5'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: USE_LARGE_FILES
Built under linux
Compiled at Dec 25 2005 01:53:45
@INC:
/home/website/lib/perl5/5.8.7/i686-linux
/home/website/lib/perl5/5.8.7
/home/website/lib/perl5/site_perl/5.8.7/i686-linux
/home/website/lib/perl5/site_perl/5.8.7
/home/website/lib/perl5/site_perl
.
----
----
gcc version used to compile both Perl and DBD::Pg:
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/specs
Configured with: /var/tmp/portage/gcc-3.3.6/work/gcc-3.3.6/configure
--prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3.6
--includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/include
--datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3.6
--mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3.6/man
--infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3.6/info
--with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.6/include/g++-v3
--host=i686-pc-linux-gnu --build=i686-pc-linux-gnu --disable-altivec
--enable-nls --without-included-gettext --with-system-zlib
--disable-checking --disable-werror --disable-libunwind-exceptions
--disable-multilib --disable-libmudflap --disable-libgcj
--enable-languages=c,c++,f77 --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu
Thread model: posix
gcc version 3.3.6 (Gentoo 3.3.6, ssp-3.3.6-1.0, pie-8.7.8)
----
So far the information about the system on which the error does occur.
Information on the system on which the error does NOT occur is below.
----
Perl version on the machine the problem does NOT occur:
Summary of my perl5 (revision 5 version 8 subversion 7) configuration:
Platform:
osname=linux, osvers=2.4.27, archname=i686-linux
uname='linux cartman 2.4.27 #2 sat nov 6 15:06:16 cet 2004 i686
unknown '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef useithreads=undef
usemultiplicity=undef
useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
use64bitint=undef use64bitall=undef uselongdouble=undef
usemymalloc=n, bincompat5005=undef
Compiler:
cc='cc', ccflags ='-fno-strict-aliasing -pipe -I/usr/local/include
-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O2',
cppflags='-fno-strict-aliasing -pipe -I/usr/local/include'
ccversion='', gccversion='2.95.3 20010315 (release)', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t',
lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -lndbm -lgdbm -ldl -lm -lcrypt -lutil -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.2.3.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.2.3'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Characteristics of this binary (from libperl):
Compile-time options: USE_LARGE_FILES
Built under linux
Compiled at Aug 30 2005 10:48:04
@INC:
/home/sebastiaan/test/lib/perl5/5.8.7/i686-linux
/home/sebastiaan/test/lib/perl5/5.8.7
/home/sebastiaan/test/lib/perl5/site_perl/5.8.7/i686-linux
/home/sebastiaan/test/lib/perl5/site_perl/5.8.7
/home/sebastiaan/test/lib/perl5/site_perl
.
----
----
gcc version on the machine where the problem does NOT occur (yes, it's
ancient):
gcc version 2.95.3 20010315 (release)
----
Kind regards,
--
Sebastiaan Hoogeveen <sebastiaan@kantoor.nederhost.nl>
NederHost
http://www.nederhost.nl