Final libpq patch?

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Abhijit Menon-Sen <ams(at)oryx(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, david(at)kineticode(dot)com
Subject: Final libpq patch?
Date: 2004-10-18 18:16:49
Message-ID: 200410181816.i9IIGnq16187@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers pgsql-patches


Here is a mega-patch that merges in your four previous patches. Is this
ready to be applied? Making libpq changes during beta is risky so we
had better be careful.

I have also attached your pgtest.c file.

---------------------------------------------------------------------------

Abhijit Menon-Sen wrote:
> At 2004-10-16 18:41:05 -0400, tgl(at)sss(dot)pgh(dot)pa(dot)us wrote:
> >
> > I think the cleanest solution is probably to add a state flag indicating
> > whether ParseComplete should generate a PGresult or not.
>
> Like the appended (incremental) patch?
>
> (I didn't think this would work, because I thought libpq would allow you
> to send multiple queries before trying to read results. But you said it
> didn't support that, so...)
>
> -- ams
>
> --- libpq-int.h.1~ 2004-10-18 17:42:13.175759981 +0530
> +++ libpq-int.h 2004-10-18 17:43:40.105986570 +0530
> @@ -269,6 +269,8 @@
> * nonblock sending semantics */
> bool ext_query; /* was our last query sent with extended
> * query protocol? */
> + bool sent_prepare; /* was our last Parse message sent with
> + * PQprepare? */
> char copy_is_binary; /* 1 = copy binary, 0 = copy text */
> int copy_already_done; /* # bytes already returned in
> * COPY OUT */
>
> --- fe-exec.c.2~ 2004-10-18 17:47:55.540189274 +0530
> +++ fe-exec.c 2004-10-18 17:48:30.119038902 +0530
> @@ -686,6 +686,7 @@
> goto sendFailed;
>
> conn->ext_query = true;
> + conn->sent_prepare = true;
> if (pqFlush(conn) < 0)
> goto sendFailed;
> conn->asyncStatus = PGASYNC_BUSY;
>
> --- fe-protocol3.c.2~ 2004-10-18 17:44:06.616198123 +0530
> +++ fe-protocol3.c 2004-10-18 17:46:34.431656569 +0530
> @@ -220,10 +220,13 @@
> conn->asyncStatus = PGASYNC_READY;
> break;
> case '1': /* Parse Complete */
> - if (conn->result == NULL)
> - conn->result = PQmakeEmptyPGresult(conn,
> - PGRES_COMMAND_OK);
> - conn->asyncStatus = PGASYNC_READY;
> + if (conn->sent_prepare) {
> + if (!conn->result)
> + conn->result = PQmakeEmptyPGresult(conn,
> + PGRES_COMMAND_OK);
> + conn->asyncStatus = PGASYNC_READY;
> + conn->sent_prepare = false;
> + }
> break;
> case '2': /* Bind Complete */
> case '3': /* Close Complete */
>
> --- libpq-fe.h.2~ 2004-10-18 17:55:40.632064120 +0530
> +++ libpq-fe.h 2004-10-18 17:56:26.501634328 +0530
> @@ -312,9 +312,9 @@
> int resultFormat);
>
> /* Interface for multiple-result or asynchronous queries */
> -extern PGresult *PQsendPrepare(PGconn *conn, const char *stmtName,
> - const char *query, int nParams,
> - const Oid *paramTypes);
> +extern int PQsendPrepare(PGconn *conn, const char *stmtName,
> + const char *query, int nParams,
> + const Oid *paramTypes);
> extern int PQsendQuery(PGconn *conn, const char *query);
> extern int PQsendQueryParams(PGconn *conn,
> const char *command,
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faqs/FAQ.html
>

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

Attachment Content-Type Size
unknown_filename text/plain 9.0 KB
unknown_filename text/plain 1.7 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2004-10-18 18:24:23 Re: [PATCHES] Open Items
Previous Message Andrew Dunstan 2004-10-18 18:15:37 confusing log messages on pg_ctl -w start

Browse pgsql-patches by date

  From Date Subject
Next Message Magnus Hagander 2004-10-18 18:24:23 Re: [PATCHES] Open Items
Previous Message Bruce Momjian 2004-10-18 17:57:40 Re: Win32 psql fix