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
Список
Дерево обсуждения
Patching dblink.c to avoid warning about open transaction Jonathan Beit-Aharon <jbeitaharon@intrusic.com>
Re: Patching dblink.c to avoid warning about open transaction Tom Lane <tgl@sss.pgh.pa.us>
Re: Patching dblink.c to avoid warning about open transaction Bruce Momjian <pgman@candle.pha.pa.us>
Re: Patching dblink.c to avoid warning about open transaction Bruce Momjian <pgman@candle.pha.pa.us>
Re: Patching dblink.c to avoid warning about open transaction Joe Conway <mail@joeconway.com>
Re: Patching dblink.c to avoid warning about open transaction Jonathan Beit-Aharon <jbeitaharon@intrusic.com>
Hi,
I'm not a member of this list (yet), so please CC me on responses and discussion.

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.

I hope someone will find it useful,
Jonathan


--- dblink.c    Sat Jan  1 00:43:05 2005
+++ /home/jbeitaharon/dev/third/postgreSQL/contrib/dblink/dblink.c      Thu Sep 22 16:10:20 2005
@@ -329,12 +329,16 @@

        if (!conn)
                DBLINK_CONN_NOT_AVAIL;
+
+       if (rcon)
+               rcon->remoteTrFlag = (PQtransactionStatus(conn) != PQTRANS_IDLE);

-       res = PQexec(conn, "BEGIN");
-       if (PQresultStatus(res) != PGRES_COMMAND_OK)
-               DBLINK_RES_INTERNALERROR("begin error");
-
-       PQclear(res);
+       if ((!rcon) || (!(rcon->remoteTrFlag))) {
+               res = PQexec(conn, "BEGIN");
+               if (PQresultStatus(res) != PGRES_COMMAND_OK)
+                       DBLINK_RES_INTERNALERROR("begin error");
+               PQclear(res);
+       }

        appendStringInfo(str, "DECLARE %s CURSOR FOR %s", curname, sql);
        res = PQexec(conn, str->data);
@@ -424,12 +428,13 @@

        PQclear(res);

-       /* commit the transaction */
-       res = PQexec(conn, "COMMIT");
-       if (PQresultStatus(res) != PGRES_COMMAND_OK)
-               DBLINK_RES_INTERNALERROR("commit error");
-
-       PQclear(res);
+       if ((!rcon) || (!(rcon->remoteTrFlag))) {
+               /* commit the transaction */
+               res = PQexec(conn, "COMMIT");
+               if (PQresultStatus(res) != PGRES_COMMAND_OK)
+                       DBLINK_RES_INTERNALERROR("commit error");
+               PQclear(res);
+       }

        PG_RETURN_TEXT_P(GET_TEXT("OK"));
 }
В списке pgsql-hackers по дате отправления
От: Bruce Momjian
Дата:
От: Ron Peacetree
Дата:
FAQ