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

Merge abotchkov@bk-internal.mysql.com:/home/bk/mysql-4.1

into deer.(none):/home/hf/work/mysql-4.1.spa
parents 3ad2158b 374a28d2
......@@ -242,6 +242,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
key_length=pointer;
if (keydef->flag & HA_SPATIAL)
{
#ifdef HAVE_SPATIAL
/* BAR TODO to support 3D and more dimensions in the future */
uint sp_segs=SPDIMS*2;
keydef->flag=HA_SPATIAL;
......@@ -270,6 +271,10 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
key_length+=SPLEN*sp_segs;
length++; /* At least one length byte */
min_key_length_skip+=SPLEN*2*SPDIMS;
#else
my_errno= HA_ERR_UNSUPPORTED;
goto err;
#endif /*HAVE_SPATIAL*/
}
else
if (keydef->flag & HA_FULLTEXT)
......@@ -588,6 +593,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
for (j=0 ; j < keydefs[i].keysegs-sp_segs ; j++)
if (mi_keyseg_write(file, &keydefs[i].seg[j]))
goto err;
#ifdef HAVE_SPATIAL
for (j=0 ; j < sp_segs ; j++)
{
HA_KEYSEG sseg;
......@@ -603,6 +609,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
if (mi_keyseg_write(file, &sseg))
goto err;
}
#endif
}
/* Create extra keys for unique definitions */
offset=reclength-uniques*MI_UNIQUE_HASH_LENGTH;
......
......@@ -46,7 +46,11 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key,
/*
TODO: nulls processing
*/
#ifdef HAVE_SPATIAL
return sp_make_key(info,keynr,key,record,filepos);
#else
DBUG_ASSERT(0); /* mi_open should check that this never happens*/
#endif
}
start=key;
......
......@@ -327,9 +327,14 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags)
}
if (share->keyinfo[i].flag & HA_SPATIAL)
{
#ifdef HAVE_SPATIAL
uint sp_segs=SPDIMS*2;
share->keyinfo[i].seg=pos-sp_segs;
share->keyinfo[i].keysegs--;
#else
my_errno=HA_ERR_UNSUPPORTED;
goto err;
#endif
}
else if (share->keyinfo[i].flag & HA_FULLTEXT)
{
......@@ -726,8 +731,12 @@ static void setup_key_functions(register MI_KEYDEF *keyinfo)
{
if (keyinfo->key_alg == HA_KEY_ALG_RTREE)
{
#ifdef HAVE_RTREE_KEYS
keyinfo->ck_insert = rtree_insert;
keyinfo->ck_delete = rtree_delete;
#else
DBUG_ASSERT(0); /* mi_open should check it never happens */
#endif
}
else
{
......
......@@ -65,6 +65,7 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, key_range *min_key,
rw_rdlock(&info->s->key_root_lock[inx]);
switch(info->s->keyinfo[inx].key_alg){
#ifdef HAVE_RTREE_KEYS
case HA_KEY_ALG_RTREE:
{
uchar * key_buff;
......@@ -79,6 +80,7 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, key_range *min_key,
res= res ? res : 1; /* Don't return 0 */
break;
}
#endif
case HA_KEY_ALG_BTREE:
default:
start_pos= (min_key ?
......
......@@ -74,6 +74,7 @@ int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len,
use_key_length=USE_WHOLE_KEY;
switch (info->s->keyinfo[inx].key_alg) {
#ifdef HAVE_RTREE_KEYS
case HA_KEY_ALG_RTREE:
if (rtree_find_first(info,inx,key_buff,use_key_length,nextflag) < 0)
{
......@@ -81,6 +82,7 @@ int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, uint key_len,
goto err;
}
break;
#endif
case HA_KEY_ALG_BTREE:
default:
if (!_mi_search(info, keyinfo, key_buff, use_key_length,
......
......@@ -45,9 +45,11 @@ int mi_rnext(MI_INFO *info, byte *buf, int inx)
if (!flag)
{
switch(info->s->keyinfo[inx].key_alg){
#ifdef HAVE_RTREE_KEYS
case HA_KEY_ALG_RTREE:
error=rtree_get_first(info,inx,info->lastkey_length);
break;
#endif
case HA_KEY_ALG_BTREE:
default:
error=_mi_search_first(info,info->s->keyinfo+inx,
......@@ -58,6 +60,7 @@ int mi_rnext(MI_INFO *info, byte *buf, int inx)
else
{
switch (info->s->keyinfo[inx].key_alg) {
#ifdef HAVE_RTREE_KEYS
case HA_KEY_ALG_RTREE:
/*
Note that rtree doesn't support that the table
......@@ -66,7 +69,7 @@ int mi_rnext(MI_INFO *info, byte *buf, int inx)
*/
error= rtree_get_next(info,inx,info->lastkey_length);
break;
#endif
case HA_KEY_ALG_BTREE:
default:
if (!changed)
......
......@@ -43,6 +43,7 @@ int mi_rnext_same(MI_INFO *info, byte *buf)
switch (keyinfo->key_alg)
{
#ifdef HAVE_RTREE_KEYS
case HA_KEY_ALG_RTREE:
if ((error=rtree_find_next(info,inx,
myisam_read_vec[info->last_key_func])))
......@@ -53,6 +54,7 @@ int mi_rnext_same(MI_INFO *info, byte *buf)
break;
}
break;
#endif
case HA_KEY_ALG_BTREE:
default:
memcpy(info->lastkey2,info->lastkey,info->last_rkey_length);
......
......@@ -17,6 +17,8 @@
#include "myisamdef.h"
#ifdef HAVE_RTREE_KEYS
#include "rt_index.h"
#include "rt_key.h"
#include "rt_mbr.h"
......@@ -991,3 +993,6 @@ ha_rows rtree_estimate(MI_INFO *info, uint keynr, uchar *key,
my_afree((byte*)page_buf);
return HA_POS_ERROR;
}
#endif /*HAVE_RTREE_KEYS*/
......@@ -18,6 +18,8 @@
#ifndef _rt_index_h
#define _rt_index_h
#ifdef HAVE_RTREE_KEYS
#define rt_PAGE_FIRST_KEY(page, nod_flag) (page + 2 + nod_flag)
#define rt_PAGE_NEXT_KEY(key, key_length, nod_flag) (key + key_length + \
(nod_flag ? nod_flag : info->s->base.rec_reflength))
......@@ -41,4 +43,5 @@ ha_rows rtree_estimate(MI_INFO *info, uint keynr, uchar *key,
int rtree_split_page(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, uchar *key,
uint key_length, my_off_t *new_page_offs);
#endif /*HAVE_RTREE_KEYS*/
#endif /* _rt_index_h */
......@@ -16,6 +16,7 @@
#include "myisamdef.h"
#ifdef HAVE_RTREE_KEYS
#include "rt_index.h"
#include "rt_key.h"
#include "rt_mbr.h"
......@@ -137,3 +138,5 @@ uchar *rtree_choose_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key,
}
return best_key;
}
#endif /*HAVE_RTREE_KEYS*/
......@@ -20,6 +20,8 @@
#ifndef _rt_key_h
#define _rt_key_h
#ifdef HAVE_RTREE_KEYS
int rtree_add_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key,
uint key_length, uchar *page_buf, my_off_t *new_page);
int rtree_delete_key(MI_INFO *info, uchar *page, uchar *key,
......@@ -28,4 +30,5 @@ int rtree_set_key_mbr(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key,
uint key_length, my_off_t child_page);
uchar *rtree_choose_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key,
uint key_length, uchar *page_buf, uint nod_flag);
#endif /*HAVE_RTREE_KEYS*/
#endif /* _rt_key_h */
......@@ -17,6 +17,8 @@
#include "myisamdef.h"
#ifdef HAVE_RTREE_KEYS
#include "rt_index.h"
#include "rt_mbr.h"
......@@ -757,3 +759,5 @@ int rtree_page_mbr(MI_INFO *info, HA_KEYSEG *keyseg, uchar *page_buf,
}
return 0;
}
#endif /*HAVE_RTREE_KEYS*/
......@@ -18,6 +18,8 @@
#ifndef _rt_mbr_h
#define _rt_mbr_h
#ifdef HAVE_RTREE_KEYS
int rtree_key_cmp(HA_KEYSEG *keyseg, uchar *a, uchar *b, uint key_length,
uint nextflag);
int rtree_combine_rect(HA_KEYSEG *keyseg,uchar *, uchar *, uchar*,
......@@ -30,4 +32,5 @@ double rtree_area_increase(HA_KEYSEG *keyseg, uchar *a, uchar *b,
uint key_length, double *ab_area);
int rtree_page_mbr(MI_INFO *info, HA_KEYSEG *keyseg, uchar *page_buf,
uchar* c, uint key_length);
#endif /*HAVE_RTREE_KEYS*/
#endif /* _rt_mbr_h */
......@@ -17,6 +17,8 @@
#include "myisamdef.h"
#ifdef HAVE_RTREE_KEYS
#include "rt_index.h"
#include "rt_key.h"
#include "rt_mbr.h"
......@@ -346,3 +348,5 @@ int rtree_split_page(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, uchar *key,
my_free((gptr) coord_buf, MYF(0));
return err_code;
}
#endif /*HAVE_RTREE_KEYS*/
......@@ -19,6 +19,9 @@
#include "myisam.h"
#ifdef HAVE_RTREE_KEYS
#include "rt_index.h"
#define MAX_REC_LENGTH 1024
......@@ -398,3 +401,10 @@ static void create_record(char *record,uint rownr)
pos+=sizeof(c);
}
}
#else
int main(int argc __attribute__((unused)),char *argv[] __attribute__((unused)))
{
exit(0);
}
#endif /*HAVE_RTREE_KEYS*/
......@@ -22,6 +22,8 @@
#define SPTYPE HA_KEYTYPE_DOUBLE
#define SPLEN 8
#ifdef HAVE_SPATIAL
enum wkbType
{
wkbPoint = 1,
......@@ -42,4 +44,5 @@ enum wkbByteOrder
uint sp_make_key(register MI_INFO *info, uint keynr, uchar *key,
const byte *record, my_off_t filepos);
#endif /*HAVE_SPATIAL*/
#endif /* _SP_DEFS_H */
......@@ -15,6 +15,9 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "myisamdef.h"
#ifdef HAVE_SPATIAL
#include "sp_defs.h"
static int sp_add_point_to_mbr(uchar *(*wkb), uchar *end, uint n_dims,
......@@ -284,3 +287,5 @@ static int sp_get_geometry_mbr(uchar *(*wkb), uchar *end, uint n_dims,
}
return res;
}
#endif /*HAVE_SPATIAL*/
......@@ -18,6 +18,8 @@
/* Written by Alex Barkov, who has a shared copyright to this code */
#include "myisam.h"
#ifdef HAVE_SPATIAL
#include "sp_defs.h"
#define MAX_REC_LENGTH 1024
......@@ -553,3 +555,11 @@ static void rtree_PrintWKB(uchar *wkb, uint n_dims)
}
}
}
#else
int main(int argc __attribute__((unused)),char *argv[] __attribute__((unused)))
{
exit(0);
}
#endif /*HAVE_SPATIAL*/
......@@ -15,6 +15,9 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
#include "mysql_priv.h"
#ifdef HAVE_SPATIAL
#define MAX_DIGITS_IN_DOUBLE 16
/***************************** Gis_class_info *******************************/
......@@ -1652,3 +1655,4 @@ const Geometry::Class_info *Gis_geometry_collection::get_class_info() const
return &geometrycollection_class;
}
#endif /*HAVE_SPATIAL*/
......@@ -17,6 +17,8 @@
#ifndef _spatial_h
#define _spatial_h
#ifdef HAVE_SPATIAL
const uint SRID_SIZE= 4;
const uint SIZEOF_STORED_DOUBLE= 8;
const uint POINT_DATA_SIZE= SIZEOF_STORED_DOUBLE*2;
......@@ -459,4 +461,5 @@ struct Geometry_buffer
void *arr[(geometry_buffer_size - 1)/sizeof(void *) + 1];
};
#endif /*HAVE_SPATAIAL*/
#endif
......@@ -1312,7 +1312,6 @@ type:
$$=FIELD_TYPE_GEOMETRY;
#else
net_printf(Lex->thd, ER_FEATURE_DISABLED,
ER(ER_FEATURE_DISABLED),
sym_group_geom.name,
sym_group_geom.needed_define);
YYABORT;
......@@ -1630,7 +1629,6 @@ key_type:
$$= Key::SPATIAL;
#else
net_printf(Lex->thd, ER_FEATURE_DISABLED,
ER(ER_FEATURE_DISABLED),
sym_group_geom.name, sym_group_geom.needed_define);
YYABORT;
#endif
......@@ -1664,7 +1662,6 @@ opt_unique_or_fulltext:
$$= Key::SPATIAL;
#else
net_printf(Lex->thd, ER_FEATURE_DISABLED,
ER(ER_FEATURE_DISABLED),
sym_group_geom.name, sym_group_geom.needed_define);
YYABORT;
#endif
......@@ -2676,7 +2673,6 @@ simple_expr:
if (!$1.symbol->create_func)
{
net_printf(Lex->thd, ER_FEATURE_DISABLED,
ER(ER_FEATURE_DISABLED),
$1.symbol->group->name,
$1.symbol->group->needed_define);
YYABORT;
......@@ -2688,7 +2684,6 @@ simple_expr:
if (!$1.symbol->create_func)
{
net_printf(Lex->thd, ER_FEATURE_DISABLED,
ER(ER_FEATURE_DISABLED),
$1.symbol->group->name,
$1.symbol->group->needed_define);
YYABORT;
......@@ -2700,7 +2695,6 @@ simple_expr:
if (!$1.symbol->create_func)
{
net_printf(Lex->thd, ER_FEATURE_DISABLED,
ER(ER_FEATURE_DISABLED),
$1.symbol->group->name,
$1.symbol->group->needed_define);
YYABORT;
......@@ -2712,7 +2706,6 @@ simple_expr:
if (!$1.symbol->create_func)
{
net_printf(Lex->thd, ER_FEATURE_DISABLED,
ER(ER_FEATURE_DISABLED),
$1.symbol->group->name,
$1.symbol->group->needed_define);
YYABORT;
......@@ -2809,7 +2802,6 @@ simple_expr:
$$= $1;
#else
net_printf(Lex->thd, ER_FEATURE_DISABLED,
ER(ER_FEATURE_DISABLED),
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