]> 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:12 +0000 (20:00 +0100)
committerAndrew Gierth <rhodiumtoad@postgresql.org>
Thu, 23 Aug 2018 20:33:55 +0000 (21:33 +0100)
commitad871a9d78841592938a0b24cc961fd1d4185607
treef9049fded8395715073f56ae1bd25a1c8beb2d11
parent6120f2234d7699849a429e5881fdb242fb6b941e
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/bin/psql/psqlscan.l
src/interfaces/ecpg/preproc/pgc.l