Reduce an unnecessary O(N^3) loop in lexer.
authorAndrew Gierth
Thu, 23 Aug 2018 18:59:38 +0000 (19:59 +0100)
committerAndrew Gierth
Thu, 23 Aug 2018 20:33:38 +0000 (21:33 +0100)
commit6c5ed6836340a801d522f620dceca1469b5bfbbc
treed994b1fc40dd7783276b0ceed63bd257f1438c29
parent788ae09f4a9560c344a0c8457ffb66bba42be0a7
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