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
#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},
......
......@@ -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)},
......
......@@ -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
......
......@@ -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;
......@@ -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) &&
......
......@@ -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
}
......
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