Code Monkey home page Code Monkey logo

dbdpg's Introduction

Bucardo - a table-based replication system

DESCRIPTION:
------------

This is version 5.6.0 of Bucardo.

COPYRIGHT:
----------

    Copyright (c) 2005-2023 Greg Sabino Mullane <[email protected]>

REQUIREMENTS:
-------------

    build, test, and install Perl 5                (at least 5.8.3)
    build, test, and install PostgreSQL            (at least 8.2)
    build, test, and install the DBI module        (at least 1.51)
    build, test, and install the DBD::Pg module    (at least 2.0.0)
    build, test, and install the DBIx::Safe module (at least 1.2.4)
    
    You must have at least one database that has PL/pgSQL and PL/Perl installed.
    Target databases may need PL/pgSQL.


INSTALLATION:
-------------

To install this module type the following:

   perl Makefile.PL
   make
   make test (but see below first)
   make install

EXAMPLES:
---------

See the test suite in the t/ subdirectory for some examples.

WEBSITE:
--------

Please visit https://bucardo.org for complete documentation.

DEVELOPMENT:
------------

To follow or participate in the development of Bucardo, use:

git clone [email protected]:bucardo/bucardo.git

GETTING HELP:
-------------

For general questions and troubleshooting, please use the [email protected]
mailing list.  GitHub issues which are support-oriented will be closed and referred to
the mailing list anyway, so help save time for everyone by posting there directly.

Post, subscribe, and see previous archives here:

https://bucardo.org/mailman/listinfo/bucardo-general

dbdpg's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

dbdpg's Issues

DBD::Pg 3.9.x fails tests on 32-bit PowerPC

The first bad commit is 5298fac:

t/04misc.t ............. 1/101 DBD::Pg::st execute failed: ERROR:  invalid input syntax for integer: "-9.22337203685478e+18" at t/04misc.t line 80.
Issuing rollback() due to DESTROY without explicit disconnect() of DBD::Pg::db handle dbname=postgres;port=5440;host=/usr/src/packages/user/perl-dbd-pg/src/DBD-Pg-3.9.1/dbdpg_test_database/data/socket at t/04misc.t line 80.
# Looks like your test exited with 255 just after 14.
t/04misc.t ............. Dubious, test returned 255 (wstat 65280, 0xff00)

After 112ddc3, the error changes to:

t/04misc.t ............. 1/101 
#   Failed test 'Constant PG_MIN_BIGINT returns correct value'
#   at t/04misc.t line 81.
#          got: '-9223372036854775808'
#     expected: '-9.22337203685478e+18'
DBD::Pg::st execute failed: ERROR:  invalid input syntax for integer: "-9.22337203685478e+18" at t/04misc.t line 87.
Issuing rollback() due to DESTROY without explicit disconnect() of DBD::Pg::db handle dbname=postgres;port=5440;host=/usr/src/packages/user/perl-dbd-pg/src/DBD-Pg-3.9.1/dbdpg_test_database/data/socket at t/04misc.t line 87.
# Looks like your test exited with 255 just after 16.
t/04misc.t ............. Dubious, test returned 255 (wstat 65280, 0xff00)

Changing it to use bignums, the error changes to test failures:

t/04misc.t ............. 1/101 
#   Failed test 'Constant PG_MIN_BIGINT returns correct value'
#   at t/04misc.t line 81.
#          got: '-9223372036854775808'
#     expected: '-9.22337203685478e+18'

#   Failed test 'Constant PG_MIN_BIGINT returns correct value'
#   at t/04misc.t line 88.
#          got: '-9223372036854775807'
#     expected: '-9.22337203685478e+18'

#   Failed test 'Constant PG_MAX_BIGINT returns correct value'
#   at t/04misc.t line 92.
#          got: '9223372036854775807'
#     expected: '9.22337203685478e+18'

#   Failed test 'Constant PG_MAX_BIGINT returns correct value'
#   at t/04misc.t line 99.
#          got: '9223372036854775806'
#     expected: '9.22337203685478e+18'
t/04misc.t ............. 99/101 # Looks like you failed 4 tests of 101.
t/04misc.t ............. Dubious, test returned 4 (wstat 1024, 0x400)

Accessing ->state appears to be leaking memory

An example program demonstrating the problem:

#!/usr/bin/perl

use strict;
use warnings;

use DBI;
use DBD::Pg;

my @connect = ("dbi:Pg:", '', '', {pg_enable_utf8 => 1, RaiseError => 0, PrintError => 0, AutoCommit => 1});
my $dbh = DBI->connect(@connect) or die "foo: ".$DBI::errstr;

for (;;) {
    my $stmt = $dbh->prepare(q{SELECT 1 / 0});
    if (!$stmt) {
        die "wtf: ".$dbh->errstr;
    }
    my $rv = $stmt->execute();
    if (defined $rv) {
        die "oh no";
    }
    for (my $j = 0; $j < 10000; ++$j) {
        my $foo = $dbh->state;
    }
}

I've tested this against the Ubuntu version of 2.19.3 and 3.6.2 they both seem to be having the same problem. I'm no XS expert, but the lack of sv_2mortal() here:

void state(sth)
SV *sth;
    CODE:
        D_imp_sth(sth);
        D_imp_dbh_from_sth;
        ST(0) = strEQ(imp_dbh->sqlstate,"00000") ? &PL_sv_no :
           /* ----> */ newSVpv(imp_dbh->sqlstate, 5);

looks suspicious compared to all the other assignments to ST(0). The problem exists for the state method on both the statement and the database handles.

Add the data types in `contrib` to pg_types

Things like hstore come back as unknown. I can see not including stuff like this if PostgreSQL didn't officially ship it, but types created in contrib seems like a relatively small lift.

Tests failing after upgrading to 3.8.1

I'm unable to upgrade to 3.8.1. Please see the following 2 Dockerfiles:

3.8.0:

FROM perl:5.28
RUN apt-get update && apt-get install -y libpq-dev
RUN cpanm -v DBD::[email protected]

3.8.1:

FROM perl:5.28
RUN apt-get update && apt-get install -y libpq-dev
RUN cpanm -v DBD::[email protected]

The first (3.8.0) installs fine. However, the second (3.8.1) fails with the following errors:

t/00basic.t ......... ok
Invalid initdb: initdb
#
# DBI                         Version 1.642
# DBD::Pg                     Version 3.8.1
# Perl                        Version 5.28.0
# OS                          linux
# PostgreSQL (compiled)       ?
# PostgreSQL (target)         ?
# PostgreSQL (reported)       ?
# Default port                ?
# DBI_DSN                     ?
# DBI_USER                    <not set>
# Test schema                 dbd_pg_testschema
t/01connect.t .......
Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
t/01constants.t ..... ok
Invalid initdb: initdb
t/02attribs.t .......
Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
Invalid initdb: initdb
t/03dbmethod.t ......
Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
Invalid initdb: initdb
t/03smethod.t .......
Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
Invalid initdb: initdb
t/04misc.t ..........
Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
Invalid initdb: initdb
t/06bytea.t .........
Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
Invalid initdb: initdb
t/07copy.t ..........
Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
Invalid initdb: initdb
t/08async.t .........
Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
Invalid initdb: initdb
t/09arrays.t ........
Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
Invalid initdb: initdb
t/12placeholders.t ..
Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
Invalid initdb: initdb
t/20savepoints.t ....
Dubious, test returned 2 (wstat 512, 0x200)
No subtests run
Invalid initdb: initdb

Failed test 'Dollar quotes with valid characters are parsed as identifiers'

Version 3.5.3 work w/o problem, but in the same environment
versions 3.5.9_1, 3.6.0 etc. fail during test with next messages:

t/12placeholders.t .. 1/257
#   Failed test 'Dollar quotes with valid characters are parsed as identifiers'
#   at t/12placeholders.t line 673.
#          got: 'Wide character in subroutine entry at /usr/i.kit/DBD-Pg-3.5.9_1/blib/lib/DBD/Pg.pm line 280.
# '
#     expected: ''

#   Failed test 'Dollar quotes with valid characters are parsed as identifiers'
#   at t/12placeholders.t line 673.
#          got: 'Wide character in subroutine entry at /usr/i.kit/DBD-Pg-3.5.9_1/blib/lib/DBD/Pg.pm line 280.
# '
#     expected: ''

#   Failed test 'Dollar quotes with valid characters are parsed as identifiers'
#   at t/12placeholders.t line 673.
#          got: 'Wide character in subroutine entry at /usr/i.kit/DBD-Pg-3.5.9_1/blib/lib/DBD/Pg.pm line 280.
# '
#     expected: ''
# Looks like you failed 3 tests of 257.
t/12placeholders.t .. Dubious, test returned 3 (wstat 768, 0x300)
Failed 3/257 subtests
...
Test Summary Report
-------------------
t/12placeholders.t (Wstat: 768 Tests: 257 Failed: 3)
  Failed tests:  140-142
  Non-zero exit status: 3
Files=16, Tests=1918, 23 wallclock secs ( 0.27 usr  0.04 sys +  4.44 cusr  0.36 csys =  5.11 CPU)
Result: FAIL
Failed 1/16 test programs. 3/1918 subtests failed.

Tests fail when run as root

... due to File::Temp::tempdir being used without having run 'require File::Temp' first:

...
t/01connect.t ..........
Dubious, test returned 1 (wstat 256, 0x100)
No subtests run
t/01constants.t ........ ok
Please wait, creating new database (version 10.16) for testing
Undefined subroutine &File::Temp::tempdir called at t/dbdpg_test_setup.pl line 376.
t/02attribs.t ..........
...

Problem installing with perl 5.30.1

I'm trying to install DBD::Pg with perl 5.30.1 under perlbrew (I have it installed normally on my 5.22 system perl). I'm getting the following build log:

cpanm (App::cpanminus) 1.7044 on perl 5.030001 built for x86_64-linux
Work directory is /home/veesh/.cpanm/work/1584234914.30106
You have make /usr/bin/make
You have /usr/bin/wget
You have /bin/tar: tar (GNU tar) 1.28
Copyright (C) 2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.
You have /usr/bin/unzip
Searching DBD::Pg () on cpanmetadb ...
--> Working on DBD::Pg
Fetching http://www.cpan.org/authors/id/T/TU/TURNSTEP/DBD-Pg-3.10.4.tar.gz
-> OK
Unpacking DBD-Pg-3.10.4.tar.gz
Entering DBD-Pg-3.10.4
Checking configure dependencies from META.yml
Checking if you have DBI 1.614 ... Yes (1.643)
Checking if you have version 0 ... Yes (0.9924)
Configuring DBD-Pg-3.10.4
Running Makefile.PL
Configuring DBD::Pg 3.10.4
PostgreSQL version: 100011 (default port: 5432)
POSTGRES_HOME: (not set)
POSTGRES_INCLUDE: /usr/include/postgresql
POSTGRES_LIB: /usr/lib/x86_64-linux-gnu
OS: linux
Checking if your kit is complete...
Looks good
Using DBI 1.643 (for perl 5.030001 on x86_64-linux) installed in /home/veesh/perl5/lib/perl5/x86_64-linux/auto/DBI/
Generating a Unix-style Makefile
Writing Makefile for DBD::Pg
Writing MYMETA.yml and MYMETA.json
-> OK
Checking dependencies from MYMETA.json ...
Checking if you have Test::More 0.88 ... Yes (1.302171)
Checking if you have version 0 ... Yes (0.9924)
Checking if you have ExtUtils::MakeMaker 6.11 ... Yes (7.30)
Checking if you have DBI 1.614 ... Yes (1.643)
Checking if you have Time::HiRes 0 ... Yes (1.9760)
Building and testing DBD-Pg-3.10.4
cp Pg.pm blib/lib/DBD/Pg.pm
cp lib/Bundle/DBD/Pg.pm blib/lib/Bundle/DBD/Pg.pm
Running Mkbootstrap for Pg ()
chmod 644 "Pg.bs"
"/home/veesh/perl5/perlbrew/perls/perl-5.30.1/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Pg.bs blib/arch/auto/DBD/Pg/Pg.bs 644
"/home/veesh/perl5/perlbrew/perls/perl-5.30.1/bin/perl" -p -e "s/~DRIVER~/Pg/g; s/^do\(/dontdo\(/" /home/veesh/perl5/lib/perl5/x86_64-linux/auto/DBI/Driver.xst > Pg.xsi
"/home/veesh/perl5/perlbrew/perls/perl-5.30.1/bin/perl" "/home/veesh/perl5/lib/perl5/ExtUtils/xsubpp"  -typemap '/home/veesh/perl5/perlbrew/perls/perl-5.30.1/lib/5.30.1/ExtUtils/typemap'  Pg.xs > Pg.xsc
mv Pg.xsc Pg.c
cc -c  -I/usr/include/postgresql -I/home/veesh/perl5/lib/perl5/x86_64-linux/auto/DBI -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPGLIBVERSION=100011 -DPGDEFPORT=5432 -O2  -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc -DVERSION=\"3.10.4\" -DXS_VERSION=\"3.10.4\" -fPIC "-I/home/veesh/perl5/perlbrew/perls/perl-5.30.1/lib/5.30.1/x86_64-linux/CORE"   Pg.c
cc -c  -I/usr/include/postgresql -I/home/veesh/perl5/lib/perl5/x86_64-linux/auto/DBI -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPGLIBVERSION=100011 -DPGDEFPORT=5432 -O2  -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc -DVERSION=\"3.10.4\" -DXS_VERSION=\"3.10.4\" -fPIC "-I/home/veesh/perl5/perlbrew/perls/perl-5.30.1/lib/5.30.1/x86_64-linux/CORE"   dbdimp.c
cc -c  -I/usr/include/postgresql -I/home/veesh/perl5/lib/perl5/x86_64-linux/auto/DBI -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPGLIBVERSION=100011 -DPGDEFPORT=5432 -O2  -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc -DVERSION=\"3.10.4\" -DXS_VERSION=\"3.10.4\" -fPIC "-I/home/veesh/perl5/perlbrew/perls/perl-5.30.1/lib/5.30.1/x86_64-linux/CORE"   quote.c
cc -c  -I/usr/include/postgresql -I/home/veesh/perl5/lib/perl5/x86_64-linux/auto/DBI -fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -DPGLIBVERSION=100011 -DPGDEFPORT=5432 -O2  -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc -DVERSION=\"3.10.4\" -DXS_VERSION=\"3.10.4\" -fPIC "-I/home/veesh/perl5/perlbrew/perls/perl-5.30.1/lib/5.30.1/x86_64-linux/CORE"   types.c
rm -f blib/arch/auto/DBD/Pg/Pg.so
LD_RUN_PATH="/usr/lib/x86_64-linux-gnu" cc  -shared -O2 -L/usr/local/lib -fstack-protector-strong  Pg.o dbdimp.o quote.o types.o  -o blib/arch/auto/DBD/Pg/Pg.so  \
   -L/usr/lib/x86_64-linux-gnu -lpq -lm   \
  
chmod 755 blib/arch/auto/DBD/Pg/Pg.so
Manifying 2 pod documents
"/home/veesh/perl5/perlbrew/perls/perl-5.30.1/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Pg.bs blib/arch/auto/DBD/Pg/Pg.bs 644
PGINITDB="/usr/lib/postgresql/10/bin/initdb" PERL_DL_NONLAZY=1 "/home/veesh/perl5/perlbrew/perls/perl-5.30.1/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00_signature.t ....... skipped: Set the environment variable TEST_SIGNATURE to enable this test
t/00basic.t ............ ok
# 
# DBI                         Version 1.643
# DBD::Pg                     Version 3.10.4
# Perl                        Version 5.30.1
# OS                          linux
# PostgreSQL (compiled)       100011
# PostgreSQL (target)         100011
# PostgreSQL (reported)       PostgreSQL 10.11 (Ubuntu 10.11-1.pgdg16.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609, 64-bit
# Default port                5432
# DBI_DSN                     dbi:Pg:
# DBI_USER                    postgres
# Test schema                 dbd_pg_testschema
# LANG                        en_US.UTF-8
# array_nulls                 on
# backslash_quote             safe_encoding
# client_encoding             UTF8
# server_encoding             UTF8
# standard_conforming_strings on
# Adjusted:                   DBI_DSN 
t/01connect.t .......... ok
t/01constants.t ........ ok
t/02attribs.t .......... ok

#   Failed test 'DB handle method "table_info" returns correct number of rows when given a 'MATERIALIZED VIEW' type argument'
#   at t/03dbmethod.t line 659.
#          got: '2'
#     expected: '0'

#   Failed test 'DB handle method "table_info" returns correct number of rows when given a 'MATERIALIZED VIEW' type argument'
#   at t/03dbmethod.t line 674.
#          got: '3'
#     expected: '1'
# Looks like you failed 2 tests of 580.
t/03dbmethod.t ......... 
Dubious, test returned 2 (wstat 512, 0x200)
Failed 2/580 subtests 
	(less 5 skipped subtests: 573 okay)
t/03smethod.t .......... ok
t/04misc.t ............. ok
t/06bytea.t ............ ok
t/07copy.t ............. ok
t/08async.t ............ ok
t/09arrays.t ........... ok
t/10_pg_error_field.t .. ok
t/12placeholders.t ..... ok
t/20savepoints.t ....... ok
t/30unicode.t .......... ok
t/99cleanup.t .......... ok

Test Summary Report
-------------------
t/03dbmethod.t       (Wstat: 512 Tests: 580 Failed: 2)
  Failed tests:  123, 125
  Non-zero exit status: 2
Files=17, Tests=2860, 26 wallclock secs ( 0.48 usr  0.03 sys +  4.58 cusr  0.56 csys =  5.65 CPU)
Result: FAIL
Failed 1/17 test programs. 2/2860 subtests failed.
Makefile:985: recipe for target 'test_dynamic' failed
make: *** [test_dynamic] Error 255
-> FAIL Installing DBD::Pg failed. See /home/veesh/.cpanm/work/1584234914.30106/build.log for details. Retry with --force to force install it.

Mysterious failures with [email protected]

One of DBIC's tests causes interpreter corruption when run against [email protected] and DBD::Pg 3.10.0 ( specifically due to commit: 81b518137a08a ). The exit code is 255 and the The exact error is:

~$ perl -Ilib t/72pg.t
...
ok 256 - Auto-PK for sequence without default: First primary key set manually
ok 257 - with_deferred_fk_checks code survived
ok 258 - code in with_deferred_fk_checks worked
ok 259 - with_deferred_fk_checks is off outside of TXN
ok 260 - Still expected exception on deferred failure at commit time
ok 261 - No warnings on deferred rollback
Use of freed value in iteration at t/72pg.t line 489.

ASAN instrumentation sadly does not reveal anything, however one of DBD::Pg's own tests fails like so:

PGINITDB="/usr/lib/postgresql/9.5/bin/initdb" PERL_DL_NONLAZY=1 "/home/rabbit/perl5/perlbrew/perls/5.24.3_asan/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00_release.t ......... skipped: Test skipped unless environment variable RELEASE_TESTING is set
t/00_signature.t ....... skipped: Set the environment variable TEST_SIGNATURE to enable this test
t/00basic.t ............ ok   
t/01connect.t .......... Please wait, creating new database (version 9.5) for testing
t/01connect.t .......... 15/15 # 
# DBI                         Version 1.634
# DBD::Pg                     Version 3.10.0
# Perl                        Version 5.24.3
# OS                          linux
# PostgreSQL (compiled)       90503
# PostgreSQL (target)         90503
# PostgreSQL (reported)       PostgreSQL 9.5.3 on x86_64-pc-linux-gnu, compiled by gcc (Debian 5.3.1-19) 5.3.1 20160509, 64-bit
# Default port                5432
# DBI_DSN                     dbi:Pg:db="postgres";port=5440;host=<pwd>/dbdpg_test_database/data/socket
# DBI_USER                    rabbit
# Test schema                 dbd_pg_testschema
# LANG                        C
# array_nulls                 on
# backslash_quote             safe_encoding
# client_encoding             UTF8
# server_encoding             UTF8
# standard_conforming_strings on
# Adjusted:                   initdb
t/01connect.t .......... ok     
t/01constants.t ........ ok     
t/02attribs.t .......... ok       
t/03dbmethod.t ......... ok       
t/03smethod.t .......... ok       
t/04misc.t ............. ok       
t/06bytea.t ............ ok     
t/07copy.t ............. ok     
t/08async.t ............ ok     
t/09arrays.t ........... 186/201 =================================================================
==3554==ERROR: AddressSanitizer: heap-use-after-free on address 0x612000049cc0 at pc 0x7fd0f6ff001c bp 0x7fff0bac5310 sp 0x7fff0bac5308
READ of size 4 at 0x612000049cc0 thread T0
    #0 0x7fd0f6ff001b in pg_st_destroy /home/rabbit/devel/dbic/dbdpg/dbdimp.c:3972
    #1 0x7fd0f6fafbb6 in XS_DBD__Pg__st_DESTROY Pg.xsi:799
    #2 0x7fd0f727892a in XS_DBI_dispatch /home/rabbit/.cpanm/work/1571091303.2816/DBI-1.634/DBI.xs:3748
    #3 0x60d72c in Perl_pp_entersub /home/rabbit/perl5/perlbrew/build/perl-5.24.3/pp_hot.c:3988
    #4 0x47379d in Perl_call_sv /home/rabbit/perl5/perlbrew/build/perl-5.24.3/perl.c:2807
    #5 0x61bcc3 in S_curse /home/rabbit/perl5/perlbrew/build/perl-5.24.3/sv.c:6853
    #6 0x61da8f in Perl_sv_clear /home/rabbit/perl5/perlbrew/build/perl-5.24.3/sv.c:6457
    #7 0x61e75e in Perl_sv_free2 /home/rabbit/perl5/perlbrew/build/perl-5.24.3/sv.c:6954
    #8 0x618381 in S_visit /home/rabbit/perl5/perlbrew/build/perl-5.24.3/sv.c:476
    #9 0x61f7bb in Perl_sv_clean_objs /home/rabbit/perl5/perlbrew/build/perl-5.24.3/sv.c:627
    #10 0x47b9f2 in perl_destruct /home/rabbit/perl5/perlbrew/build/perl-5.24.3/perl.c:816
    #11 0x421ae0 in main /home/rabbit/perl5/perlbrew/build/perl-5.24.3/perlmain.c:127
    #12 0x7fd0fa7f6b44 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21b44)
    #13 0x4220b4 (/home/rabbit/perl5/perlbrew/perls/5.24.3_asan/bin/perl+0x4220b4)

0x612000049cc0 is located 0 bytes inside of 266-byte region [0x612000049cc0,0x612000049dca)
freed by thread T0 here:
    #0 0x7fd0fb948527 in __interceptor_free (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x54527)
    #1 0x61cd19 in Perl_sv_clear /home/rabbit/perl5/perlbrew/build/perl-5.24.3/sv.c:6652

previously allocated by thread T0 here:
    #0 0x7fd0fb94873f in malloc (/usr/lib/x86_64-linux-gnu/libasan.so.1+0x5473f)
    #1 0x59d231 in Perl_safesysmalloc /home/rabbit/perl5/perlbrew/build/perl-5.24.3/util.c:153

SUMMARY: AddressSanitizer: heap-use-after-free /home/rabbit/devel/dbic/dbdpg/dbdimp.c:3972 pg_st_destroy
Shadow bytes around the buggy address:
  0x0c2480001340: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c2480001350: fd fd fd fd fd fd fd fd fd fa fa fa fa fa fa fa
  0x0c2480001360: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
  0x0c2480001370: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c2480001380: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x0c2480001390: fa fa fa fa fa fa fa fa[fd]fd fd fd fd fd fd fd
  0x0c24800013a0: fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd fd
  0x0c24800013b0: fd fd fd fd fd fd fd fd fd fd fa fa fa fa fa fa
  0x0c24800013c0: fa fa fa fa fa fa fa fa 00 00 00 00 00 00 00 00
  0x0c24800013d0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x0c24800013e0: 00 00 00 00 00 00 00 00 00 fa fa fa fa fa fa fa
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Heap right redzone:      fb
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack partial redzone:   f4
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Contiguous container OOB:fc
  ASan internal:           fe
==3554==ABORTING
t/09arrays.t ........... Dubious, test returned 1 (wstat 256, 0x100)
All 201 subtests passed 
t/10_pg_error_field.t .. ok     
t/12placeholders.t ..... NOTICE:  drop cascades to table dbd_pg_testschema.dbdpg_error_field_test
t/12placeholders.t ..... ok       
t/20savepoints.t ....... ok   
t/30unicode.t .......... ok     
t/99_lint.t ............ skipped: Test skipped unless environment variable AUTHOR_TESTING is set
t/99_perlcritic.t ...... skipped: Test skipped unless environment variable AUTHOR_TESTING is set
t/99_pod.t ............. skipped: Test skipped unless environment variable AUTHOR_TESTING is set
t/99_spellcheck.t ...... skipped: Test skipped unless environment variable AUTHOR_TESTING is set
t/99_yaml.t ............ skipped: Test skipped unless environment variable RELEASE_TESTING is set
t/99cleanup.t .......... ok   

Test Summary Report
-------------------
t/09arrays.t         (Wstat: 256 Tests: 201 Failed: 0)
  Non-zero exit status: 1
Files=23, Tests=2845, 60 wallclock secs ( 1.50 usr  0.20 sys + 17.94 cusr  3.64 csys = 23.28 CPU)
Result: FAIL

RaiseError doesn't raise an error when $sth passed to wrong $dbh

If I am in RaiseError mode and want to use one of the database handle method which can take a statement in lieu of a string, it doesn't raise an error if it points to a disconnected database. Could the disconnected handle keep track that it was in RaiseError=>1 mode even after being discontinued?

perl -wle 'use strict; use Data::Dumper; use DBI; my $dbh=DBI->connect("dbi:Pg:",undef,undef,{RaiseError=>1}); my $sth=$dbh->prepare("select * from pgbench_accounts limit 5"); $dbh->disconnect(); $dbh=DBI->connect("dbi:Pg:",undef,undef,{RaiseError=>1}); my $x=$dbh->selectrow_array($sth); print Dumper $x; print $DBD::Pg::VERSION; print $sth->errstr'

$VAR1 = undef;

3.6.2
Cannot call execute on a disconnected database handle

Tests fail on macOS using SSL - need better paths in the .bundle

I've found the root of the problem, but I don't have a fix.

I installed DBD::Pg with cpan on v5.30.2 (perl -V at end) with the Postgres pre-built package for macOS. I had set POSTGRES_LIB:

$ export POSTGRES_LIB="/Library/PostgreSQL/12/lib -lssl -lcrypto"

The compilation works fine, but the tests fail because it cannot load the libraries:

$ make test
"/usr/local/perls/perl-5.30.2/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Pg.bs blib/arch/auto/DBD/Pg/Pg.bs 644
PGINITDB="/Library/PostgreSQL/12/bin/initdb" PERL_DL_NONLAZY=1 "/usr/local/perls/perl-5.30.2/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00_signature.t ....... skipped: Set the environment variable TEST_SIGNATURE to enable this test
t/00basic.t ............ 1/3
#   Failed test 'use DBD::Pg;'
#   at t/00basic.t line 17.
#     Tried to use 'DBD::Pg'.
#     Error:  Can't load '/Users/brian/.cpan/build/DBD-Pg-3.11.1-2/blib/arch/auto/DBD/Pg/Pg.bundle' for module DBD::Pg: dlopen(/Users/brian/.cpan/build/DBD-Pg-3.11.1-2/blib/arch/auto/DBD/Pg/Pg.bundle, 2): Library not loaded: libssl.1.1.dylib
#   Referenced from: /Users/brian/.cpan/build/DBD-Pg-3.11.1-2/blib/arch/auto/DBD/Pg/Pg.bundle
#   Reason: image not found at /usr/local/perls/perl-5.30.2/lib/5.30.2/darwin-2level/DynaLoader.pm line 197.
#  at t/00basic.t line 17.
# Compilation failed in require at t/00basic.t line 17.
# BEGIN failed--compilation aborted at t/00basic.t line 17.
# CCFLAGS: q[-fno-common -DPERL_DARWIN -mmacosx-version-min=10.15 -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -DPERL_USE_SAFE_PUTENV -DPGLIBVERSION=120002 -DPGDEFPORT=5432]
# INC: q[-I/Library/PostgreSQL/12/include -I/usr/local/perls/perl-5.30.2/lib/site_perl/5.30.2/darwin-2level/auto/DBI]
# LIBS: [q[-L/Library/PostgreSQL/12/lib -lssl -lcrypto -lpq -lm]]
# If the error mentions libpq.so, please see the troubleshooting section of the README file
Bailout called.  Further testing stopped:  Cannot continue without DBD::Pg
FAILED--Further testing stopped: Cannot continue without DBD::Pg
make: *** [test_dynamic] Error 255

This is a known problem with macOS's System Integrity Protection, which unsets DYLD_* and LD_*.

Looking at the .bundle file produced, I see that the Pg libraries are names only (not paths or rpaths):

$ otool -L ./blib/arch/auto/DBD/Pg/Pg.bundle
./blib/arch/auto/DBD/Pg/Pg.bundle:
	libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
	libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
	libpq.5.dylib (compatibility version 5.0.0, current version 5.12.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1281.100.1)

I updated the bundle to have absolute paths:

$ install_name_tool -change libssl.1.1.dylib /Library/PostgreSQL/12/lib/libssl.1.1.dylib ./blib/arch/auto/DBD/Pg/Pg.bundle
$ install_name_tool -change libcrypto.1.1.dylib /Library/PostgreSQL/12/lib/libcrypto.1.1.dylib ./blib/arch/auto/DBD/Pg/Pg.bundle
$ install_name_tool -change libpq.5.dylib /Library/PostgreSQL/12/lib/libpq.5.dylib ./blib/arch/auto/DBD/Pg/Pg.bundle

Now the tests work and everyone is happy.

It took me awhile to get to this point, so I haven't even begun to look at the DBD::Pg sources to see where a fix might go in. I'm also hoping someone already knows how to fix this quickly. :)

System details

$ uname -a
Darwin foo.local 19.3.0 Darwin Kernel Version 19.3.0: Thu Jan  9 20:58:23 PST 2020; root:xnu-6153.81.5~1/RELEASE_X86_64 x86_64

$ perl -V
Summary of my perl5 (revision 5 version 30 subversion 2) configuration:
   
  Platform:
    osname=darwin
    osvers=19.3.0
    archname=darwin-2level
    uname='darwin otter.local 19.3.0 darwin kernel version 19.3.0: thu jan 9 20:58:23 pst 2020; root:xnu-6153.81.5~1release_x86_64 x86_64 '
    config_args='-des -Dprefix=/usr/local/perls/perl-5.30.2'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='cc'
    ccflags ='-fno-common -DPERL_DARWIN -mmacosx-version-min=10.15 -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -DPERL_USE_SAFE_PUTENV'
    optimize='-O3'
    cppflags='-fno-common -DPERL_DARWIN -mmacosx-version-min=10.15 -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='4.2.1 Compatible Apple LLVM 11.0.0 (clang-1100.0.33.17)'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='cc'
    ldflags =' -mmacosx-version-min=10.15 -fstack-protector-strong -L/usr/local/lib'
    libpth=/usr/local/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/11.0.0/lib /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/lib /usr/lib
    libs=-lpthread -ldbm -ldl -lm -lutil -lc
    perllibs=-lpthread -ldl -lm -lutil -lc
    libc=
    so=dylib
    useshrplib=false
    libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=bundle
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags=' -mmacosx-version-min=10.15 -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector-strong'


Characteristics of this binary (from libperl): 
  Compile-time options:
    HAS_TIMES
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_SAFE_PUTENV
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
  Built under darwin
  Compiled at Mar 15 2020 13:27:13
  %ENV:
    PERL="/Users/brian/bin/perls/perl-latest"
    PERL5_PATH="/Users/brian/bin/perls"
  @INC:
    /usr/local/perls/perl-5.30.2/lib/site_perl/5.30.2/darwin-2level
    /usr/local/perls/perl-5.30.2/lib/site_perl/5.30.2
    /usr/local/perls/perl-5.30.2/lib/5.30.2/darwin-2level
    /usr/local/perls/perl-5.30.2/lib/5.30.2

last_insert_id failing for table name with double quotes

Good day folks.

Error:
INSERT into " public.best!Tab le@Ever2$%^&()_+{}:'""?/.>,<~ 4" (" (id)$mipublic.lk'","""""''""""2--","not$%^&() _+{}:'""?/.>,<~nice","""""""""3'","""""''""""++") VALUES (?, ?, ?, ?, ?) DBD::Pg::db last_insert_id failed: Could not find the table " public.best!Tab le@Ever2$%^&*()_+{}\:'""?/.>,<~ `4" [for Statement "
SELECT i.indisprimary,
COALESCE(
-- this takes the table name as text, not regclass
pg_catalog.pg_get_serial_sequence(
-- and pre-8.3 doesn't have a cast from regclass to text,
-- and pre-9.3 doesn't have format, so do it the long way
quote_ident(n.nspname) || '.' || quote_ident(c.relname),
<>

The issue seems to be that since I have double quotes in the table name, I have to "double up" the double quotes for the insert statement but you folks may need to replace all "" in the table name to " before running your query.
$table_name_for_query = $table_name; $table_name_for_query =~ s/["]{2}/"/g;

memory management error using JSONB "key exists" operator (question mark)

I have code that uses bind parameters and the ? operator for a JSONB field. I get a variety of different errors, each time I run my test script.

Test Script:

use strict;
use DBI;
use DBD::Pg;

my $connect_info = {
    dsn => 'dbi:Pg:dbname=xxx host=localhost port=5432',
    user => 'username',
    password => 'password'
};
my $qry = q{
select count(*)
 from tablename
 where
   col1 = $1 and
   jsonb_col \? 'key' and
   1 = $2
};

for (my $i=0;$i<50;$i++){
    print STDERR "iteration $i...";

    my $dbh = DBI->connect($connect_info->{dsn},$connect_info->{user},$connect_info->{password});
    my $sqlh = $dbh->prepare($qry) || warn "Can't prepare SQL statement: $DBI::errstr\n";

    $sqlh->bind_param('$1',10000);
    $sqlh->bind_param('$2',1);

    $sqlh->execute() || warn "Cant execute SQL statement: $DBI::errstr\n";

    $sqlh->finish();
    $dbh->disconnect();

    print STDERR "done \n";
}

Example output:

iteration 0...done
iteration 1...Statement has no placeholders to bind at test-dbd-pg.pl line 25.
*** Error in `perl': double free or corruption (fasttop): 0x0000000001cb2480 ***
Aborted

Another run:

iteration 0...done
iteration 1...DBD::Pg::st execute failed: ERROR:  invalid byte sequence for encoding "UTF8": 0xcf 0x03 at test-dbd-pg.pl line 28.
Cant execute SQL statement: ERROR:  invalid byte sequence for encoding "UTF8": 0xcf 0x03
done
... (repeated 48 more times)

If I take out the bind params or only have one of them, it works fine.

If I replace jsonb_col \? 'key' in the where clause with jsonb_typeof(jsonb_col->'key') is not null it works fine.

System info:

  • Postgresql 9.6.1
  • DBD::Pg 3.7.0
  • DBI 1.637

Other than those, I believe stock Debian Jessie. I will respond to any follow up questions promptly.

Version 3.14.0 and later Cannot Compile against Postgres 9.2 or earlier

Looks like 751f5ca may have broken DBD::Pg for 9.2 and lower. Was it the intention to drop support prior to 9.3, or was the intent to support pg_lo_tell64 and friends only on 9.3 but still support 9.2 and earlier overall?

Spotted as I was adding tests for older versions of Postgres to Sqitch, where 9.2 failed with this error among others:

dbdimp.c:43:14: error: conflicting types for โ€˜lo_lseek64โ€™
 unsigned int lo_lseek64(PGconn *conn, int fd, unsigned int offset, int whence);
               ^~~~~~~~~~
 In file included from Pg.h:35,
                 from dbdimp.c:14:
/usr/include/postgresql/libpq-fe.h:620:17: note: previous declaration of โ€˜lo_lseek64โ€™ was here

Add support for $sth->last_insert_id()

DBI API since version 1.642 has support for last_insert_id also for statement handle (not only database handle), see: https://metacpan.org/pod/DBI#last_insert_id1

It would be nice if DBD::Pg supports and implement this method.

Difference between $dbh->last_insert_id and $sth->last_insert_id is that $dbh's one returns last global insert id and $sth's one returns insert id for the last executed query by $sth.

Tests fail when run in a directory with a long name

On many unix-like system, the length of a unix socket pathname is limited to about 100 bytes (see for example https://unix.stackexchange.com/questions/367008/why-is-socket-path-length-limited-to-a-hundred-chars )

If DBD::Pg is installed from a directory that already has a long name, the socket name will be too long and make the tests fail. This is more likely to happen in CI systems (e.g. in our Jenkins, running cpanm inside the workspace, the socket path ends up being something like /home/jenkins/workspace/$JOBNAME/.cpanm/work/$TIMESTAMP/DBD-Pg-$VERSION/dbdpg_test_database/data/socket/.s.PGSQL.$$)

I understand why the tempdir is kept inside the build directory: so it will persist across the various tests, and get cleaned up by whatever is doing the build / install.

Would it be possible to have it (optionally via an env variable?) created somewhere else, like under /tmp/?

Thanks in advance.

Q: autoJSONify

Hi!

Let me stupid question. Do you have planned to autoJSONify from Perl data to PG json/jsonb data types and backwards?

Regards.

Error in tests if localization is enabled and install by root

Hey!

Tests fail if we install the module into the system and localization is enabled.
Installing as normal user works.
Here's what it looks like:

In t/01connect.t
Please wait, creating new database (version 14.2) for testing
1..0 # SKIP Connection to database failed, cannot continue testing
#        
# DBI                         Version 1.643
# DBD::Pg                     Version 3.15.1   
# Perl                        Version 5.32.1
# OS                          linux             
# PostgreSQL (compiled)       ?             
# PostgreSQL (target)         ?             
# PostgreSQL (reported)       ?              
# Default port                ?                    
# DBI_DSN                     ?                 
# DBI_USER                    <not set> 
# Test schema                 dbd_pg_testschema
# LANG                        C            
# Adjusted:                   initdb         
# Error was: Could not startup new database (su -m postgres -c "pg_ctl -o '-k /tmp/dbdpg_testdatabase_u2o820/data/socket' -l /tmp/dbdpg_testdatabase_u2o820/dbdpg_test.logfile -D /tmp/dbdpg_testdatabase_u2o820/dat
a start") () (ะพะถะธะดะฐะฝะธะต ะทะฐะฟัƒัะบะฐ ัะตั€ะฒะตั€ะฐ.... ะณะพั‚ะพะฒะพ
# ัะตั€ะฒะตั€ ะทะฐะฟัƒั‰ะตะฝ
# )

Environment: debian 11, perl 5.32.1. locale ru_RU.UTF-8

In t/

12 use 5.008001; 
...
583             eval {                                                             
584                 $info = qx{$COM};                                              
585             };                                                                 
586             my $err = $@;                                                      
587             $su and chdir $olddir;                                             
588             if ($err or $info !~ /\w/) {                                       
589                 $@ = "Could not startup new database ($COM) ($err) ($info)";

In $info contains the string ะพะถะธะดะฐะฝะธะต ะทะฐะฟัƒัะบะฐ ัะตั€ะฒะตั€ะฐ.... ะณะพั‚ะพะฒะพ ัะตั€ะฒะตั€ ะทะฐะฟัƒั‰ะตะฝ - waiting for the server to start.... done. server started. But the check in 588 fails. Problem in use 5.008001;, if you turn this off, the tests pass.

With best regards

Segfault in 3.9.1

After upgrading from 3.8.1 to 3.9.1, we are seeing this segfault:

Program terminated with signal SIGSEGV, Segmentation fault.
#0  pg_st_FETCH_attrib (sth=sth@entry=0x55e44e814d70, imp_sth=0x55e449f8e420, keysv=keysv@entry=0x55e44ab61db0) at dbdimp.c:1117
1117					if (NULL == currph->value) {
t(gdb) bt
#0  pg_st_FETCH_attrib (sth=sth@entry=0x55e44e814d70, imp_sth=0x55e449f8e420, keysv=keysv@entry=0x55e44ab61db0) at dbdimp.c:1117
#1  0x00007f0969d8b025 in pg_db_FETCH_attrib (dbh=dbh@entry=0x55e44e814d70, imp_dbh=imp_dbh@entry=0x55e455f35a30, keysv=keysv@entry=0x55e44ab61db0)
    at dbdimp.c:783
#2  0x00007f0969d81ae2 in XS_DBD__Pg__db_FETCH (cv=<optimized out>) at ./Pg.xsi:367
#3  0x00007f0969fbd487 in XS_DBI_dispatch (cv=0x55e41a936798) at DBI.xs:3797
#4  0x000055e4129d3718 in Perl_pp_entersub () at pp_hot.c:5232
#5  0x000055e4129c9e63 in Perl_runops_standard () at run.c:41
#6  0x000055e41294a762 in Perl_call_sv (sv=sv@entry=0x55e4141f8930, flags=flags@entry=4098) at perl.c:3004
#7  0x000055e4129b6430 in Perl_magic_methcall (sv=sv@entry=0x55e44f8f7420, mg=mg@entry=0x55e44a16d590, meth=meth@entry=0x55e4141f8930, 
    flags=<optimized out>, argc=<optimized out>) at mg.c:1936
#8  0x000055e4129b6748 in S_magic_methcall1 (sv=sv@entry=0x55e44f8f7420, mg=mg@entry=0x55e44a16d590, meth=0x55e4141f8930, flags=flags@entry=0, n=n@entry=1, 
    val=val@entry=0x0) at mg.c:1970
#9  0x000055e4129b67b4 in S_magic_methpack (sv=sv@entry=0x55e44f8f7420, mg=mg@entry=0x55e44a16d590, meth=<optimized out>) at mg.c:1980
#10 0x000055e4129b67fd in Perl_magic_getpack (sv=0x55e44f8f7420, mg=0x55e44a16d590) at mg.c:1993
#11 0x000055e4129b3f76 in Perl_mg_get (sv=<optimized out>) at mg.c:201
#12 0x00007f0969fbfca8 in XS_DBI_dispatch (cv=0x55e41a9314d0) at DBI.xs:4048
#13 0x000055e4129d3718 in Perl_pp_entersub () at pp_hot.c:5232
#14 0x000055e4129c9e63 in Perl_runops_standard () at run.c:41
#15 0x000055e412951703 in S_run_body (oldscope=<optimized out>) at perl.c:2689
#16 perl_run (my_perl=<optimized out>) at perl.c:2617
#17 0x000055e41292c102 in main (argc=<optimized out>, argv=<optimized out>, env=<optimized out>) at perlmain.c:122

Unfortunately, I do not yet have a simple reproducer.

Add support for passing application_name into connect

When I try to pass application_name as a connection parameter as documented in the libpq-connect docs I get an error:
invalid connection option "application_name"

I know... It's not documented to work in DBD::Pg but it should. Java and Python can set it and Perl should be able to as well!

If I can set $ENV{PGAPPNAME} soon enough in the process that usually works but it's not always feasible to do so.

In the meantime, I'm issuing a SET application_name = 'foo' after connection (via DBIx::Class::Storage::DBI's on_connect_do/connect_info, scroll up to see the real-life examples).

AutoCommit gets enabled on COMMIT failure

This one caught me by surprise. I've no clue if this is intended behavior nor whether this behavior lies with DBD::Pg or with how Postgres itself handles transactions, so I'm just going to throw it out here and see if anyone can provide further insight.

Observed behavior:
AutoCommit is suddenly enabled on the connection if a $dbh->commit() fails.

Expected behavior:
A failed commit is equivalent to a ROLLBACK and leaves AutoCommit alone.

Quick test script:

#!/usr/bin/perl
use DBI;

my $dbh = DBI->connect(undef, undef, undef, { AutoCommit => 0 });

# Need to get a COMMIT to fail, a deferred constraint will do the trick.
$dbh->do('CREATE TABLE dbdpg_test (id int primary key, val integer)');
$dbh->do('ALTER TABLE dbdpg_test ADD CONSTRAINT ref FOREIGN KEY (val) REFERENCES dbdpg_test(id) DEFERRABLE INITIALLY DEFERRED');

# This succeeds, constraint is deferred.
$dbh->do('INSERT INTO dbdpg_test VALUES (1,2)');

# This fails, as expected.
$dbh->commit;

# The above (correctly) prints the following error:
#
#    DBD::Pg::db commit failed: ERROR:  insert or update on table "dbdpg_test" violates foreign key constraint "ref"
#    DETAIL:  Key (val)=(2) is not present in table "dbdpg_test".

# This, on the other hand, is unexpected:
print "AutoCommit is now enabled\n" if $dbh->{AutoCommit};

pg_getcopydata add an extra character at the end

The following code

my $row;
$dbh->do("COPY (SELECT 'abc') TO STDOUT");
$dbh->pg_getcopydata($row);
print("SURPRISE!\n") if $row =~ /\n$/s;

initializes $row with a 4-character string adding an extra 0x0A (new line '\n') on top of the value returned from the server.

I didn't find any mention of this behavior in the document. Maybe there is a way to configure that but it is not obvious from the module description.

DBD::Pg module version is 3.15.0 supplied from the standard Ubuntu 20.04 repository.
Perl version is 5.30 also coming with the standard Ubuntu 20.04 distribution.

New release

Hey! I saw that you recently released version 3.8.0 that contains some fixes for PostgreSQL 11. I tried to install the current version using

$ cpan DBD::Pg

but it only found 3.7.4, which is also what the metacpan website tells me.

Are there any plans to release it to cpan soon? Cheers!

Should the json and jsonb types be treated more like bytea under pg_enable_utf8?

DBD::Pg provides a pg_enable_utf8 option to automatically decode textual values from bytes to character strings when your database encoding is utf8. This is great!

DBD::Pg also goes out of its way to treat values of type bytea specially when pg_enable_utf8 is enabled in order to not attempt to decode arbitrary binary data as if it was utf8 encoded data. This too is really helpful and what I'd expect for bytea values.

As per https://datatracker.ietf.org/doc/html/rfc8259#section-8.1, I'd expect JSON data to be a sequence of bytes in utf8 encoding and would've expected any jsonb data I retrieve using DBD::Pg to be valid JSON which I can pass to the standard decode_json functions from modules like JSON::XS, Cpanel::JSON::XS, Mojo::JSON, etc, independently of whether or not I chose to automatically decode textual data to character strings with pg_enable_utf8. Having to use different JSON encoding/decoding functions depending on the pg_enable_utf8 setting doesn't seem ideal.

I'm wondering if the notion of byte-like types to not be decoded under pg_enable_utf8, which currently only includes bytea, should perhaps be (optionally?) extended to also include jsonb and/or json and would like to hear others' thoughts on that.

I'd be happy to provide a patch to that effect, but I thought it'd be better to reach out first to discuss what such a change would look like, as it has potential implications on backwards compatibility and might need to be something to explicitly opt into by users of the library.

Thanks!

Documentation typo

---$sth = $dbh->prepare(q{SELECT array[1:2] FROM mytable WHERE id = ?}.
+++$sth = $dbh->prepare(q{SELECT array[1:2] FROM mytable WHERE id = ?},
  {pg_placeholder_nocolons => 1});
$sth->execute(1);

Here should be comma

Compilation failed in require at (eval 20) line 3

Hello

I got the following error when I run a perl program :

install_driver(Pg) failed: Attempt to reload DBD/Pg.pm aborted Compilation failed in require at (eval 20) line 3 at /usr/local/share/perl5/Ora2Pg.pm line 2173.

Regards.

J.

Placeholders must begin with ':' when using the ":foo" style

Legacy code using ":foo" style selects fails with this error. The code is as follows:

$dbh->selectall_array('SELECT now where 1 = :id', {}, $id);

Since the call is issued as

	sv_setiv(idx, i);
	if (!dbd_bind_ph(sth, imp_sth, idx, value, 0, Nullsv, FALSE, 0)) {

with idx being the third parameter with the integer, and the third parameter is supposed to be a ":foo" string inside dbd_bind_ph, I can't find a way how this supposed to be working.

SQL-Ledger 3.2.5 posts double-encoded strings

Perl: 5.22.3 and 5.24.1 (current)
DBD-Pg: 3.6.2
PostgreSQL: 9.5.5
DBI: 1.636.0

It is a massive mess getting this app to display and post things correctly encoded. But let's give it a shot.

I am not able to get the input forms to post sane UTF-8 encoded data.

Input: mรครตรผรต
Database (via phppgadmin, psql): mรƒยครƒยตรƒยผรƒยต

Going more aggressive with PERL_UNICODE=AS seems to double-double encode the input string into the database.

Playing around with pg_enable_utf8 values from -1 to 1 affects things in a variety of ways (for example 0 value is best for output), but no configuration combination has been able to fix input values getting stored multi-encoded. Documentation says it's best to forget about this variable, so ideally things would work without it.

DBD-Pg has undergone a ton of changes wrt to utf-8 handling. I have a feeling this not about my app (after hours of debugging and testing a lot of combinations). Can you guys point at some directions how can we find out which layer is buggy here?

#17 may be involved, and my issue seems to behave like https://stackoverflow.com/questions/42753299/dbdpg-double-encodes-utf8-characters-when-inserting-data but just applying use utf8; in some few relevant source files has no effect on the double-encoded input storage problem.

Test t/12placeholders.t fails in 3.8.0 on some architectures

I tried to update perl-DBD-pg in Fedora, but the test 12placeholders.t fails on architectures ppc64le, s390x, aarch64, armv7hl. The failure is related to the commit 'Handle backslash-escaped quotes in E'' strings' (dc83d01)

The problem is that char can equal to unsigned char on some architectures. In this case, the assignment char non_standard_strings = -1; can be undefined and the following condition is not evaluated properly.
I fixed it by replacing 'char' with 'signed char'.

quote.c: 2 * possible bad tests ?

quote.c:377:14: warning: logical 'and' of mutually exclusive tests is always false [-Wlogical-op]
quote.c:379:14: warning: logical 'and' of mutually exclusive tests is always false [-Wlogical-op]

Source code is

    if (
        (ch < 'a' && ch > 'z')
        &&
        (ch < '0' && ch > '9')
        &&
        ch != '_') {

I am not sure that test is ever going to succeed. Suggest code rework.

Hard to trigger crash with async queries and InactiveDestroy

Hi,

I unfortunately can't share the test case since it uses thousands of lines of proprietary code, but it does roughly this:

use DBI;
use DBD::Pg ':async';
use Time::HiRes;

sub mayhem {
    my $dbh = DBI->connect("dbi:Pg:", '', '', {pg_enable_utf8 => 1, PrintError => 0, RaiseError => 1, pg_server_prepare => 0});
    my $sth = $dbh->prepare(q{SELECT CASE WHEN pg_sleep(random() * 0.25) IS NOT NULL THEN random()::text::uuid END}, {pg_async => PG_ASYNC});
    $dbh->{InactiveDestroy} = 1;
    $sth->execute();
    for (my $i = 0; ; ++$i) {
        if ($sth->pg_ready) {
            last;
        }
        if ($i >= 100) {
            print STDERR "wait timeout\n";
            $sth->cancel();
            exit(1);
        }
        Time::HiRes::sleep(0.05);
    }
    eval {
        $sth->pg_result();
    };
}
mayhem();

which sometimes crashes with a backtrace like this:

(gdb) bt
#0  0x00007ffff61c40fb in PQclear () from /usr/lib/x86_64-linux-gnu/libpq.so.5
#1  0x00007ffff64107f8 in pg_db_destroy (dbh=0x1d1bc40, imp_dbh=0x1d22570) at dbdimp.c:688
#2  0x00007ffff6407b54 in XS_DBD__Pg__db_DESTROY (my_perl=0x603010, cv=<optimized out>) at ./Pg.xsi:390
#3  0x00007ffff664a656 in XS_DBI_dispatch (my_perl=<optimized out>, cv=0x8c0268) at DBI.xs:3797
#4  0x00007ffff7b0ad26 in Perl_pp_entersub () from /usr/lib/libperl.so.5.18
#5  0x00007ffff7a94846 in Perl_call_sv () from /usr/lib/libperl.so.5.18
#6  0x00007ffff7b13d71 in ?? () from /usr/lib/libperl.so.5.18
#7  0x00007ffff7b14500 in Perl_sv_clear () from /usr/lib/libperl.so.5.18
#8  0x00007ffff7b14b8d in Perl_sv_free2 () from /usr/lib/libperl.so.5.18
#9  0x00007ffff7aecf48 in ?? () from /usr/lib/libperl.so.5.18
#10 0x00007ffff7aed731 in Perl_mg_free () from /usr/lib/libperl.so.5.18
#11 0x00007ffff7b1479b in Perl_sv_clear () from /usr/lib/libperl.so.5.18
#12 0x00007ffff7b14b8d in Perl_sv_free2 () from /usr/lib/libperl.so.5.18
#13 0x00007ffff7ac2938 in Perl_cv_undef () from /usr/lib/libperl.so.5.18
#14 0x00007ffff7b1473c in Perl_sv_clear () from /usr/lib/libperl.so.5.18
#15 0x00007ffff7b14b8d in Perl_sv_free2 () from /usr/lib/libperl.so.5.18
#16 0x00007ffff7b36698 in Perl_free_tmps () from /usr/lib/libperl.so.5.18
#17 0x00007ffff7b03a35 in Perl_pp_nextstate () from /usr/lib/libperl.so.5.18
#18 0x00007ffff7b03346 in Perl_runops_standard () from /usr/lib/libperl.so.5.18
#19 0x00007ffff7a9bb24 in perl_run () from /usr/lib/libperl.so.5.18
#20 0x0000000000400dd9 in main ()

If I reset InactiveDestroy back to 0 before exiting the subroutine, the problem goes away.

My hypothesis is that the culprit is this code in dbd_st_destroy:

   /* If the InactiveDestroy flag has been set, we go no further */
   if (DBIc_IADESTROY(imp_dbh)) {
       if (TRACE4_slow) {
           TRC(DBILOGFP, "%sskipping sth destroy due to InactiveDestroy\n", THEADER_slow);
       }
       fprintf(stderr, "%x\n", imp_sth);
       DBIc_IMPSET_off(imp_sth); /* let DBI know we've done it */
       if (TEND_slow) TRC(DBILOGFP, "%sEnd dbd_st_destroy (InactiveDestroy set)\n", THEADER_slow);
       return;
   }

which DBIc_IMPSET_off()s the imp_sth still assigned to imp_dbh->async_sth. Later on, when dbd_db_destroy is called, its imp_dbh->async_sth points to freed memory containing garbage and the PQclear() call crashes. My digging around with gdb supports this hypothesis: imp_dbh->async_sth still has a pointer to the same location that previously held a valid sth, but *imp_dbh->async_sth is just garbage.

I've verified this against the master branches of both DBI and DBD::Pg, but this problem seems to have existed for a long time.

Custom type arrays are not expanded

If a user defines a new type, say
CREATE DOMAIN positive_int AS int CHECK (value >= 0);
and then selects an array of such type, like
SELECT ARRAY[1,2,3]::positive_int[];
this array will not be expanded, while arrays of int are expanded as pg_expand_array is true.
The user expects that array of any type should be expanded to a Perl array.
Definitely, this is a consequence of hardcoding the datatypes data in types.c
My proposal is to extend the pg_type_data() implementation in order to search for the unknown data types in the database.

What is your opinion on this?

Time::Piece handling

This script runs fine with DBD::Pg 3.5.3, whether you uncomment the use Time::Piece line or not.

#!/usr/bin/env perl

use strict;
use Carp;
use DBI;
use DBD::Pg;
#use Time::Piece;

my $dbh = DBI->connect('dbi:Pg:dbname=try', undef, undef)
  or die 'db connection failed';

$dbh->do(q{
  DROP TABLE IF EXISTS mytable
});

$dbh->do(q{
  CREATE TABLE mytable (
    creation_date date
  )
});

my $now = localtime;
$dbh->do(q{
  INSERT INTO mytable (creation_date) VALUES (?)
}, undef, $now);

With 3.6.0, it fails if Time::Piece is loaded:

$ ./try
DBD::Pg::db do failed: ERROR:  invalid input syntax for type date: "{"48","8","21","7","10","119","4","310","0","1573189728","1"}" at ./try line 23.
$ perl -v

This is perl 5, version 18, subversion 2 (v5.18.2) built for i686-linux

I'm guessing this is perhaps related to this change?

 - Make sure we do not inadvertently modify the string passed to prepare() when
 
    doing the new backslash escape manipulation.
    [Greg Sabino Mullane]
    (CPAN ticket #114000)

I'm not sure what the preferred behavior is? We can require manual stringification of the Time::Piece object, of course. Just was rather nice that the old behavior stringified it automatically and required no change to the code.

ShowErrorStatement doesn't work on do("") requests

Please compare the outputs of the two requests that should be identical, both with

$dbh->{ShowErrorStatement} = 1;

pre-executed, both sending a text to an integer argument:

my $sth = $dbh->prepare('select relname from pg_class where relpages = ?'); $sth->execute('foo');

DBD::Pg::st execute failed: ERROR: invalid input syntax for integer: "foo" [for Statement "select relname from pg_class where relpages = ?" with ParamValues: 1='foo']

and

$dbh->do('select relname from pg_class where id relpages ?', {}, 'bar');

DBD::Pg::db do failed: ERROR: syntax error at or near "relpages" LINE 1: select relname from pg_class where id relpages $1 ^ [for Statement "select relname from pg_class where id relpages ?"]

The latter is missing the ParamValues explained.

Missing "use File::Temp" in t/dbdpg_test_setup.pl cause tests to fail

When running tests, I get the following output:

t/02attribs.t .......... Please wait, creating new database (version 12.8) for testing
Undefined subroutine &File::Temp::tempdir called at t/dbdpg_test_setup.pl line 376.
t/02attribs.t .......... Dubious, test returned 1 (wstat 256, 0x100)

which eventually leads the tests to fail.
I have added use File::Temp at the top of your script t/dbdpg_test_setup.pl, performed the tests again, and it worked normally.

Cannot connect to recent versions of pgbouncer

The check for versions is now too strict.

$ perl -MDBI -E '$dbh=DBI->connect("dbi:Pg:dbname=pgbouncer;host=/tmp;port=6432","pgbouncer","") or die "Cannot connect to pgbouncer: $!"'
DBI connect('dbname=pgbouncer;host=/tmp;port=6432','pgbouncer',...) failed: Server version 8.0 required at -e line 1.
Cannot connect to pgbouncer:  at -e line 1.

Tests fail in 3.6.1 because of explicit "die" in t/03dbmethod.t

Died at t/03dbmethod.t line 25.
t/03dbmethod.t ...... 
Dubious, test returned 255 (wstat 65280, 0xff00)

The code looks like this:

    24	my $dbh = connect_database();
    25	die;
    26	if (! $dbh) {
    27		plan skip_all => 'Connection to database failed, cannot continue testing';
    28	}

Test fails on my system for DBD-Pg-3.15.1-1

Failed test:
t/03dbmethod.t ......... 1/646 
#   Failed test 'DB handle method "get_info" returns expected result for SQL_DEFAULT_TXN_ISOLATION'
#   at t/03dbmethod.t line 624.
#          got: '8'
#     expected: '2'

Is that the transaction isolation level?

My /etc/postgresql/14/main/postgresql.conf on my systems have this:
default_transaction_isolation = 'serializable'

Tests require output that is not present in "modern" initdb

"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Pg.bs blib/arch/auto/DBD/Pg/Pg.bs 644
PGINITDB="/usr/bin/initdb" PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00_signature.t .... skipped: Set the environment variable TEST_SIGNATURE to enable this test
t/00basic.t ......... ok   
t/01connect.t ....... Please wait, creating new database (version 10.9) for testing
# 
# DBI                         Version 1.642
# DBD::Pg                     Version 3.8.1
# Perl                        Version 5.26.3
# OS                          linux
# PostgreSQL (compiled)       ?
# PostgreSQL (target)         ?
# PostgreSQL (reported)       ?
# Default port                ?
# DBI_DSN                     ?
# DBI_USER                    <not set>
# Test schema                 dbd_pg_testschema
# LANG                        C
# Adjusted:                   initdb
# Error was: initdb did not give a pg_ctl string: The files belonging to this database system will be owned by user "awilcox".
# This user must also own the server process.
# 
# The database cluster will be initialized with locale "C".
# The default text search configuration will be set to "english".
# 
# Data page checksums are disabled.
# 
# creating directory /usr/src/packages/user/perl-dbd-pg/src/DBD-Pg-3.8.1/dbdpg_test_database/data ... ok
# creating subdirectories ... ok
# selecting default max_connections ... 100
# selecting default shared_buffers ... 128MB
# selecting default timezone ... UTC
# selecting dynamic shared memory implementation ... posix
# creating configuration files ... ok
# running bootstrap script ... ok
# performing post-bootstrap initialization ... ok
# syncing data to disk ... ok
# 
# WARNING: enabling "trust" authentication for local connections
# You can change this by editing pg_hba.conf or using the option -A, or
# --auth-local and --auth-host, the next time you run initdb.
# 
# Success.
# 
# 
t/01connect.t ....... skipped: initdb did not give a pg_ctl string: The files belonging to this database system will be owned by user "awilcox".
t/01constants.t ..... ok     
t/02attribs.t ....... skipped: Connection to database failed, cannot continue testing
t/03dbmethod.t ...... skipped: Connection to database failed, cannot continue testing
t/03smethod.t ....... skipped: Connection to database failed, cannot continue testing
t/04misc.t .......... skipped: Connection to database failed, cannot continue testing
t/06bytea.t ......... skipped: Connection to database failed, cannot continue testing
t/07copy.t .......... skipped: Connection to database failed, cannot continue testing
t/08async.t ......... skipped: Connection to database failed, cannot continue testing
t/09arrays.t ........ skipped: Connection to database failed, cannot continue testing
t/12placeholders.t .. skipped: Connection to database failed, cannot continue testing
t/20savepoints.t .... skipped: Connection to database failed, cannot continue testing
t/30unicode.t ....... skipped: Connection to database failed, cannot continue testing
t/99cleanup.t ....... ok   
All tests successful.
Files=16, Tests=168,  5 wallclock secs ( 0.26 usr  0.06 sys +  8.14 cusr  1.02 csys =  9.48 CPU)
Result: PASS

If I comment out the elsif:

                #elsif ($info !~ /pg_ctl/) {
                #       $@ = "initdb did not give a pg_ctl string: $info";
                #       last GETHANDLE; ## Fail - bad output
                #}

then the tests work and pass:

"/usr/bin/perl" -MExtUtils::Command::MM -e 'cp_nonempty' -- Pg.bs blib/arch/auto/DBD/Pg/Pg.bs 644
PGINITDB="/usr/bin/initdb" PERL_DL_NONLAZY=1 "/usr/bin/perl" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switches; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/00_signature.t .... skipped: Set the environment variable TEST_SIGNATURE to enable this test
t/00basic.t ......... ok   
t/01connect.t ....... Please wait, creating new database (version 10.9) for testing
t/01connect.t ....... 12/15 # 
# DBI                         Version 1.642
# DBD::Pg                     Version 3.8.1
# Perl                        Version 5.26.3
# OS                          linux
# PostgreSQL (compiled)       100009
# PostgreSQL (target)         100009
# PostgreSQL (reported)       PostgreSQL 10.9 on powerpc64-foxkit-linux-musl, compiled by gcc (Adelie 8.3.0) 8.3.0, 64-bit
# Default port                5432
# DBI_DSN                     dbi:Pg:db="postgres";port=5440;host=<pwd>/dbdpg_test_database/data/socket
# DBI_USER                    awilcox
# Test schema                 dbd_pg_testschema
# LANG                        C
# array_nulls                 on
# backslash_quote             safe_encoding
# client_encoding             UTF8
# server_encoding             UTF8
# standard_conforming_strings on
# Adjusted:                   initdb
t/01connect.t ....... ok     
t/01constants.t ..... ok     
t/02attribs.t ....... ok       
t/03dbmethod.t ...... ok       
t/03smethod.t ....... ok       
t/04misc.t .......... ok     
t/06bytea.t ......... ok     
t/07copy.t .......... ok     
t/08async.t ......... ok     
t/09arrays.t ........ ok       
t/12placeholders.t .. ok       
t/20savepoints.t .... ok   
t/30unicode.t ....... ok     
t/99cleanup.t ....... ok   
All tests successful.
Files=16, Tests=2445, 28 wallclock secs ( 0.75 usr  0.05 sys + 39.66 cusr  0.89 csys = 41.35 CPU)
Result: PASS

Compile error 'initdb' not recognized for ver 3.15.1

Hi There,

I'm running Strawberry Perl on a Windows 10, 64 bit environment and am getting this error: Bad initdb output: 'initdb' is not recognized as an internal or external command,

This compile error occurs on multiple CPUs with slightly different versions of Strawberry Perl, 5.30.0 and 5.32.1 (latest version).

I did install the most up-to-date dependencies DBI and version, so that wasn't the issue.

I am running the command prompt as an administrator. I even tried using the force option, but the compile failed with the same error.

Many thanks!

C:\Strawberry\perl\bin\perl.exe" -MExtUtils::Command -e chmod -- 755 blib\arch\auto\DBD\Pg\Pg.xs.dll
TURNSTEP/DBD-Pg-3.15.1.tar.gz
C:\STRAWB~1\c\bin\gmake.exe -- OK
Running make test for TURNSTEP/DBD-Pg-3.15.1.tar.gz
"C:\Strawberry\perl\bin\perl.exe" -MExtUtils::Command::MM -e cp_nonempty -- Pg.bs blib\arch\auto\DBD\Pg\Pg.bs 644
"C:\Strawberry\perl\bin\perl.exe" "-MExtUtils::Command::MM" "-MTest::Harness" "-e" "undef Test::Harness::Switches; test_harness(0, 'blib\lib', 'blib\arch')" t/.t
t/00_signature.t ....... skipped: Set the environment variable TEST_SIGNATURE to enable this test
t/00basic.t ............ ok
t/01connect.t .......... #

DBI Version 1.643

DBD::Pg Version 3.15.1

Perl Version 5.30.0

OS MSWin32

PostgreSQL (compiled) ?

PostgreSQL (target) ?

PostgreSQL (reported) ?

Default port ?

DBI_DSN ?

DBI_USER

Test schema dbd_pg_testschema

LANG C

Adjusted: initdb

Error was: Bad initdb output: 'initdb' is not recognized as an internal or external command, <-----------

operable program or batch file.

Bailout called. Further testing stopped: Cannot continue: connection failed
FAILED--Further testing stopped: Cannot continue: connection failed
gmake: *** [Makefile:986: test_dynamic] Error 255
TURNSTEP/DBD-Pg-3.15.1.tar.gz
C:\STRAWB~1\c\bin\gmake.exe test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
reports TURNSTEP/DBD-Pg-3.15.1.tar.gz
Stopping: 'install' fail

Crash in the absence of client_encoding

DBD::Pg crashes the Perl process in pg_db_detect_client_encoding_utf8() if the server doesn't send client_encoding as a startup parameter. This is fine if you're connecting to a vanilla postgres, but less so if you're connecting to one which only speaks the wire protocol but doesn't care as much about encodings and such. I'm not sure whether this should be considered a bug or not, but I thought I'd open a ticket anyway. Segmentation faults certainly don't look nice.

Perl length() returns the wrong value on array elements returned by fetchrow_arrayref()

Hi,

In the below code:

#!/opt/bin/perl

use DBI;

my $db = DBI->connect('dbi:Pg:dbname=main','schemaname','password');
my $st = $db->prepare('SELECT label FROM time_code');
$st->execute;
while (my $rec = $st->fetchrow_arrayref) {
	print 'len: ' . length($rec->[0]) . ' val: ' . $rec->[0] . "\n";
}
$db->disconnect;

...the length() call returns the correct value (11) for the first row fetched, and then for all subsequent rows, it returns "11" regardless of the actual length of the string in $rec->[0]. Here's the output:

len: 11 val: Office Work
len: 11 val: Warehouse Work
len: 11 val: Holiday
len: 11 val: PTO/Vacation
len: 11 val: Sick Time

Is this a DBD::Pg issue or a DBI issue? I am running DBI 1.643 (latest) and DBD::Pg 3.12 (latest) on Perl 5.26.1 with Postgres 10.13.

Thanks in advance!

[RFE] Add MAX_INT constants

It would be nice to have a :max set of constants to import, so that code could use these to validate numeric types before passing them into queries, e.g.

use constant MIN_SMALLINT => -32768;
use constant MAX_SMALLINT => 32767;
use constant MIN_INT  => -2147483648;
use constant MAX_INT => 2147483647;
...

I'm unsure how to handle bigints for this, though.

See https://www.postgresql.org/docs/11/datatype-numeric.html

Array reference error after updating PostgreSQL from version 10 to 12

Recently we have upgraded PostgreSQL from 10.14 to 12.7 after that we have started getting error from PG.pm .

Can't use an undefined value as an ARRAY reference at /usr/lib64/perl5/vendor_perl/DBD/Pg.pm line 533.

Below is the sample code which I am trying to run

my $dbh = DBI->connect($dsn, $userid, $password, { RaiseError => 1 })
or die $DBI::errstr;
print "Opened database successfully\n";

my $RetColList;
my $sth = $dbh->column_info(undef, undef, "table_name", undef);
my $colref = $sth->fetchall_arrayref([3]);
my @Collist = @$colref;
foreach my $Col ( @Collist ) {
$RetColList= $RetColList . $Col->[0].",";
print "Debug : Inside GetListColumns RetColList=$RetColList\n";
}
$RetColList =~ s/rowid,//;

chop $RetColList;
print $RetColList;

Can you suggest what we can do to fix this issue . I also checked the latest version from Amazon Linux 2 repo "amzn2-core" is installed on my host
perl-DBD-Pg-2.19.3-4.amzn2.0.2.x86_64

Result of a commit should be checked before re-enabling AutoCommit and disabling BegunWork

Currently, if a commit fails, you can end up in a situation where you are inside of a transaction even though DBD::Pg believes otherwise. This is because DBicf_AutoCommit is set to 1 and DBIcf_BegunWork is set to 0 before the commit is even executed:

dbdpg/dbdimp.c

Lines 593 to 603 in 3f277a5

if (DBIc_has(imp_dbh, DBIcf_BegunWork)!=0) {
DBIc_set(imp_dbh, DBIcf_AutoCommit, 1);
DBIc_set(imp_dbh, DBIcf_BegunWork, 0);
}
if (!imp_dbh->done_begin) {
if (TEND_slow) TRC(DBILOGFP, "%sEnd pg_db_rollback_commit (result: 1)\n", THEADER_slow);
return 1;
}
status = _result(aTHX_ imp_dbh, action ? "commit" : "rollback");

This has happened to us several times in production when doing something like:

$dbh->begin_work;
$dbh->do( 'SET LOCAL statement_timeout TO ?', {}, $timeout );
...
$dbh->commit;

If the timeout happens during the commit, you may end up in this invalid state.

cpan based install failing on signature issue

cpan[1]> install DBD::Pg
Reading '/usr/cpan/Metadata'
Database was generated on Sat, 20 Nov 2021 19:17:03 GMT
Running install for module 'DBD::Pg'
Fetching with LWP:
http://www.cpan.org/authors/id/T/TU/TURNSTEP/DBD-Pg-3.15.0.tar.gz
WARNING: This key is not certified with a trusted signature!
Primary key fingerprint: 2E66 557A B97C 19C7 91AF 8E20 328D A867 450F 89EC
Signature for /usr/cpan/sources/authors/id/T/TU/TURNSTEP/CHECKSUMS ok
Checksum for /usr/cpan/sources/authors/id/T/TU/TURNSTEP/DBD-Pg-3.15.0.tar.gz ok
Scanning cache /usr/cpan/build for sizes
............................................................................DONE
gpg: Signature made Thu 13 Aug 2020 06:33:09 AM PDT
gpg: using DSA key 2529DF6AB8F79407E94445B4BC9B906714964AC8
gpg: Can't check signature: No public key
--- SIGNATURE Sun Jan 10 09:00:07 2021
+++ (current) Sat Nov 20 13:35:17 2021
@@ -1,44 +1,44 @@
SHA256 e4c6f4cdc9560a09492f196fc9a180867fab12742d7d05052d9842b395c6a9eb .dir-locals.el
-SHA256 599f3c02300e2558e32c2b1ea52802b6585b5e0227036c0675404e598fc163e0 .perlcriticrc
-SHA256 e8d3a038d88fb019bb96983f0c52125f86a4c3465466a20612bf4958ace70ed5 CONTRIBUTING.md
-SHA256 fb932bfd5dc64c16b1768ea293708c11c22c85b85bcb8dc85e33ad649e281f16 Changes
+SHA256 e23f1fcd188734118fec21c5c5525307568b67a0ba97308956f0dc7d0ad969a9 .perlcriticrc
+SHA256 56479e9cf7c00a72bc5458593463a5a6e5481f74f3a4be5ef94129e01c3e2f91 CONTRIBUTING.md
+SHA256 afbf4bb6502c8c1ed789fec3d74bce0253f2b3392fe3034dc663bcf42a61bf87 Changes
SHA256 d52a34724b2e3c40ffa2b3b378b574b9e3db27bc3132c88e0be3675f93f378a5 LICENSES/artistic.txt
SHA256 ab15fd526bd8dd18a9e77ebc139656bf4d33e97fc7238cd11bf60e2b9b8666c6 LICENSES/gpl-2.0.txt
SHA256 e15fb8180cca35de2c3de6854e5cf23152a7733dfa89640825ae13f6f83b0e72 MANIFEST
SHA256 f41d8891a80fa4f3fbf1c96fc745a2c8ecc0497045a9ad55daea54d5ffcb4683 MANIFEST.SKIP
-SHA256 a16a5a33fe23f3d01757d9f451ac21febc7adf966ae6e7b8fc08d744c938e272 META.yml
-SHA256 c2b3276297eb3eef4ebb3b1dbf7d67cc66d373ef32a87a28124f74cfe1c7cb5d Makefile.PL
-SHA256 d7d68c574b9469375f92aaf0bfd0e539f635a45da869f91390fdc401b1ccaefb Pg.h
-SHA256 73115a4af943b78495686c6eb6df2a8e830319ba2413277cd78920c99f549143 Pg.pm
-SHA256 ec04611ed1b769de30887bbea5d916ea1535e26beef296dcb0506a484cfd96c4 Pg.xs
-SHA256 3d883a2ac45eabb5520590098a07cb405e1109c41efe0444f205c0192d1b4a24 README
-SHA256 230949b9f9e12a116f1b776946ecad0f249cf2577ed1ac1918662fca06b9428c README.dev
+SHA256 4c329649a9622cee52f6bf51bde833c0d965a034287b39c43f9ac4eca4d22615 META.yml
+SHA256 e98c97637bd57f099d35953dcf5d467afdc357a386e2ab8926bddd2f42b8c3e8 Makefile.PL
+SHA256 829befc6322c3e371eb026d23d589ed1f5334d765b90026af53c6b1c20f9ec0a Pg.h
+SHA256 411d893d7fbb9041d19d5d1fd664da5d856f86319032b316349c36d89464918c Pg.pm
+SHA256 03687d0817f1cd7d24ddc51d13aad83338b95e36f1b8496533c326dbb4c96c96 Pg.xs
+SHA256 75b266bc2d00e5a4cf43659a468db3a1347f0003ff01d6630aa870483e5a668b README
+SHA256 abb4dc534d316fd2adedd246734110178aad80af2d3a65119d5a816f1cb37933 README.dev
SHA256 a1d224603fe3a343ba0a0f40086065c81d57fbebc734b5382b0d359da16bdd94 README.win32
-SHA256 ce798149ee5bf517fb76d6a652c3e4619bfda6ed706df068f2d0fd1f05ed259c TODO
-SHA256 7756584f0e0d909ae0ce1b156d638f3129fe756d144a9b5d7812a31c8e9188b2 dbdimp.c
-SHA256 72c7b368ca468cd1df7f5593770ac72b7680aeb6c4924f9c5b5f17b774619ead dbdimp.h
+SHA256 a4476689aa6467b0f08097e1f72d549eac1ad790d2c56ef649341c0da08558e9 TODO
+SHA256 b994e59afeaf30e5f8285a8194b3c39a72b68f7007b572a9245c4d1bffeadce4 dbdimp.c
+SHA256 e8652b039cc5ad6b2d61c5a9236e8a8f720c48c0eaad92e6d8ba8196578f01c8 dbdimp.h
SHA256 9e53f7f41aaaf1b540e2784756ef6f16f61b63df0d9956483aded3c49b6e0f48 dbivport.h
-SHA256 f639833c96bb032135480bfac7802c6adf6ab0d5964a9222fb7347ac3630a807 lib/Bundle/DBD/Pg.pm
-SHA256 c945a57d774dc5bb789f2af67892c749f8c4d42b75967c9aab4bc436ed635a90 quote.c
+SHA256 d33043fa8f0e0b9cfaea78058062a14a39e5e0a22dbd8f0a6c7e2fa98b1b8efa lib/Bundle/DBD/Pg.pm
+SHA256 50df4dba2b04d9dbe27fe64e48e2732a58de8a01013143aa18b4f9d87d26da21 quote.c
SHA256 1ee43f02036bbb68c151903c2718c483ed223aff6cc93fb1408a9158adad9136 quote.h
SHA256 49950c2c882018916ef89b59a1707b732064eb3bb6acb6a350111e1dc81000b8 t/00_signature.t
SHA256 4a95e025f903ed2d6a0aa4470f46f075d4692b9a21bd1d316ead19fb9cabd2dd t/00basic.t
-SHA256 19e8f71d48ab56d22ec1ba1551a4e5db68c113001e8ac66a6d6250c0e1799a8e t/01connect.t
-SHA256 4e506c9d0ebcd1231cdcbde147b66eba825c85bb5e708f0575ee5df57379944f t/01constants.t
-SHA256 e0075d89da43127ea1b0011dadbf5174660c52df6ffc18a40afe02d641a2d2b6 t/02attribs.t
-SHA256 2495fb2858d0f805f1e7ca93dda0760b2b8c36c4e637c43828edc1c06433664e t/03dbmethod.t
-SHA256 d3d111252be1dd32001e7d5aa0b89f5b623aa5cf0a541b94de9742b5ef48fb5f t/03smethod.t
-SHA256 c5bffc4e2284ee49d0be6a9fd4290e1139a14449ee7c651bf4252e722dfe0de8 t/04misc.t
+SHA256 0bea371cef24f361913e7865d043a314cdeaffff104f3792b00770e93b2eadcc t/01connect.t
+SHA256 50ce2e03b34dfc5e45c0af8f4078825b1ed449d201f165d8d05453762110ae72 t/01constants.t
+SHA256 4a57102776fa991abbdf52427f14b2200b0de9415495f625bbb4a89b3f9c99c0 t/02attribs.t
+SHA256 2c8ae070dcc5bd2b716be9094011de898ae79cc6df72fbea19672bce16f9afd9 t/03dbmethod.t
+SHA256 f6769b211e07e4bdeaf6e8b70c91dc2568758a92011f34d1315f9ee73478a82e t/03smethod.t
+SHA256 a3767a1b6e9adf62ec73f9d38b8bca151eb2fd872d42c2f77aeaef72178b1c56 t/04misc.t
SHA256 d30d52695492fbcb2d051c48d0d3afb621b0d5b29d876208b5fd79c5bc50b3fa t/06bytea.t
SHA256 f172234f057e485a8d5838db6986dbda18f4fe81fcf9ad0885728b8aec31b852 t/07copy.t
SHA256 2e50d0d3cea8c90882a06b99537d7aebcb8d8f062a775831d4b07056e832c4c1 t/08async.t
SHA256 13939607c75558e63395d0d77e78ed2485cd97b2e3d6559e72ec45bffdf333e4 t/09arrays.t
SHA256 97254af96ad61b3306b55ea687db6e5439e18a692f763aabc74bebe85e0c04c9 t/10_pg_error_field.t
-SHA256 a30dfbe57581c3e82e2ebf32f90a96493c5868c8aceaf2f8ef90c4c82173f299 t/12placeholders.t
+SHA256 9a4b3ba6e7931c21fdeab0225777de3512f68e58fc98305da5073694c5f84afe t/12placeholders.t
SHA256 982a438ec73b0428c263ed4608d82fd466a1668cfd4095c69d93ae002486368c t/20savepoints.t
SHA256 6bdf1b5d0bdc049bf8ff8a66d36fc41dfaea2d15e8550dc7e19ce152aa73c918 t/30unicode.t
SHA256 16b874ee36dcedc566b6c9b4c8142173e3a6babc660721939756d8a0a7d697f2 t/99cleanup.t
-SHA256 543c7990a7abd6b80889393209924c8c0d7d45509b73846d053801980394fc70 t/dbdpg_test_setup.pl
+SHA256 9cf22ac29150f372db11805cbe97a31d2d4cb5a1e62d93cd611ecde99f01f594 t/dbdpg_test_setup.pl
SHA256 50be982cc158a60f531674a593a55a05cac2f358b865e0cbcc6fc86285f719c0 t/lib/App/Info.pm
SHA256 e930aed2b35b6dd2504c8652f8037ce8e98454e0105babeca46ee133996fa084 t/lib/App/Info/Handler.pm
SHA256 bda949f555f730887b54d12627fdf17f290b245cf03ca14b7c4fc5b996c33884 t/lib/App/Info/Handler/Print.pm
@@ -47,7 +47,7 @@
SHA256 7ea6b4ee4b5cd6b0b44939544138503ede324c8a85a06a8b51334d62c1298669 t/lib/App/Info/RDBMS/PostgreSQL.pm
SHA256 36b5ac866344827a286687f036ed2702d2ccdee450ad1581a64995523b6df976 t/lib/App/Info/Request.pm
SHA256 6725541fdeb205716695fca6ff90f77d4e37e33f7d2cefab0b8f946876f646f9 t/lib/App/Info/Util.pm
-SHA256 e37a46dd0a9b569e89de9549f3a00d90327b348f3fc67d28fb8a0508cbb2a498 testme.tmp.pl
-SHA256 f9567669852e55092c612e4f63a2e0540472947555fc8a57f429fa8383970c49 types.c
-SHA256 064c0dc289767d594b1272525c28219fc7304fe2aa815b9b29a043c90ec51c12 types.h
+SHA256 eedc5a43373937237f35a298f6945d87dc0144c91eaae3eea4a19e79d0ae462c testme.tmp.pl
+SHA256 6b5ec7d1edf69f91407a7d5efd75e4dcde8a583434301fa48fe1ff50ffb1129d types.c
+SHA256 789d430468f518ec7d46114bae5fcb11f08f29bd573999b02712ac8b6e75a72a types.h
SHA256 4628f92764bdb3e2b04bda7f30fc497231fbbf80dfd24cc09ee3df2e6d6d4387 win32.mak
==> MISMATCHED content between SIGNATURE and distribution files! <==

Signature invalid for distribution file. Please investigate.

I'd recommend removing
/usr/cpan/sources/authors/id/T/TU/TURNSTEP/DBD-Pg-3.15.0.tar.gz. Some error
occurred while checking its signature, so it could be invalid.
Maybe you have configured your 'urllist' with a bad URL. Please
check this array with 'o conf urllist' and retry. Or examine the
distribution in a subshell. Try
look TURNSTEP/DBD-Pg-3.15.0.tar.gz
and run
cpansign -v
TURNSTEP/DBD-Pg-3.15.0.tar.gz
Did not pass the signature test.
Failed during this command:
TURNSTEP/DBD-Pg-3.15.0.tar.gz : signature_verify NO

cpan[2]> o conf urllist
urllist
0 [http://www.cpan.org/]
Type 'o conf' to view all configuration items

/usr/cpan/build/DBD-Pg-3.15.0-1# cpansign -v
Executing gpg --verify --batch --no-tty --keyserver=hkp://pool.sks-keyservers.net:11371 /tmp/Fmha4Yg0la
gpg: Signature made Thu 13 Aug 2020 06:33:09 AM PDT
gpg: using DSA key 2529DF6AB8F79407E94445B4BC9B906714964AC8
gpg: Can't check signature: No public key
--- SIGNATURE Sun Jan 10 09:00:07 2021
+++ (current) Sat Nov 20 13:39:01 2021
@@ -1,44 +1,44 @@
SHA256 e4c6f4cdc9560a09492f196fc9a180867fab12742d7d05052d9842b395c6a9eb .dir-locals.el
-SHA256 599f3c02300e2558e32c2b1ea52802b6585b5e0227036c0675404e598fc163e0 .perlcriticrc
-SHA256 e8d3a038d88fb019bb96983f0c52125f86a4c3465466a20612bf4958ace70ed5 CONTRIBUTING.md
-SHA256 fb932bfd5dc64c16b1768ea293708c11c22c85b85bcb8dc85e33ad649e281f16 Changes
+SHA256 e23f1fcd188734118fec21c5c5525307568b67a0ba97308956f0dc7d0ad969a9 .perlcriticrc
+SHA256 56479e9cf7c00a72bc5458593463a5a6e5481f74f3a4be5ef94129e01c3e2f91 CONTRIBUTING.md
+SHA256 afbf4bb6502c8c1ed789fec3d74bce0253f2b3392fe3034dc663bcf42a61bf87 Changes
SHA256 d52a34724b2e3c40ffa2b3b378b574b9e3db27bc3132c88e0be3675f93f378a5 LICENSES/artistic.txt
SHA256 ab15fd526bd8dd18a9e77ebc139656bf4d33e97fc7238cd11bf60e2b9b8666c6 LICENSES/gpl-2.0.txt
SHA256 e15fb8180cca35de2c3de6854e5cf23152a7733dfa89640825ae13f6f83b0e72 MANIFEST
SHA256 f41d8891a80fa4f3fbf1c96fc745a2c8ecc0497045a9ad55daea54d5ffcb4683 MANIFEST.SKIP
-SHA256 a16a5a33fe23f3d01757d9f451ac21febc7adf966ae6e7b8fc08d744c938e272 META.yml
-SHA256 c2b3276297eb3eef4ebb3b1dbf7d67cc66d373ef32a87a28124f74cfe1c7cb5d Makefile.PL
-SHA256 d7d68c574b9469375f92aaf0bfd0e539f635a45da869f91390fdc401b1ccaefb Pg.h
-SHA256 73115a4af943b78495686c6eb6df2a8e830319ba2413277cd78920c99f549143 Pg.pm
-SHA256 ec04611ed1b769de30887bbea5d916ea1535e26beef296dcb0506a484cfd96c4 Pg.xs
-SHA256 3d883a2ac45eabb5520590098a07cb405e1109c41efe0444f205c0192d1b4a24 README
-SHA256 230949b9f9e12a116f1b776946ecad0f249cf2577ed1ac1918662fca06b9428c README.dev
+SHA256 4c329649a9622cee52f6bf51bde833c0d965a034287b39c43f9ac4eca4d22615 META.yml
+SHA256 e98c97637bd57f099d35953dcf5d467afdc357a386e2ab8926bddd2f42b8c3e8 Makefile.PL
+SHA256 829befc6322c3e371eb026d23d589ed1f5334d765b90026af53c6b1c20f9ec0a Pg.h
+SHA256 411d893d7fbb9041d19d5d1fd664da5d856f86319032b316349c36d89464918c Pg.pm
+SHA256 03687d0817f1cd7d24ddc51d13aad83338b95e36f1b8496533c326dbb4c96c96 Pg.xs
+SHA256 75b266bc2d00e5a4cf43659a468db3a1347f0003ff01d6630aa870483e5a668b README
+SHA256 abb4dc534d316fd2adedd246734110178aad80af2d3a65119d5a816f1cb37933 README.dev
SHA256 a1d224603fe3a343ba0a0f40086065c81d57fbebc734b5382b0d359da16bdd94 README.win32
-SHA256 ce798149ee5bf517fb76d6a652c3e4619bfda6ed706df068f2d0fd1f05ed259c TODO
-SHA256 7756584f0e0d909ae0ce1b156d638f3129fe756d144a9b5d7812a31c8e9188b2 dbdimp.c
-SHA256 72c7b368ca468cd1df7f5593770ac72b7680aeb6c4924f9c5b5f17b774619ead dbdimp.h
+SHA256 a4476689aa6467b0f08097e1f72d549eac1ad790d2c56ef649341c0da08558e9 TODO
+SHA256 b994e59afeaf30e5f8285a8194b3c39a72b68f7007b572a9245c4d1bffeadce4 dbdimp.c
+SHA256 e8652b039cc5ad6b2d61c5a9236e8a8f720c48c0eaad92e6d8ba8196578f01c8 dbdimp.h
SHA256 9e53f7f41aaaf1b540e2784756ef6f16f61b63df0d9956483aded3c49b6e0f48 dbivport.h
-SHA256 f639833c96bb032135480bfac7802c6adf6ab0d5964a9222fb7347ac3630a807 lib/Bundle/DBD/Pg.pm
-SHA256 c945a57d774dc5bb789f2af67892c749f8c4d42b75967c9aab4bc436ed635a90 quote.c
+SHA256 d33043fa8f0e0b9cfaea78058062a14a39e5e0a22dbd8f0a6c7e2fa98b1b8efa lib/Bundle/DBD/Pg.pm
+SHA256 50df4dba2b04d9dbe27fe64e48e2732a58de8a01013143aa18b4f9d87d26da21 quote.c
SHA256 1ee43f02036bbb68c151903c2718c483ed223aff6cc93fb1408a9158adad9136 quote.h
SHA256 49950c2c882018916ef89b59a1707b732064eb3bb6acb6a350111e1dc81000b8 t/00_signature.t
SHA256 4a95e025f903ed2d6a0aa4470f46f075d4692b9a21bd1d316ead19fb9cabd2dd t/00basic.t
-SHA256 19e8f71d48ab56d22ec1ba1551a4e5db68c113001e8ac66a6d6250c0e1799a8e t/01connect.t
-SHA256 4e506c9d0ebcd1231cdcbde147b66eba825c85bb5e708f0575ee5df57379944f t/01constants.t
-SHA256 e0075d89da43127ea1b0011dadbf5174660c52df6ffc18a40afe02d641a2d2b6 t/02attribs.t
-SHA256 2495fb2858d0f805f1e7ca93dda0760b2b8c36c4e637c43828edc1c06433664e t/03dbmethod.t
-SHA256 d3d111252be1dd32001e7d5aa0b89f5b623aa5cf0a541b94de9742b5ef48fb5f t/03smethod.t
-SHA256 c5bffc4e2284ee49d0be6a9fd4290e1139a14449ee7c651bf4252e722dfe0de8 t/04misc.t
+SHA256 0bea371cef24f361913e7865d043a314cdeaffff104f3792b00770e93b2eadcc t/01connect.t
+SHA256 50ce2e03b34dfc5e45c0af8f4078825b1ed449d201f165d8d05453762110ae72 t/01constants.t
+SHA256 4a57102776fa991abbdf52427f14b2200b0de9415495f625bbb4a89b3f9c99c0 t/02attribs.t
+SHA256 2c8ae070dcc5bd2b716be9094011de898ae79cc6df72fbea19672bce16f9afd9 t/03dbmethod.t
+SHA256 f6769b211e07e4bdeaf6e8b70c91dc2568758a92011f34d1315f9ee73478a82e t/03smethod.t
+SHA256 a3767a1b6e9adf62ec73f9d38b8bca151eb2fd872d42c2f77aeaef72178b1c56 t/04misc.t
SHA256 d30d52695492fbcb2d051c48d0d3afb621b0d5b29d876208b5fd79c5bc50b3fa t/06bytea.t
SHA256 f172234f057e485a8d5838db6986dbda18f4fe81fcf9ad0885728b8aec31b852 t/07copy.t
SHA256 2e50d0d3cea8c90882a06b99537d7aebcb8d8f062a775831d4b07056e832c4c1 t/08async.t
SHA256 13939607c75558e63395d0d77e78ed2485cd97b2e3d6559e72ec45bffdf333e4 t/09arrays.t
SHA256 97254af96ad61b3306b55ea687db6e5439e18a692f763aabc74bebe85e0c04c9 t/10_pg_error_field.t
-SHA256 a30dfbe57581c3e82e2ebf32f90a96493c5868c8aceaf2f8ef90c4c82173f299 t/12placeholders.t
+SHA256 9a4b3ba6e7931c21fdeab0225777de3512f68e58fc98305da5073694c5f84afe t/12placeholders.t
SHA256 982a438ec73b0428c263ed4608d82fd466a1668cfd4095c69d93ae002486368c t/20savepoints.t
SHA256 6bdf1b5d0bdc049bf8ff8a66d36fc41dfaea2d15e8550dc7e19ce152aa73c918 t/30unicode.t
SHA256 16b874ee36dcedc566b6c9b4c8142173e3a6babc660721939756d8a0a7d697f2 t/99cleanup.t
-SHA256 543c7990a7abd6b80889393209924c8c0d7d45509b73846d053801980394fc70 t/dbdpg_test_setup.pl
+SHA256 9cf22ac29150f372db11805cbe97a31d2d4cb5a1e62d93cd611ecde99f01f594 t/dbdpg_test_setup.pl
SHA256 50be982cc158a60f531674a593a55a05cac2f358b865e0cbcc6fc86285f719c0 t/lib/App/Info.pm
SHA256 e930aed2b35b6dd2504c8652f8037ce8e98454e0105babeca46ee133996fa084 t/lib/App/Info/Handler.pm
SHA256 bda949f555f730887b54d12627fdf17f290b245cf03ca14b7c4fc5b996c33884 t/lib/App/Info/Handler/Print.pm
@@ -47,7 +47,7 @@
SHA256 7ea6b4ee4b5cd6b0b44939544138503ede324c8a85a06a8b51334d62c1298669 t/lib/App/Info/RDBMS/PostgreSQL.pm
SHA256 36b5ac866344827a286687f036ed2702d2ccdee450ad1581a64995523b6df976 t/lib/App/Info/Request.pm
SHA256 6725541fdeb205716695fca6ff90f77d4e37e33f7d2cefab0b8f946876f646f9 t/lib/App/Info/Util.pm
-SHA256 e37a46dd0a9b569e89de9549f3a00d90327b348f3fc67d28fb8a0508cbb2a498 testme.tmp.pl
-SHA256 f9567669852e55092c612e4f63a2e0540472947555fc8a57f429fa8383970c49 types.c
-SHA256 064c0dc289767d594b1272525c28219fc7304fe2aa815b9b29a043c90ec51c12 types.h
+SHA256 eedc5a43373937237f35a298f6945d87dc0144c91eaae3eea4a19e79d0ae462c testme.tmp.pl
+SHA256 6b5ec7d1edf69f91407a7d5efd75e4dcde8a583434301fa48fe1ff50ffb1129d types.c
+SHA256 789d430468f518ec7d46114bae5fcb11f08f29bd573999b02712ac8b6e75a72a types.h
SHA256 4628f92764bdb3e2b04bda7f30fc497231fbbf80dfd24cc09ee3df2e6d6d4387 win32.mak
==> MISMATCHED content between SIGNATURE and distribution files! <==

"execute called with an unbound placeholder" with functions and array slice

The following query:

SELECT a[1:abs(1)];

can not be run using DBD-Pg-3.15 . The following error is returned:

Postgres 09.05.0000:XX000:execute called with an unbound placeholder

The same query runs fine using the psql client. I think the perl driver thinks that the 1:abs part denotes a placeholder , whereas it should have been passed verbatim to the database server.

The workaround is to insert a space after the : character.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.