Re: appendPQExpBufferVA vs appendStringInfoVA - Mailing list pgsql-hackers

From David Rowley
Subject Re: appendPQExpBufferVA vs appendStringInfoVA
Date
Msg-id CAApHDvqkNZ3s-0dxGQtaOx37mqfKeHp7s_LB1=oBuSJGdy=Yzw@mail.gmail.com
Whole thread Raw
In response to Re: appendPQExpBufferVA vs appendStringInfoVA  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: appendPQExpBufferVA vs appendStringInfoVA
List pgsql-hackers
On Sat, Nov 2, 2013 at 2:27 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
David Rowley <dgrowleyml@gmail.com> writes:
> Tom commited some changes to appendStringInfoVA a few weeks ago which
> allows it to return the required buffer size if the current buffer is not
> big enough.

> On looking at appendPQExpBufferVA I'm thinking it would be nice if it could
> make use of the new pvsnprintf function to bring the same potential
> performance improvement in to there too.

Uh ... it does contain pretty much the same algorithm now.  We can't
simply use pvsnprintf there because exit-on-error is no good for
libpq's purposes, so unless we want to rethink that, a certain
amount of code duplication is unavoidable.  But they both understand
about C99 vsnprintf semantics now.


I only just noticed the changes you made to appendPQExpBufferVA(). 
I had wondered if making pvsnprintf return int instead of size_t and having it return -1 if there are problems, then letting the caller deal with those, but I'm starting to see why you did it the way you did it... There's also quite a few subtle differences with things like max allocation size that would have to be dealt with differently I guess.

I'm low on ideas on how to improve things much around here for now, but for what it's worth, I did create a patch which changes unnecessary calls to appendPQExpBuffer() into calls to appendPQExpBufferStr() similar to the recent one for appendStringInfo and appendStringInfoString. 


Regards

David Rowley
  

                        regards, tom lane

Attachment

pgsql-hackers by date:

Previous
From: Atri Sharma
Date:
Subject: Re: Handle LIMIT/OFFSET before select clause (was: Feature request: optimizer improvement)
Next
From: Alvaro Herrera
Date:
Subject: Re: Record comparison compiler warning