mirror of
https://github.com/MariaDB/server.git
synced 2025-01-16 20:12:31 +01:00
d50ae16569
Added support for key_block_size to MyISAM. Simplify interface to 'new Key' to make it easier to add new key options. mysqld option --new is used to define where key options are printed. (In 5.3 we should move all key options to after key part definition to avoid problem with reserved names) Fixed some compiler warnings and a memory leak in ssl include/my_base.h: Added flag to check if block size for key was secified include/my_sys.h: Added new support function to round up to a power of two include/myisam.h: Rename block_size -> block_size_index to avoid confusion with 'block_size' include/violite.h: Added function to free memory after new_VioSSLAcceptorFd (Will rename all vio_ssl functions in a future changeset) mysql-test/mysql-test-run.pl: Don't print port number info when we use --extern mysql-test/r/myisam.result: Added test for key_block_size mysql-test/t/myisam.test: Added test for key_block_size mysys/mf_keycache.c: Simplify code mysys/my_bit.c: Added new support function to round up to a power of two sql/ha_myisam.cc: Tell MyISAM to use the specified key_block_size MyISAM also updates the global key_block_size from the used values. sql/handler.cc: Added 'default_key_create_info' to be used as 'dummy' argument to 'new Key' sql/handler.h: Added KEY_CREATE_INFO, to be used as for general options for KEY's sql/item_func.h: Removed compiler warning sql/lex.h: Added new symbol sql/mysqld.cc: Fixed memory leak in ssl (new_VioSSLAcceptorFd) sql/sql_class.h: Change 'new Key' to use KEY_CREATE_INFO instead of 'algoritm', parser, key_page_size. This makes it easier to add new key options in the future. sql/sql_lex.h: Added key create options sql/sql_parse.cc: Use new interface to 'new Key' sql/sql_show.cc: Added support for key_block_size If --new is used, key options are printed after the key part definition. sql/sql_table.cc: Use new interface to 'new Key' Add support for key_block_size sql/sql_yacc.yy: Add support for key_block_size Allow key options before and after key_parts (In future they should be always after the key_part defintion) Use new interface to 'new Key' sql/structs.h: Added block_size to keys sql/table.cc: Remmeber and read key_block_size for table and key level sql/table.h: Added default key_block_size for table sql/unireg.cc: Remember key_block_size for key storage/myisam/ft_eval.c: Set block_length to 0 to get default key page size storage/myisam/ft_test1.c: Set block_length to 0 to get default key page size storage/myisam/mi_check.c: block_size -> block_size_index storage/myisam/mi_create.c: Added support for block size per key. Block size is rounded up to next power of two and enforced between MIN and MAX KEY_BLOCK_LENGTH. Align start of key block to start at an even offset of max_key_block_length to ensure key cache works good if all key pages are of same size. storage/myisam/mi_open.c: block_size -> block_size_index storage/myisam/mi_page.c: block_size -> block_size_index storage/myisam/mi_test1.c: Set block_length to 0 to get default key page size storage/myisam/mi_test2.c: Set block_length to 0 to get default key page size storage/myisam/mi_test3.c: Set block_length to 0 to get default key page size storage/myisam/myisamdef.h: block_size -> block_size_index to avoid confusion with 'block_size' in MySQL Added block_size as argument to MI_BLOCK_SIZE Added missing prototypes to get rid of compiler warnings storage/myisam/myisampack.c: Removed compiler warning block_size -> block_size_index vio/viosslfactories.c: Fixed memory leak in ssl (new_VioSSLAcceptorFd) mysql-test/r/myisam-system.result: New BitKeeper file ``mysql-test/r/myisam-system.result'' mysql-test/t/myisam-system.test: New BitKeeper file ``mysql-test/t/myisam-system.test''
108 lines
3.4 KiB
C
108 lines
3.4 KiB
C
/* Copyright (C) 2000 MySQL 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
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
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 */
|
|
|
|
/* Some useful bit functions */
|
|
|
|
#include "mysys_priv.h"
|
|
|
|
/*
|
|
Find smallest X in 2^X >= value
|
|
This can be used to divide a number with value by doing a shift instead
|
|
*/
|
|
|
|
uint my_bit_log2(ulong value)
|
|
{
|
|
uint bit;
|
|
for (bit=0 ; value > 1 ; value>>=1, bit++) ;
|
|
return bit;
|
|
}
|
|
|
|
static char nbits[256] = {
|
|
0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
|
|
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
|
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
|
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
|
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
|
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
|
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
|
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
|
1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
|
|
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
|
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
|
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
|
2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
|
|
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
|
3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
|
|
4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
|
|
};
|
|
|
|
uint my_count_bits(ulonglong v)
|
|
{
|
|
#if SIZEOF_LONG_LONG > 4
|
|
/* The following code is a bit faster on 16 bit machines than if we would
|
|
only shift v */
|
|
ulong v2=(ulong) (v >> 32);
|
|
return (uint) (uchar) (nbits[(uchar) v] +
|
|
nbits[(uchar) (v >> 8)] +
|
|
nbits[(uchar) (v >> 16)] +
|
|
nbits[(uchar) (v >> 24)] +
|
|
nbits[(uchar) (v2)] +
|
|
nbits[(uchar) (v2 >> 8)] +
|
|
nbits[(uchar) (v2 >> 16)] +
|
|
nbits[(uchar) (v2 >> 24)]);
|
|
#else
|
|
return (uint) (uchar) (nbits[(uchar) v] +
|
|
nbits[(uchar) (v >> 8)] +
|
|
nbits[(uchar) (v >> 16)] +
|
|
nbits[(uchar) (v >> 24)]);
|
|
#endif
|
|
}
|
|
|
|
uint my_count_bits_ushort(ushort v)
|
|
{
|
|
return nbits[v];
|
|
}
|
|
|
|
|
|
/*
|
|
Next highest power of two
|
|
|
|
SYNOPSIS
|
|
my_round_up_to_next_power()
|
|
v Value to check
|
|
|
|
RETURN
|
|
Next or equal power of 2
|
|
Note: 0 will return 0
|
|
|
|
NOTES
|
|
Algorithm by Sean Anderson, according to:
|
|
http://graphics.stanford.edu/~seander/bithacks.html
|
|
(Orignal code public domain)
|
|
|
|
Comments shows how this works with 01100000000000000000000000001011
|
|
*/
|
|
|
|
uint32 my_round_up_to_next_power(uint32 v)
|
|
{
|
|
v--; /* 01100000000000000000000000001010 */
|
|
v|= v >> 1; /* 01110000000000000000000000001111 */
|
|
v|= v >> 2; /* 01111100000000000000000000001111 */
|
|
v|= v >> 4; /* 01111111110000000000000000001111 */
|
|
v|= v >> 8; /* 01111111111111111100000000001111 */
|
|
v|= v >> 16; /* 01111111111111111111111111111111 */
|
|
return v+1; /* 10000000000000000000000000000000 */
|
|
}
|