Fixed bug #27695: View should not be allowed to have empty or

all space column names.

The parser has been modified to check VIEW column names
with the check_column_name function and to report an error
on empty and all space column names (same as for TABLE
column names).
parent 7ca65155
......@@ -4077,23 +4077,21 @@ x
1
Warnings:
Warning 1466 Leading spaces are removed from name ' x'
CREATE VIEW v1 AS SELECT 1 AS ``;
ERROR 42000: Incorrect column name ''
CREATE VIEW v1 AS SELECT 1 AS ` `;
Warnings:
Warning 1474 Name ' ' has become ''
SELECT `` FROM v1;
1
CREATE VIEW v2 AS SELECT 1 AS ` `;
Warnings:
Warning 1474 Name ' ' has become ''
SELECT `` FROM v2;
1
CREATE VIEW v3 AS SELECT 1 AS ` x`;
ERROR 42000: Incorrect column name ' '
CREATE VIEW v1 AS SELECT 1 AS ` `;
ERROR 42000: Incorrect column name ' '
CREATE VIEW v1 AS SELECT (SELECT 1 AS ` `);
ERROR 42000: Incorrect column name ' '
CREATE VIEW v1 AS SELECT 1 AS ` x`;
Warnings:
Warning 1466 Leading spaces are removed from name ' x'
SELECT `x` FROM v3;
SELECT `x` FROM v1;
x
1
DROP VIEW v1, v2, v3;
ALTER VIEW v1 AS SELECT 1 AS ` `;
ERROR 42000: Incorrect column name ' '
DROP VIEW v1;
End of 5.0 tests
......@@ -3466,22 +3466,29 @@ DROP TABLE t1;
#
--disable_ps_protocol
SELECT 1 AS ` `;
SELECT 1 AS ` `;
SELECT 1 AS ` x`;
--enable_ps_protocol
--error 1166
CREATE VIEW v1 AS SELECT 1 AS ``;
--error 1166
CREATE VIEW v1 AS SELECT 1 AS ` `;
SELECT `` FROM v1;
CREATE VIEW v2 AS SELECT 1 AS ` `;
SELECT `` FROM v2;
--error 1166
CREATE VIEW v1 AS SELECT 1 AS ` `;
CREATE VIEW v3 AS SELECT 1 AS ` x`;
SELECT `x` FROM v3;
--error 1166
CREATE VIEW v1 AS SELECT (SELECT 1 AS ` `);
DROP VIEW v1, v2, v3;
CREATE VIEW v1 AS SELECT 1 AS ` x`;
SELECT `x` FROM v1;
--enable_ps_protocol
--error 1166
ALTER VIEW v1 AS SELECT 1 AS ` `;
DROP VIEW v1;
--echo End of 5.0 tests
......@@ -4305,6 +4305,12 @@ select_item:
MYSQL_YYABORT;
if ($4.str)
{
if (Lex->sql_command == SQLCOM_CREATE_VIEW &&
check_column_name($4.str))
{
my_error(ER_WRONG_COLUMN_NAME, MYF(0), $4.str);
MYSQL_YYABORT;
}
$2->is_autogenerated_name= FALSE;
$2->set_name($4.str, $4.length, system_charset_info);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment