diff options
author | unknown <hf@deer.(none)> | 2004-01-23 16:02:57 +0400 |
---|---|---|
committer | unknown <hf@deer.(none)> | 2004-01-23 16:02:57 +0400 |
commit | 214c178f1763c14934a337c2ebce89f10aa18741 (patch) | |
tree | 8172c7f6f96ab3801ef15dfbb93d61a10809047f | |
parent | 235f1a4d60968bd9083780d13e249aad9fe7120c (diff) | |
download | mariadb-git-214c178f1763c14934a337c2ebce89f10aa18741.tar.gz |
SCRUM
wl #1163 (Make spatial code optional)
Patch I cleaned with Serg & Monty's suggestions
sql/gen_lex_hash.cc:
mysql_priv.h was included for SYM_GROUP declaration
sql/lex.h:
sym_group_xxx made global so we can use texts from them
throughout the code
sql/lex_symbol.h:
SYM_GROUP declaration moved to mysql_priv.h
sql/mysql_priv.h:
declarations about SYM_GROUP
sql/sql_table.cc:
sym_group_xxx objects used instead of text constants
a couple of HAVE_SPATIAL removed
sql/sql_yacc.yy:
sym_group_xxx used instead of text constants
some duplicated code restructured
MYF(0) parameters removed from net_printf calls
-rw-r--r-- | sql/gen_lex_hash.cc | 3 | ||||
-rw-r--r-- | sql/lex.h | 9 | ||||
-rw-r--r-- | sql/lex_symbol.h | 7 | ||||
-rw-r--r-- | sql/mysql_priv.h | 9 | ||||
-rw-r--r-- | sql/sql_table.cc | 13 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 62 |
6 files changed, 42 insertions, 61 deletions
diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 7126b7ee577..6df7d867a4d 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -81,9 +81,10 @@ TODO: #endif #include <my_getopt.h> #include "mysql_version.h" +#include "mysql_priv.h" #include "lex.h" -static struct my_option my_long_options[] = +struct my_option my_long_options[] = { {"help", '?', "Display help and exit", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/sql/lex.h b/sql/lex.h index 78a22fad153..93c3ec2f01e 100644 --- a/sql/lex.h +++ b/sql/lex.h @@ -20,8 +20,9 @@ #include "lex_symbol.h" /* We don't want to include sql_yacc.h into gen_lex_hash */ -static SYM_GROUP sym_group_common= {"", ""}; -static SYM_GROUP sym_group_geom= {"Spatial extentions", "HAVE_SPATIAL"}; +SYM_GROUP sym_group_common= {"", ""}; +SYM_GROUP sym_group_geom= {"Spatial extentions", "HAVE_SPATIAL"}; +SYM_GROUP sym_group_rtree= {"RTree keys", "HAVE_RTREE_KEYS"}; #ifdef NO_YACC_SYMBOLS #define SYM_OR_NULL(A) 0 @@ -457,7 +458,6 @@ static SYMBOL symbols[] = { static SYMBOL sql_functions[] = { { "ABS", F_SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_abs)}, -#ifdef DUMMY { "ACOS", F_SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_acos)}, { "ADDDATE", SYM(ADDDATE_SYM)}, { "ADDTIME", F_SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_addtime)}, @@ -534,7 +534,7 @@ static SYMBOL sql_functions[] = { { "FROM_UNIXTIME", SYM(FROM_UNIXTIME)}, { "GET_LOCK", F_SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_get_lock)}, { "GEOMETRYN", F_SYM(FUNC_ARG2),0,CREATE_FUNC_GEOM(create_func_geometryn)}, - { "GEOMETRYTYPE", SYM(FUNC_ARG1),0,CREATE_FUNC_GEOM(create_func_geometry_type)}, + { "GEOMETRYTYPE", F_SYM(FUNC_ARG1),0,CREATE_FUNC_GEOM(create_func_geometry_type)}, { "GEOMCOLLFROMTEXT", SYM(GEOMCOLLFROMTEXT)}, { "GEOMCOLLFROMWKB", SYM(GEOMFROMWKB)}, { "GEOMETRYCOLLECTIONFROMTEXT",SYM(GEOMCOLLFROMTEXT)}, @@ -657,7 +657,6 @@ static SYMBOL sql_functions[] = { { "SUBSTR", SYM(SUBSTRING)}, { "SUBSTRING", SYM(SUBSTRING)}, { "SUBSTRING_INDEX", SYM(SUBSTRING_INDEX)}, -#endif /*dummy*/ { "SUBTIME", F_SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_subtime)}, { "SUM", SYM(SUM_SYM)}, { "SYSDATE", SYM(NOW_SYM)}, diff --git a/sql/lex_symbol.h b/sql/lex_symbol.h index 63d4f9d69c2..d1d30a73669 100644 --- a/sql/lex_symbol.h +++ b/sql/lex_symbol.h @@ -20,17 +20,14 @@ #ifndef _lex_symbol_h #define _lex_symbol_h -typedef struct st_sym_group { - const char *name; - const char *needed_define; -} SYM_GROUP; +struct st_sym_group; typedef struct st_symbol { const char *name; uint tok; uint length; void *create_func; - SYM_GROUP *group; + struct st_sym_group *group; } SYMBOL; typedef struct st_lex_symbol diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 15a99385285..43478d8d0a4 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -1099,3 +1099,12 @@ inline void setup_table_map(TABLE *table, TABLE_LIST *table_list, uint tablenr) table->map= (table_map) 1 << tablenr; table->force_index= table_list->force_index; } + +typedef struct st_sym_group { + const char *name; + const char *needed_define; +} SYM_GROUP; + +extern SYM_GROUP sym_group_common; +extern SYM_GROUP sym_group_geom; +extern SYM_GROUP sym_group_rtree; diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 127dc4c3474..3a7055c8078 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -528,7 +528,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, break; #else my_printf_error(ER_FEATURE_DISABLED,ER(ER_FEATURE_DISABLED), MYF(0), - "Spatial extentions", "HAVE_SPATIAL"); + sym_group_geom.name, sym_group_geom.needed_define); DBUG_RETURN(-1); #endif /*HAVE_SPATIAL*/ case FIELD_TYPE_VAR_STRING: @@ -669,7 +669,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, break; #else my_printf_error(ER_FEATURE_DISABLED,ER(ER_FEATURE_DISABLED),MYF(0), - "Spatial extentions", "HAVE_SPATIAL"); + sym_group_geom.name, sym_group_geom.needed_define); DBUG_RETURN(-1); #endif case Key::FOREIGN_KEY: @@ -700,7 +700,6 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, checking for proper key parts number: */ -#ifdef HAVE_SPATIAL /* TODO: Add proper checks if handler supports key_type and algorithm */ if (key_info->flags == HA_SPATIAL) { @@ -712,7 +711,6 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, } } else -#endif if (key_info->algorithm == HA_KEY_ALG_RTREE) { #ifdef HAVE_RTREE_KEYS @@ -728,7 +726,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, DBUG_RETURN(-1); #else my_printf_error(ER_FEATURE_DISABLED,ER(ER_FEATURE_DISABLED),MYF(0), - "Spatial extentions", "HAVE_SPATIAL"); + sym_group_rtree.name, sym_group_rtree.needed_define); DBUG_RETURN(-1); #endif } @@ -829,13 +827,11 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, MYF(0),column->field_name); DBUG_RETURN(-1); } -#ifdef HAVE_SPATIAL if (key->type == Key::SPATIAL) { my_error(ER_SPATIAL_CANT_HAVE_NULL, MYF(0)); DBUG_RETURN(-1); } -#endif } if (MTYP_TYPENR(sql_field->unireg_check) == Field::NEXT_NUMBER) { @@ -859,11 +855,10 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, DBUG_RETURN(-1); } } -#ifdef HAVE_SPATIAL //TODO HF What's this for??? + /* TODO HF What's this for??? */ else if (f_is_geom(sql_field->pack_flag)) { } -#endif else if (column->length > length || ((f_is_packed(sql_field->pack_flag) || ((file->table_flags() & HA_NO_PREFIX_CHAR_KEYS) && diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 6ab44cb9f08..f4c68b79053 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -1244,8 +1244,8 @@ field_spec: (enum enum_field_types) $3, lex->length,lex->dec,lex->type, lex->default_value, lex->comment, - lex->change,lex->interval,lex->charset - ,lex->uint_geom_type)) + lex->change,lex->interval,lex->charset, + lex->uint_geom_type)) YYABORT; }; @@ -1305,8 +1305,8 @@ type: #else net_printf(Lex->thd, ER_FEATURE_DISABLED, ER(ER_FEATURE_DISABLED), - MYF(0), "Spatial extentions", - "HAVE_SPATIAL"); + sym_group_geom.name, + sym_group_geom.needed_define); YYABORT; #endif } @@ -1589,42 +1589,32 @@ delete_option: key_type: key_or_index { $$= Key::MULTIPLE; } - | FULLTEXT_SYM { $$= Key::FULLTEXT; } - | FULLTEXT_SYM key_or_index { $$= Key::FULLTEXT; } - | SPATIAL_SYM - { -#ifdef HAVE_SPATIAL - $$= Key::SPATIAL; -#else - net_printf(Lex->thd, ER_FEATURE_DISABLED, - ER(ER_FEATURE_DISABLED), - MYF(0), "Spatial extentions", - "HAVE_SPATIAL"); - YYABORT; -#endif - } - | SPATIAL_SYM key_or_index + | FULLTEXT_SYM opt_key_or_index { $$= Key::FULLTEXT; } + | SPATIAL_SYM opt_key_or_index { #ifdef HAVE_SPATIAL $$= Key::SPATIAL; #else net_printf(Lex->thd, ER_FEATURE_DISABLED, ER(ER_FEATURE_DISABLED), - MYF(0), "Spatial extentions", - "HAVE_SPATIAL"); + sym_group_geom.name, sym_group_geom.needed_define); YYABORT; #endif }; constraint_key_type: PRIMARY_SYM KEY_SYM { $$= Key::PRIMARY; } - | UNIQUE_SYM { $$= Key::UNIQUE; } - | UNIQUE_SYM key_or_index { $$= Key::UNIQUE; }; + | UNIQUE_SYM opt_key_or_index { $$= Key::UNIQUE; }; key_or_index: KEY_SYM {} | INDEX {}; +opt_key_or_index: + /* empty */ {} + | key_or_index + ; + opt_keys_or_index: /* empty */ {} | keys_or_index @@ -1646,8 +1636,7 @@ opt_unique_or_fulltext: #else net_printf(Lex->thd, ER_FEATURE_DISABLED, ER(ER_FEATURE_DISABLED), - MYF(0), "Spatial extentions", - "HAVE_SPATIAL"); + sym_group_geom.name, sym_group_geom.needed_define); YYABORT; #endif } @@ -1662,15 +1651,7 @@ opt_btree_or_rtree: BTREE_SYM { $$= HA_KEY_ALG_BTREE; } | RTREE_SYM { -#ifdef HAVE_RTREE_KEYS $$= HA_KEY_ALG_RTREE; -#else - net_printf(Lex->thd, ER_FEATURE_DISABLED, - ER(ER_FEATURE_DISABLED), - MYF(0), "RTree keys", - "HAVE_RTREE_KEYS"); - YYABORT; -#endif } | HASH_SYM { $$= HA_KEY_ALG_HASH; }; @@ -1769,8 +1750,8 @@ alter_list_item: (enum enum_field_types) $5, lex->length,lex->dec,lex->type, lex->default_value, lex->comment, - $3.str, lex->interval, lex->charset - ,lex->uint_geom_type)) + $3.str, lex->interval, lex->charset, + lex->uint_geom_type)) YYABORT; } opt_place @@ -2605,7 +2586,7 @@ simple_expr: { net_printf(Lex->thd, ER_FEATURE_DISABLED, ER(ER_FEATURE_DISABLED), - MYF(0), $1.symbol->group->name, + $1.symbol->group->name, $1.symbol->group->needed_define); YYABORT; } @@ -2617,7 +2598,7 @@ simple_expr: { net_printf(Lex->thd, ER_FEATURE_DISABLED, ER(ER_FEATURE_DISABLED), - MYF(0), $1.symbol->group->name, + $1.symbol->group->name, $1.symbol->group->needed_define); YYABORT; } @@ -2629,7 +2610,7 @@ simple_expr: { net_printf(Lex->thd, ER_FEATURE_DISABLED, ER(ER_FEATURE_DISABLED), - MYF(0), $1.symbol->group->name, + $1.symbol->group->name, $1.symbol->group->needed_define); YYABORT; } @@ -2641,7 +2622,7 @@ simple_expr: { net_printf(Lex->thd, ER_FEATURE_DISABLED, ER(ER_FEATURE_DISABLED), - MYF(0), $1.symbol->group->name, + $1.symbol->group->name, $1.symbol->group->needed_define); YYABORT; } @@ -2736,8 +2717,7 @@ simple_expr: #else net_printf(Lex->thd, ER_FEATURE_DISABLED, ER(ER_FEATURE_DISABLED), - MYF(0), "Spatial extentions", - "HAVE_SPATIAL"); + sym_group_geom.name, sym_group_geom.needed_define); YYABORT; #endif } |