diff options
| author | Bruce Momjian | 1998-05-06 23:51:16 +0000 |
|---|---|---|
| committer | Bruce Momjian | 1998-05-06 23:51:16 +0000 |
| commit | edbd51395c425795b3ccacbc9d26044beb1a1277 (patch) | |
| tree | 3933022b5410589db1a4d1273174b5daa7a66931 /src/backend | |
| parent | 2e12331d42610e6489de85b5ca18644c0bf11f14 (diff) | |
What I've done:
1. Rewritten libpq to allow asynchronous clients.
2. Implemented client side of cancel protocol in library,
and patched psql.c to send a cancel request upon SIGINT. The
backend doesn't notice it yet :-(
3. Implemented 'Z' protocol message addition and renaming of
copy in/out start messages. These are implemented conditionally,
ie, the client protocol version is checked; so the code should
still work with 1.0 clients.
4. Revised protocol and libpq sgml documents (don't have an SGML
compiler, though, so there may be some markup glitches here).
What remains to be done:
1. Implement addition of atttypmod field to RowDescriptor messages.
The client-side code is there but ifdef'd out. I have no idea
what to change on the backend side. The field should be sent
only if protocol >= 2.0, of course.
2. Implement backend response to cancel requests received as OOB
messages. (This prolly need not be conditional on protocol
version; just do it if you get SIGURG.)
3. Update libpq.3. (I'm hoping this can be generated mechanically
from libpq.sgml... if not, will do it by hand.) Is there any
other doco to fix?
4. Update non-libpq interfaces as necessary. I patched libpgtcl
so that it would compile, but haven't tested it. Dunno what
needs to be done with the other interfaces.
Have at it!
Tom Lane
Diffstat (limited to 'src/backend')
| -rw-r--r-- | src/backend/commands/async.c | 13 | ||||
| -rw-r--r-- | src/backend/tcop/dest.c | 107 | ||||
| -rw-r--r-- | src/backend/tcop/fastpath.c | 3 | ||||
| -rw-r--r-- | src/backend/tcop/postgres.c | 12 |
4 files changed, 68 insertions, 67 deletions
diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c index 551c3bad3fd..fcf02b2e4bf 100644 --- a/src/backend/commands/async.c +++ b/src/backend/commands/async.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.31 1998/04/27 04:05:08 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.32 1998/05/06 23:49:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,8 +20,7 @@ * end of commit), * 2.a If the process is the same as the backend process that issued * notification (we are notifying something that we are listening), - * signal the corresponding frontend over the comm channel using the - * out-of-band channel. + * signal the corresponding frontend over the comm channel. * 2.b For all other listening processes, we send kill(2) to wake up * the listening backend. * 3. Upon receiving a kill(2) signal from another backend process notifying @@ -30,7 +29,7 @@ * 3.a We are sleeping, wake up and signal our frontend. * 3.b We are in middle of another transaction, wait until the end of * of the current transaction and signal our frontend. - * 4. Each frontend receives this notification and prcesses accordingly. + * 4. Each frontend receives this notification and processes accordingly. * * -- jw, 12/28/93 * @@ -547,12 +546,6 @@ Async_UnlistenOnExit(int code, /* from exitpg */ * Results: * XXX * - * Side effects: - * - * We make use of the out-of-band channel to transmit the - * notification to the front end. The actual data transfer takes - * place at the front end's request. - * * -------------------------------------------------------------- */ GlobalMemory notifyContext = NULL; diff --git a/src/backend/tcop/dest.c b/src/backend/tcop/dest.c index 94d9eaad627..74da434f364 100644 --- a/src/backend/tcop/dest.c +++ b/src/backend/tcop/dest.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.17 1998/02/26 04:36:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.18 1998/05/06 23:49:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,7 +15,8 @@ * INTERFACE ROUTINES * BeginCommand - prepare destination for tuples of the given type * EndCommand - tell destination that no more tuples will arrive - * NullCommand - tell dest that the last of a query sequence was processed + * NullCommand - tell dest that an empty query string was recognized + * ReadyForQuery - tell dest that we are ready for a new query * * NOTES * These routines do the appropriate work before and after @@ -115,16 +116,10 @@ EndCommand(char *commandTag, CommandDest dest) sprintf(buf, "%s%s", commandTag, CommandInfo); CommandInfo[0] = 0; pq_putstr(buf); - pq_flush(); break; case Local: case Debug: - break; - case CopyEnd: - pq_putnchar("Z", 1); - pq_flush(); - break; case None: default: break; @@ -139,28 +134,37 @@ EndCommand(char *commandTag, CommandDest dest) * * COPY rel FROM stdin * + * NOTE: the message code letters are changed at protocol version 2.0 + * to eliminate possible confusion with data tuple messages. */ void SendCopyBegin(void) { - pq_putnchar("B", 1); -/* pq_putint(0, 4); */ - pq_flush(); + if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 2) + pq_putnchar("H", 1); /* new way */ + else + pq_putnchar("B", 1); /* old way */ } void ReceiveCopyBegin(void) { - pq_putnchar("D", 1); -/* pq_putint(0, 4); */ + if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 2) + pq_putnchar("G", 1); /* new way */ + else + pq_putnchar("D", 1); /* old way */ + /* We *must* flush here to ensure FE knows it can send. */ pq_flush(); } /* ---------------- - * NullCommand - tell dest that the last of a query sequence was processed + * NullCommand - tell dest that an empty query string was recognized * - * Necessary to implement the hacky FE/BE interface to handle - * multiple-return queries. + * In FE/BE protocol version 1.0, this hack is necessary to support + * libpq's crufty way of determining whether a multiple-command + * query string is done. In protocol 2.0 it's probably not really + * necessary to distinguish empty queries anymore, but we still do it + * for backwards compatibility with 1.0. * ---------------- */ void @@ -168,46 +172,46 @@ NullCommand(CommandDest dest) { switch (dest) { - case RemoteInternal: - case Remote: + case RemoteInternal: + case Remote: { -#if 0 - - /* - * Do any asynchronous notification. If front end wants - * to poll, it can send null queries to call this - * function. - */ - PQNotifyList *nPtr; - MemoryContext orig; - - if (notifyContext == NULL) - { - notifyContext = CreateGlobalMemory("notify"); - } - orig = MemoryContextSwitchTo((MemoryContext) notifyContext); - - for (nPtr = PQnotifies(); - nPtr != NULL; - nPtr = (PQNotifyList *) SLGetSucc(&nPtr->Node)) - { - pq_putnchar("A", 1); - pq_putint(0, sizeof(int4)); - pq_putstr(nPtr->relname); - pq_putint(nPtr->be_pid, sizeof(nPtr->be_pid)); - PQremoveNotify(nPtr); - } - pq_flush(); - PQcleanNotify();/* garbage collect */ - MemoryContextSwitchTo(orig); -#endif /* ---------------- - * tell the fe that the last of the queries has finished + * tell the fe that we saw an empty query string * ---------------- */ -/* pq_putnchar("I", 1); */ pq_putstr("I"); - /* pq_putint(0, 4); */ + } + break; + + case Local: + case Debug: + case None: + default: + break; + } +} + +/* ---------------- + * ReadyForQuery - tell dest that we are ready for a new query + * + * The ReadyForQuery message is sent in protocol versions 2.0 and up + * so that the FE can tell when we are done processing a query string. + * + * Note that by flushing the stdio buffer here, we can avoid doing it + * most other places and thus reduce the number of separate packets sent. + * ---------------- + */ +void +ReadyForQuery(CommandDest dest) +{ + switch (dest) + { + case RemoteInternal: + case Remote: + { + if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 2) + pq_putnchar("Z", 1); + /* Flush output at end of cycle in any case. */ pq_flush(); } break; @@ -264,7 +268,6 @@ BeginCommand(char *pname, * send fe info on tuples we're about to send * ---------------- */ - pq_flush(); pq_putnchar("P", 1);/* new portal.. */ pq_putstr(pname); /* portal name */ diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c index 9a59c43db56..7ec50debf8a 100644 --- a/src/backend/tcop/fastpath.c +++ b/src/backend/tcop/fastpath.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.16 1998/04/26 04:07:22 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.17 1998/05/06 23:50:10 momjian Exp $ * * NOTES * This cruft is the server side of PQfn. @@ -113,7 +113,6 @@ SendFunctionResult(Oid fid, /* function id */ } pq_putnchar("0", 1); - pq_flush(); } /* diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index efba35f2404..87e1bf9fe56 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.67 1998/02/26 04:36:31 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.68 1998/05/06 23:50:19 momjian Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -1302,7 +1302,7 @@ PostgresMain(int argc, char *argv[]) if (IsUnderPostmaster == false) { puts("\nPOSTGRES backend interactive interface"); - puts("$Revision: 1.67 $ $Date: 1998/02/26 04:36:31 $"); + puts("$Revision: 1.68 $ $Date: 1998/05/06 23:50:19 $"); } /* ---------------- @@ -1317,6 +1317,12 @@ PostgresMain(int argc, char *argv[]) for (;;) { /* ---------------- + * (0) tell the frontend we're ready for a new query. + * ---------------- + */ + ReadyForQuery(Remote); + + /* ---------------- * (1) read a command. * ---------------- */ @@ -1391,8 +1397,8 @@ PostgresMain(int argc, char *argv[]) * ---------------- */ case 'X': - IsEmptyQuery = true; pq_close(); + exitpg(0); break; default: |
