Commit 6dcda515 authored by hf@deer.(none)'s avatar hf@deer.(none)

SCRUM:

WL#1163 (Making spatial code optional)
Pack of changes to do in sql/ code.
parent ecf8118c
...@@ -4470,7 +4470,7 @@ Field_blob::Field_blob(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, ...@@ -4470,7 +4470,7 @@ Field_blob::Field_blob(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg,
:Field_str(ptr_arg, (1L << min(blob_pack_length,3)*8)-1L, :Field_str(ptr_arg, (1L << min(blob_pack_length,3)*8)-1L,
null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg, null_ptr_arg, null_bit_arg, unireg_check_arg, field_name_arg,
table_arg, cs), table_arg, cs),
geom_flag(true), packlength(blob_pack_length) packlength(blob_pack_length)
{ {
flags|= BLOB_FLAG; flags|= BLOB_FLAG;
if (table) if (table)
...@@ -4705,6 +4705,7 @@ void Field_blob::get_key_image(char *buff,uint length, ...@@ -4705,6 +4705,7 @@ void Field_blob::get_key_image(char *buff,uint length,
uint32 blob_length= get_length(ptr); uint32 blob_length= get_length(ptr);
char *blob; char *blob;
#ifdef HAVE_SPATIAL
if (type == itMBR) if (type == itMBR)
{ {
if (!blob_length) if (!blob_length)
...@@ -4721,6 +4722,7 @@ void Field_blob::get_key_image(char *buff,uint length, ...@@ -4721,6 +4722,7 @@ void Field_blob::get_key_image(char *buff,uint length,
float8store(buff+24, mbr.ymax); float8store(buff+24, mbr.ymax);
return; return;
} }
#endif /*HAVE_SPATIAL*/
if ((uint32) length > blob_length) if ((uint32) length > blob_length)
{ {
...@@ -4930,6 +4932,7 @@ uint Field_blob::max_packed_col_length(uint max_length) ...@@ -4930,6 +4932,7 @@ uint Field_blob::max_packed_col_length(uint max_length)
return (max_length > 255 ? 2 : 1)+max_length; return (max_length > 255 ? 2 : 1)+max_length;
} }
#ifdef HAVE_SPATIAL
void Field_geom::get_key_image(char *buff, uint length, CHARSET_INFO *cs, void Field_geom::get_key_image(char *buff, uint length, CHARSET_INFO *cs,
imagetype type) imagetype type)
...@@ -5013,6 +5016,7 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs) ...@@ -5013,6 +5016,7 @@ int Field_geom::store(const char *from, uint length, CHARSET_INFO *cs)
return 0; return 0;
} }
#endif /*HAVE_SPATIAL*/
/**************************************************************************** /****************************************************************************
** enum type. ** enum type.
...@@ -5488,10 +5492,12 @@ Field *make_field(char *ptr, uint32 field_length, ...@@ -5488,10 +5492,12 @@ Field *make_field(char *ptr, uint32 field_length,
f_packtype(pack_flag), f_packtype(pack_flag),
field_length); field_length);
#ifdef HAVE_SPATIAL
if (f_is_geom(pack_flag)) if (f_is_geom(pack_flag))
return new Field_geom(ptr,null_pos,null_bit, return new Field_geom(ptr,null_pos,null_bit,
unireg_check, field_name, table, unireg_check, field_name, table,
pack_length, geom_type); pack_length, geom_type);
#endif
if (f_is_blob(pack_flag)) if (f_is_blob(pack_flag))
return new Field_blob(ptr,null_pos,null_bit, return new Field_blob(ptr,null_pos,null_bit,
unireg_check, field_name, table, unireg_check, field_name, table,
...@@ -5651,10 +5657,12 @@ create_field::create_field(Field *old_field,Field *orig_field) ...@@ -5651,10 +5657,12 @@ create_field::create_field(Field *old_field,Field *orig_field)
def=new Item_string(pos,tmp.length(), charset); def=new Item_string(pos,tmp.length(), charset);
} }
} }
#ifdef HAVE_SPATIAL
if (sql_type == FIELD_TYPE_GEOMETRY) if (sql_type == FIELD_TYPE_GEOMETRY)
{ {
geom_type= ((Field_geom*)old_field)->geom_type; geom_type= ((Field_geom*)old_field)->geom_type;
} }
#endif
} }
......
...@@ -913,7 +913,6 @@ public: ...@@ -913,7 +913,6 @@ public:
class Field_blob :public Field_str { class Field_blob :public Field_str {
bool geom_flag;
protected: protected:
uint packlength; uint packlength;
String value; // For temporaries String value; // For temporaries
...@@ -926,7 +925,7 @@ public: ...@@ -926,7 +925,7 @@ public:
struct st_table *table_arg, CHARSET_INFO *cs) struct st_table *table_arg, CHARSET_INFO *cs)
:Field_str((char*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0,0, :Field_str((char*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0,0,
NONE, field_name_arg, table_arg, cs), NONE, field_name_arg, table_arg, cs),
geom_flag(true), packlength(4) packlength(4)
{ {
flags|= BLOB_FLAG; flags|= BLOB_FLAG;
} }
...@@ -1001,7 +1000,7 @@ public: ...@@ -1001,7 +1000,7 @@ public:
field_cast_enum field_cast_type() { return FIELD_CAST_BLOB; } field_cast_enum field_cast_type() { return FIELD_CAST_BLOB; }
}; };
#ifdef HAVE_SPATIAL
class Field_geom :public Field_blob { class Field_geom :public Field_blob {
public: public:
enum geometry_type geom_type; enum geometry_type geom_type;
...@@ -1029,7 +1028,7 @@ public: ...@@ -1029,7 +1028,7 @@ public:
void set_key_image(char *buff,uint length, CHARSET_INFO *cs); void set_key_image(char *buff,uint length, CHARSET_INFO *cs);
field_cast_enum field_cast_type() { return FIELD_CAST_GEOM; } field_cast_enum field_cast_type() { return FIELD_CAST_GEOM; }
}; };
#endif /*HAVE_SPATIAL*/
class Field_enum :public Field_str { class Field_enum :public Field_str {
protected: protected:
......
...@@ -487,6 +487,7 @@ Item *create_func_quote(Item* a) ...@@ -487,6 +487,7 @@ Item *create_func_quote(Item* a)
return new Item_func_quote(a); return new Item_func_quote(a);
} }
#ifdef HAVE_SPATIAL
Item *create_func_as_wkt(Item *a) Item *create_func_as_wkt(Item *a)
{ {
return new Item_func_as_wkt(a); return new Item_func_as_wkt(a);
...@@ -646,6 +647,7 @@ Item *create_func_point(Item *a, Item *b) ...@@ -646,6 +647,7 @@ Item *create_func_point(Item *a, Item *b)
{ {
return new Item_func_point(a, b); return new Item_func_point(a, b);
} }
#endif /*HAVE_SPATIAL*/
Item *create_func_crc32(Item* a) Item *create_func_crc32(Item* a)
{ {
......
...@@ -99,6 +99,8 @@ Item *create_func_is_free_lock(Item* a); ...@@ -99,6 +99,8 @@ Item *create_func_is_free_lock(Item* a);
Item *create_func_is_used_lock(Item* a); Item *create_func_is_used_lock(Item* a);
Item *create_func_quote(Item* a); Item *create_func_quote(Item* a);
#ifdef HAVE_SPATIAL
Item *create_func_geometry_from_text(Item *a); Item *create_func_geometry_from_text(Item *a);
Item *create_func_as_wkt(Item *a); Item *create_func_as_wkt(Item *a);
Item *create_func_as_wkb(Item *a); Item *create_func_as_wkb(Item *a);
...@@ -138,6 +140,8 @@ Item *create_func_numgeometries(Item *a); ...@@ -138,6 +140,8 @@ Item *create_func_numgeometries(Item *a);
Item *create_func_point(Item *a, Item *b); Item *create_func_point(Item *a, Item *b);
#endif /*HAVE_SPATIAL*/
Item *create_func_compress(Item *a); Item *create_func_compress(Item *a);
Item *create_func_uncompress(Item *a); Item *create_func_uncompress(Item *a);
Item *create_func_uncompressed_length(Item *a); Item *create_func_uncompressed_length(Item *a);
......
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
/* This file defines all spatial functions */ /* This file defines all spatial functions */
#ifdef HAVE_SPATIAL
#ifdef __GNUC__ #ifdef __GNUC__
#pragma implementation // gcc: Class implementation #pragma implementation // gcc: Class implementation
#endif #endif
...@@ -651,3 +653,5 @@ longlong Item_func_srid::val_int() ...@@ -651,3 +653,5 @@ longlong Item_func_srid::val_int()
uint32 res= uint4korr(swkb->ptr()); uint32 res= uint4korr(swkb->ptr());
return (longlong) res; return (longlong) res;
} }
#endif /*HAVE_SPATIAL*/
...@@ -17,6 +17,8 @@ ...@@ -17,6 +17,8 @@
/* This file defines all spatial functions */ /* This file defines all spatial functions */
#ifdef HAVE_SPATIAL
#ifdef __GNUC__ #ifdef __GNUC__
#pragma interface /* gcc class implementation */ #pragma interface /* gcc class implementation */
#endif #endif
...@@ -338,3 +340,12 @@ public: ...@@ -338,3 +340,12 @@ public:
const char *func_name() const { return "srid"; } const char *func_name() const { return "srid"; }
void fix_length_and_dec() { max_length= 10; } void fix_length_and_dec() { max_length= 10; }
}; };
#define GEOM_NEW(obj_constructor) new obj_constructor
#else /*HAVE_SPATIAL*/
#define GEOM_NEW(obj_constructor) NULL
#endif
This diff is collapsed.
...@@ -20,11 +20,17 @@ ...@@ -20,11 +20,17 @@
#ifndef _lex_symbol_h #ifndef _lex_symbol_h
#define _lex_symbol_h #define _lex_symbol_h
typedef 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;
} SYMBOL; } SYMBOL;
typedef struct st_lex_symbol typedef struct st_lex_symbol
......
...@@ -510,6 +510,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -510,6 +510,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
blob_columns++; blob_columns++;
break; break;
case FIELD_TYPE_GEOMETRY: case FIELD_TYPE_GEOMETRY:
#ifdef HAVE_SPATIAL
if (!(file->table_flags() & HA_HAS_GEOMETRY)) if (!(file->table_flags() & HA_HAS_GEOMETRY))
{ {
my_printf_error(ER_CHECK_NOT_IMPLEMENTED, ER(ER_CHECK_NOT_IMPLEMENTED), my_printf_error(ER_CHECK_NOT_IMPLEMENTED, ER(ER_CHECK_NOT_IMPLEMENTED),
...@@ -525,6 +526,11 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -525,6 +526,11 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
sql_field->unireg_check=Field::BLOB_FIELD; sql_field->unireg_check=Field::BLOB_FIELD;
blob_columns++; blob_columns++;
break; break;
#else
my_printf_error(ER_FEATURE_DISABLED,ER(ER_FEATURE_DISABLED), MYF(0),
"Spatial extentions", "HAVE_SPATIAL");
DBUG_RETURN(-1);
#endif /*HAVE_SPATIAL*/
case FIELD_TYPE_VAR_STRING: case FIELD_TYPE_VAR_STRING:
case FIELD_TYPE_STRING: case FIELD_TYPE_STRING:
sql_field->pack_flag=0; sql_field->pack_flag=0;
...@@ -658,8 +664,14 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -658,8 +664,14 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
key_info->flags = HA_FULLTEXT; key_info->flags = HA_FULLTEXT;
break; break;
case Key::SPATIAL: case Key::SPATIAL:
#ifdef HAVE_SPATIAL
key_info->flags = HA_SPATIAL; key_info->flags = HA_SPATIAL;
break; break;
#else
my_printf_error(ER_FEATURE_DISABLED,ER(ER_FEATURE_DISABLED),MYF(0),
"Spatial extentions", "HAVE_SPATIAL");
DBUG_RETURN(-1);
#endif
case Key::FOREIGN_KEY: case Key::FOREIGN_KEY:
key_number--; // Skip this key key_number--; // Skip this key
continue; continue;
...@@ -688,6 +700,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -688,6 +700,7 @@ 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)
{ {
...@@ -698,8 +711,11 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -698,8 +711,11 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
} }
else if (key_info->algorithm == HA_KEY_ALG_RTREE) else
#endif
if (key_info->algorithm == HA_KEY_ALG_RTREE)
{ {
#ifdef HAVE_RTREE_KEYS
if ((key_info->key_parts & 1) == 1) if ((key_info->key_parts & 1) == 1)
{ {
my_printf_error(ER_WRONG_ARGUMENTS, my_printf_error(ER_WRONG_ARGUMENTS,
...@@ -710,6 +726,11 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -710,6 +726,11 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
my_printf_error(ER_NOT_SUPPORTED_YET, ER(ER_NOT_SUPPORTED_YET), my_printf_error(ER_NOT_SUPPORTED_YET, ER(ER_NOT_SUPPORTED_YET),
MYF(0), "RTREE INDEX"); MYF(0), "RTREE INDEX");
DBUG_RETURN(-1); DBUG_RETURN(-1);
#else
my_printf_error(ER_FEATURE_DISABLED,ER(ER_FEATURE_DISABLED),MYF(0),
"Spatial extentions", "HAVE_SPATIAL");
DBUG_RETURN(-1);
#endif
} }
List_iterator<key_part_spec> cols(key->columns); List_iterator<key_part_spec> cols(key->columns);
...@@ -779,6 +800,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -779,6 +800,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
DBUG_RETURN(-1); DBUG_RETURN(-1);
} }
} }
#ifdef HAVE_SPATIAL
if (key->type == Key::SPATIAL) if (key->type == Key::SPATIAL)
{ {
if (!column->length ) if (!column->length )
...@@ -790,6 +812,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -790,6 +812,7 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
column->length=4*sizeof(double); column->length=4*sizeof(double);
} }
} }
#endif
if (!(sql_field->flags & NOT_NULL_FLAG)) if (!(sql_field->flags & NOT_NULL_FLAG))
{ {
if (key->type == Key::PRIMARY) if (key->type == Key::PRIMARY)
...@@ -806,11 +829,13 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -806,11 +829,13 @@ 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)
{ {
...@@ -834,9 +859,11 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name, ...@@ -834,9 +859,11 @@ 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???
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) &&
......
This diff is collapsed.
...@@ -405,8 +405,13 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag, ...@@ -405,8 +405,13 @@ int openfrm(const char *name, const char *alias, uint db_stat, uint prgflag,
// charset and geometry_type share the same byte in frm // charset and geometry_type share the same byte in frm
if (field_type == FIELD_TYPE_GEOMETRY) if (field_type == FIELD_TYPE_GEOMETRY)
{ {
#ifdef HAVE_SPATIAL
geom_type= (Field::geometry_type) strpos[14]; geom_type= (Field::geometry_type) strpos[14];
charset= &my_charset_bin; charset= &my_charset_bin;
#else
error= 4; // unsupported field type
goto err_not_open;
#endif
} }
else else
{ {
......
...@@ -471,7 +471,12 @@ static bool pack_fields(File file,List<create_field> &create_fields) ...@@ -471,7 +471,12 @@ static bool pack_fields(File file,List<create_field> &create_fields)
buff[12]= (uchar) field->interval_id; buff[12]= (uchar) field->interval_id;
buff[13]= (uchar) field->sql_type; buff[13]= (uchar) field->sql_type;
if (field->sql_type == FIELD_TYPE_GEOMETRY) if (field->sql_type == FIELD_TYPE_GEOMETRY)
{
buff[14]= (uchar) field->geom_type; buff[14]= (uchar) field->geom_type;
#ifndef HAVE_SPATIAL
DBUG_ASSERT(0); // Should newer happen
#endif
}
else if (field->charset) else if (field->charset)
buff[14]= (uchar) field->charset->number; buff[14]= (uchar) field->charset->number;
else else
......
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