diff options
author | Pavan Deolasee | 2016-03-03 11:40:41 +0000 |
---|---|---|
committer | Pavan Deolasee | 2016-10-18 10:00:19 +0000 |
commit | f2efdfc1328ac83dfaf586e807e3aacc85e871da (patch) | |
tree | bb02a86c617681d4496ffb9e3b707ee4fbeb3806 | |
parent | 89388618074bd57888e0ff838479f7e971d05e47 (diff) |
Honour client's request for binary data transfer.
When coordinator gets data from the datanode, it always gets it in TEXT mode.
But if the client has requested binary transfer of the data, then it must not
forward the data received from the datanode as it is. Rather it must send each
column in the desired format.
While this should fix the JDBC or libpq issue with binary data transfer, we
should really see if the coordinator to datanode communication can also use
binary mode for performance reason. But thats a separate patch.
-rw-r--r-- | src/backend/access/common/printtup.c | 23 |
1 files changed, 19 insertions, 4 deletions
diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 199e73fab9..31712da34b 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -326,23 +326,38 @@ printtup(TupleTableSlot *slot, DestReceiver *self) StringInfoData buf; int natts = typeinfo->natts; int i; + bool binary = false; + + /* Set or update my derived attribute info, if needed */ + if (myState->attrinfo != typeinfo || myState->nattrs != natts) + printtup_prepare_info(myState, typeinfo, natts); #ifdef PGXC /* + * The datanodes would have sent all attributes in TEXT form. But + * if the client has asked for any attribute to be sent in a binary format, + * then we must decode the datarow and send every attribute in the format + * that the client has asked for. Otherwise its ok to just forward the + * datarow as it is + */ + for (i = 0; i < natts; ++i) + { + PrinttupAttrInfo *thisState = myState->myinfo + i; + if (thisState->format != 0) + binary = true; + } + /* * If we are having DataRow-based tuple we do not have to encode attribute * values, just send over the DataRow message as we received it from the * Datanode */ - if (slot->tts_datarow) + if (slot->tts_datarow && !binary) { pq_putmessage('D', slot->tts_datarow->msg, slot->tts_datarow->msglen); return; } #endif - /* Set or update my derived attribute info, if needed */ - if (myState->attrinfo != typeinfo || myState->nattrs != natts) - printtup_prepare_info(myState, typeinfo, natts); /* Make sure the tuple is fully deconstructed */ slot_getallattrs(slot); |