Commit e013efcc authored by monty@hundin.mysql.fi's avatar monty@hundin.mysql.fi

Fixed problem in fulltest testcase

parent 3b43cb29
......@@ -147,11 +147,11 @@ enum ha_base_keytype {
#define HA_NOSAME 1 /* Set if not dupplicated records */
#define HA_PACK_KEY 2 /* Pack string key to previous key */
#define HA_AUTO_KEY 1024
#define HA_AUTO_KEY 16
#define HA_BINARY_PACK_KEY 32 /* Packing of all keys to prev key */
#define HA_FULLTEXT 128 /* SerG: for full-text search */
#define HA_FULLTEXT 128 /* For full-text search */
#define HA_UNIQUE_CHECK 256 /* Check the key for uniqueness */
#define HA_SPATIAL 16 /* Alex Barkov: for spatial search */
#define HA_SPATIAL 1024 /* For spatial search */
#define HA_NULL_ARE_EQUAL 2048 /* NULL in key are cmp as equal */
......
......@@ -920,7 +920,7 @@ uint mi_keydef_write(File file, MI_KEYDEF *keydef)
uchar *ptr=buff;
*ptr++ = (uchar) keydef->keysegs;
*ptr++ = keydef->key_alg; /* +BAR Rtree or Btree */
*ptr++ = keydef->key_alg; /* Rtree or Btree */
mi_int2store(ptr,keydef->flag); ptr +=2;
mi_int2store(ptr,keydef->block_length); ptr +=2;
mi_int2store(ptr,keydef->keylength); ptr +=2;
......@@ -932,7 +932,7 @@ uint mi_keydef_write(File file, MI_KEYDEF *keydef)
char *mi_keydef_read(char *ptr, MI_KEYDEF *keydef)
{
keydef->keysegs = (uint) *ptr++;
keydef->key_alg = *ptr++; /* +BAR Rtree or Btree */
keydef->key_alg = *ptr++; /* Rtree or Btree */
keydef->flag = mi_uint2korr(ptr); ptr +=2;
keydef->block_length = mi_uint2korr(ptr); ptr +=2;
......
......@@ -58,15 +58,15 @@ static int compare_bin(uchar *a, uint a_length, uchar *b, uint b_length,
return (int) (a_length-b_length);
}
#define CMP(a,b) (a<b ? -1 : a == b ? 0 : 1)
#define FCMP(A,B) ((int) (A) - (int) (B))
/*
Compare two keys
Returns <0, 0, >0 acording to which is bigger
Key_length specifies length of key to use. Number-keys can't be splited
If flag <> SEARCH_FIND compare also position
Compare two keys
Returns <0, 0, >0 acording to which is bigger
Key_length specifies length of key to use. Number-keys can't be splited
If flag <> SEARCH_FIND compare also position
*/
int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
register uchar *b, uint key_length, uint nextflag,
uint *diff_pos)
......@@ -83,13 +83,14 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
for ( ; (int) key_length >0 ; key_length=next_key_length, keyseg++)
{
uchar *end;
uint piks=! (keyseg->flag & HA_NO_SORT);
(*diff_pos)++;
/* Handle NULL part */
if (keyseg->null_bit)
{
key_length--;
if (*a != *b)
if (*a != *b && piks)
{
flag = (int) *a - (int) *b;
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
......@@ -115,7 +116,8 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
get_key_pack_length(b_length,pack_length,b);
next_key_length=key_length-b_length-pack_length;
if ((flag= mi_compare_text(keyseg->charset,a,a_length,b,b_length,
if (piks &&
(flag= mi_compare_text(keyseg->charset,a,a_length,b,b_length,
(my_bool) ((nextflag & SEARCH_PREFIX) &&
next_key_length <= 0))))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
......@@ -133,7 +135,8 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
while (b_length && b[b_length-1] == ' ')
b_length--;
}
if ((flag= mi_compare_text(keyseg->charset,a,a_length,b,b_length,
if (piks &&
(flag= mi_compare_text(keyseg->charset,a,a_length,b,b_length,
(my_bool) ((nextflag & SEARCH_PREFIX) &&
next_key_length <= 0))))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
......@@ -149,7 +152,8 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
get_key_pack_length(b_length,pack_length,b);
next_key_length=key_length-b_length-pack_length;
if ((flag=compare_bin(a,a_length,b,b_length,
if (piks &&
(flag=compare_bin(a,a_length,b,b_length,
(my_bool) ((nextflag & SEARCH_PREFIX) &&
next_key_length <= 0))))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
......@@ -160,7 +164,8 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
else
{
uint length=keyseg->length;
if ((flag=compare_bin(a,length,b,length,
if (piks &&
(flag=compare_bin(a,length,b,length,
(my_bool) ((nextflag & SEARCH_PREFIX) &&
next_key_length <= 0))))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
......@@ -175,7 +180,8 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
get_key_pack_length(b_length,pack_length,b);
next_key_length=key_length-b_length-pack_length;
if ((flag= mi_compare_text(keyseg->charset,a,a_length,b,b_length,
if (piks &&
(flag= mi_compare_text(keyseg->charset,a,a_length,b,b_length,
(my_bool) ((nextflag & SEARCH_PREFIX) &&
next_key_length <= 0))))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
......@@ -191,7 +197,8 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
get_key_pack_length(b_length,pack_length,b);
next_key_length=key_length-b_length-pack_length;
if ((flag=compare_bin(a,a_length,b,b_length,
if (piks &&
(flag=compare_bin(a,a_length,b,b_length,
(my_bool) ((nextflag & SEARCH_PREFIX) &&
next_key_length <= 0))))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
......@@ -204,7 +211,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
{
int i_1= (int) *((signed char*) a);
int i_2= (int) *((signed char*) b);
if ((flag = CMP(i_1,i_2)))
if (piks && (flag = CMP_NUM(i_1,i_2)))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end;
b++;
......@@ -213,7 +220,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
case HA_KEYTYPE_SHORT_INT:
s_1= mi_sint2korr(a);
s_2= mi_sint2korr(b);
if ((flag = CMP(s_1,s_2)))
if (piks && (flag = CMP_NUM(s_1,s_2)))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end;
b+= 2; /* sizeof(short int); */
......@@ -223,7 +230,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
uint16 us_1,us_2;
us_1= mi_sint2korr(a);
us_2= mi_sint2korr(b);
if ((flag = CMP(us_1,us_2)))
if (piks && (flag = CMP_NUM(us_1,us_2)))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end;
b+=2; /* sizeof(short int); */
......@@ -232,7 +239,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
case HA_KEYTYPE_LONG_INT:
l_1= mi_sint4korr(a);
l_2= mi_sint4korr(b);
if ((flag = CMP(l_1,l_2)))
if (piks && (flag = CMP_NUM(l_1,l_2)))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end;
b+= 4; /* sizeof(long int); */
......@@ -240,7 +247,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
case HA_KEYTYPE_ULONG_INT:
u_1= mi_sint4korr(a);
u_2= mi_sint4korr(b);
if ((flag = CMP(u_1,u_2)))
if (piks && (flag = CMP_NUM(u_1,u_2)))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end;
b+= 4; /* sizeof(long int); */
......@@ -248,7 +255,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
case HA_KEYTYPE_INT24:
l_1=mi_sint3korr(a);
l_2=mi_sint3korr(b);
if ((flag = CMP(l_1,l_2)))
if (piks && (flag = CMP_NUM(l_1,l_2)))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end;
b+= 3;
......@@ -256,7 +263,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
case HA_KEYTYPE_UINT24:
l_1=mi_uint3korr(a);
l_2=mi_uint3korr(b);
if ((flag = CMP(l_1,l_2)))
if (piks && (flag = CMP_NUM(l_1,l_2)))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end;
b+= 3;
......@@ -264,7 +271,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
case HA_KEYTYPE_FLOAT:
mi_float4get(f_1,a);
mi_float4get(f_2,b);
if ((flag = CMP(f_1,f_2)))
if (piks && (flag = CMP_NUM(f_1,f_2)))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end;
b+= 4; /* sizeof(float); */
......@@ -272,7 +279,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
case HA_KEYTYPE_DOUBLE:
mi_float8get(d_1,a);
mi_float8get(d_2,b);
if ((flag = CMP(d_1,d_2)))
if (piks && (flag = CMP_NUM(d_1,d_2)))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end;
b+= 8; /* sizeof(double); */
......@@ -303,6 +310,8 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
for ( ; blength && *b == ' ' ; b++, blength--) ;
}
if (piks)
{
if (*a == '-')
{
if (*b != '-')
......@@ -329,6 +338,12 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
while (a < end)
if (*a++ != *b++)
return ((int) a[-1] - (int) b[-1]);
}
else
{
b+=(end-a);
a=end;
}
if (swap_flag) /* Restore pointers */
swap(uchar*,a,b);
......@@ -340,7 +355,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
longlong ll_a,ll_b;
ll_a= mi_sint8korr(a);
ll_b= mi_sint8korr(b);
if ((flag = CMP(ll_a,ll_b)))
if (piks && (flag = CMP_NUM(ll_a,ll_b)))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end;
b+= 8;
......@@ -351,7 +366,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
ulonglong ll_a,ll_b;
ll_a= mi_uint8korr(a);
ll_b= mi_uint8korr(b);
if ((flag = CMP(ll_a,ll_b)))
if (piks && (flag = CMP_NUM(ll_a,ll_b)))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end;
b+= 8;
......
......@@ -680,13 +680,16 @@ int GPolygon::centroid_xy(double *x, double *y) const
uint32 i;
double res_area, res_cx, res_cy;
const char *data = m_data;
LINT_INIT(res_area);
LINT_INIT(res_cx);
LINT_INIT(res_cy);
if (no_data(data, 4))
return 1;
n_linear_rings = uint4korr(data);
data += 4;
for(i = 0; i < n_linear_rings; ++i)
for (i = 0; i < n_linear_rings; ++i)
{
if (no_data(data, 4))
return 1;
......@@ -720,7 +723,8 @@ int GPolygon::centroid_xy(double *x, double *y) const
cur_area = fabs(cur_area) / 2;
cur_cx = cur_cx / (n_points - 1);
cur_cy = cur_cy / (n_points - 1);
if(i)
if (i)
{
double d_area = res_area - cur_area;
if (d_area <= 0)
......@@ -1195,6 +1199,10 @@ int GMultiPolygon::centroid(String *result) const
double res_area, res_cx, res_cy;
double cur_area, cur_cx, cur_cy;
LINT_INIT(res_area);
LINT_INIT(res_cx);
LINT_INIT(res_cy);
const char *data = m_data;
if (no_data(data, 4))
return 1;
......@@ -1211,7 +1219,7 @@ int GMultiPolygon::centroid(String *result) const
if (p.centroid_xy(&cur_cx, &cur_cy))
return 1;
if(i)
if (i)
{
double sum_area = res_area + cur_area;
res_cx = (res_area * res_cx + cur_area * cur_cx) / sum_area;
......
......@@ -476,22 +476,24 @@ int mysql_create_table(THD *thd,const char *db, const char *table_name,
checking for proper key parts number:
*/
if(key_info->flags == HA_SPATIAL){
if(key_info->key_parts!=1){
if (key_info->flags == HA_SPATIAL)
{
if (key_info->key_parts != 1)
{
my_printf_error(ER_WRONG_ARGUMENTS,
ER(ER_WRONG_ARGUMENTS),MYF(0),"SPATIAL INDEX");
DBUG_RETURN(-1);
}
}else
}
else if (key_info->algorithm == HA_KEY_ALG_RTREE)
{
if ((key_info->key_parts & 1) == 1)
{
if(key_info->algorithm == HA_KEY_ALG_RTREE){
if((key_info->key_parts&1)==1){
my_printf_error(ER_WRONG_ARGUMENTS,
ER(ER_WRONG_ARGUMENTS),MYF(0),"RTREE INDEX");
DBUG_RETURN(-1);
}
}
}
List_iterator<key_part_spec> cols(key->columns);
for (uint column_nr=0 ; (column=cols++) ; column_nr++)
......
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