Re-simplify management of inStart in pqParseInput3's subroutines.
authorTom Lane <[email protected]>
Thu, 11 Mar 2021 19:43:45 +0000 (14:43 -0500)
committerTom Lane <[email protected]>
Thu, 11 Mar 2021 19:43:45 +0000 (14:43 -0500)
commitd2be6cdc55ad0eb0fa019a453491e1410c5315e8
treee4088a6094df4e9d8856e5394ce11ddad5779ff4
parent338b9a0d4c999a6dda7797edf0eba764399d3866
Re-simplify management of inStart in pqParseInput3's subroutines.

Commit 92785dac2 copied some logic related to advancement of inStart
from pqParseInput3 into getRowDescriptions and getAnotherTuple,
because it wanted to allow user-defined row processor callbacks to
potentially longjmp out of the library, and inStart would have to be
updated before that happened to avoid an infinite loop.  We later
decided that that API was impossibly fragile and reverted it, but
we didn't undo all of the related code changes, and this bit of
messiness survived.  Undo it now so that there's just one place in
pqParseInput3's processing where inStart is advanced; this will
simplify addition of better tracing support.

getParamDescriptions had grown similar processing somewhere along
the way (not in 92785dac2; I didn't track down just when), but it's
actually buggy because its handling of corrupt-message cases seems to
have been copied from the v2 logic where we lacked a known message
length.  The cases where we "goto not_enough_data" should not simply
return EOF, because then we won't consume the message, potentially
creating an infinite loop.  That situation now represents a
definitively corrupt message, and we should report it as such.

Although no field reports of getParamDescriptions getting stuck in
a loop have been seen, it seems appropriate to back-patch that fix.
I chose to back-patch all of this to keep the logic looking more alike
in supported branches.

Discussion: https://postgr.es/m/2217283.1615411989@sss.pgh.pa.us
src/interfaces/libpq/fe-protocol3.c