]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Re-simplify management of inStart in pqParseInput3's subroutines.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 11 Mar 2021 19:43:45 +0000 (14:43 -0500)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 11 Mar 2021 19:43:45 +0000 (14:43 -0500)
commit56defbdd0f4e152545c50619385902ed060dca61
tree493dce36174ff310208244d4d65bfc1bf710177e
parent1cc33ab95ccea0e1e36651d57ca1c8088f9994c2
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