diff options
author | unknown <bell@sanja.is.com.ua> | 2004-09-01 22:48:59 +0300 |
---|---|---|
committer | unknown <bell@sanja.is.com.ua> | 2004-09-01 22:48:59 +0300 |
commit | a3695785e47f8445813774c591d3568686c0e0fd (patch) | |
tree | 8e14b9e084dadabffdca85d55eb767c2609e4cac | |
parent | 321918b3009c4b0443bc3cf4e5eae8a072037b90 (diff) | |
download | mariadb-git-a3695785e47f8445813774c591d3568686c0e0fd.tar.gz |
system charset (with wich VIEW printed) saved in .frm and restored before parsing view (BUG#5163)
mysql-test/r/view.result:
VIEWs with national characters
mysql-test/t/view.test:
VIEWs with national characters
sql/sql_view.cc:
system charset (with wich VIEW printed) saved in .frm and restored before parsing view
sql/table.h:
system charset (with wich VIEW printed) saved in .frm
-rw-r--r-- | mysql-test/r/view.result | 8 | ||||
-rw-r--r-- | mysql-test/t/view.test | 10 | ||||
-rw-r--r-- | sql/sql_view.cc | 36 | ||||
-rw-r--r-- | sql/table.h | 1 |
4 files changed, 48 insertions, 7 deletions
diff --git a/mysql-test/r/view.result b/mysql-test/r/view.result index 9164eb1b8c4..305c72cb063 100644 --- a/mysql-test/r/view.result +++ b/mysql-test/r/view.result @@ -1222,3 +1222,11 @@ show create view v1; Table Create Table v1 CREATE VIEW `test`.`v1` AS select 99999999999999999999999999999999999999999999999999999 AS `col1` drop view v1; +create table tü (cü char); +create view vü as select cü from tü; +insert into vü values ('ü'); +select * from vü; +cü +ü +drop view vü; +drop table tü; diff --git a/mysql-test/t/view.test b/mysql-test/t/view.test index 89841312cd6..28fb40d4045 100644 --- a/mysql-test/t/view.test +++ b/mysql-test/t/view.test @@ -1168,3 +1168,13 @@ drop table t1; create view v1 as select 99999999999999999999999999999999999999999999999999999 as col1; show create view v1; drop view v1; + +# +# VIEWs with national characters +# +create table tü (cü char); +create view vü as select cü from tü; +insert into vü values ('ü'); +select * from vü; +drop view vü; +drop table tü; diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 17c5951d5cd..c27ca9e1c09 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -318,8 +318,10 @@ err: } -// index of revision number in following table -static const int revision_number_position= 4; +/* index of revision number in following table */ +static const int revision_number_position= 5; +/* index of last required parameter for making view */ +static const int last_parameter= 8; static char *view_field_names[]= { @@ -327,6 +329,7 @@ static char *view_field_names[]= (char*)"md5", (char*)"updatable", (char*)"algorithm", + (char*)"syscharset", (char*)"revision", (char*)"timestamp", (char*)"create-version", @@ -343,13 +346,15 @@ static File_option view_parameters[]= FILE_OPTIONS_ULONGLONG}, {{view_field_names[3], 9}, offsetof(TABLE_LIST, algorithm), FILE_OPTIONS_ULONGLONG}, - {{view_field_names[4], 8}, offsetof(TABLE_LIST, revision), + {{view_field_names[4], 10}, offsetof(TABLE_LIST, syscharset), + FILE_OPTIONS_STRING}, + {{view_field_names[5], 8}, offsetof(TABLE_LIST, revision), FILE_OPTIONS_REV}, - {{view_field_names[5], 9}, offsetof(TABLE_LIST, timestamp), + {{view_field_names[6], 9}, offsetof(TABLE_LIST, timestamp), FILE_OPTIONS_TIMESTAMP}, - {{view_field_names[6], 14}, offsetof(TABLE_LIST, file_version), + {{view_field_names[7], 14}, offsetof(TABLE_LIST, file_version), FILE_OPTIONS_ULONGLONG}, - {{view_field_names[7], 6}, offsetof(TABLE_LIST, source), + {{view_field_names[8], 6}, offsetof(TABLE_LIST, source), FILE_OPTIONS_ESTRING}, {{NULL, 0}, 0, FILE_OPTIONS_STRING} @@ -468,6 +473,8 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, view->query.length= str.length()-1; // we do not need last \0 view->source.str= thd->query; view->source.length= thd->query_length; + view->syscharset.str= (char *)system_charset_info->csname; + view->syscharset.length= strlen(view->syscharset.str); view->file_version= 1; view->calc_md5(md5); view->md5.str= md5; @@ -552,7 +559,8 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table) TODO: when VIEWs will be stored in cache, table mem_root should be used here */ - if (parser->parse((gptr)table, &thd->mem_root, view_parameters, 6)) + if (parser->parse((gptr)table, &thd->mem_root, view_parameters, + last_parameter)) goto err; /* @@ -604,7 +612,21 @@ mysql_make_view(File_parser *parser, TABLE_LIST *table) */ thd->options&= ~(MODE_PIPES_AS_CONCAT | MODE_ANSI_QUOTES | MODE_IGNORE_SPACE | MODE_NO_BACKSLASH_ESCAPES); + CHARSET_INFO *save_cs= thd->variables.character_set_client; + if (!table->syscharset.length) + thd->variables.character_set_client= system_charset_info; + else + { + if (!(thd->variables.character_set_client= + get_charset_by_csname(table->syscharset.str, + MY_CS_PRIMARY, MYF(MY_WME)))) + { + thd->variables.character_set_client= save_cs; + goto err; + } + } res= yyparse((void *)thd); + thd->variables.character_set_client= save_cs; thd->options= options; } if (!res && !thd->is_fatal_error) diff --git a/sql/table.h b/sql/table.h index 68c7febb5b6..93a7b8f7cf5 100644 --- a/sql/table.h +++ b/sql/table.h @@ -224,6 +224,7 @@ typedef struct st_table_list LEX_STRING view_db; /* save view database */ LEX_STRING view_name; /* save view name */ LEX_STRING timestamp; /* GMT time stamp of last operation */ + LEX_STRING syscharset; /* charset of VIEW query text*/ ulonglong file_version; /* version of file's field set */ ulonglong updatable_view; /* VIEW can be updated */ ulonglong revision; /* revision control number */ |