mariadb/sql
unknown 4f15a043e2 Fix for bugs#12472/#15137 'CREATE TABLE ... SELECT ... which explicitly
or implicitly uses stored function gives "Table not locked" error'

CREATE TABLE ... SELECT ... statement which was explicitly or implicitly
(through view) using stored function gave "Table not locked" error.

The actual bug resides in the current locking scheme of CREATE TABLE SELECT
code, which first opens and locks tables of the SELECT statement itself,
and then, having SELECT tables locked, creates the .FRM, opens the .FRM and
acquires lock on it. This scheme opens a possibility for a deadlock, which
was present and ignored since version 3.23 or earlier. This scheme also
conflicts with the invariant of the prelocking algorithm -- no table can
be open and locked while there are tables locked in prelocked mode.

The patch makes an exception for this invariant when doing CREATE TABLE ...
SELECT, thus extending the possibility of a deadlock to the prelocked mode.
We can't supply a better fix in 5.0.


mysql-test/r/sp.result:
  Added tests for bugs#12472/#15137 'CREATE TABLE ... SELECT ... which
  explicitly or implicitly uses stored function gives "Table not locked" error'
mysql-test/t/sp.test:
  Added tests for bugs#12472/#15137 'CREATE TABLE ... SELECT ... which
  explicitly or implicitly uses stored function gives "Table not locked" error'
sql/mysql_priv.h:
  Added flag which can be passed to open_table() routine in order to ignore
  set of locked tables and prelocked mode.
  We don't need declaration of create_table_from_items() any longer as it was
  moved into sql_insert.cc and made static.
sql/sql_base.cc:
  open_table():
    Added flag which allows open table ignoring set of locked tables and
    prelocked mode.
sql/sql_insert.cc:
  Moved create_table_from_items() from sql_table.cc to sql_insert.cc as it was
  not used outside of sql_insert.cc and contains code which is specific for
  CREATE TABLE ... SELECT.
  Also now when we are executing CREATE TABLE ... SELECT ... statement which
  SELECT part requires execution in prelocked mode we ignore set of locked
  tables in order to get access to the table we just have created.
  We probably don't want to do this if we are under real LOCK TABLES since
  it will widen window for deadlock too much.
sql/sql_table.cc:
  Moved create_table_from_items() routine into sql_insert.cc, since it was not
  used anywhere outside of this file and contains logic which is specific for
  CREATE TABLE ... SELECT statement.
2006-05-09 16:39:11 +04:00
..
examples documenting HA_STATUS_xxx flags 2005-11-26 08:54:13 +01:00
share Merge mysql.com:/usr/home/bar/mysql-4.1.12076 2006-04-03 17:24:14 +05:00
.cvsignore
add_errmsg
client_settings.h
custom_conf.h
derror.cc
des_key_file.cc Many files: 2005-09-30 14:03:55 +02:00
discover.cc
field.cc Additional 5.0 fix for 2006-03-29 19:31:16 +05:00
field.h Merge epotemkin@bk-internal.mysql.com:/home/bk/mysql-5.0 2006-04-05 13:30:51 +04:00
field_conv.cc Expanding a binary field should result in 0x00-filled positions, not 0x20 2006-03-02 20:49:10 -05:00
filesort.cc Move handling of suffix_length from strnxfrm_bin() to filesort to ensure proper sorting of all kind of binary objects 2005-10-14 00:04:52 +03:00
frm_crypt.cc
gen_lex_hash.cc a fix (#10742: Can't compile "sql_lex.cc" on AIX 5.2). 2005-05-19 18:56:01 +05:00
gstream.cc fixes for windows 64-bit compiler warnings 2005-06-13 12:41:15 +02:00
gstream.h
ha_archive.cc Discoved while debugging in 5.1 that there was a bug where a certain crash could lead to two problems. 1) An additional share in memory that was allocated but did not have the correct use_count (so it would never be fulled deleted). Also discovered that a thread that called repair would write new rows, but would not see them. All other threads were ok, and the data was fine, but the thread doing the repair was unable to see the new rows. 2006-02-13 04:11:22 -08:00
ha_archive.h Discoved while debugging in 5.1 that there was a bug where a certain crash could lead to two problems. 1) An additional share in memory that was allocated but did not have the correct use_count (so it would never be fulled deleted). Also discovered that a thread that called repair would write new rows, but would not see them. All other threads were ok, and the data was fine, but the thread doing the repair was unable to see the new rows. 2006-02-13 04:11:22 -08:00
ha_berkeley.cc Inefficient usage of String::append() fixed. 2005-11-20 20:47:07 +02:00
ha_berkeley.h Fixes during review of new code 2005-11-03 22:42:25 +02:00
ha_blackhole.cc Merge baker@bk-internal.mysql.com:/home/bk/mysql-5.0 2005-10-02 20:13:18 -07:00
ha_blackhole.h Merge a193-229-222-105.elisa-laajakaista.fi:/home/my/bk/mysql-4.1 2005-08-26 15:56:52 +03:00
ha_federated.cc Bug#17377 Federated Engine returns wrong Data, always the rows with the highest ID 2006-02-28 11:17:40 +01:00
ha_federated.h Bug#17377 Federated Engine returns wrong Data, always the rows with the highest ID 2006-02-28 11:17:40 +01:00
ha_heap.cc Manual merge 2006-03-30 17:14:55 +04:00
ha_heap.h Merge mysql.com:/opt/local/work/mysql-4.1-root 2006-02-02 18:17:18 +03:00
ha_innodb.cc Applied innodb-5.0-ss398 snapshot. 2006-04-01 01:54:15 +04:00
ha_innodb.h Fixed: BUG#15653, BUG#16157, BUG#16229, BUG#16298, BUG#16387, BUG#16582. 2006-01-31 21:41:48 +03:00
ha_myisam.cc many warnings (practically safe but annoying) corrected 2006-01-03 17:54:54 +01:00
ha_myisam.h A fix and a test case for Bug#10760 and complementary cleanups. 2005-07-19 22:21:12 +04:00
ha_myisammrg.cc BUG#17314: Can't use index_merge/intersection for MERGE tables 2006-02-11 21:51:43 +03:00
ha_myisammrg.h A fix and a test case for Bug#10760 and complementary cleanups. 2005-07-19 22:21:12 +04:00
ha_ndbcluster.cc Merge joreland@bk-internal.mysql.com:/home/bk/mysql-5.0 2006-03-28 15:40:08 +02:00
ha_ndbcluster.h Fix for Bug#17431 INSERT IGNORE INTO returns failed: 1296: err 4350 'Transaction already aborted' 2006-03-23 09:48:46 +01:00
handler.cc WL#2645 (CHECK TABLE FOR UPGRADE) 2006-02-17 10:52:32 +04:00
handler.h Fixed compiler warnings from gcc 4.0.2: 2006-02-25 17:46:30 +02:00
hash_filo.cc a compiler must see '#pragma implementation' *before* 2005-06-05 19:38:52 +02:00
hash_filo.h forgotten s/__GNUC__/USE_PRAGMA_INTERFACE/ causes compilation faliures 2005-05-27 14:15:08 +02:00
hostname.cc Merge mysql.com:/usr/home/ram/work/mysql-4.1 2006-03-03 15:32:00 +04:00
init.cc Fixes during review of new pushed code 2005-08-12 13:54:42 +03:00
item.cc Merge ibabaev@bk-internal.mysql.com:/home/bk/mysql-5.0 2006-04-03 21:07:27 -07:00
item.h Merge mysql.com:/home/timka/mysql/src/5.0-virgin 2006-03-31 12:39:33 +03:00
item_buff.cc sql_select.cc: 2005-07-25 12:57:23 -07:00
item_cmpfunc.cc Post review changes for the fix of bug #16504. 2006-04-03 21:02:40 -07:00
item_cmpfunc.h Post review changes for the fix of bug #16504. 2006-04-03 21:02:40 -07:00
item_create.cc Fixed BUG#12963, BUG#13000: wrong VIEW creation with DAYNAME(), 2005-09-14 20:25:00 +04:00
item_create.h Fix for BUG#12335 (SP replication) : New binlogging strategy for stored PROCEDUREs/FUNCTIONs. 2005-08-25 17:34:34 +04:00
item_func.cc Remove DBUG print that looks at args[0] even if arg_count is 0 2006-03-23 21:45:00 +01:00
item_func.h Fixed bug#13575: SP funcs in select with distinct/group and order by can 2006-03-10 13:53:00 +03:00
item_geofunc.cc Merge ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-4.1 2005-10-31 11:54:36 +02:00
item_geofunc.h Merge neptunus.(none):/home/msvensson/mysql/bug10241 2005-05-09 11:26:48 +02:00
item_row.cc Fixed bug #12762: 2005-10-15 14:32:37 -07:00
item_row.h Name resolution context added (BUG#6443) 2005-07-01 07:05:42 +03:00
item_strfunc.cc Merge mysql.com:/home/jimw/my/mysql-5.0-14676 2006-02-17 08:32:50 -08:00
item_strfunc.h Fix for bug#16678 FORMAT gives wrong result if client run with default-character-set=utf8 2006-03-06 12:52:38 +04:00
item_subselect.cc Merge rurik.mysql.com:/home/igor/mysql-5.0 2005-11-22 23:00:57 -08:00
item_subselect.h Fix bug #15706 find_field_in_tables() returns field from outer select 2006-02-15 19:45:06 +03:00
item_sum.cc item_sum.cc, sql_select.cc: 2006-03-30 19:04:21 +04:00
item_sum.h item_sum.cc, sql_select.cc: 2006-03-30 19:04:21 +04:00
item_timefunc.cc Fixed BUG#17476: Stored procedure not returning data when it is called first 2006-03-02 14:54:04 +01:00
item_timefunc.h Merge mysql.com:/home/mysql_src/mysql-4.1-gca 2005-11-10 15:13:12 +01:00
item_uniq.cc Merge with 4.1 2005-06-07 00:31:53 +03:00
item_uniq.h Inefficient usage of String::append() fixed. 2005-11-20 20:47:07 +02:00
key.cc Inefficient usage of String::append() fixed. 2005-11-20 20:47:07 +02:00
lex.h WL#2645 (CHECK TABLE FOR UPGRADE) 2006-02-17 10:52:32 +04:00
lex_symbol.h
lock.cc Merge mysql.com:/opt/local/work/mysql-4.1-7209-new 2006-01-04 17:49:45 +03:00
log.cc Fix for BUG#16559 "Replication Problems with Non transactional tables inside an interrupted trans.": 2006-02-18 17:19:16 +01:00
log_event.cc BUG#18293 (Values in stored procedures written to binlog unescaped): 2006-03-21 14:35:49 +01:00
log_event.h Fixed compiler warnings from gcc 4.0.2: 2006-02-25 17:46:30 +02:00
Makefile.am Update test results for udf 2006-03-10 12:12:08 +01:00
matherr.c
mf_iocache.cc
my_decimal.cc Fix for bug #13573 (wrong data inserted for too big decimals) 2005-10-15 21:57:32 +05:00
my_decimal.h Fix for bug #13573 (wrong data inserted for too big decimals) 2005-10-15 21:57:32 +05:00
my_lock.c
mysql_priv.h Fix for bugs#12472/#15137 'CREATE TABLE ... SELECT ... which explicitly 2006-05-09 16:39:11 +04:00
mysqld.cc Bug#14575 2006-03-16 00:15:23 -08:00
mysqld_suffix.h
net_serv.cc Make the define start at "start of line" 2006-03-02 10:55:55 +01:00
nt_servc.cc
nt_servc.h
opt_range.cc Merge mysql.com:/home/timka/mysql/src/5.0-virgin 2006-03-31 12:39:33 +03:00
opt_range.h many warnings (practically safe but annoying) corrected 2006-01-03 17:54:54 +01:00
opt_sum.cc Fixed bug #16016: MIN/MAX optimization was not applied to views. 2006-01-06 22:28:26 -08:00
parse_file.cc Fix for BUG#15921: DROP TRIGGER - can't be drop trigger created 2006-03-28 01:01:51 +04:00
parse_file.h Fix for BUG#15921: DROP TRIGGER - can't be drop trigger created 2006-03-28 01:01:51 +04:00
password.c Merge mysql.com:/opt/local/work/mysql-4.1-root 2006-01-11 17:49:56 +03:00
procedure.cc Merge with 4.1 2005-06-07 00:31:53 +03:00
procedure.h Merge neptunus.(none):/home/msvensson/mysql/bug10241 2005-05-09 11:26:48 +02:00
protocol.cc Fixes to embedded server to be able to run tests with it 2006-02-24 18:34:15 +02:00
protocol.h Fixes to embedded server to be able to run tests with it 2006-02-24 18:34:15 +02:00
records.cc Merge ua141d10.elisa.omakaista.fi:/home/my/bk/mysql-4.1 2005-10-27 23:43:20 +03:00
repl_failsafe.cc many warnings (practically safe but annoying) corrected 2006-01-03 17:54:54 +01:00
repl_failsafe.h pthread_handler_decl() changed to be ctags-friendly 2005-10-08 16:39:55 +02:00
set_var.cc Fix for BUG#13897 "failure to do SET SQL_MODE=N where N is a number > 31" (the original bug's title isn't the simplest 2006-02-18 17:32:15 +01:00
set_var.h Many files: 2006-02-14 08:24:01 +04:00
slave.cc WL#2645 (CHECK TABLE FOR UPGRADE) 2006-02-17 10:52:32 +04:00
slave.h many warnings (practically safe but annoying) corrected 2006-01-03 17:54:54 +01:00
sp.cc Merge mysql.com:/extern/mysql/bk/mysql-5.0-runtime 2006-03-28 15:08:17 +02:00
sp.h Fixed BUG#16303: erroneus stored procedures and functions should be droppable 2006-01-26 13:29:46 +01:00
sp_cache.cc Fix use of "%*s" *printf() specifiers that were really meant to be 2005-10-06 17:37:24 -07:00
sp_cache.h BUG#12228: Post review fixes: Added test case, code cleanup. 2005-08-10 21:17:02 +00:00
sp_head.cc BUG#18293 (Values in stored procedures written to binlog unescaped): 2006-03-21 14:35:49 +01:00
sp_head.h Implementation of WL#2897: Complete definer support in the stored routines. 2006-03-02 15:18:49 +03:00
sp_pcontext.cc Fixed BUG#16887: Cursor causes server segfault 2006-02-15 12:11:29 +01:00
sp_pcontext.h Fixed BUG#16887: Cursor causes server segfault 2006-02-15 12:11:29 +01:00
sp_rcontext.cc Post-review fix for BUG#15011. 2006-02-01 16:00:11 +01:00
sp_rcontext.h Fixed compiler warnings from gcc 4.0.2: 2006-02-25 17:46:30 +02:00
spatial.cc Merge sanja.is.com.ua:/home/bell/mysql/bk/work-bug1-5.0 2005-11-21 21:15:48 +02:00
spatial.h Fixed compiler warnings from gcc 4.0.2: 2006-02-25 17:46:30 +02:00
sql_acl.cc Fix for bug #18113 "SELECT * FROM information_schema.xxx crashes server" 2006-03-20 13:42:02 +04:00
sql_acl.h WL#2486 - natural/using joins according to SQL:2003 2005-11-30 21:27:11 +02:00
sql_analyse.cc Porting fix that allows others to include compiled code with different parsers. 2006-03-09 10:09:52 -08:00
sql_analyse.h Merge from 4.1 2005-05-26 21:01:55 +02:00
sql_array.h Fix for BUG#12335 (SP replication) : New binlogging strategy for stored PROCEDUREs/FUNCTIONs. 2005-08-25 17:34:34 +04:00
sql_base.cc Fix for bugs#12472/#15137 'CREATE TABLE ... SELECT ... which explicitly 2006-05-09 16:39:11 +04:00
sql_bitmap.h Bug#10932 - Building server with key limit of 128, makes test cases fail 2005-07-19 14:13:56 +02:00
sql_cache.cc Merge mysql.com:/opt/local/work/mysql-4.1-7209-new 2006-01-04 17:49:45 +03:00
sql_cache.h Fixed compiler warnings from gcc 4.0.2: 2006-02-25 17:46:30 +02:00
sql_class.cc Fixes to embedded server to be able to run tests with it 2006-02-24 18:34:15 +02:00
sql_class.h Manual merge 2006-03-30 17:14:55 +04:00
sql_client.cc
sql_crypt.cc a compiler must see '#pragma implementation' *before* 2005-06-05 19:38:52 +02:00
sql_crypt.h Add ifdefs to control when "#pragma implementation" should be used 2005-05-26 12:09:14 +02:00
sql_cursor.cc Fixes to embedded server to be able to run tests with it 2006-02-24 18:34:15 +02:00
sql_cursor.h A fix and a test case for Bug#6513 "Test Suite: Values inserted by using 2005-09-22 02:11:21 +04:00
sql_db.cc Merge aivanov@bk-internal.mysql.com:/home/bk/mysql-5.0 2006-03-01 17:43:55 +03:00
sql_delete.cc Merge neptunus.(none):/home/msvensson/mysql/bug17137/my41-bug17137 2006-03-08 10:17:12 +01:00
sql_derived.cc support of view underlying tables and SP functions security check added (BUG#9505) (WL#2787) 2005-10-28 00:18:23 +03:00
sql_do.cc Name resolution context added (BUG#6443) 2005-07-01 07:05:42 +03:00
sql_error.cc Add extre DBUG_PRINT in push_warning 2006-03-16 12:06:39 +01:00
sql_error.h
sql_handler.cc Changed condition similar to code in 4.1. 2006-01-16 23:15:00 +02:00
sql_help.cc many warnings (practically safe but annoying) corrected 2006-01-03 17:54:54 +01:00
sql_insert.cc Fix for bugs#12472/#15137 'CREATE TABLE ... SELECT ... which explicitly 2006-05-09 16:39:11 +04:00
sql_lex.cc This patch does 1) fix my build breakage 2) Complete the removal of all symbols which could clash with another parser. 2006-03-09 16:44:08 -08:00
sql_lex.h This patch does 1) fix my build breakage 2) Complete the removal of all symbols which could clash with another parser. 2006-03-09 16:44:08 -08:00
sql_list.cc a compiler must see '#pragma implementation' *before* 2005-06-05 19:38:52 +02:00
sql_list.h WL#2486 - Natural/using join according to SQL:2003. 2005-11-28 21:57:50 +02:00
sql_load.cc Reverting yesterday's patch. (cmiller:1.2099) 2006-03-29 10:56:11 -05:00
sql_manager.cc Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2005-10-12 00:59:52 +03:00
sql_manager.h
sql_map.cc WL#2286 - Compile MySQL w/YASSL support 2005-06-22 14:08:28 +05:00
sql_map.h Add ifdefs to control when "#pragma implementation" should be used 2005-05-26 12:09:14 +02:00
sql_olap.cc Implementation of WL#2486 - 2005-08-12 17:57:19 +03:00
sql_parse.cc We should prohobit concurent read of inserting file in SP 2006-03-15 19:15:52 +02:00
sql_prepare.cc Fixed bug #18279: crash in the cases when on conditions are moved 2006-03-29 16:45:29 -08:00
sql_rename.cc Fix for bug #13525 "Rename table does not keep info of triggers". 2006-02-24 23:50:36 +03:00
sql_repl.cc many warnings (practically safe but annoying) corrected 2006-01-03 17:54:54 +01:00
sql_repl.h
sql_select.cc Post review changes for the fix of bug #16504. 2006-04-03 21:02:40 -07:00
sql_select.h Merge bk-internal.mysql.com:/home/bk/mysql-5.0 2006-02-27 20:00:03 +03:00
sql_show.cc Fix for bug#18224 VIEW on information_schema crashes the server 2006-03-20 14:17:47 +04:00
sql_sort.h
sql_state.c
sql_string.cc Merge mysql.com:/usr/home/bar/mysql-4.1.b15376 2006-03-23 12:41:28 +04:00
sql_string.h Netware specific changes. 2005-12-14 01:21:56 +02:00
sql_table.cc Fix for bugs#12472/#15137 'CREATE TABLE ... SELECT ... which explicitly 2006-05-09 16:39:11 +04:00
sql_test.cc many warnings (practically safe but annoying) corrected 2006-01-03 17:54:54 +01:00
sql_trigger.cc Fix for BUG#15921: DROP TRIGGER - can't be drop trigger created 2006-03-28 01:01:51 +04:00
sql_trigger.h Merge bk-internal.mysql.com:/home/bk/mysql-5.0-runtime 2006-02-26 16:38:48 +03:00
sql_udf.cc Merge neptunus.(none):/home/msvensson/mysql/mysql-5.0 2006-03-20 21:35:05 +01:00
sql_udf.h Name resolution context added (BUG#6443) 2005-07-01 07:05:42 +03:00
sql_union.cc A fix and a test case for Bug#12736 "Server crash during a select". 2005-10-13 11:53:00 +04:00
sql_update.cc Fixed bug #16281: Multi-table update broken in 5.0 on tables imported from 4.1 2006-04-05 13:29:04 +04:00
sql_view.cc A fix and a test case for Bug#15683 "crash, Function on nested 2006-03-28 15:06:29 +04:00
sql_view.h Merge jamppa@bk-internal.mysql.com:/home/bk/mysql-5.0 2005-11-03 16:43:05 +02:00
sql_yacc.yy We should prohobit concurent read of inserting file in SP 2006-03-15 19:15:52 +02:00
stacktrace.c
stacktrace.h
strfunc.cc
structs.h Inefficient usage of String::append() fixed. 2005-11-20 20:47:07 +02:00
table.cc Merge mysql.com:/usr/home/bar/mysql-4.1.b18004 2006-03-22 13:11:31 +04:00
table.h Merge mysql.com:/home/timka/mysql/src/5.0-virgin 2006-03-06 11:41:19 +02:00
thr_malloc.cc
time.cc Fixes during review of new pushed code 2005-07-31 12:49:55 +03:00
tzfile.h
tztime.cc Fixed compiler warnings from gcc 4.0.2: 2006-02-25 17:46:30 +02:00
tztime.h Fixed compiler warnings from gcc 4.0.2: 2006-02-25 17:46:30 +02:00
udf_example.cc Fix 'metaphon' function to correctly calculate the length of the returned string 2006-03-24 11:12:32 +01:00
uniques.cc many warnings (practically safe but annoying) corrected 2006-01-03 17:54:54 +01:00
unireg.cc A fix and a test case for Bug#14210 "Simple query with > operator on 2005-11-03 14:20:13 +03:00
unireg.h Merge mysql.com:/home/mydev/mysql-5.0 2005-12-06 08:19:23 +01:00
watchdog_mysqld