diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2003-05-08 18:16:37 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2003-05-08 18:16:37 +0000 |
commit | c0a8c3ac13f84602a46ba25b9a2fd5427514f61a (patch) | |
tree | f321719251471a05a768117f35010d28076f938a /src/backend/commands | |
parent | 5e7a5c9511b65d483639dd3f7dfab7b9e92c3433 (diff) | |
download | postgresql-c0a8c3ac13f84602a46ba25b9a2fd5427514f61a.tar.gz postgresql-c0a8c3ac13f84602a46ba25b9a2fd5427514f61a.zip |
Update 3.0 protocol support to match recent agreements about how to
handle multiple 'formats' for data I/O. Restructure CommandDest and
DestReceiver stuff one more time (it's finally starting to look a bit
clean though). Code now matches latest 3.0 protocol document as far
as message formats go --- but there is no support for binary I/O yet.
Diffstat (limited to 'src/backend/commands')
-rw-r--r-- | src/backend/commands/copy.c | 28 | ||||
-rw-r--r-- | src/backend/commands/explain.c | 4 | ||||
-rw-r--r-- | src/backend/commands/portalcmds.c | 27 | ||||
-rw-r--r-- | src/backend/commands/prepare.c | 4 |
4 files changed, 28 insertions, 35 deletions
diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index ec6e771aedc..93d4b8406e8 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.197 2003/04/25 02:28:22 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.198 2003/05/08 18:16:36 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -125,8 +125,8 @@ static int server_encoding; /* * Internal communications functions */ -static void SendCopyBegin(bool binary); -static void ReceiveCopyBegin(bool binary); +static void SendCopyBegin(bool binary, int natts); +static void ReceiveCopyBegin(bool binary, int natts); static void SendCopyEnd(bool binary); static void CopySendData(void *databuf, int datasize); static void CopySendString(const char *str); @@ -143,15 +143,20 @@ static void CopyDonePeek(int c, bool pickup); * in past protocol redesigns. */ static void -SendCopyBegin(bool binary) +SendCopyBegin(bool binary, int natts) { if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 3) { /* new way */ StringInfoData buf; + int16 format = (binary ? 1 : 0); + int i; pq_beginmessage(&buf, 'H'); - pq_sendbyte(&buf, binary ? 1 : 0); + pq_sendbyte(&buf, format); /* overall format */ + pq_sendint(&buf, natts, 2); + for (i = 0; i < natts; i++) + pq_sendint(&buf, format, 2); /* per-column formats */ pq_endmessage(&buf); copy_dest = COPY_NEW_FE; copy_msgbuf = makeStringInfo(); @@ -179,15 +184,20 @@ SendCopyBegin(bool binary) } static void -ReceiveCopyBegin(bool binary) +ReceiveCopyBegin(bool binary, int natts) { if (PG_PROTOCOL_MAJOR(FrontendProtocol) >= 3) { /* new way */ StringInfoData buf; + int16 format = (binary ? 1 : 0); + int i; pq_beginmessage(&buf, 'G'); - pq_sendbyte(&buf, binary ? 1 : 0); + pq_sendbyte(&buf, format); /* overall format */ + pq_sendint(&buf, natts, 2); + for (i = 0; i < natts; i++) + pq_sendint(&buf, format, 2); /* per-column formats */ pq_endmessage(&buf); copy_dest = COPY_NEW_FE; copy_msgbuf = makeStringInfo(); @@ -682,7 +692,7 @@ DoCopy(const CopyStmt *stmt) if (pipe) { if (IsUnderPostmaster) - ReceiveCopyBegin(binary); + ReceiveCopyBegin(binary, length(attnumlist)); else copy_file = stdin; } @@ -724,7 +734,7 @@ DoCopy(const CopyStmt *stmt) if (pipe) { if (IsUnderPostmaster) - SendCopyBegin(binary); + SendCopyBegin(binary, length(attnumlist)); else copy_file = stdout; } diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 28a6e0378c8..879a7e6d682 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994-5, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.108 2003/05/06 20:26:26 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.109 2003/05/08 18:16:36 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -179,7 +179,7 @@ ExplainOneQuery(Query *query, ExplainStmt *stmt, TupOutputState *tstate) plan = planner(query, isCursor, cursorOptions); /* Create a QueryDesc requesting no output */ - queryDesc = CreateQueryDesc(query, plan, None_Receiver, NULL, NULL, + queryDesc = CreateQueryDesc(query, plan, None_Receiver, NULL, stmt->analyze); ExplainOnePlan(queryDesc, stmt, tstate); diff --git a/src/backend/commands/portalcmds.c b/src/backend/commands/portalcmds.c index 1c51a1bb89f..f9e31c3aaa1 100644 --- a/src/backend/commands/portalcmds.c +++ b/src/backend/commands/portalcmds.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/portalcmds.c,v 1.15 2003/05/06 20:26:26 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/portalcmds.c,v 1.16 2003/05/08 18:16:36 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -25,7 +25,6 @@ #include "commands/portalcmds.h" #include "executor/executor.h" -#include "executor/tstoreReceiver.h" #include "optimizer/planner.h" #include "rewrite/rewriteHandler.h" #include "tcop/pquery.h" @@ -145,7 +144,6 @@ PerformPortalFetch(FetchStmt *stmt, DestReceiver *dest, char *completionTag) { - DestReceiver *mydest = dest; Portal portal; long nprocessed; @@ -168,35 +166,21 @@ PerformPortalFetch(FetchStmt *stmt, return; } - /* - * Adjust dest if needed. MOVE wants destination None. - * - * If fetching from a binary cursor and the requested destination is - * Remote, change it to RemoteInternal. Note we do NOT change if the - * destination is RemoteExecute --- so the Execute message's format - * specification wins out over the cursor's type. - */ + /* Adjust dest if needed. MOVE wants destination None */ if (stmt->ismove) - mydest = CreateDestReceiver(None); - else if (dest->mydest == Remote && - (portal->cursorOptions & CURSOR_OPT_BINARY)) - mydest = CreateDestReceiver(RemoteInternal); + dest = None_Receiver; /* Do it */ nprocessed = PortalRunFetch(portal, stmt->direction, stmt->howMany, - mydest); + dest); /* Return command status if wanted */ if (completionTag) snprintf(completionTag, COMPLETION_TAG_BUFSIZE, "%s %ld", stmt->ismove ? "MOVE" : "FETCH", nprocessed); - - /* Clean up if we created a local destination */ - if (mydest != dest) - (mydest->destroy) (mydest); } /* @@ -329,8 +313,7 @@ PersistHoldablePortal(Portal portal) ExecutorRewind(queryDesc); /* Change the destination to output to the tuplestore */ - queryDesc->dest = CreateTuplestoreDestReceiver(portal->holdStore, - portal->holdContext); + queryDesc->dest = CreateDestReceiver(Tuplestore, portal); /* Fetch the result set into the tuplestore */ ExecutorRun(queryDesc, ForwardScanDirection, 0L); diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c index 6e16853fd78..433fd8e049e 100644 --- a/src/backend/commands/prepare.c +++ b/src/backend/commands/prepare.c @@ -10,7 +10,7 @@ * Copyright (c) 2002-2003, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/prepare.c,v 1.17 2003/05/06 21:51:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/prepare.c,v 1.18 2003/05/08 18:16:36 tgl Exp $ * *------------------------------------------------------------------------- */ @@ -528,7 +528,7 @@ ExplainExecuteQuery(ExplainStmt *stmt, TupOutputState *tstate) } /* Create a QueryDesc requesting no output */ - qdesc = CreateQueryDesc(query, plan, None_Receiver, NULL, + qdesc = CreateQueryDesc(query, plan, None_Receiver, paramLI, stmt->analyze); ExplainOnePlan(qdesc, stmt, tstate); |