• Tom Lane's avatar
    Improve pqexpbuffer.c to use modern vsnprintf implementations efficiently. · 9f9d9b51
    Tom Lane authored
    When using a C99-compliant vsnprintf, we can use its report of the required
    buffer size to avoid making multiple loops through the formatting logic.
    This is similar to the changes recently made in stringinfo.c, but we can't
    use psprintf.c here because in libpq we don't want to exit() on error.
    (The behavior pqexpbuffer.c has historically used is to mark the
    PQExpBuffer as "broken", ie empty, if it runs into any fatal problem.)
    
    To avoid duplicating code more than necessary, I refactored
    printfPQExpBuffer and appendPQExpBuffer to share a subroutine that's
    very similar to psprintf.c's pvsnprintf in spirit.
    9f9d9b51
pqexpbuffer.c 9.95 KB