Commit 54133c7e authored by acurtis/antony@ltamd64.xiphis.org's avatar acurtis/antony@ltamd64.xiphis.org

Merge xiphis.org:/home/antony/work2/mysql-5.1-engines

into  xiphis.org:/home/antony/work2/mysql-5.1-engines-merge
parents be15e3bc 28d3ee65
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
Plugin API. Common for all plugin types. Plugin API. Common for all plugin types.
*/ */
#define MYSQL_PLUGIN_INTERFACE_VERSION 0x0002 #define MYSQL_PLUGIN_INTERFACE_VERSION 0x0100
/* /*
The allowable types of plugins The allowable types of plugins
...@@ -98,7 +98,7 @@ struct st_mysql_plugin ...@@ -98,7 +98,7 @@ struct st_mysql_plugin
const char *name; /* plugin name */ const char *name; /* plugin name */
const char *author; /* plugin author (for SHOW PLUGINS) */ const char *author; /* plugin author (for SHOW PLUGINS) */
const char *descr; /* general descriptive text (for SHOW PLUGINS ) */ const char *descr; /* general descriptive text (for SHOW PLUGINS ) */
int license; /* the plugin type (a MYSQL_XXX_PLUGIN value) */ int license; /* the plugin license (PLUGIN_LICENSE_XXX) */
int (*init)(void *); /* the function to invoke when plugin is loaded */ int (*init)(void *); /* the function to invoke when plugin is loaded */
int (*deinit)(void *);/* the function to invoke when plugin is unloaded */ int (*deinit)(void *);/* the function to invoke when plugin is unloaded */
unsigned int version; /* plugin version (for SHOW PLUGINS) */ unsigned int version; /* plugin version (for SHOW PLUGINS) */
......
...@@ -272,3 +272,18 @@ select count(a) from t2 ignore index(a,b) where a='AAAAAAAA' and b='AAAAAAAA'; ...@@ -272,3 +272,18 @@ select count(a) from t2 ignore index(a,b) where a='AAAAAAAA' and b='AAAAAAAA';
insert into t2 values ('ab', 'ab', 'uh', 'oh'); insert into t2 values ('ab', 'ab', 'uh', 'oh');
explain select a from t2 where a='ab'; explain select a from t2 where a='ab';
drop table t2; drop table t2;
#
# BUG#25048 - ERROR 126 : Incorrect key file for table '.XXXX.MYI'; try to
# repair it
#
CREATE TABLE t1(c1 INT, c2 INT DEFAULT 0, c3 CHAR(255) DEFAULT '',
KEY(c1), KEY(c2), KEY(c3));
INSERT INTO t1(c1) VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),
(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0);
INSERT INTO t1 VALUES(0,0,0);
CREATE TABLE t2(c1 int);
INSERT INTO t2 VALUES(1);
DELETE t1 FROM t1,t2 WHERE t1.c1=0 AND t1.c2=0;
SELECT * FROM t1;
DROP TABLE t1,t2;
...@@ -677,6 +677,21 @@ ERROR 3D000: No database selected ...@@ -677,6 +677,21 @@ ERROR 3D000: No database selected
alter table test.t1 rename test.t1; alter table test.t1 rename test.t1;
use test; use test;
drop table t1; drop table t1;
CREATE TABLE t1(a INT) ROW_FORMAT=FIXED;
CREATE INDEX i1 ON t1(a);
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL,
KEY `i1` (`a`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
DROP INDEX i1 ON t1;
SHOW CREATE TABLE t1;
Table Create Table
t1 CREATE TABLE `t1` (
`a` int(11) DEFAULT NULL
) ENGINE=MyISAM DEFAULT CHARSET=latin1 ROW_FORMAT=FIXED
DROP TABLE t1;
DROP TABLE IF EXISTS bug24219; DROP TABLE IF EXISTS bug24219;
DROP TABLE IF EXISTS bug24219_2; DROP TABLE IF EXISTS bug24219_2;
CREATE TABLE bug24219 (a INT, INDEX(a)); CREATE TABLE bug24219 (a INT, INDEX(a));
......
...@@ -1815,6 +1815,34 @@ engine = federated ...@@ -1815,6 +1815,34 @@ engine = federated
connection='mysql://root@127.0.0.1:SLAVE_PORT/federated/test'; connection='mysql://root@127.0.0.1:SLAVE_PORT/federated/test';
drop table federated.test1, federated.test2; drop table federated.test1, federated.test2;
drop table federated.test; drop table federated.test;
set names utf8;
create table federated.t1 (a varchar(64)) DEFAULT CHARSET=utf8;
insert into federated.t1 values (0x6DC3A56E6164);
select hex(a) from federated.t1;
hex(a)
6DC3A56E6164
create table federated.t1 (a varchar(64))
ENGINE=FEDERATED
connection='mysql://root@127.0.0.1:SLAVE_PORT/federated/t1'
DEFAULT CHARSET=utf8;
set names utf8;
select hex(a) from federated.t1;
hex(a)
6DC3A56E6164
insert into federated.t1 values (0xC3A4C3B6C3BCC39F);
insert into federated.t1 values (0xD18DD184D184D0B5D0BAD182D0B8D0B2D0BDD183D18E);
select hex(a) from federated.t1;
hex(a)
6DC3A56E6164
C3A4C3B6C3BCC39F
D18DD184D184D0B5D0BAD182D0B8D0B2D0BDD183D18E
select hex(a) from federated.t1;
hex(a)
6DC3A56E6164
C3A4C3B6C3BCC39F
D18DD184D184D0B5D0BAD182D0B8D0B2D0BDD183D18E
drop table federated.t1;
drop table federated.t1;
DROP TABLE IF EXISTS federated.t1; DROP TABLE IF EXISTS federated.t1;
DROP DATABASE IF EXISTS federated; DROP DATABASE IF EXISTS federated;
DROP TABLE IF EXISTS federated.t1; DROP TABLE IF EXISTS federated.t1;
......
...@@ -286,7 +286,7 @@ NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL ...@@ -286,7 +286,7 @@ NULL UNION RESULT <union1,2> ALL NULL NULL NULL NULL NULL
explain select * from (select * from t1 where key1 = 3 or key2 =3) as Z where key8 >5; explain select * from (select * from t1 where key1 = 3 or key2 =3) as Z where key8 >5;
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY <derived2> system NULL NULL NULL NULL 1 1 PRIMARY <derived2> system NULL NULL NULL NULL 1
2 DERIVED t1 index_merge i1,i2 i1,i2 4,4 NULL 2 Using union(i1,i2); Using where 2 DERIVED t1 index_merge i1,i2 i1,i2 4,4 NULL 2 Using union(i1,i2); Using where; Using index
create table t3 like t0; create table t3 like t0;
insert into t3 select * from t0; insert into t3 select * from t0;
alter table t3 add key9 int not null, add index i9(key9); alter table t3 add key9 int not null, add index i9(key9);
...@@ -696,6 +696,17 @@ explain select a from t2 where a='ab'; ...@@ -696,6 +696,17 @@ explain select a from t2 where a='ab';
id select_type table type possible_keys key key_len ref rows Extra id select_type table type possible_keys key key_len ref rows Extra
1 SIMPLE t2 ref a a 6 const 1 Using where 1 SIMPLE t2 ref a a 6 const 1 Using where
drop table t2; drop table t2;
CREATE TABLE t1(c1 INT, c2 INT DEFAULT 0, c3 CHAR(255) DEFAULT '',
KEY(c1), KEY(c2), KEY(c3));
INSERT INTO t1(c1) VALUES(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),
(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0),(0);
INSERT INTO t1 VALUES(0,0,0);
CREATE TABLE t2(c1 int);
INSERT INTO t2 VALUES(1);
DELETE t1 FROM t1,t2 WHERE t1.c1=0 AND t1.c2=0;
SELECT * FROM t1;
c1 c2 c3
DROP TABLE t1,t2;
#---------------- Index merge test 2 ------------------------------------------- #---------------- Index merge test 2 -------------------------------------------
SET SESSION STORAGE_ENGINE = MyISAM; SET SESSION STORAGE_ENGINE = MyISAM;
drop table if exists t1,t2; drop table if exists t1,t2;
......
...@@ -1757,4 +1757,49 @@ create table t1 (a int not null, key key_block_size=1024 (a)); ...@@ -1757,4 +1757,49 @@ 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 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)); 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 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
CREATE TABLE t1 (
c1 INT,
c2 VARCHAR(300),
KEY (c1) KEY_BLOCK_SIZE 1024,
KEY (c2) KEY_BLOCK_SIZE 8192
);
INSERT INTO t1 VALUES (10, REPEAT('a', CEIL(RAND(10) * 300))),
(11, REPEAT('b', CEIL(RAND() * 300))),
(12, REPEAT('c', CEIL(RAND() * 300))),
(13, REPEAT('d', CEIL(RAND() * 300))),
(14, REPEAT('e', CEIL(RAND() * 300))),
(15, REPEAT('f', CEIL(RAND() * 300))),
(16, REPEAT('g', CEIL(RAND() * 300))),
(17, REPEAT('h', CEIL(RAND() * 300))),
(18, REPEAT('i', CEIL(RAND() * 300))),
(19, REPEAT('j', CEIL(RAND() * 300))),
(20, REPEAT('k', CEIL(RAND() * 300))),
(21, REPEAT('l', CEIL(RAND() * 300))),
(22, REPEAT('m', CEIL(RAND() * 300))),
(23, REPEAT('n', CEIL(RAND() * 300))),
(24, REPEAT('o', CEIL(RAND() * 300))),
(25, REPEAT('p', CEIL(RAND() * 300))),
(26, REPEAT('q', CEIL(RAND() * 300))),
(27, REPEAT('r', CEIL(RAND() * 300))),
(28, REPEAT('s', CEIL(RAND() * 300))),
(29, REPEAT('t', CEIL(RAND() * 300))),
(30, REPEAT('u', CEIL(RAND() * 300))),
(31, REPEAT('v', CEIL(RAND() * 300))),
(32, REPEAT('w', CEIL(RAND() * 300))),
(33, REPEAT('x', CEIL(RAND() * 300))),
(34, REPEAT('y', CEIL(RAND() * 300))),
(35, REPEAT('z', CEIL(RAND() * 300)));
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
REPAIR TABLE t1;
Table Op Msg_type Msg_text
test.t1 repair status OK
DELETE FROM t1 WHERE c1 >= 10;
CHECK TABLE t1;
Table Op Msg_type Msg_text
test.t1 check status OK
DROP TABLE t1;
End of 5.1 tests End of 5.1 tests
...@@ -499,6 +499,17 @@ alter table test.t1 rename test.t1; ...@@ -499,6 +499,17 @@ alter table test.t1 rename test.t1;
use test; use test;
drop table t1; drop table t1;
#
# BUG#23404 - ROW_FORMAT=FIXED option is lost is an index is added to the
# table
#
CREATE TABLE t1(a INT) ROW_FORMAT=FIXED;
CREATE INDEX i1 ON t1(a);
SHOW CREATE TABLE t1;
DROP INDEX i1 ON t1;
SHOW CREATE TABLE t1;
DROP TABLE t1;
# #
# Bug#24219 - ALTER TABLE ... RENAME TO ... , DISABLE KEYS leads to crash # Bug#24219 - ALTER TABLE ... RENAME TO ... , DISABLE KEYS leads to crash
# #
......
...@@ -1598,4 +1598,36 @@ drop table federated.test1, federated.test2; ...@@ -1598,4 +1598,36 @@ drop table federated.test1, federated.test2;
connection slave; connection slave;
drop table federated.test; drop table federated.test;
#
# BUG# 17044 Federated Storage Engine not UTF8 clean
#
connection slave;
set names utf8;
create table federated.t1 (a varchar(64)) DEFAULT CHARSET=utf8;
insert into federated.t1 values (0x6DC3A56E6164);
select hex(a) from federated.t1;
connection master;
--replace_result $SLAVE_MYPORT SLAVE_PORT
eval create table federated.t1 (a varchar(64))
ENGINE=FEDERATED
connection='mysql://root@127.0.0.1:$SLAVE_MYPORT/federated/t1'
DEFAULT CHARSET=utf8;
set names utf8;
select hex(a) from federated.t1;
insert into federated.t1 values (0xC3A4C3B6C3BCC39F);
insert into federated.t1 values (0xD18DD184D184D0B5D0BAD182D0B8D0B2D0BDD183D18E);
select hex(a) from federated.t1;
connection slave;
select hex(a) from federated.t1;
connection master;
drop table federated.t1;
connection slave;
drop table federated.t1;
source include/federated_cleanup.inc; source include/federated_cleanup.inc;
...@@ -1054,4 +1054,47 @@ create table t1 (a int not null, key key_block_size=1024 (a)); ...@@ -1054,4 +1054,47 @@ create table t1 (a int not null, key key_block_size=1024 (a));
--error 1064 --error 1064
create table t1 (a int not null, key `a` key_block_size=1024 (a)); 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
#
CREATE TABLE t1 (
c1 INT,
c2 VARCHAR(300),
KEY (c1) KEY_BLOCK_SIZE 1024,
KEY (c2) KEY_BLOCK_SIZE 8192
);
INSERT INTO t1 VALUES (10, REPEAT('a', CEIL(RAND(10) * 300))),
(11, REPEAT('b', CEIL(RAND() * 300))),
(12, REPEAT('c', CEIL(RAND() * 300))),
(13, REPEAT('d', CEIL(RAND() * 300))),
(14, REPEAT('e', CEIL(RAND() * 300))),
(15, REPEAT('f', CEIL(RAND() * 300))),
(16, REPEAT('g', CEIL(RAND() * 300))),
(17, REPEAT('h', CEIL(RAND() * 300))),
(18, REPEAT('i', CEIL(RAND() * 300))),
(19, REPEAT('j', CEIL(RAND() * 300))),
(20, REPEAT('k', CEIL(RAND() * 300))),
(21, REPEAT('l', CEIL(RAND() * 300))),
(22, REPEAT('m', CEIL(RAND() * 300))),
(23, REPEAT('n', CEIL(RAND() * 300))),
(24, REPEAT('o', CEIL(RAND() * 300))),
(25, REPEAT('p', CEIL(RAND() * 300))),
(26, REPEAT('q', CEIL(RAND() * 300))),
(27, REPEAT('r', CEIL(RAND() * 300))),
(28, REPEAT('s', CEIL(RAND() * 300))),
(29, REPEAT('t', CEIL(RAND() * 300))),
(30, REPEAT('u', CEIL(RAND() * 300))),
(31, REPEAT('v', CEIL(RAND() * 300))),
(32, REPEAT('w', CEIL(RAND() * 300))),
(33, REPEAT('x', CEIL(RAND() * 300))),
(34, REPEAT('y', CEIL(RAND() * 300))),
(35, REPEAT('z', CEIL(RAND() * 300)));
INSERT INTO t1 SELECT * FROM t1;
INSERT INTO t1 SELECT * FROM t1;
CHECK TABLE t1;
REPAIR TABLE t1;
DELETE FROM t1 WHERE c1 >= 10;
CHECK TABLE t1;
DROP TABLE t1;
--echo End of 5.1 tests --echo End of 5.1 tests
...@@ -1001,6 +1001,11 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT() ...@@ -1001,6 +1001,11 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT()
if (file) if (file)
{ {
range_end(); range_end();
if (head->key_read)
{
head->key_read= 0;
file->extra(HA_EXTRA_NO_KEYREAD);
}
if (free_file) if (free_file)
{ {
DBUG_PRINT("info", ("Freeing separate handler 0x%lx (free: %d)", (long) file, DBUG_PRINT("info", ("Freeing separate handler 0x%lx (free: %d)", (long) file,
...@@ -1009,10 +1014,6 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT() ...@@ -1009,10 +1014,6 @@ QUICK_RANGE_SELECT::~QUICK_RANGE_SELECT()
file->close(); file->close();
delete file; delete file;
} }
else
{
file->extra(HA_EXTRA_NO_KEYREAD);
}
} }
delete_dynamic(&ranges); /* ranges are allocated in alloc */ delete_dynamic(&ranges); /* ranges are allocated in alloc */
free_root(&alloc,MYF(0)); free_root(&alloc,MYF(0));
...@@ -1194,7 +1195,11 @@ end: ...@@ -1194,7 +1195,11 @@ end:
org_file= head->file; org_file= head->file;
head->file= file; head->file= file;
/* We don't have to set 'head->keyread' here as the 'file' is unique */ /* We don't have to set 'head->keyread' here as the 'file' is unique */
head->mark_columns_used_by_index(index); if (!head->no_keyread)
{
head->key_read= 1;
head->mark_columns_used_by_index(index);
}
head->prepare_for_position(); head->prepare_for_position();
head->file= org_file; head->file= org_file;
bitmap_copy(&column_bitmap, head->read_set); bitmap_copy(&column_bitmap, head->read_set);
......
...@@ -1807,8 +1807,6 @@ void kill_delayed_threads(void) ...@@ -1807,8 +1807,6 @@ void kill_delayed_threads(void)
delayed_insert *tmp; delayed_insert *tmp;
while ((tmp=it++)) while ((tmp=it++))
{ {
/* Ensure that the thread doesn't kill itself while we are looking at it */
pthread_mutex_lock(&tmp->mutex);
tmp->thd.killed= THD::KILL_CONNECTION; tmp->thd.killed= THD::KILL_CONNECTION;
if (tmp->thd.mysys_var) if (tmp->thd.mysys_var)
{ {
...@@ -1827,7 +1825,6 @@ void kill_delayed_threads(void) ...@@ -1827,7 +1825,6 @@ void kill_delayed_threads(void)
} }
pthread_mutex_unlock(&tmp->thd.mysys_var->mutex); pthread_mutex_unlock(&tmp->thd.mysys_var->mutex);
} }
pthread_mutex_unlock(&tmp->mutex);
} }
VOID(pthread_mutex_unlock(&LOCK_delayed_insert)); // For unlink from list VOID(pthread_mutex_unlock(&LOCK_delayed_insert)); // For unlink from list
} }
......
...@@ -7358,6 +7358,7 @@ bool mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys) ...@@ -7358,6 +7358,7 @@ bool mysql_create_index(THD *thd, TABLE_LIST *table_list, List<Key> &keys)
bzero((char*) &create_info,sizeof(create_info)); bzero((char*) &create_info,sizeof(create_info));
create_info.db_type= 0; create_info.db_type= 0;
create_info.default_table_charset= thd->variables.collation_database; create_info.default_table_charset= thd->variables.collation_database;
create_info.row_type= ROW_TYPE_NOT_USED;
DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->table_name, DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->table_name,
&create_info, table_list, &create_info, table_list,
fields, keys, 0, (ORDER*)0, fields, keys, 0, (ORDER*)0,
...@@ -7374,6 +7375,7 @@ bool mysql_drop_index(THD *thd, TABLE_LIST *table_list, ALTER_INFO *alter_info) ...@@ -7374,6 +7375,7 @@ bool mysql_drop_index(THD *thd, TABLE_LIST *table_list, ALTER_INFO *alter_info)
bzero((char*) &create_info,sizeof(create_info)); bzero((char*) &create_info,sizeof(create_info));
create_info.db_type= 0; create_info.db_type= 0;
create_info.default_table_charset= thd->variables.collation_database; create_info.default_table_charset= thd->variables.collation_database;
create_info.row_type= ROW_TYPE_NOT_USED;
alter_info->clear(); alter_info->clear();
alter_info->flags= ALTER_DROP_INDEX; alter_info->flags= ALTER_DROP_INDEX;
DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->table_name, DBUG_RETURN(mysql_alter_table(thd,table_list->db,table_list->table_name,
......
...@@ -951,29 +951,28 @@ my_bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func, ...@@ -951,29 +951,28 @@ my_bool plugin_foreach_with_mask(THD *thd, plugin_foreach_func *func,
state_mask= ~state_mask; // do it only once state_mask= ~state_mask; // do it only once
rw_rdlock(&THR_LOCK_plugin); rw_rdlock(&THR_LOCK_plugin);
total= type == MYSQL_ANY_PLUGIN ? plugin_array.elements
: plugin_hash[type].records;
/*
Do the alloca out here in case we do have a working alloca:
leaving the nested stack frame invalidates alloca allocation.
*/
plugins=(struct st_plugin_int **)my_alloca(total*sizeof(*plugins));
if (type == MYSQL_ANY_PLUGIN) if (type == MYSQL_ANY_PLUGIN)
{ {
total=plugin_array.elements;
plugins=(struct st_plugin_int **)my_alloca(total*sizeof(*plugins));
for (idx= 0; idx < total; idx++) for (idx= 0; idx < total; idx++)
{ {
plugin= dynamic_element(&plugin_array, idx, struct st_plugin_int *); plugin= dynamic_element(&plugin_array, idx, struct st_plugin_int *);
if (plugin->state & state_mask) plugins[idx]= !(plugin->state & state_mask) ? plugin : NULL;
continue;
plugins[idx]= plugin;
} }
} }
else else
{ {
HASH *hash= &plugin_hash[type]; HASH *hash= plugin_hash + type;
total=hash->records;
plugins=(struct st_plugin_int **)my_alloca(total*sizeof(*plugins));
for (idx= 0; idx < total; idx++) for (idx= 0; idx < total; idx++)
{ {
plugin= (struct st_plugin_int *) hash_element(hash, idx); plugin= (struct st_plugin_int *) hash_element(hash, idx);
if (plugin->state & state_mask) plugins[idx]= !(plugin->state & state_mask) ? plugin : NULL;
continue;
plugins[idx]= plugin;
} }
} }
rw_unlock(&THR_LOCK_plugin); rw_unlock(&THR_LOCK_plugin);
......
...@@ -1584,6 +1584,16 @@ int ha_federated::open(const char *name, int mode, uint test_if_locked) ...@@ -1584,6 +1584,16 @@ int ha_federated::open(const char *name, int mode, uint test_if_locked)
/* Connect to foreign database mysql_real_connect() */ /* Connect to foreign database mysql_real_connect() */
mysql= mysql_init(0); mysql= mysql_init(0);
/*
BUG# 17044 Federated Storage Engine is not UTF8 clean
Add set names to whatever charset the table is at open
of table
*/
/* this sets the csname like 'set names utf8' */
mysql_options(mysql,MYSQL_SET_CHARSET_NAME,
this->table->s->table_charset->csname);
if (!mysql || !mysql_real_connect(mysql, if (!mysql || !mysql_real_connect(mysql,
share->hostname, share->hostname,
share->username, share->username,
...@@ -1600,6 +1610,7 @@ int ha_federated::open(const char *name, int mode, uint test_if_locked) ...@@ -1600,6 +1610,7 @@ int ha_federated::open(const char *name, int mode, uint test_if_locked)
API silently reconnect. For future versions, we will need more logic to API silently reconnect. For future versions, we will need more logic to
deal with transactions deal with transactions
*/ */
mysql->reconnect= 1; mysql->reconnect= 1;
ref_length= (table->s->primary_key != MAX_KEY ? ref_length= (table->s->primary_key != MAX_KEY ?
......
...@@ -250,11 +250,12 @@ static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr) ...@@ -250,11 +250,12 @@ static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr)
my_off_t next_link; my_off_t next_link;
uint block_size=(nr+1)*MI_MIN_KEY_BLOCK_LENGTH; uint block_size=(nr+1)*MI_MIN_KEY_BLOCK_LENGTH;
ha_rows records; ha_rows records;
char llbuff[21],*buff; char llbuff[21], llbuff2[21], *buff;
DBUG_ENTER("check_k_link"); DBUG_ENTER("check_k_link");
DBUG_PRINT("enter", ("block_size: %u", block_size));
if (param->testflag & T_VERBOSE) if (param->testflag & T_VERBOSE)
printf("block_size %4d:",block_size); printf("block_size %4u:", block_size); /* purecov: tested */
next_link=info->s->state.key_del[nr]; next_link=info->s->state.key_del[nr];
records= (ha_rows) (info->state->key_file_length / block_size); records= (ha_rows) (info->state->key_file_length / block_size);
...@@ -264,14 +265,46 @@ static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr) ...@@ -264,14 +265,46 @@ static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr)
DBUG_RETURN(1); DBUG_RETURN(1);
if (param->testflag & T_VERBOSE) if (param->testflag & T_VERBOSE)
printf("%16s",llstr(next_link,llbuff)); printf("%16s",llstr(next_link,llbuff));
if (next_link > info->state->key_file_length ||
next_link & (info->s->blocksize-1)) /* Key blocks must lay within the key file length entirely. */
if (next_link + block_size > info->state->key_file_length)
{
/* purecov: begin tested */
mi_check_print_error(param, "Invalid key block position: %s "
"key block size: %u file_length: %s",
llstr(next_link, llbuff), block_size,
llstr(info->state->key_file_length, llbuff2));
DBUG_RETURN(1);
/* purecov: end */
}
/* Key blocks must be aligned at MI_MIN_KEY_BLOCK_LENGTH. */
if (next_link & (MI_MIN_KEY_BLOCK_LENGTH - 1))
{
/* purecov: begin tested */
mi_check_print_error(param, "Mis-aligned key block: %s "
"minimum key block length: %u",
llstr(next_link, llbuff), MI_MIN_KEY_BLOCK_LENGTH);
DBUG_RETURN(1); DBUG_RETURN(1);
/* purecov: end */
}
/*
Read the key block with MI_MIN_KEY_BLOCK_LENGTH to find next link.
If the key cache block size is smaller than block_size, we can so
avoid unecessary eviction of cache block.
*/
if (!(buff=key_cache_read(info->s->key_cache, if (!(buff=key_cache_read(info->s->key_cache,
info->s->kfile, next_link, DFLT_INIT_HITS, info->s->kfile, next_link, DFLT_INIT_HITS,
(byte*) info->buff, (byte*) info->buff, MI_MIN_KEY_BLOCK_LENGTH,
myisam_block_size, block_size, 1))) MI_MIN_KEY_BLOCK_LENGTH, 1)))
{
/* purecov: begin tested */
mi_check_print_error(param, "key cache read error for block: %s",
llstr(next_link,llbuff));
DBUG_RETURN(1); DBUG_RETURN(1);
/* purecov: end */
}
next_link=mi_sizekorr(buff); next_link=mi_sizekorr(buff);
records--; records--;
param->key_file_blocks+=block_size; param->key_file_blocks+=block_size;
...@@ -555,17 +588,37 @@ static int chk_index_down(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, ...@@ -555,17 +588,37 @@ static int chk_index_down(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo,
ha_checksum *key_checksum, uint level) ha_checksum *key_checksum, uint level)
{ {
char llbuff[22],llbuff2[22]; char llbuff[22],llbuff2[22];
if (page > info->state->key_file_length || (page & (info->s->blocksize -1))) DBUG_ENTER("chk_index_down");
{
my_off_t max_length=my_seek(info->s->kfile,0L,MY_SEEK_END,MYF(0)); /* Key blocks must lay within the key file length entirely. */
mi_check_print_error(param,"Wrong pagepointer: %s at page: %s", if (page + keyinfo->block_length > info->state->key_file_length)
llstr(page,llbuff),llstr(page,llbuff2)); {
/* purecov: begin tested */
if (page+info->s->blocksize > max_length) /* Give it a chance to fit in the real file size. */
my_off_t max_length= my_seek(info->s->kfile, 0L, MY_SEEK_END, MYF(0));
mi_check_print_error(param, "Invalid key block position: %s "
"key block size: %u file_length: %s",
llstr(page, llbuff), keyinfo->block_length,
llstr(info->state->key_file_length, llbuff2));
if (page + keyinfo->block_length > max_length)
goto err; goto err;
info->state->key_file_length=(max_length & /* Fix the remebered key file length. */
~ (my_off_t) (info->s->blocksize-1)); info->state->key_file_length= (max_length &
~ (my_off_t) (keyinfo->block_length - 1));
/* purecov: end */
}
/* Key blocks must be aligned at MI_MIN_KEY_BLOCK_LENGTH. */
if (page & (MI_MIN_KEY_BLOCK_LENGTH - 1))
{
/* purecov: begin tested */
mi_check_print_error(param, "Mis-aligned key block: %s "
"minimum key block length: %u",
llstr(page, llbuff), MI_MIN_KEY_BLOCK_LENGTH);
goto err;
/* purecov: end */
} }
if (!_mi_fetch_keypage(info,keyinfo,page, DFLT_INIT_HITS,buff,0)) if (!_mi_fetch_keypage(info,keyinfo,page, DFLT_INIT_HITS,buff,0))
{ {
mi_check_print_error(param,"Can't read key from filepos: %s", mi_check_print_error(param,"Can't read key from filepos: %s",
...@@ -576,9 +629,12 @@ static int chk_index_down(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, ...@@ -576,9 +629,12 @@ static int chk_index_down(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo,
if (chk_index(param,info,keyinfo,page,buff,keys,key_checksum,level)) if (chk_index(param,info,keyinfo,page,buff,keys,key_checksum,level))
goto err; goto err;
return 0; DBUG_RETURN(0);
/* purecov: begin tested */
err: err:
return 1; DBUG_RETURN(1);
/* purecov: end */
} }
......
...@@ -1202,9 +1202,11 @@ ulong _mi_rec_unpack(register MI_INFO *info, register byte *to, byte *from, ...@@ -1202,9 +1202,11 @@ ulong _mi_rec_unpack(register MI_INFO *info, register byte *to, byte *from,
{ {
uint size_length=rec_length- mi_portable_sizeof_char_ptr; uint size_length=rec_length- mi_portable_sizeof_char_ptr;
ulong blob_length=_mi_calc_blob_length(size_length,from); ulong blob_length=_mi_calc_blob_length(size_length,from);
if ((ulong) (from_end-from) - size_length < blob_length || ulong from_left= (ulong) (from_end - from);
min_pack_length > (uint) (from_end -(from+size_length+blob_length))) if (from_left < size_length ||
goto err; from_left - size_length < blob_length ||
from_left - size_length - blob_length < min_pack_length)
goto err;
memcpy((byte*) to,(byte*) from,(size_t) size_length); memcpy((byte*) to,(byte*) from,(size_t) size_length);
from+=size_length; from+=size_length;
memcpy_fixed((byte*) to+size_length,(byte*) &from,sizeof(char*)); memcpy_fixed((byte*) to+size_length,(byte*) &from,sizeof(char*));
......
This diff is collapsed.
...@@ -170,6 +170,7 @@ static double _mi_search_pos(register MI_INFO *info, ...@@ -170,6 +170,7 @@ static double _mi_search_pos(register MI_INFO *info,
uchar *keypos,*buff; uchar *keypos,*buff;
double offset; double offset;
DBUG_ENTER("_mi_search_pos"); DBUG_ENTER("_mi_search_pos");
LINT_INIT(max_keynr);
if (pos == HA_OFFSET_ERROR) if (pos == HA_OFFSET_ERROR)
DBUG_RETURN(0.5); DBUG_RETURN(0.5);
......
...@@ -583,7 +583,7 @@ static struct my_option my_long_options[] = ...@@ -583,7 +583,7 @@ static struct my_option my_long_options[] =
static my_bool static my_bool
get_one_option(int optid, const struct my_option *opt __attribute__((unused)), get_one_option(int optid, const struct my_option *opt __attribute__((unused)),
char *argument) char *argument __attribute__((unused)))
{ {
switch(optid) { switch(optid) {
case 'a': case 'a':
......
...@@ -594,6 +594,7 @@ int _mi_split_page(register MI_INFO *info, register MI_KEYDEF *keyinfo, ...@@ -594,6 +594,7 @@ int _mi_split_page(register MI_INFO *info, register MI_KEYDEF *keyinfo,
my_off_t new_pos; my_off_t new_pos;
MI_KEY_PARAM s_temp; MI_KEY_PARAM s_temp;
DBUG_ENTER("mi_split_page"); DBUG_ENTER("mi_split_page");
LINT_INIT(after_key);
DBUG_DUMP("buff",(byte*) buff,mi_getint(buff)); DBUG_DUMP("buff",(byte*) buff,mi_getint(buff));
if (info->s->keyinfo+info->lastinx == keyinfo) if (info->s->keyinfo+info->lastinx == keyinfo)
......
...@@ -187,6 +187,10 @@ static int split_rtree_node(SplitStruct *node, int n_entries, ...@@ -187,6 +187,10 @@ static int split_rtree_node(SplitStruct *node, int n_entries,
int next_node; int next_node;
int i; int i;
SplitStruct *end = node + n_entries; SplitStruct *end = node + n_entries;
LINT_INIT(a);
LINT_INIT(b);
LINT_INIT(next);
LINT_INIT(next_node);
if (all_size < min_size * 2) if (all_size < min_size * 2)
{ {
......
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