]> granicus.if.org Git - postgresql/commit
Reduce an unnecessary O(N^3) loop in lexer.
authorAndrew Gierth <rhodiumtoad@postgresql.org>
Thu, 23 Aug 2018 19:00:50 +0000 (20:00 +0100)
committerAndrew Gierth <rhodiumtoad@postgresql.org>
Thu, 23 Aug 2018 20:43:55 +0000 (21:43 +0100)
commit2dbfbd630bc952b5e6f7e484f5538abad499533f
treead3214957e21e2ab02811e78dd126f936b62e490
parent6953daf08e6b1ef333758f6cda54de228212f12e
Reduce an unnecessary O(N^3) loop in lexer.

The lexer's handling of operators contained an O(N^3) hazard when
dealing with long strings of + or - characters; it seems hard to
prevent this case from being O(N^2), but the additional N multiplier
was not needed.

Backpatch all the way since this has been there since 7.x, and it
presents at least a mild hazard in that trying to do Bind, PREPARE or
EXPLAIN on a hostile query could take excessive time (without
honouring cancels or timeouts) even if the query was never executed.
src/backend/parser/scan.l
src/fe_utils/psqlscan.l
src/interfaces/ecpg/preproc/pgc.l