From 11bd1f871aec1fc67bff1f8e2b8f365c70f3cbad Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 1 Sep 2005 00:13:02 +0200 Subject: [PATCH] fix for bug#12913 (Simple SQL can crash server or connection) (not initialized member leads to server crash) mysql-test/r/create.result: result of test for bug #12913 mysql-test/t/create.test: test for bug#12913 (Simple SQL can crash server or connection) sql/sql_table.cc: copy the interval pointer too or a bit later dereferencing of this pointer being 0x0 will crash the server (see bug #12913) --- mysql-test/r/create.result | 5 +++++ mysql-test/t/create.test | 7 +++++++ sql/sql_table.cc | 1 + 3 files changed, 13 insertions(+) diff --git a/mysql-test/r/create.result b/mysql-test/r/create.result index 95757fbd7dc..4de428868a0 100644 --- a/mysql-test/r/create.result +++ b/mysql-test/r/create.result @@ -587,6 +587,11 @@ DESC t2; Field Type Null Key Default Extra f2 varchar(86) YES NULL DROP TABLE t1,t2; +CREATE TABLE t12913 (f1 ENUM ('a','b')) AS SELECT 'a' AS f1; +SELECT * FROM t12913; +f1 +a +DROP TABLE t12913; create database mysqltest; use mysqltest; drop database mysqltest; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index 55321a81f5e..5c69d8f7edf 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -501,6 +501,13 @@ AS f2 FROM t1; DESC t2; DROP TABLE t1,t2; +# +# Bug#12913 Simple SQL can crash server or connection +# +CREATE TABLE t12913 (f1 ENUM ('a','b')) AS SELECT 'a' AS f1; +SELECT * FROM t12913; +DROP TABLE t12913; + # # Bug#11028: Crash on create table like # diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 92db0143980..b8ef6ed342a 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -649,6 +649,7 @@ int mysql_prepare_table(THD *thd, HA_CREATE_INFO *create_info, sql_field->decimals= dup_field->decimals; sql_field->flags= dup_field->flags; sql_field->unireg_check= dup_field->unireg_check; + sql_field->interval= dup_field->interval; it2.remove(); // Remove first (create) definition select_field_pos--; break;