Commit d168601e authored by Alexander Barkov's avatar Alexander Barkov

MDEV-20734 Allow reserved keywords as user defined type names

parent 54606df1
......@@ -1798,3 +1798,16 @@ ERROR HY000: Table 't2' was not locked with LOCK TABLES
SET STATEMENT max_statement_time=900 FOR unlock tables;
drop table t1, t2;
# End of 10.4 tests
#
# Start of 10.5 tests
#
#
# MDEV-20734 Allow reserved keywords as user defined type names
#
CREATE TABLE t1 (a DUAL);
ERROR HY000: Unknown data type: 'DUAL'
SELECT CAST(1 AS DUAL);
ERROR HY000: Unknown data type: 'DUAL'
#
# End of 10.5 tests
#
......@@ -1566,3 +1566,21 @@ SET STATEMENT max_statement_time=900 FOR unlock tables;
drop table t1, t2;
--echo # End of 10.4 tests
--echo #
--echo # Start of 10.5 tests
--echo #
--echo #
--echo # MDEV-20734 Allow reserved keywords as user defined type names
--echo #
--error ER_UNKNOWN_DATA_TYPE
CREATE TABLE t1 (a DUAL);
--error ER_UNKNOWN_DATA_TYPE
SELECT CAST(1 AS DUAL);
--echo #
--echo # End of 10.5 tests
--echo #
......@@ -609,3 +609,16 @@ ERROR HY000: Unknown system variable 'role'
#
# End of 10.3 tests
#
#
# Start of 10.5 tests
#
#
# MDEV-20734 Allow reserved keywords as user defined type names
#
CREATE TABLE t1 (a DUAL);
ERROR HY000: Unknown data type: 'DUAL'
SELECT CAST(1 AS DUAL);
ERROR HY000: Unknown data type: 'DUAL'
#
# End of 10.5 tests
#
......@@ -412,3 +412,21 @@ SELECT @@GLOBAL.role;
--echo #
--echo # End of 10.3 tests
--echo #
--echo #
--echo # Start of 10.5 tests
--echo #
--echo #
--echo # MDEV-20734 Allow reserved keywords as user defined type names
--echo #
--error ER_UNKNOWN_DATA_TYPE
CREATE TABLE t1 (a DUAL);
--error ER_UNKNOWN_DATA_TYPE
SELECT CAST(1 AS DUAL);
--echo #
--echo # End of 10.5 tests
--echo #
......@@ -5954,7 +5954,7 @@ DROP PROCEDURE IF EXISTS sp6;
--enable_warnings
delimiter //;
--error ER_PARSE_ERROR
--error ER_UNKNOWN_DATA_TYPE
CREATE PROCEDURE sp6( )
BEGIN
declare x default '0' char;
......@@ -6021,7 +6021,7 @@ DROP PROCEDURE IF EXISTS sp6;
--enable_warnings
delimiter //;
--error ER_PARSE_ERROR
--error ER_UNKNOWN_DATA_TYPE
CREATE PROCEDURE sp6( )
BEGIN
declare x default 'a' char;
......@@ -6117,7 +6117,7 @@ DROP PROCEDURE IF EXISTS sp6;
--enable_warnings
delimiter //;
--error ER_PARSE_ERROR
--error ER_UNKNOWN_DATA_TYPE
CREATE PROCEDURE sp6( )
BEGIN
declare handler continue for sqlstate '02000' set @x2 = 1;
......@@ -6141,7 +6141,7 @@ DROP PROCEDURE IF EXISTS sp6;
--enable_warnings
delimiter //;
--error ER_PARSE_ERROR
--error ER_UNKNOWN_DATA_TYPE
CREATE PROCEDURE sp6( )
BEGIN
declare handler undo for sqlstate '02000' set @x2 = 1;
......@@ -7455,7 +7455,7 @@ DROP PROCEDURE IF EXISTS sp1;
--enable_warnings
delimiter //;
--error ER_PARSE_ERROR
--error ER_UNKNOWN_DATA_TYPE
CREATE PROCEDURE sp1( )
BEGIN
declare date not null x;
......@@ -7468,7 +7468,7 @@ DROP PROCEDURE IF EXISTS sp1;
--enable_warnings
delimiter //;
--error ER_PARSE_ERROR
--error ER_UNKNOWN_DATA_TYPE
CREATE PROCEDURE sp1( )
BEGIN
declare time not null x;
......@@ -7481,7 +7481,7 @@ DROP PROCEDURE IF EXISTS sp1;
--enable_warnings
delimiter //;
--error ER_PARSE_ERROR
--error ER_UNKNOWN_DATA_TYPE
CREATE PROCEDURE sp1( )
BEGIN
declare datetime not null x;
......@@ -7494,7 +7494,7 @@ DROP PROCEDURE IF EXISTS sp1;
--enable_warnings
delimiter //;
--error ER_PARSE_ERROR
--error ER_UNKNOWN_DATA_TYPE
CREATE PROCEDURE sp1( )
BEGIN
declare timestamp not null x;
......@@ -7507,7 +7507,7 @@ DROP PROCEDURE IF EXISTS sp1;
--enable_warnings
delimiter //;
--error ER_PARSE_ERROR
--error ER_UNKNOWN_DATA_TYPE
CREATE PROCEDURE sp1( )
BEGIN
declare year not null x;
......
......@@ -10433,3 +10433,30 @@ void Lex_field_type_st::set_handler_length_flags(const Type_handler *handler,
handler= handler->type_handler_unsigned();
set(handler, length, NULL);
}
bool LEX::set_field_type_udt(Lex_field_type_st *type,
const LEX_CSTRING &name,
const Lex_length_and_dec_st &attr)
{
const Type_handler *h;
if (!(h= Type_handler::handler_by_name_or_error(name)))
return true;
type->set(h, attr);
charset= &my_charset_bin;
return false;
}
bool LEX::set_cast_type_udt(Lex_cast_type_st *type,
const LEX_CSTRING &name)
{
const Type_handler *h;
if (!(h= Type_handler::handler_by_name_or_error(name)))
return true;
type->set(h);
charset= NULL;
return false;
}
......@@ -4558,6 +4558,12 @@ struct LEX: public Query_tables_list
Item_result return_type,
const LEX_CSTRING &soname);
Spvar_definition *row_field_name(THD *thd, const Lex_ident_sys_st &name);
bool set_field_type_udt(Lex_field_type_st *type,
const LEX_CSTRING &name,
const Lex_length_and_dec_st &attr);
bool set_cast_type_udt(Lex_cast_type_st *type,
const LEX_CSTRING &name);
};
......
This diff is collapsed.
This diff is collapsed.
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