From c7ab676192dcd953a0860a9d021ff49f1c0dfbca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Lindstr=C3=B6m?= Date: Wed, 8 Apr 2020 18:09:28 +0300 Subject: MDEV-22075 : Server crashes in wsrep_should_replicate_ddl_iterate upon CREATE VIEW Fixed incorrect pointer reference when table is not available. --- mysql-test/suite/galera/r/galera_create_view.result | 4 ++++ mysql-test/suite/galera/t/galera_create_view.test | 6 ++++++ sql/wsrep_mysqld.cc | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/galera/r/galera_create_view.result create mode 100644 mysql-test/suite/galera/t/galera_create_view.test diff --git a/mysql-test/suite/galera/r/galera_create_view.result b/mysql-test/suite/galera/r/galera_create_view.result new file mode 100644 index 00000000000..19cc1abda3f --- /dev/null +++ b/mysql-test/suite/galera/r/galera_create_view.result @@ -0,0 +1,4 @@ +connection node_2; +connection node_1; +CREATE OR REPLACE VIEW v AS WITH cte AS ( SELECT 1 ) SELECT * FROM cte; +DROP VIEW v; diff --git a/mysql-test/suite/galera/t/galera_create_view.test b/mysql-test/suite/galera/t/galera_create_view.test new file mode 100644 index 00000000000..69b96a9536c --- /dev/null +++ b/mysql-test/suite/galera/t/galera_create_view.test @@ -0,0 +1,6 @@ +--source include/galera_cluster.inc + +CREATE OR REPLACE VIEW v AS WITH cte AS ( SELECT 1 ) SELECT * FROM cte; + +# Cleanup +DROP VIEW v; diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc index 99e8f0a52ec..6c2f20081a7 100644 --- a/sql/wsrep_mysqld.cc +++ b/sql/wsrep_mysqld.cc @@ -1744,7 +1744,8 @@ bool wsrep_should_replicate_ddl_iterate(THD* thd, const TABLE_LIST* table_list) { for (const TABLE_LIST* it= table_list; it; it= it->next_global) { - if (!wsrep_should_replicate_ddl(thd, it->table->s->db_type()->db_type)) + if (it->table && + !wsrep_should_replicate_ddl(thd, it->table->s->db_type()->db_type)) return false; } } -- cgit v1.2.1