From 2099315373053b2b8740bf039fc31b77c850a661 Mon Sep 17 00:00:00 2001 From: explorer Date: Tue, 18 Jun 2002 07:05:30 +0000 Subject: Fix DBD-postgresql to not keep a transaction open when idle. Without this change, postgresql 7.2 cannot vacuum properly. This change was submitted to the DBD-postgresql author, with no reply. --- databases/p5-DBD-postgresql/distinfo | 4 +- databases/p5-DBD-postgresql/patches/patch-aa | 138 +++++++++++++++++++++++++++ databases/p5-DBD-postgresql/patches/patch-ab | 13 +++ 3 files changed, 154 insertions(+), 1 deletion(-) create mode 100644 databases/p5-DBD-postgresql/patches/patch-aa create mode 100644 databases/p5-DBD-postgresql/patches/patch-ab (limited to 'databases') diff --git a/databases/p5-DBD-postgresql/distinfo b/databases/p5-DBD-postgresql/distinfo index 83d0a6a65a3..a0bf67cce15 100644 --- a/databases/p5-DBD-postgresql/distinfo +++ b/databases/p5-DBD-postgresql/distinfo @@ -1,4 +1,6 @@ -$NetBSD: distinfo,v 1.9 2002/05/16 21:19:06 mjl Exp $ +$NetBSD: distinfo,v 1.10 2002/06/18 07:05:30 explorer Exp $ SHA1 (DBD-Pg-1.13.tar.gz) = f99a5aeebd71e0cac273311cb3405d9ed5e3e9c2 Size (DBD-Pg-1.13.tar.gz) = 43038 bytes +SHA1 (patch-aa) = 402aba6095807740d63f04d45b62fdd0febdb3ec +SHA1 (patch-ab) = 6c917ab5352c6790c1b9ec9b1e52c0dd969912f9 diff --git a/databases/p5-DBD-postgresql/patches/patch-aa b/databases/p5-DBD-postgresql/patches/patch-aa new file mode 100644 index 00000000000..864b91eca2b --- /dev/null +++ b/databases/p5-DBD-postgresql/patches/patch-aa @@ -0,0 +1,138 @@ +$NetBSD: patch-aa,v 1.1 2002/06/18 07:05:32 explorer Exp $ + +diff -ur dbdimp.c.orig dbdimp.c +--- dbdimp.c.orig Thu Apr 4 18:55:51 2002 ++++ dbdimp.c Wed May 15 19:16:54 2002 +@@ -40,6 +40,30 @@ + + + int ++_dbd_begin(imp_dbh_t *imp_dbh) ++{ ++ PGresult *result = NULL; ++ ExecStatusType status; ++ ++ if (DBIc_has(imp_dbh, DBIcf_AutoCommit) == TRUE) ++ return 1; ++ ++ if (imp_dbh->need_begin == 0) ++ return 1; ++ ++ imp_dbh->need_begin = 0; ++ ++ result = PQexec(imp_dbh->conn, "begin"); ++ status = result ? PQresultStatus(result) : -1; ++ PQclear(result); ++ if (status != PGRES_COMMAND_OK) { ++ return 0; ++ } ++ ++ return 1; ++} ++ ++int + dbd_discon_all (drh, imp_drh) + SV *drh; + imp_drh_t *imp_drh; +@@ -191,6 +215,7 @@ + + imp_dbh->init_commit = 1; /* initialize AutoCommit */ + imp_dbh->pg_auto_escape = 1; /* initialize pg_auto_escape */ ++ imp_dbh->need_begin = 1; + + DBIc_IMPSET_on(imp_dbh); /* imp_dbh set up now */ + DBIc_ACTIVE_on(imp_dbh); /* call disconnect before freeing */ +@@ -241,6 +266,9 @@ + PGresult* result = 0; + ExecStatusType status; + ++ if (imp_dbh->need_begin) ++ return 1; ++ + /* execute commit */ + result = PQexec(imp_dbh->conn, "commit"); + status = result ? PQresultStatus(result) : -1; +@@ -252,15 +280,8 @@ + return 0; + } + +- /* start new transaction. AutoCommit must be FALSE, ref. 20 lines up */ +- result = PQexec(imp_dbh->conn, "begin"); +- status = result ? PQresultStatus(result) : -1; +- PQclear(result); +- if (status != PGRES_COMMAND_OK) { +- pg_error(dbh, status, "begin failed\n"); +- return 0; +- } +- ++ imp_dbh->need_begin = 1; ++ + return 1; + } + +@@ -284,6 +305,9 @@ + PGresult* result = 0; + ExecStatusType status; + ++ if (imp_dbh->need_begin) ++ return 1; ++ + /* execute rollback */ + result = PQexec(imp_dbh->conn, "rollback"); + status = result ? PQresultStatus(result) : -1; +@@ -295,15 +319,8 @@ + return 0; + } + +- /* start new transaction. AutoCommit must be FALSE, ref. 20 lines up */ +- result = PQexec(imp_dbh->conn, "begin"); +- status = result ? PQresultStatus(result) : -1; +- PQclear(result); +- if (status != PGRES_COMMAND_OK) { +- pg_error(dbh, status, "begin failed\n"); +- return 0; +- } +- ++ imp_dbh->need_begin = 1; ++ + return 1; + } + +@@ -326,7 +343,8 @@ + + if (NULL != imp_dbh->conn) { + /* rollback if AutoCommit = off */ +- if (DBIc_has(imp_dbh, DBIcf_AutoCommit) == FALSE) { ++ if ((imp_dbh->need_begin == 0) ++ && (DBIc_has(imp_dbh, DBIcf_AutoCommit) == FALSE)) { + PGresult* result = 0; + ExecStatusType status; + result = PQexec(imp_dbh->conn, "rollback"); +@@ -402,16 +420,7 @@ + if (dbis->debug >= 2) { PerlIO_printf(DBILOGFP, "dbd_db_STORE: switch AutoCommit to on: commit\n"); } + } else if ((oldval != FALSE && newval == FALSE) || (oldval == FALSE && newval == FALSE && imp_dbh->init_commit)) { + if (NULL != imp_dbh->conn) { +- /* start new transaction */ +- PGresult* result = 0; +- ExecStatusType status; +- result = PQexec(imp_dbh->conn, "begin"); +- status = result ? PQresultStatus(result) : -1; +- PQclear(result); +- if (status != PGRES_COMMAND_OK) { +- pg_error(dbh, status, "begin failed\n"); +- return 0; +- } ++ imp_dbh->need_begin = 1; + } + if (dbis->debug >= 2) { PerlIO_printf(DBILOGFP, "dbd_db_STORE: switch AutoCommit to off: begin\n"); } + } +@@ -1027,6 +1036,9 @@ + SV **svp; + + if (dbis->debug >= 1) { PerlIO_printf(DBILOGFP, "dbd_st_execute\n"); } ++ ++ if (_dbd_begin(imp_dbh) == 0) ++ return 0; + + /* + here we get the statement from the statement handle where diff --git a/databases/p5-DBD-postgresql/patches/patch-ab b/databases/p5-DBD-postgresql/patches/patch-ab new file mode 100644 index 00000000000..c7e8c1f1986 --- /dev/null +++ b/databases/p5-DBD-postgresql/patches/patch-ab @@ -0,0 +1,13 @@ +$NetBSD: patch-ab,v 1.1 2002/06/18 07:05:32 explorer Exp $ + +diff -ur dbdimp.h.orig dbdimp.h +--- dbdimp.h.orig Thu Apr 4 18:55:51 2002 ++++ dbdimp.h Thu Apr 4 19:08:29 2002 +@@ -22,6 +22,7 @@ + PGconn * conn; /* connection structure */ + int init_commit; /* initialize AutoCommit */ + int pg_auto_escape; /* initialize AutoEscape */ ++ int need_begin; /* need a begin */ + }; + + /* Define sth implementor data structure */ -- cgit v1.2.3