Hi, There are some codes in libpq/backend communication that seem very
strange to me.
in backend/access/common/printtup.c printtup():
pq_putint(strlen(outputstr) + VARHDRSZ, VARHDRSZ);
pq_putnchar(outputstr, strlen(outputstr));
the first line above sends the data length and second actually sends
the data. My question is why the data length is "strlen(outputstr) +
VARHDRSZ", not just strlen(outputstr). After some investigation, I
found a code fragment that might be an answer. In
interfaces/libpq/fe-exec.c getTuple():
/* get the value length (the first four bytes are for length) */
pqGetInt(&vlen, 4, pfin, pfdebug);
if (binary == 0)
{
vlen = vlen - 4;
}
Woh! The misterious 4-byte has been subtracted by libpq! Seems they
have been remained just for historical reasons.
--
Tatsuo Ishii
t-ishii@sra.co.jp