Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteef5c4f

Browse files
committed
pq_getstring doesn't go through pq_getbyte anymore, for better performance.
1 parent32c6c99 commiteef5c4f

File tree

1 file changed

+24
-7
lines changed

1 file changed

+24
-7
lines changed

‎src/backend/libpq/pqcomm.c

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
3030
* Portions Copyright (c) 1994, Regents of the University of California
3131
*
32-
*$Id: pqcomm.c,v 1.130 2002/04/03 00:44:27 tgl Exp $
32+
*$Id: pqcomm.c,v 1.131 2002/04/20 23:35:43 petere Exp $
3333
*
3434
*-------------------------------------------------------------------------
3535
*/
@@ -569,20 +569,37 @@ pq_getbytes(char *s, size_t len)
569569
int
570570
pq_getstring(StringInfos)
571571
{
572-
intc;
572+
inti;
573573

574574
/* Reset string to empty */
575575
s->len=0;
576576
s->data[0]='\0';
577577

578578
/* Read until we get the terminating '\0' */
579-
while ((c=pq_getbyte())!=EOF&&c!='\0')
580-
appendStringInfoCharMacro(s,c);
579+
for(;;)
580+
{
581+
while (PqRecvPointer >=PqRecvLength)
582+
{
583+
if (pq_recvbuf())/* If nothing in buffer, then recv some */
584+
returnEOF;/* Failed to recv data */
585+
}
581586

582-
if (c==EOF)
583-
returnEOF;
587+
for (i=PqRecvPointer;i<PqRecvLength;i++)
588+
if (PqRecvBuffer[i]=='\0')
589+
{
590+
/* does not copy the \0 */
591+
appendBinaryStringInfo(s,PqRecvBuffer+PqRecvPointer,
592+
i-PqRecvPointer);
593+
PqRecvPointer+=i+1;
594+
return0;
595+
}
584596

585-
return0;
597+
/* If we're here we haven't got the \0 in the buffer yet. */
598+
599+
appendBinaryStringInfo(s,PqRecvBuffer+PqRecvPointer,
600+
PqRecvLength-PqRecvPointer);
601+
PqRecvPointer=PqRecvLength;
602+
}
586603
}
587604

588605

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp