Skip to content

Commit c430f61

Browse files
author
Jan Lindström
committed
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.
1 parent d0ca241 commit c430f61

File tree

3 files changed

+26
-13
lines changed

3 files changed

+26
-13
lines changed

mysql-test/suite/galera/r/galera_create_table_like.result

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,8 @@ DROP TABLE schema2.real_table2;
4747
DROP TABLE schema2.real_table3;
4848
DROP SCHEMA schema1;
4949
DROP SCHEMA schema2;
50+
use test;
51+
CREATE TEMPORARY TABLE t (c INT) ENGINE=mrg_myisam UNION=(t,t2) insert_method=FIRST;
52+
CREATE TABLE t2 LIKE t;
53+
ERROR HY000: Table 't' is differently defined or of non-MyISAM type or doesn't exist
54+
DROP TABLE t;

mysql-test/suite/galera/t/galera_create_table_like.test

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,12 @@ DROP TABLE schema2.real_table3;
4848

4949
DROP SCHEMA schema1;
5050
DROP SCHEMA schema2;
51+
52+
#
53+
# MDEV-25856: SIGSEGV in ha_myisammrg::append_create_info
54+
#
55+
use test;
56+
CREATE TEMPORARY TABLE t (c INT) ENGINE=mrg_myisam UNION=(t,t2) insert_method=FIRST;
57+
--error 1472
58+
CREATE TABLE t2 LIKE t;
59+
DROP TABLE t;

sql/wsrep_mysqld.cc

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2876,7 +2876,7 @@ bool wsrep_create_like_table(THD* thd, TABLE_LIST* table,
28762876
if (create_info->tmp_table())
28772877
{
28782878
/* CREATE TEMPORARY TABLE LIKE must be skipped from replication */
2879-
WSREP_DEBUG("CREATE TEMPORARY TABLE LIKE... skipped replication\n %s",
2879+
WSREP_DEBUG("CREATE TEMPORARY TABLE LIKE... skipped replication\n %s",
28802880
thd->query());
28812881
}
28822882
else if (!(thd->find_temporary_table(src_table)))
@@ -2886,21 +2886,17 @@ bool wsrep_create_like_table(THD* thd, TABLE_LIST* table,
28862886
}
28872887
else
28882888
{
2889-
/* here we have CREATE TABLE LIKE <temporary table>
2890-
the temporary table definition will be needed in slaves to
2891-
enable the create to succeed
2892-
*/
2893-
TABLE_LIST tbl;
2894-
bzero((void*) &tbl, sizeof(tbl));
2895-
tbl.db= src_table->db;
2896-
tbl.table_name= tbl.alias= src_table->table_name;
2897-
tbl.table= src_table->table;
2889+
/* Non-MERGE tables ignore this call. */
2890+
if (src_table->table->file->extra(HA_EXTRA_ADD_CHILDREN_LIST))
2891+
return (true);
2892+
28982893
char buf[2048];
28992894
String query(buf, sizeof(buf), system_charset_info);
29002895
query.length(0); // Have to zero it since constructor doesn't
29012896

2902-
(void) show_create_table(thd, &tbl, &query, NULL, WITH_DB_NAME);
2903-
WSREP_DEBUG("TMP TABLE: %s", query.ptr());
2897+
int result __attribute__((unused))=
2898+
show_create_table(thd, src_table, &query, NULL, WITH_DB_NAME);
2899+
WSREP_DEBUG("TMP TABLE: %s ret_code %d", query.ptr(), result);
29042900

29052901
thd->wsrep_TOI_pre_query= query.ptr();
29062902
thd->wsrep_TOI_pre_query_len= query.length();
@@ -2909,11 +2905,14 @@ bool wsrep_create_like_table(THD* thd, TABLE_LIST* table,
29092905

29102906
thd->wsrep_TOI_pre_query= NULL;
29112907
thd->wsrep_TOI_pre_query_len= 0;
2908+
2909+
/* Non-MERGE tables ignore this call. */
2910+
src_table->table->file->extra(HA_EXTRA_DETACH_CHILDREN);
29122911
}
29132912

29142913
return(false);
29152914

2916-
WSREP_ERROR_LABEL:
2915+
wsrep_error_label:
29172916
thd->wsrep_TOI_pre_query= NULL;
29182917
return (true);
29192918
}

0 commit comments

Comments
 (0)