Re: repeated pointless memmove() calls in pqReadData() - Mailing list pgsql-bugs

From Tom Lane
Subject Re: repeated pointless memmove() calls in pqReadData()
Date
Msg-id 12791.991064040@sss.pgh.pa.us
Whole thread Raw
In response to repeated pointless memmove() calls in pqReadData()  (Brent Ewing <bge@u.washington.edu>)
List pgsql-bugs
Brent Ewing <bge@u.washington.edu> writes:
> Second, I am puzzled by repeated, apparently pointless calls to memmove() in
> the function pqReadData, which is in `src/interfaces/libpq/fe-misc.c'.

Hm.  That was never a problem back when we had an 8K row-size limit ;-)
but I can see that it might get to be an issue for retrieving huge rows.
Thanks for the suggestion.  I've applied the attached patch to current
sources.

            regards, tom lane


*** fe-misc.c~    Sat Mar 31 18:13:30 2001
--- fe-misc.c    Mon May 28 11:29:51 2001
***************
*** 400,413 ****
      /* Left-justify any data in the buffer to make room */
      if (conn->inStart < conn->inEnd)
      {
!         memmove(conn->inBuffer, conn->inBuffer + conn->inStart,
!                 conn->inEnd - conn->inStart);
!         conn->inEnd -= conn->inStart;
!         conn->inCursor -= conn->inStart;
!         conn->inStart = 0;
      }
      else
          conn->inStart = conn->inCursor = conn->inEnd = 0;

      /*
       * If the buffer is fairly full, enlarge it. We need to be able to
--- 400,419 ----
      /* Left-justify any data in the buffer to make room */
      if (conn->inStart < conn->inEnd)
      {
!         if (conn->inStart > 0)
!         {
!             memmove(conn->inBuffer, conn->inBuffer + conn->inStart,
!                     conn->inEnd - conn->inStart);
!             conn->inEnd -= conn->inStart;
!             conn->inCursor -= conn->inStart;
!             conn->inStart = 0;
!         }
      }
      else
+     {
+         /* buffer is logically empty, reset it */
          conn->inStart = conn->inCursor = conn->inEnd = 0;
+     }

      /*
       * If the buffer is fairly full, enlarge it. We need to be able to

pgsql-bugs by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: Compilation --with-python fails on Solaris 8
Next
From: Tom Lane
Date:
Subject: Re: SQL update statements are failing if submitted in sequence on same connection