Commit d319dea8 authored by unknown's avatar unknown

Merge sanja.is.com.ua:/home/bell/mysql/mysql-4.1

into sanja.is.com.ua:/home/bell/mysql/work-explain_union-4.1

parents 05c5908a 9e5a4be4
...@@ -78,10 +78,9 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -78,10 +78,9 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
uint32 u_1,u_2; uint32 u_1,u_2;
float f_1,f_2; float f_1,f_2;
double d_1,d_2; double d_1,d_2;
uint next_key_length;
*diff_pos=0; *diff_pos=0;
for ( ; (int) key_length >0 ; key_length=next_key_length, keyseg++) for ( ; (int) key_length >0 ; keyseg++)
{ {
uchar *end; uchar *end;
uint piks=! (keyseg->flag & HA_NO_SORT); uint piks=! (keyseg->flag & HA_NO_SORT);
...@@ -101,12 +100,10 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -101,12 +100,10 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
{ {
if (nextflag == (SEARCH_FIND | SEARCH_UPDATE)) if (nextflag == (SEARCH_FIND | SEARCH_UPDATE))
nextflag=SEARCH_SAME; /* Allow duplicate keys */ nextflag=SEARCH_SAME; /* Allow duplicate keys */
next_key_length=key_length;
continue; /* To next key part */ continue; /* To next key part */
} }
} }
end= a+ min(keyseg->length,key_length); end= a+ min(keyseg->length,key_length);
next_key_length=key_length-keyseg->length;
switch ((enum ha_base_keytype) keyseg->type) { switch ((enum ha_base_keytype) keyseg->type) {
case HA_KEYTYPE_TEXT: /* Ascii; Key is converted */ case HA_KEYTYPE_TEXT: /* Ascii; Key is converted */
...@@ -115,12 +112,12 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -115,12 +112,12 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
int a_length,b_length,pack_length; int a_length,b_length,pack_length;
get_key_length(a_length,a); get_key_length(a_length,a);
get_key_pack_length(b_length,pack_length,b); get_key_pack_length(b_length,pack_length,b);
next_key_length=key_length-b_length-pack_length; key_length-= b_length + pack_length;
if (piks && if (piks &&
(flag= mi_compare_text(keyseg->charset,a,a_length,b,b_length, (flag= mi_compare_text(keyseg->charset,a,a_length,b,b_length,
(my_bool) ((nextflag & SEARCH_PREFIX) && (my_bool) ((nextflag & SEARCH_PREFIX) &&
next_key_length <= 0)))) key_length <= 0))))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a+=a_length; a+=a_length;
b+=b_length; b+=b_length;
...@@ -129,6 +126,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -129,6 +126,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
else else
{ {
uint length=(uint) (end-a), a_length=length, b_length=length; uint length=(uint) (end-a), a_length=length, b_length=length;
key_length-= keyseg->length;
if (!(nextflag & SEARCH_PREFIX)) if (!(nextflag & SEARCH_PREFIX))
{ {
while (a_length && a[a_length-1] == ' ') while (a_length && a[a_length-1] == ' ')
...@@ -139,7 +137,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -139,7 +137,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
if (piks && if (piks &&
(flag= mi_compare_text(keyseg->charset,a,a_length,b,b_length, (flag= mi_compare_text(keyseg->charset,a,a_length,b,b_length,
(my_bool) ((nextflag & SEARCH_PREFIX) && (my_bool) ((nextflag & SEARCH_PREFIX) &&
next_key_length <= 0)))) key_length <= 0))))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a=end; a=end;
b+=length; b+=length;
...@@ -151,12 +149,12 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -151,12 +149,12 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
int a_length,b_length,pack_length; int a_length,b_length,pack_length;
get_key_length(a_length,a); get_key_length(a_length,a);
get_key_pack_length(b_length,pack_length,b); get_key_pack_length(b_length,pack_length,b);
next_key_length=key_length-b_length-pack_length; key_length-= b_length + pack_length;
if (piks && if (piks &&
(flag=compare_bin(a,a_length,b,b_length, (flag=compare_bin(a,a_length,b,b_length,
(my_bool) ((nextflag & SEARCH_PREFIX) && (my_bool) ((nextflag & SEARCH_PREFIX) &&
next_key_length <= 0)))) key_length <= 0))))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a+=a_length; a+=a_length;
b+=b_length; b+=b_length;
...@@ -165,10 +163,11 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -165,10 +163,11 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
else else
{ {
uint length=keyseg->length; uint length=keyseg->length;
key_length-= keyseg->length;
if (piks && if (piks &&
(flag=compare_bin(a,length,b,length, (flag=compare_bin(a,length,b,length,
(my_bool) ((nextflag & SEARCH_PREFIX) && (my_bool) ((nextflag & SEARCH_PREFIX) &&
next_key_length <= 0)))) key_length <= 0))))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a+=length; a+=length;
b+=length; b+=length;
...@@ -179,12 +178,12 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -179,12 +178,12 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
int a_length,b_length,pack_length; int a_length,b_length,pack_length;
get_key_length(a_length,a); get_key_length(a_length,a);
get_key_pack_length(b_length,pack_length,b); get_key_pack_length(b_length,pack_length,b);
next_key_length=key_length-b_length-pack_length; key_length-= b_length + pack_length;
if (piks && if (piks &&
(flag= mi_compare_text(keyseg->charset,a,a_length,b,b_length, (flag= mi_compare_text(keyseg->charset,a,a_length,b,b_length,
(my_bool) ((nextflag & SEARCH_PREFIX) && (my_bool) ((nextflag & SEARCH_PREFIX) &&
next_key_length <= 0)))) key_length <= 0))))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a+=a_length; a+=a_length;
b+=b_length; b+=b_length;
...@@ -196,12 +195,12 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -196,12 +195,12 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
int a_length,b_length,pack_length; int a_length,b_length,pack_length;
get_key_length(a_length,a); get_key_length(a_length,a);
get_key_pack_length(b_length,pack_length,b); get_key_pack_length(b_length,pack_length,b);
next_key_length=key_length-b_length-pack_length; key_length-= b_length + pack_length;
if (piks && if (piks &&
(flag=compare_bin(a,a_length,b,b_length, (flag=compare_bin(a,a_length,b,b_length,
(my_bool) ((nextflag & SEARCH_PREFIX) && (my_bool) ((nextflag & SEARCH_PREFIX) &&
next_key_length <= 0)))) key_length <= 0))))
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a+=a_length; a+=a_length;
b+=b_length; b+=b_length;
...@@ -216,6 +215,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -216,6 +215,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end; a= end;
b++; b++;
key_length-= keyseg->length;
break; break;
} }
case HA_KEYTYPE_SHORT_INT: case HA_KEYTYPE_SHORT_INT:
...@@ -225,6 +225,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -225,6 +225,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end; a= end;
b+= 2; /* sizeof(short int); */ b+= 2; /* sizeof(short int); */
key_length-= keyseg->length;
break; break;
case HA_KEYTYPE_USHORT_INT: case HA_KEYTYPE_USHORT_INT:
{ {
...@@ -235,6 +236,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -235,6 +236,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end; a= end;
b+=2; /* sizeof(short int); */ b+=2; /* sizeof(short int); */
key_length-= keyseg->length;
break; break;
} }
case HA_KEYTYPE_LONG_INT: case HA_KEYTYPE_LONG_INT:
...@@ -244,6 +246,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -244,6 +246,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end; a= end;
b+= 4; /* sizeof(long int); */ b+= 4; /* sizeof(long int); */
key_length-= keyseg->length;
break; break;
case HA_KEYTYPE_ULONG_INT: case HA_KEYTYPE_ULONG_INT:
u_1= mi_sint4korr(a); u_1= mi_sint4korr(a);
...@@ -252,6 +255,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -252,6 +255,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end; a= end;
b+= 4; /* sizeof(long int); */ b+= 4; /* sizeof(long int); */
key_length-= keyseg->length;
break; break;
case HA_KEYTYPE_INT24: case HA_KEYTYPE_INT24:
l_1=mi_sint3korr(a); l_1=mi_sint3korr(a);
...@@ -260,6 +264,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -260,6 +264,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end; a= end;
b+= 3; b+= 3;
key_length-= keyseg->length;
break; break;
case HA_KEYTYPE_UINT24: case HA_KEYTYPE_UINT24:
l_1=mi_uint3korr(a); l_1=mi_uint3korr(a);
...@@ -268,6 +273,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -268,6 +273,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end; a= end;
b+= 3; b+= 3;
key_length-= keyseg->length;
break; break;
case HA_KEYTYPE_FLOAT: case HA_KEYTYPE_FLOAT:
mi_float4get(f_1,a); mi_float4get(f_1,a);
...@@ -276,6 +282,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -276,6 +282,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end; a= end;
b+= 4; /* sizeof(float); */ b+= 4; /* sizeof(float); */
key_length-= keyseg->length;
break; break;
case HA_KEYTYPE_DOUBLE: case HA_KEYTYPE_DOUBLE:
mi_float8get(d_1,a); mi_float8get(d_1,a);
...@@ -284,6 +291,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -284,6 +291,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end; a= end;
b+= 8; /* sizeof(double); */ b+= 8; /* sizeof(double); */
key_length-= keyseg->length;
break; break;
case HA_KEYTYPE_NUM: /* Numeric key */ case HA_KEYTYPE_NUM: /* Numeric key */
{ {
...@@ -300,7 +308,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -300,7 +308,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
{ {
alength= *a++; blength= *b++; alength= *a++; blength= *b++;
end=a+alength; end=a+alength;
next_key_length=key_length-blength-1; key_length-= blength + 1;
} }
else else
{ {
...@@ -309,6 +317,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -309,6 +317,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
/* remove pre space from keys */ /* remove pre space from keys */
for ( ; alength && *a == ' ' ; a++, alength--) ; for ( ; alength && *a == ' ' ; a++, alength--) ;
for ( ; blength && *b == ' ' ; b++, blength--) ; for ( ; blength && *b == ' ' ; b++, blength--) ;
key_length-= keyseg->length;
} }
if (piks) if (piks)
...@@ -360,6 +369,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -360,6 +369,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end; a= end;
b+= 8; b+= 8;
key_length-= keyseg->length;
break; break;
} }
case HA_KEYTYPE_ULONGLONG: case HA_KEYTYPE_ULONGLONG:
...@@ -371,6 +381,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a, ...@@ -371,6 +381,7 @@ int ha_key_cmp(register HA_KEYSEG *keyseg, register uchar *a,
return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag); return ((keyseg->flag & HA_REVERSE_SORT) ? -flag : flag);
a= end; a= end;
b+= 8; b+= 8;
key_length-= keyseg->length;
break; break;
} }
#endif #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