2006-04-11 15:45:10 +02:00
|
|
|
/* Copyright (C) 2006 MySQL AB & Ramil Kalimullin & MySQL Finland AB
|
|
|
|
& TCX DataKonsult AB
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
2007-03-02 11:20:23 +01:00
|
|
|
the Free Software Foundation; version 2 of the License.
|
2006-04-11 15:45:10 +02:00
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
|
|
|
|
|
|
|
|
#include "maria_def.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_RTREE_KEYS
|
|
|
|
|
|
|
|
#include "ma_rt_index.h"
|
|
|
|
#include "ma_rt_mbr.h"
|
|
|
|
|
|
|
|
#define INTERSECT_CMP(amin, amax, bmin, bmax) ((amin > bmax) || (bmin > amax))
|
|
|
|
#define CONTAIN_CMP(amin, amax, bmin, bmax) ((bmin > amin) || (bmax < amax))
|
|
|
|
#define WITHIN_CMP(amin, amax, bmin, bmax) ((amin > bmin) || (amax < bmax))
|
|
|
|
#define DISJOINT_CMP(amin, amax, bmin, bmax) ((amin <= bmax) && (bmin <= amax))
|
|
|
|
#define EQUAL_CMP(amin, amax, bmin, bmax) ((amin != bmin) || (amax != bmax))
|
|
|
|
|
|
|
|
#define FCMP(A, B) ((int)(A) - (int)(B))
|
|
|
|
#define p_inc(A, B, X) {A += X; B += X;}
|
|
|
|
|
|
|
|
#define RT_CMP(nextflag) \
|
|
|
|
if (nextflag & MBR_INTERSECT) \
|
|
|
|
{ \
|
|
|
|
if (INTERSECT_CMP(amin, amax, bmin, bmax)) \
|
|
|
|
return 1; \
|
|
|
|
} \
|
|
|
|
else if (nextflag & MBR_CONTAIN) \
|
|
|
|
{ \
|
|
|
|
if (CONTAIN_CMP(amin, amax, bmin, bmax)) \
|
|
|
|
return 1; \
|
|
|
|
} \
|
|
|
|
else if (nextflag & MBR_WITHIN) \
|
|
|
|
{ \
|
|
|
|
if (WITHIN_CMP(amin, amax, bmin, bmax)) \
|
|
|
|
return 1; \
|
|
|
|
} \
|
|
|
|
else if (nextflag & MBR_EQUAL) \
|
|
|
|
{ \
|
|
|
|
if (EQUAL_CMP(amin, amax, bmin, bmax)) \
|
|
|
|
return 1; \
|
|
|
|
} \
|
Completion of merge of mysql-5.1 into mysql-maria.
Manually imported changes done to MyISAM (include/myisam.h,
storage/myisam/*, sql/ha_myisam.*, mysql-test/t/myisam.test,
mysql-test/t/ps_2myisam.test) the last
months into Maria (tedious, should do it more frequently in the
future), including those not done at the previous 5.1->Maria merge
(please in the future don't forget to apply MyISAM changes to Maria
when you merge 5.1 into Maria).
Note: I didn't try to import anything which could be MyISAM-related
in other tests of mysql-test (I didn't want to dig in all csets),
but as QA is working to make most tests re-usable for other engines
(Falcon), it is likely that we'll benefit from this and just have
to set engine=Maria somewhere to run those tests on Maria.
func_group and partition tests fail but they already do in main 5.1
on my machine. No Valgrind error in t/*maria*.test.
Monty: please see the commit comment of maria.result and check.
BitKeeper/deleted/.del-ha_maria.m4:
Delete: config/ac-macros/ha_maria.m4
configure.in:
fix for the new way of enabling engines
include/maria.h:
importing changes done to MyISAM the last months into Maria
include/my_handler.h:
importing changes done to MyISAM the last months into Maria
include/myisam.h:
importing changes done to MyISAM the last months into Maria
mysql-test/r/maria.result:
identical to myisam.result, except the engine name in some places
AND in the line testing key_block_size=1000000000000000000:
Maria gives a key block size of 8192 while MyISAM gives 4096;
is it explainable by the difference between MARIA_KEY_BLOCK_LENGTH
and the same constant in MyISAM? Monty?
mysql-test/r/ps_maria.result:
identical to ps_2myisam.result (except the engine name in some places)
mysql-test/t/maria.test:
instead of engine=maria everywhere, I use @@storage_engine (reduces
the diff with myisam.test).
importing changes done to MyISAM the last months into Maria
mysys/my_handler.c:
importing changes done to MyISAM the last months into Maria
sql/ha_maria.cc:
importing changes done to MyISAM the last months into Maria
sql/ha_maria.h:
importing changes done to MyISAM the last months into Maria
sql/mysqld.cc:
unneeded
storage/maria/Makefile.am:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_check.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_create.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_delete_table.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_dynrec.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_extra.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_ft_boolean_search.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_ft_eval.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_ft_nlq_search.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_ft_parser.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_ft_test1.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_ft_update.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_ftdefs.h:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_key.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_open.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_page.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_rkey.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_rsamepos.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_rt_index.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_rt_mbr.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_search.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_sort.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_test1.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_test2.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_test3.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_update.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_write.c:
importing changes done to MyISAM the last months into Maria
storage/maria/maria_chk.c:
importing changes done to MyISAM the last months into Maria
storage/maria/maria_def.h:
importing changes done to MyISAM the last months into Maria
storage/maria/maria_ftdump.c:
importing changes done to MyISAM the last months into Maria
storage/maria/maria_pack.c:
importing changes done to MyISAM the last months into Maria
2006-08-10 16:36:54 +02:00
|
|
|
else if (nextflag & MBR_DISJOINT) \
|
2006-04-11 15:45:10 +02:00
|
|
|
{ \
|
|
|
|
if (DISJOINT_CMP(amin, amax, bmin, bmax)) \
|
|
|
|
return 1; \
|
Completion of merge of mysql-5.1 into mysql-maria.
Manually imported changes done to MyISAM (include/myisam.h,
storage/myisam/*, sql/ha_myisam.*, mysql-test/t/myisam.test,
mysql-test/t/ps_2myisam.test) the last
months into Maria (tedious, should do it more frequently in the
future), including those not done at the previous 5.1->Maria merge
(please in the future don't forget to apply MyISAM changes to Maria
when you merge 5.1 into Maria).
Note: I didn't try to import anything which could be MyISAM-related
in other tests of mysql-test (I didn't want to dig in all csets),
but as QA is working to make most tests re-usable for other engines
(Falcon), it is likely that we'll benefit from this and just have
to set engine=Maria somewhere to run those tests on Maria.
func_group and partition tests fail but they already do in main 5.1
on my machine. No Valgrind error in t/*maria*.test.
Monty: please see the commit comment of maria.result and check.
BitKeeper/deleted/.del-ha_maria.m4:
Delete: config/ac-macros/ha_maria.m4
configure.in:
fix for the new way of enabling engines
include/maria.h:
importing changes done to MyISAM the last months into Maria
include/my_handler.h:
importing changes done to MyISAM the last months into Maria
include/myisam.h:
importing changes done to MyISAM the last months into Maria
mysql-test/r/maria.result:
identical to myisam.result, except the engine name in some places
AND in the line testing key_block_size=1000000000000000000:
Maria gives a key block size of 8192 while MyISAM gives 4096;
is it explainable by the difference between MARIA_KEY_BLOCK_LENGTH
and the same constant in MyISAM? Monty?
mysql-test/r/ps_maria.result:
identical to ps_2myisam.result (except the engine name in some places)
mysql-test/t/maria.test:
instead of engine=maria everywhere, I use @@storage_engine (reduces
the diff with myisam.test).
importing changes done to MyISAM the last months into Maria
mysys/my_handler.c:
importing changes done to MyISAM the last months into Maria
sql/ha_maria.cc:
importing changes done to MyISAM the last months into Maria
sql/ha_maria.h:
importing changes done to MyISAM the last months into Maria
sql/mysqld.cc:
unneeded
storage/maria/Makefile.am:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_check.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_create.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_delete_table.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_dynrec.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_extra.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_ft_boolean_search.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_ft_eval.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_ft_nlq_search.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_ft_parser.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_ft_test1.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_ft_update.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_ftdefs.h:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_key.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_open.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_page.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_rkey.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_rsamepos.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_rt_index.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_rt_mbr.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_search.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_sort.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_test1.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_test2.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_test3.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_update.c:
importing changes done to MyISAM the last months into Maria
storage/maria/ma_write.c:
importing changes done to MyISAM the last months into Maria
storage/maria/maria_chk.c:
importing changes done to MyISAM the last months into Maria
storage/maria/maria_def.h:
importing changes done to MyISAM the last months into Maria
storage/maria/maria_ftdump.c:
importing changes done to MyISAM the last months into Maria
storage/maria/maria_pack.c:
importing changes done to MyISAM the last months into Maria
2006-08-10 16:36:54 +02:00
|
|
|
}\
|
|
|
|
else /* if unknown comparison operator */ \
|
|
|
|
{ \
|
|
|
|
DBUG_ASSERT(0); \
|
2006-04-11 15:45:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#define RT_CMP_KORR(type, korr_func, len, nextflag) \
|
|
|
|
{ \
|
|
|
|
type amin, amax, bmin, bmax; \
|
2007-10-09 20:09:50 +02:00
|
|
|
amin= korr_func(a); \
|
|
|
|
bmin= korr_func(b); \
|
|
|
|
amax= korr_func(a+len); \
|
|
|
|
bmax= korr_func(b+len); \
|
2006-04-11 15:45:10 +02:00
|
|
|
RT_CMP(nextflag); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RT_CMP_GET(type, get_func, len, nextflag) \
|
|
|
|
{ \
|
|
|
|
type amin, amax, bmin, bmax; \
|
|
|
|
get_func(amin, a); \
|
|
|
|
get_func(bmin, b); \
|
|
|
|
get_func(amax, a+len); \
|
|
|
|
get_func(bmax, b+len); \
|
|
|
|
RT_CMP(nextflag); \
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Compares two keys a and b depending on nextflag
|
|
|
|
nextflag can contain these flags:
|
|
|
|
MBR_INTERSECT(a,b) a overlaps b
|
|
|
|
MBR_CONTAIN(a,b) a contains b
|
|
|
|
MBR_DISJOINT(a,b) a disjoint b
|
|
|
|
MBR_WITHIN(a,b) a within b
|
|
|
|
MBR_EQUAL(a,b) All coordinates of MBRs are equal
|
|
|
|
MBR_DATA(a,b) Data reference is the same
|
|
|
|
Returns 0 on success.
|
|
|
|
*/
|
2007-01-18 20:38:14 +01:00
|
|
|
|
Injecting more "const" declarations into code which does not change
pointed data.
I ran gcc -Wcast-qual on storage/maria, this identified un-needed casts,
a couple of functions which said they had a const parameter though
they changed the pointed content! This is fixed here. Some suspicious
places receive a comment.
The original intention of running -Wcast-qual was to find what code
changes R-tree keys: I added const words, but hidden casts
like those of int2store (casts target to (uint16*)) removed const
checking; -Wcast-qual helped find those hidden casts.
Log handler does not change the content pointed by LEX_STRING::str it
receives, so we now use a struct which has a const inside, to emphasize
this and be able to pass "const uchar*" buffers to log handler
without fear of their content being changed by it.
One-line fix for a merge glitch (when merging from MyISAM).
include/m_string.h:
As Maria's log handler uses LEX_STRING but never changes the content
pointed by LEX_STRING::str, and assigns uchar* into this member most
of the time, we introduce a new struct LEX_CUSTRING
(C const U unsigned) for the log handler.
include/my_global.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
include/my_handler.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
ha_find_null() does not change *a.
include/my_sys.h:
insert_dynamic() does not change *element.
include/myisampack.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
mysys/array.c:
insert_dynamic() does not change *element
mysys/my_handler.c:
ha_find_null() does not change *a
storage/maria/ma_bitmap.c:
Log handler receives const strings now
storage/maria/ma_blockrec.c:
Log handler receives const strings now.
_ma_apply_undo_row_delete/update() do change *header.
storage/maria/ma_blockrec.h:
correct prototype
storage/maria/ma_check.c:
Log handler receives const strings now. Un-needed casts
storage/maria/ma_checkpoint.c:
Log handler receives const strings now
storage/maria/ma_checksum.c:
unneeded cast
storage/maria/ma_commit.c:
Log handler receives const strings now
storage/maria/ma_create.c:
Log handler receives const strings now
storage/maria/ma_dbug.c:
fixing warning of gcc -Wcast-qual
storage/maria/ma_delete.c:
Log handler receives const strings now
storage/maria/ma_delete_all.c:
Log handler receives const strings now
storage/maria/ma_delete_table.c:
Log handler receives const strings now
storage/maria/ma_dynrec.c:
fixing some warnings of gcc -Wcast-qual. Unneeded casts removed.
Comment about function which lies.
storage/maria/ma_ft_parser.c:
fix for warnings of gcc -Wcast-qual, removing unneeded casts
storage/maria/ma_ft_update.c:
less casts, comment
storage/maria/ma_key.c:
less casts, stay const (warnings of gcc -Wcast-qual)
storage/maria/ma_key_recover.c:
Log handler receives const strings now
storage/maria/ma_loghandler.c:
Log handler receives const strings now
storage/maria/ma_loghandler.h:
Log handler receives const strings now
storage/maria/ma_loghandler_lsn.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
storage/maria/ma_page.c:
Log handler receives const strings now; more const
storage/maria/ma_recovery.c:
Log handler receives const strings now
storage/maria/ma_rename.c:
Log handler receives const strings now
storage/maria/ma_rt_index.c:
more const, to emphasize that functions don't change pointed content.
best_key= NULL was forgotten during merge from MyISAM a few days ago,
was causing a Valgrind warning
storage/maria/ma_rt_index.h:
new proto
storage/maria/ma_rt_key.c:
more const
storage/maria/ma_rt_key.h:
new proto
storage/maria/ma_rt_mbr.c:
more const for functions which deserve it
storage/maria/ma_rt_mbr.h:
new prototype
storage/maria/ma_rt_split.c:
make const what is not changed.
storage/maria/ma_search.c:
un-needed casts, more const
storage/maria/ma_sp_key.c:
more const
storage/maria/ma_unique.c:
un-needed casts.
storage/maria/ma_write.c:
Log handler receives const strings now
storage/maria/maria_def.h:
some more const
storage/maria/unittest/ma_test_loghandler-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_nologs-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_purge-t.c:
Log handler receives const strings now
2008-04-03 15:40:25 +02:00
|
|
|
int maria_rtree_key_cmp(HA_KEYSEG *keyseg, const uchar *b, const uchar *a,
|
|
|
|
uint key_length, uint nextflag)
|
2006-04-11 15:45:10 +02:00
|
|
|
{
|
|
|
|
for (; (int) key_length > 0; keyseg += 2 )
|
|
|
|
{
|
|
|
|
uint32 keyseg_length;
|
|
|
|
switch ((enum ha_base_keytype) keyseg->type) {
|
|
|
|
case HA_KEYTYPE_INT8:
|
|
|
|
RT_CMP_KORR(int8, mi_sint1korr, 1, nextflag);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_BINARY:
|
|
|
|
RT_CMP_KORR(uint8, mi_uint1korr, 1, nextflag);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_SHORT_INT:
|
|
|
|
RT_CMP_KORR(int16, mi_sint2korr, 2, nextflag);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_USHORT_INT:
|
|
|
|
RT_CMP_KORR(uint16, mi_uint2korr, 2, nextflag);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_INT24:
|
|
|
|
RT_CMP_KORR(int32, mi_sint3korr, 3, nextflag);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_UINT24:
|
|
|
|
RT_CMP_KORR(uint32, mi_uint3korr, 3, nextflag);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_LONG_INT:
|
|
|
|
RT_CMP_KORR(int32, mi_sint4korr, 4, nextflag);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_ULONG_INT:
|
|
|
|
RT_CMP_KORR(uint32, mi_uint4korr, 4, nextflag);
|
|
|
|
break;
|
|
|
|
#ifdef HAVE_LONG_LONG
|
|
|
|
case HA_KEYTYPE_LONGLONG:
|
|
|
|
RT_CMP_KORR(longlong, mi_sint8korr, 8, nextflag)
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_ULONGLONG:
|
|
|
|
RT_CMP_KORR(ulonglong, mi_uint8korr, 8, nextflag)
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case HA_KEYTYPE_FLOAT:
|
|
|
|
/* The following should be safe, even if we compare doubles */
|
|
|
|
RT_CMP_GET(float, mi_float4get, 4, nextflag);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_DOUBLE:
|
|
|
|
RT_CMP_GET(double, mi_float8get, 8, nextflag);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_END:
|
|
|
|
goto end;
|
|
|
|
default:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
keyseg_length= keyseg->length * 2;
|
|
|
|
key_length-= keyseg_length;
|
|
|
|
a+= keyseg_length;
|
|
|
|
b+= keyseg_length;
|
|
|
|
}
|
|
|
|
|
|
|
|
end:
|
|
|
|
if (nextflag & MBR_DATA)
|
|
|
|
{
|
Injecting more "const" declarations into code which does not change
pointed data.
I ran gcc -Wcast-qual on storage/maria, this identified un-needed casts,
a couple of functions which said they had a const parameter though
they changed the pointed content! This is fixed here. Some suspicious
places receive a comment.
The original intention of running -Wcast-qual was to find what code
changes R-tree keys: I added const words, but hidden casts
like those of int2store (casts target to (uint16*)) removed const
checking; -Wcast-qual helped find those hidden casts.
Log handler does not change the content pointed by LEX_STRING::str it
receives, so we now use a struct which has a const inside, to emphasize
this and be able to pass "const uchar*" buffers to log handler
without fear of their content being changed by it.
One-line fix for a merge glitch (when merging from MyISAM).
include/m_string.h:
As Maria's log handler uses LEX_STRING but never changes the content
pointed by LEX_STRING::str, and assigns uchar* into this member most
of the time, we introduce a new struct LEX_CUSTRING
(C const U unsigned) for the log handler.
include/my_global.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
include/my_handler.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
ha_find_null() does not change *a.
include/my_sys.h:
insert_dynamic() does not change *element.
include/myisampack.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
mysys/array.c:
insert_dynamic() does not change *element
mysys/my_handler.c:
ha_find_null() does not change *a
storage/maria/ma_bitmap.c:
Log handler receives const strings now
storage/maria/ma_blockrec.c:
Log handler receives const strings now.
_ma_apply_undo_row_delete/update() do change *header.
storage/maria/ma_blockrec.h:
correct prototype
storage/maria/ma_check.c:
Log handler receives const strings now. Un-needed casts
storage/maria/ma_checkpoint.c:
Log handler receives const strings now
storage/maria/ma_checksum.c:
unneeded cast
storage/maria/ma_commit.c:
Log handler receives const strings now
storage/maria/ma_create.c:
Log handler receives const strings now
storage/maria/ma_dbug.c:
fixing warning of gcc -Wcast-qual
storage/maria/ma_delete.c:
Log handler receives const strings now
storage/maria/ma_delete_all.c:
Log handler receives const strings now
storage/maria/ma_delete_table.c:
Log handler receives const strings now
storage/maria/ma_dynrec.c:
fixing some warnings of gcc -Wcast-qual. Unneeded casts removed.
Comment about function which lies.
storage/maria/ma_ft_parser.c:
fix for warnings of gcc -Wcast-qual, removing unneeded casts
storage/maria/ma_ft_update.c:
less casts, comment
storage/maria/ma_key.c:
less casts, stay const (warnings of gcc -Wcast-qual)
storage/maria/ma_key_recover.c:
Log handler receives const strings now
storage/maria/ma_loghandler.c:
Log handler receives const strings now
storage/maria/ma_loghandler.h:
Log handler receives const strings now
storage/maria/ma_loghandler_lsn.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
storage/maria/ma_page.c:
Log handler receives const strings now; more const
storage/maria/ma_recovery.c:
Log handler receives const strings now
storage/maria/ma_rename.c:
Log handler receives const strings now
storage/maria/ma_rt_index.c:
more const, to emphasize that functions don't change pointed content.
best_key= NULL was forgotten during merge from MyISAM a few days ago,
was causing a Valgrind warning
storage/maria/ma_rt_index.h:
new proto
storage/maria/ma_rt_key.c:
more const
storage/maria/ma_rt_key.h:
new proto
storage/maria/ma_rt_mbr.c:
more const for functions which deserve it
storage/maria/ma_rt_mbr.h:
new prototype
storage/maria/ma_rt_split.c:
make const what is not changed.
storage/maria/ma_search.c:
un-needed casts, more const
storage/maria/ma_sp_key.c:
more const
storage/maria/ma_unique.c:
un-needed casts.
storage/maria/ma_write.c:
Log handler receives const strings now
storage/maria/maria_def.h:
some more const
storage/maria/unittest/ma_test_loghandler-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_nologs-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_purge-t.c:
Log handler receives const strings now
2008-04-03 15:40:25 +02:00
|
|
|
const uchar *end= a + keyseg->length;
|
2006-04-11 15:45:10 +02:00
|
|
|
do
|
|
|
|
{
|
|
|
|
if (*a++ != *b++)
|
|
|
|
return FCMP(a[-1], b[-1]);
|
|
|
|
} while (a != end);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RT_VOL_KORR(type, korr_func, len, cast) \
|
|
|
|
{ \
|
|
|
|
type amin, amax; \
|
2007-10-09 20:09:50 +02:00
|
|
|
amin= korr_func(a); \
|
|
|
|
amax= korr_func(a+len); \
|
2006-04-11 15:45:10 +02:00
|
|
|
res *= (cast(amax) - cast(amin)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RT_VOL_GET(type, get_func, len, cast) \
|
|
|
|
{ \
|
|
|
|
type amin, amax; \
|
|
|
|
get_func(amin, a); \
|
|
|
|
get_func(amax, a+len); \
|
|
|
|
res *= (cast(amax) - cast(amin)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Calculates rectangle volume
|
|
|
|
*/
|
2007-07-02 19:45:15 +02:00
|
|
|
double maria_rtree_rect_volume(HA_KEYSEG *keyseg, uchar *a, uint key_length)
|
2006-04-11 15:45:10 +02:00
|
|
|
{
|
2007-10-09 20:09:50 +02:00
|
|
|
double res= 1;
|
2006-04-11 15:45:10 +02:00
|
|
|
for (; (int)key_length > 0; keyseg += 2)
|
|
|
|
{
|
|
|
|
uint32 keyseg_length;
|
|
|
|
switch ((enum ha_base_keytype) keyseg->type) {
|
|
|
|
case HA_KEYTYPE_INT8:
|
|
|
|
RT_VOL_KORR(int8, mi_sint1korr, 1, (double));
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_BINARY:
|
|
|
|
RT_VOL_KORR(uint8, mi_uint1korr, 1, (double));
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_SHORT_INT:
|
|
|
|
RT_VOL_KORR(int16, mi_sint2korr, 2, (double));
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_USHORT_INT:
|
|
|
|
RT_VOL_KORR(uint16, mi_uint2korr, 2, (double));
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_INT24:
|
|
|
|
RT_VOL_KORR(int32, mi_sint3korr, 3, (double));
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_UINT24:
|
|
|
|
RT_VOL_KORR(uint32, mi_uint3korr, 3, (double));
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_LONG_INT:
|
|
|
|
RT_VOL_KORR(int32, mi_sint4korr, 4, (double));
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_ULONG_INT:
|
|
|
|
RT_VOL_KORR(uint32, mi_uint4korr, 4, (double));
|
|
|
|
break;
|
|
|
|
#ifdef HAVE_LONG_LONG
|
|
|
|
case HA_KEYTYPE_LONGLONG:
|
|
|
|
RT_VOL_KORR(longlong, mi_sint8korr, 8, (double));
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_ULONGLONG:
|
|
|
|
RT_VOL_KORR(longlong, mi_sint8korr, 8, ulonglong2double);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case HA_KEYTYPE_FLOAT:
|
|
|
|
RT_VOL_GET(float, mi_float4get, 4, (double));
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_DOUBLE:
|
|
|
|
RT_VOL_GET(double, mi_float8get, 8, (double));
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_END:
|
2007-10-09 20:09:50 +02:00
|
|
|
key_length= 0;
|
2006-04-11 15:45:10 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
keyseg_length= keyseg->length * 2;
|
|
|
|
key_length-= keyseg_length;
|
|
|
|
a+= keyseg_length;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RT_D_MBR_KORR(type, korr_func, len, cast) \
|
|
|
|
{ \
|
|
|
|
type amin, amax; \
|
2007-10-09 20:09:50 +02:00
|
|
|
amin= korr_func(a); \
|
|
|
|
amax= korr_func(a+len); \
|
|
|
|
*res++= cast(amin); \
|
|
|
|
*res++= cast(amax); \
|
2006-04-11 15:45:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
#define RT_D_MBR_GET(type, get_func, len, cast) \
|
|
|
|
{ \
|
|
|
|
type amin, amax; \
|
|
|
|
get_func(amin, a); \
|
|
|
|
get_func(amax, a+len); \
|
2007-10-09 20:09:50 +02:00
|
|
|
*res++= cast(amin); \
|
|
|
|
*res++= cast(amax); \
|
2006-04-11 15:45:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
Creates an MBR as an array of doubles.
|
|
|
|
*/
|
|
|
|
|
Injecting more "const" declarations into code which does not change
pointed data.
I ran gcc -Wcast-qual on storage/maria, this identified un-needed casts,
a couple of functions which said they had a const parameter though
they changed the pointed content! This is fixed here. Some suspicious
places receive a comment.
The original intention of running -Wcast-qual was to find what code
changes R-tree keys: I added const words, but hidden casts
like those of int2store (casts target to (uint16*)) removed const
checking; -Wcast-qual helped find those hidden casts.
Log handler does not change the content pointed by LEX_STRING::str it
receives, so we now use a struct which has a const inside, to emphasize
this and be able to pass "const uchar*" buffers to log handler
without fear of their content being changed by it.
One-line fix for a merge glitch (when merging from MyISAM).
include/m_string.h:
As Maria's log handler uses LEX_STRING but never changes the content
pointed by LEX_STRING::str, and assigns uchar* into this member most
of the time, we introduce a new struct LEX_CUSTRING
(C const U unsigned) for the log handler.
include/my_global.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
include/my_handler.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
ha_find_null() does not change *a.
include/my_sys.h:
insert_dynamic() does not change *element.
include/myisampack.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
mysys/array.c:
insert_dynamic() does not change *element
mysys/my_handler.c:
ha_find_null() does not change *a
storage/maria/ma_bitmap.c:
Log handler receives const strings now
storage/maria/ma_blockrec.c:
Log handler receives const strings now.
_ma_apply_undo_row_delete/update() do change *header.
storage/maria/ma_blockrec.h:
correct prototype
storage/maria/ma_check.c:
Log handler receives const strings now. Un-needed casts
storage/maria/ma_checkpoint.c:
Log handler receives const strings now
storage/maria/ma_checksum.c:
unneeded cast
storage/maria/ma_commit.c:
Log handler receives const strings now
storage/maria/ma_create.c:
Log handler receives const strings now
storage/maria/ma_dbug.c:
fixing warning of gcc -Wcast-qual
storage/maria/ma_delete.c:
Log handler receives const strings now
storage/maria/ma_delete_all.c:
Log handler receives const strings now
storage/maria/ma_delete_table.c:
Log handler receives const strings now
storage/maria/ma_dynrec.c:
fixing some warnings of gcc -Wcast-qual. Unneeded casts removed.
Comment about function which lies.
storage/maria/ma_ft_parser.c:
fix for warnings of gcc -Wcast-qual, removing unneeded casts
storage/maria/ma_ft_update.c:
less casts, comment
storage/maria/ma_key.c:
less casts, stay const (warnings of gcc -Wcast-qual)
storage/maria/ma_key_recover.c:
Log handler receives const strings now
storage/maria/ma_loghandler.c:
Log handler receives const strings now
storage/maria/ma_loghandler.h:
Log handler receives const strings now
storage/maria/ma_loghandler_lsn.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
storage/maria/ma_page.c:
Log handler receives const strings now; more const
storage/maria/ma_recovery.c:
Log handler receives const strings now
storage/maria/ma_rename.c:
Log handler receives const strings now
storage/maria/ma_rt_index.c:
more const, to emphasize that functions don't change pointed content.
best_key= NULL was forgotten during merge from MyISAM a few days ago,
was causing a Valgrind warning
storage/maria/ma_rt_index.h:
new proto
storage/maria/ma_rt_key.c:
more const
storage/maria/ma_rt_key.h:
new proto
storage/maria/ma_rt_mbr.c:
more const for functions which deserve it
storage/maria/ma_rt_mbr.h:
new prototype
storage/maria/ma_rt_split.c:
make const what is not changed.
storage/maria/ma_search.c:
un-needed casts, more const
storage/maria/ma_sp_key.c:
more const
storage/maria/ma_unique.c:
un-needed casts.
storage/maria/ma_write.c:
Log handler receives const strings now
storage/maria/maria_def.h:
some more const
storage/maria/unittest/ma_test_loghandler-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_nologs-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_purge-t.c:
Log handler receives const strings now
2008-04-03 15:40:25 +02:00
|
|
|
int maria_rtree_d_mbr(const HA_KEYSEG *keyseg, const uchar *a,
|
|
|
|
uint key_length, double *res)
|
2006-04-11 15:45:10 +02:00
|
|
|
{
|
|
|
|
for (; (int)key_length > 0; keyseg += 2)
|
|
|
|
{
|
|
|
|
uint32 keyseg_length;
|
|
|
|
switch ((enum ha_base_keytype) keyseg->type) {
|
|
|
|
case HA_KEYTYPE_INT8:
|
|
|
|
RT_D_MBR_KORR(int8, mi_sint1korr, 1, (double));
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_BINARY:
|
|
|
|
RT_D_MBR_KORR(uint8, mi_uint1korr, 1, (double));
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_SHORT_INT:
|
|
|
|
RT_D_MBR_KORR(int16, mi_sint2korr, 2, (double));
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_USHORT_INT:
|
|
|
|
RT_D_MBR_KORR(uint16, mi_uint2korr, 2, (double));
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_INT24:
|
|
|
|
RT_D_MBR_KORR(int32, mi_sint3korr, 3, (double));
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_UINT24:
|
|
|
|
RT_D_MBR_KORR(uint32, mi_uint3korr, 3, (double));
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_LONG_INT:
|
|
|
|
RT_D_MBR_KORR(int32, mi_sint4korr, 4, (double));
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_ULONG_INT:
|
|
|
|
RT_D_MBR_KORR(uint32, mi_uint4korr, 4, (double));
|
|
|
|
break;
|
|
|
|
#ifdef HAVE_LONG_LONG
|
|
|
|
case HA_KEYTYPE_LONGLONG:
|
|
|
|
RT_D_MBR_KORR(longlong, mi_sint8korr, 8, (double));
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_ULONGLONG:
|
|
|
|
RT_D_MBR_KORR(longlong, mi_sint8korr, 8, ulonglong2double);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case HA_KEYTYPE_FLOAT:
|
|
|
|
RT_D_MBR_GET(float, mi_float4get, 4, (double));
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_DOUBLE:
|
|
|
|
RT_D_MBR_GET(double, mi_float8get, 8, (double));
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_END:
|
2007-10-09 20:09:50 +02:00
|
|
|
key_length= 0;
|
2006-04-11 15:45:10 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
keyseg_length= keyseg->length * 2;
|
|
|
|
key_length-= keyseg_length;
|
|
|
|
a+= keyseg_length;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RT_COMB_KORR(type, korr_func, store_func, len) \
|
|
|
|
{ \
|
|
|
|
type amin, amax, bmin, bmax; \
|
2007-10-09 20:09:50 +02:00
|
|
|
amin= korr_func(a); \
|
|
|
|
bmin= korr_func(b); \
|
|
|
|
amax= korr_func(a+len); \
|
|
|
|
bmax= korr_func(b+len); \
|
|
|
|
amin= min(amin, bmin); \
|
|
|
|
amax= max(amax, bmax); \
|
2006-04-11 15:45:10 +02:00
|
|
|
store_func(c, amin); \
|
|
|
|
store_func(c+len, amax); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RT_COMB_GET(type, get_func, store_func, len) \
|
|
|
|
{ \
|
|
|
|
type amin, amax, bmin, bmax; \
|
|
|
|
get_func(amin, a); \
|
|
|
|
get_func(bmin, b); \
|
|
|
|
get_func(amax, a+len); \
|
|
|
|
get_func(bmax, b+len); \
|
2007-10-09 20:09:50 +02:00
|
|
|
amin= min(amin, bmin); \
|
|
|
|
amax= max(amax, bmax); \
|
2006-04-11 15:45:10 +02:00
|
|
|
store_func(c, amin); \
|
|
|
|
store_func(c+len, amax); \
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Creates common minimal bounding rectungle
|
|
|
|
for two input rectagnles a and b
|
|
|
|
Result is written to c
|
|
|
|
*/
|
|
|
|
|
Injecting more "const" declarations into code which does not change
pointed data.
I ran gcc -Wcast-qual on storage/maria, this identified un-needed casts,
a couple of functions which said they had a const parameter though
they changed the pointed content! This is fixed here. Some suspicious
places receive a comment.
The original intention of running -Wcast-qual was to find what code
changes R-tree keys: I added const words, but hidden casts
like those of int2store (casts target to (uint16*)) removed const
checking; -Wcast-qual helped find those hidden casts.
Log handler does not change the content pointed by LEX_STRING::str it
receives, so we now use a struct which has a const inside, to emphasize
this and be able to pass "const uchar*" buffers to log handler
without fear of their content being changed by it.
One-line fix for a merge glitch (when merging from MyISAM).
include/m_string.h:
As Maria's log handler uses LEX_STRING but never changes the content
pointed by LEX_STRING::str, and assigns uchar* into this member most
of the time, we introduce a new struct LEX_CUSTRING
(C const U unsigned) for the log handler.
include/my_global.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
include/my_handler.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
ha_find_null() does not change *a.
include/my_sys.h:
insert_dynamic() does not change *element.
include/myisampack.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
mysys/array.c:
insert_dynamic() does not change *element
mysys/my_handler.c:
ha_find_null() does not change *a
storage/maria/ma_bitmap.c:
Log handler receives const strings now
storage/maria/ma_blockrec.c:
Log handler receives const strings now.
_ma_apply_undo_row_delete/update() do change *header.
storage/maria/ma_blockrec.h:
correct prototype
storage/maria/ma_check.c:
Log handler receives const strings now. Un-needed casts
storage/maria/ma_checkpoint.c:
Log handler receives const strings now
storage/maria/ma_checksum.c:
unneeded cast
storage/maria/ma_commit.c:
Log handler receives const strings now
storage/maria/ma_create.c:
Log handler receives const strings now
storage/maria/ma_dbug.c:
fixing warning of gcc -Wcast-qual
storage/maria/ma_delete.c:
Log handler receives const strings now
storage/maria/ma_delete_all.c:
Log handler receives const strings now
storage/maria/ma_delete_table.c:
Log handler receives const strings now
storage/maria/ma_dynrec.c:
fixing some warnings of gcc -Wcast-qual. Unneeded casts removed.
Comment about function which lies.
storage/maria/ma_ft_parser.c:
fix for warnings of gcc -Wcast-qual, removing unneeded casts
storage/maria/ma_ft_update.c:
less casts, comment
storage/maria/ma_key.c:
less casts, stay const (warnings of gcc -Wcast-qual)
storage/maria/ma_key_recover.c:
Log handler receives const strings now
storage/maria/ma_loghandler.c:
Log handler receives const strings now
storage/maria/ma_loghandler.h:
Log handler receives const strings now
storage/maria/ma_loghandler_lsn.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
storage/maria/ma_page.c:
Log handler receives const strings now; more const
storage/maria/ma_recovery.c:
Log handler receives const strings now
storage/maria/ma_rename.c:
Log handler receives const strings now
storage/maria/ma_rt_index.c:
more const, to emphasize that functions don't change pointed content.
best_key= NULL was forgotten during merge from MyISAM a few days ago,
was causing a Valgrind warning
storage/maria/ma_rt_index.h:
new proto
storage/maria/ma_rt_key.c:
more const
storage/maria/ma_rt_key.h:
new proto
storage/maria/ma_rt_mbr.c:
more const for functions which deserve it
storage/maria/ma_rt_mbr.h:
new prototype
storage/maria/ma_rt_split.c:
make const what is not changed.
storage/maria/ma_search.c:
un-needed casts, more const
storage/maria/ma_sp_key.c:
more const
storage/maria/ma_unique.c:
un-needed casts.
storage/maria/ma_write.c:
Log handler receives const strings now
storage/maria/maria_def.h:
some more const
storage/maria/unittest/ma_test_loghandler-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_nologs-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_purge-t.c:
Log handler receives const strings now
2008-04-03 15:40:25 +02:00
|
|
|
int maria_rtree_combine_rect(const HA_KEYSEG *keyseg, const uchar* a,
|
|
|
|
const uchar* b, uchar* c,
|
|
|
|
uint key_length)
|
2006-04-11 15:45:10 +02:00
|
|
|
{
|
|
|
|
for ( ; (int) key_length > 0 ; keyseg += 2)
|
|
|
|
{
|
|
|
|
uint32 keyseg_length;
|
|
|
|
switch ((enum ha_base_keytype) keyseg->type) {
|
|
|
|
case HA_KEYTYPE_INT8:
|
|
|
|
RT_COMB_KORR(int8, mi_sint1korr, mi_int1store, 1);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_BINARY:
|
|
|
|
RT_COMB_KORR(uint8, mi_uint1korr, mi_int1store, 1);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_SHORT_INT:
|
|
|
|
RT_COMB_KORR(int16, mi_sint2korr, mi_int2store, 2);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_USHORT_INT:
|
|
|
|
RT_COMB_KORR(uint16, mi_uint2korr, mi_int2store, 2);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_INT24:
|
|
|
|
RT_COMB_KORR(int32, mi_sint3korr, mi_int3store, 3);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_UINT24:
|
|
|
|
RT_COMB_KORR(uint32, mi_uint3korr, mi_int3store, 3);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_LONG_INT:
|
|
|
|
RT_COMB_KORR(int32, mi_sint4korr, mi_int4store, 4);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_ULONG_INT:
|
|
|
|
RT_COMB_KORR(uint32, mi_uint4korr, mi_int4store, 4);
|
|
|
|
break;
|
|
|
|
#ifdef HAVE_LONG_LONG
|
|
|
|
case HA_KEYTYPE_LONGLONG:
|
|
|
|
RT_COMB_KORR(longlong, mi_sint8korr, mi_int8store, 8);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_ULONGLONG:
|
|
|
|
RT_COMB_KORR(ulonglong, mi_uint8korr, mi_int8store, 8);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case HA_KEYTYPE_FLOAT:
|
|
|
|
RT_COMB_GET(float, mi_float4get, mi_float4store, 4);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_DOUBLE:
|
|
|
|
RT_COMB_GET(double, mi_float8get, mi_float8store, 8);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_END:
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
keyseg_length= keyseg->length * 2;
|
|
|
|
key_length-= keyseg_length;
|
|
|
|
a+= keyseg_length;
|
|
|
|
b+= keyseg_length;
|
|
|
|
c+= keyseg_length;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define RT_OVL_AREA_KORR(type, korr_func, len) \
|
|
|
|
{ \
|
|
|
|
type amin, amax, bmin, bmax; \
|
2007-10-09 20:09:50 +02:00
|
|
|
amin= korr_func(a); \
|
|
|
|
bmin= korr_func(b); \
|
|
|
|
amax= korr_func(a+len); \
|
|
|
|
bmax= korr_func(b+len); \
|
|
|
|
amin= max(amin, bmin); \
|
|
|
|
amax= min(amax, bmax); \
|
2006-04-11 15:45:10 +02:00
|
|
|
if (amin >= amax) \
|
|
|
|
return 0; \
|
|
|
|
res *= amax - amin; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RT_OVL_AREA_GET(type, get_func, len) \
|
|
|
|
{ \
|
|
|
|
type amin, amax, bmin, bmax; \
|
|
|
|
get_func(amin, a); \
|
|
|
|
get_func(bmin, b); \
|
|
|
|
get_func(amax, a+len); \
|
|
|
|
get_func(bmax, b+len); \
|
2007-10-09 20:09:50 +02:00
|
|
|
amin= max(amin, bmin); \
|
|
|
|
amax= min(amax, bmax); \
|
2006-04-11 15:45:10 +02:00
|
|
|
if (amin >= amax) \
|
|
|
|
return 0; \
|
|
|
|
res *= amax - amin; \
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Calculates overlapping area of two MBRs a & b
|
|
|
|
*/
|
2007-07-02 19:45:15 +02:00
|
|
|
double maria_rtree_overlapping_area(HA_KEYSEG *keyseg, uchar* a, uchar* b,
|
2006-04-11 15:45:10 +02:00
|
|
|
uint key_length)
|
|
|
|
{
|
2007-10-09 20:09:50 +02:00
|
|
|
double res= 1;
|
2006-04-11 15:45:10 +02:00
|
|
|
for (; (int) key_length > 0 ; keyseg += 2)
|
|
|
|
{
|
|
|
|
uint32 keyseg_length;
|
|
|
|
switch ((enum ha_base_keytype) keyseg->type) {
|
|
|
|
case HA_KEYTYPE_INT8:
|
|
|
|
RT_OVL_AREA_KORR(int8, mi_sint1korr, 1);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_BINARY:
|
|
|
|
RT_OVL_AREA_KORR(uint8, mi_uint1korr, 1);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_SHORT_INT:
|
|
|
|
RT_OVL_AREA_KORR(int16, mi_sint2korr, 2);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_USHORT_INT:
|
|
|
|
RT_OVL_AREA_KORR(uint16, mi_uint2korr, 2);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_INT24:
|
|
|
|
RT_OVL_AREA_KORR(int32, mi_sint3korr, 3);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_UINT24:
|
|
|
|
RT_OVL_AREA_KORR(uint32, mi_uint3korr, 3);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_LONG_INT:
|
|
|
|
RT_OVL_AREA_KORR(int32, mi_sint4korr, 4);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_ULONG_INT:
|
|
|
|
RT_OVL_AREA_KORR(uint32, mi_uint4korr, 4);
|
|
|
|
break;
|
|
|
|
#ifdef HAVE_LONG_LONG
|
|
|
|
case HA_KEYTYPE_LONGLONG:
|
|
|
|
RT_OVL_AREA_KORR(longlong, mi_sint8korr, 8);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_ULONGLONG:
|
|
|
|
RT_OVL_AREA_KORR(longlong, mi_sint8korr, 8);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case HA_KEYTYPE_FLOAT:
|
|
|
|
RT_OVL_AREA_GET(float, mi_float4get, 4);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_DOUBLE:
|
|
|
|
RT_OVL_AREA_GET(double, mi_float8get, 8);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_END:
|
|
|
|
return res;
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
keyseg_length= keyseg->length * 2;
|
|
|
|
key_length-= keyseg_length;
|
|
|
|
a+= keyseg_length;
|
|
|
|
b+= keyseg_length;
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RT_AREA_INC_KORR(type, korr_func, len) \
|
|
|
|
{ \
|
|
|
|
type amin, amax, bmin, bmax; \
|
2007-10-09 20:09:50 +02:00
|
|
|
amin= korr_func(a); \
|
|
|
|
bmin= korr_func(b); \
|
|
|
|
amax= korr_func(a+len); \
|
|
|
|
bmax= korr_func(b+len); \
|
2006-04-11 15:45:10 +02:00
|
|
|
a_area *= (((double)amax) - ((double)amin)); \
|
|
|
|
loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RT_AREA_INC_GET(type, get_func, len)\
|
|
|
|
{\
|
|
|
|
type amin, amax, bmin, bmax; \
|
|
|
|
get_func(amin, a); \
|
|
|
|
get_func(bmin, b); \
|
|
|
|
get_func(amax, a+len); \
|
|
|
|
get_func(bmax, b+len); \
|
|
|
|
a_area *= (((double)amax) - ((double)amin)); \
|
|
|
|
loc_ab_area *= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2007-01-18 20:38:14 +01:00
|
|
|
Calculates MBR_AREA(a+b) - MBR_AREA(a)
|
2008-04-01 16:57:30 +02:00
|
|
|
Note: when 'a' and 'b' objects are far from each other,
|
|
|
|
the area increase can be really big, so this function
|
|
|
|
can return 'inf' as a result.
|
2006-04-11 15:45:10 +02:00
|
|
|
*/
|
2007-01-18 20:38:14 +01:00
|
|
|
|
Injecting more "const" declarations into code which does not change
pointed data.
I ran gcc -Wcast-qual on storage/maria, this identified un-needed casts,
a couple of functions which said they had a const parameter though
they changed the pointed content! This is fixed here. Some suspicious
places receive a comment.
The original intention of running -Wcast-qual was to find what code
changes R-tree keys: I added const words, but hidden casts
like those of int2store (casts target to (uint16*)) removed const
checking; -Wcast-qual helped find those hidden casts.
Log handler does not change the content pointed by LEX_STRING::str it
receives, so we now use a struct which has a const inside, to emphasize
this and be able to pass "const uchar*" buffers to log handler
without fear of their content being changed by it.
One-line fix for a merge glitch (when merging from MyISAM).
include/m_string.h:
As Maria's log handler uses LEX_STRING but never changes the content
pointed by LEX_STRING::str, and assigns uchar* into this member most
of the time, we introduce a new struct LEX_CUSTRING
(C const U unsigned) for the log handler.
include/my_global.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
include/my_handler.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
ha_find_null() does not change *a.
include/my_sys.h:
insert_dynamic() does not change *element.
include/myisampack.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
mysys/array.c:
insert_dynamic() does not change *element
mysys/my_handler.c:
ha_find_null() does not change *a
storage/maria/ma_bitmap.c:
Log handler receives const strings now
storage/maria/ma_blockrec.c:
Log handler receives const strings now.
_ma_apply_undo_row_delete/update() do change *header.
storage/maria/ma_blockrec.h:
correct prototype
storage/maria/ma_check.c:
Log handler receives const strings now. Un-needed casts
storage/maria/ma_checkpoint.c:
Log handler receives const strings now
storage/maria/ma_checksum.c:
unneeded cast
storage/maria/ma_commit.c:
Log handler receives const strings now
storage/maria/ma_create.c:
Log handler receives const strings now
storage/maria/ma_dbug.c:
fixing warning of gcc -Wcast-qual
storage/maria/ma_delete.c:
Log handler receives const strings now
storage/maria/ma_delete_all.c:
Log handler receives const strings now
storage/maria/ma_delete_table.c:
Log handler receives const strings now
storage/maria/ma_dynrec.c:
fixing some warnings of gcc -Wcast-qual. Unneeded casts removed.
Comment about function which lies.
storage/maria/ma_ft_parser.c:
fix for warnings of gcc -Wcast-qual, removing unneeded casts
storage/maria/ma_ft_update.c:
less casts, comment
storage/maria/ma_key.c:
less casts, stay const (warnings of gcc -Wcast-qual)
storage/maria/ma_key_recover.c:
Log handler receives const strings now
storage/maria/ma_loghandler.c:
Log handler receives const strings now
storage/maria/ma_loghandler.h:
Log handler receives const strings now
storage/maria/ma_loghandler_lsn.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
storage/maria/ma_page.c:
Log handler receives const strings now; more const
storage/maria/ma_recovery.c:
Log handler receives const strings now
storage/maria/ma_rename.c:
Log handler receives const strings now
storage/maria/ma_rt_index.c:
more const, to emphasize that functions don't change pointed content.
best_key= NULL was forgotten during merge from MyISAM a few days ago,
was causing a Valgrind warning
storage/maria/ma_rt_index.h:
new proto
storage/maria/ma_rt_key.c:
more const
storage/maria/ma_rt_key.h:
new proto
storage/maria/ma_rt_mbr.c:
more const for functions which deserve it
storage/maria/ma_rt_mbr.h:
new prototype
storage/maria/ma_rt_split.c:
make const what is not changed.
storage/maria/ma_search.c:
un-needed casts, more const
storage/maria/ma_sp_key.c:
more const
storage/maria/ma_unique.c:
un-needed casts.
storage/maria/ma_write.c:
Log handler receives const strings now
storage/maria/maria_def.h:
some more const
storage/maria/unittest/ma_test_loghandler-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_nologs-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_purge-t.c:
Log handler receives const strings now
2008-04-03 15:40:25 +02:00
|
|
|
double maria_rtree_area_increase(const HA_KEYSEG *keyseg, const uchar *a,
|
|
|
|
const uchar *b,
|
2007-01-18 20:38:14 +01:00
|
|
|
uint key_length, double *ab_area)
|
2006-04-11 15:45:10 +02:00
|
|
|
{
|
|
|
|
double a_area= 1.0;
|
|
|
|
double loc_ab_area= 1.0;
|
|
|
|
|
|
|
|
*ab_area= 1.0;
|
|
|
|
for (; (int)key_length > 0; keyseg += 2)
|
|
|
|
{
|
|
|
|
uint32 keyseg_length;
|
|
|
|
|
|
|
|
if (keyseg->null_bit) /* Handle NULL part */
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
switch ((enum ha_base_keytype) keyseg->type) {
|
|
|
|
case HA_KEYTYPE_INT8:
|
|
|
|
RT_AREA_INC_KORR(int8, mi_sint1korr, 1);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_BINARY:
|
|
|
|
RT_AREA_INC_KORR(uint8, mi_uint1korr, 1);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_SHORT_INT:
|
|
|
|
RT_AREA_INC_KORR(int16, mi_sint2korr, 2);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_USHORT_INT:
|
|
|
|
RT_AREA_INC_KORR(uint16, mi_uint2korr, 2);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_INT24:
|
|
|
|
RT_AREA_INC_KORR(int32, mi_sint3korr, 3);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_UINT24:
|
|
|
|
RT_AREA_INC_KORR(int32, mi_uint3korr, 3);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_LONG_INT:
|
|
|
|
RT_AREA_INC_KORR(int32, mi_sint4korr, 4);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_ULONG_INT:
|
|
|
|
RT_AREA_INC_KORR(uint32, mi_uint4korr, 4);
|
|
|
|
break;
|
|
|
|
#ifdef HAVE_LONG_LONG
|
|
|
|
case HA_KEYTYPE_LONGLONG:
|
|
|
|
RT_AREA_INC_KORR(longlong, mi_sint8korr, 8);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_ULONGLONG:
|
|
|
|
RT_AREA_INC_KORR(longlong, mi_sint8korr, 8);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case HA_KEYTYPE_FLOAT:
|
|
|
|
RT_AREA_INC_GET(float, mi_float4get, 4);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_DOUBLE:
|
|
|
|
RT_AREA_INC_GET(double, mi_float8get, 8);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_END:
|
|
|
|
goto safe_end;
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
keyseg_length= keyseg->length * 2;
|
|
|
|
key_length-= keyseg_length;
|
|
|
|
a+= keyseg_length;
|
|
|
|
b+= keyseg_length;
|
|
|
|
}
|
|
|
|
safe_end:
|
|
|
|
*ab_area= loc_ab_area;
|
|
|
|
return loc_ab_area - a_area;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RT_PERIM_INC_KORR(type, korr_func, len) \
|
|
|
|
{ \
|
|
|
|
type amin, amax, bmin, bmax; \
|
2007-10-09 20:09:50 +02:00
|
|
|
amin= korr_func(a); \
|
|
|
|
bmin= korr_func(b); \
|
|
|
|
amax= korr_func(a+len); \
|
|
|
|
bmax= korr_func(b+len); \
|
2006-04-11 15:45:10 +02:00
|
|
|
a_perim+= (((double)amax) - ((double)amin)); \
|
|
|
|
*ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define RT_PERIM_INC_GET(type, get_func, len)\
|
|
|
|
{\
|
|
|
|
type amin, amax, bmin, bmax; \
|
|
|
|
get_func(amin, a); \
|
|
|
|
get_func(bmin, b); \
|
|
|
|
get_func(amax, a+len); \
|
|
|
|
get_func(bmax, b+len); \
|
|
|
|
a_perim+= (((double)amax) - ((double)amin)); \
|
|
|
|
*ab_perim+= ((double)max(amax, bmax) - (double)min(amin, bmin)); \
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
Calculates MBR_PERIMETER(a+b) - MBR_PERIMETER(a)
|
|
|
|
*/
|
2007-07-02 19:45:15 +02:00
|
|
|
double maria_rtree_perimeter_increase(HA_KEYSEG *keyseg, uchar* a, uchar* b,
|
2006-04-11 15:45:10 +02:00
|
|
|
uint key_length, double *ab_perim)
|
|
|
|
{
|
2007-10-09 20:09:50 +02:00
|
|
|
double a_perim= 0.0;
|
2006-04-11 15:45:10 +02:00
|
|
|
|
|
|
|
*ab_perim= 0.0;
|
|
|
|
for (; (int)key_length > 0; keyseg += 2)
|
|
|
|
{
|
|
|
|
uint32 keyseg_length;
|
|
|
|
|
|
|
|
if (keyseg->null_bit) /* Handle NULL part */
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
switch ((enum ha_base_keytype) keyseg->type) {
|
|
|
|
case HA_KEYTYPE_INT8:
|
|
|
|
RT_PERIM_INC_KORR(int8, mi_sint1korr, 1);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_BINARY:
|
|
|
|
RT_PERIM_INC_KORR(uint8, mi_uint1korr, 1);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_SHORT_INT:
|
|
|
|
RT_PERIM_INC_KORR(int16, mi_sint2korr, 2);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_USHORT_INT:
|
|
|
|
RT_PERIM_INC_KORR(uint16, mi_uint2korr, 2);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_INT24:
|
|
|
|
RT_PERIM_INC_KORR(int32, mi_sint3korr, 3);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_UINT24:
|
|
|
|
RT_PERIM_INC_KORR(int32, mi_uint3korr, 3);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_LONG_INT:
|
|
|
|
RT_PERIM_INC_KORR(int32, mi_sint4korr, 4);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_ULONG_INT:
|
|
|
|
RT_PERIM_INC_KORR(uint32, mi_uint4korr, 4);
|
|
|
|
break;
|
|
|
|
#ifdef HAVE_LONG_LONG
|
|
|
|
case HA_KEYTYPE_LONGLONG:
|
|
|
|
RT_PERIM_INC_KORR(longlong, mi_sint8korr, 8);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_ULONGLONG:
|
|
|
|
RT_PERIM_INC_KORR(longlong, mi_sint8korr, 8);
|
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case HA_KEYTYPE_FLOAT:
|
|
|
|
RT_PERIM_INC_GET(float, mi_float4get, 4);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_DOUBLE:
|
|
|
|
RT_PERIM_INC_GET(double, mi_float8get, 8);
|
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_END:
|
|
|
|
return *ab_perim - a_perim;
|
|
|
|
default:
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
keyseg_length= keyseg->length * 2;
|
|
|
|
key_length-= keyseg_length;
|
|
|
|
a+= keyseg_length;
|
|
|
|
b+= keyseg_length;
|
|
|
|
}
|
|
|
|
return *ab_perim - a_perim;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-12-10 01:32:00 +01:00
|
|
|
#define RT_PAGE_MBR_KORR(share, type, korr_func, store_func, len) \
|
2006-04-11 15:45:10 +02:00
|
|
|
{ \
|
|
|
|
type amin, amax, bmin, bmax; \
|
2007-10-09 20:09:50 +02:00
|
|
|
amin= korr_func(k + inc); \
|
|
|
|
amax= korr_func(k + inc + len); \
|
2007-12-10 01:32:00 +01:00
|
|
|
k= rt_PAGE_NEXT_KEY(share, k, k_len, nod_flag); \
|
|
|
|
for (; k < last; k= rt_PAGE_NEXT_KEY(share, k, k_len, nod_flag)) \
|
2006-04-11 15:45:10 +02:00
|
|
|
{ \
|
2007-10-09 20:09:50 +02:00
|
|
|
bmin= korr_func(k + inc); \
|
|
|
|
bmax= korr_func(k + inc + len); \
|
2006-04-11 15:45:10 +02:00
|
|
|
if (amin > bmin) \
|
2007-10-09 20:09:50 +02:00
|
|
|
amin= bmin; \
|
2006-04-11 15:45:10 +02:00
|
|
|
if (amax < bmax) \
|
2007-10-09 20:09:50 +02:00
|
|
|
amax= bmax; \
|
2006-04-11 15:45:10 +02:00
|
|
|
} \
|
|
|
|
store_func(c, amin); \
|
|
|
|
c += len; \
|
|
|
|
store_func(c, amax); \
|
|
|
|
c += len; \
|
|
|
|
inc += 2 * len; \
|
|
|
|
}
|
|
|
|
|
2007-12-10 01:32:00 +01:00
|
|
|
#define RT_PAGE_MBR_GET(share, type, get_func, store_func, len) \
|
2006-04-11 15:45:10 +02:00
|
|
|
{ \
|
|
|
|
type amin, amax, bmin, bmax; \
|
|
|
|
get_func(amin, k + inc); \
|
|
|
|
get_func(amax, k + inc + len); \
|
2007-12-10 01:32:00 +01:00
|
|
|
k= rt_PAGE_NEXT_KEY(share, k, k_len, nod_flag); \
|
|
|
|
for (; k < last; k= rt_PAGE_NEXT_KEY(share, k, k_len, nod_flag)) \
|
2006-04-11 15:45:10 +02:00
|
|
|
{ \
|
|
|
|
get_func(bmin, k + inc); \
|
|
|
|
get_func(bmax, k + inc + len); \
|
|
|
|
if (amin > bmin) \
|
2007-10-09 20:09:50 +02:00
|
|
|
amin= bmin; \
|
2006-04-11 15:45:10 +02:00
|
|
|
if (amax < bmax) \
|
2007-10-09 20:09:50 +02:00
|
|
|
amax= bmax; \
|
2006-04-11 15:45:10 +02:00
|
|
|
} \
|
|
|
|
store_func(c, amin); \
|
|
|
|
c += len; \
|
|
|
|
store_func(c, amax); \
|
|
|
|
c += len; \
|
|
|
|
inc += 2 * len; \
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2007-10-09 20:09:50 +02:00
|
|
|
Calculates key page total MBR= MBR(key1) + MBR(key2) + ...
|
2006-04-11 15:45:10 +02:00
|
|
|
*/
|
Injecting more "const" declarations into code which does not change
pointed data.
I ran gcc -Wcast-qual on storage/maria, this identified un-needed casts,
a couple of functions which said they had a const parameter though
they changed the pointed content! This is fixed here. Some suspicious
places receive a comment.
The original intention of running -Wcast-qual was to find what code
changes R-tree keys: I added const words, but hidden casts
like those of int2store (casts target to (uint16*)) removed const
checking; -Wcast-qual helped find those hidden casts.
Log handler does not change the content pointed by LEX_STRING::str it
receives, so we now use a struct which has a const inside, to emphasize
this and be able to pass "const uchar*" buffers to log handler
without fear of their content being changed by it.
One-line fix for a merge glitch (when merging from MyISAM).
include/m_string.h:
As Maria's log handler uses LEX_STRING but never changes the content
pointed by LEX_STRING::str, and assigns uchar* into this member most
of the time, we introduce a new struct LEX_CUSTRING
(C const U unsigned) for the log handler.
include/my_global.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
include/my_handler.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
ha_find_null() does not change *a.
include/my_sys.h:
insert_dynamic() does not change *element.
include/myisampack.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
mysys/array.c:
insert_dynamic() does not change *element
mysys/my_handler.c:
ha_find_null() does not change *a
storage/maria/ma_bitmap.c:
Log handler receives const strings now
storage/maria/ma_blockrec.c:
Log handler receives const strings now.
_ma_apply_undo_row_delete/update() do change *header.
storage/maria/ma_blockrec.h:
correct prototype
storage/maria/ma_check.c:
Log handler receives const strings now. Un-needed casts
storage/maria/ma_checkpoint.c:
Log handler receives const strings now
storage/maria/ma_checksum.c:
unneeded cast
storage/maria/ma_commit.c:
Log handler receives const strings now
storage/maria/ma_create.c:
Log handler receives const strings now
storage/maria/ma_dbug.c:
fixing warning of gcc -Wcast-qual
storage/maria/ma_delete.c:
Log handler receives const strings now
storage/maria/ma_delete_all.c:
Log handler receives const strings now
storage/maria/ma_delete_table.c:
Log handler receives const strings now
storage/maria/ma_dynrec.c:
fixing some warnings of gcc -Wcast-qual. Unneeded casts removed.
Comment about function which lies.
storage/maria/ma_ft_parser.c:
fix for warnings of gcc -Wcast-qual, removing unneeded casts
storage/maria/ma_ft_update.c:
less casts, comment
storage/maria/ma_key.c:
less casts, stay const (warnings of gcc -Wcast-qual)
storage/maria/ma_key_recover.c:
Log handler receives const strings now
storage/maria/ma_loghandler.c:
Log handler receives const strings now
storage/maria/ma_loghandler.h:
Log handler receives const strings now
storage/maria/ma_loghandler_lsn.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
storage/maria/ma_page.c:
Log handler receives const strings now; more const
storage/maria/ma_recovery.c:
Log handler receives const strings now
storage/maria/ma_rename.c:
Log handler receives const strings now
storage/maria/ma_rt_index.c:
more const, to emphasize that functions don't change pointed content.
best_key= NULL was forgotten during merge from MyISAM a few days ago,
was causing a Valgrind warning
storage/maria/ma_rt_index.h:
new proto
storage/maria/ma_rt_key.c:
more const
storage/maria/ma_rt_key.h:
new proto
storage/maria/ma_rt_mbr.c:
more const for functions which deserve it
storage/maria/ma_rt_mbr.h:
new prototype
storage/maria/ma_rt_split.c:
make const what is not changed.
storage/maria/ma_search.c:
un-needed casts, more const
storage/maria/ma_sp_key.c:
more const
storage/maria/ma_unique.c:
un-needed casts.
storage/maria/ma_write.c:
Log handler receives const strings now
storage/maria/maria_def.h:
some more const
storage/maria/unittest/ma_test_loghandler-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_nologs-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_purge-t.c:
Log handler receives const strings now
2008-04-03 15:40:25 +02:00
|
|
|
int maria_rtree_page_mbr(const MARIA_HA *info, const HA_KEYSEG *keyseg,
|
|
|
|
const uchar *page_buf,
|
2007-07-02 19:45:15 +02:00
|
|
|
uchar *c, uint key_length)
|
2006-04-11 15:45:10 +02:00
|
|
|
{
|
2007-12-10 01:32:00 +01:00
|
|
|
MARIA_SHARE *share= info->s;
|
2007-10-09 20:09:50 +02:00
|
|
|
uint inc= 0;
|
|
|
|
uint k_len= key_length;
|
2007-12-10 01:32:00 +01:00
|
|
|
uint nod_flag= _ma_test_if_nod(share, page_buf);
|
Injecting more "const" declarations into code which does not change
pointed data.
I ran gcc -Wcast-qual on storage/maria, this identified un-needed casts,
a couple of functions which said they had a const parameter though
they changed the pointed content! This is fixed here. Some suspicious
places receive a comment.
The original intention of running -Wcast-qual was to find what code
changes R-tree keys: I added const words, but hidden casts
like those of int2store (casts target to (uint16*)) removed const
checking; -Wcast-qual helped find those hidden casts.
Log handler does not change the content pointed by LEX_STRING::str it
receives, so we now use a struct which has a const inside, to emphasize
this and be able to pass "const uchar*" buffers to log handler
without fear of their content being changed by it.
One-line fix for a merge glitch (when merging from MyISAM).
include/m_string.h:
As Maria's log handler uses LEX_STRING but never changes the content
pointed by LEX_STRING::str, and assigns uchar* into this member most
of the time, we introduce a new struct LEX_CUSTRING
(C const U unsigned) for the log handler.
include/my_global.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
include/my_handler.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
ha_find_null() does not change *a.
include/my_sys.h:
insert_dynamic() does not change *element.
include/myisampack.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
mysys/array.c:
insert_dynamic() does not change *element
mysys/my_handler.c:
ha_find_null() does not change *a
storage/maria/ma_bitmap.c:
Log handler receives const strings now
storage/maria/ma_blockrec.c:
Log handler receives const strings now.
_ma_apply_undo_row_delete/update() do change *header.
storage/maria/ma_blockrec.h:
correct prototype
storage/maria/ma_check.c:
Log handler receives const strings now. Un-needed casts
storage/maria/ma_checkpoint.c:
Log handler receives const strings now
storage/maria/ma_checksum.c:
unneeded cast
storage/maria/ma_commit.c:
Log handler receives const strings now
storage/maria/ma_create.c:
Log handler receives const strings now
storage/maria/ma_dbug.c:
fixing warning of gcc -Wcast-qual
storage/maria/ma_delete.c:
Log handler receives const strings now
storage/maria/ma_delete_all.c:
Log handler receives const strings now
storage/maria/ma_delete_table.c:
Log handler receives const strings now
storage/maria/ma_dynrec.c:
fixing some warnings of gcc -Wcast-qual. Unneeded casts removed.
Comment about function which lies.
storage/maria/ma_ft_parser.c:
fix for warnings of gcc -Wcast-qual, removing unneeded casts
storage/maria/ma_ft_update.c:
less casts, comment
storage/maria/ma_key.c:
less casts, stay const (warnings of gcc -Wcast-qual)
storage/maria/ma_key_recover.c:
Log handler receives const strings now
storage/maria/ma_loghandler.c:
Log handler receives const strings now
storage/maria/ma_loghandler.h:
Log handler receives const strings now
storage/maria/ma_loghandler_lsn.h:
In macros which read pointed content: use const pointers so that
gcc -Wcast-qual does not warn about casting a const pointer to non-const.
storage/maria/ma_page.c:
Log handler receives const strings now; more const
storage/maria/ma_recovery.c:
Log handler receives const strings now
storage/maria/ma_rename.c:
Log handler receives const strings now
storage/maria/ma_rt_index.c:
more const, to emphasize that functions don't change pointed content.
best_key= NULL was forgotten during merge from MyISAM a few days ago,
was causing a Valgrind warning
storage/maria/ma_rt_index.h:
new proto
storage/maria/ma_rt_key.c:
more const
storage/maria/ma_rt_key.h:
new proto
storage/maria/ma_rt_mbr.c:
more const for functions which deserve it
storage/maria/ma_rt_mbr.h:
new prototype
storage/maria/ma_rt_split.c:
make const what is not changed.
storage/maria/ma_search.c:
un-needed casts, more const
storage/maria/ma_sp_key.c:
more const
storage/maria/ma_unique.c:
un-needed casts.
storage/maria/ma_write.c:
Log handler receives const strings now
storage/maria/maria_def.h:
some more const
storage/maria/unittest/ma_test_loghandler-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_first_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_max_lsn-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multigroup-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_multithread-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_noflush-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_nologs-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_pagecache-t.c:
Log handler receives const strings now
storage/maria/unittest/ma_test_loghandler_purge-t.c:
Log handler receives const strings now
2008-04-03 15:40:25 +02:00
|
|
|
const uchar *k;
|
|
|
|
const uchar *last= rt_PAGE_END(share, page_buf);
|
2006-04-11 15:45:10 +02:00
|
|
|
|
|
|
|
for (; (int)key_length > 0; keyseg += 2)
|
|
|
|
{
|
|
|
|
key_length -= keyseg->length * 2;
|
|
|
|
|
|
|
|
/* Handle NULL part */
|
|
|
|
if (keyseg->null_bit)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2007-12-10 01:32:00 +01:00
|
|
|
k= rt_PAGE_FIRST_KEY(share, page_buf, nod_flag);
|
2006-04-11 15:45:10 +02:00
|
|
|
|
|
|
|
switch ((enum ha_base_keytype) keyseg->type) {
|
|
|
|
case HA_KEYTYPE_INT8:
|
2007-12-10 01:32:00 +01:00
|
|
|
RT_PAGE_MBR_KORR(share, int8, mi_sint1korr, mi_int1store, 1);
|
2006-04-11 15:45:10 +02:00
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_BINARY:
|
2007-12-10 01:32:00 +01:00
|
|
|
RT_PAGE_MBR_KORR(share, uint8, mi_uint1korr, mi_int1store, 1);
|
2006-04-11 15:45:10 +02:00
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_SHORT_INT:
|
2007-12-10 01:32:00 +01:00
|
|
|
RT_PAGE_MBR_KORR(share, int16, mi_sint2korr, mi_int2store, 2);
|
2006-04-11 15:45:10 +02:00
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_USHORT_INT:
|
2007-12-10 01:32:00 +01:00
|
|
|
RT_PAGE_MBR_KORR(share, uint16, mi_uint2korr, mi_int2store, 2);
|
2006-04-11 15:45:10 +02:00
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_INT24:
|
2007-12-10 01:32:00 +01:00
|
|
|
RT_PAGE_MBR_KORR(share, int32, mi_sint3korr, mi_int3store, 3);
|
2006-04-11 15:45:10 +02:00
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_UINT24:
|
2007-12-10 01:32:00 +01:00
|
|
|
RT_PAGE_MBR_KORR(share, uint32, mi_uint3korr, mi_int3store, 3);
|
2006-04-11 15:45:10 +02:00
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_LONG_INT:
|
2007-12-10 01:32:00 +01:00
|
|
|
RT_PAGE_MBR_KORR(share, int32, mi_sint4korr, mi_int4store, 4);
|
2006-04-11 15:45:10 +02:00
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_ULONG_INT:
|
2007-12-10 01:32:00 +01:00
|
|
|
RT_PAGE_MBR_KORR(share, uint32, mi_uint4korr, mi_int4store, 4);
|
2006-04-11 15:45:10 +02:00
|
|
|
break;
|
|
|
|
#ifdef HAVE_LONG_LONG
|
|
|
|
case HA_KEYTYPE_LONGLONG:
|
2007-12-10 01:32:00 +01:00
|
|
|
RT_PAGE_MBR_KORR(share, longlong, mi_sint8korr, mi_int8store, 8);
|
2006-04-11 15:45:10 +02:00
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_ULONGLONG:
|
2007-12-10 01:32:00 +01:00
|
|
|
RT_PAGE_MBR_KORR(share, ulonglong, mi_uint8korr, mi_int8store, 8);
|
2006-04-11 15:45:10 +02:00
|
|
|
break;
|
|
|
|
#endif
|
|
|
|
case HA_KEYTYPE_FLOAT:
|
2007-12-10 01:32:00 +01:00
|
|
|
RT_PAGE_MBR_GET(share, float, mi_float4get, mi_float4store, 4);
|
2006-04-11 15:45:10 +02:00
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_DOUBLE:
|
2007-12-10 01:32:00 +01:00
|
|
|
RT_PAGE_MBR_GET(share, double, mi_float8get, mi_float8store, 8);
|
2006-04-11 15:45:10 +02:00
|
|
|
break;
|
|
|
|
case HA_KEYTYPE_END:
|
|
|
|
return 0;
|
|
|
|
default:
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /*HAVE_RTREE_KEYS*/
|