head 1.4; access; symbols pkgsrc-2013Q2:1.4.0.42 pkgsrc-2013Q2-base:1.4 pkgsrc-2012Q4:1.4.0.40 pkgsrc-2012Q4-base:1.4 pkgsrc-2011Q4:1.4.0.38 pkgsrc-2011Q4-base:1.4 pkgsrc-2011Q2:1.4.0.36 pkgsrc-2011Q2-base:1.4 pkgsrc-2009Q4:1.4.0.34 pkgsrc-2009Q4-base:1.4 pkgsrc-2008Q4:1.4.0.32 pkgsrc-2008Q4-base:1.4 pkgsrc-2008Q3:1.4.0.30 pkgsrc-2008Q3-base:1.4 cube-native-xorg:1.4.0.28 cube-native-xorg-base:1.4 pkgsrc-2008Q2:1.4.0.26 pkgsrc-2008Q2-base:1.4 pkgsrc-2008Q1:1.4.0.24 pkgsrc-2008Q1-base:1.4 pkgsrc-2007Q4:1.4.0.22 pkgsrc-2007Q4-base:1.4 pkgsrc-2007Q3:1.4.0.20 pkgsrc-2007Q3-base:1.4 pkgsrc-2007Q2:1.4.0.18 pkgsrc-2007Q2-base:1.4 pkgsrc-2007Q1:1.4.0.16 pkgsrc-2007Q1-base:1.4 pkgsrc-2006Q4:1.4.0.14 pkgsrc-2006Q4-base:1.4 pkgsrc-2006Q3:1.4.0.12 pkgsrc-2006Q3-base:1.4 pkgsrc-2006Q2:1.4.0.10 pkgsrc-2006Q2-base:1.4 pkgsrc-2006Q1:1.4.0.8 pkgsrc-2006Q1-base:1.4 pkgsrc-2005Q4:1.4.0.6 pkgsrc-2005Q4-base:1.4 pkgsrc-2005Q3:1.4.0.4 pkgsrc-2005Q3-base:1.4 pkgsrc-2005Q2:1.4.0.2 pkgsrc-2005Q2-base:1.4 pkgsrc-2005Q1:1.3.0.14 pkgsrc-2005Q1-base:1.3 pkgsrc-2004Q4:1.3.0.12 pkgsrc-2004Q4-base:1.3 pkgsrc-2004Q3:1.3.0.10 pkgsrc-2004Q3-base:1.3 pkgsrc-2004Q2:1.3.0.8 pkgsrc-2004Q2-base:1.3 pkgsrc-2004Q1:1.3.0.6 pkgsrc-2004Q1-base:1.3 pkgsrc-2003Q4:1.3.0.4 pkgsrc-2003Q4-base:1.3 netbsd-1-6-1:1.3.0.2 netbsd-1-6-1-base:1.3 netbsd-1-6:1.1.0.8 netbsd-1-6-RELEASE-base:1.1 pkgviews:1.1.0.4 pkgviews-base:1.1 buildlink2-base:1.1 buildlink2:1.1.0.2; locks; strict; comment @# @; 1.4 date 2005.04.08.14.36.17; author jwise; state dead; branches; next 1.3; 1.3 date 2003.01.17.16.41.39; author mjl; state Exp; branches; next 1.2; 1.2 date 2002.08.21.23.10.39; author mjl; state Exp; branches; next 1.1; 1.1 date 2002.06.18.07.05.32; author explorer; state Exp; branches 1.1.2.1; next ; 1.1.2.1 date 2002.06.18.07.05.32; author jlam; state dead; branches; next 1.1.2.2; 1.1.2.2 date 2002.06.23.18.43.34; author jlam; state Exp; branches; next ; desc @@ 1.4 log @These have been folded into the main sources. @ text @$NetBSD: patch-aa,v 1.3 2003/01/17 16:41:39 mjl Exp $ --- dbdimp.c.orig Wed Jan 8 23:08:17 2003 +++ dbdimp.c Fri Jan 17 17:23:37 2003 @@@@ -40,6 +40,30 @@@@ int +_dbd_begin(imp_dbh_t *imp_dbh) +{ + PGresult *result = NULL; + ExecStatusType status; + + if (DBIc_has(imp_dbh, DBIcf_AutoCommit) != FALSE) + 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; @@@@ -192,6 +216,7 @@@@ imp_dbh->init_commit = 1; /* initialize AutoCommit */ imp_dbh->pg_auto_escape = 1; /* initialize pg_auto_escape */ imp_dbh->pg_bool_tf = 0; /* initialize pg_bool_tf */ + imp_dbh->need_begin = 1; DBIc_IMPSET_on(imp_dbh); /* imp_dbh set up now */ DBIc_ACTIVE_on(imp_dbh); /* call disconnect before freeing */ @@@@ -283,6 +308,9 @@@@ PGresult* result = 0; ExecStatusType commitstatus, beginstatus; + if (imp_dbh->need_begin) + return 1; + /* execute commit */ result = PQexec(imp_dbh->conn, "commit"); commitstatus = result ? PQresultStatus(result) : -1; @@@@ -294,21 +322,12 @@@@ pg_error(dbh, commitstatus, PQerrorMessage(imp_dbh->conn)); } - /* start new transaction. AutoCommit must be FALSE, ref. 20 lines up */ - result = PQexec(imp_dbh->conn, "begin"); - beginstatus = result ? PQresultStatus(result) : -1; - PQclear(result); - if (beginstatus != PGRES_COMMAND_OK) { - /* Maybe add some loud barf here? Raising some very high error? */ - pg_error(dbh, beginstatus, "begin failed\n"); - return 0; - } - /* if the initial COMMIT failed, return 0 now */ if (commitstatus != PGRES_COMMAND_OK) { return 0; } - + + imp_dbh->need_begin = 1; return 1; } @@@@ -332,6 +351,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; @@@@ -343,15 +365,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; } @@@@ -374,7 +389,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"); @@@@ -450,16 +466,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"); } } @@@@ -1142,6 +1149,11 @@@@ return -2; } + if (_dbd_begin(imp_dbh) == 0) { + pg_error(sth, -1, "executing begin failed\n"); + return -2; + } + statement = imp_sth->statement; if (! statement) { /* are we prepared ? */ @ 1.3 log @Update p5-DBD-postgresql to 1.21 - System tables no longer returned by tables(). - Fix table_attributes to handle removal of pg_relcheck in 7.3, - Properly reset transaction status after failed transaction when autocommit is off. Properly report transaction failure message. - New pg_bool_tf database handle that when set to true booleans are returned as 't'/'f' rather than 1/0. - Maintenance transferred to GBorg. - Added implementations of column_info() and table_info(), and primary_key_info(). - The POD formatting was cleaned up. - The preparser was updated to better handle escaped characters. - Added eg/lotest.pl as a demonstration of using large objects in buffers rather than files. - Added LISTEN/NOTIFY functionality. - Added constants for common PostgreSQL data types. - Fixed compile-time warnings. @ text @d1 1 a1 1 $NetBSD$ @ 1.2 log @Fix problems introduced by our local patch: AutoCommit handles wouldn't, and executes on closed handles crashed perl hard. Fixes PR/18009. @ text @d3 2 a4 2 --- dbdimp.c.orig Sat Apr 27 22:35:52 2002 +++ dbdimp.c Thu Aug 22 01:01:06 2002 d36 1 a36 2 @@@@ -191,6 +215,7 @@@@ d39 1 d44 1 a44 1 @@@@ -241,6 +266,9 @@@@ d46 1 a46 1 ExecStatusType status; d48 2 a49 2 + if (imp_dbh->need_begin) + return 1; d53 3 a55 3 status = result ? PQresultStatus(result) : -1; @@@@ -252,15 +280,8 @@@@ return 0; d60 1 a60 1 - status = result ? PQresultStatus(result) : -1; d62 3 a64 2 - if (status != PGRES_COMMAND_OK) { - pg_error(dbh, status, "begin failed\n"); d67 5 d73 1 a74 1 + d78 1 a78 1 @@@@ -284,6 +305,9 @@@@ d88 1 a88 1 @@@@ -295,15 +319,8 @@@@ d106 1 a106 1 @@@@ -326,7 +343,8 @@@@ d116 1 a116 1 @@@@ -402,16 +420,7 @@@@ d134 1 a134 1 @@@@ -1080,6 +1089,11 @@@@ @ 1.1 log @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. @ text @d3 2 a4 3 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 d14 1 a14 1 + if (DBIc_has(imp_dbh, DBIcf_AutoCommit) == TRUE) d128 12 a139 10 @@@@ -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 @ 1.1.2.1 log @file patch-aa was added on branch buildlink2 on 2002-06-23 18:43:34 +0000 @ text @d1 138 @ 1.1.2.2 log @Merge from pkgsrc-current to buildlink2 branch. @ text @a0 138 $NetBSD: patch-aa,v 1.1.2.1 2002/06/23 18:43:34 jlam 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 @