Below is the list of changes that have just been committed into a local
5.1 repository of anozdrin. When anozdrin does a push these changes
will be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html
ChangeSet@stripped, 2008-01-28 16:20:15+03:00, anozdrin@quad. +14 -0
Fix for Bug#30217: Views: changes in metadata behaviour
between 5.0 and 5.1.
The problem was that in the patch for Bug#11986 it was decided
to store original query in UTF8 encoding for the INFORMATION_SCHEMA.
This approach however turned out to be quite difficult to implement
properly.
So, the fix is to rollback to the previous functionality, but also
to fix it to support multi-character-set-queries properly. The idea
is to generate UTF8-query from the item-tree after parsing view
declaration. The UTF8-query should:
- be completely in UTF8;
- not contain character set introducers.
For more information, see WL4052.
mysql-test/include/ddl_i18n.check_views.inc@stripped, 2008-01-28 16:20:13+03:00, anozdrin@quad. +12 -0
Add a test case for Bug#30217.
mysql-test/r/ddl_i18n_koi8r.result@stripped, 2008-01-28 16:20:13+03:00, anozdrin@quad. +45 -7
Update result file.
mysql-test/r/ddl_i18n_utf8.result@stripped, 2008-01-28 16:20:13+03:00, anozdrin@quad. +45 -7
Update result file.
mysql-test/r/information_schema.result@stripped, 2008-01-28 16:20:13+03:00, anozdrin@quad. +10 -15
Update result file.
mysql-test/r/information_schema_db.result@stripped, 2008-01-28 16:20:13+03:00, anozdrin@quad. +1 -1
Update result file.
mysql-test/r/show_check.result@stripped, 2008-01-28 16:20:13+03:00, anozdrin@quad. +2 -2
Update result file.
mysql-test/t/ddl_i18n_koi8r.test@stripped, 2008-01-28 16:20:13+03:00, anozdrin@quad. +7 -1
Add a test case for Bug#30217.
mysql-test/t/ddl_i18n_utf8.test@stripped, 2008-01-28 16:20:13+03:00, anozdrin@quad. +7 -1
Add a test case for Bug#30217.
sql/item.cc@stripped, 2008-01-28 16:20:13+03:00, anozdrin@quad. +32 -3
Item_string::print():
- Do not append character set introducer to the text literal
if we're building UTF8-query for INFORMATION_SCHEMA;
- Convert text literal to UTF8 if we're building UTF8-query
for INFORMATION_SCHEMA.
sql/sql_class.cc@stripped, 2008-01-28 16:20:13+03:00, anozdrin@quad. +50 -29
1. Initialize THD::m_dump_utf8_query in the constructor;
2. Polishing:
- make THD::init() private;
- update comments.
sql/sql_class.h@stripped, 2008-01-28 16:20:13+03:00, anozdrin@quad. +18 -9
1. Introduce dump_utf8_query property of THD;
2. Make THD::init() private;
sql/sql_lex.h@stripped, 2008-01-28 16:20:13+03:00, anozdrin@quad. +0 -2
Remove st_lex::view_body_utf8.
sql/sql_view.cc@stripped, 2008-01-28 16:20:13+03:00, anozdrin@quad. +21 -3
Build UTF8-query for INFORMATION_SCHEMA from item-tree.
sql/sql_yacc.yy@stripped, 2008-01-28 16:20:14+03:00, anozdrin@quad. +1 -21
Remove st_lex::view_body_utf8.
diff -Nrup a/mysql-test/include/ddl_i18n.check_views.inc b/mysql-test/include/ddl_i18n.check_views.inc
--- a/mysql-test/include/ddl_i18n.check_views.inc 2007-06-28 21:34:50 +04:00
+++ b/mysql-test/include/ddl_i18n.check_views.inc 2008-01-28 16:20:13 +03:00
@@ -9,6 +9,10 @@ SHOW CREATE VIEW v1|
SHOW CREATE VIEW v2|
+--echo
+
+SHOW CREATE VIEW v3|
+
# - Check INFORMATION_SCHEMA;
--echo
@@ -20,6 +24,10 @@ SELECT * FROM INFORMATION_SCHEMA.VIEWS W
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'|
+--echo
+
+SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v3'|
+
# - Execute the views;
--echo
@@ -30,3 +38,7 @@ SELECT COLLATION(c1), COLLATION(c2) FROM
--echo
SELECT COLLATION(c1) FROM v2|
+
+--echo
+
+SELECT * FROM v3|
diff -Nrup a/mysql-test/r/ddl_i18n_koi8r.result b/mysql-test/r/ddl_i18n_koi8r.result
--- a/mysql-test/r/ddl_i18n_koi8r.result 2007-09-28 15:02:41 +04:00
+++ b/mysql-test/r/ddl_i18n_koi8r.result 2008-01-28 16:20:13 +03:00
@@ -16,6 +16,8 @@ FROM t1|
CREATE VIEW v2 AS SELECT _utf8'тест' as c1|
+CREATE VIEW v3 AS SELECT _utf8'тест'|
+
SHOW CREATE VIEW v1|
@@ -26,15 +28,22 @@ SHOW CREATE VIEW v2|
View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select _utf8'тест' AS `c1` koi8r koi8r_general_ci
+SHOW CREATE VIEW v3|
+View Create View character_set_client collation_connection
+
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
-FROM t1 NONE YES root@localhost DEFINER koi8r koi8r_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+
+SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v3'|
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
SELECT COLLATION(c1), COLLATION(c2) FROM v1|
@@ -45,6 +54,10 @@ SELECT COLLATION(c1) FROM v2|
COLLATION(c1)
utf8_general_ci
+SELECT * FROM v3|
+
ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
@@ -54,6 +67,7 @@ SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci|
SELECT * FROM mysqltest1.v1|
SELECT * FROM mysqltest1.v2|
+SELECT * FROM mysqltest1.v3|
use mysqltest1|
set names koi8r|
@@ -66,15 +80,22 @@ SHOW CREATE VIEW v2|
View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select _utf8'тест' AS `c1` koi8r koi8r_general_ci
+SHOW CREATE VIEW v3|
+View Create View character_set_client collation_connection
+
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
-FROM t1 NONE YES root@localhost DEFINER koi8r koi8r_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+
+SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v3'|
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
SELECT COLLATION(c1), COLLATION(c2) FROM v1|
@@ -85,6 +106,10 @@ SELECT COLLATION(c1) FROM v2|
COLLATION(c1)
utf8_general_ci
+SELECT * FROM v3|
+
---> Dumping mysqltest1 to ddl_i18n_koi8r.views.mysqltest1.sql
@@ -99,6 +124,7 @@ SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci|
SELECT * FROM mysqltest1.v1|
SELECT * FROM mysqltest1.v2|
+SELECT * FROM mysqltest1.v3|
use mysqltest1|
set names koi8r|
@@ -111,15 +137,23 @@ SHOW CREATE VIEW v2|
View Create View character_set_client collation_connection
v2 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v2` AS select _utf8'тест' AS `c1` koi8r koi8r_general_ci
+SHOW CREATE VIEW v3|
+View Create View character_set_client collation_connection
+
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v3'|
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+
SELECT COLLATION(c1), COLLATION(c2) FROM v1|
COLLATION(c1) COLLATION(c2)
@@ -128,6 +162,10 @@ koi8r_general_ci binary
SELECT COLLATION(c1) FROM v2|
COLLATION(c1)
utf8_general_ci
+
+SELECT * FROM v3|
---> connection: default
use test|
diff -Nrup a/mysql-test/r/ddl_i18n_utf8.result b/mysql-test/r/ddl_i18n_utf8.result
--- a/mysql-test/r/ddl_i18n_utf8.result 2007-09-28 15:02:41 +04:00
+++ b/mysql-test/r/ddl_i18n_utf8.result 2008-01-28 16:20:13 +03:00
@@ -16,6 +16,8 @@ FROM t1|
+
SHOW CREATE VIEW v1|
@@ -26,15 +28,22 @@ SHOW CREATE VIEW v2|
View Create View character_set_client collation_connection
+SHOW CREATE VIEW v3|
+View Create View character_set_client collation_connection
+
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
-NULL mysqltest1 v1 SELECT 'тест' AS c1, кол AS c2
-FROM t1 NONE YES root@localhost DEFINER utf8 utf8_general_ci
+NULL mysqltest1 v1 select 'тест' AS `c1`,`mysqltest1`.`t1`.`кол` AS `c2` from `mysqltest1`.`t1` NONE YES root@localhost DEFINER utf8 utf8_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
-NULL mysqltest1 v2 SELECT 'тест' as c1 NONE NO root@localhost DEFINER utf8 utf8_general_ci
+NULL mysqltest1 v2 select 'тест' AS `c1` NONE NO root@localhost DEFINER utf8 utf8_general_ci
+
+SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v3'|
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+NULL mysqltest1 v3 select 'тест' AS `тест` NONE NO root@localhost DEFINER utf8 utf8_general_ci
SELECT COLLATION(c1), COLLATION(c2) FROM v1|
@@ -45,6 +54,10 @@ SELECT COLLATION(c1) FROM v2|
COLLATION(c1)
koi8r_general_ci
+SELECT * FROM v3|
+тест
+тест
+
ALTER DATABASE mysqltest1 COLLATE cp866_general_ci|
@@ -54,6 +67,7 @@ SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci|
SELECT * FROM mysqltest1.v1|
SELECT * FROM mysqltest1.v2|
+SELECT * FROM mysqltest1.v3|
use mysqltest1|
set names utf8|
@@ -66,15 +80,22 @@ SHOW CREATE VIEW v2|
View Create View character_set_client collation_connection
+SHOW CREATE VIEW v3|
+View Create View character_set_client collation_connection
+
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
-NULL mysqltest1 v1 SELECT 'тест' AS c1, кол AS c2
-FROM t1 NONE YES root@localhost DEFINER utf8 utf8_general_ci
+NULL mysqltest1 v1 select 'тест' AS `c1`,`mysqltest1`.`t1`.`кол` AS `c2` from `mysqltest1`.`t1` NONE YES root@localhost DEFINER utf8 utf8_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
-NULL mysqltest1 v2 SELECT 'тест' as c1 NONE NO root@localhost DEFINER utf8 utf8_general_ci
+NULL mysqltest1 v2 select 'тест' AS `c1` NONE NO root@localhost DEFINER utf8 utf8_general_ci
+
+SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v3'|
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+NULL mysqltest1 v3 select 'тест' AS `тест` NONE NO root@localhost DEFINER utf8 utf8_general_ci
SELECT COLLATION(c1), COLLATION(c2) FROM v1|
@@ -85,6 +106,10 @@ SELECT COLLATION(c1) FROM v2|
COLLATION(c1)
koi8r_general_ci
+SELECT * FROM v3|
+тест
+тест
+
---> Dumping mysqltest1 to ddl_i18n_utf8views.mysqltest1.sql
@@ -99,6 +124,7 @@ SET @@character_set_results= cp1251|
SET @@collation_connection= cp1251_general_ci|
SELECT * FROM mysqltest1.v1|
SELECT * FROM mysqltest1.v2|
+SELECT * FROM mysqltest1.v3|
use mysqltest1|
set names utf8|
@@ -111,15 +137,23 @@ SHOW CREATE VIEW v2|
View Create View character_set_client collation_connection
+SHOW CREATE VIEW v3|
+View Create View character_set_client collation_connection
+
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v1'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
-NULL mysqltest1 v1 select 'тест' AS `c1`,`t1`.`кол` AS `c2` from `t1` NONE YES root@localhost DEFINER utf8 utf8_general_ci
+NULL mysqltest1 v1 select 'тест' AS `c1`,`mysqltest1`.`t1`.`кол` AS `c2` from `mysqltest1`.`t1` NONE YES root@localhost DEFINER utf8 utf8_general_ci
SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v2'|
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL mysqltest1 v2 select 'тест' AS `c1` NONE NO root@localhost DEFINER utf8 utf8_general_ci
+SELECT * FROM INFORMATION_SCHEMA.VIEWS WHERE table_name = 'v3'|
+TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
+NULL mysqltest1 v3 select 'тест' AS `тест` NONE NO root@localhost DEFINER utf8 utf8_general_ci
+
SELECT COLLATION(c1), COLLATION(c2) FROM v1|
COLLATION(c1) COLLATION(c2)
@@ -128,6 +162,10 @@ utf8_general_ci binary
SELECT COLLATION(c1) FROM v2|
COLLATION(c1)
koi8r_general_ci
+
+SELECT * FROM v3|
+тест
+тест
---> connection: default
use test|
diff -Nrup a/mysql-test/r/information_schema.result b/mysql-test/r/information_schema.result
--- a/mysql-test/r/information_schema.result 2007-12-04 11:48:09 +03:00
+++ b/mysql-test/r/information_schema.result 2008-01-28 16:20:13 +03:00
@@ -386,15 +386,11 @@ show keys from v4;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
select * from information_schema.views where TABLE_NAME like "v%";
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
-NULL test v0 select schema_name from information_schema.schemata NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
-NULL test v1 select table_name from information_schema.tables
-where table_name="v1" NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
-NULL test v2 select column_name from information_schema.columns
-where table_name="v2" NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
-NULL test v3 select CHARACTER_SET_NAME from information_schema.character_sets
-where CHARACTER_SET_NAME like "latin1%" NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
-NULL test v4 select COLLATION_NAME from information_schema.collations
-where COLLATION_NAME like "latin1%" NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
+NULL test v0 select `schemata`.`SCHEMA_NAME` AS `c` from `information_schema`.`schemata` NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
+NULL test v1 select `tables`.`TABLE_NAME` AS `c` from `information_schema`.`tables` where (`tables`.`TABLE_NAME` = 'v1') NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
+NULL test v2 select `columns`.`COLUMN_NAME` AS `c` from `information_schema`.`columns` where (`columns`.`TABLE_NAME` = 'v2') NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
+NULL test v3 select `character_sets`.`CHARACTER_SET_NAME` AS `c` from `information_schema`.`character_sets` where (`character_sets`.`CHARACTER_SET_NAME` like 'latin1%') NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
+NULL test v4 select `collations`.`COLLATION_NAME` AS `c` from `information_schema`.`collations` where (`collations`.`COLLATION_NAME` like 'latin1%') NONE NO root@localhost DEFINER latin1 latin1_swedish_ci
drop view v0, v1, v2, v3, v4;
create table t1 (a int);
grant select,update,insert on t1 to mysqltest_1@localhost;
@@ -487,9 +483,9 @@ create view v2 (c) as select a from t1 W
create view v3 (c) as select a from t1 WITH CASCADED CHECK OPTION;
select * from information_schema.views;
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
-NULL test v1 select a from t1 with check option CASCADED YES root@localhost DEFINER latin1 latin1_swedish_ci
-NULL test v2 select a from t1 WITH LOCAL CHECK OPTION LOCAL YES root@localhost DEFINER latin1 latin1_swedish_ci
-NULL test v3 select a from t1 WITH CASCADED CHECK OPTION CASCADED YES root@localhost DEFINER latin1 latin1_swedish_ci
+NULL test v1 select `test`.`t1`.`a` AS `c` from `test`.`t1` CASCADED YES root@localhost DEFINER latin1 latin1_swedish_ci
+NULL test v2 select `test`.`t1`.`a` AS `c` from `test`.`t1` LOCAL YES root@localhost DEFINER latin1 latin1_swedish_ci
+NULL test v3 select `test`.`t1`.`a` AS `c` from `test`.`t1` CASCADED YES root@localhost DEFINER latin1 latin1_swedish_ci
grant select (a) on test.t1 to joe@localhost with grant option;
select * from INFORMATION_SCHEMA.COLUMN_PRIVILEGES;
GRANTEE TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME PRIVILEGE_TYPE IS_GRANTABLE
@@ -1174,7 +1170,7 @@ select * from information_schema.views
where table_name='v1' or table_name='v2';
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
NULL test v1 NONE YES root@localhost DEFINER latin1 latin1_swedish_ci
-NULL test v2 select 1 NONE NO mysqltest_1@localhost DEFINER latin1 latin1_swedish_ci
+NULL test v2 select 1 AS `1` NONE NO mysqltest_1@localhost DEFINER latin1 latin1_swedish_ci
drop view v1, v2;
drop table t1;
drop user mysqltest_1@localhost;
@@ -1555,8 +1551,7 @@ AS SELECT *
FROM INFORMATION_SCHEMA.TABLES;
SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS where TABLE_NAME = 'v1';
VIEW_DEFINITION
-SELECT *
-FROM INFORMATION_SCHEMA.TABLES
+select `TABLES`.`TABLE_CATALOG` AS `TABLE_CATALOG`,`TABLES`.`TABLE_SCHEMA` AS `TABLE_SCHEMA`,`TABLES`.`TABLE_NAME` AS `TABLE_NAME`,`TABLES`.`TABLE_TYPE` AS `TABLE_TYPE`,`TABLES`.`ENGINE` AS `ENGINE`,`TABLES`.`VERSION` AS `VERSION`,`TABLES`.`ROW_FORMAT` AS `ROW_FORMAT`,`TABLES`.`TABLE_ROWS` AS `TABLE_ROWS`,`TABLES`.`AVG_ROW_LENGTH` AS `AVG_ROW_LENGTH`,`TABLES`.`DATA_LENGTH` AS `DATA_LENGTH`,`TABLES`.`MAX_DATA_LENGTH` AS `MAX_DATA_LENGTH`,`TABLES`.`INDEX_LENGTH` AS `INDEX_LENGTH`,`TABLES`.`DATA_FREE` AS `DATA_FREE`,`TABLES`.`AUTO_INCREMENT` AS `AUTO_INCREMENT`,`TABLES`.`CREATE_TIME` AS `CREATE_TIME`,`TABLES`.`UPDATE_TIME` AS `UPDATE_TIME`,`TABLES`.`CHECK_TIME` AS `CHECK_TIME`,`TABLES`.`TABLE_COLLATION` AS `TABLE_COLLATION`,`TABLES`.`CHECKSUM` AS `CHECKSUM`,`TABLES`.`CREATE_OPTIONS` AS `CREATE_OPTIONS`,`TABLES`.`TABLE_COMMENT` AS `TABLE_COMMENT` from `INFORMATION_SCHEMA`.`TABLES`
DROP VIEW v1;
SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME ='information_schema';
diff -Nrup a/mysql-test/r/information_schema_db.result b/mysql-test/r/information_schema_db.result
--- a/mysql-test/r/information_schema_db.result 2007-10-26 12:24:28 +04:00
+++ b/mysql-test/r/information_schema_db.result 2008-01-28 16:20:13 +03:00
@@ -209,7 +209,7 @@ v2
select view_definition from information_schema.views a
where a.table_name = 'v2';
view_definition
-select f1 from testdb_1.v1
+select `v1`.`f1` AS `f1` from `testdb_1`.`v1`
select view_definition from information_schema.views a
where a.table_name = 'testdb_1.v1';
view_definition
diff -Nrup a/mysql-test/r/show_check.result b/mysql-test/r/show_check.result
--- a/mysql-test/r/show_check.result 2007-11-13 16:22:37 +03:00
+++ b/mysql-test/r/show_check.result 2008-01-28 16:20:13 +03:00
@@ -1075,7 +1075,7 @@ Catalog Database Table Table_alias Colum
def VIEWS TABLE_CATALOG TABLE_CATALOG 253 1536 0 Y 0 0 33
def VIEWS TABLE_SCHEMA TABLE_SCHEMA 253 192 4 N 1 0 33
def VIEWS TABLE_NAME TABLE_NAME 253 192 2 N 1 0 33
-def VIEWS VIEW_DEFINITION VIEW_DEFINITION 252 589815 8 N 17 0 33
+def VIEWS VIEW_DEFINITION VIEW_DEFINITION 252 589815 15 N 17 0 33
def VIEWS CHECK_OPTION CHECK_OPTION 253 24 4 N 1 0 33
def VIEWS IS_UPDATABLE IS_UPDATABLE 253 9 2 N 1 0 33
def VIEWS DEFINER DEFINER 253 231 14 N 1 0 33
@@ -1083,7 +1083,7 @@ def VIEWS SECURITY_TYPE SECURITY_TYPE
def VIEWS CHARACTER_SET_CLIENT CHARACTER_SET_CLIENT 253 96 6 N 1 0 33
def VIEWS COLLATION_CONNECTION COLLATION_CONNECTION 253 96 6 N 1 0 33
TABLE_CATALOG TABLE_SCHEMA TABLE_NAME VIEW_DEFINITION CHECK_OPTION IS_UPDATABLE DEFINER SECURITY_TYPE CHARACTER_SET_CLIENT COLLATION_CONNECTION
-NULL test v1 SELECT 1 NONE NO root@localhost DEFINER binary binary
+NULL test v1 select 1 AS `1` NONE NO root@localhost DEFINER binary binary
----------------------------------------------------------------
SHOW CREATE PROCEDURE p1;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
diff -Nrup a/mysql-test/t/ddl_i18n_koi8r.test b/mysql-test/t/ddl_i18n_koi8r.test
--- a/mysql-test/t/ddl_i18n_koi8r.test 2007-07-19 01:31:17 +04:00
+++ b/mysql-test/t/ddl_i18n_koi8r.test 2008-01-28 16:20:13 +03:00
@@ -85,6 +85,10 @@ CREATE VIEW v2 AS SELECT _utf8'тест'
--echo
+CREATE VIEW v3 AS SELECT _utf8'тест'|
+
+--echo
+
#
# First-round checks.
#
@@ -120,6 +124,7 @@ SET @@collation_connection= cp1251_gener
--disable_result_log
SELECT * FROM mysqltest1.v1|
SELECT * FROM mysqltest1.v2|
+SELECT * FROM mysqltest1.v3|
--enable_result_log
use mysqltest1|
@@ -168,7 +173,7 @@ DROP DATABASE mysqltest1|
--echo
--echo ---> connection: con3
-# - Switch environment variables and trigger loading stored procedures;
+# - Switch environment variables and trigger loading views;
SET @@character_set_client= cp1251|
SET @@character_set_results= cp1251|
@@ -177,6 +182,7 @@ SET @@collation_connection= cp1251_gener
--disable_result_log
SELECT * FROM mysqltest1.v1|
SELECT * FROM mysqltest1.v2|
+SELECT * FROM mysqltest1.v3|
--enable_result_log
use mysqltest1|
diff -Nrup a/mysql-test/t/ddl_i18n_utf8.test b/mysql-test/t/ddl_i18n_utf8.test
--- a/mysql-test/t/ddl_i18n_utf8.test 2007-07-19 01:31:17 +04:00
+++ b/mysql-test/t/ddl_i18n_utf8.test 2008-01-28 16:20:13 +03:00
--echo
+
+--echo
+
#
# First-round checks.
#
@@ -120,6 +124,7 @@ SET @@collation_connection= cp1251_gener
--disable_result_log
SELECT * FROM mysqltest1.v1|
SELECT * FROM mysqltest1.v2|
+SELECT * FROM mysqltest1.v3|
--enable_result_log
use mysqltest1|
@@ -168,7 +173,7 @@ DROP DATABASE mysqltest1|
--echo
--echo ---> connection: con3
-# - Switch environment variables and trigger loading stored procedures;
+# - Switch environment variables and trigger loading views;
SET @@character_set_client= cp1251|
SET @@character_set_results= cp1251|
@@ -177,6 +182,7 @@ SET @@collation_connection= cp1251_gener
--disable_result_log
SELECT * FROM mysqltest1.v1|
SELECT * FROM mysqltest1.v2|
+SELECT * FROM mysqltest1.v3|
--enable_result_log
use mysqltest1|
diff -Nrup a/sql/item.cc b/sql/item.cc
--- a/sql/item.cc 2008-01-19 20:59:07 +03:00
+++ b/sql/item.cc 2008-01-28 16:20:13 +03:00
@@ -2304,10 +2304,39 @@ my_decimal *Item_float::val_decimal(my_d
void Item_string::print(String *str)
{
- str->append('_');
- str->append(collation.collation->csname);
+ THD *thd= current_thd;
+ bool dump_utf8_query= thd->get_dump_utf8_query();
+
+ if (!dump_utf8_query)
+ {
+ str->append('_');
+ str->append(collation.collation->csname);
+ }
+
str->append('\'');
- str_value.print(str);
+
+ if (dump_utf8_query &&
+ !my_charset_same(str_value.charset(), system_charset_info))
+ {
+ LEX_STRING utf8_lex_str;
+
+ thd->convert_string(&utf8_lex_str,
+ system_charset_info,
+ str_value.c_ptr_safe(),
+ str_value.length(),
+ str_value.charset());
+
+ String utf8_str(utf8_lex_str.str,
+ utf8_lex_str.length,
+ system_charset_info);
+
+ utf8_str.print(str);
+ }
+ else
+ {
+ str_value.print(str);
+ }
+
str->append('\'');
}
diff -Nrup a/sql/sql_class.cc b/sql/sql_class.cc
--- a/sql/sql_class.cc 2008-01-10 20:44:21 +03:00
+++ b/sql/sql_class.cc 2008-01-28 16:20:13 +03:00
@@ -493,7 +493,8 @@ THD::THD()
bootstrap(0),
derived_tables_processing(FALSE),
spcont(NULL),
- m_lip(NULL)
+ m_lip(NULL),
+ m_dump_utf8_query(FALSE)
{
ulong tmp;
@@ -570,7 +571,8 @@ THD::THD()
command=COM_CONNECT;
*scramble= '\0';
- init();
+ init(); // TODO: why call it here, why not in init_for_queries()?
+
/* Initialize sub structures */
init_sql_alloc(&warn_root, WARN_ALLOC_BLOCK_SIZE, WARN_ALLOC_PREALLOC_SIZE);
user_connect=(USER_CONN *)0;
@@ -677,8 +679,10 @@ void thd_get_xid(const MYSQL_THD thd, MY
*xid = *(MYSQL_XID *) &thd->transaction.xid_state.xid;
}
-/*
- Init common variables that has to be reset on start and on change_user
+/**
+ This operation just contains the code common for THD-instance
+ initialization for a new connection and for COM_CHANGE_USER
+ implementation.
*/
void THD::init(void)
@@ -722,16 +726,30 @@ void THD::init(void)
bzero((char *) &status_var, sizeof(status_var));
}
+/**
+ Initialize THD instance for connection processing.
-/*
- Init THD for query processing.
- This has to be called once before we call mysql_parse.
- See also comments in sql_class.h.
+ Initialize memory roots necessary for query processing and (!)
+ pre-allocate memory for it. We can't do that in THD constructor because
+ there are use cases (acl_init, delayed inserts, watcher threads, killing
+ mysqld) where it's vital to not allocate excessive and not used memory.
+
+ TODO: is it really the case? It seems, THD::init_for_queries() is always
+ called for THD instance. It seems, the real reason is that THD instance
+ can be cached, i.e. one THD instance can serve several connections. So,
+ this operation pre-allocates memory for the new connection. Similarly,
+ cleanup() frees pre-allocated memory for the connection.
+
+ This operation must be be called once before query parsing (i.e. before
+ calling mysql_parse()).
+
+ @note This operation does not return error. If preallocation fails, it
+ will be noticed at the first call to alloc_root().
*/
void THD::init_for_queries()
{
- set_time();
+ set_time();
ha_enable_transaction(this,TRUE);
reset_root_defaults(mem_root, variables.query_alloc_block_size,
@@ -746,14 +764,11 @@ void THD::init_for_queries()
}
-/*
- Do what's needed when one invokes change user
+/**
+ Change user context (implement COM_CHANGE_USER).
- SYNOPSIS
- change_user()
-
- IMPLEMENTATION
- Reset all resources that are connection specific
+ Basically change_user() resets all resources that are connection
+ specific.
*/
@@ -772,7 +787,13 @@ void THD::change_user(void)
}
-/* Do operations that may take a long time */
+/**
+ Cleanup THD instance after connection.
+
+ Reverse operation for THD::init_for_queries(). THD::cleanup() frees all
+ the connection-specific memory so that THD instance can be placed back
+ into the cache and then used for handling another connection.
+*/
void THD::cleanup(void)
{
@@ -1017,20 +1038,20 @@ bool THD::store_globals()
}
-/*
- Cleanup after query.
+/**
+ Cleanup THD instance after query execution.
- SYNOPSIS
- THD::cleanup_after_query()
-
- DESCRIPTION
- This function is used to reset thread data to its default state.
+ This function is used to reset thread data to its default state. It is
+ called once after processing one atomic query.
- NOTE
- This function is not suitable for setting thread data to some
- non-default values, as there is only one replication thread, so
- different master threads may overwrite data of each other on
- slave.
+ Unfortunately there is no distinguish operation to be called before
+ processing atomic query -- this logic is distributed in the code. For
+ example, one can consider sql_parse.cc (dispatch_command(), alloc_root(),
+ mysql_parse() and so on).
+
+ @note This function is not suitable for setting thread data to some
+ non-default values, as there is only one replication thread, so different
+ master threads may overwrite data of each other on slave.
*/
void THD::cleanup_after_query()
diff -Nrup a/sql/sql_class.h b/sql/sql_class.h
--- a/sql/sql_class.h 2008-01-19 22:32:43 +03:00
+++ b/sql/sql_class.h 2008-01-28 16:20:13 +03:00
@@ -1682,16 +1682,10 @@ public:
THD();
~THD();
+private:
void init(void);
- /*
- Initialize memory roots necessary for query processing and (!)
- pre-allocate memory for it. We can't do that in THD constructor because
- there are use cases (acl_init, delayed inserts, watcher threads,
- killing mysqld) where it's vital to not allocate excessive and not used
- memory. Note, that we still don't return error from init_for_queries():
- if preallocation fails, we should notice that at the first call to
- alloc_root.
- */
+
+public:
void init_for_queries();
void change_user(void);
void cleanup(void);
@@ -2074,6 +2068,9 @@ public:
*/
void pop_internal_handler();
+ inline void set_dump_utf8_query(bool dump_utf8_query);
+ inline bool get_dump_utf8_query() const;
+
private:
/** The current internal error handler for this thread, or NULL. */
Internal_error_handler *m_internal_handler;
@@ -2093,7 +2090,19 @@ private:
tree itself is reused between executions and thus is stored elsewhere.
*/
MEM_ROOT main_mem_root;
+
+ bool m_dump_utf8_query;
};
+
+inline void THD::set_dump_utf8_query(bool dump_utf8_query)
+{
+ m_dump_utf8_query= dump_utf8_query;
+}
+
+inline bool THD::get_dump_utf8_query() const
+{
+ return m_dump_utf8_query;
+}
/** A short cut for thd->main_da.set_ok_status(). */
diff -Nrup a/sql/sql_lex.h b/sql/sql_lex.h
--- a/sql/sql_lex.h 2007-11-28 17:34:10 +03:00
+++ b/sql/sql_lex.h 2008-01-28 16:20:13 +03:00
@@ -1703,8 +1703,6 @@ typedef struct st_lex : public Query_tab
*/
bool use_only_table_context;
- LEX_STRING view_body_utf8;
-
/*
Reference to a struct that contains information in various commands
to add/create/drop/change table spaces.
diff -Nrup a/sql/sql_view.cc b/sql/sql_view.cc
--- a/sql/sql_view.cc 2007-10-30 20:08:13 +03:00
+++ b/sql/sql_view.cc 2008-01-28 16:20:13 +03:00
@@ -696,8 +696,18 @@ static int mysql_register_view(THD *thd,
enum_view_create_mode mode)
{
LEX *lex= thd->lex;
- char buff[4096];
- String view_query(buff, sizeof (buff), thd->charset());
+
+ /* We store view definition SELECT in the client character set. */
+ char view_query_buff[4096];
+ String view_query(view_query_buff,
+ sizeof (view_query_buff),
+ thd->charset());
+
+ char utf8_query_buff[4096];
+ String utf8_query(utf8_query_buff,
+ sizeof (utf8_query_buff),
+ system_charset_info);
+
char md5[MD5_BUFF_LENGTH];
bool can_be_merged;
char dir_buff[FN_REFLEN], path_buff[FN_REFLEN];
@@ -707,10 +717,17 @@ static int mysql_register_view(THD *thd,
/* print query */
view_query.length(0);
+ utf8_query.length(0);
{
ulong sql_mode= thd->variables.sql_mode & MODE_ANSI_QUOTES;
thd->variables.sql_mode&= ~MODE_ANSI_QUOTES;
+
lex->unit.print(&view_query);
+
+ thd->set_dump_utf8_query(TRUE);
+ lex->unit.print(&utf8_query);
+ thd->set_dump_utf8_query(FALSE);
+
thd->variables.sql_mode|= sql_mode;
}
DBUG_PRINT("info", ("View: %s", view_query.ptr()));
@@ -853,7 +870,8 @@ loop_out:
lex_string_set(&view->view_connection_cl_name,
view->view_creation_ctx->get_connection_cl()->name);
- view->view_body_utf8= lex->view_body_utf8;
+ view->view_body_utf8.str= utf8_query.c_ptr_safe();
+ view->view_body_utf8.length= utf8_query.length();
/*
Check that table of main select do not used in subqueries.
diff -Nrup a/sql/sql_yacc.yy b/sql/sql_yacc.yy
--- a/sql/sql_yacc.yy 2008-01-24 02:21:04 +03:00
+++ b/sql/sql_yacc.yy 2008-01-28 16:20:14 +03:00
@@ -11899,27 +11899,7 @@ view_tail:
if (!lex->select_lex.add_table_to_list(thd, $3, NULL, TL_OPTION_UPDATING))
MYSQL_YYABORT;
}
- view_list_opt AS
- {
- THD *thd= YYTHD;
- Lex_input_stream *lip= thd->m_lip;
-
- lip->body_utf8_start(thd, lip->get_cpp_ptr());
- }
- view_select
- {
- THD *thd= YYTHD;
- LEX *lex= thd->lex;
- Lex_input_stream *lip= thd->m_lip;
-
- lip->body_utf8_append(lip->get_cpp_ptr());
-
- lex->view_body_utf8.str= thd->strmake(lip->get_body_utf8_str(),
- lip->get_body_utf8_length());
- lex->view_body_utf8.length= lip->get_body_utf8_length();
-
- trim_whitespace(&my_charset_utf8_general_ci, &lex->view_body_utf8);
- }
+ view_list_opt AS view_select
;
view_list_opt: