Commit c430f612 authored by Jan Lindström's avatar Jan Lindström

MDEV-25856 : SIGSEGV in ha_myisammrg::append_create_info

For MERGE-tables we need to init children list before calling
show_create_table and then detach children before we continue
normal mysql_create_like_table execution.
parent d0ca2415
...@@ -47,3 +47,8 @@ DROP TABLE schema2.real_table2; ...@@ -47,3 +47,8 @@ DROP TABLE schema2.real_table2;
DROP TABLE schema2.real_table3; DROP TABLE schema2.real_table3;
DROP SCHEMA schema1; DROP SCHEMA schema1;
DROP SCHEMA schema2; DROP SCHEMA schema2;
use test;
CREATE TEMPORARY TABLE t (c INT) ENGINE=mrg_myisam UNION=(t,t2) insert_method=FIRST;
CREATE TABLE t2 LIKE t;
ERROR HY000: Table 't' is differently defined or of non-MyISAM type or doesn't exist
DROP TABLE t;
...@@ -48,3 +48,12 @@ DROP TABLE schema2.real_table3; ...@@ -48,3 +48,12 @@ DROP TABLE schema2.real_table3;
DROP SCHEMA schema1; DROP SCHEMA schema1;
DROP SCHEMA schema2; DROP SCHEMA schema2;
#
# MDEV-25856: SIGSEGV in ha_myisammrg::append_create_info
#
use test;
CREATE TEMPORARY TABLE t (c INT) ENGINE=mrg_myisam UNION=(t,t2) insert_method=FIRST;
--error 1472
CREATE TABLE t2 LIKE t;
DROP TABLE t;
...@@ -2876,7 +2876,7 @@ bool wsrep_create_like_table(THD* thd, TABLE_LIST* table, ...@@ -2876,7 +2876,7 @@ bool wsrep_create_like_table(THD* thd, TABLE_LIST* table,
if (create_info->tmp_table()) if (create_info->tmp_table())
{ {
/* CREATE TEMPORARY TABLE LIKE must be skipped from replication */ /* CREATE TEMPORARY TABLE LIKE must be skipped from replication */
WSREP_DEBUG("CREATE TEMPORARY TABLE LIKE... skipped replication\n %s", WSREP_DEBUG("CREATE TEMPORARY TABLE LIKE... skipped replication\n %s",
thd->query()); thd->query());
} }
else if (!(thd->find_temporary_table(src_table))) else if (!(thd->find_temporary_table(src_table)))
...@@ -2886,21 +2886,17 @@ bool wsrep_create_like_table(THD* thd, TABLE_LIST* table, ...@@ -2886,21 +2886,17 @@ bool wsrep_create_like_table(THD* thd, TABLE_LIST* table,
} }
else else
{ {
/* here we have CREATE TABLE LIKE <temporary table> /* Non-MERGE tables ignore this call. */
the temporary table definition will be needed in slaves to if (src_table->table->file->extra(HA_EXTRA_ADD_CHILDREN_LIST))
enable the create to succeed return (true);
*/
TABLE_LIST tbl;
bzero((void*) &tbl, sizeof(tbl));
tbl.db= src_table->db;
tbl.table_name= tbl.alias= src_table->table_name;
tbl.table= src_table->table;
char buf[2048]; char buf[2048];
String query(buf, sizeof(buf), system_charset_info); String query(buf, sizeof(buf), system_charset_info);
query.length(0); // Have to zero it since constructor doesn't query.length(0); // Have to zero it since constructor doesn't
(void) show_create_table(thd, &tbl, &query, NULL, WITH_DB_NAME); int result __attribute__((unused))=
WSREP_DEBUG("TMP TABLE: %s", query.ptr()); show_create_table(thd, src_table, &query, NULL, WITH_DB_NAME);
WSREP_DEBUG("TMP TABLE: %s ret_code %d", query.ptr(), result);
thd->wsrep_TOI_pre_query= query.ptr(); thd->wsrep_TOI_pre_query= query.ptr();
thd->wsrep_TOI_pre_query_len= query.length(); thd->wsrep_TOI_pre_query_len= query.length();
...@@ -2909,11 +2905,14 @@ bool wsrep_create_like_table(THD* thd, TABLE_LIST* table, ...@@ -2909,11 +2905,14 @@ bool wsrep_create_like_table(THD* thd, TABLE_LIST* table,
thd->wsrep_TOI_pre_query= NULL; thd->wsrep_TOI_pre_query= NULL;
thd->wsrep_TOI_pre_query_len= 0; thd->wsrep_TOI_pre_query_len= 0;
/* Non-MERGE tables ignore this call. */
src_table->table->file->extra(HA_EXTRA_DETACH_CHILDREN);
} }
return(false); return(false);
WSREP_ERROR_LABEL: wsrep_error_label:
thd->wsrep_TOI_pre_query= NULL; thd->wsrep_TOI_pre_query= NULL;
return (true); return (true);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment