summaryrefslogtreecommitdiff
path: root/myisam/mi_create.c
diff options
context:
space:
mode:
authorunknown <bar@gw.udmsearch.izhnet.ru>2002-02-20 14:11:21 +0400
committerunknown <bar@gw.udmsearch.izhnet.ru>2002-02-20 14:11:21 +0400
commit3d5dc65dfd72083ed159220d03bea942094e8662 (patch)
tree20573ea174df56ec053e23fa07eb87679f3b7a38 /myisam/mi_create.c
parentb87d6ee9d730fb2df74a3981b552b0da2e09570c (diff)
downloadmariadb-git-3d5dc65dfd72083ed159220d03bea942094e8662.tar.gz
This ChangeSet adds RTREE support into myisam library.
RTREEs will be used for GIS extension in MySQL myisam/.cvsignore: Added sp_test and rt_test myisam/Makefile.am: Added RTREE files myisam/mi_create.c: Added RTREE/SPATIAL initialization myisam/mi_delete.c: Switched to use virual function, instead of mi_ck_delete() direct call myisam/mi_key.c: Added sp_make_key() call in the case of SPATIAL index type myisam/mi_open.c: Added some new initialization actions which depend on key_alg being used: RTREE or BTREE myisam/mi_range.c: Rtree estimation myisam/mi_rkey.c: rtree myisam/mi_rnext.c: rtree myisam/mi_rnext_same.c: rtree myisam/mi_static.c: New search flags for bounding rectungles myisam/mi_test1.c: one now should always specify key_alg during keyinfo initializing: BTREE or RTREE myisam/mi_test2.c: Added key_alg initializing myisam/mi_test3.c: Added key_alg initialization myisam/mi_update.c: Switched to virtual functions, instead of mi_ck_delete/mi_ck_write direct call myisam/mi_write.c: Virtual function instead of mi_ck_write() direct call myisam/myisamdef.h: Rtree additions
Diffstat (limited to 'myisam/mi_create.c')
-rw-r--r--myisam/mi_create.c55
1 files changed, 52 insertions, 3 deletions
diff --git a/myisam/mi_create.c b/myisam/mi_create.c
index 91c2c64c3cf..8f4a44a52a4 100644
--- a/myisam/mi_create.c
+++ b/myisam/mi_create.c
@@ -17,6 +17,8 @@
/* Create a MyISAM table */
#include "fulltext.h"
+#include "sp_defs.h"
+
#if defined(MSDOS) || defined(__WIN__)
#ifdef __WIN__
#include <fcntl.h>
@@ -233,11 +235,42 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
for (i=0, keydef=keydefs ; i < keys ; i++ , keydef++)
{
- share.state.key_root[i]= HA_OFFSET_ERROR;
+ share.state.key_root[i]= HA_OFFSET_ERROR;
min_key_length_skipp=length=0;
key_length=pointer;
+ if (keydef->flag & HA_SPATIAL)
+ {
+ /* BAR TODO to support 3D and more dimensions in the future */
+ uint sp_segs=SPDIMS*2;
+ keydef->flag=HA_SPATIAL;
+ if (flags & HA_DONT_TOUCH_DATA)
+ {
+ /*
+ called by myisamchk - i.e. table structure was taken from
+ MYI file and SPATIAL key *do has* additional sp_segs keysegs.
+ We'd better delete them now
+ */
+ keydef->keysegs-=sp_segs;
+ }
+
+ for (j=0, keyseg=keydef->seg ; (int) j < keydef->keysegs ;
+ j++, keyseg++)
+ {
+ if (keyseg->type != HA_KEYTYPE_BINARY &&
+ keyseg->type != HA_KEYTYPE_VARBINARY)
+ {
+ my_errno=HA_WRONG_CREATE_OPTION;
+ goto err;
+ }
+ }
+ keydef->keysegs+=sp_segs;
+ key_length+=SPLEN*sp_segs;
+ length++; /* At least one length byte */
+ min_key_length_skipp+=SPLEN*2*SPDIMS;
+ }
+ else
if (keydef->flag & HA_FULLTEXT) /* SerG */
{
keydef->flag=HA_FULLTEXT | HA_PACK_KEY | HA_VAR_LENGTH_KEY;
@@ -554,12 +587,13 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
for (i=0 ; i < share.base.keys - uniques; i++)
{
uint ft_segs=(keydefs[i].flag & HA_FULLTEXT) ? FT_SEGS : 0;
+ uint sp_segs=(keydefs[i].flag & HA_SPATIAL) ? 2*SPDIMS : 0;
if (mi_keydef_write(file, &keydefs[i]))
goto err;
- for (j=0 ; j < keydefs[i].keysegs-ft_segs ; j++)
+ for (j=0 ; j < keydefs[i].keysegs-ft_segs-sp_segs ; j++)
if (mi_keyseg_write(file, &keydefs[i].seg[j]))
- goto err;
+ goto err;
for (j=0 ; j < ft_segs ; j++)
{
MI_KEYSEG seg=ft_keysegs[j];
@@ -567,6 +601,21 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
if (mi_keyseg_write(file, &seg))
goto err;
}
+ for (j=0 ; j < sp_segs ; j++)
+ {
+ MI_KEYSEG sseg;
+ sseg.type=SPTYPE;
+ sseg.language= 7;
+ sseg.null_bit=0;
+ sseg.bit_start=0;
+ sseg.bit_end=0;
+ sseg.length=SPLEN;
+ sseg.null_pos=0;
+ sseg.start=j*SPLEN;
+ sseg.flag= HA_SWAP_KEY;
+ if (mi_keyseg_write(file, &sseg))
+ goto err;
+ }
}
/* Create extra keys for unique definitions */
offset=reclength-uniques*MI_UNIQUE_HASH_LENGTH;