perl-dbi.patch 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. --- DBD-Pg-1.22/dbdimp.c.orig Thu Mar 27 04:14:19 2003
  2. +++ DBD-Pg-1.22/dbdimp.c Sat May 17 13:26:56 2003
  3. @@ -97,6 +97,36 @@
  4. free(err);
  5. }
  6. +
  7. +int
  8. +_dbd_begin(dbh, imp_dbh)
  9. + SV *dbh;
  10. + imp_dbh_t *imp_dbh;
  11. +{
  12. + PGresult *result = NULL;
  13. + ExecStatusType status;
  14. +
  15. + if (DBIc_has(imp_dbh, DBIcf_AutoCommit))
  16. + return 1;
  17. +
  18. + if (imp_dbh->pg_need_begin == 0)
  19. + return 1;
  20. +
  21. + imp_dbh->pg_need_begin = 0;
  22. +
  23. + /* start new transaction. AutoCommit must be FALSE, ref. ~8 lines up */
  24. + result = PQexec(imp_dbh->conn, "begin");
  25. + status = result ? PQresultStatus(result) : -1;
  26. + PQclear(result);
  27. + if (status != PGRES_COMMAND_OK) {
  28. + pg_error(dbh, status, "begin failed\n");
  29. + return 0;
  30. + }
  31. +
  32. + return 1;
  33. +}
  34. +
  35. +
  36. static int
  37. pgtype_bind_ok (dbtype)
  38. int dbtype;
  39. @@ -193,6 +223,7 @@
  40. imp_dbh->init_commit = 1; /* initialize AutoCommit */
  41. imp_dbh->pg_auto_escape = 1; /* initialize pg_auto_escape */
  42. imp_dbh->pg_bool_tf = 0; /* initialize pg_bool_tf */
  43. + imp_dbh->pg_need_begin = 1; /* initialize begin state */
  44. DBIc_IMPSET_on(imp_dbh); /* imp_dbh set up now */
  45. DBIc_ACTIVE_on(imp_dbh); /* call disconnect before freeing */
  46. @@ -284,7 +315,7 @@
  47. if (NULL != imp_dbh->conn) {
  48. PGresult* result = 0;
  49. - ExecStatusType commitstatus, beginstatus;
  50. + ExecStatusType commitstatus;
  51. /* execute commit */
  52. result = PQexec(imp_dbh->conn, "commit");
  53. @@ -297,15 +328,8 @@
  54. pg_error(dbh, commitstatus, PQerrorMessage(imp_dbh->conn));
  55. }
  56. - /* start new transaction. AutoCommit must be FALSE, ref. 20 lines up */
  57. - result = PQexec(imp_dbh->conn, "begin");
  58. - beginstatus = result ? PQresultStatus(result) : -1;
  59. - PQclear(result);
  60. - if (beginstatus != PGRES_COMMAND_OK) {
  61. - /* Maybe add some loud barf here? Raising some very high error? */
  62. - pg_error(dbh, beginstatus, "begin failed\n");
  63. - return 0;
  64. - }
  65. + /* mark need for a begin at the start of the next command */
  66. + imp_dbh->pg_need_begin = 1;
  67. /* if the initial COMMIT failed, return 0 now */
  68. if (commitstatus != PGRES_COMMAND_OK) {
  69. @@ -335,6 +359,10 @@
  70. PGresult* result = 0;
  71. ExecStatusType status;
  72. + /* no rollback is needed if we are not already in a transaction */
  73. + if (imp_dbh->pg_need_begin)
  74. + return 1;
  75. +
  76. /* execute rollback */
  77. result = PQexec(imp_dbh->conn, "rollback");
  78. status = result ? PQresultStatus(result) : -1;
  79. @@ -346,14 +374,8 @@
  80. return 0;
  81. }
  82. - /* start new transaction. AutoCommit must be FALSE, ref. 20 lines up */
  83. - result = PQexec(imp_dbh->conn, "begin");
  84. - status = result ? PQresultStatus(result) : -1;
  85. - PQclear(result);
  86. - if (status != PGRES_COMMAND_OK) {
  87. - pg_error(dbh, status, "begin failed\n");
  88. - return 0;
  89. - }
  90. + /* mark need for a begin at the start of the next command */
  91. + imp_dbh->pg_need_begin = 1;
  92. return 1;
  93. }
  94. @@ -377,7 +399,8 @@
  95. if (NULL != imp_dbh->conn) {
  96. /* rollback if AutoCommit = off */
  97. - if (DBIc_has(imp_dbh, DBIcf_AutoCommit) == FALSE) {
  98. + if ((imp_dbh->pg_need_begin == 0)
  99. + && (DBIc_has(imp_dbh, DBIcf_AutoCommit) == FALSE)) {
  100. PGresult* result = 0;
  101. ExecStatusType status;
  102. result = PQexec(imp_dbh->conn, "rollback");
  103. @@ -453,16 +476,7 @@
  104. if (dbis->debug >= 2) { PerlIO_printf(DBILOGFP, "dbd_db_STORE: switch AutoCommit to on: commit\n"); }
  105. } else if ((oldval != FALSE && newval == FALSE) || (oldval == FALSE && newval == FALSE && imp_dbh->init_commit)) {
  106. if (NULL != imp_dbh->conn) {
  107. - /* start new transaction */
  108. - PGresult* result = 0;
  109. - ExecStatusType status;
  110. - result = PQexec(imp_dbh->conn, "begin");
  111. - status = result ? PQresultStatus(result) : -1;
  112. - PQclear(result);
  113. - if (status != PGRES_COMMAND_OK) {
  114. - pg_error(dbh, status, "begin failed\n");
  115. - return 0;
  116. - }
  117. + imp_dbh->pg_need_begin = 1;
  118. }
  119. if (dbis->debug >= 2) { PerlIO_printf(DBILOGFP, "dbd_db_STORE: switch AutoCommit to off: begin\n"); }
  120. }
  121. @@ -1182,6 +1196,9 @@
  122. SV **svp;
  123. if (dbis->debug >= 1) { PerlIO_printf(DBILOGFP, "dbd_st_execute\n"); }
  124. +
  125. + if (_dbd_begin(sth, imp_dbh) == 0)
  126. + return 0;
  127. /*
  128. here we get the statement from the statement handle where
  129. --- DBD-Pg-1.22/dbdimp.h.orig Tue Mar 25 23:17:00 2003
  130. +++ DBD-Pg-1.22/dbdimp.h Sat May 17 13:29:12 2003
  131. @@ -28,6 +28,7 @@
  132. #ifdef SvUTF8_off
  133. int pg_enable_utf8; /* should we attempt to make utf8 strings? */
  134. #endif
  135. + int pg_need_begin; /* does a begin need to be sent */
  136. };
  137. /* Define sth implementor data structure */
  138. --- DBD-ODBC-1.06/Makefile.PL.dist 2003-06-23 15:42:09.000000000 +0200
  139. +++ DBD-ODBC-1.06/Makefile.PL 2003-06-23 15:42:23.000000000 +0200
  140. @@ -424,7 +424,7 @@
  141. changes_pm = ' . File::Spec->catfile($self->{INST_LIB}, 'DBD/ODBC', 'Changes.pm') . '
  142. config :: $(changes_pm)
  143. - @$(NOOP)
  144. + @$(NOOP)
  145. $(changes_pm): Changes
  146. $(NOECHO) $(MKPATH) $(inst_libdbdodbc)
  147. --- DBD-Pg-1.22/Makefile.PL.dist 2003-07-01 08:31:41.000000000 +0200
  148. +++ DBD-Pg-1.22/Makefile.PL 2003-07-01 08:31:57.000000000 +0200
  149. @@ -36,7 +36,7 @@
  150. $POSTGRES_INCLUDE = $pg->inc_dir;
  151. $POSTGRES_LIB = $pg->lib_dir;
  152. } elsif ((!$ENV{POSTGRES_INCLUDE} or !$ENV{POSTGRES_LIB}) and $ENV{POSTGRES_HOME}) {
  153. - $POSTGRES_INCLUDE = "$ENV{POSTGRES_HOME}/include";
  154. + $POSTGRES_INCLUDE = "$ENV{POSTGRES_HOME}/include/postgresql";
  155. $POSTGRES_LIB = "$ENV{POSTGRES_HOME}/lib";
  156. } else {
  157. $POSTGRES_INCLUDE = "$ENV{POSTGRES_INCLUDE}";