1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-10 17:42:29 +03:00

Commit the bulk of Mike Ansley's long-query changes in the

backend.  Still much left to do.
This commit is contained in:
Tom Lane
1999-08-31 04:26:40 +00:00
parent ab5cafa5d3
commit e25e6a6dc3
6 changed files with 67 additions and 109 deletions

View File

@@ -28,7 +28,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pqcomm.c,v 1.81 1999/07/23 03:00:10 tgl Exp $
* $Id: pqcomm.c,v 1.82 1999/08/31 04:26:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -526,38 +526,32 @@ pq_getbytes(char *s, size_t len)
/* --------------------------------
* pq_getstring - get a null terminated string from connection
*
* The return value is placed in an expansible StringInfo.
* Note that space allocation comes from the current memory context!
*
* NOTE: this routine does not do any MULTIBYTE conversion,
* even though it is presumably useful only for text, because
* no code in this module should depend on MULTIBYTE mode.
* See pq_getstr in pqformat.c for that.
*
* FIXME: we ought to use an expansible StringInfo buffer,
* rather than dropping data if the message is too long.
*
* returns 0 if OK, EOF if trouble
* --------------------------------
*/
int
pq_getstring(char *s, size_t len)
pq_getstring(StringInfo s)
{
int c;
/*
* Keep on reading until we get the terminating '\0', discarding any
* bytes we don't have room for.
*/
/* Reset string to empty */
s->len = 0;
s->data[0] = '\0';
/* Read until we get the terminating '\0' */
while ((c = pq_getbyte()) != EOF && c != '\0')
{
if (len > 1)
{
*s++ = c;
len--;
}
appendStringInfoChar(s, c);
}
*s = '\0';
if (c == EOF)
return EOF;

View File

@@ -15,7 +15,7 @@
*
* Copyright (c) 1994, Regents of the University of California
*
* $Id: pqformat.c,v 1.7 1999/07/17 20:17:03 momjian Exp $
* $Id: pqformat.c,v 1.8 1999/08/31 04:26:37 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -290,37 +290,30 @@ pq_getint(int *result, int b)
/* --------------------------------
* pq_getstr - get a null terminated string from connection
*
* FIXME: we ought to use an expansible StringInfo buffer,
* rather than dropping data if the message is too long.
* The return value is placed in an expansible StringInfo.
* Note that space allocation comes from the current memory context!
*
* returns 0 if OK, EOF if trouble
* --------------------------------
*/
int
pq_getstr(char *s, int maxlen)
pq_getstr(StringInfo s)
{
int c;
#ifdef MULTIBYTE
char *p;
#endif
c = pq_getstring(s, maxlen);
c = pq_getstring(s);
#ifdef MULTIBYTE
p = (char *) pg_client_to_server((unsigned char *) s, strlen(s));
if (p != s) /* actual conversion has been done? */
p = (char *) pg_client_to_server((unsigned char *) s->data, s->len);
if (p != s->data) /* actual conversion has been done? */
{
int newlen = strlen(p);
if (newlen < maxlen)
strcpy(s, p);
else
{
strncpy(s, p, maxlen);
s[maxlen - 1] = '\0';
}
/* reset s to empty, and append the new string p */
s->len = 0;
s->data[0] = '\0';
appendBinaryStringInfo(s, p, strlen(p));
}
#endif