Skip Menu |

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

Report information
The Basics
Id: 14302
Status: resolved
Priority: 0/
Queue: DBD-Pg

People
Owner: Nobody in particular
Requestors: schroer [...] scase.de
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 1.43
Fixed in: 1.44



Subject: login to PG8.03 does'n work under mod_perl
CGI-Scripts using DBD-Pg 1.43 couldn't login to PgSQL 8.03 if they run under mod_perl but work fine as pure CGI. At debugging I find out that PQserverVersion(imp_dbh->conn) in dbdimp.c return "0" if DBD-Pg running in mod_perl enviroment (but return 800003 if running in pure CGI). Attached you find a workaround that works fine on my server. Version dumping: - Debian stable (sarge) - Linux dev 2.6.8-2-686 #1 Thu May 19 17:53:30 JST 2005 i686 GNU/Linux - perl, v5.8.4 built for i386-linux-thread-multi - DBI 1.48 - DBD::Pg 1.43 - PostgreSQL 8.03 self compiled (./configure --with-perl --with-python --with-openssl --enable-thread-safety) - Apache/1.3.33 (Debian GNU/Linux) - mod_perl 1.29.0.3-6 (Debian GNU/Linux) There exist messages at the dbdpg-general mailinglist that describe this problem this different enviroment, too. See: http://gborg.postgresql.org/pipermail/dbdpg-general/2005-July/001869.html http://gborg.postgresql.org/pipermail/dbdpg-general/2005-July/001870.html http://gborg.postgresql.org/pipermail/dbdpg-general/2005-August/001892.html http://gborg.postgresql.org/pipermail/dbdpg-general/2005-August/001893.html Best regards, Jochen
*** dbdimp.c_orig 2005-08-25 03:54:20.462423656 +0200 --- dbdimp.c 2005-08-25 04:13:04.222586144 +0200 *************** *** 302,354 **** PQfinish(imp_dbh->conn); return 0; } /* Enable warnings to go through perl */ (void)PQsetNoticeProcessor(imp_dbh->conn, pg_warn, (void *)SvRV(dbh)); /* XXX this causes a problem with nmake */ /* Figure out what protocol this server is using */ imp_dbh->pg_protocol = PQprotocolVersion(imp_dbh->conn); /* Older versions use the one defined above */ /* Figure out this particular backend's version */ #if PGLIBVERSION >= 80000 imp_dbh->pg_server_version = PQserverVersion(imp_dbh->conn); ! #else imp_dbh->pg_server_version = -1; { PGresult *result; int status, cnt, vmaj, vmin, vrev; result = PQexec(imp_dbh->conn, "SELECT version(), 'DBD::Pg'"); if (result) status = PQresultStatus(result); else status = -1; if (PGRES_TUPLES_OK != status || (0==PQntuples(result))) { if (dbis->debug >= 4) (void)PerlIO_printf(DBILOGFP, " Could not get version from the server, status was %d\n", status); } else { cnt = sscanf(PQgetvalue(result,0,0), "PostgreSQL %d.%d.%d", &vmaj, &vmin, &vrev); PQclear(result); if (cnt >= 2) { if (cnt == 2) vrev = 0; imp_dbh->pg_server_version = (100 * vmaj + vmin) * 100 + vrev; } } } ! #endif Renew(imp_dbh->sqlstate, 6, char); /* freed in dbd_db_destroy (and above) */ if (!imp_dbh->sqlstate) croak("No memory"); strncpy(imp_dbh->sqlstate, "S1000\0", 6); imp_dbh->done_begin = FALSE; /* We are not inside a transaction */ imp_dbh->pg_bool_tf = FALSE; imp_dbh->pg_enable_utf8 = 0; imp_dbh->prepare_number = 1; imp_dbh->prepare_now = FALSE; imp_dbh->pg_errorlevel = 1; /* Matches PG default */ imp_dbh->savepoints = newAV(); imp_dbh->copystate = 0; --- 302,356 ---- PQfinish(imp_dbh->conn); return 0; } /* Enable warnings to go through perl */ (void)PQsetNoticeProcessor(imp_dbh->conn, pg_warn, (void *)SvRV(dbh)); /* XXX this causes a problem with nmake */ /* Figure out what protocol this server is using */ imp_dbh->pg_protocol = PQprotocolVersion(imp_dbh->conn); /* Older versions use the one defined above */ /* Figure out this particular backend's version */ #if PGLIBVERSION >= 80000 imp_dbh->pg_server_version = PQserverVersion(imp_dbh->conn); ! if (!imp_dbh->pg_server_version) ! #endif ! { imp_dbh->pg_server_version = -1; { PGresult *result; int status, cnt, vmaj, vmin, vrev; result = PQexec(imp_dbh->conn, "SELECT version(), 'DBD::Pg'"); if (result) status = PQresultStatus(result); else status = -1; if (PGRES_TUPLES_OK != status || (0==PQntuples(result))) { if (dbis->debug >= 4) (void)PerlIO_printf(DBILOGFP, " Could not get version from the server, status was %d\n", status); } else { cnt = sscanf(PQgetvalue(result,0,0), "PostgreSQL %d.%d.%d", &vmaj, &vmin, &vrev); PQclear(result); if (cnt >= 2) { if (cnt == 2) vrev = 0; imp_dbh->pg_server_version = (100 * vmaj + vmin) * 100 + vrev; } } } ! } Renew(imp_dbh->sqlstate, 6, char); /* freed in dbd_db_destroy (and above) */ if (!imp_dbh->sqlstate) croak("No memory"); strncpy(imp_dbh->sqlstate, "S1000\0", 6); imp_dbh->done_begin = FALSE; /* We are not inside a transaction */ imp_dbh->pg_bool_tf = FALSE; imp_dbh->pg_enable_utf8 = 0; imp_dbh->prepare_number = 1; imp_dbh->prepare_now = FALSE; imp_dbh->pg_errorlevel = 1; /* Matches PG default */ imp_dbh->savepoints = newAV(); imp_dbh->copystate = 0;
[guest - Wed Aug 24 20:49:56 2005]: Show quoted text
> There exist messages at the dbdpg-general mailinglist that describe > this problem this different enviroment, too. > See: > http://gborg.postgresql.org/pipermail/dbdpg-general/2005- > July/001869.html > http://gborg.postgresql.org/pipermail/dbdpg-general/2005- > July/001870.html
I get feedback from Steve Bougerolle that this fix worked for him, too. Regards, Jochen