Commit 99c431db authored by unknown's avatar unknown

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
parent 381fdf1a
dnl ---------------------------------------------------------------------------
dnl Macro: MYSQL_CHECK_MARIA
dnl Sets HAVE_MARIA_DB if --with-maria-storage-engine is used
dnl ---------------------------------------------------------------------------
AC_DEFUN([MYSQL_CHECK_MARIA], [
AC_ARG_WITH([maria-storage-engine],
[
--with-maria-storage-engine
Enable the Maria Storage Engine],
[mariadb="$withval"],
[mariadb=no])
AC_MSG_CHECKING([for Maria storage engine])
case "$mariadb" in
yes )
AC_DEFINE([HAVE_MARIA_DB], [1], [Builds Maria Storage Engine])
AC_MSG_RESULT([yes])
[mariadb=yes]
;;
* )
AC_MSG_RESULT([no])
[mariadb=no]
;;
esac
])
dnl ---------------------------------------------------------------------------
dnl END OF MYSQL_CHECK_MARIA SECTION
dnl ---------------------------------------------------------------------------
...@@ -2200,15 +2200,16 @@ MYSQL_PLUGIN_ACTIONS(ndbcluster,[MYSQL_SETUP_NDBCLUSTER]) ...@@ -2200,15 +2200,16 @@ MYSQL_PLUGIN_ACTIONS(ndbcluster,[MYSQL_SETUP_NDBCLUSTER])
MYSQL_STORAGE_ENGINE(partition, partition, [Partition Support], MYSQL_STORAGE_ENGINE(partition, partition, [Partition Support],
[MySQL Partitioning Support], [max,max-no-ndb]) [MySQL Partitioning Support], [max,max-no-ndb])
dnl -- ndbcluster requires partition to be enabled
MYSQL_PLUGIN_DEPENDS(ndbcluster, [partition])
MYSQL_STORAGE_ENGINE(maria,maria, [Maria Storage Engine], MYSQL_STORAGE_ENGINE(maria,maria, [Maria Storage Engine],
[Traditional transactional MySQL tables]) [Traditional transactional MySQL tables], [max,max-no-ndb])
MYSQL_PLUGIN_DIRECTORY(maria, [storage/maria]) MYSQL_PLUGIN_DIRECTORY(maria, [storage/maria])
MYSQL_PLUGIN_STATIC(maria, [libmaria.a]) MYSQL_PLUGIN_STATIC(maria, [libmaria.a])
MYSQL_PLUGIN_MANDATORY(maria) MYSQL_PLUGIN_MANDATORY(maria)
dnl -- ndbcluster requires partition to be enabled
MYSQL_PLUGIN_DEPENDS(ndbcluster, [partition])
MYSQL_CONFIGURE_PLUGINS([none]) MYSQL_CONFIGURE_PLUGINS([none])
# Only build client code? # Only build client code?
......
...@@ -168,7 +168,7 @@ typedef struct st_maria_keydef /* Key definition with open & info */ ...@@ -168,7 +168,7 @@ typedef struct st_maria_keydef /* Key definition with open & info */
uint16 keylength; /* Tot length of keyparts (auto) */ uint16 keylength; /* Tot length of keyparts (auto) */
uint16 minlength; /* min length of (packed) key (auto) */ uint16 minlength; /* min length of (packed) key (auto) */
uint16 maxlength; /* max length of (packed) key (auto) */ uint16 maxlength; /* max length of (packed) key (auto) */
uint16 block_size; /* block_size (auto) */ uint16 block_size_index; /* block_size (auto) */
uint32 version; /* For concurrent read/write */ uint32 version; /* For concurrent read/write */
uint32 ftparser_nr; /* distinct ftparser number */ uint32 ftparser_nr; /* distinct ftparser number */
...@@ -235,7 +235,6 @@ typedef struct st_maria_columndef /* column information */ ...@@ -235,7 +235,6 @@ typedef struct st_maria_columndef /* column information */
} MARIA_COLUMNDEF; } MARIA_COLUMNDEF;
extern my_string maria_log_filename; /* Name of logfile */
extern ulong maria_block_size; extern ulong maria_block_size;
extern ulong maria_concurrent_insert; extern ulong maria_concurrent_insert;
extern my_bool maria_flush, maria_delay_key_write, maria_single_user; extern my_bool maria_flush, maria_delay_key_write, maria_single_user;
...@@ -281,9 +280,9 @@ extern int maria_delete_table(const char *name); ...@@ -281,9 +280,9 @@ extern int maria_delete_table(const char *name);
extern int maria_rename(const char *from, const char *to); extern int maria_rename(const char *from, const char *to);
extern int maria_extra(struct st_maria_info *file, extern int maria_extra(struct st_maria_info *file,
enum ha_extra_function function, void *extra_arg); enum ha_extra_function function, void *extra_arg);
extern int maria_reset(struct st_maria_info *file);
extern ha_rows maria_records_in_range(struct st_maria_info *info, int inx, extern ha_rows maria_records_in_range(struct st_maria_info *info, int inx,
key_range *min_key, key_range *max_key); key_range *min_key, key_range *max_key);
extern int maria_logging(int activate_log);
extern int maria_is_changed(struct st_maria_info *info); extern int maria_is_changed(struct st_maria_info *info);
extern int maria_delete_all_rows(struct st_maria_info *info); extern int maria_delete_all_rows(struct st_maria_info *info);
extern uint maria_get_pointer_length(ulonglong file_length, uint def); extern uint maria_get_pointer_length(ulonglong file_length, uint def);
...@@ -328,6 +327,7 @@ typedef struct st_maria_sort_param ...@@ -328,6 +327,7 @@ typedef struct st_maria_sort_param
uchar **sort_keys; uchar **sort_keys;
byte *rec_buff; byte *rec_buff;
void *wordlist, *wordptr; void *wordlist, *wordptr;
MEM_ROOT wordroot;
char *record; char *record;
MY_TMPDIR *tmpdir; MY_TMPDIR *tmpdir;
......
...@@ -18,8 +18,6 @@ ...@@ -18,8 +18,6 @@
#ifndef _my_handler_h #ifndef _my_handler_h
#define _my_handler_h #define _my_handler_h
#include "my_base.h"
#include "m_ctype.h"
#include "myisampack.h" #include "myisampack.h"
/* /*
......
...@@ -334,6 +334,7 @@ typedef struct st_mi_sort_param ...@@ -334,6 +334,7 @@ typedef struct st_mi_sort_param
uchar **sort_keys; uchar **sort_keys;
byte *rec_buff; byte *rec_buff;
void *wordlist, *wordptr; void *wordlist, *wordptr;
MEM_ROOT wordroot;
char *record; char *record;
MY_TMPDIR *tmpdir; MY_TMPDIR *tmpdir;
......
This diff is collapsed.
...@@ -1775,7 +1775,7 @@ NULL as const12, @arg12 as param12, ...@@ -1775,7 +1775,7 @@ NULL as const12, @arg12 as param12,
show create table t5 ; show create table t5 ;
Table Create Table Table Create Table
t5 CREATE TABLE `t5` ( t5 CREATE TABLE `t5` (
`const01` bigint(1) NOT NULL DEFAULT '0', `const01` int(1) NOT NULL DEFAULT '0',
`param01` bigint(20) DEFAULT NULL, `param01` bigint(20) DEFAULT NULL,
`const02` decimal(2,1) NOT NULL DEFAULT '0.0', `const02` decimal(2,1) NOT NULL DEFAULT '0.0',
`param02` decimal(65,30) DEFAULT NULL, `param02` decimal(65,30) DEFAULT NULL,
...@@ -1805,7 +1805,7 @@ t5 CREATE TABLE `t5` ( ...@@ -1805,7 +1805,7 @@ t5 CREATE TABLE `t5` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t5 ; select * from t5 ;
Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr Catalog Database Table Table_alias Column Column_alias Type Length Max length Is_null Flags Decimals Charsetnr
def test t5 t5 const01 const01 8 1 1 N 32769 0 63 def test t5 t5 const01 const01 3 1 1 N 32769 0 63
def test t5 t5 param01 param01 8 20 1 Y 32768 0 63 def test t5 t5 param01 param01 8 20 1 Y 32768 0 63
def test t5 t5 const02 const02 246 4 3 N 1 1 63 def test t5 t5 const02 const02 246 4 3 N 1 1 63
def test t5 t5 param02 param02 246 67 32 Y 0 30 63 def test t5 t5 param02 param02 246 67 32 Y 0 30 63
......
This diff is collapsed.
...@@ -524,7 +524,6 @@ HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, uchar *a) ...@@ -524,7 +524,6 @@ HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, uchar *a)
case HA_KEYTYPE_VARTEXT1: case HA_KEYTYPE_VARTEXT1:
case HA_KEYTYPE_VARTEXT2: case HA_KEYTYPE_VARTEXT2:
case HA_KEYTYPE_VARBINARY1: case HA_KEYTYPE_VARBINARY1:
case HA_KEYTYPE_VARTEXT2:
case HA_KEYTYPE_VARBINARY2: case HA_KEYTYPE_VARBINARY2:
{ {
int a_length; int a_length;
......
This diff is collapsed.
...@@ -49,7 +49,7 @@ class ha_maria :public handler ...@@ -49,7 +49,7 @@ class ha_maria :public handler
{ return "MARIA"; } { return "MARIA"; }
const char *index_type(uint key_number); const char *index_type(uint key_number);
const char **bas_ext() const; const char **bas_ext() const;
ulong table_flags() const ulonglong table_flags() const
{ return int_table_flags; } { return int_table_flags; }
ulong index_flags(uint inx, uint part, bool all_parts) const ulong index_flags(uint inx, uint part, bool all_parts) const
{ {
...@@ -106,6 +106,7 @@ class ha_maria :public handler ...@@ -106,6 +106,7 @@ class ha_maria :public handler
void info(uint); void info(uint);
int extra(enum ha_extra_function operation); int extra(enum ha_extra_function operation);
int extra_opt(enum ha_extra_function operation, ulong cache_size); int extra_opt(enum ha_extra_function operation, ulong cache_size);
int reset(void);
int external_lock(THD * thd, int lock_type); int external_lock(THD * thd, int lock_type);
int delete_all_rows(void); int delete_all_rows(void);
int disable_indexes(uint mode); int disable_indexes(uint mode);
...@@ -118,7 +119,10 @@ class ha_maria :public handler ...@@ -118,7 +119,10 @@ class ha_maria :public handler
int create(const char *name, TABLE * form, HA_CREATE_INFO * create_info); int create(const char *name, TABLE * form, HA_CREATE_INFO * create_info);
THR_LOCK_DATA **store_lock(THD * thd, THR_LOCK_DATA ** to, THR_LOCK_DATA **store_lock(THD * thd, THR_LOCK_DATA ** to,
enum thr_lock_type lock_type); enum thr_lock_type lock_type);
ulonglong get_auto_increment(); virtual void get_auto_increment(ulonglong offset, ulonglong increment,
ulonglong nb_desired_values,
ulonglong *first_value,
ulonglong *nb_reserved_values);
int rename_table(const char *from, const char *to); int rename_table(const char *from, const char *to);
int delete_table(const char *name); int delete_table(const char *name);
int check(THD * thd, HA_CHECK_OPT * check_opt); int check(THD * thd, HA_CHECK_OPT * check_opt);
......
...@@ -6021,7 +6021,6 @@ log and this option does nothing anymore.", ...@@ -6021,7 +6021,6 @@ log and this option does nothing anymore.",
(gptr*) &maria_stats_method_str, (gptr*) &maria_stats_method_str, 0, (gptr*) &maria_stats_method_str, (gptr*) &maria_stats_method_str, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif #endif
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
"Max packetlength to send/receive from to server.", "Max packetlength to send/receive from to server.",
(gptr*) &global_system_variables.max_allowed_packet, (gptr*) &global_system_variables.max_allowed_packet,
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
EXTRA_DIST = ma_test_all.sh ma_test_all.res ma_ft_stem.c cmakelists.txt EXTRA_DIST = ma_test_all.sh ma_test_all.res ma_ft_stem.c CMakeLists.txt
pkgdata_DATA = ma_test_all ma_test_all.res pkgdata_DATA = ma_test_all ma_test_all.res
INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
......
This diff is collapsed.
...@@ -28,9 +28,9 @@ ...@@ -28,9 +28,9 @@
#endif #endif
#include <m_ctype.h> #include <m_ctype.h>
/* /*
** Old options is used when recreating database, from isamchk Old options is used when recreating database, from maria_chk
*/ */
int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs, int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
uint columns, MARIA_COLUMNDEF *recinfo, uint columns, MARIA_COLUMNDEF *recinfo,
...@@ -45,6 +45,7 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs, ...@@ -45,6 +45,7 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
key_length,info_length,key_segs,options,min_key_length_skip, key_length,info_length,key_segs,options,min_key_length_skip,
base_pos,long_varchar_count,varchar_length, base_pos,long_varchar_count,varchar_length,
max_key_block_length,unique_key_parts,fulltext_keys,offset; max_key_block_length,unique_key_parts,fulltext_keys,offset;
uint aligned_key_start, block_length;
ulong reclength, real_reclength,min_pack_length; ulong reclength, real_reclength,min_pack_length;
char filename[FN_REFLEN],linkname[FN_REFLEN], *linkname_ptr; char filename[FN_REFLEN],linkname[FN_REFLEN], *linkname_ptr;
ulong pack_reclength; ulong pack_reclength;
...@@ -59,6 +60,8 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs, ...@@ -59,6 +60,8 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
my_off_t key_root[HA_MAX_POSSIBLE_KEY],key_del[MARIA_MAX_KEY_BLOCK_SIZE]; my_off_t key_root[HA_MAX_POSSIBLE_KEY],key_del[MARIA_MAX_KEY_BLOCK_SIZE];
MARIA_CREATE_INFO tmp_create_info; MARIA_CREATE_INFO tmp_create_info;
DBUG_ENTER("maria_create"); DBUG_ENTER("maria_create");
DBUG_PRINT("enter", ("keys: %u columns: %u uniques: %u flags: %u",
keys, columns, uniques, flags));
if (!ci) if (!ci)
{ {
...@@ -428,8 +431,16 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs, ...@@ -428,8 +431,16 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
key_segs) key_segs)
share.state.rec_per_key_part[key_segs-1]=1L; share.state.rec_per_key_part[key_segs-1]=1L;
length+=key_length; length+=key_length;
/* Get block length for key, if defined by user */
block_length= (keydef->block_length ?
my_round_up_to_next_power(keydef->block_length) :
maria_block_size);
block_length= max(block_length, MARIA_MIN_KEY_BLOCK_LENGTH);
block_length= min(block_length, MARIA_MAX_KEY_BLOCK_LENGTH);
keydef->block_length= MARIA_BLOCK_SIZE(length-real_length_diff, keydef->block_length= MARIA_BLOCK_SIZE(length-real_length_diff,
pointer,MARIA_MAX_KEYPTR_SIZE); pointer,MARIA_MAX_KEYPTR_SIZE,
block_length);
if (keydef->block_length > MARIA_MAX_KEY_BLOCK_LENGTH || if (keydef->block_length > MARIA_MAX_KEY_BLOCK_LENGTH ||
length >= HA_MAX_KEY_BUFF) length >= HA_MAX_KEY_BUFF)
{ {
...@@ -474,6 +485,17 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs, ...@@ -474,6 +485,17 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
(key_segs + unique_key_parts)*HA_KEYSEG_SIZE+ (key_segs + unique_key_parts)*HA_KEYSEG_SIZE+
columns*MARIA_COLUMNDEF_SIZE); columns*MARIA_COLUMNDEF_SIZE);
DBUG_PRINT("info", ("info_length: %u", info_length));
/* There are only 16 bits for the total header length. */
if (info_length > 65535)
{
my_printf_error(0, "Maria table '%s' has too many columns and/or "
"indexes and/or unique constraints.",
MYF(0), name + dirname_length(name));
my_errno= HA_WRONG_CREATE_OPTION;
goto err;
}
bmove(share.state.header.file_version,(byte*) maria_file_magic,4); bmove(share.state.header.file_version,(byte*) maria_file_magic,4);
ci->old_options=options| (ci->old_options & HA_OPTION_TEMP_COMPRESS_RECORD ? ci->old_options=options| (ci->old_options & HA_OPTION_TEMP_COMPRESS_RECORD ?
HA_OPTION_COMPRESS_RECORD | HA_OPTION_COMPRESS_RECORD |
...@@ -485,7 +507,7 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs, ...@@ -485,7 +507,7 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
mi_int2store(share.state.header.base_pos,base_pos); mi_int2store(share.state.header.base_pos,base_pos);
share.state.header.language= (ci->language ? share.state.header.language= (ci->language ?
ci->language : default_charset_info->number); ci->language : default_charset_info->number);
share.state.header.max_block_size=max_key_block_length/MARIA_MIN_KEY_BLOCK_LENGTH; share.state.header.max_block_size_index= max_key_block_length/MARIA_MIN_KEY_BLOCK_LENGTH;
share.state.dellink = HA_OFFSET_ERROR; share.state.dellink = HA_OFFSET_ERROR;
share.state.process= (ulong) getpid(); share.state.process= (ulong) getpid();
...@@ -512,8 +534,12 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs, ...@@ -512,8 +534,12 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
mi_int2store(share.state.header.unique_key_parts,unique_key_parts); mi_int2store(share.state.header.unique_key_parts,unique_key_parts);
maria_set_all_keys_active(share.state.key_map, keys); maria_set_all_keys_active(share.state.key_map, keys);
aligned_key_start= my_round_up_to_next_power(max_key_block_length ?
max_key_block_length :
maria_block_size);
share.base.keystart = share.state.state.key_file_length= share.base.keystart = share.state.state.key_file_length=
MY_ALIGN(info_length, maria_block_size); MY_ALIGN(info_length, aligned_key_start);
share.base.max_key_block_length=max_key_block_length; share.base.max_key_block_length=max_key_block_length;
share.base.max_key_length=ALIGN_SIZE(max_key_length+4); share.base.max_key_length=ALIGN_SIZE(max_key_length+4);
share.base.records=ci->max_rows; share.base.records=ci->max_rows;
...@@ -549,9 +575,21 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs, ...@@ -549,9 +575,21 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
{ {
char *iext= strrchr(ci->index_file_name, '.'); char *iext= strrchr(ci->index_file_name, '.');
int have_iext= iext && !strcmp(iext, MARIA_NAME_IEXT); int have_iext= iext && !strcmp(iext, MARIA_NAME_IEXT);
if (options & HA_OPTION_TMP_TABLE)
fn_format(filename, ci->index_file_name, "", MARIA_NAME_IEXT, {
MY_UNPACK_FILENAME| (have_iext ? MY_REPLACE_EXT :MY_APPEND_EXT)); char *path;
/* chop off the table name, tempory tables use generated name */
if ((path= strrchr(ci->index_file_name, FN_LIBCHAR)))
*path= '\0';
fn_format(filename, name, ci->index_file_name, MARIA_NAME_IEXT,
MY_REPLACE_DIR | MY_UNPACK_FILENAME | MY_APPEND_EXT);
}
else
{
fn_format(filename, ci->index_file_name, "", MARIA_NAME_IEXT,
MY_UNPACK_FILENAME | (have_iext ? MY_REPLACE_EXT :
MY_APPEND_EXT));
}
fn_format(linkname, name, "", MARIA_NAME_IEXT, fn_format(linkname, name, "", MARIA_NAME_IEXT,
MY_UNPACK_FILENAME|MY_APPEND_EXT); MY_UNPACK_FILENAME|MY_APPEND_EXT);
linkname_ptr=linkname; linkname_ptr=linkname;
...@@ -614,9 +652,21 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs, ...@@ -614,9 +652,21 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
char *dext= strrchr(ci->data_file_name, '.'); char *dext= strrchr(ci->data_file_name, '.');
int have_dext= dext && !strcmp(dext, MARIA_NAME_DEXT); int have_dext= dext && !strcmp(dext, MARIA_NAME_DEXT);
fn_format(filename, ci->data_file_name, "", MARIA_NAME_DEXT, if (options & HA_OPTION_TMP_TABLE)
MY_UNPACK_FILENAME | {
(have_dext ? MY_REPLACE_EXT : MY_APPEND_EXT)); char *path;
/* chop off the table name, tempory tables use generated name */
if ((path= strrchr(ci->data_file_name, FN_LIBCHAR)))
*path= '\0';
fn_format(filename, name, ci->data_file_name, MARIA_NAME_DEXT,
MY_REPLACE_DIR | MY_UNPACK_FILENAME | MY_APPEND_EXT);
}
else
{
fn_format(filename, ci->data_file_name, "", MARIA_NAME_DEXT,
MY_UNPACK_FILENAME |
(have_dext ? MY_REPLACE_EXT : MY_APPEND_EXT));
}
fn_format(linkname, name, "",MARIA_NAME_DEXT, fn_format(linkname, name, "",MARIA_NAME_DEXT,
MY_UNPACK_FILENAME | MY_APPEND_EXT); MY_UNPACK_FILENAME | MY_APPEND_EXT);
linkname_ptr=linkname; linkname_ptr=linkname;
...@@ -636,7 +686,7 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs, ...@@ -636,7 +686,7 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
} }
errpos=3; errpos=3;
} }
DBUG_PRINT("info", ("write state info and base info"));
if (_ma_state_info_write(file, &share.state, 2) || if (_ma_state_info_write(file, &share.state, 2) ||
_ma_base_info_write(file, &share.base)) _ma_base_info_write(file, &share.base))
goto err; goto err;
...@@ -650,6 +700,7 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs, ...@@ -650,6 +700,7 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
#endif #endif
/* Write key and keyseg definitions */ /* Write key and keyseg definitions */
DBUG_PRINT("info", ("write key and keyseg definitions"));
for (i=0 ; i < share.base.keys - uniques; i++) for (i=0 ; i < share.base.keys - uniques; i++)
{ {
uint sp_segs=(keydefs[i].flag & HA_SPATIAL) ? 2*SPDIMS : 0; uint sp_segs=(keydefs[i].flag & HA_SPATIAL) ? 2*SPDIMS : 0;
...@@ -700,6 +751,7 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs, ...@@ -700,6 +751,7 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
} }
/* Save unique definition */ /* Save unique definition */
DBUG_PRINT("info", ("write unique definitions"));
for (i=0 ; i < share.state.header.uniques ; i++) for (i=0 ; i < share.state.header.uniques ; i++)
{ {
HA_KEYSEG *keyseg_end; HA_KEYSEG *keyseg_end;
...@@ -730,6 +782,7 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs, ...@@ -730,6 +782,7 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
goto err; goto err;
} }
} }
DBUG_PRINT("info", ("write field definitions"));
for (i=0 ; i < share.base.fields ; i++) for (i=0 ; i < share.base.fields ; i++)
if (_ma_recinfo_write(file, &recinfo[i])) if (_ma_recinfo_write(file, &recinfo[i]))
goto err; goto err;
...@@ -744,6 +797,7 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs, ...@@ -744,6 +797,7 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
#endif #endif
/* Enlarge files */ /* Enlarge files */
DBUG_PRINT("info", ("enlarge to keystart: %lu", (ulong) share.base.keystart));
if (my_chsize(file,(ulong) share.base.keystart,0,MYF(0))) if (my_chsize(file,(ulong) share.base.keystart,0,MYF(0)))
goto err; goto err;
...@@ -772,7 +826,7 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs, ...@@ -772,7 +826,7 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
VOID(my_close(dfile,MYF(0))); VOID(my_close(dfile,MYF(0)));
/* fall through */ /* fall through */
case 2: case 2:
/* QQ: Tnu should add a call to my_raid_delete() here */ /* QQ: Tõnu should add a call to my_raid_delete() here */
if (! (flags & HA_DONT_TOUCH_DATA)) if (! (flags & HA_DONT_TOUCH_DATA))
my_delete_with_symlink(fn_format(filename,name,"",MARIA_NAME_DEXT, my_delete_with_symlink(fn_format(filename,name,"",MARIA_NAME_DEXT,
MY_UNPACK_FILENAME | MY_APPEND_EXT), MY_UNPACK_FILENAME | MY_APPEND_EXT),
......
...@@ -34,12 +34,24 @@ int maria_delete_table(const char *name) ...@@ -34,12 +34,24 @@ int maria_delete_table(const char *name)
#ifdef USE_RAID #ifdef USE_RAID
{ {
MARIA_HA *info; MARIA_HA *info;
/* we use 'open_for_repair' to be able to delete a crashed table */ /*
if (!(info=maria_open(name, O_RDONLY, HA_OPEN_FOR_REPAIR))) When built with RAID support, we need to determine if this table
DBUG_RETURN(my_errno); makes use of the raid feature. If yes, we need to remove all raid
raid_type = info->s->base.raid_type; chunks. This is done with my_raid_delete(). Unfortunately it is
raid_chunks = info->s->base.raid_chunks; necessary to open the table just to check this. We use
maria_close(info); 'open_for_repair' to be able to open even a crashed table. If even
this open fails, we assume no raid configuration for this table
and try to remove the normal data file only. This may however
leave the raid chunks behind.
*/
if (!(info= maria_open(name, O_RDONLY, HA_OPEN_FOR_REPAIR)))
raid_type= 0;
else
{
raid_type= info->s->base.raid_type;
raid_chunks= info->s->base.raid_chunks;
maria_close(info);
}
} }
#ifdef EXTRA_DEBUG #ifdef EXTRA_DEBUG
_ma_check_table_is_closed(name,"delete"); _ma_check_table_is_closed(name,"delete");
......
...@@ -67,6 +67,11 @@ static int _ma_cmp_buffer(File file, const byte *buff, my_off_t filepos, ...@@ -67,6 +67,11 @@ static int _ma_cmp_buffer(File file, const byte *buff, my_off_t filepos,
my_bool _ma_dynmap_file(MARIA_HA *info, my_off_t size) my_bool _ma_dynmap_file(MARIA_HA *info, my_off_t size)
{ {
DBUG_ENTER("_ma_dynmap_file"); DBUG_ENTER("_ma_dynmap_file");
if (size > (my_off_t) (~((size_t) 0)) - MEMMAP_EXTRA_MARGIN)
{
DBUG_PRINT("warning", ("File is too large for mmap"));
DBUG_RETURN(1);
}
info->s->file_map= (byte*) info->s->file_map= (byte*)
my_mmap(0, (size_t)(size + MEMMAP_EXTRA_MARGIN), my_mmap(0, (size_t)(size + MEMMAP_EXTRA_MARGIN),
info->s->mode==O_RDONLY ? PROT_READ : info->s->mode==O_RDONLY ? PROT_READ :
...@@ -1324,6 +1329,9 @@ int _ma_read_dynamic_record(MARIA_HA *info, my_off_t filepos, byte *buf) ...@@ -1324,6 +1329,9 @@ int _ma_read_dynamic_record(MARIA_HA *info, my_off_t filepos, byte *buf)
info->rec_cache.pos_in_file <= block_info.next_filepos && info->rec_cache.pos_in_file <= block_info.next_filepos &&
flush_io_cache(&info->rec_cache)) flush_io_cache(&info->rec_cache))
goto err; goto err;
/* A corrupted table can have wrong pointers. (Bug# 19835) */
if (block_info.next_filepos == HA_OFFSET_ERROR)
goto panic;
info->rec_cache.seek_not_done=1; info->rec_cache.seek_not_done=1;
if ((b_type= _ma_get_block_info(&block_info,file, if ((b_type= _ma_get_block_info(&block_info,file,
block_info.next_filepos)) block_info.next_filepos))
......
...@@ -47,29 +47,6 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, void *extra_arg ...@@ -47,29 +47,6 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, void *extra_arg
DBUG_PRINT("enter",("function: %d",(int) function)); DBUG_PRINT("enter",("function: %d",(int) function));
switch (function) { switch (function) {
case HA_EXTRA_RESET:
/*
Free buffers and reset the following flags:
EXTRA_CACHE, EXTRA_WRITE_CACHE, EXTRA_KEYREAD, EXTRA_QUICK
If the row buffer cache is large (for dynamic tables), reduce it
to save memory.
*/
if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED))
{
info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
error=end_io_cache(&info->rec_cache);
}
if (share->base.blobs)
_ma_alloc_rec_buff(info, -1, &info->rec_buff);
#if defined(HAVE_MMAP) && defined(HAVE_MADVISE)
if (info->opt_flag & MEMMAP_USED)
madvise(share->file_map,share->state.state.data_file_length,MADV_RANDOM);
#endif
info->opt_flag&= ~(KEY_READ_USED | REMEMBER_OLD_POS);
info->quick_mode=0;
/* Fall through */
case HA_EXTRA_RESET_STATE: /* Reset state (don't free buffers) */ case HA_EXTRA_RESET_STATE: /* Reset state (don't free buffers) */
info->lastinx= 0; /* Use first index as def */ info->lastinx= 0; /* Use first index as def */
info->last_search_keypage=info->lastpos= HA_OFFSET_ERROR; info->last_search_keypage=info->lastpos= HA_OFFSET_ERROR;
...@@ -423,3 +400,37 @@ static void maria_extra_keyflag(MARIA_HA *info, enum ha_extra_function function) ...@@ -423,3 +400,37 @@ static void maria_extra_keyflag(MARIA_HA *info, enum ha_extra_function function)
} }
} }
} }
int maria_reset(MARIA_HA *info)
{
int error= 0;
MARIA_SHARE *share=info->s;
DBUG_ENTER("maria_reset");
/*
Free buffers and reset the following flags:
EXTRA_CACHE, EXTRA_WRITE_CACHE, EXTRA_KEYREAD, EXTRA_QUICK
If the row buffer cache is large (for dynamic tables), reduce it
to save memory.
*/
if (info->opt_flag & (READ_CACHE_USED | WRITE_CACHE_USED))
{
info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED);
error= end_io_cache(&info->rec_cache);
}
if (share->base.blobs)
_ma_alloc_rec_buff(info, -1, &info->rec_buff);
#if defined(HAVE_MMAP) && defined(HAVE_MADVISE)
if (info->opt_flag & MEMMAP_USED)
madvise(share->file_map,share->state.state.data_file_length,MADV_RANDOM);
#endif
info->opt_flag&= ~(KEY_READ_USED | REMEMBER_OLD_POS);
info->quick_mode=0;
info->lastinx= 0; /* Use first index as def */
info->last_search_keypage= info->lastpos= HA_OFFSET_ERROR;
info->page_changed= 1;
info->update= ((info->update & HA_STATE_CHANGED) | HA_STATE_NEXT_FOUND |
HA_STATE_PREV_FOUND);
DBUG_RETURN(error);
}
...@@ -167,10 +167,11 @@ typedef struct st_my_ftb_param ...@@ -167,10 +167,11 @@ typedef struct st_my_ftb_param
} MY_FTB_PARAM; } MY_FTB_PARAM;
static int ftb_query_add_word(void *param, char *word, int word_len, static int ftb_query_add_word(MYSQL_FTPARSER_PARAM *param,
char *word, int word_len,
MYSQL_FTPARSER_BOOLEAN_INFO *info) MYSQL_FTPARSER_BOOLEAN_INFO *info)
{ {
MY_FTB_PARAM *ftb_param= (MY_FTB_PARAM *)param; MY_FTB_PARAM *ftb_param= param->mysql_ftparam;
FTB_WORD *ftbw; FTB_WORD *ftbw;
FTB_EXPR *ftbe, *tmp_expr; FTB_EXPR *ftbe, *tmp_expr;
FT_WORD *phrase_word; FT_WORD *phrase_word;
...@@ -268,9 +269,10 @@ static int ftb_query_add_word(void *param, char *word, int word_len, ...@@ -268,9 +269,10 @@ static int ftb_query_add_word(void *param, char *word, int word_len,
} }
static int ftb_parse_query_internal(void *param, char *query, int len) static int ftb_parse_query_internal(MYSQL_FTPARSER_PARAM *param,
char *query, int len)
{ {
MY_FTB_PARAM *ftb_param= (MY_FTB_PARAM *)param; MY_FTB_PARAM *ftb_param= param->mysql_ftparam;
MYSQL_FTPARSER_BOOLEAN_INFO info; MYSQL_FTPARSER_BOOLEAN_INFO info;
CHARSET_INFO *cs= ftb_param->ftb->charset; CHARSET_INFO *cs= ftb_param->ftb->charset;
char **start= &query; char **start= &query;
...@@ -280,7 +282,7 @@ static int ftb_parse_query_internal(void *param, char *query, int len) ...@@ -280,7 +282,7 @@ static int ftb_parse_query_internal(void *param, char *query, int len)
info.prev= ' '; info.prev= ' ';
info.quot= 0; info.quot= 0;
while (maria_ft_get_word(cs, start, end, &w, &info)) while (maria_ft_get_word(cs, start, end, &w, &info))
ftb_query_add_word(param, w.pos, w.len, &info); param->mysql_add_word(param, w.pos, w.len, &info);
return(0); return(0);
} }
...@@ -295,20 +297,21 @@ static void _ftb_parse_query(FTB *ftb, byte *query, uint len, ...@@ -295,20 +297,21 @@ static void _ftb_parse_query(FTB *ftb, byte *query, uint len,
if (ftb->state != UNINITIALIZED) if (ftb->state != UNINITIALIZED)
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
if (! (param= maria_ftparser_call_initializer(ftb->info, ftb->keynr, 0)))
DBUG_VOID_RETURN;
ftb_param.ftb= ftb; ftb_param.ftb= ftb;
ftb_param.depth= 0; ftb_param.depth= 0;
ftb_param.ftbe= ftb->root; ftb_param.ftbe= ftb->root;
ftb_param.up_quot= 0; ftb_param.up_quot= 0;
if (! (param= maria_ftparser_call_initializer(ftb->info, ftb->keynr)))
DBUG_VOID_RETURN;
param->mysql_parse= ftb_parse_query_internal; param->mysql_parse= ftb_parse_query_internal;
param->mysql_add_word= ftb_query_add_word; param->mysql_add_word= ftb_query_add_word;
param->mysql_ftparam= (void *)&ftb_param; param->mysql_ftparam= (void *)&ftb_param;
param->cs= ftb->charset; param->cs= ftb->charset;
param->doc= query; param->doc= query;
param->length= len; param->length= len;
param->flags= 0;
param->mode= MYSQL_FTPARSER_FULL_BOOLEAN_INFO; param->mode= MYSQL_FTPARSER_FULL_BOOLEAN_INFO;
parser->parse(param); parser->parse(param);
DBUG_VOID_RETURN; DBUG_VOID_RETURN;
...@@ -577,10 +580,11 @@ typedef struct st_my_ftb_phrase_param ...@@ -577,10 +580,11 @@ typedef struct st_my_ftb_phrase_param
} MY_FTB_PHRASE_PARAM; } MY_FTB_PHRASE_PARAM;
static int ftb_phrase_add_word(void *param, char *word, int word_len, static int ftb_phrase_add_word(MYSQL_FTPARSER_PARAM *param,
char *word, int word_len,
MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused))) MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused)))
{ {
MY_FTB_PHRASE_PARAM *phrase_param= (MY_FTB_PHRASE_PARAM *)param; MY_FTB_PHRASE_PARAM *phrase_param= param->mysql_ftparam;
FT_WORD *w= (FT_WORD *)phrase_param->document->data; FT_WORD *w= (FT_WORD *)phrase_param->document->data;
LIST *phrase, *document; LIST *phrase, *document;
w->pos= word; w->pos= word;
...@@ -608,14 +612,15 @@ static int ftb_phrase_add_word(void *param, char *word, int word_len, ...@@ -608,14 +612,15 @@ static int ftb_phrase_add_word(void *param, char *word, int word_len,
} }
static int ftb_check_phrase_internal(void *param, char *document, int len) static int ftb_check_phrase_internal(MYSQL_FTPARSER_PARAM *param,
char *document, int len)
{ {
FT_WORD word; FT_WORD word;
MY_FTB_PHRASE_PARAM *phrase_param= (MY_FTB_PHRASE_PARAM *)param; MY_FTB_PHRASE_PARAM *phrase_param= param->mysql_ftparam;
const char *docend= document + len; const char *docend= document + len;
while (maria_ft_simple_get_word(phrase_param->cs, &document, docend, &word, FALSE)) while (maria_ft_simple_get_word(phrase_param->cs, &document, docend, &word, FALSE))
{ {
ftb_phrase_add_word(param, word.pos, word.len, 0); param->mysql_add_word(param, word.pos, word.len, 0);
if (phrase_param->match) if (phrase_param->match)
return 1; return 1;
} }
...@@ -644,7 +649,8 @@ static int _ftb_check_phrase(FTB *ftb, const byte *document, uint len, ...@@ -644,7 +649,8 @@ static int _ftb_check_phrase(FTB *ftb, const byte *document, uint len,
MYSQL_FTPARSER_PARAM *param; MYSQL_FTPARSER_PARAM *param;
DBUG_ENTER("_ftb_check_phrase"); DBUG_ENTER("_ftb_check_phrase");
DBUG_ASSERT(parser); DBUG_ASSERT(parser);
if (! (param= maria_ftparser_call_initializer(ftb->info, ftb->keynr)))
if (! (param= maria_ftparser_call_initializer(ftb->info, ftb->keynr, 1)))
DBUG_RETURN(0); DBUG_RETURN(0);
ftb_param.phrase= ftbe->phrase; ftb_param.phrase= ftbe->phrase;
ftb_param.document= ftbe->document; ftb_param.document= ftbe->document;
...@@ -659,6 +665,7 @@ static int _ftb_check_phrase(FTB *ftb, const byte *document, uint len, ...@@ -659,6 +665,7 @@ static int _ftb_check_phrase(FTB *ftb, const byte *document, uint len,
param->cs= ftb->charset; param->cs= ftb->charset;
param->doc= (byte *)document; param->doc= (byte *)document;
param->length= len; param->length= len;
param->flags= 0;
param->mode= MYSQL_FTPARSER_WITH_STOPWORDS; param->mode= MYSQL_FTPARSER_WITH_STOPWORDS;
parser->parse(param); parser->parse(param);
DBUG_RETURN(ftb_param.match ? 1 : 0); DBUG_RETURN(ftb_param.match ? 1 : 0);
...@@ -819,10 +826,11 @@ typedef struct st_my_ftb_find_param ...@@ -819,10 +826,11 @@ typedef struct st_my_ftb_find_param
} MY_FTB_FIND_PARAM; } MY_FTB_FIND_PARAM;
static int ftb_find_relevance_add_word(void *param, char *word, int len, static int ftb_find_relevance_add_word(MYSQL_FTPARSER_PARAM *param,
char *word, int len,
MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused))) MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused)))
{ {
MY_FTB_FIND_PARAM *ftb_param= (MY_FTB_FIND_PARAM *)param; MY_FTB_FIND_PARAM *ftb_param= param->mysql_ftparam;
FT_INFO *ftb= ftb_param->ftb; FT_INFO *ftb= ftb_param->ftb;
FTB_WORD *ftbw; FTB_WORD *ftbw;
int a, b, c; int a, b, c;
...@@ -852,13 +860,15 @@ static int ftb_find_relevance_add_word(void *param, char *word, int len, ...@@ -852,13 +860,15 @@ static int ftb_find_relevance_add_word(void *param, char *word, int len,
} }
static int ftb_find_relevance_parse(void *param, char *doc, int len) static int ftb_find_relevance_parse(MYSQL_FTPARSER_PARAM *param,
char *doc, int len)
{ {
FT_INFO *ftb= ((MY_FTB_FIND_PARAM *)param)->ftb; MY_FTB_FIND_PARAM *ftb_param= param->mysql_ftparam;
FT_INFO *ftb= ftb_param->ftb;
char *end= doc + len; char *end= doc + len;
FT_WORD w; FT_WORD w;
while (maria_ft_simple_get_word(ftb->charset, &doc, end, &w, TRUE)) while (maria_ft_simple_get_word(ftb->charset, &doc, end, &w, TRUE))
ftb_find_relevance_add_word(param, w.pos, w.len, 0); param->mysql_add_word(param, w.pos, w.len, 0);
return(0); return(0);
} }
...@@ -878,7 +888,7 @@ float maria_ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length) ...@@ -878,7 +888,7 @@ float maria_ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length)
return -2.0; return -2.0;
if (!ftb->queue.elements) if (!ftb->queue.elements)
return 0; return 0;
if (! (param= maria_ftparser_call_initializer(ftb->info, ftb->keynr))) if (! (param= maria_ftparser_call_initializer(ftb->info, ftb->keynr, 0)))
return 0; return 0;
if (ftb->state != INDEX_SEARCH && docid <= ftb->lastpos) if (ftb->state != INDEX_SEARCH && docid <= ftb->lastpos)
...@@ -904,17 +914,17 @@ float maria_ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length) ...@@ -904,17 +914,17 @@ float maria_ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length)
ftb_param.ftb= ftb; ftb_param.ftb= ftb;
ftb_param.ftsi= &ftsi2; ftb_param.ftsi= &ftsi2;
param->mysql_parse= ftb_find_relevance_parse;
param->mysql_add_word= ftb_find_relevance_add_word;
param->mysql_ftparam= (void *)&ftb_param;
param->flags= 0;
param->cs= ftb->charset;
param->mode= MYSQL_FTPARSER_SIMPLE_MODE;
while (_ma_ft_segiterator(&ftsi)) while (_ma_ft_segiterator(&ftsi))
{ {
if (!ftsi.pos) if (!ftsi.pos)
continue; continue;
/* Since subsequent call to _ftb_check_phrase overwrites param elements,
it must be reinitialized at each iteration _inside_ the loop. */
param->mysql_parse= ftb_find_relevance_parse;
param->mysql_add_word= ftb_find_relevance_add_word;
param->mysql_ftparam= (void *)&ftb_param;
param->cs= ftb->charset;
param->mode= MYSQL_FTPARSER_SIMPLE_MODE;
param->doc= (byte *)ftsi.pos; param->doc= (byte *)ftsi.pos;
param->length= ftsi.len; param->length= ftsi.len;
parser->parse(param); parser->parse(param);
......
...@@ -55,6 +55,7 @@ int main(int argc, char *argv[]) ...@@ -55,6 +55,7 @@ int main(int argc, char *argv[])
/* Define a key over the first column */ /* Define a key over the first column */
keyinfo[0].seg=keyseg; keyinfo[0].seg=keyseg;
keyinfo[0].keysegs=1; keyinfo[0].keysegs=1;
keyinfo[0].block_length= 0; /* Default block length */
keyinfo[0].seg[0].type= HA_KEYTYPE_TEXT; keyinfo[0].seg[0].type= HA_KEYTYPE_TEXT;
keyinfo[0].seg[0].flag= HA_BLOB_PART; keyinfo[0].seg[0].flag= HA_BLOB_PART;
keyinfo[0].seg[0].start=recinfo[0].length; keyinfo[0].seg[0].start=recinfo[0].length;
......
...@@ -226,7 +226,7 @@ FT_INFO *maria_ft_init_nlq_search(MARIA_HA *info, uint keynr, byte *query, ...@@ -226,7 +226,7 @@ FT_INFO *maria_ft_init_nlq_search(MARIA_HA *info, uint keynr, byte *query,
aio.charset=info->s->keyinfo[keynr].seg->charset; aio.charset=info->s->keyinfo[keynr].seg->charset;
aio.keybuff=info->lastkey+info->s->base.max_key_length; aio.keybuff=info->lastkey+info->s->base.max_key_length;
parser= info->s->keyinfo[keynr].parser; parser= info->s->keyinfo[keynr].parser;
if (! (ftparser_param= maria_ftparser_call_initializer(info, keynr))) if (! (ftparser_param= maria_ftparser_call_initializer(info, keynr, 0)))
goto err; goto err;
bzero(&wtree,sizeof(wtree)); bzero(&wtree,sizeof(wtree));
...@@ -235,7 +235,9 @@ FT_INFO *maria_ft_init_nlq_search(MARIA_HA *info, uint keynr, byte *query, ...@@ -235,7 +235,9 @@ FT_INFO *maria_ft_init_nlq_search(MARIA_HA *info, uint keynr, byte *query,
NULL, NULL); NULL, NULL);
maria_ft_parse_init(&wtree, aio.charset); maria_ft_parse_init(&wtree, aio.charset);
if (maria_ft_parse(&wtree, query, query_len, 0, parser, ftparser_param)) ftparser_param->flags= 0;
if (maria_ft_parse(&wtree, query, query_len, parser, ftparser_param,
&wtree.mem_root))
goto err; goto err;
if (tree_walk(&wtree, (tree_walk_action)&walk_and_match, &aio, if (tree_walk(&wtree, (tree_walk_action)&walk_and_match, &aio,
...@@ -255,7 +257,9 @@ FT_INFO *maria_ft_init_nlq_search(MARIA_HA *info, uint keynr, byte *query, ...@@ -255,7 +257,9 @@ FT_INFO *maria_ft_init_nlq_search(MARIA_HA *info, uint keynr, byte *query,
if (!(*info->read_record)(info,docid,record)) if (!(*info->read_record)(info,docid,record))
{ {
info->update|= HA_STATE_AKTIV; info->update|= HA_STATE_AKTIV;
_ma_ft_parse(&wtree, info, keynr, record, 1, ftparser_param); ftparser_param->flags= MYSQL_FTFLAGS_NEED_COPY;
_ma_ft_parse(&wtree, info, keynr, record, ftparser_param,
&wtree.mem_root);
} }
} }
delete_queue(&best); delete_queue(&best);
......
...@@ -28,7 +28,7 @@ typedef struct st_maria_ft_docstat { ...@@ -28,7 +28,7 @@ typedef struct st_maria_ft_docstat {
typedef struct st_my_maria_ft_parser_param typedef struct st_my_maria_ft_parser_param
{ {
TREE *wtree; TREE *wtree;
my_bool with_alloc; MEM_ROOT *mem_root;
} MY_FT_PARSER_PARAM; } MY_FT_PARSER_PARAM;
...@@ -48,14 +48,14 @@ static int walk_and_copy(FT_WORD *word,uint32 count,FT_DOCSTAT *docstat) ...@@ -48,14 +48,14 @@ static int walk_and_copy(FT_WORD *word,uint32 count,FT_DOCSTAT *docstat)
/* transforms tree of words into the array, applying normalization */ /* transforms tree of words into the array, applying normalization */
FT_WORD * maria_ft_linearize(TREE *wtree) FT_WORD * maria_ft_linearize(TREE *wtree, MEM_ROOT *mem_root)
{ {
FT_WORD *wlist,*p; FT_WORD *wlist,*p;
FT_DOCSTAT docstat; FT_DOCSTAT docstat;
DBUG_ENTER("maria_ft_linearize"); DBUG_ENTER("maria_ft_linearize");
if ((wlist=(FT_WORD *) my_malloc(sizeof(FT_WORD)* if ((wlist=(FT_WORD *) alloc_root(mem_root, sizeof(FT_WORD)*
(1+wtree->elements_in_tree),MYF(0)))) (1+wtree->elements_in_tree))))
{ {
docstat.list=wlist; docstat.list=wlist;
docstat.uniq=wtree->elements_in_tree; docstat.uniq=wtree->elements_in_tree;
...@@ -114,6 +114,7 @@ byte maria_ft_get_word(CHARSET_INFO *cs, byte **start, byte *end, ...@@ -114,6 +114,7 @@ byte maria_ft_get_word(CHARSET_INFO *cs, byte **start, byte *end,
FT_WORD *word, MYSQL_FTPARSER_BOOLEAN_INFO *param) FT_WORD *word, MYSQL_FTPARSER_BOOLEAN_INFO *param)
{ {
byte *doc=*start; byte *doc=*start;
int ctype;
uint mwc, length, mbl; uint mwc, length, mbl;
param->yesno=(FTB_YES==' ') ? 1 : (param->quot != 0); param->yesno=(FTB_YES==' ') ? 1 : (param->quot != 0);
...@@ -122,9 +123,11 @@ byte maria_ft_get_word(CHARSET_INFO *cs, byte **start, byte *end, ...@@ -122,9 +123,11 @@ byte maria_ft_get_word(CHARSET_INFO *cs, byte **start, byte *end,
while (doc<end) while (doc<end)
{ {
for (;doc<end;doc++) for (; doc < end; doc+= (mbl > 0 ? mbl : 1))
{ {
if (true_word_char(cs,*doc)) break; mbl= cs->cset->ctype(cs, &ctype, (uchar*)doc, (uchar*)end);
if (true_word_char(ctype, *doc))
break;
if (*doc == FTB_RQUOT && param->quot) if (*doc == FTB_RQUOT && param->quot)
{ {
param->quot=doc; param->quot=doc;
...@@ -158,14 +161,16 @@ byte maria_ft_get_word(CHARSET_INFO *cs, byte **start, byte *end, ...@@ -158,14 +161,16 @@ byte maria_ft_get_word(CHARSET_INFO *cs, byte **start, byte *end,
} }
mwc=length=0; mwc=length=0;
for (word->pos=doc; doc<end; length++, mbl=my_mbcharlen(cs, *(uchar *)doc), doc+=(mbl ? mbl : 1)) for (word->pos= doc; doc < end; length++, doc+= (mbl > 0 ? mbl : 1))
if (true_word_char(cs,*doc)) {
mbl= cs->cset->ctype(cs, &ctype, (uchar*)doc, (uchar*)end);
if (true_word_char(ctype, *doc))
mwc=0; mwc=0;
else if (!misc_word_char(*doc) || mwc) else if (!misc_word_char(*doc) || mwc)
break; break;
else else
mwc++; mwc++;
}
param->prev='A'; /* be sure *prev is true_word_char */ param->prev='A'; /* be sure *prev is true_word_char */
word->len= (uint)(doc-word->pos) - mwc; word->len= (uint)(doc-word->pos) - mwc;
if ((param->trunc=(doc<end && *doc == FTB_TRUNC))) if ((param->trunc=(doc<end && *doc == FTB_TRUNC)))
...@@ -199,25 +204,32 @@ byte maria_ft_simple_get_word(CHARSET_INFO *cs, byte **start, const byte *end, ...@@ -199,25 +204,32 @@ byte maria_ft_simple_get_word(CHARSET_INFO *cs, byte **start, const byte *end,
FT_WORD *word, my_bool skip_stopwords) FT_WORD *word, my_bool skip_stopwords)
{ {
byte *doc= *start; byte *doc= *start;
int ctype;
uint mwc, length, mbl; uint mwc, length, mbl;
DBUG_ENTER("maria_ft_simple_get_word"); DBUG_ENTER("maria_ft_simple_get_word");
do do
{ {
for (;; doc++) for (;; doc+= (mbl > 0 ? mbl : 1))
{ {
if (doc >= end) DBUG_RETURN(0); if (doc >= end)
if (true_word_char(cs, *doc)) break; DBUG_RETURN(0);
mbl= cs->cset->ctype(cs, &ctype, (uchar*)doc, (uchar*)end);
if (true_word_char(ctype, *doc))
break;
} }
mwc= length= 0; mwc= length= 0;
for (word->pos=doc; doc<end; length++, mbl=my_mbcharlen(cs, *(uchar *)doc), doc+=(mbl ? mbl : 1)) for (word->pos= doc; doc < end; length++, doc+= (mbl > 0 ? mbl : 1))
if (true_word_char(cs,*doc)) {
mbl= cs->cset->ctype(cs, &ctype, (uchar*)doc, (uchar*)end);
if (true_word_char(ctype, *doc))
mwc= 0; mwc= 0;
else if (!misc_word_char(*doc) || mwc) else if (!misc_word_char(*doc) || mwc)
break; break;
else else
mwc++; mwc++;
}
word->len= (uint)(doc-word->pos) - mwc; word->len= (uint)(doc-word->pos) - mwc;
...@@ -241,19 +253,20 @@ void maria_ft_parse_init(TREE *wtree, CHARSET_INFO *cs) ...@@ -241,19 +253,20 @@ void maria_ft_parse_init(TREE *wtree, CHARSET_INFO *cs)
} }
static int maria_ft_add_word(void *param, byte *word, uint word_len, static int maria_ft_add_word(MYSQL_FTPARSER_PARAM *param,
char *word, int word_len,
MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused))) MYSQL_FTPARSER_BOOLEAN_INFO *boolean_info __attribute__((unused)))
{ {
TREE *wtree; TREE *wtree;
FT_WORD w; FT_WORD w;
MY_FT_PARSER_PARAM *ft_param=param->mysql_ftparam;
DBUG_ENTER("maria_ft_add_word"); DBUG_ENTER("maria_ft_add_word");
wtree= ((MY_FT_PARSER_PARAM *)param)->wtree; wtree= ft_param->wtree;
if (((MY_FT_PARSER_PARAM *)param)->with_alloc) if (param->flags & MYSQL_FTFLAGS_NEED_COPY)
{ {
byte *ptr; byte *ptr;
/* allocating the data in the tree - to avoid mallocs and frees */
DBUG_ASSERT(wtree->with_delete == 0); DBUG_ASSERT(wtree->with_delete == 0);
ptr= (byte *)alloc_root(&wtree->mem_root, word_len); ptr= (byte *)alloc_root(ft_param->mem_root, word_len);
memcpy(ptr, word, word_len); memcpy(ptr, word, word_len);
w.pos= ptr; w.pos= ptr;
} }
...@@ -269,30 +282,31 @@ static int maria_ft_add_word(void *param, byte *word, uint word_len, ...@@ -269,30 +282,31 @@ static int maria_ft_add_word(void *param, byte *word, uint word_len,
} }
static int maria_ft_parse_internal(void *param, byte *doc, uint doc_len) static int maria_ft_parse_internal(MYSQL_FTPARSER_PARAM *param,
byte *doc, int doc_len)
{ {
byte *end=doc+doc_len; byte *end=doc+doc_len;
MY_FT_PARSER_PARAM *ft_param=param->mysql_ftparam;
TREE *wtree= ft_param->wtree;
FT_WORD w; FT_WORD w;
TREE *wtree;
DBUG_ENTER("maria_ft_parse_internal"); DBUG_ENTER("maria_ft_parse_internal");
wtree= ((MY_FT_PARSER_PARAM *)param)->wtree;
while (maria_ft_simple_get_word(wtree->custom_arg, &doc, end, &w, TRUE)) while (maria_ft_simple_get_word(wtree->custom_arg, &doc, end, &w, TRUE))
if (maria_ft_add_word(param, w.pos, w.len, 0)) if (param->mysql_add_word(param, w.pos, w.len, 0))
DBUG_RETURN(1); DBUG_RETURN(1);
DBUG_RETURN(0); DBUG_RETURN(0);
} }
int maria_ft_parse(TREE *wtree, byte *doc, int doclen, my_bool with_alloc, int maria_ft_parse(TREE *wtree, byte *doc, int doclen,
struct st_mysql_ftparser *parser, struct st_mysql_ftparser *parser,
MYSQL_FTPARSER_PARAM *param) MYSQL_FTPARSER_PARAM *param, MEM_ROOT *mem_root)
{ {
MY_FT_PARSER_PARAM my_param; MY_FT_PARSER_PARAM my_param;
DBUG_ENTER("maria_ft_parse"); DBUG_ENTER("maria_ft_parse");
DBUG_ASSERT(parser); DBUG_ASSERT(parser);
my_param.wtree= wtree; my_param.wtree= wtree;
my_param.with_alloc= with_alloc; my_param.mem_root= mem_root;
param->mysql_parse= maria_ft_parse_internal; param->mysql_parse= maria_ft_parse_internal;
param->mysql_add_word= maria_ft_add_word; param->mysql_add_word= maria_ft_add_word;
...@@ -305,7 +319,9 @@ int maria_ft_parse(TREE *wtree, byte *doc, int doclen, my_bool with_alloc, ...@@ -305,7 +319,9 @@ int maria_ft_parse(TREE *wtree, byte *doc, int doclen, my_bool with_alloc,
} }
MYSQL_FTPARSER_PARAM *maria_ftparser_call_initializer(MARIA_HA *info, uint keynr) #define MAX_PARAM_NR 2
MYSQL_FTPARSER_PARAM *maria_ftparser_call_initializer(MARIA_HA *info,
uint keynr, uint paramnr)
{ {
uint32 ftparser_nr; uint32 ftparser_nr;
struct st_mysql_ftparser *parser; struct st_mysql_ftparser *parser;
...@@ -344,9 +360,16 @@ MYSQL_FTPARSER_PARAM *maria_ftparser_call_initializer(MARIA_HA *info, uint keynr ...@@ -344,9 +360,16 @@ MYSQL_FTPARSER_PARAM *maria_ftparser_call_initializer(MARIA_HA *info, uint keynr
} }
info->s->ftparsers= ftparsers; info->s->ftparsers= ftparsers;
} }
/*
We have to allocate two MYSQL_FTPARSER_PARAM structures per plugin
because in a boolean search a parser is called recursively
ftb_find_relevance* calls ftb_check_phrase*
(MAX_PARAM_NR=2)
*/
info->ftparser_param= (MYSQL_FTPARSER_PARAM *) info->ftparser_param= (MYSQL_FTPARSER_PARAM *)
my_malloc(sizeof(MYSQL_FTPARSER_PARAM) * my_malloc(MAX_PARAM_NR * sizeof(MYSQL_FTPARSER_PARAM) *
info->s->ftparsers, MYF(MY_WME|MY_ZEROFILL)); info->s->ftparsers, MYF(MY_WME|MY_ZEROFILL));
init_alloc_root(&info->ft_memroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
if (! info->ftparser_param) if (! info->ftparser_param)
return 0; return 0;
} }
...@@ -360,6 +383,8 @@ MYSQL_FTPARSER_PARAM *maria_ftparser_call_initializer(MARIA_HA *info, uint keynr ...@@ -360,6 +383,8 @@ MYSQL_FTPARSER_PARAM *maria_ftparser_call_initializer(MARIA_HA *info, uint keynr
ftparser_nr= info->s->keyinfo[keynr].ftparser_nr; ftparser_nr= info->s->keyinfo[keynr].ftparser_nr;
parser= info->s->keyinfo[keynr].parser; parser= info->s->keyinfo[keynr].parser;
} }
DBUG_ASSERT(paramnr < MAX_PARAM_NR);
ftparser_nr= ftparser_nr*MAX_PARAM_NR + paramnr;
if (! info->ftparser_param[ftparser_nr].mysql_add_word) if (! info->ftparser_param[ftparser_nr].mysql_add_word)
{ {
/* Note, that mysql_add_word is used here as a flag: /* Note, that mysql_add_word is used here as a flag:
...@@ -376,19 +401,25 @@ MYSQL_FTPARSER_PARAM *maria_ftparser_call_initializer(MARIA_HA *info, uint keynr ...@@ -376,19 +401,25 @@ MYSQL_FTPARSER_PARAM *maria_ftparser_call_initializer(MARIA_HA *info, uint keynr
void maria_ftparser_call_deinitializer(MARIA_HA *info) void maria_ftparser_call_deinitializer(MARIA_HA *info)
{ {
uint i, keys= info->s->state.header.keys; uint i, j, keys= info->s->state.header.keys;
free_root(&info->ft_memroot, MYF(0));
if (! info->ftparser_param) if (! info->ftparser_param)
return; return;
for (i= 0; i < keys; i++) for (i= 0; i < keys; i++)
{ {
MARIA_KEYDEF *keyinfo= &info->s->keyinfo[i]; MARIA_KEYDEF *keyinfo= &info->s->keyinfo[i];
MYSQL_FTPARSER_PARAM *ftparser_param= for (j=0; j < MAX_PARAM_NR; j++)
&info->ftparser_param[keyinfo->ftparser_nr];
if (keyinfo->flag & HA_FULLTEXT && ftparser_param->mysql_add_word)
{ {
if (keyinfo->parser->deinit) MYSQL_FTPARSER_PARAM *ftparser_param=
keyinfo->parser->deinit(ftparser_param); &info->ftparser_param[keyinfo->ftparser_nr*MAX_PARAM_NR + j];
ftparser_param->mysql_add_word= 0; if (keyinfo->flag & HA_FULLTEXT && ftparser_param->mysql_add_word)
{
if (keyinfo->parser->deinit)
keyinfo->parser->deinit(ftparser_param);
ftparser_param->mysql_add_word= 0;
}
else
break;
} }
} }
} }
...@@ -90,6 +90,7 @@ static int run_test(const char *filename) ...@@ -90,6 +90,7 @@ static int run_test(const char *filename)
/* Define a key over the first column */ /* Define a key over the first column */
keyinfo[0].seg=keyseg; keyinfo[0].seg=keyseg;
keyinfo[0].keysegs=1; keyinfo[0].keysegs=1;
keyinfo[0].block_length= 0; /* Default block length */
keyinfo[0].seg[0].type= key_type; keyinfo[0].seg[0].type= key_type;
keyinfo[0].seg[0].flag= (key_field == FIELD_BLOB) ? HA_BLOB_PART: keyinfo[0].seg[0].flag= (key_field == FIELD_BLOB) ? HA_BLOB_PART:
(key_field == FIELD_VARCHAR) ? HA_VAR_LENGTH_PART:0; (key_field == FIELD_VARCHAR) ? HA_VAR_LENGTH_PART:0;
......
...@@ -95,9 +95,8 @@ uint _ma_ft_segiterator(register FT_SEG_ITERATOR *ftsi) ...@@ -95,9 +95,8 @@ uint _ma_ft_segiterator(register FT_SEG_ITERATOR *ftsi)
/* parses a document i.e. calls maria_ft_parse for every keyseg */ /* parses a document i.e. calls maria_ft_parse for every keyseg */
uint _ma_ft_parse(TREE *parsed, MARIA_HA *info, uint keynr, uint _ma_ft_parse(TREE *parsed, MARIA_HA *info, uint keynr, const byte *record,
const byte *record, my_bool with_alloc, MYSQL_FTPARSER_PARAM *param, MEM_ROOT *mem_root)
MYSQL_FTPARSER_PARAM *param)
{ {
FT_SEG_ITERATOR ftsi; FT_SEG_ITERATOR ftsi;
struct st_mysql_ftparser *parser; struct st_mysql_ftparser *parser;
...@@ -110,25 +109,27 @@ uint _ma_ft_parse(TREE *parsed, MARIA_HA *info, uint keynr, ...@@ -110,25 +109,27 @@ uint _ma_ft_parse(TREE *parsed, MARIA_HA *info, uint keynr,
while (_ma_ft_segiterator(&ftsi)) while (_ma_ft_segiterator(&ftsi))
{ {
if (ftsi.pos) if (ftsi.pos)
if (maria_ft_parse(parsed, (byte *)ftsi.pos, ftsi.len, with_alloc, parser, if (maria_ft_parse(parsed, (byte *)ftsi.pos, ftsi.len, parser, param,
param)) mem_root))
DBUG_RETURN(1); DBUG_RETURN(1);
} }
DBUG_RETURN(0); DBUG_RETURN(0);
} }
FT_WORD * _ma_ft_parserecord(MARIA_HA *info, uint keynr, const byte *record) FT_WORD * _ma_ft_parserecord(MARIA_HA *info, uint keynr, const byte *record,
MEM_ROOT *mem_root)
{ {
TREE ptree; TREE ptree;
MYSQL_FTPARSER_PARAM *param; MYSQL_FTPARSER_PARAM *param;
DBUG_ENTER("_ma_ft_parserecord"); DBUG_ENTER("_ma_ft_parserecord");
if (! (param= maria_ftparser_call_initializer(info, keynr))) if (! (param= maria_ftparser_call_initializer(info, keynr, 0)))
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
bzero((char*) &ptree, sizeof(ptree)); bzero((char*) &ptree, sizeof(ptree));
if (_ma_ft_parse(&ptree, info, keynr, record, 0, param)) param->flags= 0;
if (_ma_ft_parse(&ptree, info, keynr, record, param, mem_root))
DBUG_RETURN(NULL); DBUG_RETURN(NULL);
DBUG_RETURN(maria_ft_linearize(&ptree)); DBUG_RETURN(maria_ft_linearize(&ptree, mem_root));
} }
static int _ma_ft_store(MARIA_HA *info, uint keynr, byte *keybuf, static int _ma_ft_store(MARIA_HA *info, uint keynr, byte *keybuf,
...@@ -174,10 +175,6 @@ int _ma_ft_cmp(MARIA_HA *info, uint keynr, const byte *rec1, const byte *rec2) ...@@ -174,10 +175,6 @@ int _ma_ft_cmp(MARIA_HA *info, uint keynr, const byte *rec1, const byte *rec2)
FT_SEG_ITERATOR ftsi1, ftsi2; FT_SEG_ITERATOR ftsi1, ftsi2;
CHARSET_INFO *cs=info->s->keyinfo[keynr].seg->charset; CHARSET_INFO *cs=info->s->keyinfo[keynr].seg->charset;
DBUG_ENTER("_ma_ft_cmp"); DBUG_ENTER("_ma_ft_cmp");
#ifndef MYSQL_HAS_TRUE_CTYPE_IMPLEMENTATION
if (cs->mbmaxlen > 1)
DBUG_RETURN(THOSE_TWO_DAMN_KEYS_ARE_REALLY_DIFFERENT);
#endif
_ma_ft_segiterator_init(info, keynr, rec1, &ftsi1); _ma_ft_segiterator_init(info, keynr, rec1, &ftsi1);
_ma_ft_segiterator_init(info, keynr, rec2, &ftsi2); _ma_ft_segiterator_init(info, keynr, rec2, &ftsi2);
...@@ -206,10 +203,11 @@ int _ma_ft_update(MARIA_HA *info, uint keynr, byte *keybuf, ...@@ -206,10 +203,11 @@ int _ma_ft_update(MARIA_HA *info, uint keynr, byte *keybuf,
int cmp, cmp2; int cmp, cmp2;
DBUG_ENTER("_ma_ft_update"); DBUG_ENTER("_ma_ft_update");
if (!(old_word=oldlist= _ma_ft_parserecord(info, keynr, oldrec))) if (!(old_word=oldlist=_ma_ft_parserecord(info, keynr, oldrec,
goto err0; &info->ft_memroot)) ||
if (!(new_word=newlist= _ma_ft_parserecord(info, keynr, newrec))) !(new_word=newlist=_ma_ft_parserecord(info, keynr, newrec,
goto err1; &info->ft_memroot)))
goto err;
error=0; error=0;
while(old_word->pos && new_word->pos) while(old_word->pos && new_word->pos)
...@@ -222,13 +220,13 @@ int _ma_ft_update(MARIA_HA *info, uint keynr, byte *keybuf, ...@@ -222,13 +220,13 @@ int _ma_ft_update(MARIA_HA *info, uint keynr, byte *keybuf,
{ {
key_length= _ma_ft_make_key(info,keynr,keybuf,old_word,pos); key_length= _ma_ft_make_key(info,keynr,keybuf,old_word,pos);
if ((error= _ma_ck_delete(info,keynr,(uchar*) keybuf,key_length))) if ((error= _ma_ck_delete(info,keynr,(uchar*) keybuf,key_length)))
goto err2; goto err;
} }
if (cmp > 0 || cmp2) if (cmp > 0 || cmp2)
{ {
key_length= _ma_ft_make_key(info,keynr,keybuf,new_word,pos); key_length= _ma_ft_make_key(info,keynr,keybuf,new_word,pos);
if ((error= _ma_ck_write(info,keynr,(uchar*) keybuf,key_length))) if ((error= _ma_ck_write(info,keynr,(uchar*) keybuf,key_length)))
goto err2; goto err;
} }
if (cmp<=0) old_word++; if (cmp<=0) old_word++;
if (cmp>=0) new_word++; if (cmp>=0) new_word++;
...@@ -238,11 +236,8 @@ int _ma_ft_update(MARIA_HA *info, uint keynr, byte *keybuf, ...@@ -238,11 +236,8 @@ int _ma_ft_update(MARIA_HA *info, uint keynr, byte *keybuf,
else if (new_word->pos) else if (new_word->pos)
error= _ma_ft_store(info,keynr,keybuf,new_word,pos); error= _ma_ft_store(info,keynr,keybuf,new_word,pos);
err2: err:
my_free((char*) newlist,MYF(0)); free_root(&info->ft_memroot, MYF(MY_MARK_BLOCKS_FREE));
err1:
my_free((char*) oldlist,MYF(0));
err0:
DBUG_RETURN(error); DBUG_RETURN(error);
} }
...@@ -255,12 +250,12 @@ int _ma_ft_add(MARIA_HA *info, uint keynr, byte *keybuf, const byte *record, ...@@ -255,12 +250,12 @@ int _ma_ft_add(MARIA_HA *info, uint keynr, byte *keybuf, const byte *record,
int error= -1; int error= -1;
FT_WORD *wlist; FT_WORD *wlist;
DBUG_ENTER("_ma_ft_add"); DBUG_ENTER("_ma_ft_add");
DBUG_PRINT("enter",("keynr: %d",keynr));
if ((wlist= _ma_ft_parserecord(info, keynr, record))) if ((wlist= _ma_ft_parserecord(info, keynr, record, &info->ft_memroot)))
{
error= _ma_ft_store(info,keynr,keybuf,wlist,pos); error= _ma_ft_store(info,keynr,keybuf,wlist,pos);
my_free((char*) wlist,MYF(0)); free_root(&info->ft_memroot, MYF(MY_MARK_BLOCKS_FREE));
} DBUG_PRINT("exit",("Return: %d",error));
DBUG_RETURN(error); DBUG_RETURN(error);
} }
...@@ -275,11 +270,9 @@ int _ma_ft_del(MARIA_HA *info, uint keynr, byte *keybuf, const byte *record, ...@@ -275,11 +270,9 @@ int _ma_ft_del(MARIA_HA *info, uint keynr, byte *keybuf, const byte *record,
DBUG_ENTER("_ma_ft_del"); DBUG_ENTER("_ma_ft_del");
DBUG_PRINT("enter",("keynr: %d",keynr)); DBUG_PRINT("enter",("keynr: %d",keynr));
if ((wlist= _ma_ft_parserecord(info, keynr, record))) if ((wlist= _ma_ft_parserecord(info, keynr, record, &info->ft_memroot)))
{
error= _ma_ft_erase(info,keynr,keybuf,wlist,pos); error= _ma_ft_erase(info,keynr,keybuf,wlist,pos);
my_free((char*) wlist,MYF(0)); free_root(&info->ft_memroot, MYF(MY_MARK_BLOCKS_FREE));
}
DBUG_PRINT("exit",("Return: %d",error)); DBUG_PRINT("exit",("Return: %d",error));
DBUG_RETURN(error); DBUG_RETURN(error);
} }
......
...@@ -24,12 +24,15 @@ ...@@ -24,12 +24,15 @@
#include <queues.h> #include <queues.h>
#include <mysql/plugin.h> #include <mysql/plugin.h>
#define true_word_char(s,X) (my_isalnum(s,X) || (X)=='_') #define true_word_char(ctype, character) \
((ctype) & (_MY_U | _MY_L | _MY_NMR) || \
(character) == '_')
#define misc_word_char(X) 0 #define misc_word_char(X) 0
#define word_char(s,X) (true_word_char(s,X) || misc_word_char(X))
#define FT_MAX_WORD_LEN_FOR_SORT 31 #define FT_MAX_WORD_LEN_FOR_SORT 31
#define FTPARSER_MEMROOT_ALLOC_SIZE 65536
#define COMPILE_STOPWORDS_IN #define COMPILE_STOPWORDS_IN
/* Interested readers may consult SMART /* Interested readers may consult SMART
...@@ -119,12 +122,12 @@ void _ma_ft_segiterator_dummy_init(const byte *, uint, FT_SEG_ITERATOR *); ...@@ -119,12 +122,12 @@ void _ma_ft_segiterator_dummy_init(const byte *, uint, FT_SEG_ITERATOR *);
uint _ma_ft_segiterator(FT_SEG_ITERATOR *); uint _ma_ft_segiterator(FT_SEG_ITERATOR *);
void maria_ft_parse_init(TREE *, CHARSET_INFO *); void maria_ft_parse_init(TREE *, CHARSET_INFO *);
int maria_ft_parse(TREE *, byte *, int, my_bool, struct st_mysql_ftparser *parser, int maria_ft_parse(TREE *, byte *, int, struct st_mysql_ftparser *parser,
MYSQL_FTPARSER_PARAM *param); MYSQL_FTPARSER_PARAM *, MEM_ROOT *);
FT_WORD * maria_ft_linearize(TREE *); FT_WORD * maria_ft_linearize(TREE *, MEM_ROOT *);
FT_WORD * _ma_ft_parserecord(MARIA_HA *, uint, const byte *); FT_WORD * _ma_ft_parserecord(MARIA_HA *, uint, const byte *, MEM_ROOT *);
uint _ma_ft_parse(TREE *, MARIA_HA *, uint, const byte *, my_bool, uint _ma_ft_parse(TREE *, MARIA_HA *, uint, const byte *,
MYSQL_FTPARSER_PARAM *param); MYSQL_FTPARSER_PARAM *, MEM_ROOT *);
FT_INFO *maria_ft_init_nlq_search(MARIA_HA *, uint, byte *, uint, uint, byte *); FT_INFO *maria_ft_init_nlq_search(MARIA_HA *, uint, byte *, uint, uint, byte *);
FT_INFO *maria_ft_init_boolean_search(MARIA_HA *, uint, byte *, uint, CHARSET_INFO *); FT_INFO *maria_ft_init_boolean_search(MARIA_HA *, uint, byte *, uint, CHARSET_INFO *);
...@@ -145,5 +148,6 @@ float maria_ft_boolean_get_relevance(FT_INFO *); ...@@ -145,5 +148,6 @@ float maria_ft_boolean_get_relevance(FT_INFO *);
my_off_t maria_ft_boolean_get_docid(FT_INFO *); my_off_t maria_ft_boolean_get_docid(FT_INFO *);
void maria_ft_boolean_reinit_search(FT_INFO *); void maria_ft_boolean_reinit_search(FT_INFO *);
extern MYSQL_FTPARSER_PARAM *maria_ftparser_call_initializer(MARIA_HA *info, extern MYSQL_FTPARSER_PARAM *maria_ftparser_call_initializer(MARIA_HA *info,
uint keynr); uint keynr,
uint paramnr);
extern void maria_ftparser_call_deinitializer(MARIA_HA *info); extern void maria_ftparser_call_deinitializer(MARIA_HA *info);
...@@ -127,7 +127,7 @@ uint _ma_make_key(register MARIA_HA *info, uint keynr, uchar *key, ...@@ -127,7 +127,7 @@ uint _ma_make_key(register MARIA_HA *info, uint keynr, uchar *key,
} }
if (keyseg->flag & HA_VAR_LENGTH_PART) if (keyseg->flag & HA_VAR_LENGTH_PART)
{ {
uint pack_length= keyseg->bit_start; uint pack_length= (keyseg->bit_start == 1 ? 1 : 2);
uint tmp_length= (pack_length == 1 ? (uint) *(uchar*) pos : uint tmp_length= (pack_length == 1 ? (uint) *(uchar*) pos :
uint2korr(pos)); uint2korr(pos));
pos+= pack_length; /* Skip VARCHAR length */ pos+= pack_length; /* Skip VARCHAR length */
...@@ -509,20 +509,19 @@ int _ma_read_key_record(MARIA_HA *info, my_off_t filepos, byte *buf) ...@@ -509,20 +509,19 @@ int _ma_read_key_record(MARIA_HA *info, my_off_t filepos, byte *buf)
/* /*
Update auto_increment info Retrieve auto_increment info
SYNOPSIS SYNOPSIS
_ma_update_auto_increment() retrieve_auto_increment()
info MARIA handler info Maria handler
record Row to update record Row to update
IMPLEMENTATION IMPLEMENTATION
Only replace the auto_increment value if it is higher than the previous For signed columns we don't retrieve the auto increment value if it's
one. For signed columns we don't update the auto increment value if it's
less than zero. less than zero.
*/ */
void _ma_update_auto_increment(MARIA_HA *info,const byte *record) ulonglong ma_retrieve_auto_increment(MARIA_HA *info,const byte *record)
{ {
ulonglong value= 0; /* Store unsigned values here */ ulonglong value= 0; /* Store unsigned values here */
longlong s_value= 0; /* Store signed values here */ longlong s_value= 0; /* Store signed values here */
...@@ -587,6 +586,5 @@ void _ma_update_auto_increment(MARIA_HA *info,const byte *record) ...@@ -587,6 +586,5 @@ void _ma_update_auto_increment(MARIA_HA *info,const byte *record)
and if s_value == 0 then value will contain either s_value or the and if s_value == 0 then value will contain either s_value or the
correct value. correct value.
*/ */
set_if_bigger(info->s->state.auto_increment, return (s_value > 0) ? (ulonglong) s_value : value;
(s_value > 0) ? (ulonglong) s_value : value);
} }
...@@ -95,7 +95,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -95,7 +95,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
bzero((byte*) &info,sizeof(info)); bzero((byte*) &info,sizeof(info));
my_realpath(name_buff, fn_format(org_name,name,"",MARIA_NAME_IEXT, my_realpath(name_buff, fn_format(org_name,name,"",MARIA_NAME_IEXT,
MY_UNPACK_FILENAME|MY_APPEND_EXT),MYF(0)); MY_UNPACK_FILENAME),MYF(0));
pthread_mutex_lock(&THR_LOCK_maria); pthread_mutex_lock(&THR_LOCK_maria);
if (!(old_info=_ma_test_if_reopen(name_buff))) if (!(old_info=_ma_test_if_reopen(name_buff)))
{ {
...@@ -287,7 +287,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -287,7 +287,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
&share->data_file_name,strlen(data_name)+1, &share->data_file_name,strlen(data_name)+1,
&share->state.key_root,keys*sizeof(my_off_t), &share->state.key_root,keys*sizeof(my_off_t),
&share->state.key_del, &share->state.key_del,
(share->state.header.max_block_size*sizeof(my_off_t)), (share->state.header.max_block_size_index*sizeof(my_off_t)),
#ifdef THREAD #ifdef THREAD
&share->key_root_lock,sizeof(rw_lock_t)*keys, &share->key_root_lock,sizeof(rw_lock_t)*keys,
#endif #endif
...@@ -302,7 +302,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags) ...@@ -302,7 +302,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
(char*) key_root, sizeof(my_off_t)*keys); (char*) key_root, sizeof(my_off_t)*keys);
memcpy((char*) share->state.key_del, memcpy((char*) share->state.key_del,
(char*) key_del, (sizeof(my_off_t) * (char*) key_del, (sizeof(my_off_t) *
share->state.header.max_block_size)); share->state.header.max_block_size_index));
strmov(share->unique_file_name, name_buff); strmov(share->unique_file_name, name_buff);
share->unique_name_length= strlen(name_buff); share->unique_name_length= strlen(name_buff);
strmov(share->index_file_name, index_name); strmov(share->index_file_name, index_name);
...@@ -799,7 +799,7 @@ uint _ma_state_info_write(File file, MARIA_STATE_INFO *state, uint pWrite) ...@@ -799,7 +799,7 @@ uint _ma_state_info_write(File file, MARIA_STATE_INFO *state, uint pWrite)
uchar buff[MARIA_STATE_INFO_SIZE + MARIA_STATE_EXTRA_SIZE]; uchar buff[MARIA_STATE_INFO_SIZE + MARIA_STATE_EXTRA_SIZE];
uchar *ptr=buff; uchar *ptr=buff;
uint i, keys= (uint) state->header.keys, uint i, keys= (uint) state->header.keys,
key_blocks=state->header.max_block_size; key_blocks=state->header.max_block_size_index;
DBUG_ENTER("_ma_state_info_write"); DBUG_ENTER("_ma_state_info_write");
memcpy_fixed(ptr,&state->header,sizeof(state->header)); memcpy_fixed(ptr,&state->header,sizeof(state->header));
...@@ -865,7 +865,7 @@ uchar *_ma_state_info_read(uchar *ptr, MARIA_STATE_INFO *state) ...@@ -865,7 +865,7 @@ uchar *_ma_state_info_read(uchar *ptr, MARIA_STATE_INFO *state)
ptr +=sizeof(state->header); ptr +=sizeof(state->header);
keys=(uint) state->header.keys; keys=(uint) state->header.keys;
key_parts=mi_uint2korr(state->header.key_parts); key_parts=mi_uint2korr(state->header.key_parts);
key_blocks=state->header.max_block_size; key_blocks=state->header.max_block_size_index;
state->open_count = mi_uint2korr(ptr); ptr +=2; state->open_count = mi_uint2korr(ptr); ptr +=2;
state->changed= (bool) *ptr++; state->changed= (bool) *ptr++;
...@@ -1038,7 +1038,7 @@ char *_ma_keydef_read(char *ptr, MARIA_KEYDEF *keydef) ...@@ -1038,7 +1038,7 @@ char *_ma_keydef_read(char *ptr, MARIA_KEYDEF *keydef)
keydef->keylength = mi_uint2korr(ptr); ptr +=2; keydef->keylength = mi_uint2korr(ptr); ptr +=2;
keydef->minlength = mi_uint2korr(ptr); ptr +=2; keydef->minlength = mi_uint2korr(ptr); ptr +=2;
keydef->maxlength = mi_uint2korr(ptr); ptr +=2; keydef->maxlength = mi_uint2korr(ptr); ptr +=2;
keydef->block_size = keydef->block_length/MARIA_MIN_KEY_BLOCK_LENGTH-1; keydef->block_size_index = keydef->block_length/MARIA_MIN_KEY_BLOCK_LENGTH-1;
keydef->underflow_block_length=keydef->block_length/3; keydef->underflow_block_length=keydef->block_length/3;
keydef->version = 0; /* Not saved */ keydef->version = 0; /* Not saved */
keydef->parser = &ft_default_parser; keydef->parser = &ft_default_parser;
......
...@@ -112,8 +112,8 @@ int _ma_dispose(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, my_off_t pos, ...@@ -112,8 +112,8 @@ int _ma_dispose(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, my_off_t pos,
DBUG_ENTER("_ma_dispose"); DBUG_ENTER("_ma_dispose");
DBUG_PRINT("enter",("pos: %ld", (long) pos)); DBUG_PRINT("enter",("pos: %ld", (long) pos));
old_link=info->s->state.key_del[keyinfo->block_size]; old_link= info->s->state.key_del[keyinfo->block_size_index];
info->s->state.key_del[keyinfo->block_size]=pos; info->s->state.key_del[keyinfo->block_size_index]= pos;
mi_sizestore(buff,old_link); mi_sizestore(buff,old_link);
info->s->state.changed|= STATE_NOT_SORTED_PAGES; info->s->state.changed|= STATE_NOT_SORTED_PAGES;
DBUG_RETURN(key_cache_write(info->s->key_cache, DBUG_RETURN(key_cache_write(info->s->key_cache,
...@@ -132,7 +132,8 @@ my_off_t _ma_new(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, int level) ...@@ -132,7 +132,8 @@ my_off_t _ma_new(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, int level)
char buff[8]; char buff[8];
DBUG_ENTER("_ma_new"); DBUG_ENTER("_ma_new");
if ((pos=info->s->state.key_del[keyinfo->block_size]) == HA_OFFSET_ERROR) if ((pos= info->s->state.key_del[keyinfo->block_size_index]) ==
HA_OFFSET_ERROR)
{ {
if (info->state->key_file_length >= if (info->state->key_file_length >=
info->s->base.max_key_file_length - keyinfo->block_length) info->s->base.max_key_file_length - keyinfo->block_length)
...@@ -152,7 +153,7 @@ my_off_t _ma_new(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, int level) ...@@ -152,7 +153,7 @@ my_off_t _ma_new(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, int level)
(uint) keyinfo->block_length,0)) (uint) keyinfo->block_length,0))
pos= HA_OFFSET_ERROR; pos= HA_OFFSET_ERROR;
else else
info->s->state.key_del[keyinfo->block_size]=mi_sizekorr(buff); info->s->state.key_del[keyinfo->block_size_index]= mi_sizekorr(buff);
} }
info->s->state.changed|= STATE_NOT_SORTED_PAGES; info->s->state.changed|= STATE_NOT_SORTED_PAGES;
DBUG_PRINT("exit",("Pos: %ld",(long) pos)); DBUG_PRINT("exit",("Pos: %ld",(long) pos));
......
...@@ -92,7 +92,18 @@ int maria_rkey(MARIA_HA *info, byte *buf, int inx, const byte *key, uint key_len ...@@ -92,7 +92,18 @@ int maria_rkey(MARIA_HA *info, byte *buf, int inx, const byte *key, uint key_len
if (!_ma_search(info, keyinfo, key_buff, use_key_length, if (!_ma_search(info, keyinfo, key_buff, use_key_length,
maria_read_vec[search_flag], info->s->state.key_root[inx])) maria_read_vec[search_flag], info->s->state.key_root[inx]))
{ {
while (info->lastpos >= info->state->data_file_length) /*
If we are searching for an exact key (including the data pointer)
and this was added by an concurrent insert,
then the result is "key not found".
*/
if ((search_flag == HA_READ_KEY_EXACT) &&
(info->lastpos >= info->state->data_file_length))
{
my_errno= HA_ERR_KEY_NOT_FOUND;
info->lastpos= HA_OFFSET_ERROR;
}
else while (info->lastpos >= info->state->data_file_length)
{ {
/* /*
Skip rows that are inserted by other threads since we got a lock Skip rows that are inserted by other threads since we got a lock
...@@ -101,9 +112,9 @@ int maria_rkey(MARIA_HA *info, byte *buf, int inx, const byte *key, uint key_len ...@@ -101,9 +112,9 @@ int maria_rkey(MARIA_HA *info, byte *buf, int inx, const byte *key, uint key_len
*/ */
if (_ma_search_next(info, keyinfo, info->lastkey, if (_ma_search_next(info, keyinfo, info->lastkey,
info->lastkey_length, info->lastkey_length,
maria_readnext_vec[search_flag], maria_readnext_vec[search_flag],
info->s->state.key_root[inx])) info->s->state.key_root[inx]))
break; break;
} }
} }
......
...@@ -31,8 +31,9 @@ ...@@ -31,8 +31,9 @@
int maria_rsame_with_pos(MARIA_HA *info, byte *record, int inx, my_off_t filepos) int maria_rsame_with_pos(MARIA_HA *info, byte *record, int inx, my_off_t filepos)
{ {
DBUG_ENTER("maria_rsame_with_pos"); DBUG_ENTER("maria_rsame_with_pos");
DBUG_PRINT("enter",("index: %d filepos: %ld", inx, (long) filepos));
if (inx < -1 || ! maria_is_key_active(info->s->state.key_map, inx)) if (inx < -1 || (inx >= 0 && !maria_is_key_active(info->s->state.key_map, inx)))
{ {
DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX); DBUG_RETURN(my_errno=HA_ERR_WRONG_INDEX);
} }
......
...@@ -183,9 +183,11 @@ int maria_rtree_find_first(MARIA_HA *info, uint keynr, uchar *key, uint key_leng ...@@ -183,9 +183,11 @@ int maria_rtree_find_first(MARIA_HA *info, uint keynr, uchar *key, uint key_leng
return -1; return -1;
} }
/* Save searched key */ /*
memcpy(info->first_mbr_key, key, keyinfo->keylength - Save searched key, include data pointer.
info->s->base.rec_reflength); The data pointer is required if the search_flag contains MBR_DATA.
*/
memcpy(info->first_mbr_key, key, keyinfo->keylength);
info->last_rkey_length = key_length; info->last_rkey_length = key_length;
info->maria_rtree_recursion_depth = -1; info->maria_rtree_recursion_depth = -1;
......
...@@ -52,10 +52,14 @@ ...@@ -52,10 +52,14 @@
if (EQUAL_CMP(amin, amax, bmin, bmax)) \ if (EQUAL_CMP(amin, amax, bmin, bmax)) \
return 1; \ return 1; \
} \ } \
else /* if (nextflag & MBR_DISJOINT) */ \ else if (nextflag & MBR_DISJOINT) \
{ \ { \
if (DISJOINT_CMP(amin, amax, bmin, bmax)) \ if (DISJOINT_CMP(amin, amax, bmin, bmax)) \
return 1; \ return 1; \
}\
else /* if unknown comparison operator */ \
{ \
DBUG_ASSERT(0); \
} }
#define RT_CMP_KORR(type, korr_func, len, nextflag) \ #define RT_CMP_KORR(type, korr_func, len, nextflag) \
......
...@@ -259,15 +259,16 @@ int _ma_seq_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, uchar *page, ...@@ -259,15 +259,16 @@ int _ma_seq_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, uchar *page,
{ {
maria_print_error(info->s, HA_ERR_CRASHED); maria_print_error(info->s, HA_ERR_CRASHED);
my_errno=HA_ERR_CRASHED; my_errno=HA_ERR_CRASHED;
DBUG_PRINT("error",("Found wrong key: length: %u page: %lx end: %lx", DBUG_PRINT("error",
length, (long) page, (long) end)); ("Found wrong key: length: %u page: 0x%lx end: 0x%lx",
length, (long) page, (long) end));
DBUG_RETURN(MARIA_FOUND_WRONG_KEY); DBUG_RETURN(MARIA_FOUND_WRONG_KEY);
} }
if ((flag=ha_key_cmp(keyinfo->seg,t_buff,key,key_len,comp_flag, if ((flag=ha_key_cmp(keyinfo->seg,t_buff,key,key_len,comp_flag,
not_used)) >= 0) not_used)) >= 0)
break; break;
#ifdef EXTRA_DEBUG #ifdef EXTRA_DEBUG
DBUG_PRINT("loop",("page: %lx key: '%s' flag: %d", (long) page, t_buff, DBUG_PRINT("loop",("page: 0x%lx key: '%s' flag: %d", (long) page, t_buff,
flag)); flag));
#endif #endif
memcpy(buff,t_buff,length); memcpy(buff,t_buff,length);
...@@ -276,7 +277,7 @@ int _ma_seq_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, uchar *page, ...@@ -276,7 +277,7 @@ int _ma_seq_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, uchar *page,
if (flag == 0) if (flag == 0)
memcpy(buff,t_buff,length); /* Result is first key */ memcpy(buff,t_buff,length); /* Result is first key */
*last_key= page == end; *last_key= page == end;
DBUG_PRINT("exit",("flag: %d ret_pos: %lx", flag, (long) *ret_pos)); DBUG_PRINT("exit",("flag: %d ret_pos: 0x%lx", flag, (long) *ret_pos));
DBUG_RETURN(flag); DBUG_RETURN(flag);
} /* _ma_seq_search */ } /* _ma_seq_search */
...@@ -416,8 +417,9 @@ int _ma_prefix_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, uchar *pag ...@@ -416,8 +417,9 @@ int _ma_prefix_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, uchar *pag
{ {
maria_print_error(info->s, HA_ERR_CRASHED); maria_print_error(info->s, HA_ERR_CRASHED);
my_errno=HA_ERR_CRASHED; my_errno=HA_ERR_CRASHED;
DBUG_PRINT("error",("Found wrong key: length: %u page: %lx end: %lx", DBUG_PRINT("error",
length, (long) page, (long) end)); ("Found wrong key: length: %u page: 0x%lx end: %lx",
length, (long) page, (long) end));
DBUG_RETURN(MARIA_FOUND_WRONG_KEY); DBUG_RETURN(MARIA_FOUND_WRONG_KEY);
} }
...@@ -551,7 +553,7 @@ int _ma_prefix_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, uchar *pag ...@@ -551,7 +553,7 @@ int _ma_prefix_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, uchar *pag
*last_key= page == end; *last_key= page == end;
DBUG_PRINT("exit",("flag: %d ret_pos: %lx", flag, (long) *ret_pos)); DBUG_PRINT("exit",("flag: %d ret_pos: 0x%lx", flag, (long) *ret_pos));
DBUG_RETURN(flag); DBUG_RETURN(flag);
} /* _ma_prefix_search */ } /* _ma_prefix_search */
...@@ -813,7 +815,7 @@ uint _ma_get_pack_key(register MARIA_KEYDEF *keyinfo, uint nod_flag, ...@@ -813,7 +815,7 @@ uint _ma_get_pack_key(register MARIA_KEYDEF *keyinfo, uint nod_flag,
if (length > keyseg->length) if (length > keyseg->length)
{ {
DBUG_PRINT("error", DBUG_PRINT("error",
("Found too long null packed key: %u of %u at %lx", ("Found too long null packed key: %u of %u at 0x%lx",
length, keyseg->length, (long) *page_pos)); length, keyseg->length, (long) *page_pos));
DBUG_DUMP("key",(char*) *page_pos,16); DBUG_DUMP("key",(char*) *page_pos,16);
maria_print_error(keyinfo->share, HA_ERR_CRASHED); maria_print_error(keyinfo->share, HA_ERR_CRASHED);
...@@ -870,7 +872,7 @@ uint _ma_get_pack_key(register MARIA_KEYDEF *keyinfo, uint nod_flag, ...@@ -870,7 +872,7 @@ uint _ma_get_pack_key(register MARIA_KEYDEF *keyinfo, uint nod_flag,
} }
if (length > (uint) keyseg->length) if (length > (uint) keyseg->length)
{ {
DBUG_PRINT("error",("Found too long packed key: %u of %u at %lx", DBUG_PRINT("error",("Found too long packed key: %u of %u at 0x%lx",
length, keyseg->length, (long) *page_pos)); length, keyseg->length, (long) *page_pos));
DBUG_DUMP("key",(char*) *page_pos,16); DBUG_DUMP("key",(char*) *page_pos,16);
maria_print_error(keyinfo->share, HA_ERR_CRASHED); maria_print_error(keyinfo->share, HA_ERR_CRASHED);
...@@ -936,8 +938,9 @@ uint _ma_get_binary_pack_key(register MARIA_KEYDEF *keyinfo, uint nod_flag, ...@@ -936,8 +938,9 @@ uint _ma_get_binary_pack_key(register MARIA_KEYDEF *keyinfo, uint nod_flag,
{ {
if (length > keyinfo->maxlength) if (length > keyinfo->maxlength)
{ {
DBUG_PRINT("error",("Found too long binary packed key: %u of %u at %lx", DBUG_PRINT("error",
length, keyinfo->maxlength, (long) *page_pos)); ("Found too long binary packed key: %u of %u at 0x%lx",
length, keyinfo->maxlength, (long) *page_pos));
DBUG_DUMP("key",(char*) *page_pos,16); DBUG_DUMP("key",(char*) *page_pos,16);
maria_print_error(keyinfo->share, HA_ERR_CRASHED); maria_print_error(keyinfo->share, HA_ERR_CRASHED);
my_errno=HA_ERR_CRASHED; my_errno=HA_ERR_CRASHED;
...@@ -984,7 +987,7 @@ uint _ma_get_binary_pack_key(register MARIA_KEYDEF *keyinfo, uint nod_flag, ...@@ -984,7 +987,7 @@ uint _ma_get_binary_pack_key(register MARIA_KEYDEF *keyinfo, uint nod_flag,
length-=tmp; length-=tmp;
from=page; from_end=page_end; from=page; from_end=page_end;
} }
DBUG_PRINT("info",("key: %lx from: %lx length: %u", DBUG_PRINT("info",("key: 0x%lx from: 0x%lx length: %u",
(long) key, (long) from, length)); (long) key, (long) from, length));
memmove((byte*) key, (byte*) from, (size_t) length); memmove((byte*) key, (byte*) from, (size_t) length);
key+=length; key+=length;
...@@ -1042,7 +1045,7 @@ uchar *_ma_get_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *page, ...@@ -1042,7 +1045,7 @@ uchar *_ma_get_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *page,
} }
} }
} }
DBUG_PRINT("exit",("page: %lx length: %u", (long) page, DBUG_PRINT("exit",("page: 0x%lx length: %u", (long) page,
*return_key_length)); *return_key_length));
DBUG_RETURN(page); DBUG_RETURN(page);
} /* _ma_get_key */ } /* _ma_get_key */
...@@ -1095,7 +1098,8 @@ uchar *_ma_get_last_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *page, ...@@ -1095,7 +1098,8 @@ uchar *_ma_get_last_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *page,
uint nod_flag; uint nod_flag;
uchar *lastpos; uchar *lastpos;
DBUG_ENTER("_ma_get_last_key"); DBUG_ENTER("_ma_get_last_key");
DBUG_PRINT("enter",("page: %lx endpos: %lx", (long) page, (long) endpos)); DBUG_PRINT("enter",("page: 0x%lx endpos: 0x%lx", (long) page,
(long) endpos));
nod_flag=_ma_test_if_nod(page); nod_flag=_ma_test_if_nod(page);
if (! (keyinfo->flag & (HA_VAR_LENGTH_KEY | HA_BINARY_PACK_KEY))) if (! (keyinfo->flag & (HA_VAR_LENGTH_KEY | HA_BINARY_PACK_KEY)))
...@@ -1115,7 +1119,7 @@ uchar *_ma_get_last_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *page, ...@@ -1115,7 +1119,7 @@ uchar *_ma_get_last_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *page,
*return_key_length=(*keyinfo->get_key)(keyinfo,nod_flag,&page,lastkey); *return_key_length=(*keyinfo->get_key)(keyinfo,nod_flag,&page,lastkey);
if (*return_key_length == 0) if (*return_key_length == 0)
{ {
DBUG_PRINT("error",("Couldn't find last key: page: %lx", DBUG_PRINT("error",("Couldn't find last key: page: 0x%lx",
(long) page)); (long) page));
maria_print_error(info->s, HA_ERR_CRASHED); maria_print_error(info->s, HA_ERR_CRASHED);
my_errno=HA_ERR_CRASHED; my_errno=HA_ERR_CRASHED;
...@@ -1123,7 +1127,7 @@ uchar *_ma_get_last_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *page, ...@@ -1123,7 +1127,7 @@ uchar *_ma_get_last_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *page,
} }
} }
} }
DBUG_PRINT("exit",("lastpos: %lx length: %u", (long) lastpos, DBUG_PRINT("exit",("lastpos: 0x%lx length: %u", (long) lastpos,
*return_key_length)); *return_key_length));
DBUG_RETURN(lastpos); DBUG_RETURN(lastpos);
} /* _ma_get_last_key */ } /* _ma_get_last_key */
...@@ -1472,7 +1476,7 @@ _ma_calc_var_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag, ...@@ -1472,7 +1476,7 @@ _ma_calc_var_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag,
if (!*key++) if (!*key++)
{ {
s_temp->key=key; s_temp->key=key;
s_temp->ref_length=s_temp->key_length=0; s_temp->key_length=0;
s_temp->totlength=key_length-1+diff_flag; s_temp->totlength=key_length-1+diff_flag;
s_temp->next_key_pos=0; /* No next key */ s_temp->next_key_pos=0; /* No next key */
return (s_temp->totlength); return (s_temp->totlength);
...@@ -1627,12 +1631,12 @@ _ma_calc_var_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag, ...@@ -1627,12 +1631,12 @@ _ma_calc_var_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag,
s_temp->prev_length= org_key_length; s_temp->prev_length= org_key_length;
s_temp->n_ref_length=s_temp->n_length= org_key_length; s_temp->n_ref_length=s_temp->n_length= org_key_length;
length+= org_key_length; length+= org_key_length;
/* +get_pack_length(org_key_length); */
} }
return (int) length; return (int) length;
} }
ref_length=n_length; ref_length=n_length;
/* Get information about not packed key suffix */
get_key_pack_length(n_length,next_length_pack,next_key); get_key_pack_length(n_length,next_length_pack,next_key);
/* Test if new keys has fewer characters that match the previous key */ /* Test if new keys has fewer characters that match the previous key */
...@@ -1641,7 +1645,6 @@ _ma_calc_var_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag, ...@@ -1641,7 +1645,6 @@ _ma_calc_var_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag,
s_temp->part_of_prev_key= 0; s_temp->part_of_prev_key= 0;
s_temp->prev_length= ref_length; s_temp->prev_length= ref_length;
s_temp->n_ref_length= s_temp->n_length= n_length+ref_length; s_temp->n_ref_length= s_temp->n_length= n_length+ref_length;
/* s_temp->prev_key+= get_pack_length(org_key_length); */
return (int) length+ref_length-next_length_pack; return (int) length+ref_length-next_length_pack;
} }
if (ref_length+pack_marker > new_ref_length) if (ref_length+pack_marker > new_ref_length)
...@@ -1652,9 +1655,7 @@ _ma_calc_var_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag, ...@@ -1652,9 +1655,7 @@ _ma_calc_var_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag,
s_temp->prev_length= ref_length - new_pack_length; s_temp->prev_length= ref_length - new_pack_length;
s_temp->n_ref_length=s_temp->n_length=n_length + s_temp->prev_length; s_temp->n_ref_length=s_temp->n_length=n_length + s_temp->prev_length;
s_temp->prev_key+= new_pack_length; s_temp->prev_key+= new_pack_length;
/* +get_pack_length(org_key_length); */ length-= (next_length_pack - get_pack_length(s_temp->n_length));
length= length-get_pack_length(ref_length)+
get_pack_length(new_pack_length);
return (int) length + s_temp->prev_length; return (int) length + s_temp->prev_length;
} }
} }
...@@ -1664,7 +1665,7 @@ _ma_calc_var_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag, ...@@ -1664,7 +1665,7 @@ _ma_calc_var_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag,
ref_length=0; ref_length=0;
next_length_pack=0; next_length_pack=0;
} }
DBUG_PRINT("test",("length: %d next_key: %lx", length, DBUG_PRINT("test",("length: %d next_key: 0x%lx", length,
(long) next_key)); (long) next_key));
{ {
......
...@@ -442,6 +442,7 @@ pthread_handler_t _ma_thr_find_all_keys(void *arg) ...@@ -442,6 +442,7 @@ pthread_handler_t _ma_thr_find_all_keys(void *arg)
close_cached_file(&info->tempfile_for_exceptions); close_cached_file(&info->tempfile_for_exceptions);
ok: ok:
free_root(&info->wordroot, MYF(0));
remove_io_thread(&info->read_cache); remove_io_thread(&info->read_cache);
pthread_mutex_lock(&info->sort_info->mutex); pthread_mutex_lock(&info->sort_info->mutex);
info->sort_info->threads_running--; info->sort_info->threads_running--;
......
...@@ -96,6 +96,7 @@ static int run_test(const char *filename) ...@@ -96,6 +96,7 @@ static int run_test(const char *filename)
/* Define a key over the first column */ /* Define a key over the first column */
keyinfo[0].seg=keyseg; keyinfo[0].seg=keyseg;
keyinfo[0].keysegs=1; keyinfo[0].keysegs=1;
keyinfo[0].block_length= 0; /* Default block length */
keyinfo[0].key_alg=HA_KEY_ALG_BTREE; keyinfo[0].key_alg=HA_KEY_ALG_BTREE;
keyinfo[0].seg[0].type= key_type; keyinfo[0].seg[0].type= key_type;
keyinfo[0].seg[0].flag= pack_seg; keyinfo[0].seg[0].flag= pack_seg;
......
...@@ -96,6 +96,7 @@ int main(int argc, char *argv[]) ...@@ -96,6 +96,7 @@ int main(int argc, char *argv[])
keyinfo[0].key_alg=HA_KEY_ALG_BTREE; keyinfo[0].key_alg=HA_KEY_ALG_BTREE;
keyinfo[0].keysegs=1; keyinfo[0].keysegs=1;
keyinfo[0].flag = pack_type; keyinfo[0].flag = pack_type;
keyinfo[0].block_length= 0; /* Default block length */
keyinfo[1].seg= &glob_keyseg[1][0]; keyinfo[1].seg= &glob_keyseg[1][0];
keyinfo[1].seg[0].start=7; keyinfo[1].seg[0].start=7;
keyinfo[1].seg[0].length=6; keyinfo[1].seg[0].length=6;
...@@ -112,6 +113,7 @@ int main(int argc, char *argv[]) ...@@ -112,6 +113,7 @@ int main(int argc, char *argv[])
keyinfo[1].key_alg=HA_KEY_ALG_BTREE; keyinfo[1].key_alg=HA_KEY_ALG_BTREE;
keyinfo[1].keysegs=2; keyinfo[1].keysegs=2;
keyinfo[1].flag =0; keyinfo[1].flag =0;
keyinfo[1].block_length= MARIA_MIN_KEY_BLOCK_LENGTH; /* Diff blocklength */
keyinfo[2].seg= &glob_keyseg[2][0]; keyinfo[2].seg= &glob_keyseg[2][0];
keyinfo[2].seg[0].start=12; keyinfo[2].seg[0].start=12;
keyinfo[2].seg[0].length=8; keyinfo[2].seg[0].length=8;
...@@ -122,6 +124,7 @@ int main(int argc, char *argv[]) ...@@ -122,6 +124,7 @@ int main(int argc, char *argv[])
keyinfo[2].key_alg=HA_KEY_ALG_BTREE; keyinfo[2].key_alg=HA_KEY_ALG_BTREE;
keyinfo[2].keysegs=1; keyinfo[2].keysegs=1;
keyinfo[2].flag =HA_NOSAME; keyinfo[2].flag =HA_NOSAME;
keyinfo[2].block_length= 0; /* Default block length */
keyinfo[3].seg= &glob_keyseg[3][0]; keyinfo[3].seg= &glob_keyseg[3][0];
keyinfo[3].seg[0].start=0; keyinfo[3].seg[0].start=0;
keyinfo[3].seg[0].length=reclength-(use_blob ? 8 : 0); keyinfo[3].seg[0].length=reclength-(use_blob ? 8 : 0);
...@@ -133,6 +136,7 @@ int main(int argc, char *argv[]) ...@@ -133,6 +136,7 @@ int main(int argc, char *argv[])
keyinfo[3].key_alg=HA_KEY_ALG_BTREE; keyinfo[3].key_alg=HA_KEY_ALG_BTREE;
keyinfo[3].keysegs=1; keyinfo[3].keysegs=1;
keyinfo[3].flag = pack_type; keyinfo[3].flag = pack_type;
keyinfo[3].block_length= 0; /* Default block length */
keyinfo[4].seg= &glob_keyseg[4][0]; keyinfo[4].seg= &glob_keyseg[4][0];
keyinfo[4].seg[0].start=0; keyinfo[4].seg[0].start=0;
keyinfo[4].seg[0].length=5; keyinfo[4].seg[0].length=5;
...@@ -144,6 +148,7 @@ int main(int argc, char *argv[]) ...@@ -144,6 +148,7 @@ int main(int argc, char *argv[])
keyinfo[4].key_alg=HA_KEY_ALG_BTREE; keyinfo[4].key_alg=HA_KEY_ALG_BTREE;
keyinfo[4].keysegs=1; keyinfo[4].keysegs=1;
keyinfo[4].flag = pack_type; keyinfo[4].flag = pack_type;
keyinfo[4].block_length= 0; /* Default block length */
keyinfo[5].seg= &glob_keyseg[5][0]; keyinfo[5].seg= &glob_keyseg[5][0];
keyinfo[5].seg[0].start=0; keyinfo[5].seg[0].start=0;
keyinfo[5].seg[0].length=4; keyinfo[5].seg[0].length=4;
...@@ -155,6 +160,7 @@ int main(int argc, char *argv[]) ...@@ -155,6 +160,7 @@ int main(int argc, char *argv[])
keyinfo[5].key_alg=HA_KEY_ALG_BTREE; keyinfo[5].key_alg=HA_KEY_ALG_BTREE;
keyinfo[5].keysegs=1; keyinfo[5].keysegs=1;
keyinfo[5].flag = pack_type; keyinfo[5].flag = pack_type;
keyinfo[5].block_length= 0; /* Default block length */
recinfo[0].type=pack_fields ? FIELD_SKIP_PRESPACE : 0; recinfo[0].type=pack_fields ? FIELD_SKIP_PRESPACE : 0;
recinfo[0].length=7; recinfo[0].length=7;
...@@ -701,7 +707,7 @@ int main(int argc, char *argv[]) ...@@ -701,7 +707,7 @@ int main(int argc, char *argv[])
if (!silent) if (!silent)
printf("- maria_extra(CACHE) + maria_rrnd.... + maria_extra(NO_CACHE)\n"); printf("- maria_extra(CACHE) + maria_rrnd.... + maria_extra(NO_CACHE)\n");
if (maria_extra(file,HA_EXTRA_RESET,0) || maria_extra(file,HA_EXTRA_CACHE,0)) if (maria_reset(file) || maria_extra(file,HA_EXTRA_CACHE,0))
{ {
if (locking || (!use_blob && !pack_fields)) if (locking || (!use_blob && !pack_fields))
{ {
...@@ -744,7 +750,7 @@ int main(int argc, char *argv[]) ...@@ -744,7 +750,7 @@ int main(int argc, char *argv[])
DBUG_PRINT("progpos",("Removing keys")); DBUG_PRINT("progpos",("Removing keys"));
lastpos = HA_OFFSET_ERROR; lastpos = HA_OFFSET_ERROR;
/* DBUG_POP(); */ /* DBUG_POP(); */
maria_extra(file,HA_EXTRA_RESET,0); maria_reset(file);
found_parts=0; found_parts=0;
while ((error=maria_rrnd(file,read_record,HA_OFFSET_ERROR)) != while ((error=maria_rrnd(file,read_record,HA_OFFSET_ERROR)) !=
HA_ERR_END_OF_FILE) HA_ERR_END_OF_FILE)
...@@ -911,13 +917,13 @@ static void get_options(int argc, char **argv) ...@@ -911,13 +917,13 @@ static void get_options(int argc, char **argv)
} }
break; break;
case 'e': /* maria_block_length */ case 'e': /* maria_block_length */
if ((maria_block_size=atoi(++pos)) < MARIA_MIN_KEY_BLOCK_LENGTH || if ((maria_block_size= atoi(++pos)) < MARIA_MIN_KEY_BLOCK_LENGTH ||
maria_block_size > MARIA_MAX_KEY_BLOCK_LENGTH) maria_block_size > MARIA_MAX_KEY_BLOCK_LENGTH)
{ {
fprintf(stderr,"Wrong maria_block_length\n"); fprintf(stderr,"Wrong maria_block_length\n");
exit(1); exit(1);
} }
maria_block_size=1 << my_bit_log2(maria_block_size); maria_block_size= my_round_up_to_next_power(maria_block_size);
break; break;
case 'E': /* maria_block_length */ case 'E': /* maria_block_length */
if ((key_cache_block_size=atoi(++pos)) < MARIA_MIN_KEY_BLOCK_LENGTH || if ((key_cache_block_size=atoi(++pos)) < MARIA_MIN_KEY_BLOCK_LENGTH ||
...@@ -926,7 +932,7 @@ static void get_options(int argc, char **argv) ...@@ -926,7 +932,7 @@ static void get_options(int argc, char **argv)
fprintf(stderr,"Wrong key_cache_block_size\n"); fprintf(stderr,"Wrong key_cache_block_size\n");
exit(1); exit(1);
} }
key_cache_block_size=1 << my_bit_log2(key_cache_block_size); key_cache_block_size= my_round_up_to_next_power(key_cache_block_size);
break; break;
case 'f': case 'f':
if ((first_key=atoi(++pos)) < 0 || first_key >= MARIA_KEYS) if ((first_key=atoi(++pos)) < 0 || first_key >= MARIA_KEYS)
......
...@@ -77,6 +77,7 @@ int main(int argc,char **argv) ...@@ -77,6 +77,7 @@ int main(int argc,char **argv)
keyinfo[0].key_alg=HA_KEY_ALG_BTREE; keyinfo[0].key_alg=HA_KEY_ALG_BTREE;
keyinfo[0].keysegs=1; keyinfo[0].keysegs=1;
keyinfo[0].flag = (uint8) HA_PACK_KEY; keyinfo[0].flag = (uint8) HA_PACK_KEY;
keyinfo[0].block_length= 0; /* Default block length */
keyinfo[1].seg= &keyseg[1][0]; keyinfo[1].seg= &keyseg[1][0];
keyinfo[1].seg[0].start=8; keyinfo[1].seg[0].start=8;
keyinfo[1].seg[0].length=4; /* Long is always 4 in maria */ keyinfo[1].seg[0].length=4; /* Long is always 4 in maria */
...@@ -85,6 +86,7 @@ int main(int argc,char **argv) ...@@ -85,6 +86,7 @@ int main(int argc,char **argv)
keyinfo[1].key_alg=HA_KEY_ALG_BTREE; keyinfo[1].key_alg=HA_KEY_ALG_BTREE;
keyinfo[1].keysegs=1; keyinfo[1].keysegs=1;
keyinfo[1].flag =HA_NOSAME; keyinfo[1].flag =HA_NOSAME;
keyinfo[1].block_length= 0; /* Default block length */
recinfo[0].type=0; recinfo[0].type=0;
recinfo[0].length=sizeof(record.id); recinfo[0].length=sizeof(record.id);
......
...@@ -164,7 +164,8 @@ int maria_update(register MARIA_HA *info, const byte *oldrec, byte *newrec) ...@@ -164,7 +164,8 @@ int maria_update(register MARIA_HA *info, const byte *oldrec, byte *newrec)
key_changed|= HA_STATE_CHANGED; /* Must update index file */ key_changed|= HA_STATE_CHANGED; /* Must update index file */
} }
if (auto_key_changed) if (auto_key_changed)
_ma_update_auto_increment(info,newrec); set_if_bigger(info->s->state.auto_increment,
ma_retrieve_auto_increment(info, newrec));
if (share->calc_checksum) if (share->calc_checksum)
info->state->checksum+=(info->checksum - old_checksum); info->state->checksum+=(info->checksum - old_checksum);
......
...@@ -145,7 +145,8 @@ int maria_write(MARIA_HA *info, byte *record) ...@@ -145,7 +145,8 @@ int maria_write(MARIA_HA *info, byte *record)
info->state->checksum+=info->checksum; info->state->checksum+=info->checksum;
} }
if (share->base.auto_key) if (share->base.auto_key)
_ma_update_auto_increment(info,record); set_if_bigger(info->s->state.auto_increment,
ma_retrieve_auto_increment(info, record));
info->update= (HA_STATE_CHANGED | HA_STATE_AKTIV | HA_STATE_WRITTEN | info->update= (HA_STATE_CHANGED | HA_STATE_AKTIV | HA_STATE_WRITTEN |
HA_STATE_ROW_CHANGED); HA_STATE_ROW_CHANGED);
info->state->records++; info->state->records++;
......
...@@ -34,10 +34,6 @@ SET_STACK_SIZE(9000) /* Minimum stack size for program */ ...@@ -34,10 +34,6 @@ SET_STACK_SIZE(9000) /* Minimum stack size for program */
#define my_raid_delete(A,B,C) my_delete(A,B) #define my_raid_delete(A,B,C) my_delete(A,B)
#endif #endif
#ifdef OS2
#define _sanity(a,b)
#endif
static uint decode_bits; static uint decode_bits;
static char **default_argv; static char **default_argv;
static const char *load_default_groups[]= { "mariachk", 0 }; static const char *load_default_groups[]= { "mariachk", 0 };
...@@ -92,10 +88,6 @@ int main(int argc, char **argv) ...@@ -92,10 +88,6 @@ int main(int argc, char **argv)
MY_INIT(argv[0]); MY_INIT(argv[0]);
my_progname_short= my_progname+dirname_length(my_progname); my_progname_short= my_progname+dirname_length(my_progname);
#ifdef __EMX__
_wildcard (&argc, &argv);
#endif
mariachk_init(&check_param); mariachk_init(&check_param);
check_param.opt_lock_memory= 1; /* Lock memory if possible */ check_param.opt_lock_memory= 1; /* Lock memory if possible */
check_param.using_global_keycache = 0; check_param.using_global_keycache = 0;
...@@ -381,7 +373,7 @@ static void usage(void) ...@@ -381,7 +373,7 @@ static void usage(void)
directly with '--variable-name=value'.\n\ directly with '--variable-name=value'.\n\
-t, --tmpdir=path Path for temporary files. Multiple paths can be\n\ -t, --tmpdir=path Path for temporary files. Multiple paths can be\n\
specified, separated by "); specified, separated by ");
#if defined( __WIN__) || defined(OS2) || defined(__NETWARE__) #if defined( __WIN__) || defined(__NETWARE__)
printf("semicolon (;)"); printf("semicolon (;)");
#else #else
printf("colon (:)"); printf("colon (:)");
......
...@@ -55,7 +55,7 @@ typedef struct st_maria_state_info ...@@ -55,7 +55,7 @@ typedef struct st_maria_state_info
uchar keys; /* number of keys in file */ uchar keys; /* number of keys in file */
uchar uniques; /* number of UNIQUE definitions */ uchar uniques; /* number of UNIQUE definitions */
uchar language; /* Language for indexes */ uchar language; /* Language for indexes */
uchar max_block_size; /* max keyblock size */ uchar max_block_size_index; /* max keyblock size */
uchar fulltext_keys; uchar fulltext_keys;
uchar not_used; /* To align to 8 */ uchar not_used; /* To align to 8 */
} header; } header;
...@@ -246,6 +246,7 @@ struct st_maria_info ...@@ -246,6 +246,7 @@ struct st_maria_info
/* accumulate indexfile changes between write's */ /* accumulate indexfile changes between write's */
TREE *bulk_insert; TREE *bulk_insert;
DYNAMIC_ARRAY *ft1_to_ft2; /* used only in ft1->ft2 conversion */ DYNAMIC_ARRAY *ft1_to_ft2; /* used only in ft1->ft2 conversion */
MEM_ROOT ft_memroot; /* used by the parser */
MYSQL_FTPARSER_PARAM *ftparser_param; /* share info between init/deinit */ MYSQL_FTPARSER_PARAM *ftparser_param; /* share info between init/deinit */
char *filename; /* parameter to open filename */ char *filename; /* parameter to open filename */
uchar *buff, /* Temp area for key */ uchar *buff, /* Temp area for key */
...@@ -398,7 +399,7 @@ struct st_maria_info ...@@ -398,7 +399,7 @@ struct st_maria_info
#define MARIA_FOUND_WRONG_KEY 32738 /* Impossible value from ha_key_cmp */ #define MARIA_FOUND_WRONG_KEY 32738 /* Impossible value from ha_key_cmp */
#define MARIA_MAX_KEY_BLOCK_SIZE (MARIA_MAX_KEY_BLOCK_LENGTH/MARIA_MIN_KEY_BLOCK_LENGTH) #define MARIA_MAX_KEY_BLOCK_SIZE (MARIA_MAX_KEY_BLOCK_LENGTH/MARIA_MIN_KEY_BLOCK_LENGTH)
#define MARIA_BLOCK_SIZE(key_length,data_pointer,key_pointer) (((((key_length)+(data_pointer)+(key_pointer))*4+(key_pointer)+2)/maria_block_size+1)*maria_block_size) #define MARIA_BLOCK_SIZE(key_length,data_pointer,key_pointer,block_size) (((((key_length)+(data_pointer)+(key_pointer))*4+(key_pointer)+2)/(block_size)+1)*(block_size))
#define MARIA_MAX_KEYPTR_SIZE 5 /* For calculating block lengths */ #define MARIA_MAX_KEYPTR_SIZE 5 /* For calculating block lengths */
#define MARIA_MIN_KEYBLOCK_LENGTH 50 /* When to split delete blocks */ #define MARIA_MIN_KEYBLOCK_LENGTH 50 /* When to split delete blocks */
...@@ -572,7 +573,7 @@ extern int _ma_read_key_record(MARIA_HA *info, my_off_t filepos, ...@@ -572,7 +573,7 @@ extern int _ma_read_key_record(MARIA_HA *info, my_off_t filepos,
byte *buf); byte *buf);
extern int _ma_read_cache(IO_CACHE *info, byte *buff, my_off_t pos, extern int _ma_read_cache(IO_CACHE *info, byte *buff, my_off_t pos,
uint length, int re_read_if_possibly); uint length, int re_read_if_possibly);
extern void _ma_update_auto_increment(MARIA_HA *info, const byte *record); extern ulonglong ma_retrieve_auto_increment(MARIA_HA *info, const byte *record);
extern byte *_ma_alloc_rec_buff(MARIA_HA *, ulong, byte **); extern byte *_ma_alloc_rec_buff(MARIA_HA *, ulong, byte **);
#define _ma_get_rec_buff_ptr(info,buf) \ #define _ma_get_rec_buff_ptr(info,buf) \
......
...@@ -34,20 +34,20 @@ static uint lengths[256]; ...@@ -34,20 +34,20 @@ static uint lengths[256];
static struct my_option my_long_options[] = static struct my_option my_long_options[] =
{ {
{"dump", 'd', "Dump index (incl. data offsets and word weights).", {"help", 'h', "Display help and exit.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"stats", 's', "Report global stats.", {"help", '?', "Synonym for -h.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"verbose", 'v', "Be verbose.",
(gptr*) &verbose, (gptr*) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{"count", 'c', "Calculate per-word stats (counts and global weights).", {"count", 'c', "Calculate per-word stats (counts and global weights).",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"length", 'l', "Report length distribution.", {"dump", 'd', "Dump index (incl. data offsets and word weights).",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"help", 'h', "Display help and exit.", {"length", 'l', "Report length distribution.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"help", '?', "Synonym for -h.", {"stats", 's', "Report global stats.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"verbose", 'v', "Be verbose.",
(gptr*) &verbose, (gptr*) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
}; };
...@@ -87,7 +87,8 @@ int main(int argc,char *argv[]) ...@@ -87,7 +87,8 @@ int main(int argc,char *argv[])
init_key_cache(maria_key_cache,MARIA_KEY_BLOCK_LENGTH,USE_BUFFER_INIT, 0, 0); init_key_cache(maria_key_cache,MARIA_KEY_BLOCK_LENGTH,USE_BUFFER_INIT, 0, 0);
if (!(info=maria_open(argv[0],2,HA_OPEN_ABORT_IF_LOCKED|HA_OPEN_FROM_SQL_LAYER))) if (!(info=maria_open(argv[0], O_RDONLY,
HA_OPEN_ABORT_IF_LOCKED|HA_OPEN_FROM_SQL_LAYER)))
{ {
error=my_errno; error=my_errno;
goto err; goto err;
......
...@@ -2968,7 +2968,7 @@ static int save_state(MARIA_HA *isam_file,PACK_MRG_INFO *mrg,my_off_t new_length ...@@ -2968,7 +2968,7 @@ static int save_state(MARIA_HA *isam_file,PACK_MRG_INFO *mrg,my_off_t new_length
maria_clear_all_keys_active(share->state.key_map); maria_clear_all_keys_active(share->state.key_map);
for (key=0 ; key < share->base.keys ; key++) for (key=0 ; key < share->base.keys ; key++)
share->state.key_root[key]= HA_OFFSET_ERROR; share->state.key_root[key]= HA_OFFSET_ERROR;
for (key=0 ; key < share->state.header.max_block_size ; key++) for (key=0 ; key < share->state.header.max_block_size_index ; key++)
share->state.key_del[key]= HA_OFFSET_ERROR; share->state.key_del[key]= HA_OFFSET_ERROR;
isam_file->state->checksum=crc; /* Save crc here */ isam_file->state->checksum=crc; /* Save crc here */
share->changed=1; /* Force write of header */ share->changed=1; /* Force write of header */
...@@ -3035,7 +3035,7 @@ static int mrg_rrnd(PACK_MRG_INFO *info,byte *buf) ...@@ -3035,7 +3035,7 @@ static int mrg_rrnd(PACK_MRG_INFO *info,byte *buf)
{ {
isam_info= *(info->current=info->file); isam_info= *(info->current=info->file);
info->end=info->current+info->count; info->end=info->current+info->count;
maria_extra(isam_info, HA_EXTRA_RESET, 0); maria_reset(isam_info);
maria_extra(isam_info, HA_EXTRA_CACHE, 0); maria_extra(isam_info, HA_EXTRA_CACHE, 0);
filepos=isam_info->s->pack.header_length; filepos=isam_info->s->pack.header_length;
} }
...@@ -3058,7 +3058,7 @@ static int mrg_rrnd(PACK_MRG_INFO *info,byte *buf) ...@@ -3058,7 +3058,7 @@ static int mrg_rrnd(PACK_MRG_INFO *info,byte *buf)
info->current++; info->current++;
isam_info= *info->current; isam_info= *info->current;
filepos=isam_info->s->pack.header_length; filepos=isam_info->s->pack.header_length;
maria_extra(isam_info,HA_EXTRA_RESET, 0); maria_reset(isam_info);
maria_extra(isam_info,HA_EXTRA_CACHE, 0); maria_extra(isam_info,HA_EXTRA_CACHE, 0);
} }
} }
......
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