Commit 77176c2d authored by unknown's avatar unknown

Geometry field type implementation


sql/field.cc:
  Field_geom implementations
sql/field.h:
  Necessary additions to Field_geom type
sql/ha_myisam.cc:
  Field_geom works mostly like blob
sql/sql_parse.cc:
  working with FIELD_TYPE_GEOM
sql/sql_table.cc:
  specifying FIELD_TYPE_GEOMETRY flags
parent e0e1110e
......@@ -4271,7 +4271,7 @@ void Field_blob::set_key_image(char *buff,uint length)
void Field_geom::get_key_image(char *buff,uint length, imagetype type)
{
length-=HA_KEY_BLOB_LENGTH;
/* length-=HA_KEY_BLOB_LENGTH;
ulong blob_length=get_length(ptr);
char *blob;
get_ptr(&blob);
......@@ -4286,12 +4286,19 @@ void Field_geom::get_key_image(char *buff,uint length, imagetype type)
float8store(buff+16, mbr.ymin);
float8store(buff+24, mbr.ymax);
return;
*/
Field_blob::get_key_image(buff, length, type);
}
void Field_geom::set_key_image(char *buff,uint length)
{
Field_blob::set_key_image(buff, length);
}
void Field_geom::sql_type(String &res) const
{
res.set("geometry", 8U, default_charset_info);
}
int Field_blob::key_cmp(const byte *key_ptr, uint max_key_length)
......@@ -4941,6 +4948,7 @@ uint32 calc_pack_length(enum_field_types type,uint32 length)
case FIELD_TYPE_BLOB: return 2+portable_sizeof_char_ptr;
case FIELD_TYPE_MEDIUM_BLOB: return 3+portable_sizeof_char_ptr;
case FIELD_TYPE_LONG_BLOB: return 4+portable_sizeof_char_ptr;
case FIELD_TYPE_GEOMETRY: return 2+portable_sizeof_char_ptr;
case FIELD_TYPE_SET:
case FIELD_TYPE_ENUM: abort(); return 0; // This shouldn't happen
default: return 0;
......@@ -4988,15 +4996,15 @@ Field *make_field(char *ptr, uint32 field_length,
f_packtype(pack_flag),
field_length);
if (f_is_geom(pack_flag))
return new Field_geom(ptr,null_pos,null_bit,
unireg_check, field_name, table,
pack_length,f_is_binary(pack_flag) != 0);
if (f_is_blob(pack_flag))
return new Field_blob(ptr,null_pos,null_bit,
unireg_check, field_name, table,
pack_length,f_is_binary(pack_flag) != 0,
default_charset_info);
if (f_is_geom(pack_flag))
return new Field_geom(ptr,null_pos,null_bit,
unireg_check, field_name, table,
pack_length,f_is_binary(pack_flag) != 0);
if (interval)
{
......
......@@ -937,6 +937,8 @@ public:
:Field_blob(len_arg, maybe_null_arg, field_name_arg,
table_arg, binary_arg, default_charset_info) {}
enum ha_base_keytype key_type() const { return HA_KEYTYPE_VARBINARY; }
enum_field_types type() const { return FIELD_TYPE_GEOMETRY;}
void sql_type(String &str) const;
void get_key_image(char *buff,uint length, imagetype type);
void set_key_image(char *buff,uint length);
......
......@@ -1066,7 +1066,7 @@ int ha_myisam::create(const char *name, register TABLE *table,
keydef[i].flag|=HA_AUTO_KEY;
found_auto_increment=1;
}
if (field->type() == FIELD_TYPE_BLOB)
if ((field->type() == FIELD_TYPE_BLOB) || (field->type() == FIELD_TYPE_GEOMETRY))
{
keydef[i].seg[j].flag|=HA_BLOB_PART;
/* save number of bytes used to pack length */
......
......@@ -3018,7 +3018,6 @@ bool add_field_to_list(char *field_name, enum_field_types type,
case FIELD_TYPE_STRING:
case FIELD_TYPE_VAR_STRING:
case FIELD_TYPE_NULL:
case FIELD_TYPE_GEOMETRY:
break;
case FIELD_TYPE_DECIMAL:
if (!length)
......@@ -3031,6 +3030,7 @@ bool add_field_to_list(char *field_name, enum_field_types type,
case FIELD_TYPE_TINY_BLOB:
case FIELD_TYPE_LONG_BLOB:
case FIELD_TYPE_MEDIUM_BLOB:
case FIELD_TYPE_GEOMETRY:
if (default_value) // Allow empty as default value
{
String str,*res;
......@@ -3166,7 +3166,7 @@ bool add_field_to_list(char *field_name, enum_field_types type,
if (new_field->length >= MAX_FIELD_WIDTH ||
(!new_field->length && !(new_field->flags & BLOB_FLAG) &&
type != FIELD_TYPE_STRING && type != FIELD_TYPE_VAR_STRING))
type != FIELD_TYPE_STRING && type != FIELD_TYPE_VAR_STRING && type != FIELD_TYPE_GEOMETRY))
{
net_printf(&thd->net,ER_TOO_BIG_FIELDLENGTH,field_name,
MAX_FIELD_WIDTH-1); /* purecov: inspected */
......
......@@ -351,6 +351,16 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
sql_field->unireg_check=Field::BLOB_FIELD;
blob_columns++;
break;
case FIELD_TYPE_GEOMETRY:
sql_field->pack_flag=FIELDFLAG_GEOM |
pack_length_to_packflag(sql_field->pack_length -
portable_sizeof_char_ptr);
if (sql_field->flags & BINARY_FLAG)
sql_field->pack_flag|=FIELDFLAG_BINARY;
sql_field->length=8; // Unireg field length
sql_field->unireg_check=Field::BLOB_FIELD;
blob_columns++;
break;
case FIELD_TYPE_VAR_STRING:
case FIELD_TYPE_STRING:
sql_field->pack_flag=0;
......
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