MariaDB server is a community developed fork of MySQL server. Started by core members of the original MySQL team, MariaDB actively works with outside developers to deliver the most featureful, stable, and sanely licensed open SQL server in the industry.
  • MariaDB\ 71.8%
  • C++ 16.4%
  • C 10.4%
  • Shell 0.5%
  • Perl 0.4%
  • Other 0.3%
Find a file
unknown 611dbd0bb3 Bug#30882 Dropping a temporary table inside a stored function may cause a server crash
If a stored function that contains a drop temporary table statement
is invoked by a create temporary table of the same name may cause
a server crash. The problem is that when dropping a table no check
is done to ensure that table is not being used by some outer query
(or outer statement), potentially leaving the outer query with a
reference to a stale (freed) table.

The solution is when dropping a temporary table, always check if
the table is being used by some outer statement as a temporary
table can be dropped inside stored procedures.

The check is performed by looking at the TABLE::query_id value for
temporary tables. To simplify this check and to solve a bug related
to handling of temporary tables in prelocked mode, this patch changes
the way in which this member is used to track the fact that table is
used/unused. Now we ensure that TABLE::query_id is zero for unused
temporary tables (which means that all temporary tables which were
used by a statement should be marked as free for reuse after it's
execution has been completed).


mysql-test/include/handler.inc:
  Add test case for side effect of Bug#30882
mysql-test/r/handler_innodb.result:
  Add test case result for side effect of Bug#30882
mysql-test/r/handler_myisam.result:
  Add test case result for side effect of Bug#30882
mysql-test/r/sp-error.result:
  Add test case result for Bug#30882
mysql-test/t/sp-error.test:
  Add test case for Bug#30882
sql/event_db_repository.cc:
  Update close_thread_tables call, no more default values.
sql/mysql_priv.h:
  Remove implicit default parameters values of the close_thread_tables
  function as no callers are using it.
sql/slave.cc:
  Update close_thread_tables call, no more default values
sql/sp_head.cc:
  Update close_thread_tables call, no more default values
sql/sql_base.cc:
  Changed the approach to distinguishing currently unused temporary tables.
  Now we ensure that such tables always have TABLE::query_id set to 0 and
  use this fact to perform checks during opening and dropping of temporary
  tables. This means that we have to call close_thread_tables() even for
  statements which use only temporary tables. To make this call cheaper,
  we re-factored close_thread_tables() to not take LOCK_open unless there
  are open base tables.
sql/sql_handler.cc:
  Properly close temporary tables associated with a handler.
sql/sql_insert.cc:
  close_temporary_table is now merged into drop_temporary_table.
sql/sql_parse.cc:
  Now the condition doesn't cover all cases because close_thread_tables()
  must be called even for statements that use only temporary tables.
sql/sql_table.cc:
  Use drop_temporary_table which perform checks to verify if
  the table is not being used. Error path problem is due to
  a handler tables issue and is going to be addressed in bug
  31397.
sql/table.h:
  Rename previously unused clear_query_id and document the usage of
  query_id and open_by_handler.
2007-11-01 18:52:56 -02:00
BitKeeper Merge pippilotta.erinye.com:/shared/home/df/mysql/build/mysql-5.0-build 2007-06-18 20:18:32 +02:00
BUILD Merge kboortz@bk-internal.mysql.com:/home/bk/mysql-5.1-build 2007-09-26 18:49:09 +02:00
client Merge mysql.com:/home/gluh/MySQL/Merge/5.1 2007-10-23 19:08:21 +05:00
cmd-line-utils make_binary_distribution.sh: 2007-09-26 20:19:33 +02:00
config/ac-macros Merge polly.(none):/home/kaa/src/maint/bug31254/my51-bug31254 2007-10-12 15:10:33 +04:00
dbug Bug #27099: system_mysql fail in pushbuild windows 2007-10-15 19:56:24 +03:00
Docs Merge mysql.com:/home/kent/bk/tmp/mysql-5.0-build 2007-03-22 19:44:14 +01:00
extra Merge ramayana.hindu.god:/home/tsmith/m/bk/51 2007-10-10 14:15:09 -06:00
include Cleanup: use helper functions to set an error in MYSQL or MYSQL_STMT. 2007-10-31 17:16:53 +03:00
libmysql Merge bk-internal.mysql.com:/home/bk/mysql-5.1-runtime 2007-10-31 17:30:46 +03:00
libmysql_r Makefile.am: 2007-09-26 19:41:46 +02:00
libmysqld Cleanup: use helper functions to set an error in MYSQL or MYSQL_STMT. 2007-10-31 17:16:53 +03:00
man my_strtoll10-x86.s: 2006-12-31 01:02:27 +01:00
mysql-test Bug#30882 Dropping a temporary table inside a stored function may cause a server crash 2007-11-01 18:52:56 -02:00
mysys Merge anubis.xiphis.org:/usr/home/antony/work/mysql-5.1-engines 2007-10-19 13:06:37 -07:00
netware Merge zippy.cornsilk.net:/home/cmiller/work/mysql/mysql-5.0-maint 2007-10-08 12:40:21 -04:00
plugin Makefile.am: 2007-09-26 18:47:55 +02:00
pstack Makefile.am, configure.in: 2007-09-27 21:39:23 +02:00
regex Merge bk-internal.mysql.com:/home/bk/mysql-5.1-marvel 2007-08-16 18:21:47 +02:00
scripts Merge anubis.xiphis.org:/usr/home/antony/work/mysql-5.1-engines 2007-10-19 13:06:37 -07:00
server-tools WL#4104: Deprecate the Instance Manager. 2007-10-22 23:02:05 +04:00
sql Bug#30882 Dropping a temporary table inside a stored function may cause a server crash 2007-11-01 18:52:56 -02:00
sql-bench Fixed compiler warnings 2007-02-23 13:13:55 +02:00
sql-common Another attempt to fix the Windows compilation failre. 2007-11-01 00:55:25 +03:00
storage Merge mysql.com:/home/gluh/MySQL/Merge/5.1 2007-10-23 19:08:21 +05:00
strings Merge mysql.com:/home/gluh/MySQL/Merge/5.1 2007-10-23 19:08:21 +05:00
support-files Makefile.am, make_binary_distribution.sh: 2007-09-27 12:21:56 +02:00
tests Post merge fix for bug 31669. 2007-10-31 13:54:53 -02:00
unittest Fixes Bug#30127: --debug-info no longer prints memory usage in mysql 2007-08-01 22:59:05 +03:00
vio Merge pilot.(none):/data/msvensson/mysql/mysql-5.0-maint 2007-08-28 11:36:10 +02:00
win Merge ramayana.hindu.god:/home/tsmith/m/bk/51 2007-09-28 10:55:28 -06:00
zlib CMakeLists.txt, README, configure.js 2007-08-03 21:51:37 +02:00
.bzrignore Merge gleb.loc:/home/uchum/work/bk/5.0-opt 2007-09-06 19:15:31 +05:00
.cvsignore Import changeset 2000-07-31 21:29:14 +02:00
CMakeLists.txt CMakeLists.txt (many), win/README, mysql_manifest.cmake, configure.js: 2007-08-06 23:16:01 +02:00
configure.in Merge solace.(none):/home/mtaylor/src/mysql/mysql-5.0-maint 2007-10-12 02:18:13 -07:00
COPYING - manual.texi will be replaced with a manual written in DocBook/XML. This ChangeSet removes all 2005-04-13 11:51:38 +02:00
EXCEPTIONS-CLIENT EXCEPTIONS-CLIENT: 2007-03-14 18:28:16 +01:00
Makefile.am Merge solace.(none):/home/mtaylor/src/mysql/mysql-5.0-maint 2007-10-12 02:18:13 -07:00
README make_binary_distribution.sh: 2006-11-07 22:26:37 +01:00

This is a release of MySQL, a dual-license SQL database server.
MySQL is brought to you by the MySQL team at MySQL AB.

License information can be found in these files:
- For GPL (free) distributions, see the COPYING file and
  the EXCEPTIONS-CLIENT file.
- For commercial distributions, see the LICENSE.mysql file.


For further information about MySQL or additional documentation, see:
- The latest information about MySQL: http://www.mysql.com
- The current MySQL documentation: http://dev.mysql.com/doc

Some manual sections of special interest:

- If you are migrating from an older version of MySQL, please read the
  "Upgrading from..." section first!
- To see what MySQL can do, take a look at the features section.
- For installation instructions, see the Installing and Upgrading chapter.
- For the new features/bugfix history, see the Change History appendix.
- For the currently known bugs/misfeatures (known errors) see the Problems
  and Common Errors appendix.
- For a list of developers and other contributors, see the Credits
  appendix.

A local copy of the MySQL Reference Manual can be found in the Docs
directory in GNU Info format.  You can also browse the manual online or
download it in any of several formats at the URL given earlier in this
file.

************************************************************

IMPORTANT:

Bug or error reports should be sent to http://bugs.mysql.com.