Patching dblink.c to avoid warning about open transaction
От | Jonathan Beit-Aharon |
---|---|
Тема | Patching dblink.c to avoid warning about open transaction |
Дата | |
Msg-id | 43346510.3050405@intrusic.com обсуждение исходный текст |
Ответы |
Re: Patching dblink.c to avoid warning about open transaction
|
Список | pgsql-hackers |
<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 theboolean remoteTrFlag was already defined, and all I had to add was its setting and two references.<br /><br /> I hopesomeone will find it useful,<br /> Jonathan<br /><br /><br /> --- dblink.c Sat Jan 1 00:43:05 2005<br /> +++ /home/jbeitaharon/dev/third/postgreSQL/contrib/dblink/dblink.c Thu Sep 22 16:10:20 2005<br /> @@ -329,12 +329,16 @@<br/><br /> if (!conn)<br /> DBLINK_CONN_NOT_AVAIL;<br /> +<br /> + if (rcon)<br /> + rcon->remoteTrFlag = (PQtransactionStatus(conn) != PQTRANS_IDLE);<br /><br /> - res = PQexec(conn,"BEGIN");<br /> - if (PQresultStatus(res) != PGRES_COMMAND_OK)<br /> - DBLINK_RES_INTERNALERROR("beginerror");<br /> -<br /> - PQclear(res);<br /> + if ((!rcon) || (!(rcon->remoteTrFlag))){<br /> + res = PQexec(conn, "BEGIN");<br /> + if (PQresultStatus(res)!= PGRES_COMMAND_OK)<br /> + DBLINK_RES_INTERNALERROR("begin error");<br /> + PQclear(res);<br /> + }<br /><br /> appendStringInfo(str, "DECLARE %s CURSOR FOR %s", curname,sql);<br /> res = PQexec(conn, str->data);<br /> @@ -424,12 +428,13 @@<br /><br /> PQclear(res);<br/><br /> - /* commit the transaction */<br /> - res = PQexec(conn, "COMMIT");<br /> - if(PQresultStatus(res) != PGRES_COMMAND_OK)<br /> - DBLINK_RES_INTERNALERROR("commit error");<br /> -<br />- PQclear(res);<br /> + if ((!rcon) || (!(rcon->remoteTrFlag))) {<br /> + /* commit the transaction*/<br /> + res = PQexec(conn, "COMMIT");<br /> + if (PQresultStatus(res) != PGRES_COMMAND_OK)<br/> + DBLINK_RES_INTERNALERROR("commit error");<br /> + PQclear(res);<br/> + }<br /><br /> PG_RETURN_TEXT_P(GET_TEXT("OK"));<br /> }</font>
В списке pgsql-hackers по дате отправления: