bucardo / dbdpg Goto Github PK
View Code? Open in Web Editor NEWPerl Postgres driver DBD::Pg aka dbdpg
Perl Postgres driver DBD::Pg aka dbdpg
DBD::Pg is Copyright (C) 1994-2024, Greg Sabino Mullane DBD::Pg -- the DBI PostgreSQL interface for Perl DESCRIPTION: ------------ This is version 3.18.0 of DBD::Pg, the Perl interface to Postgres using DBI. The web site for this interface, and the latest version, can be found at: http://search.cpan.org/dist/DBD-Pg/ The mailing list is at: http://www.nntp.perl.org/group/perl.dbd.pg/ Subscribe with an email to [email protected] The development of DBD::Pg can be tracked at: git://github.com/bucardo/dbdpg.git For information about PostgreSQL, visit: http://www.postgresql.org/ For information on what has changed for each version, see the Changes files. REQUIREMENTS: ------------- build, test, and install Perl 5 (at least 5.8.1) build, test, and install the DBI module (at least 1.614) build, test, and install PostgreSQL (at least 8.0) build, test, and install Test::Simple (at least 0.47) DBD::Pg needs to know where to find the libpq libraries: this is usually done by checking the output of the pg_config executable. If pg_config is not available, then you may need to install the development package for PostgreSQL. To do this on Debian and Ubuntu, use: apt-get install libpq-dev; on RedHat, CentOS, etc. use: yum install postgresql-devel. Note that the development libraries are needed even if you already have PostgreSQL up and running. IF YOU HAVE PROBLEMS OR COMMENTS: --------------------------------- Please send any problems and comments to <[email protected]> Please include what OS you are using, and the version of Perl, DBI, and DBD::Pg you are using. Also tell which version of PostgreSQL DBD::Pg was compiled against, and which version you are connecting to. The easiest way to gather all of this information is to run "make test", which outputs it all early in the tests. View the archive at http://www.nntp.perl.org/group/perl.dbd.pg/ To subscribe, email [email protected] To unsubscribe, email [email protected] To get help regarding your subscription, email [email protected] You can also try the #postgresql channel on irc.libera.chat, which usually (but not always) has people who can help you with DBD::Pg. BUG REPORTS: ----------- Bug reports are welcome at: https://github.com/bucardo/dbdpg/issues PATCHES: -------- Patches are always welcome: the best way is to create a Pull Request at https://github.com/bucardo/dbdpg INSTALLATION: ------------- Before installing, please use the "cpansign -v" program to cryptographically verify that your copy of DBD::Pg is complete and valid. The program "cpansign" is part of Module::Signature, available from CPAN. By default Makefile.PL uses App::Info to find the location of the PostgreSQL library and include directories. However, if you want to control it yourself, define the environment variables POSTGRES_INCLUDE and POSTGRES_LIB, or define just POSTGRES_HOME. Note that if you have compiled PostgreSQL with SSL support, you must define the POSTGRES_LIB environment variable and add "-lssl" and "-lcrypto" to it, like this: export POSTGRES_LIB="/usr/local/pgsql/lib -lssl -lcrypto" The usual steps to install DBD::Pg: 1. perl Makefile.PL 2. make 3. make test 4. make install Do steps 1 to 2 as a normal user, not as root! If the script cannot find the pg_config information itself, it will ask you for the path to it. Enter the complete path to the pg_config file here, including the name of the file itself. TESTING: -------- The tests rely on being able to connect to a valid Postgres database. The easiest way to ensure this is to set the following environment variables: DBI_DSN=dbi:Pg:dbname=<database> DBI_USER=<username> DBI_PASS=<password> If you are running on a non-standard port, you must set PGPORT or add the port to the DBI_DSN variable like this: DBI_DSN='dbi:Pg:dbname=<database>;port=<port#>' Put double quotes around the dbname if it has a semicolon or a space inside of it: DBI_DSN='dbi:Pg:dbname="<data;base>"' If no valid connection is found, the tests will use the "initdb" program to try and create a Postgres database cluster to test with. The first available port starting at 5440 will be used. If your directory path is long, Postgres may fail to start as there is a maximum length to socket directory paths. If this happens, please set the environment variable DBDPG_TEMPDIR to something short, such as "/tmp". You can increase the verbosity of the tests by setting the environment variable TEST_VERBOSE. You can also enable tracing within the tests themselves by setting DBD_TRACE to whatever trace level you want. Be aware that setting the trace level can result in extremely verbose output. When reporting test failures, please use TEST_VERBOSE=1, but do *not* set DBD_TRACE unless requested, and send only the relevant sections. Please consider installing CPAN::Reporter so that your tests are automatically gathered and reported, which helps the development of DBD::Pg. TROUBLESHOOTING: ---------------- * Placeholder issues If you find that some of your queries containing placeholders are no longer working, this may because DBD::Pg now uses the native PostgreSQL placeholders on the server itself whenever possible. Previously, DBD::Pg did a simple emulation of placeholders, so the rules were not as strict. You should either rewrite your queries to make them legal SQL syntax for PostgreSQL, or turn off server-side prepares. To change your queries, make sure that the type of each placeholder can be determined by the PostgreSQL parser. So instead of: SELECT ? use something like: SELECT ?::int To turn off server-side prepares completely (with a loss of some performance and features), do this at the top of your scripts: $dbh->{pg_server_prepare} = 0; This can also be set for individual queries at the statement handle level: see the documentation section on "Placeholders" for more details. * PostgreSQL library issues: DBD::Pg uses the libpq library that comes with Postgres. If the shared libpq library is not available, DBD::Pg will error with a message that usually mentions a file names libpq.so, like this: Can't load './blib/arch/auto/DBD/Pg/Pg.so' for module DBD::Pg: libpq.so.5: cannot open shared object file: No such file or directory at .../DynaLoader.pm line 230. This means that the libraries are not installed in a place where the system can find them when it tries to load the Pg.so file. On some systems, you can run /sbin/ldconfig -v to see a list of shared modules, or just search the system for the file with "locate libpq.so". If it exists but is not being loaded, you may need to add the directory it is in to /etc/ld.so.conf file and run the ldconfig command. Otherwise, you may need to add the path to the environment variable LD_LIBRARY_PATH. If you get an error message like: perl: error while loading shared libraries: /usr/lib/perl5/site_perl/5.6.1/i386-linux/auto/DBD/Pg/Pg.so: undefined symbol: PQconnectdb when you call DBI->connect, then your libpq.so was probably not seen at build-time. This should have caused 'make test' to fail; did you really run it and look at the output? * Mac installation issues Modern Mac software has a feature called Software Integrity Protection that strips out all LD_* and DYLD_* environment variables when a program starts, which means DBD::Pg will no compile. One solution is to use the install_name_tool program to modify the relative paths to absolute ones. As an example: sudo install_name_tool -change \ libpq.5.dylib /Library/PostgreSQL/11/lib/libpq.5.dylib \ ~/perl5/lib/perl5/darwin-thread-multi-2level/auto/DBD/Pg/Pg.bundle * Perl issues: Some Linux distributions have incomplete perl installations. If you have compile errors like "XS_VERSION_BOOTCHECK undeclared", do: find .../lib/perl5 -name XSUB.h -print If this file is not present, you need to recompile and re-install perl. If you get a message about "use of uninitialized value in -d" when doing a "make install_vendor", you can work around this by adding a dummy value to the INSTALLVENDORBIN environment variable: make install_vendor INSTALLVENDORBIN=/tmp (thanks to Peter Eisentraut <peter_e at gmx.net>) * Strawberry Perl issues: You'll need to create a .a library from the .dll before running the Makefile.PL, by running pexports and dlltool as shown below, within the C:\Program Files\PostgreSQL\8.3\bin directory: C:\Windows\> C:\MinGW\bin\pexports libpq.dll > libpq.def C:\Windows\> C:\MinGW\bin\dlltool -dllname libpq.dll --def libpq.def --output-lib "C:\Program Files\PostgreSQL\12\lib\libpq.a" pexports and dlltool are included with MinGW - Minimalist Gnu for Windows, found here: https://osdn.net/projects/mingw/releases/ Once you have installed MinGW you can install pexports and dlltool as follows: C:\Windows\> C:\MinGW\bin\mingw-get.exe install pexports C:\Windows\> C:\MinGW\bin\mingw-get.exe install dlltool Then you'll need to set the required environment: set PATH=C:\PROGRA~1\PostgreSQL\8.3\bin;%PATH% set DBI_DSN=dbi:Pg:dbname=testdb set DBI_USER=*PostgreSQL username* set DBI_PASS=*PostgreSQL password* set POSTGRES_HOME=C:/PROGRA~1/PostgreSQL/8.3 set POSTGRES_INCLUDE=C:/PROGRA~1/PostgreSQL/8.3/include set POSTGRES_LIB=C:/PROGRA~1/PostgreSQL/8.3/lib Note that the username and password are the ones for PostgreSQL, NOT the ones for the Windows account that the PostgreSQL installer creates to run the service safely. (You may wish to set these variables on the system level, by going to Control Panel > System > Advanced tab > Environment Variables button and adding the environment variables there.) Now the Makefile.PL can be ran: perl Makefile.PL dmake dmake test dmake install * SGI issues: If you get segmentation faults, make sure you are using the malloc which comes with perl when compiling perl (the default is not to). (thanks to "David R. Noble" <drnoble at engsci.sandia.gov>) * HP issues: If you get error messages like: can't open shared library: .../lib/libpq.sl No such file or directory when running the test script, try to replace the 'shared' option in the LDDFLAGS with 'archive'. (thanks to Dan Lauterbach <danla at dimensional.com>) * FreeBSD issues: If you get during "make test" the error message: 'DBD driver has not implemented the AutoCommit attribute' recompile the DBI module and the DBD-Pg module and disable optimization. This error message is due to the broken optimization in gcc-2.7.2.1. If you get compiler errors like: In function `XS_DBD__Pg__dr_discon_all_' `sv_yes' undeclared (first use in this function) it may be because there is a 'patchlevel.h' file from another package (such as 'hdf') in your POSTGRES_INCLUDE dir. The presence of this file prevents the compiler from finding the perl include file 'mach/CORE/patchlevel.h'. Do 'pg_config --includedir' to identify the POSTGRES_INCLUDE dir. Rename patchlevel.h whilst you build DBD::Pg. * Sun issues: If you get compile errors like: /usr/include/string.h:57: parse error before `]' then you need to remove from pgsql/include/libpq-fe.h the define for strerror, which clashes with the definition in the standard include file. * Win32 issues: For installation, please see the README.win32 file. Running DBD-Pg scripts on Win32 needs some configuration work on the server side: o add a postgres user with the same name as the NT-User (e.g. Administrator) o make sure, that your pg_hba.conf on the server is configured, such that a connection from another host will be accepted * OS X issues: You may need to add "-lssl" and "-lcrypto" to your LIB variable before compiling. (thanks to <rob at cabrion dot com>) If having problems compiling, try running: env -i command This trick stops 'command' from inheriting environment variables from the shell process, which more often than not fixes up such weird build errors without having to do anything else in particular. (thanks to David Landgren <david at landgren dot net>) * SCO issues: If the 'make test' gives an error about a symbol not being found, you can correct the problem by manually running ld after the 'make' command: LD_RUN_PATH="/usr/local/pgsql/lib" ld -G -L/usr/local/lib Pg.o \ dbdimp.o -o blib/arch/auto/DBD/Pg/Pg.so -L/usr/local/pgsql/lib -lpq \ -L/opt/K/SKUNK2000/Gcc/2.95.2pl1/usr/local/lib/gcc-lib/i386-pc-sco3.2v5.0.5/2.95.2/ \ -lgcc Once this is done, 'make test' succeeds properly. (thanks to <jmore at remote-print.com>) COPYRIGHT: ---------- Copyright (c) 2002-2024 Greg Sabino Mullane and others: see the Changes file Portions Copyright (c) 2002 Jeffrey W. Baker Portions Copyright (c) 1997-2001 Edmund Mergl Portions Copyright (c) 1994-1997 Tim Bunce LICENSE INFORMATION: -------------------- This module (DBD::Pg) is free software; you can redistribute it and/or modify it under the same terms as Perl 5.10.0. For more details, see the full text of the licenses in the directory LICENSES.
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.
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.
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
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!
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.
I have a problem with discovering column types of query result: https://gist.github.com/jef-sure/9a28e7c12f0c03d32080456afd4dafd3
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
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.
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:
Lines 593 to 603 in 3f277a5
$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.
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!
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.
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!
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)
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.
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.
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.
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.
According to the documentation of libpq it is possible
to specify multiple hosts in the connection string. This syntax is used to connect
to a cluster with master and standby nodes. Parameter target_session_attrs
determines
what node will be chosen by libpg.
It is however not clear how one should specify this in the DBI syntax. This host=host1,host2
doesn't work for sure.
Is this supported?
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 }
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
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
.
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 .......... #
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
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.
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
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. :)
$ 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
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.
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};
Just like this
Because this is more handy to use modern tools
This will lead to github repository from metacpan
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'
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.
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
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'.
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! <==
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;
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.
Hi!
Let me stupid question. Do you have planned to autoJSONify from Perl data to PG json/jsonb data types and backwards?
Regards.
Please include "DBD-Pg" or "DBD::Pg" in the description, so the repository can be found by searching for the actual name of the distribution and/or module.
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.
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.
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:
Other than those, I believe stock Debian Jessie. I will respond to any follow up questions promptly.
"/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
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?
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.
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
---$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
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.
... 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 ..........
...
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).
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.
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
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.