mtr test:
CREATE TABLE t1(a INT);
|
DELIMITER $$;
|
CREATE FUNCTION f1() RETURNS VARCHAR(16383)
|
BEGIN
|
INSERT INTO t1 VALUES(1);
|
RETURN 'test';
|
END;
|
$$
|
DELIMITER ;$$
|
|
CREATE OR REPLACE TABLE t1 AS SELECT f1();
|
LOCK TABLE t1 WRITE;
|
CREATE OR REPLACE TABLE t1 AS SELECT f1();
|
UNLOCK TABLES;
|
|
DROP FUNCTION f1;
|
DROP TABLE t1;
|
There's a guard in mysql_execute_command() that prevents referencing the same table multiple times:
if ((create_info.options & HA_LEX_CREATE_REPLACE) &&
|
!create_info.tmp_table())
|
{
|
TABLE_LIST *duplicate;
|
if ((duplicate= unique_table(thd, lex->query_tables,
|
lex->query_tables->next_global,
|
0)))
|
{
|
update_non_unique_table_error(lex->query_tables, "CREATE",
|
duplicate);
|
res= TRUE;
|
goto end_with_restore_list;
|
}
|
}
|
But it doesn't work because find_dup_table() has this condition:
/*
|
Skip if marked to be excluded (could be a derived table) or if
|
entry is a prelocking placeholder.
|
*/
|
if (res->select_lex &&
|
!res->select_lex->exclude_from_table_unique_test &&
|
!res->prelocking_placeholder)
|
break;
|
10.3 d71a8855ee
|
mysqld: /data/src/10.3/sql/table_cache.cc:1147: bool tdc_remove_table(THD*, enum_tdc_remove_table_type, const char*, const char*, bool): Assertion `element->all_tables.is_empty() || remove_type != TDC_RT_REMOVE_ALL' failed.
|
180420 17:59:32 [ERROR] mysqld got signal 6 ;
|
|
#7 0x00007fe3ce535ee2 in __assert_fail () from /lib/x86_64-linux-gnu/libc.so.6
|
#8 0x000055b9b0a18e85 in tdc_remove_table (thd=0x7fe360000b00, remove_type=TDC_RT_REMOVE_ALL, db=0x7fe360013fd8 "test", table_name=0x7fe360013950 "t1", kill_delayed_threads=false) at /data/src/10.3/sql/table_cache.cc:1147
|
#9 0x000055b9b08c1e4d in mysql_rm_table_no_locks (thd=0x7fe360000b00, tables=0x7fe3cc2335d0, if_exists=false, drop_temporary=false, drop_view=false, drop_sequence=false, dont_log_query=true, dont_free_locks=true) at /data/src/10.3/sql/sql_table.cc:2502
|
#10 0x000055b9b08c8d60 in create_table_impl (thd=0x7fe360000b00, orig_db=0x7fe3600139a0, orig_table_name=0x7fe3600139b0, db=0x7fe3600139a0, table_name=0x7fe3600139b0, path=0x7fe3cc233d00 "./test/t1", options=..., create_info=0x7fe3cc2357e0, alter_info=0x7fe3cc235720, create_table_mode=1, is_trans=0x0, key_info=0x7fe3cc233ce0, key_count=0x7fe3cc233cd4, frm=0x7fe3cc233cf0) at /data/src/10.3/sql/sql_table.cc:4878
|
#11 0x000055b9b08c9802 in mysql_create_table_no_lock (thd=0x7fe360000b00, db=0x7fe3600139a0, table_name=0x7fe3600139b0, create_info=0x7fe3cc2357e0, alter_info=0x7fe3cc235720, is_trans=0x0, create_table_mode=1, table_list=0x7fe360013988) at /data/src/10.3/sql/sql_table.cc:5082
|
#12 0x000055b9b07c72c8 in select_create::create_table_from_items (this=0x7fe360015f88, thd=0x7fe360000b00, items=0x7fe3cc235160, lock=0x7fe3cc235150, hooks=0x7fe3cc2351a0) at /data/src/10.3/sql/sql_insert.cc:4228
|
#13 0x000055b9b07c7a25 in select_create::prepare (this=0x7fe360015f88, _values=..., u=0x7fe360004948) at /data/src/10.3/sql/sql_insert.cc:4403
|
#14 0x000055b9b083bbf7 in JOIN::prepare (this=0x7fe360016078, tables_init=0x0, wild_num=0, conds_init=0x0, og_num=0, order_init=0x0, skip_order_by=false, group_init=0x0, having_init=0x0, proc_param_init=0x0, select_lex_arg=0x7fe3600050c0, unit_arg=0x7fe360004948) at /data/src/10.3/sql/sql_select.cc:1331
|
#15 0x000055b9b08457db in mysql_select (thd=0x7fe360000b00, tables=0x0, wild_num=0, fields=..., conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2416184064, result=0x7fe360015f88, unit=0x7fe360004948, select_lex=0x7fe3600050c0) at /data/src/10.3/sql/sql_select.cc:4130
|
#16 0x000055b9b0837deb in handle_select (thd=0x7fe360000b00, lex=0x7fe360004880, result=0x7fe360015f88, setup_tables_done_option=0) at /data/src/10.3/sql/sql_select.cc:382
|
#17 0x000055b9b07fad44 in mysql_execute_command (thd=0x7fe360000b00) at /data/src/10.3/sql/sql_parse.cc:4238
|
#18 0x000055b9b0806cf4 in mysql_parse (thd=0x7fe360000b00, rawbuf=0x7fe360013888 "CREATE OR REPLACE TABLE t1 AS SELECT f1()", length=41, parser_state=0x7fe3cc236620, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:8001
|
#19 0x000055b9b07f44d7 in dispatch_command (command=COM_QUERY, thd=0x7fe360000b00, packet=0x7fe36001bab1 "CREATE OR REPLACE TABLE t1 AS SELECT f1()", packet_length=41, is_com_multi=false, is_next_command=false) at /data/src/10.3/sql/sql_parse.cc:1846
|
#20 0x000055b9b07f2f16 in do_command (thd=0x7fe360000b00) at /data/src/10.3/sql/sql_parse.cc:1391
|
#21 0x000055b9b0955a13 in do_handle_one_connection (connect=0x55b9b4016920) at /data/src/10.3/sql/sql_connect.cc:1402
|
#22 0x000055b9b09557a0 in handle_one_connection (arg=0x55b9b4016920) at /data/src/10.3/sql/sql_connect.cc:1308
|
#23 0x00007fe3d020c494 in start_thread (arg=0x7fe3cc237700) at pthread_create.c:333
|
#24 0x00007fe3ce5f293f in clone () from /lib/x86_64-linux-gnu/libc.so.6
|
{"report":{"fcp":2480.2999997138977,"ttfb":757.5999999046326,"pageVisibility":"visible","entityId":58669,"key":"jira.project.issue.view-issue","isInitial":true,"threshold":1000,"elementTimings":{},"userDeviceMemory":8,"userDeviceProcessors":64,"apdex":0.5,"journeyId":"781e33cb-511a-4bef-9caf-a68fd0564d65","navigationType":0,"readyForUser":2639.3999996185303,"redirectCount":0,"resourceLoadedEnd":2628.2999997138977,"resourceLoadedStart":770,"resourceTiming":[{"duration":1030.8999996185303,"initiatorType":"link","name":"https://jira.mariadb.org/s/2c21342762a6a02add1c328bed317ffd-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/css/_super/batch.css","startTime":770,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":770,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1800.8999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":1031.7000002861023,"initiatorType":"link","name":"https://jira.mariadb.org/s/7ebd35e77e471bc30ff0eba799ebc151-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/css/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.css?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&slack-enabled=true&whisper-enabled=true","startTime":770.2999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":770.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1802,"responseStart":0,"secureConnectionStart":0},{"duration":1043.7000002861023,"initiatorType":"script","name":"https://jira.mariadb.org/s/0917945aaa57108d00c5076fea35e069-CDN/lu2cib/820016/12ta74/0a8bac35585be7fc6c9cc5a0464cd4cf/_/download/contextbatch/js/_super/batch.js?locale=en","startTime":770.3999996185303,"connectEnd":770.3999996185303,"connectStart":770.3999996185303,"domainLookupEnd":770.3999996185303,"domainLookupStart":770.3999996185303,"fetchStart":770.3999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":770.3999996185303,"responseEnd":1814.0999999046326,"responseStart":1814.0999999046326,"secureConnectionStart":770.3999996185303},{"duration":1212.5999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/s/2d8175ec2fa4c816e8023260bd8c1786-CDN/lu2cib/820016/12ta74/494e4c556ecbb29f90a3d3b4f09cb99c/_/download/contextbatch/js/jira.browse.project,project.issue.navigator,jira.view.issue,jira.general,jira.global,atl.general,-_super/batch.js?agile_global_admin_condition=true&jag=true&jira.create.linked.issue=true&locale=en&slack-enabled=true&whisper-enabled=true","startTime":770.5999999046326,"connectEnd":770.5999999046326,"connectStart":770.5999999046326,"domainLookupEnd":770.5999999046326,"domainLookupStart":770.5999999046326,"fetchStart":770.5999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":770.5999999046326,"responseEnd":1983.1999998092651,"responseStart":1983.1999998092651,"secureConnectionStart":770.5999999046326},{"duration":1216.9000000953674,"initiatorType":"script","name":"https://jira.mariadb.org/s/a9324d6758d385eb45c462685ad88f1d-CDN/lu2cib/820016/12ta74/c92c0caa9a024ae85b0ebdbed7fb4bd7/_/download/contextbatch/js/atl.global,-_super/batch.js?locale=en","startTime":770.7999997138977,"connectEnd":770.7999997138977,"connectStart":770.7999997138977,"domainLookupEnd":770.7999997138977,"domainLookupStart":770.7999997138977,"fetchStart":770.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":770.7999997138977,"responseEnd":1987.6999998092651,"responseStart":1987.6999998092651,"secureConnectionStart":770.7999997138977},{"duration":1217.1999998092651,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-en/jira.webresources:calendar-en.js","startTime":771,"connectEnd":771,"connectStart":771,"domainLookupEnd":771,"domainLookupStart":771,"fetchStart":771,"redirectEnd":0,"redirectStart":0,"requestStart":771,"responseEnd":1988.1999998092651,"responseStart":1988.1999998092651,"secureConnectionStart":771},{"duration":1219.8000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:calendar-localisation-moment/jira.webresources:calendar-localisation-moment.js","startTime":771.1999998092651,"connectEnd":771.1999998092651,"connectStart":771.1999998092651,"domainLookupEnd":771.1999998092651,"domainLookupStart":771.1999998092651,"fetchStart":771.1999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":771.1999998092651,"responseEnd":1991,"responseStart":1991,"secureConnectionStart":771.1999998092651},{"duration":1224.0999999046326,"initiatorType":"link","name":"https://jira.mariadb.org/s/b04b06a02d1959df322d9cded3aeecc1-CDN/lu2cib/820016/12ta74/a2ff6aa845ffc9a1d22fe23d9ee791fc/_/download/contextbatch/css/jira.global.look-and-feel,-_super/batch.css","startTime":771.2999997138977,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":771.2999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1995.3999996185303,"responseStart":0,"secureConnectionStart":0},{"duration":1220.5999999046326,"initiatorType":"script","name":"https://jira.mariadb.org/rest/api/1.0/shortcuts/820016/47140b6e0a9bc2e4913da06536125810/shortcuts.js?context=issuenavigation&context=issueaction","startTime":771.5,"connectEnd":771.5,"connectStart":771.5,"domainLookupEnd":771.5,"domainLookupStart":771.5,"fetchStart":771.5,"redirectEnd":0,"redirectStart":0,"requestStart":771.5,"responseEnd":1992.0999999046326,"responseStart":1992.0999999046326,"secureConnectionStart":771.5},{"duration":1223.8000001907349,"initiatorType":"link","name":"https://jira.mariadb.org/s/3ac36323ba5e4eb0af2aa7ac7211b4bb-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/css/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.css?jira.create.linked.issue=true","startTime":771.6999998092651,"connectEnd":0,"connectStart":0,"domainLookupEnd":0,"domainLookupStart":0,"fetchStart":771.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":0,"responseEnd":1995.5,"responseStart":0,"secureConnectionStart":0},{"duration":1221,"initiatorType":"script","name":"https://jira.mariadb.org/s/5d5e8fe91fbc506585e83ea3b62ccc4b-CDN/lu2cib/820016/12ta74/d176f0986478cc64f24226b3d20c140d/_/download/contextbatch/js/com.atlassian.jira.projects.sidebar.init,-_super,-project.issue.navigator,-jira.view.issue/batch.js?jira.create.linked.issue=true&locale=en","startTime":771.8999996185303,"connectEnd":771.8999996185303,"connectStart":771.8999996185303,"domainLookupEnd":771.8999996185303,"domainLookupStart":771.8999996185303,"fetchStart":771.8999996185303,"redirectEnd":0,"redirectStart":0,"requestStart":771.8999996185303,"responseEnd":1992.8999996185303,"responseStart":1992.8999996185303,"secureConnectionStart":771.8999996185303},{"duration":1759.8000001907349,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-js/jira.webresources:bigpipe-js.js","startTime":772.6999998092651,"connectEnd":772.6999998092651,"connectStart":772.6999998092651,"domainLookupEnd":772.6999998092651,"domainLookupStart":772.6999998092651,"fetchStart":772.6999998092651,"redirectEnd":0,"redirectStart":0,"requestStart":772.6999998092651,"responseEnd":2532.5,"responseStart":2532.5,"secureConnectionStart":772.6999998092651},{"duration":1855.5,"initiatorType":"script","name":"https://jira.mariadb.org/s/d41d8cd98f00b204e9800998ecf8427e-CDN/lu2cib/820016/12ta74/1.0/_/download/batch/jira.webresources:bigpipe-init/jira.webresources:bigpipe-init.js","startTime":772.7999997138977,"connectEnd":772.7999997138977,"connectStart":772.7999997138977,"domainLookupEnd":772.7999997138977,"domainLookupStart":772.7999997138977,"fetchStart":772.7999997138977,"redirectEnd":0,"redirectStart":0,"requestStart":772.7999997138977,"responseEnd":2628.2999997138977,"responseStart":2628.2999997138977,"secureConnectionStart":772.7999997138977},{"duration":512.9000000953674,"initiatorType":"xmlhttprequest","name":"https://jira.mariadb.org/rest/webResources/1.0/resources","startTime":2020.0999999046326,"connectEnd":2020.0999999046326,"connectStart":2020.0999999046326,"domainLookupEnd":2020.0999999046326,"domainLookupStart":2020.0999999046326,"fetchStart":2020.0999999046326,"redirectEnd":0,"redirectStart":0,"requestStart":2020.0999999046326,"responseEnd":2533,"responseStart":2533,"secureConnectionStart":2020.0999999046326}],"fetchStart":0,"domainLookupStart":0,"domainLookupEnd":0,"connectStart":0,"connectEnd":0,"requestStart":584,"responseStart":758,"responseEnd":764,"domLoading":768,"domInteractive":2781,"domContentLoadedEventStart":2781,"domContentLoadedEventEnd":2897,"domComplete":5693,"loadEventStart":5694,"loadEventEnd":5699,"userAgent":"Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)","marks":[{"name":"bigPipe.sidebar-id.start","time":2752.0999999046326},{"name":"bigPipe.sidebar-id.end","time":2753.199999809265},{"name":"bigPipe.activity-panel-pipe-id.start","time":2753.3999996185303},{"name":"bigPipe.activity-panel-pipe-id.end","time":2760.2999997138977},{"name":"activityTabFullyLoaded","time":2931.0999999046326}],"measures":[],"correlationId":"69245d91016506","effectiveType":"4g","downlink":9.4,"rtt":0,"serverDuration":103,"dbReadsTimeInMs":12,"dbConnsTimeInMs":21,"applicationHash":"9d11dbea5f4be3d4cc21f03a88dd11d8c8687422","experiments":[]}}