Patching dblink.c to avoid warning about open transaction

From: Jonathan Beit-Aharon <jbeitaharon(at)intrusic(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Cc: Jonathan Beit-Aharon <jbeitaharon(at)intrusic(dot)com>
Subject: Patching dblink.c to avoid warning about open transaction
Date: 2005-09-23 20:26:56
Message-ID: 43346510.3050405@intrusic.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#3333ff">
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
<font size="+1">Hi,<br>
</font><font size="+1">I'm not a member of this list (yet), so please
CC me on responses and
discussion.<br>
</font><br>
<font size="+1">The patch below seems to be completion of work already
started, because the boolean remoteTrFlag was already defined, and all
I had to add was its setting and two references.<br>
<br>
I hope someone will find it useful,<br>
Jonathan<br>
<br>
<br>
--- dblink.c&nbsp;&nbsp;&nbsp; Sat Jan&nbsp; 1 00:43:05 2005<br>
+++ /home/jbeitaharon/dev/third/postgreSQL/contrib/dblink/dblink.c&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Thu Sep 22 16:10:20 2005<br>
@@ -329,12 +329,16 @@<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (!conn)<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DBLINK_CONN_NOT_AVAIL;<br>
+<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (rcon)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; rcon-&gt;remoteTrFlag = (PQtransactionStatus(conn) !=
PQTRANS_IDLE);<br>
<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res = PQexec(conn, "BEGIN");<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (PQresultStatus(res) != PGRES_COMMAND_OK)<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DBLINK_RES_INTERNALERROR("begin error");<br>
-<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PQclear(res);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ((!rcon) || (!(rcon-&gt;remoteTrFlag))) {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res = PQexec(conn, "BEGIN");<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (PQresultStatus(res) != PGRES_COMMAND_OK)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DBLINK_RES_INTERNALERROR("begin error");<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PQclear(res);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; appendStringInfo(str, "DECLARE %s CURSOR FOR %s", curname, sql);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res = PQexec(conn, str-&gt;data);<br>
@@ -424,12 +428,13 @@<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PQclear(res);<br>
<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* commit the transaction */<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res = PQexec(conn, "COMMIT");<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (PQresultStatus(res) != PGRES_COMMAND_OK)<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DBLINK_RES_INTERNALERROR("commit error");<br>
-<br>
-&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PQclear(res);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if ((!rcon) || (!(rcon-&gt;remoteTrFlag))) {<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* commit the transaction */<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res = PQexec(conn, "COMMIT");<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (PQresultStatus(res) != PGRES_COMMAND_OK)<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; DBLINK_RES_INTERNALERROR("commit error");<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PQclear(res);<br>
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<br>
<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; PG_RETURN_TEXT_P(GET_TEXT("OK"));<br>
&nbsp;}</font>
</body>
</html>

Attachment Content-Type Size
unknown_filename text/html 3.9 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 2005-09-23 20:32:05 Re: Improved \df(+) in psql + backward-compatibility
Previous Message Ron Peacetree 2005-09-23 19:44:54 Re: [PERFORM] Releasing memory during External sorting?

Browse pgsql-patches by date

  From Date Subject
Next Message Bruce Momjian 2005-09-23 20:32:05 Re: Improved \df(+) in psql + backward-compatibility
Previous Message Bruce Momjian 2005-09-23 19:59:11 Re: be-secure.c patch