Skip to content
  • Tor Didriksen's avatar
    d18c716d
    Bug#14744160 LIMIT PARSER MEMORY USAGE · d18c716d
    Tor Didriksen authored
    Problem:
    We currently have no way of limiting memory consumption when parsing
    SQL queries. With a large value for max_allowed_packet it is easy to
    construct queries which require several gigabytes of memory during
    parsing.
    
    Solution:
    We build on the MEM_ROOT extensions developed for bug
    Bug#17769777 : EXCESSIVE MEMORY CONSUMPTION WITH MANY AND / BETWEEN ITEMS
    
    Introduce a maximum capacity for the MEM_ROOT used by the parser,
    and raise an error if this capacity is exceeded during parsing.
    If the lexer sees a ER_CAPACITY_EXCEEDED error, it returns ABORT_SYM
    and parsing of the current query is terminated.
    
    The memory capacity can be set with the new system variable
    'parser_max_mem_size'. By default there is no limit, i.e. the variable is
    set to 4294967295 bytes on 32bit systems, 18446744073709551615ULL
    on 64bit systems. The database administrator may set
    @@global.parser_max_mem_size to a lower value, in order to protect
    against out-of-memory situations caused by parsing long/complex SQL queries.
    d18c716d
    Bug#14744160 LIMIT PARSER MEMORY USAGE
    Tor Didriksen authored
    Problem:
    We currently have no way of limiting memory consumption when parsing
    SQL queries. With a large value for max_allowed_packet it is easy to
    construct queries which require several gigabytes of memory during
    parsing.
    
    Solution:
    We build on the MEM_ROOT extensions developed for bug
    Bug#17769777 : EXCESSIVE MEMORY CONSUMPTION WITH MANY AND / BETWEEN ITEMS
    
    Introduce a maximum capacity for the MEM_ROOT used by the parser,
    and raise an error if this capacity is exceeded during parsing.
    If the lexer sees a ER_CAPACITY_EXCEEDED error, it returns ABORT_SYM
    and parsing of the current query is terminated.
    
    The memory capacity can be set with the new system variable
    'parser_max_mem_size'. By default there is no limit, i.e. the variable is
    set to 4294967295 bytes on 32bit systems, 18446744073709551615ULL
    on 64bit systems. The database administrator may set
    @@global.parser_max_mem_size to a lower value, in order to protect
    against out-of-memory situations caused by parsing long/complex SQL queries.
Loading