|
|
|
@ -133,30 +133,27 @@ pq_sendbytes(StringInfo buf, const void *data, int datalen) |
|
|
|
|
* pq_sendcountedtext - append a counted text string (with character set conversion) |
|
|
|
|
* |
|
|
|
|
* The data sent to the frontend by this routine is a 4-byte count field |
|
|
|
|
* followed by the string. The count includes itself or not, as per the |
|
|
|
|
* countincludesself flag (pre-3.0 protocol requires it to include itself). |
|
|
|
|
* The passed text string need not be null-terminated, and the data sent |
|
|
|
|
* to the frontend isn't either. |
|
|
|
|
* followed by the string. The count does not include itself, as required by |
|
|
|
|
* protocol version 3.0. The passed text string need not be null-terminated, |
|
|
|
|
* and the data sent to the frontend isn't either. |
|
|
|
|
* -------------------------------- |
|
|
|
|
*/ |
|
|
|
|
void |
|
|
|
|
pq_sendcountedtext(StringInfo buf, const char *str, int slen, |
|
|
|
|
bool countincludesself) |
|
|
|
|
pq_sendcountedtext(StringInfo buf, const char *str, int slen) |
|
|
|
|
{ |
|
|
|
|
int extra = countincludesself ? 4 : 0; |
|
|
|
|
char *p; |
|
|
|
|
|
|
|
|
|
p = pg_server_to_client(str, slen); |
|
|
|
|
if (p != str) /* actual conversion has been done? */ |
|
|
|
|
{ |
|
|
|
|
slen = strlen(p); |
|
|
|
|
pq_sendint32(buf, slen + extra); |
|
|
|
|
pq_sendint32(buf, slen); |
|
|
|
|
appendBinaryStringInfoNT(buf, p, slen); |
|
|
|
|
pfree(p); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
pq_sendint32(buf, slen + extra); |
|
|
|
|
pq_sendint32(buf, slen); |
|
|
|
|
appendBinaryStringInfoNT(buf, str, slen); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|