From 56f43d9d021ddad1342d5f9c8b47f56a4adbc04e Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 11 Nov 2005 20:03:32 +0300 Subject: [PATCH] Fix bug #13622 Wrong view .frm created if some field's alias contain \n View .frm parser assumes that query string will take only 1 line, with \n in aliases query stringmay take several lines thus produces bad .frm file. 'query' parameter type changed from 'string' to 'escaped string' sql/sql_view.cc: Fix bug #13622 \n in column alias results in broken .frm 'query' parameter type changed to 'escaped string' mysql-test/r/view.result: Test case for bug #13622 Wrong view .frm created if some field's alias contain \n mysql-test/t/view.test: Test case for bug #13622 Wrong view .frm created if some field's alias contain \n --- mysql-test/r/view.result | 8 ++++++++ mysql-test/t/view.test | 9 +++++++++ sql/sql_view.cc | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 6f15e7af399..45d7ef6882d 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -2323,3 +2323,11 @@ id select_type table type possible_keys key key_len ref rows Extra 1 PRIMARY t3 ALL NULL NULL NULL NULL 3 Using where DROP VIEW v1,v2; DROP TABLE t1,t2,t3; +create table t1 (f1 int); +create view v1 as select t1.f1 as '123 +456' from t1; +select * from v1; +123 +456 +drop view v1; +drop table t1; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index aa3189bad69..3bb1e9beb11 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -2189,4 +2189,13 @@ EXPLAIN SELECT * FROM v2 WHERE a=1; DROP VIEW v1,v2; DROP TABLE t1,t2,t3; +# +# Bug #13622 Wrong view .frm created if some field's alias contain \n +# +create table t1 (f1 int); +create view v1 as select t1.f1 as '123 +456' from t1; +select * from v1; +drop view v1; +drop table t1; diff --git a/sql/sql_view.cc b/sql/sql_view.cc index b30f8cb156c..4e7074dc0e5 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -496,7 +496,7 @@ static const int num_view_backups= 3; static File_option view_parameters[]= {{{(char*) STRING_WITH_LEN("query")}, offsetof(TABLE_LIST, query), - FILE_OPTIONS_STRING}, + FILE_OPTIONS_ESTRING}, {{(char*) STRING_WITH_LEN("md5")}, offsetof(TABLE_LIST, md5), FILE_OPTIONS_STRING},