Browse Source
Manual merge of mysql-5.1-bugteam to mysql-trunk-merge.
Manual merge of mysql-5.1-bugteam to mysql-trunk-merge.
Conflicts: Text conflict in client/mysqlbinlog.cc Text conflict in mysql-test/r/explain.result Text conflict in mysql-test/r/subselect.result Text conflict in mysql-test/r/subselect3.result Text conflict in mysql-test/r/type_datetime.result Text conflict in sql/share/Makefile.ampull/374/head
50 changed files with 1243 additions and 442 deletions
-
489COPYING
-
20client/mysql.cc
-
5client/mysql_upgrade.c
-
9client/mysqlbinlog.cc
-
2client/mysqltest.cc
-
4mysql-test/Makefile.am
-
25mysql-test/include/view_alias.inc
-
2mysql-test/r/compare.result
-
2mysql-test/r/explain.result
-
15mysql-test/r/gis-rtree.result
-
4mysql-test/r/group_by.result
-
67mysql-test/r/merge.result
-
33mysql-test/r/myisam.result
-
4mysql-test/r/ps.result
-
62mysql-test/r/subselect.result
-
18mysql-test/r/subselect3.result
-
24mysql-test/r/trigger.result
-
8mysql-test/r/type_datetime.result
-
2mysql-test/r/union.result
-
13mysql-test/r/update.result
-
4mysql-test/r/view.result
-
111mysql-test/r/view_alias.result
-
17mysql-test/r/xa.result
-
BINmysql-test/std_data/bug48265.frm
-
29mysql-test/suite/binlog/r/binlog_innodb_row.result
-
1mysql-test/suite/binlog/r/binlog_row_mix_innodb_myisam.result
-
11mysql-test/suite/binlog/r/binlog_tmp_table.result
-
37mysql-test/suite/binlog/t/binlog_innodb_row.test
-
66mysql-test/suite/binlog/t/binlog_tmp_table.test
-
24mysql-test/t/gis-rtree.test
-
57mysql-test/t/merge.test
-
28mysql-test/t/myisam.test
-
30mysql-test/t/trigger.test
-
16mysql-test/t/update.test
-
92mysql-test/t/view_alias.test
-
16mysql-test/t/xa.test
-
5scripts/Makefile.am
-
1sql/item.cc
-
2sql/log_event.cc
-
7sql/set_var.cc
-
8sql/share/Makefile.am
-
3sql/sql_base.cc
-
18sql/sql_delete.cc
-
10sql/sql_select.cc
-
32sql/sql_view.cc
-
12storage/myisam/ha_myisam.cc
-
18storage/myisam/rt_index.c
-
122storage/myisammrg/ha_myisammrg.cc
-
8storage/myisammrg/myrg_open.c
-
2storage/ndb/src/common/util/Makefile.am
@ -0,0 +1,25 @@ |
|||
# Routine to be called by t/view.inc |
|||
# |
|||
# The variable $after_select must be set before calling this routine. |
|||
|
|||
eval CREATE VIEW v1 AS SELECT $after_select; |
|||
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'; |
|||
# |
|||
# Extract the VIEW's SELECT from INFORMATION_SCHEMA.VIEWS |
|||
let $query1 = `SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'`; |
|||
# |
|||
# Extract the VIEW's SELECT from SHOW CREATE VIEW |
|||
# SHOW CREATE VIEW v1 |
|||
# View Create View character_set_client collation_connection |
|||
# v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select '<--- ..... |
|||
let $value= query_get_value(SHOW CREATE VIEW v1, Create View, 1); |
|||
let $query2 = `SELECT SUBSTR("$value",INSTR("$value",' as select ') + CHAR_LENGTH(' as '))`; |
|||
DROP VIEW v1; |
|||
|
|||
# Recreate the view based on SELECT from INFORMATION_SCHEMA.VIEWS |
|||
eval CREATE VIEW v1 AS $query1; |
|||
DROP VIEW v1; |
|||
# Recreate the view based on SHOW CREATE VIEW |
|||
eval CREATE VIEW v1 AS $query2; |
|||
DROP VIEW v1; |
|||
|
|||
@ -0,0 +1,111 @@ |
|||
# |
|||
# Bug#40277 SHOW CREATE VIEW returns invalid SQL |
|||
# Bug#41999 SHOW CREATE VIEW returns invalid SQL if subquery is used in SELECT list |
|||
# |
|||
# 65 characters exceed the maximum length of a column identifier. The system cannot derive the name from statement. |
|||
# Constant with length = 65 . Expect to get the identifier 'Name_exp_1'. |
|||
CREATE VIEW v1 AS SELECT '<--- 65 char including the arrows --->'; |
|||
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'; |
|||
COLUMN_NAME |
|||
Name_exp_1 |
|||
DROP VIEW v1; |
|||
CREATE VIEW v1 AS select '<--- 65 char including the arrows --->' AS `Name_exp_1`; |
|||
DROP VIEW v1; |
|||
CREATE VIEW v1 AS select '<--- 65 char including the arrows --->' AS `Name_exp_1`; |
|||
DROP VIEW v1; |
|||
# Subquery with length = 65 . Expect to get the identifier 'Name_exp_1'. |
|||
# Attention: Identifier for the column within the subquery will be not generated. |
|||
CREATE VIEW v1 AS SELECT (SELECT '<--- 54 char including the arrows (+ 11 outside) -->'); |
|||
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'; |
|||
COLUMN_NAME |
|||
Name_exp_1 |
|||
DROP VIEW v1; |
|||
CREATE VIEW v1 AS select (select '<--- 54 char including the arrows (+ 11 outside) -->') AS `Name_exp_1`; |
|||
DROP VIEW v1; |
|||
CREATE VIEW v1 AS select (select '<--- 54 char including the arrows (+ 11 outside) -->') AS `Name_exp_1`; |
|||
DROP VIEW v1; |
|||
# ----------------------------------------------------------------------------------------------------------------- |
|||
# 64 characters are the maximum length of a column identifier. The system can derive the name from the statement. |
|||
CREATE VIEW v1 AS SELECT '<--- 64 char including the arrows --->'; |
|||
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'; |
|||
COLUMN_NAME |
|||
<--- 64 char including the arrows ---> |
|||
DROP VIEW v1; |
|||
CREATE VIEW v1 AS select '<--- 64 char including the arrows --->' AS `<--- 64 char including the arrows --->`; |
|||
DROP VIEW v1; |
|||
CREATE VIEW v1 AS select '<--- 64 char including the arrows --->' AS `<--- 64 char including the arrows --->`; |
|||
DROP VIEW v1; |
|||
CREATE VIEW v1 AS SELECT (SELECT '<--- 53 char including the arrows (+ 11 outside) --->'); |
|||
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'; |
|||
COLUMN_NAME |
|||
(SELECT '<--- 53 char including the arrows (+ 11 outside) --->') |
|||
DROP VIEW v1; |
|||
CREATE VIEW v1 AS select (select '<--- 53 char including the arrows (+ 11 outside) --->') AS `(SELECT '<--- 53 char including the arrows (+ 11 outside) --->')`; |
|||
DROP VIEW v1; |
|||
CREATE VIEW v1 AS select (select '<--- 53 char including the arrows (+ 11 outside) --->') AS `(SELECT '<--- 53 char including the arrows (+ 11 outside) --->')`; |
|||
DROP VIEW v1; |
|||
# ----------------------------------------------------------------------------------------------------------------- |
|||
# Identifiers must not have trailing spaces. The system cannot derive the name from a constant with trailing space. |
|||
# Generated identifiers have at their end the position within the select column list. |
|||
# 'c2 ' -> 'Name_exp_1' , ' c4 ' -> 'Name_exp_2' |
|||
CREATE VIEW v1 AS SELECT 'c1', 'c2 ', ' c3', ' c4 '; |
|||
SELECT COLUMN_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'; |
|||
COLUMN_NAME |
|||
c1 |
|||
Name_exp_2 |
|||
c3 |
|||
Name_exp_4 |
|||
DROP VIEW v1; |
|||
CREATE VIEW v1 AS select 'c1' AS `c1`,'c2 ' AS `Name_exp_2`,' c3' AS `c3`,' c4 ' AS `Name_exp_4`; |
|||
DROP VIEW v1; |
|||
CREATE VIEW v1 AS select 'c1' AS `c1`,'c2 ' AS `Name_exp_2`,' c3' AS `c3`,' c4 ' AS `Name_exp_4`; |
|||
DROP VIEW v1; |
|||
# |
|||
# Bug#40277 SHOW CREATE VIEW returns invalid SQL |
|||
# |
|||
DROP VIEW IF EXISTS v1; |
|||
DROP TABLE IF EXISTS t1,t2; |
|||
# Column name exceeds the maximum length. |
|||
CREATE VIEW v1 AS SELECT '0000000000 1111111111 2222222222 3333333333 4444444444 5555555555'; |
|||
DROP VIEW v1; |
|||
CREATE VIEW v1 AS select '0000000000 1111111111 2222222222 3333333333 4444444444 5555555555' AS `Name_exp_1`; |
|||
DROP VIEW v1; |
|||
# Column names with leading trailing spaces. |
|||
CREATE VIEW v1 AS SELECT 'c1', 'c2 ', ' c3', ' c4 '; |
|||
DROP VIEW v1; |
|||
CREATE VIEW v1 AS select 'c1' AS `c1`,'c2 ' AS `Name_exp_2`,' c3' AS `c3`,' c4 ' AS `Name_exp_4`; |
|||
DROP VIEW v1; |
|||
# Column name conflicts with a auto-generated one. |
|||
CREATE VIEW v1 AS SELECT 'c1', 'c2 ', ' c3', ' c4 ', 'Name_exp_2'; |
|||
DROP VIEW v1; |
|||
CREATE VIEW v1 AS select 'c1' AS `c1`,'c2 ' AS `Name_exp_2`,' c3' AS `c3`,' c4 ' AS `Name_exp_4`,'Name_exp_2' AS `My_exp_Name_exp_2`; |
|||
DROP VIEW v1; |
|||
# Invalid conlumn name in subquery. |
|||
CREATE VIEW v1 AS SELECT (SELECT ' c1 '); |
|||
DROP VIEW v1; |
|||
CREATE VIEW v1 AS select (select ' c1 ') AS `(SELECT ' c1 ')`; |
|||
DROP VIEW v1; |
|||
CREATE TABLE t1(a INT); |
|||
CREATE TABLE t2 LIKE t1; |
|||
# Test alias in subquery |
|||
CREATE VIEW v1 AS SELECT a FROM t1 WHERE EXISTS (SELECT 1 FROM t2 AS b WHERE b.a = 0); |
|||
DROP VIEW v1; |
|||
CREATE VIEW v1 AS select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(select 1 from `test`.`t2` `b` where (`b`.`a` = 0)); |
|||
DROP VIEW v1; |
|||
# Test column alias in subquery |
|||
CREATE VIEW v1 AS SELECT a FROM t1 WHERE EXISTS (SELECT a AS alias FROM t1 GROUP BY alias); |
|||
SHOW CREATE VIEW v1; |
|||
View Create View character_set_client collation_connection |
|||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where exists(select `t1`.`a` AS `alias` from `t1` group by `t1`.`a`) latin1 latin1_swedish_ci |
|||
DROP VIEW v1; |
|||
CREATE VIEW v1 AS select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(select `test`.`t1`.`a` AS `alias` from `test`.`t1` group by `test`.`t1`.`a`); |
|||
DROP VIEW v1; |
|||
# Alias as the expression column name. |
|||
CREATE VIEW v1 AS SELECT a FROM t1 WHERE EXISTS (SELECT ' a ' AS alias FROM t1 GROUP BY alias); |
|||
SHOW CREATE VIEW v1; |
|||
View Create View character_set_client collation_connection |
|||
v1 CREATE ALGORITHM=UNDEFINED DEFINER=`root`@`localhost` SQL SECURITY DEFINER VIEW `v1` AS select `t1`.`a` AS `a` from `t1` where exists(select ' a ' AS `alias` from `t1` group by ' a ') latin1 latin1_swedish_ci |
|||
DROP VIEW v1; |
|||
CREATE VIEW v1 AS select `test`.`t1`.`a` AS `a` from `test`.`t1` where exists(select ' a ' AS `alias` from `test`.`t1` group by ' a '); |
|||
DROP VIEW v1; |
|||
DROP TABLE t1, t2; |
|||
@ -0,0 +1,92 @@ |
|||
--echo # |
|||
--echo # Bug#40277 SHOW CREATE VIEW returns invalid SQL |
|||
--echo # Bug#41999 SHOW CREATE VIEW returns invalid SQL if subquery is used in SELECT list |
|||
--echo # |
|||
|
|||
--echo # 65 characters exceed the maximum length of a column identifier. The system cannot derive the name from statement. |
|||
--echo # Constant with length = 65 . Expect to get the identifier 'Name_exp_1'. |
|||
let $after_select= '<--- 65 char including the arrows --->'; |
|||
--source include/view_alias.inc |
|||
--echo # Subquery with length = 65 . Expect to get the identifier 'Name_exp_1'. |
|||
--echo # Attention: Identifier for the column within the subquery will be not generated. |
|||
let $after_select= (SELECT '<--- 54 char including the arrows (+ 11 outside) -->'); |
|||
--source include/view_alias.inc |
|||
--echo # ----------------------------------------------------------------------------------------------------------------- |
|||
# |
|||
--echo # 64 characters are the maximum length of a column identifier. The system can derive the name from the statement. |
|||
let $after_select= '<--- 64 char including the arrows --->'; |
|||
--source include/view_alias.inc |
|||
let $after_select= (SELECT '<--- 53 char including the arrows (+ 11 outside) --->'); |
|||
--source include/view_alias.inc |
|||
--echo # ----------------------------------------------------------------------------------------------------------------- |
|||
# |
|||
--echo # Identifiers must not have trailing spaces. The system cannot derive the name from a constant with trailing space. |
|||
--echo # Generated identifiers have at their end the position within the select column list. |
|||
--echo # 'c2 ' -> 'Name_exp_1' , ' c4 ' -> 'Name_exp_2' |
|||
let $after_select= 'c1', 'c2 ', ' c3', ' c4 '; |
|||
--source include/view_alias.inc |
|||
|
|||
--echo # |
|||
--echo # Bug#40277 SHOW CREATE VIEW returns invalid SQL |
|||
--echo # |
|||
|
|||
--disable_warnings |
|||
DROP VIEW IF EXISTS v1; |
|||
DROP TABLE IF EXISTS t1,t2; |
|||
--enable_warnings |
|||
|
|||
--echo # Column name exceeds the maximum length. |
|||
CREATE VIEW v1 AS SELECT '0000000000 1111111111 2222222222 3333333333 4444444444 5555555555'; |
|||
let $query = `SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'`; |
|||
DROP VIEW v1; |
|||
eval CREATE VIEW v1 AS $query; |
|||
DROP VIEW v1; |
|||
|
|||
--echo # Column names with leading trailing spaces. |
|||
CREATE VIEW v1 AS SELECT 'c1', 'c2 ', ' c3', ' c4 '; |
|||
let $query = `SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'`; |
|||
DROP VIEW v1; |
|||
eval CREATE VIEW v1 AS $query; |
|||
DROP VIEW v1; |
|||
|
|||
--echo # Column name conflicts with a auto-generated one. |
|||
CREATE VIEW v1 AS SELECT 'c1', 'c2 ', ' c3', ' c4 ', 'Name_exp_2'; |
|||
let $query = `SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'`; |
|||
DROP VIEW v1; |
|||
eval CREATE VIEW v1 AS $query; |
|||
DROP VIEW v1; |
|||
|
|||
--echo # Invalid conlumn name in subquery. |
|||
CREATE VIEW v1 AS SELECT (SELECT ' c1 '); |
|||
let $query = `SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'`; |
|||
DROP VIEW v1; |
|||
eval CREATE VIEW v1 AS $query; |
|||
DROP VIEW v1; |
|||
|
|||
CREATE TABLE t1(a INT); |
|||
CREATE TABLE t2 LIKE t1; |
|||
|
|||
--echo # Test alias in subquery |
|||
CREATE VIEW v1 AS SELECT a FROM t1 WHERE EXISTS (SELECT 1 FROM t2 AS b WHERE b.a = 0); |
|||
let $query = `SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'`; |
|||
DROP VIEW v1; |
|||
eval CREATE VIEW v1 AS $query; |
|||
DROP VIEW v1; |
|||
|
|||
--echo # Test column alias in subquery |
|||
CREATE VIEW v1 AS SELECT a FROM t1 WHERE EXISTS (SELECT a AS alias FROM t1 GROUP BY alias); |
|||
SHOW CREATE VIEW v1; |
|||
let $query = `SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'`; |
|||
DROP VIEW v1; |
|||
eval CREATE VIEW v1 AS $query; |
|||
DROP VIEW v1; |
|||
|
|||
--echo # Alias as the expression column name. |
|||
CREATE VIEW v1 AS SELECT a FROM t1 WHERE EXISTS (SELECT ' a ' AS alias FROM t1 GROUP BY alias); |
|||
SHOW CREATE VIEW v1; |
|||
let $query = `SELECT VIEW_DEFINITION FROM INFORMATION_SCHEMA.VIEWS WHERE TABLE_SCHEMA = 'test' AND TABLE_NAME = 'v1'`; |
|||
DROP VIEW v1; |
|||
eval CREATE VIEW v1 AS $query; |
|||
DROP VIEW v1; |
|||
|
|||
DROP TABLE t1, t2; |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue