mirror of
https://github.com/MariaDB/server.git
synced 2025-01-30 18:41:56 +01:00
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).
This commit is contained in:
parent
7ca65155ad
commit
e36846deca
3 changed files with 38 additions and 27 deletions
|
@ -4078,22 +4078,20 @@ x
|
||||||
Warnings:
|
Warnings:
|
||||||
Warning 1466 Leading spaces are removed from name ' x'
|
Warning 1466 Leading spaces are removed from name ' x'
|
||||||
CREATE VIEW v1 AS SELECT 1 AS ``;
|
CREATE VIEW v1 AS SELECT 1 AS ``;
|
||||||
Warnings:
|
ERROR 42000: Incorrect column name ''
|
||||||
Warning 1474 Name ' ' has become ''
|
CREATE VIEW v1 AS SELECT 1 AS ` `;
|
||||||
SELECT `` FROM v1;
|
ERROR 42000: Incorrect column name ' '
|
||||||
|
CREATE VIEW v1 AS SELECT 1 AS ` `;
|
||||||
1
|
ERROR 42000: Incorrect column name ' '
|
||||||
CREATE VIEW v2 AS SELECT 1 AS ` `;
|
CREATE VIEW v1 AS SELECT (SELECT 1 AS ` `);
|
||||||
Warnings:
|
ERROR 42000: Incorrect column name ' '
|
||||||
Warning 1474 Name ' ' has become ''
|
CREATE VIEW v1 AS SELECT 1 AS ` x`;
|
||||||
SELECT `` FROM v2;
|
|
||||||
|
|
||||||
1
|
|
||||||
CREATE VIEW v3 AS SELECT 1 AS ` x`;
|
|
||||||
Warnings:
|
Warnings:
|
||||||
Warning 1466 Leading spaces are removed from name ' x'
|
Warning 1466 Leading spaces are removed from name ' x'
|
||||||
SELECT `x` FROM v3;
|
SELECT `x` FROM v1;
|
||||||
x
|
x
|
||||||
1
|
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
|
End of 5.0 tests
|
||||||
|
|
|
@ -3466,22 +3466,29 @@ DROP TABLE t1;
|
||||||
#
|
#
|
||||||
|
|
||||||
--disable_ps_protocol
|
--disable_ps_protocol
|
||||||
|
|
||||||
SELECT 1 AS ` `;
|
SELECT 1 AS ` `;
|
||||||
SELECT 1 AS ` `;
|
SELECT 1 AS ` `;
|
||||||
SELECT 1 AS ` x`;
|
SELECT 1 AS ` x`;
|
||||||
|
|
||||||
CREATE VIEW v1 AS SELECT 1 AS ` `;
|
|
||||||
SELECT `` FROM v1;
|
|
||||||
|
|
||||||
CREATE VIEW v2 AS SELECT 1 AS ` `;
|
|
||||||
SELECT `` FROM v2;
|
|
||||||
|
|
||||||
CREATE VIEW v3 AS SELECT 1 AS ` x`;
|
|
||||||
SELECT `x` FROM v3;
|
|
||||||
|
|
||||||
DROP VIEW v1, v2, v3;
|
|
||||||
|
|
||||||
--enable_ps_protocol
|
--enable_ps_protocol
|
||||||
|
|
||||||
|
--error 1166
|
||||||
|
CREATE VIEW v1 AS SELECT 1 AS ``;
|
||||||
|
|
||||||
|
--error 1166
|
||||||
|
CREATE VIEW v1 AS SELECT 1 AS ` `;
|
||||||
|
|
||||||
|
--error 1166
|
||||||
|
CREATE VIEW v1 AS SELECT 1 AS ` `;
|
||||||
|
|
||||||
|
--error 1166
|
||||||
|
CREATE VIEW v1 AS SELECT (SELECT 1 AS ` `);
|
||||||
|
|
||||||
|
CREATE VIEW v1 AS SELECT 1 AS ` x`;
|
||||||
|
SELECT `x` FROM v1;
|
||||||
|
|
||||||
|
--error 1166
|
||||||
|
ALTER VIEW v1 AS SELECT 1 AS ` `;
|
||||||
|
|
||||||
|
DROP VIEW v1;
|
||||||
|
|
||||||
--echo End of 5.0 tests
|
--echo End of 5.0 tests
|
||||||
|
|
|
@ -4305,6 +4305,12 @@ select_item:
|
||||||
MYSQL_YYABORT;
|
MYSQL_YYABORT;
|
||||||
if ($4.str)
|
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->is_autogenerated_name= FALSE;
|
||||||
$2->set_name($4.str, $4.length, system_charset_info);
|
$2->set_name($4.str, $4.length, system_charset_info);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue