Commit 5bef77a3 authored by unknown's avatar unknown

Merge bk-internal.mysql.com:/home/bk/mysql-maria

into  mysql.com:/home/my/mysql-maria


BitKeeper/etc/ignore:
  auto-union
BUILD/SETUP.sh:
  Auto merged
mysql-test/lib/init_db.sql:
  Auto merged
mysql-test/lib/mtr_cases.pl:
  Auto merged
mysql-test/lib/mtr_diff.pl:
  Auto merged
mysql-test/lib/mtr_gcov.pl:
  Auto merged
mysql-test/lib/mtr_gprof.pl:
  Auto merged
mysql-test/lib/mtr_im.pl:
  Auto merged
mysql-test/lib/mtr_io.pl:
  Auto merged
mysql-test/lib/mtr_match.pl:
  Auto merged
mysql-test/lib/mtr_misc.pl:
  Auto merged
mysql-test/lib/mtr_process.pl:
  Auto merged
mysql-test/lib/mtr_report.pl:
  Auto merged
mysql-test/lib/mtr_stress.pl:
  Auto merged
mysql-test/lib/mtr_timer.pl:
  Auto merged
mysql-test/lib/mtr_unique.pl:
  Auto merged
mysql-test/mysql-test-run.pl:
  Auto merged
mysql-test/t/disabled.def:
  Auto merged
mysql-test/t/myisam.test:
  Auto merged
mysql-test/t/query_cache_notembedded.test:
  Auto merged
sql/filesort.cc:
  Auto merged
sql/handler.cc:
  Auto merged
sql/slave.cc:
  Auto merged
sql/slave.h:
  Auto merged
sql/sql_table.cc:
  Auto merged
storage/maria/ha_maria.h:
  Auto merged
storage/maria/ma_bitmap.c:
  Auto merged
storage/maria/ma_blockrec.c:
  Auto merged
storage/maria/ma_blockrec.h:
  Auto merged
storage/maria/ma_check.c:
  Auto merged
storage/maria/ma_checksum.c:
  Auto merged
storage/maria/ma_create.c:
  Auto merged
storage/maria/ma_delete.c:
  Auto merged
storage/maria/ma_delete_all.c:
  Auto merged
storage/maria/ma_extra.c:
  Auto merged
storage/maria/ma_info.c:
  Auto merged
storage/maria/ma_search.c:
  Auto merged
storage/maria/ma_test2.c:
  Auto merged
storage/maria/ma_write.c:
  Auto merged
storage/maria/maria_def.h:
  Auto merged
storage/myisam/mi_create.c:
  Auto merged
storage/myisam/mi_test2.c:
  Auto merged
sql/share/errmsg.txt:
  Use remote version
mysql-test/include/varchar.inc:
  Manual merge (take changes from remote tree)
storage/maria/ha_maria.cc:
  Manual merge
parents 1a77ebd1 0abffa05
...@@ -2401,6 +2401,15 @@ storage/maria/maria_ftdump ...@@ -2401,6 +2401,15 @@ storage/maria/maria_ftdump
storage/maria/maria_log storage/maria/maria_log
storage/maria/maria_pack storage/maria/maria_pack
storage/maria/unittest/maria_control storage/maria/unittest/maria_control
storage/maria/unittest/mf_pagecache_consist_1k-t-big
storage/maria/unittest/mf_pagecache_consist_1kHC-t-big
storage/maria/unittest/mf_pagecache_consist_1kRD-t-big
storage/maria/unittest/mf_pagecache_consist_1kWR-t-big
storage/maria/unittest/mf_pagecache_consist_64k-t-big
storage/maria/unittest/mf_pagecache_consist_64kHC-t-big
storage/maria/unittest/mf_pagecache_consist_64kRD-t-big
storage/maria/unittest/mf_pagecache_consist_64kWR-t-big
storage/maria/unittest/mf_pagecache_single_64k-t-big
storage/myisam/.deps/ft_boolean_search.Po storage/myisam/.deps/ft_boolean_search.Po
storage/myisam/.deps/ft_nlq_search.Po storage/myisam/.deps/ft_nlq_search.Po
storage/myisam/.deps/ft_parser.Po storage/myisam/.deps/ft_parser.Po
......
...@@ -121,9 +121,8 @@ valgrind_flags="-USAFEMALLOC -UFORCE_INIT_OF_VARS -DHAVE_purify " ...@@ -121,9 +121,8 @@ valgrind_flags="-USAFEMALLOC -UFORCE_INIT_OF_VARS -DHAVE_purify "
valgrind_flags="$valgrind_flags -DMYSQL_SERVER_SUFFIX=-valgrind-max" valgrind_flags="$valgrind_flags -DMYSQL_SERVER_SUFFIX=-valgrind-max"
# #
# Used in -debug builds # Used in -debug builds
debug_cflags="-DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS" debug_cflags="-DUNIV_MUST_NOT_INLINE -DEXTRA_DEBUG -DFORCE_INIT_OF_VARS "
debug_cflags="$debug_cflags -DSAFEMALLOC -DPEDANTIC_SAFEMALLOC -DSAFE_MUTEX" debug_cflags="$debug_cflags -DSAFEMALLOC -DPEDANTIC_SAFEMALLOC -DSAFE_MUTEX"
debug_cflags="$debug_cflags -DMY_LF_EXTRA_DEBUG"
error_inject="--with-error-inject " error_inject="--with-error-inject "
# #
# Base C++ flags for all builds # Base C++ flags for all builds
...@@ -155,6 +154,8 @@ then ...@@ -155,6 +154,8 @@ then
base_configs="$base_configs --with-libedit" base_configs="$base_configs --with-libedit"
fi fi
static_link="--with-mysqld-ldflags=-all-static "
static_link="$static_link --with-client-ldflags=-all-static"
# we need local-infile in all binaries for rpl000001 # we need local-infile in all binaries for rpl000001
# if you need to disable local-infile in the client, write a build script # if you need to disable local-infile in the client, write a build script
# and unset local_infile_configs # and unset local_infile_configs
......
...@@ -122,22 +122,23 @@ typedef struct st_maria_isaminfo /* Struct from h_info */ ...@@ -122,22 +122,23 @@ typedef struct st_maria_isaminfo /* Struct from h_info */
my_off_t data_file_length; /* Length of data file */ my_off_t data_file_length; /* Length of data file */
my_off_t max_data_file_length, index_file_length; my_off_t max_data_file_length, index_file_length;
my_off_t max_index_file_length, delete_length; my_off_t max_index_file_length, delete_length;
ulong reclength; /* Recordlength */
ulong mean_reclength; /* Mean recordlength (if packed) */
ulonglong auto_increment; ulonglong auto_increment;
ulonglong key_map; /* Which keys are used */ ulonglong key_map; /* Which keys are used */
time_t create_time; /* When table was created */
time_t check_time;
time_t update_time;
ulong record_offset;
ulong *rec_per_key; /* for sql optimizing */
ulong reclength; /* Recordlength */
ulong mean_reclength; /* Mean recordlength (if packed) */
char *data_file_name, *index_file_name; char *data_file_name, *index_file_name;
enum data_file_type data_file_type;
uint keys; /* Number of keys in use */ uint keys; /* Number of keys in use */
uint options; /* HA_OPTION_... used */ uint options; /* HA_OPTION_... used */
uint reflength;
int errkey, /* With key was dupplicated on err */ int errkey, /* With key was dupplicated on err */
sortkey; /* clustered by this key */ sortkey; /* clustered by this key */
File filenr; /* (uniq) filenr for datafile */ File filenr; /* (uniq) filenr for datafile */
time_t create_time; /* When table was created */
time_t check_time;
time_t update_time;
uint reflength;
ulong record_offset;
ulong *rec_per_key; /* for sql optimizing */
} MARIA_INFO; } MARIA_INFO;
......
...@@ -2237,6 +2237,25 @@ sub setup_vardir() { ...@@ -2237,6 +2237,25 @@ sub setup_vardir() {
{ {
unlink($name); unlink($name);
} }
if ( $opt_valgrind and $opt_debug )
{
# When both --valgrind and --debug is selected, send
# all output to the trace file, making it possible to
# see the exact location where valgrind complains
foreach my $mysqld (@{$master}, @{$slave})
{
my $sidx= $mysqld->{idx} ? "$mysqld->{idx}" : "";
my $trace_name= "$opt_vardir/log/" . $mysqld->{type} . "$sidx.trace";
open(LOG, ">$mysqld->{path_myerr}") or die "Can't create $mysqld->{path_myerr}\n";
print LOG "
NOTE: When running with --valgrind --debug the output from the .err file is
stored together with the trace file to make it easier to find the exact
position for valgrind errors.
See trace file $trace_name.\n";
close(LOG);
$mysqld->{path_myerr}= $trace_name;
}
}
} }
......
This diff is collapsed.
...@@ -39,5 +39,4 @@ mysql_upgrade : Bug#25074 mysql_upgrade gives inconsisten results ...@@ -39,5 +39,4 @@ mysql_upgrade : Bug#25074 mysql_upgrade gives inconsisten results
plugin : Bug#25659 memory leak via "plugins" test plugin : Bug#25659 memory leak via "plugins" test
rpl_ndb_dd_advance : Bug#25913 rpl_ndb_dd_advance fails randomly rpl_ndb_dd_advance : Bug#25913 rpl_ndb_dd_advance fails randomly
ndb_alter_table : Bug##25774 ndb_alter_table.test fails in DBUG_ASSERT() on Linux x64 ndb_alter_table : Bug##25774 ndb_alter_table.test fails in DBUG_ASSERT() on Linux x64
maria : Until maria is fully functional
ps_maria : Until maria is fully functional ps_maria : Until maria is fully functional
# #
# Test bugs in the MARIA code # Testing of potential probelms in Maria
# This code was initially taken from myisam.test
# #
-- source include/have_maria.inc -- source include/have_maria.inc
let $default=`select @@global.storage_engine`; let $default=`select @@global.storage_engine`;
...@@ -48,7 +50,7 @@ while ($1) ...@@ -48,7 +50,7 @@ while ($1)
} }
SET SQL_WARNINGS=1; SET SQL_WARNINGS=1;
--enable_warnings --enable_warnings
enable_query_log; --enable_query_log
check table t1; check table t1;
repair table t1; repair table t1;
delete from t1 where (a & 1); delete from t1 where (a & 1);
...@@ -404,7 +406,7 @@ check table t1; ...@@ -404,7 +406,7 @@ check table t1;
drop table t1; drop table t1;
# #
# two bugs in maria-space-stripping feature # Test space-stripping features
# #
create table t1 ( a text not null, key a (a(20))); create table t1 ( a text not null, key a (a(20)));
insert into t1 values ('aaa '),('aaa'),('aa'); insert into t1 values ('aaa '),('aaa'),('aa');
...@@ -417,7 +419,7 @@ select concat(a,'.') from t1; ...@@ -417,7 +419,7 @@ select concat(a,'.') from t1;
drop table t1; drop table t1;
# #
# Third bug in the same code (BUG#2295) # More space testing
# #
create table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10))); create table t1(a text not null, b text not null, c text not null, index (a(10),b(10),c(10)));
...@@ -428,9 +430,9 @@ select * from t1 where a='807780' and b='477' and c='165'; ...@@ -428,9 +430,9 @@ select * from t1 where a='807780' and b='477' and c='165';
drop table t1; drop table t1;
# #
# space-stripping in _mi_prefix_search: BUG#5284 # Space-stripping in prefix_search
# #
DROP TABLE IF EXISTS t1;
CREATE TABLE t1 (a varchar(150) NOT NULL, KEY (a)); CREATE TABLE t1 (a varchar(150) NOT NULL, KEY (a));
INSERT t1 VALUES ("can \tcan"); INSERT t1 VALUES ("can \tcan");
INSERT t1 VALUES ("can can"); INSERT t1 VALUES ("can can");
...@@ -442,6 +444,7 @@ DROP TABLE t1; ...@@ -442,6 +444,7 @@ DROP TABLE t1;
# #
# Verify blob handling # Verify blob handling
# #
create table t1 (a blob); create table t1 (a blob);
insert into t1 values('a '),('a'); insert into t1 values('a '),('a');
select concat(a,'.') from t1 where a='a'; select concat(a,'.') from t1 where a='a';
...@@ -458,9 +461,9 @@ create table t1 (a int not null auto_increment primary key, b text not null, uni ...@@ -458,9 +461,9 @@ create table t1 (a int not null auto_increment primary key, b text not null, uni
insert into t1 (b) values ('a'),('b'),('c'); insert into t1 (b) values ('a'),('b'),('c');
select concat(b,'.') from t1; select concat(b,'.') from t1;
update t1 set b='b ' where a=2; update t1 set b='b ' where a=2;
--error 1062 --error 1582
update t1 set b='b ' where a > 1; update t1 set b='b ' where a > 1;
--error 1062 --error 1582
insert into t1 (b) values ('b'); insert into t1 (b) values ('b');
select * from t1; select * from t1;
delete from t1 where b='b'; delete from t1 where b='b';
...@@ -468,7 +471,7 @@ select a,concat(b,'.') from t1; ...@@ -468,7 +471,7 @@ select a,concat(b,'.') from t1;
drop table t1; drop table t1;
# #
# Test keys with 0 segments. (Bug #3203) # Test keys with 0 segments
# #
create table t1 (a int not null); create table t1 (a int not null);
create table t2 (a int not null, primary key (a)); create table t2 (a int not null, primary key (a));
...@@ -482,7 +485,7 @@ explain select distinct t1.a from t1,t2 order by t2.a; ...@@ -482,7 +485,7 @@ explain select distinct t1.a from t1,t2 order by t2.a;
drop table t1,t2; drop table t1,t2;
# #
# Bug#14616 - Freshly imported table returns error 124 when using LIMIT # Test freshly imported table and LIMIT
# #
create table t1 ( create table t1 (
c1 varchar(32), c1 varchar(32),
...@@ -494,16 +497,18 @@ select c1 from t1 order by c1 limit 1; ...@@ -494,16 +497,18 @@ select c1 from t1 order by c1 limit 1;
drop table t1; drop table t1;
# #
# Bug #14400 Join could miss concurrently inserted row # Test join that could miss concurrently inserted row
# Note that for the moment Maria only supports multiple writers if we have
# static or dynamic row format
# #
# Partial key. # Partial key.
create table t1 (a int not null, primary key(a)); create table t1 (a int not null, primary key(a)) ROW_FORMAT=FIXED;
create table t2 (a int not null, b int not null, primary key(a,b)); create table t2 (a int not null, b int not null, primary key(a,b)) ROW_FORMAT=FIXED;
insert into t1 values (1),(2),(3),(4),(5),(6); insert into t1 values (1),(2),(3),(4),(5),(6);
insert into t2 values (1,1),(2,1); insert into t2 values (1,1),(2,1);
lock tables t1 read local, t2 read local; lock tables t1 read local, t2 read local;
select straight_join * from t1,t2 force index (primary) where t1.a=t2.a; select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
connect (root,localhost,root,,test,$MASTER_MYPORT,master.sock); connect (root,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
insert into t2 values(2,0); insert into t2 values(2,0);
disconnect root; disconnect root;
connection default; connection default;
...@@ -511,8 +516,8 @@ select straight_join * from t1,t2 force index (primary) where t1.a=t2.a; ...@@ -511,8 +516,8 @@ select straight_join * from t1,t2 force index (primary) where t1.a=t2.a;
drop table t1,t2; drop table t1,t2;
# #
# Full key. # Full key.
CREATE TABLE t1 (c1 varchar(250) NOT NULL); CREATE TABLE t1 (c1 varchar(250) NOT NULL) ROW_FORMAT=DYNAMIC;
CREATE TABLE t2 (c1 varchar(250) NOT NULL, PRIMARY KEY (c1)); CREATE TABLE t2 (c1 varchar(250) NOT NULL, PRIMARY KEY (c1)) ROW_FORMAT=DYNAMIC;
INSERT INTO t1 VALUES ('test000001'), ('test000002'), ('test000003'); INSERT INTO t1 VALUES ('test000001'), ('test000002'), ('test000003');
INSERT INTO t2 VALUES ('test000002'), ('test000003'), ('test000004'); INSERT INTO t2 VALUES ('test000002'), ('test000003'), ('test000004');
LOCK TABLES t1 READ LOCAL, t2 READ LOCAL; LOCK TABLES t1 READ LOCAL, t2 READ LOCAL;
...@@ -527,8 +532,6 @@ SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2 ...@@ -527,8 +532,6 @@ SELECT t1.c1 AS t1c1, t2.c1 AS t2c1 FROM t1, t2
WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1; WHERE t1.c1 = t2.c1 HAVING t1c1 != t2c1;
DROP TABLE t1,t2; DROP TABLE t1,t2;
# End of 4.0 tests
# #
# Test RTREE index # Test RTREE index
# #
...@@ -566,13 +569,16 @@ insert t1 select * from t2; ...@@ -566,13 +569,16 @@ insert t1 select * from t2;
show keys from t1; show keys from t1;
alter table t1 enable keys; alter table t1 enable keys;
show keys from t1; show keys from t1;
#TODO after we have repair: delete the following --disable-warnings
--disable_warnings
alter table t1 engine=heap; alter table t1 engine=heap;
--enable_warnings
alter table t1 disable keys; alter table t1 disable keys;
show keys from t1; show keys from t1;
drop table t1,t2; drop table t1,t2;
# #
# index search for NULL in blob. Bug #4816 # Index search for NULL in blob
# #
create table t1 ( a tinytext, b char(1), index idx (a(1),b) ); create table t1 ( a tinytext, b char(1), index idx (a(1),b) );
insert into t1 values (null,''), (null,''); insert into t1 values (null,''), (null,'');
...@@ -581,7 +587,7 @@ select count(*) from t1 where a is null; ...@@ -581,7 +587,7 @@ select count(*) from t1 where a is null;
drop table t1; drop table t1;
# #
# bug9188 - Corruption Can't open file: 'table.MYI' (errno: 145) # Test corruption Can't open file: 'table.MYI' (errno: 145)
# #
create table t1 (c1 int, c2 varchar(4) not null default '', create table t1 (c1 int, c2 varchar(4) not null default '',
key(c2(3))) default charset=utf8; key(c2(3))) default charset=utf8;
...@@ -592,9 +598,9 @@ drop table t1; ...@@ -592,9 +598,9 @@ drop table t1;
# #
# Bug#12296 - CHECKSUM TABLE reports 0 for the table # Test CHECKSUM TABLE
# This happened if the first record was marked as deleted.
# #
create table t1 (c1 int); create table t1 (c1 int);
insert into t1 values (1),(2),(3),(4); insert into t1 values (1),(2),(3),(4);
checksum table t1; checksum table t1;
...@@ -607,7 +613,7 @@ checksum table t2; ...@@ -607,7 +613,7 @@ checksum table t2;
drop table t1, t2; drop table t1, t2;
# #
# BUG#12232: New maria_stats_method variable. # maria_stats_method variable.
# #
show variables like 'maria_stats_method'; show variables like 'maria_stats_method';
...@@ -677,7 +683,9 @@ show index from t1; ...@@ -677,7 +683,9 @@ show index from t1;
set maria_stats_method=DEFAULT; set maria_stats_method=DEFAULT;
drop table t1; drop table t1;
# BUG#13814 - key value packed incorrectly for TINYBLOBs #
# Test key value packing for TINYBLOBs
#
create table t1( create table t1(
cip INT NOT NULL, cip INT NOT NULL,
...@@ -695,8 +703,9 @@ select * from t1 where bob is null and cip=1; ...@@ -695,8 +703,9 @@ select * from t1 where bob is null and cip=1;
drop table t1; drop table t1;
# #
# Bug#14980 - COUNT(*) incorrect on MARIA table with certain INDEX # Test COUNT(*) table with different INDEX
# #
create table t1 ( create table t1 (
id1 int not null auto_increment, id1 int not null auto_increment,
id2 int not null default '0', id2 int not null default '0',
...@@ -713,9 +722,9 @@ select count(id1) from t1 where id2 = 10; ...@@ -713,9 +722,9 @@ select count(id1) from t1 where id2 = 10;
drop table t1; drop table t1;
# #
# BUG##20357 - Got error 124 from storage engine using MIN and MAX functions # Test MIN and MAX functions in queries
# in queries
# #
CREATE TABLE t1(a TINYINT, KEY(a)); CREATE TABLE t1(a TINYINT, KEY(a));
INSERT INTO t1 VALUES(1); INSERT INTO t1 VALUES(1);
SELECT MAX(a) FROM t1 IGNORE INDEX(a); SELECT MAX(a) FROM t1 IGNORE INDEX(a);
...@@ -725,7 +734,7 @@ SELECT MAX(a) FROM t1 IGNORE INDEX(a); ...@@ -725,7 +734,7 @@ SELECT MAX(a) FROM t1 IGNORE INDEX(a);
DROP TABLE t1; DROP TABLE t1;
# #
# BUG#18036 - update of table joined to self reports table as crashed # Test update of table joined to self
# #
CREATE TABLE t1(a CHAR(9), b VARCHAR(7)); CREATE TABLE t1(a CHAR(9), b VARCHAR(7));
INSERT INTO t1(a) VALUES('xxxxxxxxx'),('xxxxxxxxx'); INSERT INTO t1(a) VALUES('xxxxxxxxx'),('xxxxxxxxx');
...@@ -734,7 +743,7 @@ SELECT * FROM t1; ...@@ -734,7 +743,7 @@ SELECT * FROM t1;
DROP TABLE t1; DROP TABLE t1;
# #
# Bug#8283 - OPTIMIZE TABLE causes data loss # OPTIMIZE TABLE with multiple threads
# #
SET @@maria_repair_threads=2; SET @@maria_repair_threads=2;
SHOW VARIABLES LIKE 'maria_repair%'; SHOW VARIABLES LIKE 'maria_repair%';
...@@ -756,7 +765,7 @@ CREATE TABLE t1 ( ...@@ -756,7 +765,7 @@ CREATE TABLE t1 (
PRIMARY KEY (`_id`), PRIMARY KEY (`_id`),
UNIQUE KEY `sequence_name_index` (`name`(50)), UNIQUE KEY `sequence_name_index` (`name`(50)),
KEY (`length_`) KEY (`length_`)
) ENGINE=maria DEFAULT CHARSET=latin1; ) DEFAULT CHARSET=latin1;
# #
INSERT INTO t1 VALUES INSERT INTO t1 VALUES
(1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''), (1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
...@@ -798,7 +807,7 @@ CREATE TABLE t1 ( ...@@ -798,7 +807,7 @@ CREATE TABLE t1 (
PRIMARY KEY (`_id`), PRIMARY KEY (`_id`),
UNIQUE KEY `sequence_name_index` (`name`(50)), UNIQUE KEY `sequence_name_index` (`name`(50)),
KEY (`length_`) KEY (`length_`)
) ENGINE=maria DEFAULT CHARSET=latin1; ) DEFAULT CHARSET=latin1;
# #
INSERT INTO t1 VALUES INSERT INTO t1 VALUES
(1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''), (1,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,'sample1',''),
...@@ -825,6 +834,7 @@ DROP TABLE t1; ...@@ -825,6 +834,7 @@ DROP TABLE t1;
# #
SET @@maria_repair_threads=1; SET @@maria_repair_threads=1;
SHOW VARIABLES LIKE 'maria_repair%'; SHOW VARIABLES LIKE 'maria_repair%';
# #
# Test varchar # Test varchar
# #
...@@ -854,7 +864,7 @@ create table t1 (v varchar(65535)); ...@@ -854,7 +864,7 @@ create table t1 (v varchar(65535));
# #
set @save_concurrent_insert=@@concurrent_insert; set @save_concurrent_insert=@@concurrent_insert;
set global concurrent_insert=1; set global concurrent_insert=1;
create table t1 (a int); create table t1 (a int) ROW_FORMAT=FIXED;
insert into t1 values (1),(2),(3),(4),(5); insert into t1 values (1),(2),(3),(4),(5);
lock table t1 read local; lock table t1 read local;
connect (con1,localhost,root,,); connect (con1,localhost,root,,);
...@@ -879,7 +889,7 @@ drop table t1; ...@@ -879,7 +889,7 @@ drop table t1;
disconnect con1; disconnect con1;
# Same test with dynamic record length # Same test with dynamic record length
create table t1 (a int, b varchar(30) default "hello"); create table t1 (a int, b varchar(30) default "hello") ROW_FORMAT=DYNAMIC;
insert into t1 (a) values (1),(2),(3),(4),(5); insert into t1 (a) values (1),(2),(3),(4),(5);
lock table t1 read local; lock table t1 read local;
connect (con1,localhost,root,,); connect (con1,localhost,root,,);
...@@ -904,9 +914,10 @@ drop table t1; ...@@ -904,9 +914,10 @@ drop table t1;
disconnect con1; disconnect con1;
set global concurrent_insert=@save_concurrent_insert; set global concurrent_insert=@save_concurrent_insert;
#
# ANALYZE TABLE and ALTER TABLE .. ENABLE INDEX
#
# 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)); create table t1 (a int, key(a));
insert into t1 values (1),(2),(3),(4),(NULL),(NULL),(NULL),(NULL); insert into t1 values (1),(2),(3),(4),(NULL),(NULL),(NULL),(NULL);
...@@ -920,7 +931,7 @@ show keys from t1; ...@@ -920,7 +931,7 @@ show keys from t1;
drop table t1; drop table t1;
# #
# Bug#8706 - temporary table with data directory option fails # Test temporary table with data directory option
# #
connect (session1,localhost,root,,); connect (session1,localhost,root,,);
connect (session2,localhost,root,,); connect (session2,localhost,root,,);
...@@ -957,7 +968,7 @@ drop table t1; ...@@ -957,7 +968,7 @@ drop table t1;
--echo End of 4.1 tests --echo End of 4.1 tests
# #
# Bug#10056 - PACK_KEYS option take values greater than 1 while creating table # Test if PACK_KEYS option takes values greater than 1 while creating table
# #
create table t1 (c1 int) pack_keys=0; create table t1 (c1 int) pack_keys=0;
create table t2 (c1 int) pack_keys=1; create table t2 (c1 int) pack_keys=1;
...@@ -966,8 +977,6 @@ create table t3 (c1 int) pack_keys=default; ...@@ -966,8 +977,6 @@ create table t3 (c1 int) pack_keys=default;
create table t4 (c1 int) pack_keys=2; create table t4 (c1 int) pack_keys=2;
drop table t1, t2, t3; drop table t1, t2, t3;
--echo End of 5.0 tests
# #
# Test of key_block_size # Test of key_block_size
# #
...@@ -1033,7 +1042,7 @@ create table t1 (a int not null, key `a` key_block_size=1024 (a)); ...@@ -1033,7 +1042,7 @@ create table t1 (a int not null, key `a` key_block_size=1024 (a));
# #
# Bug#22119 - Changing MI_KEY_BLOCK_LENGTH makes a wrong myisamchk # Test of changing MI_KEY_BLOCK_LENGTH
# #
CREATE TABLE t1 ( CREATE TABLE t1 (
c1 INT, c1 INT,
...@@ -1075,8 +1084,6 @@ DELETE FROM t1 WHERE c1 >= 10; ...@@ -1075,8 +1084,6 @@ DELETE FROM t1 WHERE c1 >= 10;
CHECK TABLE t1; CHECK TABLE t1;
DROP TABLE t1; DROP TABLE t1;
--echo End of 5.1 tests # End of 5.2 tests
eval set global storage_engine=$default; eval set global storage_engine=$default;
# End of 5.2 tests
...@@ -451,7 +451,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, ...@@ -451,7 +451,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select,
ref_pos= ref_buff; ref_pos= ref_buff;
quick_select=select && select->quick; quick_select=select && select->quick;
record=0; record=0;
flag= ((!indexfile && file->ha_table_flags() & HA_REC_NOT_IN_SEQ) flag= ((!indexfile && (file->ha_table_flags() & HA_REC_NOT_IN_SEQ))
|| quick_select); || quick_select);
if (indexfile || flag) if (indexfile || flag)
ref_pos= &file->ref[0]; ref_pos= &file->ref[0];
......
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#include <my_dir.h> #include <my_dir.h>
#include <sql_common.h> #include <sql_common.h>
static Log_event* next_event(RELAY_LOG_INFO* rli);
#ifdef HAVE_REPLICATION #ifdef HAVE_REPLICATION
#include "rpl_tblmap.h" #include "rpl_tblmap.h"
......
...@@ -126,7 +126,7 @@ static void _ma_check_print_msg(HA_CHECK *param, const char *msg_type, ...@@ -126,7 +126,7 @@ static void _ma_check_print_msg(HA_CHECK *param, const char *msg_type,
RETURN VALUE RETURN VALUE
0 OK 0 OK
!0 error code # error code
*/ */
int table2maria(TABLE *table_arg, MARIA_KEYDEF **keydef_out, int table2maria(TABLE *table_arg, MARIA_KEYDEF **keydef_out,
...@@ -142,6 +142,7 @@ int table2maria(TABLE *table_arg, MARIA_KEYDEF **keydef_out, ...@@ -142,6 +142,7 @@ int table2maria(TABLE *table_arg, MARIA_KEYDEF **keydef_out,
TABLE_SHARE *share= table_arg->s; TABLE_SHARE *share= table_arg->s;
uint options= share->db_options_in_use; uint options= share->db_options_in_use;
DBUG_ENTER("table2maria"); DBUG_ENTER("table2maria");
if (!(my_multi_malloc(MYF(MY_WME), if (!(my_multi_malloc(MYF(MY_WME),
recinfo_out, (share->fields * 2 + 2) * sizeof(MARIA_COLUMNDEF), recinfo_out, (share->fields * 2 + 2) * sizeof(MARIA_COLUMNDEF),
keydef_out, share->keys * sizeof(MARIA_KEYDEF), keydef_out, share->keys * sizeof(MARIA_KEYDEF),
...@@ -268,7 +269,8 @@ int table2maria(TABLE *table_arg, MARIA_KEYDEF **keydef_out, ...@@ -268,7 +269,8 @@ int table2maria(TABLE *table_arg, MARIA_KEYDEF **keydef_out,
recinfo_pos->type= FIELD_BLOB; recinfo_pos->type= FIELD_BLOB;
else if (found->type() == MYSQL_TYPE_VARCHAR) else if (found->type() == MYSQL_TYPE_VARCHAR)
recinfo_pos->type= FIELD_VARCHAR; recinfo_pos->type= FIELD_VARCHAR;
else if (!(options & HA_OPTION_PACK_RECORD)) else if (!(options & HA_OPTION_PACK_RECORD) ||
(found->zero_pack() && (found->flags & PRI_KEY_FLAG)))
recinfo_pos->type= FIELD_NORMAL; recinfo_pos->type= FIELD_NORMAL;
else if (found->zero_pack()) else if (found->zero_pack())
recinfo_pos->type= FIELD_SKIP_ZERO; recinfo_pos->type= FIELD_SKIP_ZERO;
...@@ -503,6 +505,14 @@ const char *ha_maria::index_type(uint key_number) ...@@ -503,6 +505,14 @@ const char *ha_maria::index_type(uint key_number)
} }
double ha_maria::scan_time()
{
if (file->s->data_file_type == BLOCK_RECORD)
return ulonglong2double(stats.data_file_length - file->s->block_size) / max(file->s->block_size / 2, IO_SIZE) + 2;
return handler::scan_time();
}
#ifdef HAVE_REPLICATION #ifdef HAVE_REPLICATION
int ha_maria::net_read_dump(NET * net) int ha_maria::net_read_dump(NET * net)
{ {
...@@ -653,7 +663,7 @@ int ha_maria::open(const char *name, int mode, uint test_if_locked) ...@@ -653,7 +663,7 @@ int ha_maria::open(const char *name, int mode, uint test_if_locked)
info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST); info(HA_STATUS_NO_LOCK | HA_STATUS_VARIABLE | HA_STATUS_CONST);
if (!(test_if_locked & HA_OPEN_WAIT_IF_LOCKED)) if (!(test_if_locked & HA_OPEN_WAIT_IF_LOCKED))
VOID(maria_extra(file, HA_EXTRA_WAIT_LOCK, 0)); VOID(maria_extra(file, HA_EXTRA_WAIT_LOCK, 0));
if (!table->s->db_record_offset) if (file->s->data_file_type != STATIC_RECORD)
int_table_flags |= HA_REC_NOT_IN_SEQ; int_table_flags |= HA_REC_NOT_IN_SEQ;
if (file->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD)) if (file->s->options & (HA_OPTION_CHECKSUM | HA_OPTION_COMPRESS_RECORD))
int_table_flags |= HA_HAS_CHECKSUM; int_table_flags |= HA_HAS_CHECKSUM;
...@@ -1028,6 +1038,16 @@ int ha_maria::repair(THD *thd, HA_CHECK &param, bool do_optimize) ...@@ -1028,6 +1038,16 @@ int ha_maria::repair(THD *thd, HA_CHECK &param, bool do_optimize)
param.out_flag= 0; param.out_flag= 0;
strmov(fixed_name, file->filename); strmov(fixed_name, file->filename);
#ifndef TO_BE_FIXED
/* QQ: Until we have repair for block format, lie that it succeded */
if (file->s->data_file_type == BLOCK_RECORD)
{
if (optimize)
DBUG_RETURN(analyze(thd, (HA_CHECK_OPT*) 0));
DBUG_RETURN(HA_ADMIN_OK);
}
#endif
// Don't lock tables if we have used LOCK TABLE // Don't lock tables if we have used LOCK TABLE
if (!thd->locked_tables && if (!thd->locked_tables &&
maria_lock_database(file, table->s->tmp_table ? F_EXTRA_LCK : F_WRLCK)) maria_lock_database(file, table->s->tmp_table ? F_EXTRA_LCK : F_WRLCK))
...@@ -1039,7 +1059,8 @@ int ha_maria::repair(THD *thd, HA_CHECK &param, bool do_optimize) ...@@ -1039,7 +1059,8 @@ int ha_maria::repair(THD *thd, HA_CHECK &param, bool do_optimize)
if (!do_optimize || if (!do_optimize ||
((file->state->del || share->state.split != file->state->records) && ((file->state->del || share->state.split != file->state->records) &&
(!(param.testflag & T_QUICK) || (!(param.testflag & T_QUICK) ||
!(share->state.changed & STATE_NOT_OPTIMIZED_KEYS)))) (share->state.changed & (STATE_NOT_OPTIMIZED_KEYS |
STATE_NOT_OPTIMIZED_ROWS)))))
{ {
ulonglong key_map= ((local_testflag & T_CREATE_MISSING_KEYS) ? ulonglong key_map= ((local_testflag & T_CREATE_MISSING_KEYS) ?
maria_get_mask_all_keys_active(share->base.keys) : maria_get_mask_all_keys_active(share->base.keys) :
...@@ -1449,6 +1470,8 @@ void ha_maria::start_bulk_insert(ha_rows rows) ...@@ -1449,6 +1470,8 @@ void ha_maria::start_bulk_insert(ha_rows rows)
can_enable_indexes= maria_is_all_keys_active(file->s->state.key_map, can_enable_indexes= maria_is_all_keys_active(file->s->state.key_map,
file->s->base.keys); file->s->base.keys);
/* TODO: Remove when we have repair() working */
can_enable_indexes= 0;
if (!(specialflag & SPECIAL_SAFE_MODE)) if (!(specialflag & SPECIAL_SAFE_MODE))
{ {
...@@ -1487,10 +1510,12 @@ void ha_maria::start_bulk_insert(ha_rows rows) ...@@ -1487,10 +1510,12 @@ void ha_maria::start_bulk_insert(ha_rows rows)
int ha_maria::end_bulk_insert() int ha_maria::end_bulk_insert()
{ {
int err;
DBUG_ENTER("ha_maria::end_bulk_insert");
maria_end_bulk_insert(file); maria_end_bulk_insert(file);
int err= maria_extra(file, HA_EXTRA_NO_CACHE, 0); err= maria_extra(file, HA_EXTRA_NO_CACHE, 0);
return err ? err : can_enable_indexes ? DBUG_RETURN(err ? err : can_enable_indexes ?
enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE) : 0; enable_indexes(HA_KEY_SWITCH_NONUNIQ_SAVE) : 0);
} }
...@@ -1660,6 +1685,14 @@ int ha_maria::rnd_init(bool scan) ...@@ -1660,6 +1685,14 @@ int ha_maria::rnd_init(bool scan)
} }
int ha_maria::rnd_end()
{
/* Safe to call even if we don't have started a scan */
maria_scan_end(file);
return 0;
}
int ha_maria::rnd_next(byte *buf) int ha_maria::rnd_next(byte *buf)
{ {
statistic_increment(table->in_use->status_var.ha_read_rnd_next_count, statistic_increment(table->in_use->status_var.ha_read_rnd_next_count,
...@@ -1825,6 +1858,28 @@ void ha_maria::update_create_info(HA_CREATE_INFO *create_info) ...@@ -1825,6 +1858,28 @@ void ha_maria::update_create_info(HA_CREATE_INFO *create_info)
} }
enum row_type ha_maria::get_row_type() const
{
switch (file->s->data_file_type) {
case STATIC_RECORD: return ROW_TYPE_FIXED;
case DYNAMIC_RECORD: return ROW_TYPE_DYNAMIC;
case BLOCK_RECORD: return ROW_TYPE_PAGES;
case COMPRESSED_RECORD: return ROW_TYPE_COMPRESSED;
default: return ROW_TYPE_NOT_USED;
}
}
static enum data_file_type maria_row_type(HA_CREATE_INFO *info)
{
switch (info->row_type) {
case ROW_TYPE_FIXED: return STATIC_RECORD;
case ROW_TYPE_DYNAMIC: return DYNAMIC_RECORD;
default: return BLOCK_RECORD;
}
}
int ha_maria::create(const char *name, register TABLE *table_arg, int ha_maria::create(const char *name, register TABLE *table_arg,
HA_CREATE_INFO *ha_create_info) HA_CREATE_INFO *ha_create_info)
{ {
...@@ -1838,6 +1893,7 @@ int ha_maria::create(const char *name, register TABLE *table_arg, ...@@ -1838,6 +1893,7 @@ int ha_maria::create(const char *name, register TABLE *table_arg,
uint options= share->db_options_in_use; uint options= share->db_options_in_use;
enum data_file_type row_type; enum data_file_type row_type;
DBUG_ENTER("ha_maria::create"); DBUG_ENTER("ha_maria::create");
for (i= 0; i < share->keys; i++) for (i= 0; i < share->keys; i++)
{ {
if (table_arg->key_info[i].flags & HA_USES_PARSER) if (table_arg->key_info[i].flags & HA_USES_PARSER)
...@@ -1846,6 +1902,7 @@ int ha_maria::create(const char *name, register TABLE *table_arg, ...@@ -1846,6 +1902,7 @@ int ha_maria::create(const char *name, register TABLE *table_arg,
break; break;
} }
} }
row_type= maria_row_type(ha_create_info);
if ((error= table2maria(table_arg, &keydef, &recinfo, &records))) if ((error= table2maria(table_arg, &keydef, &recinfo, &records)))
DBUG_RETURN(error); /* purecov: inspected */ DBUG_RETURN(error); /* purecov: inspected */
bzero((char*) &create_info, sizeof(create_info)); bzero((char*) &create_info, sizeof(create_info));
...@@ -1869,19 +1926,6 @@ int ha_maria::create(const char *name, register TABLE *table_arg, ...@@ -1869,19 +1926,6 @@ int ha_maria::create(const char *name, register TABLE *table_arg,
if (options & HA_OPTION_DELAY_KEY_WRITE) if (options & HA_OPTION_DELAY_KEY_WRITE)
create_flags|= HA_CREATE_DELAY_KEY_WRITE; create_flags|= HA_CREATE_DELAY_KEY_WRITE;
switch (ha_create_info->row_type) {
case ROW_TYPE_FIXED:
row_type= STATIC_RECORD;
break;
case ROW_TYPE_DYNAMIC:
row_type= DYNAMIC_RECORD;
break;
default:
case ROW_TYPE_PAGES:
row_type= BLOCK_RECORD;
break;
}
/* TODO: Check that the following fn_format is really needed */ /* TODO: Check that the following fn_format is really needed */
error= error=
maria_create(fn_format(buff, name, "", "", maria_create(fn_format(buff, name, "", "",
...@@ -2012,6 +2056,7 @@ bool ha_maria::check_if_incompatible_data(HA_CREATE_INFO *info, ...@@ -2012,6 +2056,7 @@ bool ha_maria::check_if_incompatible_data(HA_CREATE_INFO *info,
if (info->auto_increment_value != stats.auto_increment_value || if (info->auto_increment_value != stats.auto_increment_value ||
info->data_file_name != data_file_name || info->data_file_name != data_file_name ||
info->index_file_name != index_file_name || info->index_file_name != index_file_name ||
maria_row_type(info) != data_file_type ||
table_changes == IS_EQUAL_NO || table_changes == IS_EQUAL_NO ||
table_changes & IS_EQUAL_PACK_LENGTH) // Not implemented yet table_changes & IS_EQUAL_PACK_LENGTH) // Not implemented yet
return COMPATIBLE_DATA_NO; return COMPATIBLE_DATA_NO;
......
...@@ -37,6 +37,7 @@ class ha_maria :public handler ...@@ -37,6 +37,7 @@ class ha_maria :public handler
MARIA_HA *file; MARIA_HA *file;
ulonglong int_table_flags; ulonglong int_table_flags;
char *data_file_name, *index_file_name; char *data_file_name, *index_file_name;
enum data_file_type data_file_type;
bool can_enable_indexes; bool can_enable_indexes;
int repair(THD * thd, HA_CHECK &param, bool optimize); int repair(THD * thd, HA_CHECK &param, bool optimize);
...@@ -62,7 +63,9 @@ public: ...@@ -62,7 +63,9 @@ public:
{ return HA_MAX_KEY_LENGTH; } { return HA_MAX_KEY_LENGTH; }
uint max_supported_key_part_length() const uint max_supported_key_part_length() const
{ return HA_MAX_KEY_LENGTH; } { return HA_MAX_KEY_LENGTH; }
enum row_type get_row_type() const;
uint checksum() const; uint checksum() const;
virtual double scan_time();
virtual bool check_if_locking_is_allowed(uint sql_command, virtual bool check_if_locking_is_allowed(uint sql_command,
ulong type, TABLE * table, ulong type, TABLE * table,
...@@ -98,6 +101,7 @@ public: ...@@ -98,6 +101,7 @@ public:
} }
int ft_read(byte * buf); int ft_read(byte * buf);
int rnd_init(bool scan); int rnd_init(bool scan);
int rnd_end(void);
int rnd_next(byte * buf); int rnd_next(byte * buf);
int rnd_pos(byte * buf, byte * pos); int rnd_pos(byte * buf, byte * pos);
int restart_rnd_next(byte * buf, byte * pos); int restart_rnd_next(byte * buf, byte * pos);
......
...@@ -936,7 +936,7 @@ static my_bool find_mid(MARIA_HA *info, ulong pages, uint position) ...@@ -936,7 +936,7 @@ static my_bool find_mid(MARIA_HA *info, ulong pages, uint position)
MARIA_BITMAP_BLOCK *block; MARIA_BITMAP_BLOCK *block;
block= dynamic_element(&info->bitmap_blocks, position, MARIA_BITMAP_BLOCK *); block= dynamic_element(&info->bitmap_blocks, position, MARIA_BITMAP_BLOCK *);
while (allocate_full_pages(bitmap, pages, block, 1)) while (!allocate_full_pages(bitmap, pages, block, 1))
{ {
if (move_to_next_bitmap(info, bitmap)) if (move_to_next_bitmap(info, bitmap))
return 1; return 1;
...@@ -1100,6 +1100,9 @@ static my_bool write_rest_of_head(MARIA_HA *info, uint position, ...@@ -1100,6 +1100,9 @@ static my_bool write_rest_of_head(MARIA_HA *info, uint position,
MARIA_SHARE *share= info->s; MARIA_SHARE *share= info->s;
uint full_page_size= FULL_PAGE_SIZE(share->block_size); uint full_page_size= FULL_PAGE_SIZE(share->block_size);
MARIA_BITMAP_BLOCK *block; MARIA_BITMAP_BLOCK *block;
DBUG_ENTER("write_rest_of_head");
DBUG_PRINT("enter", ("position: %u rest_length: %lu", position,
rest_length));
if (position == 0) if (position == 0)
{ {
...@@ -1113,8 +1116,8 @@ static my_bool write_rest_of_head(MARIA_HA *info, uint position, ...@@ -1113,8 +1116,8 @@ static my_bool write_rest_of_head(MARIA_HA *info, uint position,
pages++; pages++;
rest_length= 0; rest_length= 0;
} }
if (find_mid(info, rest_length / full_page_size, 1)) if (find_mid(info, pages, 1))
return 1; DBUG_RETURN(1);
/* /*
Insert empty block after full pages, to allow write_block_record() to Insert empty block after full pages, to allow write_block_record() to
split segment into used + free page split segment into used + free page
...@@ -1126,7 +1129,7 @@ static my_bool write_rest_of_head(MARIA_HA *info, uint position, ...@@ -1126,7 +1129,7 @@ static my_bool write_rest_of_head(MARIA_HA *info, uint position,
if (rest_length) if (rest_length)
{ {
if (find_tail(info, rest_length, ELEMENTS_RESERVED_FOR_MAIN_PART - 1)) if (find_tail(info, rest_length, ELEMENTS_RESERVED_FOR_MAIN_PART - 1))
return 1; DBUG_RETURN(1);
} }
else else
{ {
...@@ -1137,7 +1140,7 @@ static my_bool write_rest_of_head(MARIA_HA *info, uint position, ...@@ -1137,7 +1140,7 @@ static my_bool write_rest_of_head(MARIA_HA *info, uint position,
block->page_count= 0; block->page_count= 0;
block->used= 0; block->used= 0;
} }
return 0; DBUG_RETURN(0);
} }
...@@ -1509,6 +1512,9 @@ my_bool _ma_reset_full_page_bits(MARIA_HA *info, MARIA_FILE_BITMAP *bitmap, ...@@ -1509,6 +1512,9 @@ my_bool _ma_reset_full_page_bits(MARIA_HA *info, MARIA_FILE_BITMAP *bitmap,
For the first block (head block) the logic is same as for a tail block For the first block (head block) the logic is same as for a tail block
Note that we may have 'filler blocks' that are used to split a block
in half; These can be recognized by that they have page_count == 0.
RETURN RETURN
0 ok 0 ok
1 error (Couldn't write or read bitmap page) 1 error (Couldn't write or read bitmap page)
...@@ -1547,6 +1553,9 @@ my_bool _ma_bitmap_release_unused(MARIA_HA *info, MARIA_BITMAP_BLOCKS *blocks) ...@@ -1547,6 +1553,9 @@ my_bool _ma_bitmap_release_unused(MARIA_HA *info, MARIA_BITMAP_BLOCKS *blocks)
/* Handle all full pages and tail pages (for head page and blob) */ /* Handle all full pages and tail pages (for head page and blob) */
for (block++; block < end; block++) for (block++; block < end; block++)
{ {
if (!block->page_count)
continue; /* Skip 'filler blocks' */
if (block->used & BLOCKUSED_TAIL) if (block->used & BLOCKUSED_TAIL)
{ {
if (block->used & BLOCKUSED_USED) if (block->used & BLOCKUSED_USED)
......
This diff is collapsed.
...@@ -70,7 +70,7 @@ enum en_page_type { UNALLOCATED_PAGE, HEAD_PAGE, TAIL_PAGE, BLOB_PAGE, MAX_PAGE_ ...@@ -70,7 +70,7 @@ enum en_page_type { UNALLOCATED_PAGE, HEAD_PAGE, TAIL_PAGE, BLOB_PAGE, MAX_PAGE_
/* Fixed part of Max possible header size; See table in ma_blockrec.c */ /* Fixed part of Max possible header size; See table in ma_blockrec.c */
#define MAX_FIXED_HEADER_SIZE (FLAG_SIZE + 3 + ROW_EXTENT_SIZE + 3) #define MAX_FIXED_HEADER_SIZE (FLAG_SIZE + 3 + ROW_EXTENT_SIZE + 3)
#define TRANS_MAX_FIXED_HEADER_SIZE (MAX_FIXED_HEADER_SIZE + \ #define TRANS_MAX_FIXED_HEADER_SIZE (MAX_FIXED_HEADER_SIZE + \
FLAG_SIZE + TRANSID_SIZE + VERPTR_SIZE + \ TRANSID_SIZE + VERPTR_SIZE + \
TRANSID_SIZE) TRANSID_SIZE)
/* We use 1 byte in record header to store number of directory entries */ /* We use 1 byte in record header to store number of directory entries */
...@@ -90,6 +90,7 @@ enum en_page_type { UNALLOCATED_PAGE, HEAD_PAGE, TAIL_PAGE, BLOB_PAGE, MAX_PAGE_ ...@@ -90,6 +90,7 @@ enum en_page_type { UNALLOCATED_PAGE, HEAD_PAGE, TAIL_PAGE, BLOB_PAGE, MAX_PAGE_
static inline MARIA_RECORD_POS ma_recordpos(ulonglong page, uint offset) static inline MARIA_RECORD_POS ma_recordpos(ulonglong page, uint offset)
{ {
DBUG_ASSERT(offset <= 255);
return (MARIA_RECORD_POS) ((page << 8) | offset); return (MARIA_RECORD_POS) ((page << 8) | offset);
} }
......
...@@ -135,7 +135,9 @@ int maria_chk_status(HA_CHECK *param, register MARIA_HA *info) ...@@ -135,7 +135,9 @@ int maria_chk_status(HA_CHECK *param, register MARIA_HA *info)
return 0; return 0;
} }
/* Check delete links */ /*
Check delete links in row data
*/
int maria_chk_del(HA_CHECK *param, register MARIA_HA *info, uint test_flag) int maria_chk_del(HA_CHECK *param, register MARIA_HA *info, uint test_flag)
{ {
...@@ -146,6 +148,10 @@ int maria_chk_del(HA_CHECK *param, register MARIA_HA *info, uint test_flag) ...@@ -146,6 +148,10 @@ int maria_chk_del(HA_CHECK *param, register MARIA_HA *info, uint test_flag)
DBUG_ENTER("maria_chk_del"); DBUG_ENTER("maria_chk_del");
LINT_INIT(old_link); LINT_INIT(old_link);
if (info->s->data_file_type == BLOCK_RECORD)
DBUG_RETURN(0); /* No delete links here */
param->record_checksum=0; param->record_checksum=0;
delete_link_length=((info->s->options & HA_OPTION_PACK_RECORD) ? 20 : delete_link_length=((info->s->options & HA_OPTION_PACK_RECORD) ? 20 :
info->s->rec_reflength+1); info->s->rec_reflength+1);
...@@ -2144,6 +2150,7 @@ err: ...@@ -2144,6 +2150,7 @@ err:
restore_data_file_type(share); restore_data_file_type(share);
share->state.changed|= (STATE_NOT_OPTIMIZED_KEYS | STATE_NOT_SORTED_PAGES | share->state.changed|= (STATE_NOT_OPTIMIZED_KEYS | STATE_NOT_SORTED_PAGES |
STATE_NOT_ANALYZED); STATE_NOT_ANALYZED);
share->state.changed&= ~STATE_NOT_OPTIMIZED_ROWS;
DBUG_RETURN(got_error); DBUG_RETURN(got_error);
} }
...@@ -2919,7 +2926,8 @@ err: ...@@ -2919,7 +2926,8 @@ err:
} }
else if (key_map == share->state.key_map) else if (key_map == share->state.key_map)
share->state.changed&= ~STATE_NOT_OPTIMIZED_KEYS; share->state.changed&= ~STATE_NOT_OPTIMIZED_KEYS;
share->state.changed|=STATE_NOT_SORTED_PAGES; share->state.changed|= STATE_NOT_SORTED_PAGES;
share->state.changed&= ~STATE_NOT_OPTIMIZED_ROWS;
my_free(sort_param.rec_buff, MYF(MY_ALLOW_ZERO_PTR)); my_free(sort_param.rec_buff, MYF(MY_ALLOW_ZERO_PTR));
my_free(sort_param.record,MYF(MY_ALLOW_ZERO_PTR)); my_free(sort_param.record,MYF(MY_ALLOW_ZERO_PTR));
...@@ -3439,7 +3447,8 @@ err: ...@@ -3439,7 +3447,8 @@ err:
} }
else if (key_map == share->state.key_map) else if (key_map == share->state.key_map)
share->state.changed&= ~STATE_NOT_OPTIMIZED_KEYS; share->state.changed&= ~STATE_NOT_OPTIMIZED_KEYS;
share->state.changed|=STATE_NOT_SORTED_PAGES; share->state.changed|= STATE_NOT_SORTED_PAGES;
share->state.changed&= ~STATE_NOT_OPTIMIZED_ROWS;
pthread_cond_destroy (&sort_info.cond); pthread_cond_destroy (&sort_info.cond);
pthread_mutex_destroy(&sort_info.mutex); pthread_mutex_destroy(&sort_info.mutex);
......
...@@ -19,14 +19,13 @@ ...@@ -19,14 +19,13 @@
ha_checksum _ma_checksum(MARIA_HA *info, const byte *record) ha_checksum _ma_checksum(MARIA_HA *info, const byte *record)
{ {
uint i;
ha_checksum crc=0; ha_checksum crc=0;
MARIA_COLUMNDEF *rec=info->s->rec; MARIA_COLUMNDEF *rec= info->s->rec, *rec_end= rec+ info->s->base.fields;
if (info->s->base.null_bytes) if (info->s->base.null_bytes)
crc= my_checksum(crc, record, info->s->base.null_bytes); crc= my_checksum(crc, record, info->s->base.null_bytes);
for (i=info->s->base.fields ; i-- ; ) for ( ; rec != rec_end ; rec++)
{ {
const byte *pos= record + rec->offset; const byte *pos= record + rec->offset;
ulong length; ulong length;
......
...@@ -43,7 +43,7 @@ int maria_create(const char *name, enum data_file_type record_type, ...@@ -43,7 +43,7 @@ int maria_create(const char *name, enum data_file_type record_type,
{ {
register uint i,j; register uint i,j;
File dfile,file; File dfile,file;
int errpos,save_errno, create_mode= O_RDWR | O_TRUNC; int errpos,save_errno, create_mode= O_RDWR | O_TRUNC, res;
myf create_flag; myf create_flag;
uint length,max_key_length,packed,pack_bytes,pointer,real_length_diff, uint length,max_key_length,packed,pack_bytes,pointer,real_length_diff,
key_length,info_length,key_segs,options,min_key_length_skip, key_length,info_length,key_segs,options,min_key_length_skip,
...@@ -155,6 +155,7 @@ int maria_create(const char *name, enum data_file_type record_type, ...@@ -155,6 +155,7 @@ int maria_create(const char *name, enum data_file_type record_type,
type == FIELD_SKIP_ENDSPACE) type == FIELD_SKIP_ENDSPACE)
{ {
max_field_lengths+= rec->length > 255 ? 2 : 1; max_field_lengths+= rec->length > 255 ? 2 : 1;
if (record_type != BLOCK_RECORD)
min_pack_length++; min_pack_length++;
packed++; packed++;
} }
...@@ -162,28 +163,33 @@ int maria_create(const char *name, enum data_file_type record_type, ...@@ -162,28 +163,33 @@ int maria_create(const char *name, enum data_file_type record_type,
{ {
varchar_length+= rec->length-1; /* Used for min_pack_length */ varchar_length+= rec->length-1; /* Used for min_pack_length */
pack_reclength++; pack_reclength++;
if (record_type != BLOCK_RECORD)
min_pack_length++; min_pack_length++;
max_field_lengths++; max_field_lengths++;
packed++; packed++;
rec->fill_length= 1;
/* We must test for 257 as length includes pack-length */ /* We must test for 257 as length includes pack-length */
if (test(rec->length >= 257)) if (test(rec->length >= 257))
{ {
long_varchar_count++; long_varchar_count++;
max_field_lengths++; max_field_lengths++;
rec->fill_length= 2;
} }
} }
else if (type != FIELD_SKIP_ZERO) else if (type == FIELD_SKIP_ZERO)
packed++;
else
{ {
min_pack_length+=rec->length; if (record_type != BLOCK_RECORD || !rec->null_bit)
min_pack_length+= rec->length;
rec->empty_pos= 0; rec->empty_pos= 0;
rec->empty_bit= 0; rec->empty_bit= 0;
} }
else
packed++;
} }
else /* FIELD_NORMAL */ else /* FIELD_NORMAL */
{ {
min_pack_length+=rec->length; if (record_type != BLOCK_RECORD || !rec->null_bit)
min_pack_length+= rec->length;
if (!rec->null_bit) if (!rec->null_bit)
{ {
share.base.fixed_not_null_fields++; share.base.fixed_not_null_fields++;
...@@ -203,6 +209,8 @@ int maria_create(const char *name, enum data_file_type record_type, ...@@ -203,6 +209,8 @@ int maria_create(const char *name, enum data_file_type record_type,
if (rec->type == (int) FIELD_SKIP_ZERO && rec->length == 1) if (rec->type == (int) FIELD_SKIP_ZERO && rec->length == 1)
{ {
rec->type=(int) FIELD_NORMAL; rec->type=(int) FIELD_NORMAL;
rec->empty_pos= 0;
rec->empty_bit= 0;
packed--; packed--;
min_pack_length++; min_pack_length++;
break; break;
...@@ -364,7 +372,7 @@ int maria_create(const char *name, enum data_file_type record_type, ...@@ -364,7 +372,7 @@ int maria_create(const char *name, enum data_file_type record_type,
keyseg->type != HA_KEYTYPE_VARBINARY2) keyseg->type != HA_KEYTYPE_VARBINARY2)
{ {
my_errno=HA_WRONG_CREATE_OPTION; my_errno=HA_WRONG_CREATE_OPTION;
goto err; goto err_no_lock;
} }
} }
keydef->keysegs+=sp_segs; keydef->keysegs+=sp_segs;
...@@ -373,7 +381,7 @@ int maria_create(const char *name, enum data_file_type record_type, ...@@ -373,7 +381,7 @@ int maria_create(const char *name, enum data_file_type record_type,
min_key_length_skip+=SPLEN*2*SPDIMS; min_key_length_skip+=SPLEN*2*SPDIMS;
#else #else
my_errno= HA_ERR_UNSUPPORTED; my_errno= HA_ERR_UNSUPPORTED;
goto err; goto err_no_lock;
#endif /*HAVE_SPATIAL*/ #endif /*HAVE_SPATIAL*/
} }
else if (keydef->flag & HA_FULLTEXT) else if (keydef->flag & HA_FULLTEXT)
...@@ -389,7 +397,7 @@ int maria_create(const char *name, enum data_file_type record_type, ...@@ -389,7 +397,7 @@ int maria_create(const char *name, enum data_file_type record_type,
keyseg->type != HA_KEYTYPE_VARTEXT2) keyseg->type != HA_KEYTYPE_VARTEXT2)
{ {
my_errno=HA_WRONG_CREATE_OPTION; my_errno=HA_WRONG_CREATE_OPTION;
goto err; goto err_no_lock;
} }
if (!(keyseg->flag & HA_BLOB_PART) && if (!(keyseg->flag & HA_BLOB_PART) &&
(keyseg->type == HA_KEYTYPE_VARTEXT1 || (keyseg->type == HA_KEYTYPE_VARTEXT1 ||
...@@ -514,7 +522,7 @@ int maria_create(const char *name, enum data_file_type record_type, ...@@ -514,7 +522,7 @@ int maria_create(const char *name, enum data_file_type record_type,
if (keydef->keysegs > HA_MAX_KEY_SEG) if (keydef->keysegs > HA_MAX_KEY_SEG)
{ {
my_errno=HA_WRONG_CREATE_OPTION; my_errno=HA_WRONG_CREATE_OPTION;
goto err; goto err_no_lock;
} }
/* /*
key_segs may be 0 in the case when we only want to be able to key_segs may be 0 in the case when we only want to be able to
...@@ -525,10 +533,10 @@ int maria_create(const char *name, enum data_file_type record_type, ...@@ -525,10 +533,10 @@ int maria_create(const char *name, enum data_file_type record_type,
key_segs) key_segs)
share.state.rec_per_key_part[key_segs-1]=1L; share.state.rec_per_key_part[key_segs-1]=1L;
length+=key_length; length+=key_length;
if (length >= min(HA_MAX_KEY_BUFF, MARIA_MAX_KEY_LENGTH)) if (length >= HA_MAX_KEY_BUFF)
{ {
my_errno=HA_WRONG_CREATE_OPTION; my_errno=HA_WRONG_CREATE_OPTION;
goto err; goto err_no_lock;
} }
keydef->block_length= maria_block_size; keydef->block_length= maria_block_size;
keydef->keylength= (uint16) key_length; keydef->keylength= (uint16) key_length;
...@@ -572,7 +580,7 @@ int maria_create(const char *name, enum data_file_type record_type, ...@@ -572,7 +580,7 @@ int maria_create(const char *name, enum data_file_type record_type,
"indexes and/or unique constraints.", "indexes and/or unique constraints.",
MYF(0), name + dirname_length(name)); MYF(0), name + dirname_length(name));
my_errno= HA_WRONG_CREATE_OPTION; my_errno= HA_WRONG_CREATE_OPTION;
goto err; goto err_no_lock;
} }
bmove(share.state.header.file_version,(byte*) maria_file_magic,4); bmove(share.state.header.file_version,(byte*) maria_file_magic,4);
...@@ -645,11 +653,16 @@ int maria_create(const char *name, enum data_file_type record_type, ...@@ -645,11 +653,16 @@ int maria_create(const char *name, enum data_file_type record_type,
share.base.max_data_file_length= (my_off_t) ci->data_file_length; share.base.max_data_file_length= (my_off_t) ci->data_file_length;
} }
if (record_type == BLOCK_RECORD)
share.base.min_block_length= share.base.min_row_length;
else
{
share.base.min_block_length= share.base.min_block_length=
(share.base.pack_reclength+3 < MARIA_EXTEND_BLOCK_LENGTH && (share.base.pack_reclength+3 < MARIA_EXTEND_BLOCK_LENGTH &&
! share.base.blobs) ? ! share.base.blobs) ?
max(share.base.pack_reclength,MARIA_MIN_BLOCK_LENGTH) : max(share.base.pack_reclength,MARIA_MIN_BLOCK_LENGTH) :
MARIA_EXTEND_BLOCK_LENGTH; MARIA_EXTEND_BLOCK_LENGTH;
}
if (! (flags & HA_DONT_TOUCH_DATA)) if (! (flags & HA_DONT_TOUCH_DATA))
share.state.create_time= (long) time((time_t*) 0); share.state.create_time= (long) time((time_t*) 0);
...@@ -868,18 +881,25 @@ int maria_create(const char *name, enum data_file_type record_type, ...@@ -868,18 +881,25 @@ int maria_create(const char *name, enum data_file_type record_type,
if (record_type == BLOCK_RECORD) if (record_type == BLOCK_RECORD)
{ {
/* Store columns in a more efficent order */ /* Store columns in a more efficent order */
MARIA_COLUMNDEF **tmp, **pos; MARIA_COLUMNDEF **col_order, **pos;
if (!(tmp= (MARIA_COLUMNDEF**) my_malloc(share.base.fields * if (!(col_order= (MARIA_COLUMNDEF**) my_malloc(share.base.fields *
sizeof(MARIA_COLUMNDEF*), sizeof(MARIA_COLUMNDEF*),
MYF(MY_WME)))) MYF(MY_WME))))
goto err; goto err;
for (rec= recinfo, pos= tmp ; rec != rec_end ; rec++, pos++) for (rec= recinfo, pos= col_order ; rec != rec_end ; rec++, pos++)
*pos= rec; *pos= rec;
qsort(tmp, share.base.fields, sizeof(*tmp), (qsort_cmp) compare_columns); qsort(col_order, share.base.fields, sizeof(*col_order),
(qsort_cmp) compare_columns);
for (i=0 ; i < share.base.fields ; i++) for (i=0 ; i < share.base.fields ; i++)
if (_ma_recinfo_write(file, tmp[i])) {
if (_ma_recinfo_write(file, col_order[i]))
{
my_free((gptr) col_order, MYF(0));
goto err; goto err;
} }
}
my_free((gptr) col_order, MYF(0));
}
else else
{ {
for (i=0 ; i < share.base.fields ; i++) for (i=0 ; i < share.base.fields ; i++)
...@@ -917,8 +937,9 @@ int maria_create(const char *name, enum data_file_type record_type, ...@@ -917,8 +937,9 @@ int maria_create(const char *name, enum data_file_type record_type,
} }
errpos=0; errpos=0;
pthread_mutex_unlock(&THR_LOCK_maria); pthread_mutex_unlock(&THR_LOCK_maria);
res= 0;
if (my_close(file,MYF(0))) if (my_close(file,MYF(0)))
goto err; res= my_errno;
/* /*
RECOVERY TODO RECOVERY TODO
Write a log record describing the CREATE operation (just the file Write a log record describing the CREATE operation (just the file
...@@ -933,10 +954,12 @@ int maria_create(const char *name, enum data_file_type record_type, ...@@ -933,10 +954,12 @@ int maria_create(const char *name, enum data_file_type record_type,
will clean up the frm, so we needn't write anything to the log. will clean up the frm, so we needn't write anything to the log.
*/ */
my_free((char*) rec_per_key_part,MYF(0)); my_free((char*) rec_per_key_part,MYF(0));
DBUG_RETURN(0); DBUG_RETURN(res);
err: err:
pthread_mutex_unlock(&THR_LOCK_maria); pthread_mutex_unlock(&THR_LOCK_maria);
err_no_lock:
save_errno=my_errno; save_errno=my_errno;
switch (errpos) { switch (errpos) {
case 3: case 3:
......
...@@ -104,6 +104,7 @@ int maria_delete(MARIA_HA *info,const byte *record) ...@@ -104,6 +104,7 @@ int maria_delete(MARIA_HA *info,const byte *record)
info->update= HA_STATE_CHANGED+HA_STATE_DELETED+HA_STATE_ROW_CHANGED; info->update= HA_STATE_CHANGED+HA_STATE_DELETED+HA_STATE_ROW_CHANGED;
info->state->records--; info->state->records--;
share->state.changed|= STATE_NOT_OPTIMIZED_ROWS;
mi_sizestore(lastpos, info->cur_row.lastpos); mi_sizestore(lastpos, info->cur_row.lastpos);
VOID(_ma_writeinfo(info,WRITEINFO_UPDATE_KEYFILE)); VOID(_ma_writeinfo(info,WRITEINFO_UPDATE_KEYFILE));
......
...@@ -36,6 +36,7 @@ int maria_delete_all_rows(MARIA_HA *info) ...@@ -36,6 +36,7 @@ int maria_delete_all_rows(MARIA_HA *info)
goto err; goto err;
info->state->records=info->state->del=state->split=0; info->state->records=info->state->del=state->split=0;
state->changed= 0; /* File is optimized */
state->dellink = HA_OFFSET_ERROR; state->dellink = HA_OFFSET_ERROR;
state->sortkey= (ushort) ~0; state->sortkey= (ushort) ~0;
info->state->key_file_length=share->base.keystart; info->state->key_file_length=share->base.keystart;
......
...@@ -44,6 +44,8 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, ...@@ -44,6 +44,8 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
int error=0; int error=0;
ulong cache_size; ulong cache_size;
MARIA_SHARE *share=info->s; MARIA_SHARE *share=info->s;
my_bool block_records= share->data_file_type == BLOCK_RECORD;
DBUG_ENTER("maria_extra"); DBUG_ENTER("maria_extra");
DBUG_PRINT("enter",("function: %d",(int) function)); DBUG_PRINT("enter",("function: %d",(int) function));
...@@ -64,6 +66,9 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, ...@@ -64,6 +66,9 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
HA_STATE_PREV_FOUND); HA_STATE_PREV_FOUND);
break; break;
case HA_EXTRA_CACHE: case HA_EXTRA_CACHE:
if (block_records)
break; /* Not supported */
if (info->lock_type == F_UNLCK && if (info->lock_type == F_UNLCK &&
(share->options & HA_OPTION_PACK_RECORD)) (share->options & HA_OPTION_PACK_RECORD))
{ {
...@@ -130,6 +135,8 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, ...@@ -130,6 +135,8 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
error=1; /* Not possibly if not locked */ error=1; /* Not possibly if not locked */
break; break;
} }
if (block_records)
break; /* Not supported */
cache_size= (extra_arg ? *(ulong*) extra_arg : cache_size= (extra_arg ? *(ulong*) extra_arg :
my_default_record_cache_size); my_default_record_cache_size);
...@@ -353,6 +360,8 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, ...@@ -353,6 +360,8 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
break; break;
case HA_EXTRA_MMAP: case HA_EXTRA_MMAP:
#ifdef HAVE_MMAP #ifdef HAVE_MMAP
if (block_records)
break; /* Not supported */
pthread_mutex_lock(&share->intern_lock); pthread_mutex_lock(&share->intern_lock);
/* /*
Memory map the data file if it is not already mapped and if there Memory map the data file if it is not already mapped and if there
...@@ -395,8 +404,10 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function, ...@@ -395,8 +404,10 @@ int maria_extra(MARIA_HA *info, enum ha_extra_function function,
/* /*
Start/Stop Inserting Duplicates Into a Table, WL#1648. Start/Stop Inserting Duplicates Into a Table, WL#1648.
*/ */
static void maria_extra_keyflag(MARIA_HA *info, enum ha_extra_function function)
static void maria_extra_keyflag(MARIA_HA *info,
enum ha_extra_function function)
{ {
uint idx; uint idx;
......
...@@ -76,14 +76,14 @@ int maria_status(MARIA_HA *info, register MARIA_INFO *x, uint flag) ...@@ -76,14 +76,14 @@ int maria_status(MARIA_HA *info, register MARIA_INFO *x, uint flag)
x->create_time=share->state.create_time; x->create_time=share->state.create_time;
x->reflength= maria_get_pointer_length(share->base.max_data_file_length, x->reflength= maria_get_pointer_length(share->base.max_data_file_length,
maria_data_pointer_size); maria_data_pointer_size);
x->record_offset= ((share->options & x->record_offset= (info->s->data_file_type == STATIC_RECORD ?
(HA_OPTION_PACK_RECORD | HA_OPTION_COMPRESS_RECORD)) ? share->base.pack_reclength: 0);
0L : share->base.pack_reclength);
x->sortkey= -1; /* No clustering */ x->sortkey= -1; /* No clustering */
x->rec_per_key = share->state.rec_per_key_part; x->rec_per_key = share->state.rec_per_key_part;
x->key_map = share->state.key_map; x->key_map = share->state.key_map;
x->data_file_name = share->data_file_name; x->data_file_name = share->data_file_name;
x->index_file_name = share->index_file_name; x->index_file_name = share->index_file_name;
x->data_file_type = share->data_file_type;
} }
if ((flag & HA_STATUS_TIME) && !my_fstat(info->dfile,&state,MYF(0))) if ((flag & HA_STATUS_TIME) && !my_fstat(info->dfile,&state,MYF(0)))
x->update_time=state.st_mtime; x->update_time=state.st_mtime;
......
...@@ -188,7 +188,7 @@ int _ma_bin_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, byte *page, ...@@ -188,7 +188,7 @@ int _ma_bin_search(MARIA_HA *info, register MARIA_KEYDEF *keyinfo, byte *page,
totlength=keyinfo->keylength+(nod_flag=_ma_test_if_nod(page)); totlength=keyinfo->keylength+(nod_flag=_ma_test_if_nod(page));
start=0; mid=1; start=0; mid=1;
save_end=end=(int) ((maria_getint(page)-2-nod_flag)/totlength-1); save_end=end=(int) ((maria_getint(page)-2-nod_flag)/totlength-1);
DBUG_PRINT("test",("maria_getint: %d end: %d",maria_getint(page),end)); DBUG_PRINT("test",("page_length: %d end: %d",maria_getint(page),end));
page+=2+nod_flag; page+=2+nod_flag;
while (start != end) while (start != end)
...@@ -970,12 +970,12 @@ uint _ma_get_binary_pack_key(register MARIA_KEYDEF *keyinfo, uint nod_flag, ...@@ -970,12 +970,12 @@ uint _ma_get_binary_pack_key(register MARIA_KEYDEF *keyinfo, uint nod_flag,
{ {
/* Get length of dynamic length key part */ /* Get length of dynamic length key part */
if (from == from_end) { from=page; from_end=page_end; } if (from == from_end) { from=page; from_end=page_end; }
if ((length= (*key++ = *from++)) == 255) if ((length= (uint) (uchar) (*key++ = *from++)) == 255)
{ {
if (from == from_end) { from=page; from_end=page_end; } if (from == from_end) { from=page; from_end=page_end; }
length= (uint) ((*key++ = *from++)) << 8; length= ((uint) (uchar) ((*key++ = *from++))) << 8;
if (from == from_end) { from=page; from_end=page_end; } if (from == from_end) { from=page; from_end=page_end; }
length+= (uint) ((*key++ = *from++)); length+= (uint) (uchar) ((*key++ = *from++));
} }
} }
else else
...@@ -987,6 +987,7 @@ uint _ma_get_binary_pack_key(register MARIA_KEYDEF *keyinfo, uint nod_flag, ...@@ -987,6 +987,7 @@ uint _ma_get_binary_pack_key(register MARIA_KEYDEF *keyinfo, uint nod_flag,
length-=tmp; length-=tmp;
from=page; from_end=page_end; from=page; from_end=page_end;
} }
DBUG_ASSERT((int) length >= 0);
DBUG_PRINT("info",("key: 0x%lx from: 0x%lx length: %u", DBUG_PRINT("info",("key: 0x%lx from: 0x%lx length: %u",
(long) key, (long) from, length)); (long) key, (long) from, length));
memmove((byte*) key, (byte*) from, (size_t) length); memmove((byte*) key, (byte*) from, (size_t) length);
......
...@@ -814,8 +814,7 @@ int main(int argc, char *argv[]) ...@@ -814,8 +814,7 @@ int main(int argc, char *argv[])
{ {
ulong blob_length,pos; ulong blob_length,pos;
uchar *ptr; uchar *ptr;
longget(blob_length,read_record+blob_pos+4); memcpy_fixed(&ptr, read_record+blob_pos+4, sizeof(ptr));
ptr=(uchar*) blob_length;
longget(blob_length,read_record+blob_pos); longget(blob_length,read_record+blob_pos);
for (pos=0 ; pos < blob_length ; pos++) for (pos=0 ; pos < blob_length ; pos++)
{ {
......
...@@ -1066,6 +1066,7 @@ void maria_flush_bulk_insert(MARIA_HA *info, uint inx) ...@@ -1066,6 +1066,7 @@ void maria_flush_bulk_insert(MARIA_HA *info, uint inx)
void maria_end_bulk_insert(MARIA_HA *info) void maria_end_bulk_insert(MARIA_HA *info)
{ {
DBUG_ENTER("maria_end_bulk_insert");
if (info->bulk_insert) if (info->bulk_insert)
{ {
uint i; uint i;
...@@ -1079,4 +1080,5 @@ void maria_end_bulk_insert(MARIA_HA *info) ...@@ -1079,4 +1080,5 @@ void maria_end_bulk_insert(MARIA_HA *info)
my_free((void *)info->bulk_insert, MYF(0)); my_free((void *)info->bulk_insert, MYF(0));
info->bulk_insert=0; info->bulk_insert=0;
} }
DBUG_VOID_RETURN;
} }
...@@ -441,6 +441,7 @@ struct st_maria_info ...@@ -441,6 +441,7 @@ struct st_maria_info
#define STATE_NOT_ANALYZED 8 #define STATE_NOT_ANALYZED 8
#define STATE_NOT_OPTIMIZED_KEYS 16 #define STATE_NOT_OPTIMIZED_KEYS 16
#define STATE_NOT_SORTED_PAGES 32 #define STATE_NOT_SORTED_PAGES 32
#define STATE_NOT_OPTIMIZED_ROWS 64
/* options to maria_read_cache */ /* options to maria_read_cache */
......
...@@ -45,7 +45,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, ...@@ -45,7 +45,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
key_length,info_length,key_segs,options,min_key_length_skip, key_length,info_length,key_segs,options,min_key_length_skip,
base_pos,long_varchar_count,varchar_length, base_pos,long_varchar_count,varchar_length,
max_key_block_length,unique_key_parts,fulltext_keys,offset; max_key_block_length,unique_key_parts,fulltext_keys,offset;
uint aligned_key_start, block_length; uint aligned_key_start, block_length, res;
ulong reclength, real_reclength,min_pack_length; ulong reclength, real_reclength,min_pack_length;
char filename[FN_REFLEN],linkname[FN_REFLEN], *linkname_ptr; char filename[FN_REFLEN],linkname[FN_REFLEN], *linkname_ptr;
ulong pack_reclength; ulong pack_reclength;
...@@ -270,7 +270,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, ...@@ -270,7 +270,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
keyseg->type != HA_KEYTYPE_VARBINARY2) keyseg->type != HA_KEYTYPE_VARBINARY2)
{ {
my_errno=HA_WRONG_CREATE_OPTION; my_errno=HA_WRONG_CREATE_OPTION;
goto err; goto err_no_lock;
} }
} }
keydef->keysegs+=sp_segs; keydef->keysegs+=sp_segs;
...@@ -279,7 +279,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, ...@@ -279,7 +279,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
min_key_length_skip+=SPLEN*2*SPDIMS; min_key_length_skip+=SPLEN*2*SPDIMS;
#else #else
my_errno= HA_ERR_UNSUPPORTED; my_errno= HA_ERR_UNSUPPORTED;
goto err; goto err_no_lock;
#endif /*HAVE_SPATIAL*/ #endif /*HAVE_SPATIAL*/
} }
else if (keydef->flag & HA_FULLTEXT) else if (keydef->flag & HA_FULLTEXT)
...@@ -295,7 +295,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, ...@@ -295,7 +295,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
keyseg->type != HA_KEYTYPE_VARTEXT2) keyseg->type != HA_KEYTYPE_VARTEXT2)
{ {
my_errno=HA_WRONG_CREATE_OPTION; my_errno=HA_WRONG_CREATE_OPTION;
goto err; goto err_no_lock;
} }
if (!(keyseg->flag & HA_BLOB_PART) && if (!(keyseg->flag & HA_BLOB_PART) &&
(keyseg->type == HA_KEYTYPE_VARTEXT1 || (keyseg->type == HA_KEYTYPE_VARTEXT1 ||
...@@ -420,7 +420,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, ...@@ -420,7 +420,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
if (keydef->keysegs > HA_MAX_KEY_SEG) if (keydef->keysegs > HA_MAX_KEY_SEG)
{ {
my_errno=HA_WRONG_CREATE_OPTION; my_errno=HA_WRONG_CREATE_OPTION;
goto err; goto err_no_lock;
} }
/* /*
key_segs may be 0 in the case when we only want to be able to key_segs may be 0 in the case when we only want to be able to
...@@ -445,7 +445,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, ...@@ -445,7 +445,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
length >= HA_MAX_KEY_BUFF) length >= HA_MAX_KEY_BUFF)
{ {
my_errno=HA_WRONG_CREATE_OPTION; my_errno=HA_WRONG_CREATE_OPTION;
goto err; goto err_no_lock;
} }
set_if_bigger(max_key_block_length,keydef->block_length); set_if_bigger(max_key_block_length,keydef->block_length);
keydef->keylength= (uint16) key_length; keydef->keylength= (uint16) key_length;
...@@ -492,7 +492,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, ...@@ -492,7 +492,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
"indexes and/or unique constraints.", "indexes and/or unique constraints.",
MYF(0), name + dirname_length(name)); MYF(0), name + dirname_length(name));
my_errno= HA_WRONG_CREATE_OPTION; my_errno= HA_WRONG_CREATE_OPTION;
goto err; goto err_no_lock;
} }
bmove(share.state.header.file_version,(byte*) myisam_file_magic,4); bmove(share.state.header.file_version,(byte*) myisam_file_magic,4);
...@@ -814,13 +814,16 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, ...@@ -814,13 +814,16 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs,
} }
errpos=0; errpos=0;
pthread_mutex_unlock(&THR_LOCK_myisam); pthread_mutex_unlock(&THR_LOCK_myisam);
res= 0;
if (my_close(file,MYF(0))) if (my_close(file,MYF(0)))
goto err; res= my_errno;
my_free((char*) rec_per_key_part,MYF(0)); my_free((char*) rec_per_key_part,MYF(0));
DBUG_RETURN(0); DBUG_RETURN(res);
err: err:
pthread_mutex_unlock(&THR_LOCK_myisam); pthread_mutex_unlock(&THR_LOCK_myisam);
err_no_lock:
save_errno=my_errno; save_errno=my_errno;
switch (errpos) { switch (errpos) {
case 3: case 3:
......
...@@ -777,8 +777,7 @@ int main(int argc, char *argv[]) ...@@ -777,8 +777,7 @@ int main(int argc, char *argv[])
{ {
ulong blob_length,pos; ulong blob_length,pos;
uchar *ptr; uchar *ptr;
longget(blob_length,read_record+blob_pos+4); memcpy_fixed(&ptr, read_record+blob_pos+4, sizeof(ptr));
ptr=(uchar*) blob_length;
longget(blob_length,read_record+blob_pos); longget(blob_length,read_record+blob_pos);
for (pos=0 ; pos < blob_length ; pos++) for (pos=0 ; pos < blob_length ; pos++)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment