diff --git a/mysql-test/main/sp_gis.result b/mysql-test/main/sp_gis.result index 7a76507754f..35c7e52e833 100644 --- a/mysql-test/main/sp_gis.result +++ b/mysql-test/main/sp_gis.result @@ -28,3 +28,75 @@ test.a() test.x() test.y() drop function a; drop function x; drop function y; +# +# Start of 10.5 tests +# +# +# MDEV-19944 Remove GIS data types from keyword list in lex.h +# +CREATE FUNCTION point() RETURNS POINT RETURN NULL; +Warnings: +Note 1585 This function 'point' has the same name as a native function +SELECT point(); +point() +NULL +DROP FUNCTION point; +CREATE FUNCTION point(x INT) RETURNS POINT RETURN NULL; +Warnings: +Note 1585 This function 'point' has the same name as a native function +SELECT point(1); +point(1) +NULL +DROP FUNCTION point; +CREATE FUNCTION point(x INT, y INT) RETURNS POINT RETURN NULL; +Warnings: +Note 1585 This function 'point' has the same name as a native function +SELECT AsText(point(1,1)); +AsText(point(1,1)) +POINT(1 1) +DROP FUNCTION point; +CREATE FUNCTION linestring() RETURNS POINT RETURN NULL; +Warnings: +Note 1585 This function 'linestring' has the same name as a native function +SELECT linestring(); +linestring() +NULL +DROP FUNCTION linestring; +CREATE FUNCTION polygon() RETURNS POINT RETURN NULL; +Warnings: +Note 1585 This function 'polygon' has the same name as a native function +SELECT polygon(); +polygon() +NULL +DROP FUNCTION polygon; +CREATE FUNCTION multipoint() RETURNS POINT RETURN NULL; +Warnings: +Note 1585 This function 'multipoint' has the same name as a native function +SELECT multipoint(); +multipoint() +NULL +DROP FUNCTION multipoint; +CREATE FUNCTION multilinestring() RETURNS POINT RETURN NULL; +Warnings: +Note 1585 This function 'multilinestring' has the same name as a native function +SELECT multilinestring(); +multilinestring() +NULL +DROP FUNCTION multilinestring; +CREATE FUNCTION multipolygon() RETURNS POINT RETURN NULL; +Warnings: +Note 1585 This function 'multipolygon' has the same name as a native function +SELECT multipolygon(); +multipolygon() +NULL +DROP FUNCTION multipolygon; +CREATE FUNCTION geometrycollection() RETURNS POINT RETURN NULL; +Warnings: +Note 1585 This function 'geometrycollection' has the same name as a native function +SELECT geometrycollection(); +geometrycollection() +NULL +DROP FUNCTION geometrycollection; +# +# End of 10.5 tests +# diff --git a/mysql-test/main/sp_gis.test b/mysql-test/main/sp_gis.test index 51ed78b27d5..4148a4ec423 100644 --- a/mysql-test/main/sp_gis.test +++ b/mysql-test/main/sp_gis.test @@ -37,3 +37,66 @@ drop function a; drop function x; drop function y; +--echo # +--echo # Start of 10.5 tests +--echo # + +--echo # +--echo # MDEV-19944 Remove GIS data types from keyword list in lex.h +--echo # + +CREATE FUNCTION point() RETURNS POINT RETURN NULL; +--disable_warnings +SELECT point(); +--enable_warnings +DROP FUNCTION point; + +CREATE FUNCTION point(x INT) RETURNS POINT RETURN NULL; +--disable_warnings +SELECT point(1); +--enable_warnings +DROP FUNCTION point; + +CREATE FUNCTION point(x INT, y INT) RETURNS POINT RETURN NULL; +SELECT AsText(point(1,1)); +DROP FUNCTION point; + +CREATE FUNCTION linestring() RETURNS POINT RETURN NULL; +--disable_warnings +SELECT linestring(); +--enable_warnings +DROP FUNCTION linestring; + +CREATE FUNCTION polygon() RETURNS POINT RETURN NULL; +--disable_warnings +SELECT polygon(); +--enable_warnings +DROP FUNCTION polygon; + +CREATE FUNCTION multipoint() RETURNS POINT RETURN NULL; +--disable_warnings +SELECT multipoint(); +--enable_warnings +DROP FUNCTION multipoint; + +CREATE FUNCTION multilinestring() RETURNS POINT RETURN NULL; +--disable_warnings +SELECT multilinestring(); +--enable_warnings +DROP FUNCTION multilinestring; + +CREATE FUNCTION multipolygon() RETURNS POINT RETURN NULL; +--disable_warnings +SELECT multipolygon(); +--enable_warnings +DROP FUNCTION multipolygon; + +CREATE FUNCTION geometrycollection() RETURNS POINT RETURN NULL; +--disable_warnings +SELECT geometrycollection(); +--enable_warnings +DROP FUNCTION geometrycollection; + +--echo # +--echo # End of 10.5 tests +--echo # diff --git a/mysql-test/suite/funcs_1/r/storedproc.result b/mysql-test/suite/funcs_1/r/storedproc.result index 81ed8405b7d..98dadf45aff 100644 --- a/mysql-test/suite/funcs_1/r/storedproc.result +++ b/mysql-test/suite/funcs_1/r/storedproc.result @@ -9347,8 +9347,7 @@ CREATE PROCEDURE sp1( ) BEGIN declare x char1; END// -ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'char1; -END' at line 3 +ERROR HY000: Unknown data type: 'char1' DROP PROCEDURE IF EXISTS sp1; Warnings: Note 1305 PROCEDURE db_storedproc.sp1 does not exist diff --git a/mysql-test/suite/funcs_1/t/storedproc.test b/mysql-test/suite/funcs_1/t/storedproc.test index 31786410a7b..8171360b078 100644 --- a/mysql-test/suite/funcs_1/t/storedproc.test +++ b/mysql-test/suite/funcs_1/t/storedproc.test @@ -11208,7 +11208,7 @@ delimiter ;// DROP PROCEDURE IF EXISTS sp1; delimiter //; ---error ER_PARSE_ERROR +--error ER_UNKNOWN_DATA_TYPE CREATE PROCEDURE sp1( ) BEGIN declare x char1; diff --git a/sql/lex.h b/sql/lex.h index ec657ff48df..c52e981f8b8 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -261,8 +261,6 @@ static SYMBOL symbols[] = { { "FUNCTION", SYM(FUNCTION_SYM)}, { "GENERAL", SYM(GENERAL)}, { "GENERATED", SYM(GENERATED_SYM)}, - { "GEOMETRY", SYM(GEOMETRY_SYM)}, - { "GEOMETRYCOLLECTION",SYM(GEOMETRYCOLLECTION)}, { "GET_FORMAT", SYM(GET_FORMAT)}, { "GET", SYM(GET_SYM)}, { "GLOBAL", SYM(GLOBAL_SYM)}, @@ -343,7 +341,6 @@ static SYMBOL symbols[] = { { "LIMIT", SYM(LIMIT)}, { "LINEAR", SYM(LINEAR_SYM)}, { "LINES", SYM(LINES)}, - { "LINESTRING", SYM(LINESTRING)}, { "LIST", SYM(LIST_SYM)}, { "LOAD", SYM(LOAD)}, { "LOCAL", SYM(LOCAL_SYM)}, @@ -409,9 +406,6 @@ static SYMBOL symbols[] = { { "MODIFIES", SYM(MODIFIES_SYM)}, { "MODIFY", SYM(MODIFY_SYM)}, { "MONTH", SYM(MONTH_SYM)}, - { "MULTILINESTRING", SYM(MULTILINESTRING)}, - { "MULTIPOINT", SYM(MULTIPOINT)}, - { "MULTIPOLYGON", SYM(MULTIPOLYGON)}, { "MUTEX", SYM(MUTEX_SYM)}, { "MYSQL", SYM(MYSQL_SYM)}, { "MYSQL_ERRNO", SYM(MYSQL_ERRNO_SYM)}, @@ -476,8 +470,6 @@ static SYMBOL symbols[] = { { "PHASE", SYM(PHASE_SYM)}, { "PLUGIN", SYM(PLUGIN_SYM)}, { "PLUGINS", SYM(PLUGINS_SYM)}, - { "POINT", SYM(POINT_SYM)}, - { "POLYGON", SYM(POLYGON)}, { "PORT", SYM(PORT_SYM)}, { "PORTION", SYM(PORTION_SYM)}, { "PRECEDES", SYM(PRECEDES_SYM)}, diff --git a/sql/share/errmsg-utf8.txt b/sql/share/errmsg-utf8.txt index 139ef3c5634..73877425360 100644 --- a/sql/share/errmsg-utf8.txt +++ b/sql/share/errmsg-utf8.txt @@ -7933,3 +7933,5 @@ ER_TOO_LONG_KEYPART 42000 S1009 eng "Specified key part was too long; max key part length is %u bytes" ER_TOO_LONG_DATABASE_COMMENT eng "Comment for database '%-.64s' is too long (max = %u)" +ER_UNKNOWN_DATA_TYPE + eng "Unknown data type: '%-.64s'" diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index e0801e9f43a..40086f39d65 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -945,6 +945,9 @@ bool is_native_function(THD *thd, const LEX_CSTRING *name) if (is_lex_native_function(name)) return true; + if (Type_handler::handler_by_name(*name)) + return true; + return false; } diff --git a/sql/sql_type.cc b/sql/sql_type.cc index edabc03e15a..9f6bbc3e992 100644 --- a/sql/sql_type.cc +++ b/sql/sql_type.cc @@ -74,6 +74,10 @@ Type_handler_interval_DDhhmmssff type_handler_interval_DDhhmmssff; class Type_collection_std: public Type_collection { public: + const Type_handler *handler_by_name(const LEX_CSTRING &name) const override + { + return NULL; + } const Type_handler *aggregate_for_result(const Type_handler *a, const Type_handler *b) const override @@ -230,6 +234,26 @@ public: init_aggregators(data, &type_handler_multilinestring) || init_aggregators(data, &type_handler_multipolygon); } + const Type_handler *handler_by_name(const LEX_CSTRING &name) const override + { + if (type_handler_point.name().eq(name)) + return &type_handler_point; + if (type_handler_linestring.name().eq(name)) + return &type_handler_linestring; + if (type_handler_polygon.name().eq(name)) + return &type_handler_polygon; + if (type_handler_multipoint.name().eq(name)) + return &type_handler_multipoint; + if (type_handler_multilinestring.name().eq(name)) + return &type_handler_multilinestring; + if (type_handler_multipolygon.name().eq(name)) + return &type_handler_multipolygon; + if (type_handler_geometry.name().eq(name)) + return &type_handler_geometry; + if (type_handler_geometrycollection.name().eq(name)) + return &type_handler_geometrycollection; + return NULL; + } }; @@ -252,6 +276,29 @@ bool Type_handler_data::init() } +const Type_handler * +Type_handler::handler_by_name(const LEX_CSTRING &name) +{ +#ifdef HAVE_SPATIAL + const Type_handler *ha= type_collection_geometry.handler_by_name(name); + if (ha) + return ha; +#endif + return NULL; +} + + +const Type_handler * +Type_handler::handler_by_name_or_error(const LEX_CSTRING &name) +{ + const Type_handler *h= handler_by_name(name); + if (!h) + my_error(ER_UNKNOWN_DATA_TYPE, MYF(0), + ErrConvString(name.str, name.length, system_charset_info).ptr()); + return h; +} + + Type_handler_data *type_handler_data= NULL; @@ -3244,6 +3291,64 @@ bool Type_handler_point::Key_part_spec_init_foreign(Key_part_spec *part, } +Item * +Type_handler_point::make_constructor_item(THD *thd, List *args) const +{ + if (!args || args->elements != 2) + return NULL; + Item_args tmp(thd, *args); + return new (thd->mem_root) Item_func_point(thd, + tmp.arguments()[0], + tmp.arguments()[1]); +} + + +Item * +Type_handler_linestring::make_constructor_item(THD *thd, List *args) const +{ + return args ? new (thd->mem_root) Item_func_linestring(thd, *args) : NULL; +} + + +Item * +Type_handler_polygon::make_constructor_item(THD *thd, List *args) const +{ + return args ? new (thd->mem_root) Item_func_polygon(thd, *args) : NULL; +} + + +Item * +Type_handler_multipoint::make_constructor_item(THD *thd, List *args) const +{ + return args ? new (thd->mem_root) Item_func_multipoint(thd, *args) : NULL; +} + + +Item * +Type_handler_multilinestring::make_constructor_item(THD *thd, + List *args) const +{ + return args ? new (thd->mem_root) Item_func_multilinestring(thd, *args) : + NULL; +} + + +Item * +Type_handler_multipolygon::make_constructor_item(THD *thd, + List *args) const +{ + return args ? new (thd->mem_root) Item_func_multipolygon(thd, *args) : NULL; +} + + +Item * +Type_handler_geometrycollection::make_constructor_item(THD *thd, + List *args) const +{ + return args ? new (thd->mem_root) Item_func_geometrycollection(thd, *args) : + NULL; +} + #endif // HAVE_SPATIAL /*************************************************************************/ diff --git a/sql/sql_type.h b/sql/sql_type.h index 8cef59f23ae..dd765d876e4 100644 --- a/sql/sql_type.h +++ b/sql/sql_type.h @@ -3074,6 +3074,12 @@ public: } const char *ptr() const { return LEX_CSTRING::str; } uint length() const { return (uint) LEX_CSTRING::length; } + bool eq(const LEX_CSTRING &other) const + { + return !my_strnncoll(system_charset_info, + (const uchar *) LEX_CSTRING::str, LEX_CSTRING::length, + (const uchar *) other.str, other.length); + } }; @@ -3248,6 +3254,8 @@ protected: enum_field_types type) const; public: + static const Type_handler *handler_by_name(const LEX_CSTRING &name); + static const Type_handler *handler_by_name_or_error(const LEX_CSTRING &name); static const Type_handler *odbc_literal_type_handler(const LEX_CSTRING *str); static const Type_handler *blob_type_handler(uint max_octet_length); static const Type_handler *string_type_handler(uint max_octet_length); @@ -3674,6 +3682,10 @@ public: Item *src, const Item *cmp) const= 0; virtual Item_cache *Item_get_cache(THD *thd, const Item *item) const= 0; + virtual Item *make_constructor_item(THD *thd, List *args) const + { + return NULL; + } /** A builder for literals with data type name prefix, e.g.: TIME'00:00:00', DATE'2001-01-01', TIMESTAMP'2001-01-01 00:00:00'. @@ -6549,6 +6561,7 @@ class Type_handler_point: public Type_handler_geometry public: geometry_types geometry_type() const override { return GEOM_POINT; } const Name name() const override { return m_name_point; } + Item *make_constructor_item(THD *thd, List *args) const override; bool Key_part_spec_init_primary(Key_part_spec *part, const Column_definition &def, const handler *file) const override; @@ -6570,6 +6583,7 @@ class Type_handler_linestring: public Type_handler_geometry public: geometry_types geometry_type() const { return GEOM_LINESTRING; } const Name name() const { return m_name_linestring; } + Item *make_constructor_item(THD *thd, List *args) const override; }; class Type_handler_polygon: public Type_handler_geometry @@ -6578,6 +6592,7 @@ class Type_handler_polygon: public Type_handler_geometry public: geometry_types geometry_type() const { return GEOM_POLYGON; } const Name name() const { return m_name_polygon; } + Item *make_constructor_item(THD *thd, List *args) const override; }; class Type_handler_multipoint: public Type_handler_geometry @@ -6586,6 +6601,7 @@ class Type_handler_multipoint: public Type_handler_geometry public: geometry_types geometry_type() const { return GEOM_MULTIPOINT; } const Name name() const { return m_name_multipoint; } + Item *make_constructor_item(THD *thd, List *args) const override; }; class Type_handler_multilinestring: public Type_handler_geometry @@ -6594,6 +6610,7 @@ class Type_handler_multilinestring: public Type_handler_geometry public: geometry_types geometry_type() const { return GEOM_MULTILINESTRING; } const Name name() const { return m_name_multilinestring; } + Item *make_constructor_item(THD *thd, List *args) const override; }; class Type_handler_multipolygon: public Type_handler_geometry @@ -6602,6 +6619,7 @@ class Type_handler_multipolygon: public Type_handler_geometry public: geometry_types geometry_type() const { return GEOM_MULTIPOLYGON; } const Name name() const { return m_name_multipolygon; } + Item *make_constructor_item(THD *thd, List *args) const override; }; class Type_handler_geometrycollection: public Type_handler_geometry @@ -6610,6 +6628,7 @@ class Type_handler_geometrycollection: public Type_handler_geometry public: geometry_types geometry_type() const { return GEOM_GEOMETRYCOLLECTION; } const Name name() const { return m_name_geometrycollection; } + Item *make_constructor_item(THD *thd, List *args) const override; }; extern MYSQL_PLUGIN_IMPORT Type_handler_geometry type_handler_geometry; @@ -6736,6 +6755,7 @@ class Type_collection { public: virtual ~Type_collection() {} + virtual const Type_handler *handler_by_name(const LEX_CSTRING &name) const= 0; virtual const Type_handler *aggregate_for_result(const Type_handler *h1, const Type_handler *h2) const= 0; diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 466259c0f6d..70884fbe748 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1322,8 +1322,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token FUNCTION_SYM /* SQL-2003-R, Oracle-R */ %token GENERAL %token GENERATED_SYM -%token GEOMETRYCOLLECTION -%token GEOMETRY_SYM %token GET_FORMAT /* MYSQL-FUNC */ %token GET_SYM /* SQL-2003-R */ %token GLOBAL_SYM /* SQL-2003-R */ @@ -1363,7 +1361,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token LEAVES %token LESS_SYM %token LEVEL_SYM -%token LINESTRING %token LIST_SYM %token LOCAL_SYM /* SQL-2003-R */ %token LOCKS_SYM @@ -1409,9 +1406,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token MODE_SYM %token MODIFY_SYM %token MONTH_SYM /* SQL-2003-R */ -%token MULTILINESTRING -%token MULTIPOINT -%token MULTIPOLYGON %token MUTEX_SYM %token MYSQL_SYM %token MYSQL_ERRNO_SYM @@ -1458,8 +1452,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token PHASE_SYM %token PLUGINS_SYM %token PLUGIN_SYM -%token POINT_SYM -%token POLYGON %token PORT_SYM %token PRECEDES_SYM /* MYSQL */ %token PRECEDING_SYM /* SQL-2011-N */ @@ -1831,8 +1823,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %type field_spec column_def -%type spatial_type - %type order_dir lock_option udf_type opt_local opt_no_write_to_binlog @@ -6838,6 +6828,14 @@ field_type: | field_type_string | field_type_lob | field_type_misc + | IDENT_sys float_options srid_option + { + const Type_handler *h; + if (!(h= Type_handler::handler_by_name_or_error($1))) + MYSQL_YYABORT; + $$.set(h, $2); + Lex->charset= &my_charset_bin; + } ; field_type_numeric: @@ -7008,16 +7006,6 @@ field_type_lob: Lex->charset=&my_charset_bin; $$.set(&type_handler_long_blob); } - | spatial_type float_options srid_option - { -#ifdef HAVE_SPATIAL - Lex->charset=&my_charset_bin; - $$.set($1, $2); -#else - my_yyabort_error((ER_FEATURE_DISABLED, MYF(0), sym_group_geom.name, - sym_group_geom.needed_define)); -#endif - } | MEDIUMBLOB opt_compressed { Lex->charset=&my_charset_bin; @@ -7061,17 +7049,6 @@ field_type_misc: { $$.set(&type_handler_set); } ; -spatial_type: - GEOMETRY_SYM { $$= GEOM_TYPE(&type_handler_geometry); } - | GEOMETRYCOLLECTION { $$= GEOM_TYPE(&type_handler_geometrycollection); } - | POINT_SYM { $$= GEOM_TYPE(&type_handler_point); } - | MULTIPOINT { $$= GEOM_TYPE(&type_handler_multipoint); } - | LINESTRING { $$= GEOM_TYPE(&type_handler_linestring); } - | MULTILINESTRING { $$= GEOM_TYPE(&type_handler_multilinestring); } - | POLYGON { $$= GEOM_TYPE(&type_handler_polygon); } - | MULTIPOLYGON { $$= GEOM_TYPE(&type_handler_multipolygon); } - ; - char: CHAR_SYM {} ; @@ -11045,34 +11022,6 @@ geometry_function: Item_func_spatial_precise_rel(thd, $3, $5, Item_func::SP_CONTAINS_FUNC)); } - | GEOMETRYCOLLECTION '(' expr_list ')' - { - $$= GEOM_NEW(thd, Item_func_geometrycollection(thd, *$3)); - } - | LINESTRING '(' expr_list ')' - { - $$= GEOM_NEW(thd, Item_func_linestring(thd, *$3)); - } - | MULTILINESTRING '(' expr_list ')' - { - $$= GEOM_NEW(thd, Item_func_multilinestring(thd, *$3)); - } - | MULTIPOINT '(' expr_list ')' - { - $$= GEOM_NEW(thd, Item_func_multipoint(thd, *$3)); - } - | MULTIPOLYGON '(' expr_list ')' - { - $$= GEOM_NEW(thd, Item_func_multipolygon(thd, *$3)); - } - | POINT_SYM '(' expr ',' expr ')' - { - $$= GEOM_NEW(thd, Item_func_point(thd, $3, $5)); - } - | POLYGON '(' expr_list ')' - { - $$= GEOM_NEW(thd, Item_func_polygon(thd, *$3)); - } | WITHIN '(' expr ',' expr ')' { $$= GEOM_NEW(thd, Item_func_spatial_precise_rel(thd, $3, $5, @@ -11111,6 +11060,7 @@ function_call_generic: } opt_udf_expr_list ')' { + const Type_handler *h; Create_func *builder; Item *item= NULL; @@ -11126,8 +11076,12 @@ function_call_generic: This will be revised with WL#2128 (SQL PATH) */ - builder= find_native_function_builder(thd, &$1); - if (builder) + if ((h= Type_handler::handler_by_name($1)) && + (item= h->make_constructor_item(thd, $4))) + { + // Found a constructor with a proper argument count + } + else if ((builder= find_native_function_builder(thd, &$1))) { item= builder->create_func(thd, &$1, $4); } @@ -15901,21 +15855,13 @@ keyword_data_type: | DATETIME | ENUM | FIXED_SYM - | GEOMETRYCOLLECTION - | GEOMETRY_SYM | JSON_SYM - | LINESTRING | MEDIUM_SYM - | MULTILINESTRING - | MULTIPOINT - | MULTIPOLYGON | NATIONAL_SYM | NCHAR_SYM | NUMBER_MARIADB_SYM | NUMBER_ORACLE_SYM | NVARCHAR_SYM - | POINT_SYM - | POLYGON | RAW_MARIADB_SYM | RAW_ORACLE_SYM | ROW_SYM diff --git a/sql/sql_yacc_ora.yy b/sql/sql_yacc_ora.yy index be556f3d8e3..113f9b4d2f6 100644 --- a/sql/sql_yacc_ora.yy +++ b/sql/sql_yacc_ora.yy @@ -787,8 +787,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token FUNCTION_SYM /* SQL-2003-R, Oracle-R */ %token GENERAL %token GENERATED_SYM -%token GEOMETRYCOLLECTION -%token GEOMETRY_SYM %token GET_FORMAT /* MYSQL-FUNC */ %token GET_SYM /* SQL-2003-R */ %token GLOBAL_SYM /* SQL-2003-R */ @@ -828,7 +826,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token LEAVES %token LESS_SYM %token LEVEL_SYM -%token LINESTRING %token LIST_SYM %token LOCAL_SYM /* SQL-2003-R */ %token LOCKS_SYM @@ -874,9 +871,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token MODE_SYM %token MODIFY_SYM %token MONTH_SYM /* SQL-2003-R */ -%token MULTILINESTRING -%token MULTIPOINT -%token MULTIPOLYGON %token MUTEX_SYM %token MYSQL_SYM %token MYSQL_ERRNO_SYM @@ -923,8 +917,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %token PHASE_SYM %token PLUGINS_SYM %token PLUGIN_SYM -%token POINT_SYM -%token POLYGON %token PORT_SYM %token PRECEDES_SYM /* MYSQL */ %token PRECEDING_SYM /* SQL-2011-N */ @@ -1304,8 +1296,6 @@ bool my_yyoverflow(short **a, YYSTYPE **b, size_t *yystacksize); %type field_spec column_def -%type spatial_type - %type order_dir lock_option udf_type opt_local opt_no_write_to_binlog @@ -6837,6 +6827,14 @@ field_type: | field_type_string | field_type_lob | field_type_misc + | IDENT_sys float_options srid_option + { + const Type_handler *h; + if (!(h= Type_handler::handler_by_name_or_error($1))) + MYSQL_YYABORT; + $$.set(h, $2); + Lex->charset= &my_charset_bin; + } ; @@ -7059,16 +7057,6 @@ field_type_lob: Lex->charset=&my_charset_bin; $$.set(&type_handler_long_blob); } - | spatial_type float_options srid_option - { -#ifdef HAVE_SPATIAL - Lex->charset=&my_charset_bin; - $$.set($1, $2); -#else - my_yyabort_error((ER_FEATURE_DISABLED, MYF(0), sym_group_geom.name, - sym_group_geom.needed_define)); -#endif - } | MEDIUMBLOB opt_compressed { Lex->charset=&my_charset_bin; @@ -7112,17 +7100,6 @@ field_type_misc: { $$.set(&type_handler_set); } ; -spatial_type: - GEOMETRY_SYM { $$= GEOM_TYPE(&type_handler_geometry); } - | GEOMETRYCOLLECTION { $$= GEOM_TYPE(&type_handler_geometrycollection); } - | POINT_SYM { $$= GEOM_TYPE(&type_handler_point); } - | MULTIPOINT { $$= GEOM_TYPE(&type_handler_multipoint); } - | LINESTRING { $$= GEOM_TYPE(&type_handler_linestring); } - | MULTILINESTRING { $$= GEOM_TYPE(&type_handler_multilinestring); } - | POLYGON { $$= GEOM_TYPE(&type_handler_polygon); } - | MULTIPOLYGON { $$= GEOM_TYPE(&type_handler_multipolygon); } - ; - char: CHAR_SYM {} ; @@ -11145,34 +11122,6 @@ geometry_function: Item_func_spatial_precise_rel(thd, $3, $5, Item_func::SP_CONTAINS_FUNC)); } - | GEOMETRYCOLLECTION '(' expr_list ')' - { - $$= GEOM_NEW(thd, Item_func_geometrycollection(thd, *$3)); - } - | LINESTRING '(' expr_list ')' - { - $$= GEOM_NEW(thd, Item_func_linestring(thd, *$3)); - } - | MULTILINESTRING '(' expr_list ')' - { - $$= GEOM_NEW(thd, Item_func_multilinestring(thd, *$3)); - } - | MULTIPOINT '(' expr_list ')' - { - $$= GEOM_NEW(thd, Item_func_multipoint(thd, *$3)); - } - | MULTIPOLYGON '(' expr_list ')' - { - $$= GEOM_NEW(thd, Item_func_multipolygon(thd, *$3)); - } - | POINT_SYM '(' expr ',' expr ')' - { - $$= GEOM_NEW(thd, Item_func_point(thd, $3, $5)); - } - | POLYGON '(' expr_list ')' - { - $$= GEOM_NEW(thd, Item_func_polygon(thd, *$3)); - } | WITHIN '(' expr ',' expr ')' { $$= GEOM_NEW(thd, Item_func_spatial_precise_rel(thd, $3, $5, @@ -11211,6 +11160,7 @@ function_call_generic: } opt_udf_expr_list ')' { + const Type_handler *h; Create_func *builder; Item *item= NULL; @@ -11226,8 +11176,12 @@ function_call_generic: This will be revised with WL#2128 (SQL PATH) */ - builder= find_native_function_builder(thd, &$1); - if (builder) + if ((h= Type_handler::handler_by_name($1)) && + (item= h->make_constructor_item(thd, $4))) + { + // Found a constructor with a proper argument count + } + else if ((builder= find_native_function_builder(thd, &$1))) { item= builder->create_func(thd, &$1, $4); } @@ -16067,21 +16021,13 @@ keyword_data_type: | DATETIME | ENUM | FIXED_SYM - | GEOMETRYCOLLECTION - | GEOMETRY_SYM | JSON_SYM - | LINESTRING | MEDIUM_SYM - | MULTILINESTRING - | MULTIPOINT - | MULTIPOLYGON | NATIONAL_SYM | NCHAR_SYM | NUMBER_MARIADB_SYM | NUMBER_ORACLE_SYM | NVARCHAR_SYM - | POINT_SYM - | POLYGON | RAW_MARIADB_SYM | RAW_ORACLE_SYM | ROW_SYM diff --git a/storage/test_sql_discovery/mysql-test/sql_discovery/simple.result b/storage/test_sql_discovery/mysql-test/sql_discovery/simple.result index 23b7804638f..d63ec136225 100644 --- a/storage/test_sql_discovery/mysql-test/sql_discovery/simple.result +++ b/storage/test_sql_discovery/mysql-test/sql_discovery/simple.result @@ -82,7 +82,7 @@ select * from t1; ERROR HY000: Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table t1 (a uint)' show warnings; Level Code Message -Error 1064 You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'uint)' at line 1 +Error 4161 Unknown data type: 'uint' Error 1939 Engine TEST_SQL_DISCOVERY failed to discover table `test`.`t1` with 'create table t1 (a uint)' set @@test_sql_discovery_statement='t1:create table t1 (a int)'; select * from t1;