mariadb/sql
unknown 13105534fa Bug#31048: Many nested subqueries may cause server crash.
This bug is actually two. The first one manifests itself on an EXPLAIN
SELECT query with nested subqueries that employs the filesort algorithm.
The whole SELECT under explain is marked as UNCACHEABLE_EXPLAIN to preserve
some temporary structures for explain. As a side-effect of this values of
nested subqueries weren't cached and subqueries were re-evaluated many
times. Each time buffer for filesort was allocated but wasn't freed because
freeing occurs at the end of topmost SELECT. Thus all available memory was
eaten up step by step and OOM event occur.
The second bug manifests itself on SELECT queries with conditions where
a subquery result is compared with a key field and the subquery itself also
has such condition. When a long chain of such nested subqueries is present
the stack overrun occur. This happens because at some point the range optimizer
temporary puts the PARAM structure on the stack. Its size if about 8K and
the stack is exhausted very fast.

Now the subselect_single_select_engine::exec function allows subquery result
caching when the UNCACHEABLE_EXPLAIN flag is set.
Now the SQL_SELECT::test_quick_select function calls the check_stack_overrun
function for stack checking purposes to prevent server crash.


mysql-test/t/subselect.test:
  Added a test case for the bug#31048: Many nested subqueries may cause server crash.
mysql-test/r/subselect.result:
  Added a test case for the bug#31048: Many nested subqueries may cause server crash.
sql/opt_range.cc:
  Bug#31048: Many nested subqueries may cause server crash.
  Now the SQL_SELECT::test_quick_select function calls the check_stack_overrun
  function for stack checking purposes to preven server crash.
sql/item_subselect.cc:
  Bug31048: Many nested subqueries may cause server crash.
  Now the subselect_single_select_engine::exec function allows subquery result
  caching when the UNCACHEABLE_EXPLAIN flag is set.
2007-11-19 20:00:25 +00:00
..
examples Bug#28862 Extended Latin1 characters get lost in CVS engine 2007-06-15 11:19:35 +05:00
share Fixed bug #27695. 2007-09-13 18:41:50 +05:00
.cvsignore
add_errmsg
client_settings.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
CMakeLists.txt CMakeLists.txt: 2007-08-29 22:29:07 +02:00
custom_conf.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
derror.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
des_key_file.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
discover.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
field.cc Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt 2007-10-23 11:26:37 +03:00
field.h Bug #30825: Problems when putting a non-spatial index on a GIS column 2007-10-10 16:26:02 +03:00
field_conv.cc field_conv.cc: 2007-07-12 00:55:40 +05:00
filesort.cc Fix for bug #31742: delete from ... order by function call that causes 2007-10-22 16:10:08 +04:00
frm_crypt.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
gen_lex_hash.cc gen_lex_hash.cc: 2007-01-31 00:06:42 +01:00
gstream.cc Merge mysql.com:/home/hf/work/30286/my41-30286 2007-10-05 16:33:08 +05:00
gstream.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
ha_archive.cc BUG#29207 - archive table reported as corrupt by check table (P1) 2007-06-27 13:19:34 +05:00
ha_archive.h Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-01-22 14:04:40 +02:00
ha_berkeley.cc BUG#28591: make the fix work for BDB tables too: 2007-07-26 20:52:53 +04:00
ha_berkeley.h Fixed compiler warnings (for linux and win32 and win64) 2007-02-22 16:59:57 +02:00
ha_blackhole.cc Bug#19717: The blackhole engine is returning an OK flag in 2007-02-14 18:35:59 +02:00
ha_blackhole.h Merge mysql.com:/home/svoj/devel/mysql/BUG27998/mysql-4.1-engines 2007-05-10 18:14:04 +05:00
ha_federated.cc type conversions fixed to avoid warnings on Windows 2007-10-23 14:27:11 +05:00
ha_federated.h Merge ramayana.hindu.god:/home/tsmith/m/bk/50 2007-08-01 18:14:50 -06:00
ha_heap.cc type conversions fixed to get rid of warnings 2007-10-23 16:32:05 +05:00
ha_heap.h [pb problem]: ha_heap->clone() fails on windows because of mess with 2007-07-17 19:51:50 +04:00
ha_innodb.cc Merge mysql.com:/home/gluh/MySQL/Merge/5.0 2007-10-23 18:51:43 +05:00
ha_innodb.h Bug #20358: InnoDB hang on the adaptive hash index latch in btr0sea.c 2007-10-02 23:47:30 -06:00
ha_myisam.cc type conversions fixed to avoid warnings on Windows 2007-10-23 14:27:11 +05:00
ha_myisam.h Bug#28249 Query Cache returns wrong result with concurrent insert / certain lock 2007-07-12 13:29:51 +02:00
ha_myisammrg.cc BUG#26976 - Missing table in merge not noted in related error msg + 2007-06-14 16:18:01 +05:00
ha_myisammrg.h BUG#26976 - Missing table in merge not noted in related error msg + 2007-06-06 04:42:41 +05:00
ha_ndbcluster.cc Merge whalegate.ndb.mysql.com:/home/tomas/mysql-5.0-ndb 2007-09-12 14:01:51 +02:00
ha_ndbcluster.h Merge dev3-221.dev.cn.tlan:/home/ngb/mysql/mysql-5.0/mysql-5.0-ndb-bj 2007-05-08 10:00:12 +08:00
ha_ndbcluster_cond.cc bug#27494 An invalid subselect crashes mysql server: Added check for missing arguments 2007-09-13 09:47:21 +02:00
ha_ndbcluster_cond.h Bug #29185 Large IN list crashes mysqld with cluster and condition pushdown 2007-06-19 13:56:02 +02:00
handler.cc bug#28570: handler::index_read() is called with different find_flag when 2007-08-15 09:23:44 +02:00
handler.h Merge tsmith@bk-internal.mysql.com:/home/bk/mysql-5.0-opt 2007-08-01 18:39:13 -06:00
hash_filo.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
hash_filo.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
hostname.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
init.cc Fix for bug #28121 "INSERT or UPDATE into DOUBLE(200,0) field being truncated to 31 digits" 2007-05-28 12:44:59 +04:00
item.cc Merge spetrunia@bk-internal.mysql.com:/home/bk/mysql-5.0-opt 2007-10-23 20:03:06 +04:00
item.h Bug #28550 "Potential bugs related to the return type of the CHAR function". 2007-10-21 21:45:31 +04:00
item_buff.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
item_cmpfunc.cc Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt 2007-10-13 09:12:15 +03:00
item_cmpfunc.h Bug#27216: functions with parameters of different date types may return wrong 2007-09-22 11:49:27 +04:00
item_create.cc Fix for bug #30200: mysqlbinlog.test: connection_id() not restored under ps-protocol 2007-08-02 14:51:03 +05:00
item_create.h Bug #27921 View ignores precision for CAST() 2007-05-10 00:17:21 +05:00
item_func.cc Merge mysql.com:/home/gluh/MySQL/Merge/5.0 2007-10-23 18:51:43 +05:00
item_func.h Bug#30832:Assertion + crash with select name_const('test',now()); 2007-10-09 11:36:05 +02:00
item_geofunc.cc Bug #31155 gis types in union'd select cause crash. 2007-10-04 12:01:28 +05:00
item_geofunc.h Bug #31155 gis types in union'd select cause crash. 2007-10-04 12:01:28 +05:00
item_row.cc Many files: 2006-12-23 20:17:15 +01:00
item_row.h Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-01-22 14:04:40 +02:00
item_strfunc.cc Bug#30981 CHAR(0x41 USING ucs2) doesn't add leading zero 2007-10-11 16:07:10 +05:00
item_strfunc.h Bug #28550 "Potential bugs related to the return type of the CHAR function". 2007-10-21 21:45:31 +04:00
item_subselect.cc Bug#31048: Many nested subqueries may cause server crash. 2007-11-19 20:00:25 +00:00
item_subselect.h Fixed bug #27870. The bug that causes crashes manifests itself at some 2007-04-17 17:35:29 -07:00
item_sum.cc Merge mysql.com:/home/gluh/MySQL/Merge/5.0 2007-10-23 18:51:43 +05:00
item_sum.h Bug#27333: subquery grouped for aggregate of outer 2007-06-29 10:39:17 +03:00
item_timefunc.cc Bug #31221: Optimizer incorrectly identifies impossible WHERE clause 2007-10-18 15:19:04 +03:00
item_timefunc.h Merge mysql.com:/home/gluh/MySQL/Merge/5.0 2007-10-23 18:51:43 +05:00
item_uniq.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
item_uniq.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
key.cc Patch to eliminate compilation errors under VC after bug #13191 fix. 2007-04-29 12:56:46 +05:00
lex.h Fix -ansi -pedantic warning (can't cast a pointer to function 2007-03-08 12:04:45 +03:00
lex_symbol.h Fix -ansi -pedantic warning (can't cast a pointer to function 2007-03-08 12:04:45 +03:00
lock.cc Bug#25164 create table a as select * from A hangs 2007-08-27 10:13:54 -03:00
log.cc (pushing for Andrei) 2007-07-30 18:27:36 +03:00
log_event.cc Fix for bug #29928: INSERT ... VALUES(connection_id(), ...) incorrect 2007-08-01 15:27:03 +05:00
log_event.h Bug#22725 Replication outages from ER_SERVER_SHUTDOWN (1053) set in replication events 2007-05-28 22:20:22 +03:00
Makefile.am Bug#29414 HPUX build fails - 'noinst_HEADERS' does not exist 2007-06-28 11:13:18 +02:00
matherr.c my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
message.mc make dist changes for Cmake build 2006-09-01 10:32:12 +02:00
mf_iocache.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
my_decimal.cc Bug#31227: memory overrun with decimal (6,6) and zerofill and group_concat 2007-10-05 09:38:57 +02:00
my_decimal.h Merge bk-internal.mysql.com:/data0/bk/mysql-5.0 2007-05-28 00:05:38 +02:00
my_lock.c my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
mysql_priv.h Merge mysql.com:/home/gluh/MySQL/Merge/5.0 2007-10-23 18:51:43 +05:00
mysqld.cc Merge tnurnberg@bk-internal.mysql.com:/home/bk/mysql-5.0-maint 2007-10-12 11:30:53 +02:00
mysqld_suffix.h Many files: 2006-12-23 20:17:15 +01:00
net_serv.cc Merge mysql.com:/home/hf/work/29117/my41-29117 2007-06-19 12:31:37 +05:00
nt_servc.cc
nt_servc.h
opt_range.cc Bug#31048: Many nested subqueries may cause server crash. 2007-11-19 20:00:25 +00:00
opt_range.h Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-01-22 14:04:40 +02:00
opt_sum.cc Bug#27573: MIN() on an indexed column which is always NULL sets _other_ results 2007-05-15 15:29:12 +03:00
parse_file.cc Polishing: add comments. 2007-04-06 18:56:39 +04:00
parse_file.h Many files: 2006-12-23 20:17:15 +01:00
password.c Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-01-22 14:04:40 +02:00
procedure.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
procedure.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
protocol.cc Bug#27216: functions with parameters of different date types may return wrong 2007-09-22 11:49:27 +04:00
protocol.h Backport of TIME->MYSQL_TIME / Y2K fixset 2007-05-16 10:44:59 +02:00
records.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
repl_failsafe.cc Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-02-21 14:07:08 +02:00
repl_failsafe.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
set_var.cc Merge mysql.com:/home/gluh/MySQL/Merge/5.0 2007-10-23 18:51:43 +05:00
set_var.h Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-02-21 14:07:08 +02:00
slave.cc Merge polly.local:/home/kaa/src/maint/bug24192/my50-bug24192 2007-07-11 19:29:11 +04:00
slave.h Fix for BUG#24432 2007-02-08 15:53:14 +01:00
sp.cc Bug#28318 CREATE FUNCTION (UDF) requires a schema 2007-10-09 20:46:33 -03:00
sp.h Many files: 2006-12-23 20:17:15 +01:00
sp_cache.cc Many files: 2006-12-23 20:17:15 +01:00
sp_cache.h Many files: 2006-12-23 20:17:15 +01:00
sp_head.cc Bug#28318 CREATE FUNCTION (UDF) requires a schema 2007-10-09 20:46:33 -03:00
sp_head.h Bug#28318 CREATE FUNCTION (UDF) requires a schema 2007-10-09 20:46:33 -03:00
sp_pcontext.cc Bug#26503 (Illegal SQL exception handler code causes the server to crash) 2007-03-14 12:02:32 -06:00
sp_pcontext.h Bug#26503 (Illegal SQL exception handler code causes the server to crash) 2007-03-14 12:02:32 -06:00
sp_rcontext.cc Bug#24989: The DEADLOCK error is improperly handled by InnoDB. 2007-07-30 17:14:34 +04:00
sp_rcontext.h Bug#24989: The DEADLOCK error is improperly handled by InnoDB. 2007-07-30 17:14:34 +04:00
spatial.cc Bug #29166: 2007-07-05 18:24:48 +03:00
spatial.h Bug #24563: MBROverlaps does not seem to function propertly. 2007-03-23 16:28:07 -06:00
sql_acl.cc Merge mysql.com:/home/gluh/MySQL/Merge/5.0 2007-10-23 18:51:43 +05:00
sql_acl.h Bug #30468: column level privileges not respected when joining tables 2007-09-27 12:15:19 +03:00
sql_analyse.cc Merge rkalimullin@bk-internal.mysql.com:/home/bk/mysql-5.0-maint 2007-02-06 17:18:43 +04:00
sql_analyse.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_array.h Many files: 2006-12-23 20:17:15 +01:00
sql_base.cc Merge mysql.com:/home/gluh/MySQL/Merge/5.0 2007-10-23 18:51:43 +05:00
sql_bitmap.h Many files: 2006-12-23 20:17:15 +01:00
sql_cache.cc Merge adventure.(none):/home/thek/Development/cpp/bug21074/my50-bug21074 2007-09-03 13:46:10 +02:00
sql_cache.h Bug #30269 Query cache eats memory 2007-08-17 16:55:20 +02:00
sql_class.cc Bug #31517: Potential crash due to access of NULL thd in mark_transaction_to_rollback() 2007-10-10 14:00:57 -06:00
sql_class.h Bug#30384: Having SQL_BUFFER_RESULT option in the CREATE .. KEY(..) .. SELECT 2007-09-21 12:09:00 +04:00
sql_client.cc Bug#26664 test suite times out on OS X 64bit 2007-05-24 11:21:27 +02:00
sql_crypt.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_crypt.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_cursor.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_cursor.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_db.cc A fix and a teset case for Bug#28551 The warning 2007-07-05 02:20:32 +04:00
sql_delete.cc (pushing for Andrei) 2007-07-30 18:27:36 +03:00
sql_derived.cc - renaming TMP_TABLE to NON_TRANSACTIONAL_TMP_TABLE because this is 2007-03-22 15:07:32 +01:00
sql_do.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_error.cc Merge bk-internal.mysql.com:/home/bk/mysql-5.0-runtime 2007-06-20 12:46:15 +04:00
sql_error.h BUG#26976 - Missing table in merge not noted in related error msg + 2007-06-06 04:42:41 +05:00
sql_handler.cc Bug#31409 RENAME TABLE causes server crash or deadlock when used with HANDLER statements 2007-10-12 10:55:46 -03:00
sql_help.cc Bug #25831: Deficiencies in INSERT ... SELECT ... field name resolving. 2007-02-19 14:39:37 +02:00
sql_insert.cc Merge gkodinov@bk-internal.mysql.com:/home/bk/mysql-5.0-opt 2007-09-27 12:17:16 +03:00
sql_lex.cc Merge weblab.(none):/home/marcsql/TREE/mysql-5.0-base 2007-08-30 17:23:40 -06:00
sql_lex.h Bug #30377: EXPLAIN loses last_query_cost when used with UNION 2007-08-28 18:51:03 +03:00
sql_list.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_list.h Merge of BUG#26624 and BUG#26625 2007-03-29 10:35:28 +04:00
sql_load.cc (pushing for Andrei) 2007-07-30 18:27:36 +03:00
sql_locale.cc Merge mysql.com:/nfsdisk1/lars/bkroot/mysql-5.0-rpl 2007-01-12 12:22:54 +01:00
sql_manager.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_manager.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_map.cc type conversions fixed to avoid warnings on Windows 2007-10-23 14:27:11 +05:00
sql_map.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_olap.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_parse.cc Merge mysql.com:/home/gluh/MySQL/Merge/5.0 2007-10-23 18:51:43 +05:00
sql_prepare.cc Merge bk-internal.mysql.com:/home/bk/mysql-5.0-runtime 2007-07-12 23:22:17 +04:00
sql_rename.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_repl.cc Fix for bug #29420: crash with show and purge binlogs 2007-07-05 13:09:56 +05:00
sql_repl.h my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_select.cc Merge mysql.com:/home/gluh/MySQL/Merge/5.0 2007-10-23 18:51:43 +05:00
sql_select.h Bug #30825: Problems when putting a non-spatial index on a GIS column 2007-10-10 16:26:02 +03:00
sql_show.cc Bug#27747 database metadata doesn't return sufficient column default info 2007-09-20 13:54:46 +05:00
sql_sort.h Fixed bug #25798. 2007-07-01 15:33:28 -07:00
sql_state.c Many files: 2006-12-23 20:17:15 +01:00
sql_string.cc Reversing additional change suggested by Serg 2007-08-07 19:25:45 +05:00
sql_string.h Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2007-01-22 14:04:40 +02:00
sql_table.cc Bug #30825: Problems when putting a non-spatial index on a GIS column 2007-10-10 16:26:02 +03:00
sql_test.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
sql_trigger.cc Fixed whitespace 2007-09-04 16:40:27 -06:00
sql_trigger.h A fix and a test case for Bug#26141 mixing table types in trigger 2007-07-12 22:26:41 +04:00
sql_udf.cc Implementing code review comments 2007-10-16 11:16:31 -06:00
sql_udf.h Remove typedef st_table_list TABLE_LIST and always use name 'TABLE_LIST'. 2007-07-06 16:18:49 +04:00
sql_union.cc Post-merge fixes 2007-07-31 16:15:56 +04:00
sql_update.cc type conversions fixed to avoid warnings on Windows 2007-10-23 14:27:11 +05:00
sql_view.cc Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0-opt 2007-09-27 23:45:39 +04:00
sql_view.h Many files: 2006-12-23 20:17:15 +01:00
sql_yacc.yy Merge mysql.com:/home/gluh/MySQL/Merge/5.0 2007-10-23 18:51:43 +05:00
stacktrace.c Bug #29543 GCov information not written in case of crash. 2007-07-07 07:46:17 +02:00
stacktrace.h Many files: 2006-12-23 20:17:15 +01:00
strfunc.cc Fixed compiler warnings. 2007-03-22 20:32:07 +02:00
structs.h Bug#28149 overflow in some "SHOW STATUS"-variables 2007-06-09 17:46:09 +05:00
table.cc Bug #30825: Problems when putting a non-spatial index on a GIS column 2007-10-10 16:26:02 +03:00
table.h Bug #28702: VIEWs defined with USE/FORCE KEY ignore that request 2007-09-24 15:34:10 +03:00
thr_malloc.cc my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
time.cc Bug #29536: timestamp inconsistent in replication around 1970 2007-08-06 04:57:28 -07:00
tzfile.h Many files: 2006-12-23 20:17:15 +01:00
tztime.cc Backport of TIME->MYSQL_TIME / Y2K fixset 2007-05-16 10:44:59 +02:00
tztime.h Backport of TIME->MYSQL_TIME / Y2K fixset 2007-05-16 10:44:59 +02:00
udf_example.c Bug #29804 UDF parameters don't contain correct string length 2007-10-17 17:54:11 -04:00
udf_example.def Bug #29804 UDF parameters don't contain correct string length 2007-10-17 17:54:11 -04:00
uniques.cc Fixed bug #25798. 2007-07-01 15:33:28 -07:00
unireg.cc Bug #29325: 2007-07-11 10:49:54 +03:00
unireg.h Fixed bug #27352. 2007-08-03 01:58:21 +05:00
watchdog_mysqld