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
This commit is contained in:
unknown 2006-08-10 16:36:54 +02:00
parent 381fdf1a67
commit 99c431db92
43 changed files with 952 additions and 528 deletions

View file

@ -1,29 +0,0 @@
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 ---------------------------------------------------------------------------

View file

@ -2200,15 +2200,16 @@ MYSQL_PLUGIN_ACTIONS(ndbcluster,[MYSQL_SETUP_NDBCLUSTER])
MYSQL_STORAGE_ENGINE(partition, partition, [Partition Support],
[MySQL Partitioning Support], [max,max-no-ndb])
MYSQL_STORAGE_ENGINE(maria,maria, [Maria Storage Engine],
[Traditional transactional MySQL tables])
MYSQL_PLUGIN_DIRECTORY(maria, [storage/maria])
MYSQL_PLUGIN_STATIC(maria, [libmaria.a])
MYSQL_PLUGIN_MANDATORY(maria)
dnl -- ndbcluster requires partition to be enabled
MYSQL_PLUGIN_DEPENDS(ndbcluster, [partition])
MYSQL_STORAGE_ENGINE(maria,maria, [Maria Storage Engine],
[Traditional transactional MySQL tables], [max,max-no-ndb])
MYSQL_PLUGIN_DIRECTORY(maria, [storage/maria])
MYSQL_PLUGIN_STATIC(maria, [libmaria.a])
MYSQL_PLUGIN_MANDATORY(maria)
MYSQL_CONFIGURE_PLUGINS([none])
# Only build client code?

View file

@ -168,7 +168,7 @@ typedef struct st_maria_keydef /* Key definition with open & info */
uint16 keylength; /* Tot length of keyparts (auto) */
uint16 minlength; /* min 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 ftparser_nr; /* distinct ftparser number */
@ -235,7 +235,6 @@ typedef struct st_maria_columndef /* column information */
} MARIA_COLUMNDEF;
extern my_string maria_log_filename; /* Name of logfile */
extern ulong maria_block_size;
extern ulong maria_concurrent_insert;
extern my_bool maria_flush, maria_delay_key_write, maria_single_user;
@ -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_extra(struct st_maria_info *file,
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,
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_delete_all_rows(struct st_maria_info *info);
extern uint maria_get_pointer_length(ulonglong file_length, uint def);
@ -328,6 +327,7 @@ typedef struct st_maria_sort_param
uchar **sort_keys;
byte *rec_buff;
void *wordlist, *wordptr;
MEM_ROOT wordroot;
char *record;
MY_TMPDIR *tmpdir;

View file

@ -18,8 +18,6 @@
#ifndef _my_handler_h
#define _my_handler_h
#include "my_base.h"
#include "m_ctype.h"
#include "myisampack.h"
/*

View file

@ -334,6 +334,7 @@ typedef struct st_mi_sort_param
uchar **sort_keys;
byte *rec_buff;
void *wordlist, *wordptr;
MEM_ROOT wordroot;
char *record;
MY_TMPDIR *tmpdir;

View file

@ -1,9 +1,11 @@
set global storage_engine=maria;
set session storage_engine=maria;
drop table if exists t1,t2;
SET SQL_WARNINGS=1;
CREATE TABLE t1 (
STRING_DATA char(255) default NULL,
KEY string_data (STRING_DATA)
) ENGINE=MARIA;
);
INSERT INTO t1 VALUES ('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
INSERT INTO t1 VALUES ('DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD');
INSERT INTO t1 VALUES ('FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF');
@ -14,7 +16,7 @@ CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
create table t1 (a tinyint not null auto_increment, b blob not null, primary key (a)) engine=maria;
create table t1 (a tinyint not null auto_increment, b blob not null, primary key (a));
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
@ -32,7 +34,7 @@ check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
create table t1 (a int not null auto_increment, b int not null, primary key (a), index(b)) engine=maria;
create table t1 (a int not null auto_increment, b int not null, primary key (a), index(b));
insert into t1 (b) values (1),(2),(2),(2),(2);
optimize table t1;
Table Op Msg_type Msg_text
@ -49,7 +51,7 @@ Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_par
t1 0 PRIMARY 1 a A 5 NULL NULL BTREE
t1 1 b 1 b A 1 NULL NULL BTREE
drop table t1;
create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=maria;
create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b));
insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
explain select * from t1 order by a;
id select_type table type possible_keys key key_len ref rows Extra
@ -76,7 +78,7 @@ explain select a,b,c from t1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 4
drop table t1;
CREATE TABLE t1 (a INT) engine=maria;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1), (2), (3);
LOCK TABLES t1 WRITE;
INSERT INTO t1 VALUES (1), (2), (3);
@ -84,7 +86,7 @@ OPTIMIZE TABLE t1;
Table Op Msg_type Msg_text
test.t1 optimize status OK
DROP TABLE t1;
create table t1 ( t1 char(255), key(t1(250))) engine=maria;
create table t1 ( t1 char(255), key(t1(250)));
insert t1 values ('137513751375137513751375137513751375137569516951695169516951695169516951695169');
insert t1 values ('178417841784178417841784178417841784178403420342034203420342034203420342034203');
insert t1 values ('213872387238723872387238723872387238723867376737673767376737673767376737673767');
@ -245,7 +247,7 @@ int, i967 int, i968 int, i969 int, i970 int, i971 int, i972 int, i973 int, i974
int, i975 int, i976 int, i977 int, i978 int, i979 int, i980 int, i981 int, i982
int, i983 int, i984 int, i985 int, i986 int, i987 int, i988 int, i989 int, i990
int, i991 int, i992 int, i993 int, i994 int, i995 int, i996 int, i997 int, i998
int, i999 int, i1000 int, b blob) row_format=dynamic engine=maria;
int, i999 int, i1000 int, b blob) row_format=dynamic;
insert into t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@ -313,7 +315,7 @@ KEY `ip` (`ip`),
KEY `poster_login` (`poster_login`),
KEY `topic_id` (`topic_id`),
FULLTEXT KEY `post_text` (`post_text`)
) ENGINE=MARIA;
);
INSERT INTO t1 (post_text) VALUES ('ceci est un test'),('ceci est un test'),('ceci est un test'),('ceci est un test'),('ceci est un test');
REPAIR TABLE t1;
Table Op Msg_type Msg_text
@ -322,15 +324,15 @@ CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
CREATE TABLE t1 (a varchar(255), b varchar(255), c varchar(255), d varchar(255), e varchar(255), KEY t1 (a, b, c, d, e)) engine=maria;
CREATE TABLE t1 (a varchar(255), b varchar(255), c varchar(255), d varchar(255), e varchar(255), KEY t1 (a, b, c, d, e));
ERROR 42000: Specified key was too long; max key length is 1000 bytes
CREATE TABLE t1 (a varchar(255), b varchar(255), c varchar(255), d varchar(255), e varchar(255)) engine=maria;
CREATE TABLE t1 (a varchar(255), b varchar(255), c varchar(255), d varchar(255), e varchar(255));
ALTER TABLE t1 ADD INDEX t1 (a, b, c, d, e);
ERROR 42000: Specified key was too long; max key length is 1000 bytes
DROP TABLE t1;
CREATE TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a)) engine=maria;
CREATE TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a));
INSERT into t1 values (0, null, 0), (0, null, 1), (0, null, 2), (0, null,3), (1,1,4);
create table t2 (a int not null, b int, c int, key(b), key(c), key(a)) engine=maria;
create table t2 (a int not null, b int, c int, key(b), key(c), key(a));
INSERT into t2 values (1,1,1), (2,2,2);
optimize table t1;
Table Op Msg_type Msg_text
@ -346,11 +348,11 @@ t1 1 c_2 2 a A 5 NULL NULL BTREE
explain select * from t1,t2 where t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL a NULL NULL NULL 2
1 SIMPLE t1 ALL a NULL NULL NULL 4 Using where
1 SIMPLE t1 ALL a NULL NULL NULL 5 Using where
explain select * from t1,t2 force index(a) where t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL a NULL NULL NULL 2
1 SIMPLE t1 ALL a NULL NULL NULL 4 Using where
1 SIMPLE t1 ALL a NULL NULL NULL 5 Using where
explain select * from t1 force index(a),t2 force index(a) where t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL a NULL NULL NULL 2
@ -362,7 +364,7 @@ id select_type table type possible_keys key key_len ref rows Extra
explain select * from t1,t2 force index(c) where t1.a=t2.a;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ALL NULL NULL NULL NULL 2
1 SIMPLE t1 ALL a NULL NULL NULL 4 Using where
1 SIMPLE t1 ALL a NULL NULL NULL 5 Using where
explain select * from t1 where a=0 or a=2;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL a NULL NULL NULL 5 Using where
@ -376,7 +378,7 @@ explain select * from t1 use index() where c=1;
id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t1 ALL NULL NULL NULL NULL 5 Using where
drop table t1,t2;
create table t1 (a int not null auto_increment primary key, b varchar(255)) engine=maria;
create table t1 (a int not null auto_increment primary key, b varchar(255));
insert into t1 (b) values (repeat('a',100)),(repeat('b',100)),(repeat('c',100));
update t1 set b=repeat(left(b,1),200) where a=1;
delete from t1 where (a & 1)= 0;
@ -398,7 +400,7 @@ check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
create table t1 ( a text not null, key a (a(20))) engine=maria;
create table t1 ( a text not null, key a (a(20)));
insert into t1 values ('aaa '),('aaa'),('aa');
check table t1;
Table Op Msg_type Msg_text
@ -420,7 +422,7 @@ bbb.
bbb.
aa.
drop table t1;
create table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10))) engine=maria;
create table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10)));
insert into t1 values('807780', '477', '165');
insert into t1 values('807780', '477', '162');
insert into t1 values('807780', '472', '162');
@ -431,7 +433,7 @@ drop table t1;
DROP TABLE IF EXISTS t1;
Warnings:
Note 1051 Unknown table 't1'
CREATE TABLE t1 (a varchar(150) NOT NULL, KEY (a)) engine=maria;
CREATE TABLE t1 (a varchar(150) NOT NULL, KEY (a));
INSERT t1 VALUES ("can \tcan");
INSERT t1 VALUES ("can can");
INSERT t1 VALUES ("can");
@ -444,7 +446,7 @@ CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
create table t1 (a blob) engine=maria;
create table t1 (a blob);
insert into t1 values('a '),('a');
select concat(a,'.') from t1 where a='a';
concat(a,'.')
@ -460,7 +462,7 @@ select concat(a,'.') from t1 where a='a ';
concat(a,'.')
a .
drop table t1;
create table t1 (a int not null auto_increment primary key, b text not null, unique b (b(20))) engine=maria;
create table t1 (a int not null auto_increment primary key, b text not null, unique b (b(20)));
insert into t1 (b) values ('a'),('b'),('c');
select concat(b,'.') from t1;
concat(b,'.')
@ -483,8 +485,8 @@ a concat(b,'.')
1 a.
3 c.
drop table t1;
create table t1 (a int not null) engine=maria;
create table t2 (a int not null, primary key (a)) engine=maria;
create table t1 (a int not null);
create table t2 (a int not null, primary key (a));
insert into t1 values (1);
insert into t2 values (1),(2);
select sql_big_result distinct t1.a from t1,t2 order by t2.a;
@ -508,17 +510,17 @@ drop table t1,t2;
create table t1 (
c1 varchar(32),
key (c1)
) engine=maria;
);
alter table t1 disable keys;
insert into t1 values ('a'), ('b');
select c1 from t1 order by c1 limit 1;
c1
a
drop table t1;
CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) ENGINE=MARIA;
CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`));
Got one of the listed errors
create table t1 (a int, b varchar(200), c text not null) checksum=1 engine=maria;
create table t2 (a int, b varchar(200), c text not null) checksum=0 engine=maria;
create table t1 (a int, b varchar(200), c text not null) checksum=1;
create table t2 (a int, b varchar(200), c text not null) checksum=0;
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
insert t2 select * from t1;
checksum table t1, t2, t3 quick;
@ -543,7 +545,7 @@ test.t3 NULL
Warnings:
Error 1146 Table 'test.t3' doesn't exist
drop table t1,t2;
create table t1 (a int, key (a)) engine=maria;
create table t1 (a int, key (a));
show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 1 a 1 a A NULL NULL NULL YES BTREE
@ -551,7 +553,7 @@ alter table t1 disable keys;
show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 1 a 1 a A NULL NULL NULL YES BTREE disabled
create table t2 (a int) engine=maria;
create table t2 (a int);
set @@rand_seed1=31415926,@@rand_seed2=2718281828;
insert t1 select * from t2;
show keys from t1;
@ -569,7 +571,7 @@ show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 1 a 1 a NULL 500 NULL NULL YES HASH
drop table t1,t2;
create table t1 ( a tinytext, b char(1), index idx (a(1),b)) engine=maria;
create table t1 ( a tinytext, b char(1), index idx (a(1),b) );
insert into t1 values (null,''), (null,'');
explain select count(*) from t1 where a is null;
id select_type table type possible_keys key key_len ref rows Extra
@ -579,20 +581,20 @@ count(*)
2
drop table t1;
create table t1 (c1 int, c2 varchar(4) not null default '',
key(c2(3))) default charset=utf8 engine=maria;
key(c2(3))) default charset=utf8;
insert into t1 values (1,'A'), (2, 'B'), (3, 'A');
update t1 set c2='A B' where c1=2;
check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
create table t1 (c1 int) engine=maria;
create table t1 (c1 int);
insert into t1 values (1),(2),(3),(4);
checksum table t1;
Table Checksum
test.t1 149057747
delete from t1 where c1 = 1;
create table t2 engine=maria as select * from t1;
create table t2 as select * from t1;
checksum table t1;
Table Checksum
test.t1 984116287
@ -603,7 +605,7 @@ drop table t1, t2;
show variables like 'maria_stats_method';
Variable_name Value
maria_stats_method nulls_unequal
create table t1 (a int, key(a)) engine=maria;
create table t1 (a int, key(a));
insert into t1 values (0),(1),(2),(3),(4);
insert into t1 select NULL from t1;
analyze table t1;
@ -668,7 +670,7 @@ maria_stats_method nulls_ignored
create table t1 (
a char(3), b char(4), c char(5), d char(6),
key(a,b,c,d)
) engine=maria;
);
insert into t1 values ('bcd','def1', NULL, 'zz');
insert into t1 values ('bcd','def2', NULL, 'zz');
insert into t1 values ('bce','def1', 'yuu', NULL);
@ -699,7 +701,7 @@ cip INT NOT NULL,
time TIME NOT NULL,
score INT NOT NULL DEFAULT 0,
bob TINYBLOB
) engine=maria;
);
insert into t1 (cip, time) VALUES (1, '00:01'), (2, '00:02'), (3,'00:03');
insert into t1 (cip, bob, time) VALUES (4, 'a', '00:04'), (5, 'b', '00:05'),
(6, 'c', '00:06');
@ -729,7 +731,27 @@ select count(id1) from t1 where id2 = 10;
count(id1)
5
drop table t1;
set storage_engine=MARIA;
CREATE TABLE t1(a TINYINT, KEY(a));
INSERT INTO t1 VALUES(1);
SELECT MAX(a) FROM t1 IGNORE INDEX(a);
MAX(a)
1
ALTER TABLE t1 DISABLE KEYS;
SELECT MAX(a) FROM t1;
MAX(a)
1
SELECT MAX(a) FROM t1 IGNORE INDEX(a);
MAX(a)
1
DROP TABLE t1;
CREATE TABLE t1(a CHAR(9), b VARCHAR(7));
INSERT INTO t1(a) VALUES('xxxxxxxxx'),('xxxxxxxxx');
UPDATE t1 AS ta1,t1 AS ta2 SET ta1.b='aaaaaa',ta2.b='bbbbbb';
SELECT * FROM t1;
a b
xxxxxxxxx bbbbbb
xxxxxxxxx bbbbbb
DROP TABLE t1;
drop table if exists t1,t2,t3;
--- Testing varchar ---
--- Testing varchar ---
@ -1301,11 +1323,11 @@ select * from t1 where a=20 and b is null;
a b
20 NULL
drop table t1;
create table t1 (v varchar(65530), key(v)) engine=maria;
create table t1 (v varchar(65530), key(v));
Warnings:
Warning 1071 Specified key was too long; max key length is 1000 bytes
drop table if exists t1;
create table t1 (v varchar(65536)) engine=maria;
create table t1 (v varchar(65536));
Warnings:
Note 1246 Converting column 'v' from VARCHAR to TEXT
show create table t1;
@ -1314,7 +1336,7 @@ t1 CREATE TABLE `t1` (
`v` mediumtext
) ENGINE=MARIA DEFAULT CHARSET=latin1
drop table t1;
create table t1 (v varchar(65530) character set utf8) engine=maria;
create table t1 (v varchar(65530) character set utf8);
Warnings:
Note 1246 Converting column 'v' from VARCHAR to TEXT
show create table t1;
@ -1323,24 +1345,11 @@ t1 CREATE TABLE `t1` (
`v` mediumtext CHARACTER SET utf8
) ENGINE=MARIA DEFAULT CHARSET=latin1
drop table t1;
create table t1 (v varchar(65535)) engine=maria;
create table t1 (v varchar(65535));
ERROR 42000: Row size too large. The maximum row size for the used table type, not counting BLOBs, is 65535. You have to change some columns to TEXT or BLOBs
set storage_engine=MyISAM;
create table t1 (a int) engine=maria;
drop table if exists t1;
Warnings:
Error 2 Can't find file: 't1' (errno: 2)
create table t1 (a int) engine=maria;
drop table t1;
Got one of the listed errors
create table t1 (a int) engine=maria;
drop table t1;
Got one of the listed errors
drop table t1;
ERROR 42S02: Unknown table 't1'
set @save_concurrent_insert=@@concurrent_insert;
set global concurrent_insert=1;
create table t1 (a int) engine=maria;
create table t1 (a int);
insert into t1 values (1),(2),(3),(4),(5);
lock table t1 read local;
insert into t1 values(6),(7);
@ -1367,7 +1376,7 @@ check table t1;
Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
create table t1 (a int, b varchar(30) default "hello") engine=maria;
create table t1 (a int, b varchar(30) default "hello");
insert into t1 (a) values (1),(2),(3),(4),(5);
lock table t1 read local;
insert into t1 (a) values(6),(7);
@ -1395,7 +1404,7 @@ Table Op Msg_type Msg_text
test.t1 check status OK
drop table t1;
set global concurrent_insert=@save_concurrent_insert;
create table t1 (a int, key(a)) engine=maria;
create table t1 (a int, key(a));
insert into t1 values (1),(2),(3),(4),(NULL),(NULL),(NULL),(NULL);
analyze table t1;
Table Op Msg_type Msg_text
@ -1409,9 +1418,172 @@ show keys from t1;
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment
t1 1 a 1 a A 8 NULL NULL YES BTREE
drop table t1;
create table t1 (c1 int) engine=maria pack_keys=0;
create table t2 (c1 int) engine=maria pack_keys=1;
create table t3 (c1 int) engine=maria pack_keys=default;
create table t4 (c1 int) engine=maria pack_keys=2;
show create table t1;
show create table t1;
create table t1 (a int) select 42 a;
select * from t1;
a
9
select * from t1;
a
99
select * from t1;
a
42
drop table t1;
End of 4.1 tests
create table t1 (c1 int) pack_keys=0;
create table t2 (c1 int) pack_keys=1;
create table t3 (c1 int) pack_keys=default;
create table t4 (c1 int) pack_keys=2;
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '2' at line 1
drop table t1, t2, t3;
End of 5.0 tests
create table t1 (a int not null, key `a` (a) key_block_size=1024);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
KEY `a` (`a`) KEY_BLOCK_SIZE=1024
) ENGINE=MARIA DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a int not null, key `a` (a) key_block_size=2048);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
KEY `a` (`a`) KEY_BLOCK_SIZE=2048
) ENGINE=MARIA DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a varchar(2048), key `a` (a));
Warnings:
Warning 1071 Specified key was too long; max key length is 1000 bytes
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(2048) DEFAULT NULL,
KEY `a` (`a`(1000))
) ENGINE=MARIA DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a varchar(2048), key `a` (a) key_block_size=1024);
Warnings:
Warning 1071 Specified key was too long; max key length is 1000 bytes
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(2048) DEFAULT NULL,
KEY `a` (`a`(1000)) KEY_BLOCK_SIZE=4096
) ENGINE=MARIA DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a int not null, b varchar(2048), key (a), key(b)) key_block_size=1024;
Warnings:
Warning 1071 Specified key was too long; max key length is 1000 bytes
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` varchar(2048) DEFAULT NULL,
KEY `a` (`a`),
KEY `b` (`b`(1000)) KEY_BLOCK_SIZE=4096
) ENGINE=MARIA DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=1024
alter table t1 key_block_size=2048;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` varchar(2048) DEFAULT NULL,
KEY `a` (`a`) KEY_BLOCK_SIZE=1024,
KEY `b` (`b`(1000)) KEY_BLOCK_SIZE=4096
) ENGINE=MARIA DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=2048
alter table t1 add c int, add key (c);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` varchar(2048) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
KEY `a` (`a`) KEY_BLOCK_SIZE=1024,
KEY `b` (`b`(1000)) KEY_BLOCK_SIZE=4096,
KEY `c` (`c`)
) ENGINE=MARIA DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=2048
alter table t1 key_block_size=0;
alter table t1 add d int, add key (d);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` varchar(2048) DEFAULT NULL,
`c` int(11) DEFAULT NULL,
`d` int(11) DEFAULT NULL,
KEY `a` (`a`) KEY_BLOCK_SIZE=1024,
KEY `b` (`b`(1000)) KEY_BLOCK_SIZE=4096,
KEY `c` (`c`) KEY_BLOCK_SIZE=2048,
KEY `d` (`d`)
) ENGINE=MARIA DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a int not null, b varchar(2048), key (a), key(b)) key_block_size=8192;
Warnings:
Warning 1071 Specified key was too long; max key length is 1000 bytes
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` varchar(2048) DEFAULT NULL,
KEY `a` (`a`),
KEY `b` (`b`(1000))
) ENGINE=MARIA DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=8192
drop table t1;
create table t1 (a int not null, b varchar(2048), key (a) key_block_size=1024, key(b)) key_block_size=8192;
Warnings:
Warning 1071 Specified key was too long; max key length is 1000 bytes
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` varchar(2048) DEFAULT NULL,
KEY `a` (`a`) KEY_BLOCK_SIZE=1024,
KEY `b` (`b`(1000))
) ENGINE=MARIA DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=8192
drop table t1;
create table t1 (a int not null, b int, key (a) key_block_size=1024, key(b) key_block_size=8192) key_block_size=16384;
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
`b` int(11) DEFAULT NULL,
KEY `a` (`a`) KEY_BLOCK_SIZE=1024,
KEY `b` (`b`) KEY_BLOCK_SIZE=8192
) ENGINE=MARIA DEFAULT CHARSET=latin1 KEY_BLOCK_SIZE=16384
drop table t1;
create table t1 (a int not null, key `a` (a) key_block_size=512);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
KEY `a` (`a`) KEY_BLOCK_SIZE=1024
) ENGINE=MARIA DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a varchar(2048), key `a` (a) key_block_size=1000000000000000000);
Warnings:
Warning 1071 Specified key was too long; max key length is 1000 bytes
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` varchar(2048) DEFAULT NULL,
KEY `a` (`a`(1000)) KEY_BLOCK_SIZE=8192
) ENGINE=MARIA DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a int not null, key `a` (a) key_block_size=1025);
show create table t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) NOT NULL,
KEY `a` (`a`) KEY_BLOCK_SIZE=2048
) ENGINE=MARIA DEFAULT CHARSET=latin1
drop table t1;
create table t1 (a int not null, key key_block_size=1024 (a));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '=1024 (a))' at line 1
create table t1 (a int not null, key `a` key_block_size=1024 (a));
ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'key_block_size=1024 (a))' at line 1
End of 5.1 tests
set global storage_engine=MyISAM;

View file

@ -1775,7 +1775,7 @@ NULL as const12, @arg12 as param12,
show create table t5 ;
Table Create Table
t5 CREATE TABLE `t5` (
`const01` bigint(1) NOT NULL DEFAULT '0',
`const01` int(1) NOT NULL DEFAULT '0',
`param01` bigint(20) DEFAULT NULL,
`const02` decimal(2,1) NOT NULL DEFAULT '0.0',
`param02` decimal(65,30) DEFAULT NULL,
@ -1805,7 +1805,7 @@ t5 CREATE TABLE `t5` (
) ENGINE=MyISAM DEFAULT CHARSET=latin1
select * from t5 ;
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 const02 const02 246 4 3 N 1 1 63
def test t5 t5 param02 param02 246 67 32 Y 0 30 63

View file

@ -3,6 +3,10 @@
#
-- source include/have_maria.inc
let $default=`select @@global.storage_engine`;
set global storage_engine=maria;
set session storage_engine=maria;
# Initialise
--disable_warnings
drop table if exists t1,t2;
@ -16,7 +20,7 @@ SET SQL_WARNINGS=1;
CREATE TABLE t1 (
STRING_DATA char(255) default NULL,
KEY string_data (STRING_DATA)
) ENGINE=MARIA;
);
INSERT INTO t1 VALUES ('AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
INSERT INTO t1 VALUES ('DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD');
@ -31,7 +35,7 @@ drop table t1;
# Test problem with rows that are 65517-65520 bytes long
#
create table t1 (a tinyint not null auto_increment, b blob not null, primary key (a)) engine=maria;
create table t1 (a tinyint not null auto_increment, b blob not null, primary key (a));
let $1=100;
disable_query_log;
@ -57,7 +61,7 @@ drop table t1;
# Test bug: Two optimize in a row reset index cardinality
#
create table t1 (a int not null auto_increment, b int not null, primary key (a), index(b)) engine=maria;
create table t1 (a int not null auto_increment, b int not null, primary key (a), index(b));
insert into t1 (b) values (1),(2),(2),(2),(2);
optimize table t1;
show index from t1;
@ -69,7 +73,7 @@ drop table t1;
# Test of how ORDER BY works when doing it on the whole table
#
create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b)) engine=maria;
create table t1 (a int not null, b int not null, c int not null, primary key (a),key(b));
insert into t1 values (3,3,3),(1,1,1),(2,2,2),(4,4,4);
explain select * from t1 order by a;
explain select * from t1 order by b;
@ -84,7 +88,7 @@ drop table t1;
#
# Test of OPTIMIZE of locked and modified tables
#
CREATE TABLE t1 (a INT) engine=maria;
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1), (2), (3);
LOCK TABLES t1 WRITE;
INSERT INTO t1 VALUES (1), (2), (3);
@ -96,7 +100,7 @@ DROP TABLE t1;
# in ha_maria::repair, and index size is changed (decreased).
#
create table t1 ( t1 char(255), key(t1(250))) engine=maria;
create table t1 ( t1 char(255), key(t1(250)));
insert t1 values ('137513751375137513751375137513751375137569516951695169516951695169516951695169');
insert t1 values ('178417841784178417841784178417841784178403420342034203420342034203420342034203');
insert t1 values ('213872387238723872387238723872387238723867376737673767376737673767376737673767');
@ -258,7 +262,7 @@ int, i967 int, i968 int, i969 int, i970 int, i971 int, i972 int, i973 int, i974
int, i975 int, i976 int, i977 int, i978 int, i979 int, i980 int, i981 int, i982
int, i983 int, i984 int, i985 int, i986 int, i987 int, i988 int, i989 int, i990
int, i991 int, i992 int, i993 int, i994 int, i995 int, i996 int, i997 int, i998
int, i999 int, i1000 int, b blob) row_format=dynamic engine=maria;
int, i999 int, i1000 int, b blob) row_format=dynamic;
insert into t1 values (1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
@ -325,7 +329,7 @@ CREATE TABLE `t1` (
KEY `poster_login` (`poster_login`),
KEY `topic_id` (`topic_id`),
FULLTEXT KEY `post_text` (`post_text`)
) ENGINE=MARIA;
);
INSERT INTO t1 (post_text) VALUES ('ceci est un test'),('ceci est un test'),('ceci est un test'),('ceci est un test'),('ceci est un test');
@ -338,8 +342,8 @@ drop table t1;
#
--error 1071
CREATE TABLE t1 (a varchar(255), b varchar(255), c varchar(255), d varchar(255), e varchar(255), KEY t1 (a, b, c, d, e)) engine=maria;
CREATE TABLE t1 (a varchar(255), b varchar(255), c varchar(255), d varchar(255), e varchar(255)) engine=maria;
CREATE TABLE t1 (a varchar(255), b varchar(255), c varchar(255), d varchar(255), e varchar(255), KEY t1 (a, b, c, d, e));
CREATE TABLE t1 (a varchar(255), b varchar(255), c varchar(255), d varchar(255), e varchar(255));
--error 1071
ALTER TABLE t1 ADD INDEX t1 (a, b, c, d, e);
DROP TABLE t1;
@ -348,9 +352,9 @@ DROP TABLE t1;
# Test of cardinality of keys with NULL
#
CREATE TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a)) engine=maria;
CREATE TABLE t1 (a int not null, b int, c int, key(b), key(c), key(a,b), key(c,a));
INSERT into t1 values (0, null, 0), (0, null, 1), (0, null, 2), (0, null,3), (1,1,4);
create table t2 (a int not null, b int, c int, key(b), key(c), key(a)) engine=maria;
create table t2 (a int not null, b int, c int, key(b), key(c), key(a));
INSERT into t2 values (1,1,1), (2,2,2);
optimize table t1;
show index from t1;
@ -369,7 +373,7 @@ drop table t1,t2;
# Test bug when updating a split dynamic row where keys are not changed
#
create table t1 (a int not null auto_increment primary key, b varchar(255)) engine=maria;
create table t1 (a int not null auto_increment primary key, b varchar(255));
insert into t1 (b) values (repeat('a',100)),(repeat('b',100)),(repeat('c',100));
update t1 set b=repeat(left(b,1),200) where a=1;
delete from t1 where (a & 1)= 0;
@ -402,7 +406,7 @@ drop table t1;
#
# two bugs in maria-space-stripping feature
#
create table t1 ( a text not null, key a (a(20))) engine=maria;
create table t1 ( a text not null, key a (a(20)));
insert into t1 values ('aaa '),('aaa'),('aa');
check table t1;
repair table t1;
@ -416,7 +420,7 @@ drop table t1;
# Third bug in the same code (BUG#2295)
#
create table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10))) engine=maria;
create table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10)));
insert into t1 values('807780', '477', '165');
insert into t1 values('807780', '477', '162');
insert into t1 values('807780', '472', '162');
@ -427,7 +431,7 @@ drop table t1;
# space-stripping in _mi_prefix_search: BUG#5284
#
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a varchar(150) NOT NULL, KEY (a)) engine=maria;
CREATE TABLE t1 (a varchar(150) NOT NULL, KEY (a));
INSERT t1 VALUES ("can \tcan");
INSERT t1 VALUES ("can can");
INSERT t1 VALUES ("can");
@ -438,7 +442,7 @@ DROP TABLE t1;
#
# Verify blob handling
#
create table t1 (a blob) engine=maria;
create table t1 (a blob);
insert into t1 values('a '),('a');
select concat(a,'.') from t1 where a='a';
select concat(a,'.') from t1 where a='a ';
@ -450,7 +454,7 @@ drop table t1;
#
# Test text and unique
#
create table t1 (a int not null auto_increment primary key, b text not null, unique b (b(20))) engine=maria;
create table t1 (a int not null auto_increment primary key, b text not null, unique b (b(20)));
insert into t1 (b) values ('a'),('b'),('c');
select concat(b,'.') from t1;
update t1 set b='b ' where a=2;
@ -466,8 +470,8 @@ drop table t1;
#
# Test keys with 0 segments. (Bug #3203)
#
create table t1 (a int not null) engine=maria;
create table t2 (a int not null, primary key (a)) engine=maria;
create table t1 (a int not null);
create table t2 (a int not null, primary key (a));
insert into t1 values (1);
insert into t2 values (1),(2);
select sql_big_result distinct t1.a from t1,t2 order by t2.a;
@ -483,7 +487,7 @@ drop table t1,t2;
create table t1 (
c1 varchar(32),
key (c1)
) engine=maria;
);
alter table t1 disable keys;
insert into t1 values ('a'), ('b');
select c1 from t1 order by c1 limit 1;
@ -493,13 +497,13 @@ drop table t1;
# Test RTREE index
#
--error 1235, 1289
CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`)) ENGINE=MARIA;
CREATE TABLE t1 (`a` int(11) NOT NULL default '0', `b` int(11) NOT NULL default '0', UNIQUE KEY `a` USING RTREE (`a`,`b`));
# INSERT INTO t1 VALUES (1,1),(1,1);
# DELETE FROM rt WHERE a<1;
# DROP TABLE IF EXISTS t1;
create table t1 (a int, b varchar(200), c text not null) checksum=1 engine=maria;
create table t2 (a int, b varchar(200), c text not null) checksum=0 engine=maria;
create table t1 (a int, b varchar(200), c text not null) checksum=1;
create table t2 (a int, b varchar(200), c text not null) checksum=0;
insert t1 values (1, "aaa", "bbb"), (NULL, "", "ccccc"), (0, NULL, "");
insert t2 select * from t1;
checksum table t1, t2, t3 quick;
@ -508,11 +512,11 @@ checksum table t1, t2, t3 extended;
#show table status;
drop table t1,t2;
create table t1 (a int, key (a)) engine=maria;
create table t1 (a int, key (a));
show keys from t1;
alter table t1 disable keys;
show keys from t1;
create table t2 (a int) engine=maria;
create table t2 (a int);
let $i=1000;
set @@rand_seed1=31415926,@@rand_seed2=2718281828;
--disable_query_log
@ -534,7 +538,7 @@ drop table t1,t2;
#
# index search for NULL in blob. Bug #4816
#
create table t1 ( a tinytext, b char(1), index idx (a(1),b)) engine=maria;
create table t1 ( a tinytext, b char(1), index idx (a(1),b) );
insert into t1 values (null,''), (null,'');
explain select count(*) from t1 where a is null;
select count(*) from t1 where a is null;
@ -544,7 +548,7 @@ drop table t1;
# bug9188 - Corruption Can't open file: 'table.MYI' (errno: 145)
#
create table t1 (c1 int, c2 varchar(4) not null default '',
key(c2(3))) default charset=utf8 engine=maria;
key(c2(3))) default charset=utf8;
insert into t1 values (1,'A'), (2, 'B'), (3, 'A');
update t1 set c2='A B' where c1=2;
check table t1;
@ -555,11 +559,11 @@ drop table t1;
# Bug#12296 - CHECKSUM TABLE reports 0 for the table
# This happened if the first record was marked as deleted.
#
create table t1 (c1 int) engine=maria;
create table t1 (c1 int);
insert into t1 values (1),(2),(3),(4);
checksum table t1;
delete from t1 where c1 = 1;
create table t2 engine=maria as select * from t1;
create table t2 as select * from t1;
# The following returns 0 with the bug in place.
checksum table t1;
# The above should give the same number as the following.
@ -572,7 +576,7 @@ drop table t1, t2;
show variables like 'maria_stats_method';
create table t1 (a int, key(a)) engine=maria;
create table t1 (a int, key(a));
insert into t1 values (0),(1),(2),(3),(4);
insert into t1 select NULL from t1;
@ -623,7 +627,7 @@ show variables like 'maria_stats_method';
create table t1 (
a char(3), b char(4), c char(5), d char(6),
key(a,b,c,d)
) engine=maria;
);
insert into t1 values ('bcd','def1', NULL, 'zz');
insert into t1 values ('bcd','def2', NULL, 'zz');
insert into t1 values ('bce','def1', 'yuu', NULL);
@ -644,7 +648,7 @@ create table t1(
time TIME NOT NULL,
score INT NOT NULL DEFAULT 0,
bob TINYBLOB
) engine=maria;
);
insert into t1 (cip, time) VALUES (1, '00:01'), (2, '00:02'), (3,'00:03');
insert into t1 (cip, bob, time) VALUES (4, 'a', '00:04'), (5, 'b', '00:05'),
@ -663,7 +667,7 @@ create table t1 (
t text not null,
primary key (id1),
key x (id2, t(32))
) engine=maria;
) engine=maria; # engine clause is redundant but it's to test its parsing
insert into t1 (id2, t) values
(10, 'abc'), (10, 'abc'), (10, 'abc'),
(20, 'abc'), (20, 'abc'), (20, 'def'),
@ -672,51 +676,49 @@ select count(*) from t1 where id2 = 10;
select count(id1) from t1 where id2 = 10;
drop table t1;
# End of 4.1 tests
#
# BUG##20357 - Got error 124 from storage engine using MIN and MAX functions
# in queries
#
CREATE TABLE t1(a TINYINT, KEY(a));
INSERT INTO t1 VALUES(1);
SELECT MAX(a) FROM t1 IGNORE INDEX(a);
ALTER TABLE t1 DISABLE KEYS;
SELECT MAX(a) FROM t1;
SELECT MAX(a) FROM t1 IGNORE INDEX(a);
DROP TABLE t1;
#
# BUG#18036 - update of table joined to self reports table as crashed
#
CREATE TABLE t1(a CHAR(9), b VARCHAR(7));
INSERT INTO t1(a) VALUES('xxxxxxxxx'),('xxxxxxxxx');
UPDATE t1 AS ta1,t1 AS ta2 SET ta1.b='aaaaaa',ta2.b='bbbbbb';
SELECT * FROM t1;
DROP TABLE t1;
#
# Test varchar
#
let $default=`select @@storage_engine`;
set storage_engine=MARIA;
source include/varchar.inc;
#
# Some errors/warnings on create
#
create table t1 (v varchar(65530), key(v)) engine=maria;
create table t1 (v varchar(65530), key(v));
drop table if exists t1;
create table t1 (v varchar(65536)) engine=maria;
create table t1 (v varchar(65536));
show create table t1;
drop table t1;
create table t1 (v varchar(65530) character set utf8) engine=maria;
create table t1 (v varchar(65530) character set utf8);
show create table t1;
drop table t1;
# MARIA specific varchar tests
--error 1118
create table t1 (v varchar(65535)) engine=maria;
eval set storage_engine=$default;
#
# Test how DROP TABLE works if the index or data file doesn't exists
create table t1 (a int) engine=maria;
system rm $MYSQLTEST_VARDIR/master-data/test/t1.MAI ;
drop table if exists t1;
create table t1 (a int) engine=maria;
system rm $MYSQLTEST_VARDIR/master-data/test/t1.MAI ;
--error 1051,6
drop table t1;
create table t1 (a int) engine=maria;
system rm $MYSQLTEST_VARDIR/master-data/test/t1.MAD ;
--error 1105,6,29
drop table t1;
--error 1051
drop table t1;
create table t1 (v varchar(65535));
#
# Test concurrent insert
@ -724,7 +726,7 @@ drop table t1;
#
set @save_concurrent_insert=@@concurrent_insert;
set global concurrent_insert=1;
create table t1 (a int) engine=maria;
create table t1 (a int);
insert into t1 values (1),(2),(3),(4),(5);
lock table t1 read local;
connect (con1,localhost,root,,);
@ -749,7 +751,7 @@ drop table t1;
disconnect con1;
# Same test with dynamic record length
create table t1 (a int, b varchar(30) default "hello") engine=maria;
create table t1 (a int, b varchar(30) default "hello");
insert into t1 (a) values (1),(2),(3),(4),(5);
lock table t1 read local;
connect (con1,localhost,root,,);
@ -777,7 +779,7 @@ set global concurrent_insert=@save_concurrent_insert;
# BUG#9622 - ANALYZE TABLE and ALTER TABLE .. ENABLE INDEX produce
# different statistics on the same table with NULL values.
create table t1 (a int, key(a)) engine=maria;
create table t1 (a int, key(a));
insert into t1 values (1),(2),(3),(4),(NULL),(NULL),(NULL),(NULL);
analyze table t1;
@ -789,14 +791,120 @@ show keys from t1;
drop table t1;
#
# Bug#8706 - temporary table with data directory option fails
#
connect (session1,localhost,root,,);
connect (session2,localhost,root,,);
connection session1;
disable_query_log;
eval create temporary table t1 (a int) data directory="$MYSQLTEST_VARDIR/tmp" select 9 a;
enable_query_log;
disable_result_log;
show create table t1;
enable_result_log;
connection session2;
disable_query_log;
eval create temporary table t1 (a int) data directory="$MYSQLTEST_VARDIR/tmp" select 99 a;
enable_query_log;
disable_result_log;
show create table t1;
enable_result_log;
connection default;
create table t1 (a int) select 42 a;
connection session1;
select * from t1;
disconnect session1;
connection session2;
select * from t1;
disconnect session2;
connection default;
select * from t1;
drop table t1;
--echo End of 4.1 tests
#
# Bug#10056 - PACK_KEYS option take values greater than 1 while creating table
#
create table t1 (c1 int) engine=maria pack_keys=0;
create table t2 (c1 int) engine=maria pack_keys=1;
create table t3 (c1 int) engine=maria pack_keys=default;
create table t1 (c1 int) pack_keys=0;
create table t2 (c1 int) pack_keys=1;
create table t3 (c1 int) pack_keys=default;
--error 1064
create table t4 (c1 int) engine=maria pack_keys=2;
create table t4 (c1 int) pack_keys=2;
drop table t1, t2, t3;
--echo End of 5.0 tests
#
# Test of key_block_size
#
create table t1 (a int not null, key `a` (a) key_block_size=1024);
show create table t1;
drop table t1;
create table t1 (a int not null, key `a` (a) key_block_size=2048);
show create table t1;
drop table t1;
create table t1 (a varchar(2048), key `a` (a));
show create table t1;
drop table t1;
create table t1 (a varchar(2048), key `a` (a) key_block_size=1024);
show create table t1;
drop table t1;
create table t1 (a int not null, b varchar(2048), key (a), key(b)) key_block_size=1024;
show create table t1;
alter table t1 key_block_size=2048;
show create table t1;
alter table t1 add c int, add key (c);
show create table t1;
alter table t1 key_block_size=0;
alter table t1 add d int, add key (d);
show create table t1;
drop table t1;
create table t1 (a int not null, b varchar(2048), key (a), key(b)) key_block_size=8192;
show create table t1;
drop table t1;
create table t1 (a int not null, b varchar(2048), key (a) key_block_size=1024, key(b)) key_block_size=8192;
show create table t1;
drop table t1;
create table t1 (a int not null, b int, key (a) key_block_size=1024, key(b) key_block_size=8192) key_block_size=16384;
show create table t1;
drop table t1;
# Test limits and errors of key_block_size
create table t1 (a int not null, key `a` (a) key_block_size=512);
show create table t1;
drop table t1;
create table t1 (a varchar(2048), key `a` (a) key_block_size=1000000000000000000);
show create table t1;
drop table t1;
create table t1 (a int not null, key `a` (a) key_block_size=1025);
show create table t1;
drop table t1;
--error 1064
create table t1 (a int not null, key key_block_size=1024 (a));
--error 1064
create table t1 (a int not null, key `a` key_block_size=1024 (a));
--echo End of 5.1 tests
eval set global storage_engine=$default;
# End of 5.2 tests

View file

@ -524,7 +524,6 @@ HA_KEYSEG *ha_find_null(HA_KEYSEG *keyseg, uchar *a)
case HA_KEYTYPE_VARTEXT1:
case HA_KEYTYPE_VARTEXT2:
case HA_KEYTYPE_VARBINARY1:
case HA_KEYTYPE_VARTEXT2:
case HA_KEYTYPE_VARBINARY2:
{
int a_length;

View file

@ -30,8 +30,9 @@
#include "../storage/maria/ma_rt_index.h"
#endif
#include <mysql/plugin.h>
ulong maria_recover_options= HA_RECOVER_NONE;
static bool ha_maria_init();
/* bits in maria_recover_options */
const char *maria_recover_names[]=
@ -60,65 +61,9 @@ TYPELIB maria_stats_method_typelib=
** MARIA tables
*****************************************************************************/
static handler *maria_create_handler(TABLE_SHARE * table);
/* MARIA handlerton */
static const char maria_hton_name[]= "MARIA";
static const char maria_hton_comment[]=
"Transactional storage engine, optimized for long running transactions";
handlerton maria_hton=
static handler *maria_create_handler(TABLE_SHARE * table, MEM_ROOT *mem_root)
{
MYSQL_HANDLERTON_INTERFACE_VERSION,
maria_hton_name,
SHOW_OPTION_YES,
maria_hton_comment,
DB_TYPE_MARIA,
ha_maria_init,
0, /* slot */
0, /* savepoint size. */
NULL, /* close_connection */
NULL, /* savepoint */
NULL, /* rollback to savepoint */
NULL, /* release savepoint */
NULL, /* commit */
NULL, /* rollback */
NULL, /* prepare */
NULL, /* recover */
NULL, /* commit_by_xid */
NULL, /* rollback_by_xid */
NULL, /* create_cursor_read_view */
NULL, /* set_cursor_read_view */
NULL, /* close_cursor_read_view */
/*
MARIA doesn't support transactions yet and doesn't have
transaction-dependent context: cursors can survive a commit.
*/
maria_create_handler, /* Create a new handler */
NULL, /* Drop a database */
maria_panic, /* Panic call */
NULL, /* Start Consistent Snapshot */
NULL, /* Flush logs */
NULL, /* Show status */
NULL, /* Partition flags */
NULL, /* Alter table flags */
NULL, /* Alter Tablespace */
NULL, /* Fill Files Table */
HTON_CAN_RECREATE,
NULL, /* binlog_func */
NULL, /* binlog_log_query */
NULL /* release_temporary_latches */
};
static bool ha_maria_init()
{
return test(maria_init());
}
static handler *maria_create_handler(TABLE_SHARE *table)
{
return new ha_maria(table);
return new (mem_root) ha_maria(table);
}
@ -208,9 +153,10 @@ void _ma_check_print_warning(HA_CHECK *param, const char *fmt, ...)
ha_maria::ha_maria(TABLE_SHARE *table_arg):
handler(&maria_hton, table_arg), file(0),
int_table_flags(HA_NULL_IN_KEY | HA_CAN_FULLTEXT | HA_CAN_SQL_HANDLER |
HA_DUPP_POS | HA_CAN_INDEX_BLOBS | HA_AUTO_PART_KEY |
HA_FILE_BASED | HA_CAN_GEOMETRY | HA_READ_RND_SAME |
HA_CAN_INSERT_DELAYED | HA_CAN_BIT_FIELD),
HA_DUPLICATE_POS | HA_CAN_INDEX_BLOBS | HA_AUTO_PART_KEY |
HA_FILE_BASED | HA_CAN_GEOMETRY | HA_NO_TRANSACTIONS |
HA_CAN_INSERT_DELAYED | HA_CAN_BIT_FIELD |
HA_HAS_RECORDS | HA_STATS_RECORDS_IS_EXACT),
can_enable_indexes(1)
{}
@ -376,6 +322,7 @@ int ha_maria::open(const char *name, int mode, uint test_if_locked)
if (table->key_info[i].flags & HA_USES_PARSER)
file->s->keyinfo[i].parser=
(struct st_mysql_ftparser *) parser->plugin->info;
table->key_info[i].block_size= file->s->keyinfo[i].block_length;
}
return (0);
}
@ -1284,13 +1231,14 @@ int ha_maria::index_read_idx(byte * buf, uint index, const byte * key,
int ha_maria::index_read_last(byte * buf, const byte * key, uint key_len)
{
DBUG_ENTER("ha_maria::index_read_last");
DBUG_ASSERT(inited == INDEX);
statistic_increment(table->in_use->status_var.ha_read_key_count,
&LOCK_status);
int error= maria_rkey(file, buf, active_index, key, key_len,
HA_READ_PREFIX_LAST);
table->status= error ? STATUS_NOT_FOUND : 0;
return error;
DBUG_RETURN(error);
}
@ -1355,7 +1303,7 @@ int ha_maria::rnd_init(bool scan)
{
if (scan)
return maria_scan_init(file);
return maria_extra(file, HA_EXTRA_RESET, 0);
return maria_reset(file); // Free buffers
}
@ -1400,24 +1348,23 @@ void ha_maria::info(uint flag)
(void) maria_status(file, &info, flag);
if (flag & HA_STATUS_VARIABLE)
{
records= info.records;
deleted= info.deleted;
data_file_length= info.data_file_length;
index_file_length= info.index_file_length;
delete_length= info.delete_length;
check_time= info.check_time;
mean_rec_length= info.mean_reclength;
stats.records= info.records;
stats.deleted= info.deleted;
stats.data_file_length= info.data_file_length;
stats.index_file_length= info.index_file_length;
stats.delete_length= info.delete_length;
stats.check_time= info.check_time;
stats.mean_rec_length= info.mean_reclength;
}
if (flag & HA_STATUS_CONST)
{
TABLE_SHARE *share= table->s;
max_data_file_length= info.max_data_file_length;
max_index_file_length= info.max_index_file_length;
create_time= info.create_time;
sortkey= info.sortkey;
stats.max_data_file_length= info.max_data_file_length;
stats.max_index_file_length= info.max_index_file_length;
stats.create_time= info.create_time;
ref_length= info.reflength;
share->db_options_in_use= info.options;
block_size= maria_block_size;
stats.block_size= maria_block_size;
/* Update share */
if (share->tmp_table == NO_TMP_TABLE)
@ -1448,11 +1395,11 @@ void ha_maria::info(uint flag)
if (flag & HA_STATUS_ERRKEY)
{
errkey= info.errkey;
my_store_ptr(dupp_ref, ref_length, info.dupp_key_pos);
my_store_ptr(dup_ref, ref_length, info.dupp_key_pos);
}
/* Faster to always update, than to do it based on flag */
update_time= info.update_time;
auto_increment_value= info.auto_increment;
stats.update_time= info.update_time;
stats.auto_increment_value= info.auto_increment;
}
@ -1463,6 +1410,10 @@ int ha_maria::extra(enum ha_extra_function operation)
return maria_extra(file, operation, 0);
}
int ha_maria::reset(void)
{
return maria_reset(file);
}
/* To be used with WRITE_CACHE and EXTRA_CACHE */
@ -1510,7 +1461,7 @@ void ha_maria::update_create_info(HA_CREATE_INFO *create_info)
ha_maria::info(HA_STATUS_AUTO | HA_STATUS_CONST);
if (!(create_info->used_fields & HA_CREATE_USED_AUTO))
{
create_info->auto_increment_value= auto_increment_value;
create_info->auto_increment_value= stats.auto_increment_value;
}
create_info->data_file_name= data_file_name;
create_info->index_file_name= index_file_name;
@ -1552,6 +1503,8 @@ int ha_maria::create(const char *name, register TABLE *table_arg,
keydef[i].key_alg= pos->algorithm == HA_KEY_ALG_UNDEF ?
(pos->flags & HA_SPATIAL ? HA_KEY_ALG_RTREE : HA_KEY_ALG_BTREE) :
pos->algorithm;
keydef[i].block_length= pos->block_size;
keydef[i].seg= keyseg;
keydef[i].keysegs= pos->key_parts;
for (j= 0; j < pos->key_parts; j++)
@ -1731,7 +1684,10 @@ int ha_maria::rename_table(const char *from, const char *to)
}
ulonglong ha_maria::get_auto_increment()
void ha_maria::get_auto_increment(ulonglong offset, ulonglong increment,
ulonglong nb_desired_values,
ulonglong *first_value,
ulonglong *nb_reserved_values)
{
ulonglong nr;
int error;
@ -1740,7 +1696,10 @@ ulonglong ha_maria::get_auto_increment()
if (!table->s->next_number_key_offset)
{ // Autoincrement at key-start
ha_maria::info(HA_STATUS_AUTO);
return auto_increment_value;
*first_value= stats.auto_increment_value;
/* Maria has only table-level lock for now, so reserves to +inf */
*nb_reserved_values= ULONGLONG_MAX;
return;
}
/* it's safe to call the following if bulk_insert isn't on */
@ -1761,7 +1720,14 @@ ulonglong ha_maria::get_auto_increment()
val_int_offset(table->s->rec_buff_length) + 1);
}
extra(HA_EXTRA_NO_KEYREAD);
return nr;
*first_value= nr;
/*
MySQL needs to call us for next row: assume we are inserting ("a",null)
here, we return 3, and next this statement will want to insert ("b",null):
there is no reason why ("b",3+1) would be the good row to insert: maybe it
already exists, maybe 3+1 is too large...
*/
*nb_reserved_values= 1;
}
@ -1825,9 +1791,11 @@ bool ha_maria::check_if_incompatible_data(HA_CREATE_INFO *info,
{
uint options= table->s->db_options_in_use;
if (info->auto_increment_value != auto_increment_value ||
if (info->auto_increment_value != stats.auto_increment_value ||
info->data_file_name != data_file_name ||
info->index_file_name != index_file_name || table_changes == IS_EQUAL_NO)
info->index_file_name != index_file_name ||
table_changes == IS_EQUAL_NO ||
table_changes & IS_EQUAL_PACK_LENGTH) // Not implemented yet
return COMPATIBLE_DATA_NO;
if ((options & (HA_OPTION_PACK_RECORD | HA_OPTION_CHECKSUM |
@ -1838,14 +1806,29 @@ bool ha_maria::check_if_incompatible_data(HA_CREATE_INFO *info,
return COMPATIBLE_DATA_YES;
}
handlerton maria_hton;
static int ha_maria_init()
{
maria_hton.state=SHOW_OPTION_YES;
maria_hton.db_type=DB_TYPE_MARIA;
maria_hton.create=maria_create_handler;
maria_hton.panic=maria_panic;
maria_hton.flags=HTON_CAN_RECREATE;
return test(maria_init());
}
struct st_mysql_storage_engine maria_storage_engine=
{ MYSQL_HANDLERTON_INTERFACE_VERSION, &maria_hton };
mysql_declare_plugin(maria)
{
MYSQL_STORAGE_ENGINE_PLUGIN,
&maria_hton,
maria_hton_name,
&maria_storage_engine,
"Maria",
"MySQL AB",
maria_hton_comment,
NULL, /* Plugin Init */
"Traditional transactional MySQL tables",
ha_maria_init, /* Plugin Init */
NULL, /* Plugin Deinit */
0x0100, /* 1.0 */
0

View file

@ -49,7 +49,7 @@ public:
{ return "MARIA"; }
const char *index_type(uint key_number);
const char **bas_ext() const;
ulong table_flags() const
ulonglong table_flags() const
{ return int_table_flags; }
ulong index_flags(uint inx, uint part, bool all_parts) const
{
@ -106,6 +106,7 @@ public:
void info(uint);
int extra(enum ha_extra_function operation);
int extra_opt(enum ha_extra_function operation, ulong cache_size);
int reset(void);
int external_lock(THD * thd, int lock_type);
int delete_all_rows(void);
int disable_indexes(uint mode);
@ -118,7 +119,10 @@ public:
int create(const char *name, TABLE * form, HA_CREATE_INFO * create_info);
THR_LOCK_DATA **store_lock(THD * thd, THR_LOCK_DATA ** to,
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 delete_table(const char *name);
int check(THD * thd, HA_CHECK_OPT * check_opt);

View file

@ -6021,7 +6021,6 @@ log and this option does nothing anymore.",
(gptr*) &maria_stats_method_str, (gptr*) &maria_stats_method_str, 0,
GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
#endif
{"max_allowed_packet", OPT_MAX_ALLOWED_PACKET,
"Max packetlength to send/receive from to server.",
(gptr*) &global_system_variables.max_allowed_packet,

View file

@ -14,7 +14,7 @@
# along with this program; if not, write to the Free Software
# 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
INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include

View file

@ -359,7 +359,7 @@ int maria_chk_key(HA_CHECK *param, register MARIA_HA *info)
puts("- check key delete-chain");
param->key_file_blocks=info->s->base.keystart;
for (key=0 ; key < info->s->state.header.max_block_size ; key++)
for (key=0 ; key < info->s->state.header.max_block_size_index ; key++)
if (check_k_link(param,info,key))
{
if (param->testflag & T_VERBOSE) puts("");
@ -454,25 +454,24 @@ int maria_chk_key(HA_CHECK *param, register MARIA_HA *info)
if ((uint) share->base.auto_key -1 == key)
{
/* Check that auto_increment key is bigger than max key value */
ulonglong save_auto_value=info->s->state.auto_increment;
info->s->state.auto_increment=0;
ulonglong auto_increment;
info->lastinx=key;
_ma_read_key_record(info, 0L, info->rec_buff);
_ma_update_auto_increment(info, info->rec_buff);
if (info->s->state.auto_increment > save_auto_value)
auto_increment= ma_retrieve_auto_increment(info, info->rec_buff);
if (auto_increment > info->s->state.auto_increment)
{
_ma_check_print_warning(param,
"Auto-increment value: %s is smaller than max used value: %s",
llstr(save_auto_value,buff2),
llstr(info->s->state.auto_increment, buff));
llstr(info->s->state.auto_increment,buff2),
llstr(auto_increment, buff));
}
if (param->testflag & T_AUTO_INC)
{
set_if_bigger(info->s->state.auto_increment,
param->auto_increment_value);
set_if_bigger(info->s->state.auto_increment,
auto_increment);
set_if_bigger(info->s->state.auto_increment,
param->auto_increment_value);
}
else
info->s->state.auto_increment=save_auto_value;
/* Check that there isn't a row with auto_increment = 0 in the table */
maria_extra(info,HA_EXTRA_KEYREAD,0);
@ -1160,7 +1159,7 @@ int maria_chk_data_link(HA_CHECK *param, MARIA_HA *info,int extend)
#ifdef HAVE_RTREE_KEYS
(keyinfo->flag & HA_SPATIAL) ?
maria_rtree_find_first(info, key, info->lastkey, key_length,
SEARCH_SAME) :
MBR_EQUAL | MBR_DATA) :
#endif
_ma_search(info,keyinfo,info->lastkey,key_length,
SEARCH_SAME, info->s->state.key_root[key]);
@ -1412,7 +1411,7 @@ int maria_repair(HA_CHECK *param, register MARIA_HA *info,
share->state.key_root[i]= HA_OFFSET_ERROR;
/* Drop the delete chain. */
for (i=0 ; i < share->state.header.max_block_size ; i++)
for (i=0 ; i < share->state.header.max_block_size_index ; i++)
share->state.key_del[i]= HA_OFFSET_ERROR;
/*
@ -1796,7 +1795,7 @@ int maria_sort_index(HA_CHECK *param, register MARIA_HA *info, my_string name)
info->update= (short) (HA_STATE_CHANGED | HA_STATE_ROW_CHANGED);
for (key=0 ; key < info->s->base.keys ; key++)
info->s->state.key_root[key]=index_pos[key];
for (key=0 ; key < info->s->state.header.max_block_size ; key++)
for (key=0 ; key < info->s->state.header.max_block_size_index ; key++)
info->s->state.key_del[key]= HA_OFFSET_ERROR;
info->s->state.changed&= ~STATE_NOT_SORTED_PAGES;
@ -2079,7 +2078,7 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
/* Clear the pointers to the given rows */
for (i=0 ; i < share->base.keys ; i++)
share->state.key_root[i]= HA_OFFSET_ERROR;
for (i=0 ; i < share->state.header.max_block_size ; i++)
for (i=0 ; i < share->state.header.max_block_size_index ; i++)
share->state.key_del[i]= HA_OFFSET_ERROR;
info->state->key_file_length=share->base.keystart;
}
@ -2101,6 +2100,7 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
my_seek(param->read_cache.file,0L,MY_SEEK_END,MYF(0));
sort_param.wordlist=NULL;
init_alloc_root(&sort_param.wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
if (share->data_file_type == DYNAMIC_RECORD)
length=max(share->base.min_pack_length+1,share->base.min_block_length);
@ -2163,12 +2163,36 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
{
uint ft_max_word_len_for_sort=FT_MAX_WORD_LEN_FOR_SORT*
sort_param.keyinfo->seg->charset->mbmaxlen;
sort_info.max_records=
(ha_rows) (sort_info.filelength/ft_min_word_len+1);
sort_param.key_length+=ft_max_word_len_for_sort-HA_FT_MAXBYTELEN;
/*
fulltext indexes may have much more entries than the
number of rows in the table. We estimate the number here.
Note, built-in parser is always nr. 0 - see ftparser_call_initializer()
*/
if (sort_param.keyinfo->ftparser_nr == 0)
{
/*
for built-in parser the number of generated index entries
cannot be larger than the size of the data file divided
by the minimal word's length
*/
sort_info.max_records=
(ha_rows) (sort_info.filelength/ft_min_word_len+1);
}
else
{
/*
for external plugin parser we cannot tell anything at all :(
so, we'll use all the sort memory and start from ~10 buffpeks.
(see _create_index_by_sort)
*/
sort_info.max_records=
10*param->sort_buffer_length/sort_param.key_length;
}
sort_param.key_read=sort_maria_ft_key_read;
sort_param.key_write=sort_maria_ft_key_write;
sort_param.key_length+=ft_max_word_len_for_sort-HA_FT_MAXBYTELEN;
}
else
{
@ -2184,6 +2208,7 @@ int maria_repair_by_sort(HA_CHECK *param, register MARIA_HA *info,
goto err;
}
param->calc_checksum=0; /* No need to calc glob_crc */
free_root(&sort_param.wordroot, MYF(0));
/* Set for next loop */
sort_info.max_records= (ha_rows) info->state->records;
@ -2447,7 +2472,7 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
/* Clear the pointers to the given rows */
for (i=0 ; i < share->base.keys ; i++)
share->state.key_root[i]= HA_OFFSET_ERROR;
for (i=0 ; i < share->state.header.max_block_size ; i++)
for (i=0 ; i < share->state.header.max_block_size_index ; i++)
share->state.key_del[i]= HA_OFFSET_ERROR;
info->state->key_file_length=share->base.keystart;
}
@ -2573,6 +2598,7 @@ int maria_repair_parallel(HA_CHECK *param, register MARIA_HA *info,
uint ft_max_word_len_for_sort=FT_MAX_WORD_LEN_FOR_SORT*
sort_param[i].keyinfo->seg->charset->mbmaxlen;
sort_param[i].key_length+=ft_max_word_len_for_sort-HA_FT_MAXBYTELEN;
init_alloc_root(&sort_param[i].wordroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
}
}
sort_info.total_keys=i;
@ -2794,10 +2820,12 @@ static int sort_maria_ft_key_read(MARIA_SORT_PARAM *sort_param, void *key)
{
for (;;)
{
my_free((char*) wptr, MYF(MY_ALLOW_ZERO_PTR));
free_root(&sort_param->wordroot, MYF(MY_MARK_BLOCKS_FREE));
if ((error=sort_get_next_record(sort_param)))
DBUG_RETURN(error);
if (!(wptr= _ma_ft_parserecord(info,sort_param->key,sort_param->record)))
if (!(wptr= _ma_ft_parserecord(info,sort_param->key,sort_param->record,
&sort_param->wordroot)))
DBUG_RETURN(1);
if (wptr->pos)
break;
@ -2821,7 +2849,7 @@ static int sort_maria_ft_key_read(MARIA_SORT_PARAM *sort_param, void *key)
#endif
if (!wptr->pos)
{
my_free((char*) sort_param->wordlist, MYF(0));
free_root(&sort_param->wordroot, MYF(MY_MARK_BLOCKS_FREE));
sort_param->wordlist=0;
error=_ma_sort_write_record(sort_param);
}
@ -3784,6 +3812,7 @@ int maria_recreate_table(HA_CHECK *param, MARIA_HA **org_info, char *filename)
ha_rows max_records;
ulonglong file_length,tmp_length;
MARIA_CREATE_INFO create_info;
DBUG_ENTER("maria_recreate_table");
error=1; /* Default error */
info= **org_info;
@ -3793,7 +3822,7 @@ int maria_recreate_table(HA_CHECK *param, MARIA_HA **org_info, char *filename)
unpack= (share.options & HA_OPTION_COMPRESS_RECORD) &&
(param->testflag & T_UNPACK);
if (!(keyinfo=(MARIA_KEYDEF*) my_alloca(sizeof(MARIA_KEYDEF)*share.base.keys)))
return 0;
DBUG_RETURN(0);
memcpy((byte*) keyinfo,(byte*) share.keyinfo,
(size_t) (sizeof(MARIA_KEYDEF)*share.base.keys));
@ -3802,14 +3831,14 @@ int maria_recreate_table(HA_CHECK *param, MARIA_HA **org_info, char *filename)
(key_parts+share.base.keys))))
{
my_afree((gptr) keyinfo);
return 1;
DBUG_RETURN(1);
}
if (!(recdef=(MARIA_COLUMNDEF*)
my_alloca(sizeof(MARIA_COLUMNDEF)*(share.base.fields+1))))
{
my_afree((gptr) keyinfo);
my_afree((gptr) keysegs);
return 1;
DBUG_RETURN(1);
}
if (!(uniquedef=(MARIA_UNIQUEDEF*)
my_alloca(sizeof(MARIA_UNIQUEDEF)*(share.state.header.uniques+1))))
@ -3817,7 +3846,7 @@ int maria_recreate_table(HA_CHECK *param, MARIA_HA **org_info, char *filename)
my_afree((gptr) recdef);
my_afree((gptr) keyinfo);
my_afree((gptr) keysegs);
return 1;
DBUG_RETURN(1);
}
/* Copy the column definitions */
@ -3887,6 +3916,11 @@ int maria_recreate_table(HA_CHECK *param, MARIA_HA **org_info, char *filename)
create_info.language = (param->language ? param->language :
share.state.header.language);
create_info.key_file_length= status_info.key_file_length;
/*
Allow for creating an auto_increment key. This has an effect only if
an auto_increment key exists in the original table.
*/
create_info.with_auto_increment= TRUE;
/* We don't have to handle symlinks here because we are using
HA_DONT_TOUCH_DATA */
if (maria_create(filename,
@ -3931,7 +3965,7 @@ end:
my_afree((gptr) keyinfo);
my_afree((gptr) recdef);
my_afree((gptr) keysegs);
return error;
DBUG_RETURN(error);
}
@ -4034,6 +4068,8 @@ void _ma_update_auto_increment_key(HA_CHECK *param, MARIA_HA *info,
my_bool repair_only)
{
byte *record;
DBUG_ENTER("update_auto_increment_key");
if (!info->s->base.auto_key ||
! maria_is_key_active(info->s->state.key_map, info->s->base.auto_key - 1))
{
@ -4041,7 +4077,7 @@ void _ma_update_auto_increment_key(HA_CHECK *param, MARIA_HA *info,
_ma_check_print_info(param,
"Table: %s doesn't have an auto increment key\n",
param->isam_file_name);
return;
DBUG_VOID_RETURN;
}
if (!(param->testflag & T_SILENT) &&
!(param->testflag & T_REP))
@ -4054,7 +4090,7 @@ void _ma_update_auto_increment_key(HA_CHECK *param, MARIA_HA *info,
MYF(0))))
{
_ma_check_print_error(param,"Not enough memory for extra record");
return;
DBUG_VOID_RETURN;
}
maria_extra(info,HA_EXTRA_KEYREAD,0);
@ -4065,23 +4101,22 @@ void _ma_update_auto_increment_key(HA_CHECK *param, MARIA_HA *info,
maria_extra(info,HA_EXTRA_NO_KEYREAD,0);
my_free((char*) record, MYF(0));
_ma_check_print_error(param,"%d when reading last record",my_errno);
return;
DBUG_VOID_RETURN;
}
if (!repair_only)
info->s->state.auto_increment=param->auto_increment_value;
}
else
{
ulonglong auto_increment= (repair_only ? info->s->state.auto_increment :
param->auto_increment_value);
info->s->state.auto_increment=0;
_ma_update_auto_increment(info, record);
ulonglong auto_increment= ma_retrieve_auto_increment(info, record);
set_if_bigger(info->s->state.auto_increment,auto_increment);
if (!repair_only)
set_if_bigger(info->s->state.auto_increment, param->auto_increment_value);
}
maria_extra(info,HA_EXTRA_NO_KEYREAD,0);
my_free((char*) record, MYF(0));
maria_update_state_info(param, info, UPDATE_AUTO_INC);
return;
DBUG_VOID_RETURN;
}

View file

@ -28,9 +28,9 @@
#endif
#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,
uint columns, MARIA_COLUMNDEF *recinfo,
@ -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,
base_pos,long_varchar_count,varchar_length,
max_key_block_length,unique_key_parts,fulltext_keys,offset;
uint aligned_key_start, block_length;
ulong reclength, real_reclength,min_pack_length;
char filename[FN_REFLEN],linkname[FN_REFLEN], *linkname_ptr;
ulong pack_reclength;
@ -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];
MARIA_CREATE_INFO tmp_create_info;
DBUG_ENTER("maria_create");
DBUG_PRINT("enter", ("keys: %u columns: %u uniques: %u flags: %u",
keys, columns, uniques, flags));
if (!ci)
{
@ -428,8 +431,16 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
key_segs)
share.state.rec_per_key_part[key_segs-1]=1L;
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,
pointer,MARIA_MAX_KEYPTR_SIZE);
pointer,MARIA_MAX_KEYPTR_SIZE,
block_length);
if (keydef->block_length > MARIA_MAX_KEY_BLOCK_LENGTH ||
length >= HA_MAX_KEY_BUFF)
{
@ -474,6 +485,17 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
(key_segs + unique_key_parts)*HA_KEYSEG_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);
ci->old_options=options| (ci->old_options & HA_OPTION_TEMP_COMPRESS_RECORD ?
HA_OPTION_COMPRESS_RECORD |
@ -485,7 +507,7 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
mi_int2store(share.state.header.base_pos,base_pos);
share.state.header.language= (ci->language ?
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.process= (ulong) getpid();
@ -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);
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=
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_length=ALIGN_SIZE(max_key_length+4);
share.base.records=ci->max_rows;
@ -549,9 +575,21 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
{
char *iext= strrchr(ci->index_file_name, '.');
int have_iext= iext && !strcmp(iext, MARIA_NAME_IEXT);
fn_format(filename, ci->index_file_name, "", MARIA_NAME_IEXT,
MY_UNPACK_FILENAME| (have_iext ? MY_REPLACE_EXT :MY_APPEND_EXT));
if (options & HA_OPTION_TMP_TABLE)
{
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,
MY_UNPACK_FILENAME|MY_APPEND_EXT);
linkname_ptr=linkname;
@ -614,9 +652,21 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
char *dext= strrchr(ci->data_file_name, '.');
int have_dext= dext && !strcmp(dext, MARIA_NAME_DEXT);
fn_format(filename, ci->data_file_name, "", MARIA_NAME_DEXT,
MY_UNPACK_FILENAME |
(have_dext ? MY_REPLACE_EXT : MY_APPEND_EXT));
if (options & HA_OPTION_TMP_TABLE)
{
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,
MY_UNPACK_FILENAME | MY_APPEND_EXT);
linkname_ptr=linkname;
@ -636,7 +686,7 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
}
errpos=3;
}
DBUG_PRINT("info", ("write state info and base info"));
if (_ma_state_info_write(file, &share.state, 2) ||
_ma_base_info_write(file, &share.base))
goto err;
@ -650,6 +700,7 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
#endif
/* Write key and keyseg definitions */
DBUG_PRINT("info", ("write key and keyseg definitions"));
for (i=0 ; i < share.base.keys - uniques; i++)
{
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,
}
/* Save unique definition */
DBUG_PRINT("info", ("write unique definitions"));
for (i=0 ; i < share.state.header.uniques ; i++)
{
HA_KEYSEG *keyseg_end;
@ -730,6 +782,7 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
goto err;
}
}
DBUG_PRINT("info", ("write field definitions"));
for (i=0 ; i < share.base.fields ; i++)
if (_ma_recinfo_write(file, &recinfo[i]))
goto err;
@ -744,6 +797,7 @@ int maria_create(const char *name,uint keys,MARIA_KEYDEF *keydefs,
#endif
/* Enlarge files */
DBUG_PRINT("info", ("enlarge to keystart: %lu", (ulong) share.base.keystart));
if (my_chsize(file,(ulong) share.base.keystart,0,MYF(0)))
goto err;
@ -772,7 +826,7 @@ err:
VOID(my_close(dfile,MYF(0)));
/* fall through */
case 2:
/* QQ: Tõnu 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))
my_delete_with_symlink(fn_format(filename,name,"",MARIA_NAME_DEXT,
MY_UNPACK_FILENAME | MY_APPEND_EXT),

View file

@ -34,12 +34,24 @@ int maria_delete_table(const char *name)
#ifdef USE_RAID
{
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)))
DBUG_RETURN(my_errno);
raid_type = info->s->base.raid_type;
raid_chunks = info->s->base.raid_chunks;
maria_close(info);
/*
When built with RAID support, we need to determine if this table
makes use of the raid feature. If yes, we need to remove all raid
chunks. This is done with my_raid_delete(). Unfortunately it is
necessary to open the table just to check this. We use
'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
_ma_check_table_is_closed(name,"delete");

View file

@ -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)
{
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*)
my_mmap(0, (size_t)(size + MEMMAP_EXTRA_MARGIN),
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)
info->rec_cache.pos_in_file <= block_info.next_filepos &&
flush_io_cache(&info->rec_cache))
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;
if ((b_type= _ma_get_block_info(&block_info,file,
block_info.next_filepos))

View file

@ -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));
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) */
info->lastinx= 0; /* Use first index as def */
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)
}
}
}
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);
}

View file

@ -167,10 +167,11 @@ typedef struct st_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)
{
MY_FTB_PARAM *ftb_param= (MY_FTB_PARAM *)param;
MY_FTB_PARAM *ftb_param= param->mysql_ftparam;
FTB_WORD *ftbw;
FTB_EXPR *ftbe, *tmp_expr;
FT_WORD *phrase_word;
@ -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;
CHARSET_INFO *cs= ftb_param->ftb->charset;
char **start= &query;
@ -280,7 +282,7 @@ static int ftb_parse_query_internal(void *param, char *query, int len)
info.prev= ' ';
info.quot= 0;
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);
}
@ -295,20 +297,21 @@ static void _ftb_parse_query(FTB *ftb, byte *query, uint len,
if (ftb->state != UNINITIALIZED)
DBUG_VOID_RETURN;
if (! (param= maria_ftparser_call_initializer(ftb->info, ftb->keynr, 0)))
DBUG_VOID_RETURN;
ftb_param.ftb= ftb;
ftb_param.depth= 0;
ftb_param.ftbe= ftb->root;
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_add_word= ftb_query_add_word;
param->mysql_ftparam= (void *)&ftb_param;
param->cs= ftb->charset;
param->doc= query;
param->length= len;
param->flags= 0;
param->mode= MYSQL_FTPARSER_FULL_BOOLEAN_INFO;
parser->parse(param);
DBUG_VOID_RETURN;
@ -577,10 +580,11 @@ typedef struct st_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)))
{
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;
LIST *phrase, *document;
w->pos= word;
@ -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;
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;
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)
return 1;
}
@ -644,7 +649,8 @@ static int _ftb_check_phrase(FTB *ftb, const byte *document, uint len,
MYSQL_FTPARSER_PARAM *param;
DBUG_ENTER("_ftb_check_phrase");
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);
ftb_param.phrase= ftbe->phrase;
ftb_param.document= ftbe->document;
@ -659,6 +665,7 @@ static int _ftb_check_phrase(FTB *ftb, const byte *document, uint len,
param->cs= ftb->charset;
param->doc= (byte *)document;
param->length= len;
param->flags= 0;
param->mode= MYSQL_FTPARSER_WITH_STOPWORDS;
parser->parse(param);
DBUG_RETURN(ftb_param.match ? 1 : 0);
@ -819,10 +826,11 @@ typedef struct st_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)))
{
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;
FTB_WORD *ftbw;
int a, b, c;
@ -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;
FT_WORD w;
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);
}
@ -878,7 +888,7 @@ float maria_ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length)
return -2.0;
if (!ftb->queue.elements)
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;
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)
ftb_param.ftb= ftb;
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))
{
if (!ftsi.pos)
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->length= ftsi.len;
parser->parse(param);

View file

@ -55,6 +55,7 @@ int main(int argc, char *argv[])
/* Define a key over the first column */
keyinfo[0].seg=keyseg;
keyinfo[0].keysegs=1;
keyinfo[0].block_length= 0; /* Default block length */
keyinfo[0].seg[0].type= HA_KEYTYPE_TEXT;
keyinfo[0].seg[0].flag= HA_BLOB_PART;
keyinfo[0].seg[0].start=recinfo[0].length;

View file

@ -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.keybuff=info->lastkey+info->s->base.max_key_length;
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;
bzero(&wtree,sizeof(wtree));
@ -235,7 +235,9 @@ FT_INFO *maria_ft_init_nlq_search(MARIA_HA *info, uint keynr, byte *query,
NULL, NULL);
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;
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,
if (!(*info->read_record)(info,docid,record))
{
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);

View file

@ -28,7 +28,7 @@ typedef struct st_maria_ft_docstat {
typedef struct st_my_maria_ft_parser_param
{
TREE *wtree;
my_bool with_alloc;
MEM_ROOT *mem_root;
} MY_FT_PARSER_PARAM;
@ -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 */
FT_WORD * maria_ft_linearize(TREE *wtree)
FT_WORD * maria_ft_linearize(TREE *wtree, MEM_ROOT *mem_root)
{
FT_WORD *wlist,*p;
FT_DOCSTAT docstat;
DBUG_ENTER("maria_ft_linearize");
if ((wlist=(FT_WORD *) my_malloc(sizeof(FT_WORD)*
(1+wtree->elements_in_tree),MYF(0))))
if ((wlist=(FT_WORD *) alloc_root(mem_root, sizeof(FT_WORD)*
(1+wtree->elements_in_tree))))
{
docstat.list=wlist;
docstat.uniq=wtree->elements_in_tree;
@ -114,6 +114,7 @@ byte maria_ft_get_word(CHARSET_INFO *cs, byte **start, byte *end,
FT_WORD *word, MYSQL_FTPARSER_BOOLEAN_INFO *param)
{
byte *doc=*start;
int ctype;
uint mwc, length, mbl;
param->yesno=(FTB_YES==' ') ? 1 : (param->quot != 0);
@ -122,9 +123,11 @@ byte maria_ft_get_word(CHARSET_INFO *cs, byte **start, byte *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)
{
param->quot=doc;
@ -158,14 +161,16 @@ byte maria_ft_get_word(CHARSET_INFO *cs, byte **start, byte *end,
}
mwc=length=0;
for (word->pos=doc; doc<end; length++, mbl=my_mbcharlen(cs, *(uchar *)doc), doc+=(mbl ? mbl : 1))
if (true_word_char(cs,*doc))
for (word->pos= doc; doc < end; length++, doc+= (mbl > 0 ? mbl : 1))
{
mbl= cs->cset->ctype(cs, &ctype, (uchar*)doc, (uchar*)end);
if (true_word_char(ctype, *doc))
mwc=0;
else if (!misc_word_char(*doc) || mwc)
break;
else
mwc++;
}
param->prev='A'; /* be sure *prev is true_word_char */
word->len= (uint)(doc-word->pos) - mwc;
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,
FT_WORD *word, my_bool skip_stopwords)
{
byte *doc= *start;
int ctype;
uint mwc, length, mbl;
DBUG_ENTER("maria_ft_simple_get_word");
do
{
for (;; doc++)
for (;; doc+= (mbl > 0 ? mbl : 1))
{
if (doc >= end) DBUG_RETURN(0);
if (true_word_char(cs, *doc)) break;
if (doc >= end)
DBUG_RETURN(0);
mbl= cs->cset->ctype(cs, &ctype, (uchar*)doc, (uchar*)end);
if (true_word_char(ctype, *doc))
break;
}
mwc= length= 0;
for (word->pos=doc; doc<end; length++, mbl=my_mbcharlen(cs, *(uchar *)doc), doc+=(mbl ? mbl : 1))
if (true_word_char(cs,*doc))
for (word->pos= doc; doc < end; length++, doc+= (mbl > 0 ? mbl : 1))
{
mbl= cs->cset->ctype(cs, &ctype, (uchar*)doc, (uchar*)end);
if (true_word_char(ctype, *doc))
mwc= 0;
else if (!misc_word_char(*doc) || mwc)
break;
else
mwc++;
}
word->len= (uint)(doc-word->pos) - mwc;
@ -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)))
{
TREE *wtree;
FT_WORD w;
MY_FT_PARSER_PARAM *ft_param=param->mysql_ftparam;
DBUG_ENTER("maria_ft_add_word");
wtree= ((MY_FT_PARSER_PARAM *)param)->wtree;
if (((MY_FT_PARSER_PARAM *)param)->with_alloc)
wtree= ft_param->wtree;
if (param->flags & MYSQL_FTFLAGS_NEED_COPY)
{
byte *ptr;
/* allocating the data in the tree - to avoid mallocs and frees */
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);
w.pos= ptr;
}
@ -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;
MY_FT_PARSER_PARAM *ft_param=param->mysql_ftparam;
TREE *wtree= ft_param->wtree;
FT_WORD w;
TREE *wtree;
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))
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(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,
MYSQL_FTPARSER_PARAM *param)
MYSQL_FTPARSER_PARAM *param, MEM_ROOT *mem_root)
{
MY_FT_PARSER_PARAM my_param;
DBUG_ENTER("maria_ft_parse");
DBUG_ASSERT(parser);
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_add_word= maria_ft_add_word;
@ -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;
struct st_mysql_ftparser *parser;
@ -344,9 +360,16 @@ MYSQL_FTPARSER_PARAM *maria_ftparser_call_initializer(MARIA_HA *info, uint keynr
}
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 *)
my_malloc(sizeof(MYSQL_FTPARSER_PARAM) *
my_malloc(MAX_PARAM_NR * sizeof(MYSQL_FTPARSER_PARAM) *
info->s->ftparsers, MYF(MY_WME|MY_ZEROFILL));
init_alloc_root(&info->ft_memroot, FTPARSER_MEMROOT_ALLOC_SIZE, 0);
if (! info->ftparser_param)
return 0;
}
@ -360,6 +383,8 @@ MYSQL_FTPARSER_PARAM *maria_ftparser_call_initializer(MARIA_HA *info, uint keynr
ftparser_nr= info->s->keyinfo[keynr].ftparser_nr;
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)
{
/* 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
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)
return;
for (i= 0; i < keys; i++)
{
MARIA_KEYDEF *keyinfo= &info->s->keyinfo[i];
MYSQL_FTPARSER_PARAM *ftparser_param=
&info->ftparser_param[keyinfo->ftparser_nr];
if (keyinfo->flag & HA_FULLTEXT && ftparser_param->mysql_add_word)
for (j=0; j < MAX_PARAM_NR; j++)
{
if (keyinfo->parser->deinit)
keyinfo->parser->deinit(ftparser_param);
ftparser_param->mysql_add_word= 0;
MYSQL_FTPARSER_PARAM *ftparser_param=
&info->ftparser_param[keyinfo->ftparser_nr*MAX_PARAM_NR + j];
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;
}
}
}

View file

@ -90,6 +90,7 @@ static int run_test(const char *filename)
/* Define a key over the first column */
keyinfo[0].seg=keyseg;
keyinfo[0].keysegs=1;
keyinfo[0].block_length= 0; /* Default block length */
keyinfo[0].seg[0].type= key_type;
keyinfo[0].seg[0].flag= (key_field == FIELD_BLOB) ? HA_BLOB_PART:
(key_field == FIELD_VARCHAR) ? HA_VAR_LENGTH_PART:0;

View file

@ -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 */
uint _ma_ft_parse(TREE *parsed, MARIA_HA *info, uint keynr,
const byte *record, my_bool with_alloc,
MYSQL_FTPARSER_PARAM *param)
uint _ma_ft_parse(TREE *parsed, MARIA_HA *info, uint keynr, const byte *record,
MYSQL_FTPARSER_PARAM *param, MEM_ROOT *mem_root)
{
FT_SEG_ITERATOR ftsi;
struct st_mysql_ftparser *parser;
@ -110,25 +109,27 @@ uint _ma_ft_parse(TREE *parsed, MARIA_HA *info, uint keynr,
while (_ma_ft_segiterator(&ftsi))
{
if (ftsi.pos)
if (maria_ft_parse(parsed, (byte *)ftsi.pos, ftsi.len, with_alloc, parser,
param))
if (maria_ft_parse(parsed, (byte *)ftsi.pos, ftsi.len, parser, param,
mem_root))
DBUG_RETURN(1);
}
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;
MYSQL_FTPARSER_PARAM *param;
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);
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(maria_ft_linearize(&ptree));
DBUG_RETURN(maria_ft_linearize(&ptree, mem_root));
}
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)
FT_SEG_ITERATOR ftsi1, ftsi2;
CHARSET_INFO *cs=info->s->keyinfo[keynr].seg->charset;
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, rec2, &ftsi2);
@ -206,10 +203,11 @@ int _ma_ft_update(MARIA_HA *info, uint keynr, byte *keybuf,
int cmp, cmp2;
DBUG_ENTER("_ma_ft_update");
if (!(old_word=oldlist= _ma_ft_parserecord(info, keynr, oldrec)))
goto err0;
if (!(new_word=newlist= _ma_ft_parserecord(info, keynr, newrec)))
goto err1;
if (!(old_word=oldlist=_ma_ft_parserecord(info, keynr, oldrec,
&info->ft_memroot)) ||
!(new_word=newlist=_ma_ft_parserecord(info, keynr, newrec,
&info->ft_memroot)))
goto err;
error=0;
while(old_word->pos && new_word->pos)
@ -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);
if ((error= _ma_ck_delete(info,keynr,(uchar*) keybuf,key_length)))
goto err2;
goto err;
}
if (cmp > 0 || cmp2)
{
key_length= _ma_ft_make_key(info,keynr,keybuf,new_word,pos);
if ((error= _ma_ck_write(info,keynr,(uchar*) keybuf,key_length)))
goto err2;
goto err;
}
if (cmp<=0) old_word++;
if (cmp>=0) new_word++;
@ -238,11 +236,8 @@ int _ma_ft_update(MARIA_HA *info, uint keynr, byte *keybuf,
else if (new_word->pos)
error= _ma_ft_store(info,keynr,keybuf,new_word,pos);
err2:
my_free((char*) newlist,MYF(0));
err1:
my_free((char*) oldlist,MYF(0));
err0:
err:
free_root(&info->ft_memroot, MYF(MY_MARK_BLOCKS_FREE));
DBUG_RETURN(error);
}
@ -255,12 +250,12 @@ int _ma_ft_add(MARIA_HA *info, uint keynr, byte *keybuf, const byte *record,
int error= -1;
FT_WORD *wlist;
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);
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);
}
@ -275,11 +270,9 @@ int _ma_ft_del(MARIA_HA *info, uint keynr, byte *keybuf, const byte *record,
DBUG_ENTER("_ma_ft_del");
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);
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);
}

View file

@ -24,12 +24,15 @@
#include <queues.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 word_char(s,X) (true_word_char(s,X) || misc_word_char(X))
#define FT_MAX_WORD_LEN_FOR_SORT 31
#define FTPARSER_MEMROOT_ALLOC_SIZE 65536
#define COMPILE_STOPWORDS_IN
/* Interested readers may consult SMART
@ -119,12 +122,12 @@ void _ma_ft_segiterator_dummy_init(const byte *, uint, FT_SEG_ITERATOR *);
uint _ma_ft_segiterator(FT_SEG_ITERATOR *);
void maria_ft_parse_init(TREE *, CHARSET_INFO *);
int maria_ft_parse(TREE *, byte *, int, my_bool, struct st_mysql_ftparser *parser,
MYSQL_FTPARSER_PARAM *param);
FT_WORD * maria_ft_linearize(TREE *);
FT_WORD * _ma_ft_parserecord(MARIA_HA *, uint, const byte *);
uint _ma_ft_parse(TREE *, MARIA_HA *, uint, const byte *, my_bool,
MYSQL_FTPARSER_PARAM *param);
int maria_ft_parse(TREE *, byte *, int, struct st_mysql_ftparser *parser,
MYSQL_FTPARSER_PARAM *, MEM_ROOT *);
FT_WORD * maria_ft_linearize(TREE *, MEM_ROOT *);
FT_WORD * _ma_ft_parserecord(MARIA_HA *, uint, const byte *, MEM_ROOT *);
uint _ma_ft_parse(TREE *, MARIA_HA *, uint, const byte *,
MYSQL_FTPARSER_PARAM *, MEM_ROOT *);
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 *);
@ -145,5 +148,6 @@ float maria_ft_boolean_get_relevance(FT_INFO *);
my_off_t maria_ft_boolean_get_docid(FT_INFO *);
void maria_ft_boolean_reinit_search(FT_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);

View file

@ -127,7 +127,7 @@ uint _ma_make_key(register MARIA_HA *info, uint keynr, uchar *key,
}
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 :
uint2korr(pos));
pos+= pack_length; /* Skip VARCHAR length */
@ -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
_ma_update_auto_increment()
info MARIA handler
retrieve_auto_increment()
info Maria handler
record Row to update
IMPLEMENTATION
Only replace the auto_increment value if it is higher than the previous
one. For signed columns we don't update the auto increment value if it's
For signed columns we don't retrieve the auto increment value if it's
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 */
longlong s_value= 0; /* Store signed values here */
@ -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
correct value.
*/
set_if_bigger(info->s->state.auto_increment,
(s_value > 0) ? (ulonglong) s_value : value);
return (s_value > 0) ? (ulonglong) s_value : value;
}

View file

@ -95,7 +95,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
bzero((byte*) &info,sizeof(info));
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);
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)
&share->data_file_name,strlen(data_name)+1,
&share->state.key_root,keys*sizeof(my_off_t),
&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
&share->key_root_lock,sizeof(rw_lock_t)*keys,
#endif
@ -302,7 +302,7 @@ MARIA_HA *maria_open(const char *name, int mode, uint open_flags)
(char*) key_root, sizeof(my_off_t)*keys);
memcpy((char*) share->state.key_del,
(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);
share->unique_name_length= strlen(name_buff);
strmov(share->index_file_name, index_name);
@ -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 *ptr=buff;
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");
memcpy_fixed(ptr,&state->header,sizeof(state->header));
@ -865,7 +865,7 @@ uchar *_ma_state_info_read(uchar *ptr, MARIA_STATE_INFO *state)
ptr +=sizeof(state->header);
keys=(uint) state->header.keys;
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->changed= (bool) *ptr++;
@ -1038,7 +1038,7 @@ char *_ma_keydef_read(char *ptr, MARIA_KEYDEF *keydef)
keydef->keylength = mi_uint2korr(ptr); ptr +=2;
keydef->minlength = 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->version = 0; /* Not saved */
keydef->parser = &ft_default_parser;

View file

@ -112,8 +112,8 @@ int _ma_dispose(register MARIA_HA *info, MARIA_KEYDEF *keyinfo, my_off_t pos,
DBUG_ENTER("_ma_dispose");
DBUG_PRINT("enter",("pos: %ld", (long) pos));
old_link=info->s->state.key_del[keyinfo->block_size];
info->s->state.key_del[keyinfo->block_size]=pos;
old_link= info->s->state.key_del[keyinfo->block_size_index];
info->s->state.key_del[keyinfo->block_size_index]= pos;
mi_sizestore(buff,old_link);
info->s->state.changed|= STATE_NOT_SORTED_PAGES;
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)
char buff[8];
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 >=
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)
(uint) keyinfo->block_length,0))
pos= HA_OFFSET_ERROR;
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;
DBUG_PRINT("exit",("Pos: %ld",(long) pos));

View file

@ -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,
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
@ -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,
info->lastkey_length,
maria_readnext_vec[search_flag],
info->s->state.key_root[inx]))
info->lastkey_length,
maria_readnext_vec[search_flag],
info->s->state.key_root[inx]))
break;
}
}

View file

@ -31,8 +31,9 @@
int maria_rsame_with_pos(MARIA_HA *info, byte *record, int inx, my_off_t filepos)
{
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);
}

View file

@ -183,9 +183,11 @@ int maria_rtree_find_first(MARIA_HA *info, uint keynr, uchar *key, uint key_leng
return -1;
}
/* Save searched key */
memcpy(info->first_mbr_key, key, keyinfo->keylength -
info->s->base.rec_reflength);
/*
Save searched key, include data pointer.
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->maria_rtree_recursion_depth = -1;

View file

@ -52,10 +52,14 @@
if (EQUAL_CMP(amin, amax, bmin, bmax)) \
return 1; \
} \
else /* if (nextflag & MBR_DISJOINT) */ \
else if (nextflag & MBR_DISJOINT) \
{ \
if (DISJOINT_CMP(amin, amax, bmin, bmax)) \
return 1; \
}\
else /* if unknown comparison operator */ \
{ \
DBUG_ASSERT(0); \
}
#define RT_CMP_KORR(type, korr_func, len, nextflag) \

View file

@ -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);
my_errno=HA_ERR_CRASHED;
DBUG_PRINT("error",("Found wrong key: length: %u page: %lx end: %lx",
length, (long) page, (long) end));
DBUG_PRINT("error",
("Found wrong key: length: %u page: 0x%lx end: 0x%lx",
length, (long) page, (long) end));
DBUG_RETURN(MARIA_FOUND_WRONG_KEY);
}
if ((flag=ha_key_cmp(keyinfo->seg,t_buff,key,key_len,comp_flag,
not_used)) >= 0)
break;
#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));
#endif
memcpy(buff,t_buff,length);
@ -276,7 +277,7 @@ int _ma_seq_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, uchar *page,
if (flag == 0)
memcpy(buff,t_buff,length); /* Result is first key */
*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);
} /* _ma_seq_search */
@ -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);
my_errno=HA_ERR_CRASHED;
DBUG_PRINT("error",("Found wrong key: length: %u page: %lx end: %lx",
length, (long) page, (long) end));
DBUG_PRINT("error",
("Found wrong key: length: %u page: 0x%lx end: %lx",
length, (long) page, (long) end));
DBUG_RETURN(MARIA_FOUND_WRONG_KEY);
}
@ -551,7 +553,7 @@ int _ma_prefix_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, uchar *pag
*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);
} /* _ma_prefix_search */
@ -813,7 +815,7 @@ uint _ma_get_pack_key(register MARIA_KEYDEF *keyinfo, uint nod_flag,
if (length > keyseg->length)
{
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));
DBUG_DUMP("key",(char*) *page_pos,16);
maria_print_error(keyinfo->share, HA_ERR_CRASHED);
@ -870,7 +872,7 @@ uint _ma_get_pack_key(register MARIA_KEYDEF *keyinfo, uint nod_flag,
}
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));
DBUG_DUMP("key",(char*) *page_pos,16);
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,
{
if (length > keyinfo->maxlength)
{
DBUG_PRINT("error",("Found too long binary packed key: %u of %u at %lx",
length, keyinfo->maxlength, (long) *page_pos));
DBUG_PRINT("error",
("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);
maria_print_error(keyinfo->share, 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,
length-=tmp;
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));
memmove((byte*) key, (byte*) from, (size_t) length);
key+=length;
@ -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));
DBUG_RETURN(page);
} /* _ma_get_key */
@ -1095,7 +1098,8 @@ uchar *_ma_get_last_key(MARIA_HA *info, MARIA_KEYDEF *keyinfo, uchar *page,
uint nod_flag;
uchar *lastpos;
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);
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,
*return_key_length=(*keyinfo->get_key)(keyinfo,nod_flag,&page,lastkey);
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));
maria_print_error(info->s, 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,
}
}
}
DBUG_PRINT("exit",("lastpos: %lx length: %u", (long) lastpos,
DBUG_PRINT("exit",("lastpos: 0x%lx length: %u", (long) lastpos,
*return_key_length));
DBUG_RETURN(lastpos);
} /* _ma_get_last_key */
@ -1472,7 +1476,7 @@ _ma_calc_var_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag,
if (!*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->next_key_pos=0; /* No next key */
return (s_temp->totlength);
@ -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->n_ref_length=s_temp->n_length= org_key_length;
length+= org_key_length;
/* +get_pack_length(org_key_length); */
}
return (int) length;
}
ref_length=n_length;
/* Get information about not packed key suffix */
get_key_pack_length(n_length,next_length_pack,next_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,
s_temp->part_of_prev_key= 0;
s_temp->prev_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;
}
if (ref_length+pack_marker > new_ref_length)
@ -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->n_ref_length=s_temp->n_length=n_length + s_temp->prev_length;
s_temp->prev_key+= new_pack_length;
/* +get_pack_length(org_key_length); */
length= length-get_pack_length(ref_length)+
get_pack_length(new_pack_length);
length-= (next_length_pack - get_pack_length(s_temp->n_length));
return (int) length + s_temp->prev_length;
}
}
@ -1664,7 +1665,7 @@ _ma_calc_var_pack_key_length(MARIA_KEYDEF *keyinfo, uint nod_flag,
ref_length=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));
{

View file

@ -442,6 +442,7 @@ err:
close_cached_file(&info->tempfile_for_exceptions);
ok:
free_root(&info->wordroot, MYF(0));
remove_io_thread(&info->read_cache);
pthread_mutex_lock(&info->sort_info->mutex);
info->sort_info->threads_running--;

View file

@ -96,6 +96,7 @@ static int run_test(const char *filename)
/* Define a key over the first column */
keyinfo[0].seg=keyseg;
keyinfo[0].keysegs=1;
keyinfo[0].block_length= 0; /* Default block length */
keyinfo[0].key_alg=HA_KEY_ALG_BTREE;
keyinfo[0].seg[0].type= key_type;
keyinfo[0].seg[0].flag= pack_seg;

View file

@ -96,6 +96,7 @@ int main(int argc, char *argv[])
keyinfo[0].key_alg=HA_KEY_ALG_BTREE;
keyinfo[0].keysegs=1;
keyinfo[0].flag = pack_type;
keyinfo[0].block_length= 0; /* Default block length */
keyinfo[1].seg= &glob_keyseg[1][0];
keyinfo[1].seg[0].start=7;
keyinfo[1].seg[0].length=6;
@ -112,6 +113,7 @@ int main(int argc, char *argv[])
keyinfo[1].key_alg=HA_KEY_ALG_BTREE;
keyinfo[1].keysegs=2;
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[0].start=12;
keyinfo[2].seg[0].length=8;
@ -122,6 +124,7 @@ int main(int argc, char *argv[])
keyinfo[2].key_alg=HA_KEY_ALG_BTREE;
keyinfo[2].keysegs=1;
keyinfo[2].flag =HA_NOSAME;
keyinfo[2].block_length= 0; /* Default block length */
keyinfo[3].seg= &glob_keyseg[3][0];
keyinfo[3].seg[0].start=0;
keyinfo[3].seg[0].length=reclength-(use_blob ? 8 : 0);
@ -133,6 +136,7 @@ int main(int argc, char *argv[])
keyinfo[3].key_alg=HA_KEY_ALG_BTREE;
keyinfo[3].keysegs=1;
keyinfo[3].flag = pack_type;
keyinfo[3].block_length= 0; /* Default block length */
keyinfo[4].seg= &glob_keyseg[4][0];
keyinfo[4].seg[0].start=0;
keyinfo[4].seg[0].length=5;
@ -144,6 +148,7 @@ int main(int argc, char *argv[])
keyinfo[4].key_alg=HA_KEY_ALG_BTREE;
keyinfo[4].keysegs=1;
keyinfo[4].flag = pack_type;
keyinfo[4].block_length= 0; /* Default block length */
keyinfo[5].seg= &glob_keyseg[5][0];
keyinfo[5].seg[0].start=0;
keyinfo[5].seg[0].length=4;
@ -155,6 +160,7 @@ int main(int argc, char *argv[])
keyinfo[5].key_alg=HA_KEY_ALG_BTREE;
keyinfo[5].keysegs=1;
keyinfo[5].flag = pack_type;
keyinfo[5].block_length= 0; /* Default block length */
recinfo[0].type=pack_fields ? FIELD_SKIP_PRESPACE : 0;
recinfo[0].length=7;
@ -701,7 +707,7 @@ int main(int argc, char *argv[])
if (!silent)
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))
{
@ -744,7 +750,7 @@ int main(int argc, char *argv[])
DBUG_PRINT("progpos",("Removing keys"));
lastpos = HA_OFFSET_ERROR;
/* DBUG_POP(); */
maria_extra(file,HA_EXTRA_RESET,0);
maria_reset(file);
found_parts=0;
while ((error=maria_rrnd(file,read_record,HA_OFFSET_ERROR)) !=
HA_ERR_END_OF_FILE)
@ -911,13 +917,13 @@ static void get_options(int argc, char **argv)
}
break;
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)
{
fprintf(stderr,"Wrong maria_block_length\n");
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;
case 'E': /* maria_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)
fprintf(stderr,"Wrong key_cache_block_size\n");
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;
case 'f':
if ((first_key=atoi(++pos)) < 0 || first_key >= MARIA_KEYS)

View file

@ -77,6 +77,7 @@ int main(int argc,char **argv)
keyinfo[0].key_alg=HA_KEY_ALG_BTREE;
keyinfo[0].keysegs=1;
keyinfo[0].flag = (uint8) HA_PACK_KEY;
keyinfo[0].block_length= 0; /* Default block length */
keyinfo[1].seg= &keyseg[1][0];
keyinfo[1].seg[0].start=8;
keyinfo[1].seg[0].length=4; /* Long is always 4 in maria */
@ -85,6 +86,7 @@ int main(int argc,char **argv)
keyinfo[1].key_alg=HA_KEY_ALG_BTREE;
keyinfo[1].keysegs=1;
keyinfo[1].flag =HA_NOSAME;
keyinfo[1].block_length= 0; /* Default block length */
recinfo[0].type=0;
recinfo[0].length=sizeof(record.id);

View file

@ -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 */
}
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)
info->state->checksum+=(info->checksum - old_checksum);

View file

@ -145,7 +145,8 @@ int maria_write(MARIA_HA *info, byte *record)
info->state->checksum+=info->checksum;
}
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 |
HA_STATE_ROW_CHANGED);
info->state->records++;

View file

@ -34,10 +34,6 @@ SET_STACK_SIZE(9000) /* Minimum stack size for program */
#define my_raid_delete(A,B,C) my_delete(A,B)
#endif
#ifdef OS2
#define _sanity(a,b)
#endif
static uint decode_bits;
static char **default_argv;
static const char *load_default_groups[]= { "mariachk", 0 };
@ -92,10 +88,6 @@ int main(int argc, char **argv)
MY_INIT(argv[0]);
my_progname_short= my_progname+dirname_length(my_progname);
#ifdef __EMX__
_wildcard (&argc, &argv);
#endif
mariachk_init(&check_param);
check_param.opt_lock_memory= 1; /* Lock memory if possible */
check_param.using_global_keycache = 0;
@ -381,7 +373,7 @@ static void usage(void)
directly with '--variable-name=value'.\n\
-t, --tmpdir=path Path for temporary files. Multiple paths can be\n\
specified, separated by ");
#if defined( __WIN__) || defined(OS2) || defined(__NETWARE__)
#if defined( __WIN__) || defined(__NETWARE__)
printf("semicolon (;)");
#else
printf("colon (:)");

View file

@ -55,7 +55,7 @@ typedef struct st_maria_state_info
uchar keys; /* number of keys in file */
uchar uniques; /* number of UNIQUE definitions */
uchar language; /* Language for indexes */
uchar max_block_size; /* max keyblock size */
uchar max_block_size_index; /* max keyblock size */
uchar fulltext_keys;
uchar not_used; /* To align to 8 */
} header;
@ -246,6 +246,7 @@ struct st_maria_info
/* accumulate indexfile changes between write's */
TREE *bulk_insert;
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 */
char *filename; /* parameter to open filename */
uchar *buff, /* Temp area for key */
@ -398,7 +399,7 @@ struct st_maria_info
#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_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_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,
byte *buf);
extern int _ma_read_cache(IO_CACHE *info, byte *buff, my_off_t pos,
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 **);
#define _ma_get_rec_buff_ptr(info,buf) \

View file

@ -34,20 +34,20 @@ static uint lengths[256];
static struct my_option my_long_options[] =
{
{"help", 'h', "Display help and exit.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"help", '?', "Synonym for -h.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"count", 'c', "Calculate per-word stats (counts and global weights).",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"dump", 'd', "Dump index (incl. data offsets and word weights).",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"length", 'l', "Report length distribution.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"stats", 's', "Report global stats.",
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).",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"length", 'l', "Report length distribution.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"help", 'h', "Display help and exit.",
0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0},
{"help", '?', "Synonym for -h.",
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[])
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;
goto err;

View file

@ -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);
for (key=0 ; key < share->base.keys ; key++)
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;
isam_file->state->checksum=crc; /* Save crc here */
share->changed=1; /* Force write of header */
@ -3035,7 +3035,7 @@ static int mrg_rrnd(PACK_MRG_INFO *info,byte *buf)
{
isam_info= *(info->current=info->file);
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);
filepos=isam_info->s->pack.header_length;
}
@ -3058,7 +3058,7 @@ static int mrg_rrnd(PACK_MRG_INFO *info,byte *buf)
info->current++;
isam_info= *info->current;
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);
}
}