Commit 215a65b1 authored by hf@deer.(none)'s avatar hf@deer.(none)

SCRUM

wl #1163 (Make spatial code optional)
Patch I cleaned with Serg & Monty's suggestions
parent 6dcda515
...@@ -81,9 +81,10 @@ So, we can read full search-structure as 32-bit word ...@@ -81,9 +81,10 @@ So, we can read full search-structure as 32-bit word
#endif #endif
#include <my_getopt.h> #include <my_getopt.h>
#include "mysql_version.h" #include "mysql_version.h"
#include "mysql_priv.h"
#include "lex.h" #include "lex.h"
static struct my_option my_long_options[] = struct my_option my_long_options[] =
{ {
{"help", '?', "Display help and exit", {"help", '?', "Display help and exit",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
......
...@@ -20,8 +20,9 @@ ...@@ -20,8 +20,9 @@
#include "lex_symbol.h" #include "lex_symbol.h"
/* We don't want to include sql_yacc.h into gen_lex_hash */ /* We don't want to include sql_yacc.h into gen_lex_hash */
static SYM_GROUP sym_group_common= {"", ""}; SYM_GROUP sym_group_common= {"", ""};
static SYM_GROUP sym_group_geom= {"Spatial extentions", "HAVE_SPATIAL"}; SYM_GROUP sym_group_geom= {"Spatial extentions", "HAVE_SPATIAL"};
SYM_GROUP sym_group_rtree= {"RTree keys", "HAVE_RTREE_KEYS"};
#ifdef NO_YACC_SYMBOLS #ifdef NO_YACC_SYMBOLS
#define SYM_OR_NULL(A) 0 #define SYM_OR_NULL(A) 0
...@@ -457,7 +458,6 @@ static SYMBOL symbols[] = { ...@@ -457,7 +458,6 @@ static SYMBOL symbols[] = {
static SYMBOL sql_functions[] = { static SYMBOL sql_functions[] = {
{ "ABS", F_SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_abs)}, { "ABS", F_SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_abs)},
#ifdef DUMMY
{ "ACOS", F_SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_acos)}, { "ACOS", F_SYM(FUNC_ARG1),0,CREATE_FUNC(create_func_acos)},
{ "ADDDATE", SYM(ADDDATE_SYM)}, { "ADDDATE", SYM(ADDDATE_SYM)},
{ "ADDTIME", F_SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_addtime)}, { "ADDTIME", F_SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_addtime)},
...@@ -534,7 +534,7 @@ static SYMBOL sql_functions[] = { ...@@ -534,7 +534,7 @@ static SYMBOL sql_functions[] = {
{ "FROM_UNIXTIME", SYM(FROM_UNIXTIME)}, { "FROM_UNIXTIME", SYM(FROM_UNIXTIME)},
{ "GET_LOCK", F_SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_get_lock)}, { "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)}, { "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)}, { "GEOMCOLLFROMTEXT", SYM(GEOMCOLLFROMTEXT)},
{ "GEOMCOLLFROMWKB", SYM(GEOMFROMWKB)}, { "GEOMCOLLFROMWKB", SYM(GEOMFROMWKB)},
{ "GEOMETRYCOLLECTIONFROMTEXT",SYM(GEOMCOLLFROMTEXT)}, { "GEOMETRYCOLLECTIONFROMTEXT",SYM(GEOMCOLLFROMTEXT)},
...@@ -657,7 +657,6 @@ static SYMBOL sql_functions[] = { ...@@ -657,7 +657,6 @@ static SYMBOL sql_functions[] = {
{ "SUBSTR", SYM(SUBSTRING)}, { "SUBSTR", SYM(SUBSTRING)},
{ "SUBSTRING", SYM(SUBSTRING)}, { "SUBSTRING", SYM(SUBSTRING)},
{ "SUBSTRING_INDEX", SYM(SUBSTRING_INDEX)}, { "SUBSTRING_INDEX", SYM(SUBSTRING_INDEX)},
#endif /*dummy*/
{ "SUBTIME", F_SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_subtime)}, { "SUBTIME", F_SYM(FUNC_ARG2),0,CREATE_FUNC(create_func_subtime)},
{ "SUM", SYM(SUM_SYM)}, { "SUM", SYM(SUM_SYM)},
{ "SYSDATE", SYM(NOW_SYM)}, { "SYSDATE", SYM(NOW_SYM)},
......
...@@ -20,17 +20,14 @@ ...@@ -20,17 +20,14 @@
#ifndef _lex_symbol_h #ifndef _lex_symbol_h
#define _lex_symbol_h #define _lex_symbol_h
typedef struct st_sym_group { struct st_sym_group;
const char *name;
const char *needed_define;
} SYM_GROUP;
typedef struct st_symbol { typedef struct st_symbol {
const char *name; const char *name;
uint tok; uint tok;
uint length; uint length;
void *create_func; void *create_func;
SYM_GROUP *group; struct st_sym_group *group;
} SYMBOL; } SYMBOL;
typedef struct st_lex_symbol typedef struct st_lex_symbol
......
...@@ -1099,3 +1099,12 @@ inline void setup_table_map(TABLE *table, TABLE_LIST *table_list, uint tablenr) ...@@ -1099,3 +1099,12 @@ inline void setup_table_map(TABLE *table, TABLE_LIST *table_list, uint tablenr)
table->map= (table_map) 1 << tablenr; table->map= (table_map) 1 << tablenr;
table->force_index= table_list->force_index; 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;
...@@ -528,7 +528,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -528,7 +528,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
break; break;
#else #else
my_printf_error(ER_FEATURE_DISABLED,ER(ER_FEATURE_DISABLED), MYF(0), 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); DBUG_RETURN(-1);
#endif /*HAVE_SPATIAL*/ #endif /*HAVE_SPATIAL*/
case FIELD_TYPE_VAR_STRING: case FIELD_TYPE_VAR_STRING:
...@@ -669,7 +669,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -669,7 +669,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
break; break;
#else #else
my_printf_error(ER_FEATURE_DISABLED,ER(ER_FEATURE_DISABLED),MYF(0), 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); DBUG_RETURN(-1);
#endif #endif
case Key::FOREIGN_KEY: case Key::FOREIGN_KEY:
...@@ -700,7 +700,6 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -700,7 +700,6 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
checking for proper key parts number: checking for proper key parts number:
*/ */
#ifdef HAVE_SPATIAL
/* TODO: Add proper checks if handler supports key_type and algorithm */ /* TODO: Add proper checks if handler supports key_type and algorithm */
if (key_info->flags == HA_SPATIAL) if (key_info->flags == HA_SPATIAL)
{ {
...@@ -712,7 +711,6 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -712,7 +711,6 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
} }
} }
else else
#endif
if (key_info->algorithm == HA_KEY_ALG_RTREE) if (key_info->algorithm == HA_KEY_ALG_RTREE)
{ {
#ifdef HAVE_RTREE_KEYS #ifdef HAVE_RTREE_KEYS
...@@ -728,7 +726,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -728,7 +726,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
DBUG_RETURN(-1); DBUG_RETURN(-1);
#else #else
my_printf_error(ER_FEATURE_DISABLED,ER(ER_FEATURE_DISABLED),MYF(0), 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); DBUG_RETURN(-1);
#endif #endif
} }
...@@ -829,13 +827,11 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -829,13 +827,11 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
MYF(0),column->field_name); MYF(0),column->field_name);
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
#ifdef HAVE_SPATIAL
if (key->type == Key::SPATIAL) if (key->type == Key::SPATIAL)
{ {
my_error(ER_SPATIAL_CANT_HAVE_NULL, MYF(0)); my_error(ER_SPATIAL_CANT_HAVE_NULL, MYF(0));
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
#endif
} }
if (MTYP_TYPENR(sql_field->unireg_check) == Field::NEXT_NUMBER) 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, ...@@ -859,11 +855,10 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
DBUG_RETURN(-1); 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)) else if (f_is_geom(sql_field->pack_flag))
{ {
} }
#endif
else if (column->length > length || else if (column->length > length ||
((f_is_packed(sql_field->pack_flag) || ((f_is_packed(sql_field->pack_flag) ||
((file->table_flags() & HA_NO_PREFIX_CHAR_KEYS) && ((file->table_flags() & HA_NO_PREFIX_CHAR_KEYS) &&
......
...@@ -1244,8 +1244,8 @@ field_spec: ...@@ -1244,8 +1244,8 @@ field_spec:
(enum enum_field_types) $3, (enum enum_field_types) $3,
lex->length,lex->dec,lex->type, lex->length,lex->dec,lex->type,
lex->default_value, lex->comment, lex->default_value, lex->comment,
lex->change,lex->interval,lex->charset lex->change,lex->interval,lex->charset,
,lex->uint_geom_type)) lex->uint_geom_type))
YYABORT; YYABORT;
}; };
...@@ -1305,8 +1305,8 @@ type: ...@@ -1305,8 +1305,8 @@ type:
#else #else
net_printf(Lex->thd, ER_FEATURE_DISABLED, net_printf(Lex->thd, ER_FEATURE_DISABLED,
ER(ER_FEATURE_DISABLED), ER(ER_FEATURE_DISABLED),
MYF(0), "Spatial extentions", sym_group_geom.name,
"HAVE_SPATIAL"); sym_group_geom.needed_define);
YYABORT; YYABORT;
#endif #endif
} }
...@@ -1589,42 +1589,32 @@ delete_option: ...@@ -1589,42 +1589,32 @@ delete_option:
key_type: key_type:
key_or_index { $$= Key::MULTIPLE; } key_or_index { $$= Key::MULTIPLE; }
| FULLTEXT_SYM { $$= Key::FULLTEXT; } | FULLTEXT_SYM opt_key_or_index { $$= Key::FULLTEXT; }
| FULLTEXT_SYM key_or_index { $$= Key::FULLTEXT; } | SPATIAL_SYM opt_key_or_index
| 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
{ {
#ifdef HAVE_SPATIAL #ifdef HAVE_SPATIAL
$$= Key::SPATIAL; $$= Key::SPATIAL;
#else #else
net_printf(Lex->thd, ER_FEATURE_DISABLED, net_printf(Lex->thd, ER_FEATURE_DISABLED,
ER(ER_FEATURE_DISABLED), ER(ER_FEATURE_DISABLED),
MYF(0), "Spatial extentions", sym_group_geom.name, sym_group_geom.needed_define);
"HAVE_SPATIAL");
YYABORT; YYABORT;
#endif #endif
}; };
constraint_key_type: constraint_key_type:
PRIMARY_SYM KEY_SYM { $$= Key::PRIMARY; } PRIMARY_SYM KEY_SYM { $$= Key::PRIMARY; }
| UNIQUE_SYM { $$= Key::UNIQUE; } | UNIQUE_SYM opt_key_or_index { $$= Key::UNIQUE; };
| UNIQUE_SYM key_or_index { $$= Key::UNIQUE; };
key_or_index: key_or_index:
KEY_SYM {} KEY_SYM {}
| INDEX {}; | INDEX {};
opt_key_or_index:
/* empty */ {}
| key_or_index
;
opt_keys_or_index: opt_keys_or_index:
/* empty */ {} /* empty */ {}
| keys_or_index | keys_or_index
...@@ -1646,8 +1636,7 @@ opt_unique_or_fulltext: ...@@ -1646,8 +1636,7 @@ opt_unique_or_fulltext:
#else #else
net_printf(Lex->thd, ER_FEATURE_DISABLED, net_printf(Lex->thd, ER_FEATURE_DISABLED,
ER(ER_FEATURE_DISABLED), ER(ER_FEATURE_DISABLED),
MYF(0), "Spatial extentions", sym_group_geom.name, sym_group_geom.needed_define);
"HAVE_SPATIAL");
YYABORT; YYABORT;
#endif #endif
} }
...@@ -1662,15 +1651,7 @@ opt_btree_or_rtree: ...@@ -1662,15 +1651,7 @@ opt_btree_or_rtree:
BTREE_SYM { $$= HA_KEY_ALG_BTREE; } BTREE_SYM { $$= HA_KEY_ALG_BTREE; }
| RTREE_SYM | RTREE_SYM
{ {
#ifdef HAVE_RTREE_KEYS
$$= HA_KEY_ALG_RTREE; $$= 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; }; | HASH_SYM { $$= HA_KEY_ALG_HASH; };
...@@ -1769,8 +1750,8 @@ alter_list_item: ...@@ -1769,8 +1750,8 @@ alter_list_item:
(enum enum_field_types) $5, (enum enum_field_types) $5,
lex->length,lex->dec,lex->type, lex->length,lex->dec,lex->type,
lex->default_value, lex->comment, lex->default_value, lex->comment,
$3.str, lex->interval, lex->charset $3.str, lex->interval, lex->charset,
,lex->uint_geom_type)) lex->uint_geom_type))
YYABORT; YYABORT;
} }
opt_place opt_place
...@@ -2605,7 +2586,7 @@ simple_expr: ...@@ -2605,7 +2586,7 @@ simple_expr:
{ {
net_printf(Lex->thd, ER_FEATURE_DISABLED, net_printf(Lex->thd, ER_FEATURE_DISABLED,
ER(ER_FEATURE_DISABLED), ER(ER_FEATURE_DISABLED),
MYF(0), $1.symbol->group->name, $1.symbol->group->name,
$1.symbol->group->needed_define); $1.symbol->group->needed_define);
YYABORT; YYABORT;
} }
...@@ -2617,7 +2598,7 @@ simple_expr: ...@@ -2617,7 +2598,7 @@ simple_expr:
{ {
net_printf(Lex->thd, ER_FEATURE_DISABLED, net_printf(Lex->thd, ER_FEATURE_DISABLED,
ER(ER_FEATURE_DISABLED), ER(ER_FEATURE_DISABLED),
MYF(0), $1.symbol->group->name, $1.symbol->group->name,
$1.symbol->group->needed_define); $1.symbol->group->needed_define);
YYABORT; YYABORT;
} }
...@@ -2629,7 +2610,7 @@ simple_expr: ...@@ -2629,7 +2610,7 @@ simple_expr:
{ {
net_printf(Lex->thd, ER_FEATURE_DISABLED, net_printf(Lex->thd, ER_FEATURE_DISABLED,
ER(ER_FEATURE_DISABLED), ER(ER_FEATURE_DISABLED),
MYF(0), $1.symbol->group->name, $1.symbol->group->name,
$1.symbol->group->needed_define); $1.symbol->group->needed_define);
YYABORT; YYABORT;
} }
...@@ -2641,7 +2622,7 @@ simple_expr: ...@@ -2641,7 +2622,7 @@ simple_expr:
{ {
net_printf(Lex->thd, ER_FEATURE_DISABLED, net_printf(Lex->thd, ER_FEATURE_DISABLED,
ER(ER_FEATURE_DISABLED), ER(ER_FEATURE_DISABLED),
MYF(0), $1.symbol->group->name, $1.symbol->group->name,
$1.symbol->group->needed_define); $1.symbol->group->needed_define);
YYABORT; YYABORT;
} }
...@@ -2736,8 +2717,7 @@ simple_expr: ...@@ -2736,8 +2717,7 @@ simple_expr:
#else #else
net_printf(Lex->thd, ER_FEATURE_DISABLED, net_printf(Lex->thd, ER_FEATURE_DISABLED,
ER(ER_FEATURE_DISABLED), ER(ER_FEATURE_DISABLED),
MYF(0), "Spatial extentions", sym_group_geom.name, sym_group_geom.needed_define);
"HAVE_SPATIAL");
YYABORT; YYABORT;
#endif #endif
} }
......
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