diff options
author | unknown <monty@donna.mysql.com> | 2001-01-16 06:02:05 +0200 |
---|---|---|
committer | unknown <monty@donna.mysql.com> | 2001-01-16 06:02:05 +0200 |
commit | 0365e2d3dceccb1dc3727336e1596869e3c1a180 (patch) | |
tree | d2fb03ef30e8182ca60cf1262a5a9db0e97a08a5 | |
parent | 9e67d0bec4c5d697c76ce05f12d424210ea0b656 (diff) | |
download | mariadb-git-0365e2d3dceccb1dc3727336e1596869e3c1a180.tar.gz |
Removed not used variable 'last_ref'
Fixed problem with negative DECIMAL() keys
Fixed some bugs with NULL keys in BDB
More mysql-test tests
Docs/manual.texi:
Changelog
client/mysqltest.c:
Added syntax: -- error #,#,...
heap/hp_info.c:
cleanup
include/thr_lock.h:
cleanup
isam/pack_isam.c:
cleanup
myisam/mi_check.c:
cleanup
myisam/mi_extra.c:
cleanup
myisammrg/myrg_rkey.c:
cleanup
mysql-test/mysql-test-run.sh:
Change to run test as root
mysql-test/r/bdb.result:
Many new tests
mysql-test/r/func_system.result:
Change to root user
mysql-test/t/bdb.test:
many more tests
mysql-test/t/create.test:
Change to work by test and root user
sql/field.cc:
Fixed problem with negative DECIMAL() keys
sql/filesort.cc:
cleanup
sql/ha_berkeley.cc:
Added purecoverage notes
Fixed some bugs with NULL keys
sql/init.cc:
cleanup
sql/mysql_priv.h:
cleanup
sql/mysqld.cc:
cleanup
sql/records.cc:
cleanup
sql/unireg.h:
cleanup
-rw-r--r-- | Docs/manual.texi | 2 | ||||
-rw-r--r-- | client/mysqltest.c | 56 | ||||
-rw-r--r-- | heap/hp_info.c | 3 | ||||
-rw-r--r-- | include/thr_lock.h | 31 | ||||
-rw-r--r-- | isam/pack_isam.c | 13 | ||||
-rw-r--r-- | myisam/mi_check.c | 2 | ||||
-rw-r--r-- | myisam/mi_extra.c | 1 | ||||
-rw-r--r-- | myisammrg/myrg_rkey.c | 1 | ||||
-rw-r--r-- | mysql-test/mysql-test-run.sh | 4 | ||||
-rw-r--r-- | mysql-test/r/bdb.result | 56 | ||||
-rw-r--r-- | mysql-test/r/func_system.result | 2 | ||||
-rw-r--r-- | mysql-test/r/type_decimal.result | 5 | ||||
-rw-r--r-- | mysql-test/t/bdb.test | 71 | ||||
-rw-r--r-- | mysql-test/t/create.test | 3 | ||||
-rw-r--r-- | mysql-test/t/type_decimal.test | 149 | ||||
-rw-r--r-- | sql/field.cc | 17 | ||||
-rw-r--r-- | sql/filesort.cc | 5 | ||||
-rw-r--r-- | sql/ha_berkeley.cc | 198 | ||||
-rw-r--r-- | sql/init.cc | 1 | ||||
-rw-r--r-- | sql/mysql_priv.h | 1 | ||||
-rw-r--r-- | sql/mysqld.cc | 1 | ||||
-rw-r--r-- | sql/records.cc | 12 | ||||
-rw-r--r-- | sql/unireg.h | 6 |
23 files changed, 463 insertions, 177 deletions
diff --git a/Docs/manual.texi b/Docs/manual.texi index 9875a4e91a5..6610761a650 100644 --- a/Docs/manual.texi +++ b/Docs/manual.texi @@ -40383,6 +40383,8 @@ though, so Version 3.23 is not released as a stable version yet. @appendixsubsec Changes in release 3.23.31 @itemize @bullet @item +Fixed problem when using @code{DECIMAL()} keys on negative numbers. +@item @code{HOUR()} on a @code{CHAR} column always returned @code{NULL}. @item Fixed security bug in something (please upgrade if you are using a earlier diff --git a/client/mysqltest.c b/client/mysqltest.c index c3f31cdd3c0..875cfd03c15 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -70,6 +70,7 @@ #define INIT_Q_LINES 1024 #define MIN_VAR_ALLOC 32 #define BLOCK_STACK_DEPTH 32 +#define MAX_EXPECTED_ERRORS 10 static int record = 0, verbose = 0, silent = 0, opt_sleep=0; static char *db = 0, *pass=0; @@ -88,7 +89,7 @@ static char TMPDIR[FN_REFLEN]; static int block_stack[BLOCK_STACK_DEPTH]; static int *cur_block, *block_stack_end; -static uint global_expected_errno=0; +static uint global_expected_errno[MAX_EXPECTED_ERRORS]; DYNAMIC_ARRAY q_lines; @@ -132,7 +133,7 @@ struct st_query char *query, *first_argument; int first_word_len; my_bool abort_on_error, require_file; - uint expected_errno; + uint expected_errno[MAX_EXPECTED_ERRORS]; char record_file[FN_REFLEN]; /* Add new commands before Q_UNKNOWN */ enum { Q_CONNECTION=1, Q_QUERY, Q_CONNECT, @@ -542,17 +543,24 @@ static void get_file_name(char *filename, struct st_query* q) } -static int get_int(struct st_query* q) +static void get_ints(uint *to,struct st_query* q) { char* p=q->first_argument; - int res; - DBUG_ENTER("get_int"); + long val; + DBUG_ENTER("get_ints"); + while (*p && isspace(*p)) p++; if (!*p) die("Missing argument in %s\n", q->query); - res=atoi(p); - DBUG_PRINT("result",("res: %d",res)); - DBUG_RETURN(res); + + for (; (p=str2int(p,10,(long) INT_MIN, (long) INT_MAX, &val)) ; p++) + { + *to++= (uint) val; + if (*p != ',') + break; + } + *to++=0; /* End of data */ + DBUG_VOID_RETURN; } @@ -918,9 +926,10 @@ int read_query(struct st_query** q_ptr) q->record_file[0] = 0; q->require_file=0; q->first_word_len = 0; - q->expected_errno = global_expected_errno; - q->abort_on_error = global_expected_errno == 0; - global_expected_errno=0; + memcpy((gptr) q->expected_errno, (gptr) global_expected_errno, + sizeof(global_expected_errno)); + q->abort_on_error = global_expected_errno[0] == 0; + bzero((gptr) global_expected_errno,sizeof(global_expected_errno)); q->type = Q_UNKNOWN; q->query=0; if (read_line(read_query_buf, sizeof(read_query_buf))) @@ -947,7 +956,8 @@ int read_query(struct st_query** q_ptr) p++; for (;isdigit(*p);p++) expected_errno = expected_errno * 10 + *p - '0'; - q->expected_errno = expected_errno; + q->expected_errno[0] = expected_errno; + q->expected_errno[1] = 0; } } @@ -1178,15 +1188,17 @@ int run_query(MYSQL* mysql, struct st_query* q) mysql_errno(mysql), mysql_error(mysql)); else { - if (q->expected_errno) + for (i=0 ; q->expected_errno[i] ; i++) + { + if ((q->expected_errno[i] == mysql_errno(mysql))) + goto end; /* Ok */ + } + if (i) { - error = (q->expected_errno != mysql_errno(mysql)); - if (error) - verbose_msg("query '%s' failed with wrong errno\ - %d instead of %d", q->query, mysql_errno(mysql), q->expected_errno); + verbose_msg("query '%s' failed with wrong errno\ + %d instead of %d...", q->query, mysql_errno(mysql), q->expected_errno[0]); goto end; } - verbose_msg("query '%s' failed: %d: %s", q->query, mysql_errno(mysql), mysql_error(mysql)); /* if we do not abort on error, failure to run the query does @@ -1196,11 +1208,11 @@ int run_query(MYSQL* mysql, struct st_query* q) } } - if (q->expected_errno) + if (q->expected_errno[0]) { error = 1; - verbose_msg("query '%s' succeeded - should have failed with errno %d", - q->query, q->expected_errno); + verbose_msg("query '%s' succeeded - should have failed with errno %d...", + q->query, q->expected_errno[0]); goto end; } @@ -1373,7 +1385,7 @@ int main(int argc, char** argv) require_file=0; break; case Q_ERROR: - global_expected_errno=get_int(q); + get_ints(global_expected_errno,q); break; case Q_REQUIRE: get_file_name(save_file,q); diff --git a/heap/hp_info.c b/heap/hp_info.c index 260ac31ab8e..379f4d9ec0f 100644 --- a/heap/hp_info.c +++ b/heap/hp_info.c @@ -44,7 +44,8 @@ ulong heap_position_old(HP_INFO *info) /* Note that heap_info does NOT return information about the current position anymore; Use heap_position instead */ -int heap_info(reg1 HP_INFO *info,reg2 HEAPINFO *x,int flag) +int heap_info(reg1 HP_INFO *info,reg2 HEAPINFO *x, + int flag __attribute__((unused))) { DBUG_ENTER("heap_info"); x->records = info->s->records; diff --git a/include/thr_lock.h b/include/thr_lock.h index 288a762703d..569a09d7aa5 100644 --- a/include/thr_lock.h +++ b/include/thr_lock.h @@ -29,11 +29,36 @@ extern "C" { struct st_thr_lock; enum thr_lock_type { TL_IGNORE=-1, - TL_UNLOCK, TL_READ, TL_READ_HIGH_PRIORITY, + TL_UNLOCK, /* UNLOCK ANY LOCK */ + TL_READ, /* Read lock */ + /* High prior. than TL_WRITE. Allow concurrent insert */ + TL_READ_HIGH_PRIORITY, + /* READ, Don't allow concurrent insert */ TL_READ_NO_INSERT, - TL_WRITE_ALLOW_WRITE, TL_WRITE_ALLOW_READ, + /* + Write lock, but allow other threads to read / write. + Used by BDB tables in MySQL to mark that someone is + reading/writing to the table. + */ + TL_WRITE_ALLOW_WRITE, + /* + Write lock, but allow other threads to read / write. + Used by ALTER TABLE in MySQL to mark to allow readers + to use the table until ALTER TABLE is finished. + */ + TL_WRITE_ALLOW_READ, + /* + WRITE lock used by concurrent insert. Will allow + READ, if one could use concurrent insert on table. + */ TL_WRITE_CONCURRENT_INSERT, - TL_WRITE_DELAYED, TL_WRITE_LOW_PRIORITY, TL_WRITE, + /* Write used by INSERT DELAYED. Allows READ locks */ + TL_WRITE_DELAYED, + /* WRITE lock that has lower priority than TL_READ */ + TL_WRITE_LOW_PRIORITY, + /* Normal WRITE lock */ + TL_WRITE, + /* Abort new lock request with an error */ TL_WRITE_ONLY}; extern ulong max_write_lock_count; diff --git a/isam/pack_isam.c b/isam/pack_isam.c index cadec5bcef5..c2cbb72cf74 100644 --- a/isam/pack_isam.c +++ b/isam/pack_isam.c @@ -576,7 +576,7 @@ static int compress(MRG_INFO *mrg,char *result_table) if (verbose && mrg->records) printf("Min record length: %6d Max length: %6d Mean total length: %6lu\n", mrg->min_pack_length,mrg->max_pack_length, - (ulong) new_length/mrg->records); + (ulong) (new_length/mrg->records)); if (!test_only) { @@ -763,11 +763,11 @@ static int get_statistic(MRG_INFO *mrg,HUFF_COUNTS *huff_counts) { global_count=count; if (!(element=tree_insert(&count->int_tree,pos,0)) || - (element->count == 1 && + ((element->count == 1 && count->tree_buff + tree_buff_length < - count->tree_pos + count->field_length || - count->field_length == 1 && - count->int_tree.elements_in_tree > 1)) + count->tree_pos + count->field_length) || + (count->field_length == 1 && + count->int_tree.elements_in_tree > 1))) { delete_tree(&count->int_tree); my_free(count->tree_buff,MYF(0)); @@ -862,7 +862,8 @@ static int get_statistic(MRG_INFO *mrg,HUFF_COUNTS *huff_counts) DBUG_RETURN(0); } -static int compare_huff_elements(void *not_used, byte *a, byte *b) +static int compare_huff_elements(void *not_used __attribute__((unused)), + byte *a, byte *b) { return *((my_off_t*) a) < *((my_off_t*) b) ? -1 : (*((my_off_t*) a) == *((my_off_t*) b) ? 0 : 1); diff --git a/myisam/mi_check.c b/myisam/mi_check.c index 67503bd4f6c..ee9e3387119 100644 --- a/myisam/mi_check.c +++ b/myisam/mi_check.c @@ -1182,7 +1182,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, That is the next line for... (serg) */ - share->state.key_map= (((ulonglong) 1L << share->base.keys)-1 & + share->state.key_map= ((((ulonglong) 1L << share->base.keys)-1) & param->keys_in_use); info->state->key_file_length=share->base.keystart; diff --git a/myisam/mi_extra.c b/myisam/mi_extra.c index eaf9400babe..fe95c60931c 100644 --- a/myisam/mi_extra.c +++ b/myisam/mi_extra.c @@ -151,6 +151,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function) { info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); error=end_io_cache(&info->rec_cache); + /* Sergei will insert full text index caching here */ } #if defined(HAVE_MMAP) && defined(HAVE_MADVICE) if (info->opt_flag & MEMMAP_USED) diff --git a/myisammrg/myrg_rkey.c b/myisammrg/myrg_rkey.c index 7432366f348..c907701d50d 100644 --- a/myisammrg/myrg_rkey.c +++ b/myisammrg/myrg_rkey.c @@ -46,6 +46,7 @@ int myrg_rkey(MYRG_INFO *info,byte *record,int inx, const byte *key, int err; byte *buf=((search_flag == HA_READ_KEY_EXACT) ? record: 0); LINT_INIT(key_buff); + LINT_INIT(pack_key_length); if (_myrg_init_queue(info,inx,search_flag)) return my_errno; diff --git a/mysql-test/mysql-test-run.sh b/mysql-test/mysql-test-run.sh index 670f45420c8..3cdfa836014 100644 --- a/mysql-test/mysql-test-run.sh +++ b/mysql-test/mysql-test-run.sh @@ -10,7 +10,6 @@ # Access Definitions #-- DB=test -DBUSER=test DBPASSWD= VERBOSE="" TZ=GMT-3; export TZ # for UNIX_TIMESTAMP tests to work @@ -209,6 +208,9 @@ fi if [ -n "$USE_RUNNING_SERVER" ] then MASTER_MYSOCK="/tmp/mysql.sock" + DBUSER=test +else + DBUSER=root # We want to do FLUSH xxx commands fi if [ -w / ] diff --git a/mysql-test/r/bdb.result b/mysql-test/r/bdb.result index 34f1c4a1b11..218c963e098 100644 --- a/mysql-test/r/bdb.result +++ b/mysql-test/r/bdb.result @@ -130,11 +130,23 @@ level id parent_id 1 1005 101 1 1006 101 1 1007 101 +Table Op Msg_type Msg_text +test.t1 optimize status OK +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Comment +t1 0 PRIMARY 1 id A 39 NULL NULL +t1 1 parent_id 1 parent_id A 9 NULL NULL +t1 1 level 1 level A 3 NULL NULL gesuchnr benutzer_id 1 1 2 1 +Table Op Msg_type Msg_text +test.t1 optimize status OK a 2 +Table Op Msg_type Msg_text +test.t1 check error The handler for the table doesn't support check/repair +a b +2 testing a b a 1 a 2 @@ -152,6 +164,8 @@ d 2 d 5 e 1 k 1 +count(*) +16 n after rollback n after commit 4 after commit @@ -249,6 +263,12 @@ id ggid email passwd 1 test1 xxx id ggid email passwd 2 test2 yyy +id ggid email passwd +1 this will work +3 test2 this will work +id ggid email passwd +1 this will work +id ggid email passwd user_name password subscribed user_id quota weight access_date access_time approved dummy_primary_key user_0 somepassword N 0 0 0 2000-09-07 23:06:59 2000-09-07 23:06:59 1 user_1 somepassword Y 1 1 1 2000-09-07 23:06:59 2000-09-07 23:06:59 2 @@ -402,14 +422,50 @@ id parent_id level 1180 105 2 count(*) 1 +count(*) +1 +count(*) +2 +count(*) +1 +count(*) +1 +count(*) +1 +sca_pic +NULL +NULL a 1 2 3 +a +2 +3 +5 b this is a blob b i this is a blob 1 b i this is a blob 1 + 1 + 2 + 3 +b i b i +NULL NULL +b i +updated 1 +NULL -1 +NULL NULL +updated 1 + 2 + 3 +a b +world 2 +hello 1 +Table Op Msg_type Msg_text +test.t1 optimize status OK +Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Comment +t1 0 PRIMARY 1 a A 1 NULL NULL diff --git a/mysql-test/r/func_system.result b/mysql-test/r/func_system.result index 08719a2150b..c6ec28bfd34 100644 --- a/mysql-test/r/func_system.result +++ b/mysql-test/r/func_system.result @@ -1,4 +1,4 @@ database() user() -test test@localhost +test root@localhost version()>="3.23.29" 1 diff --git a/mysql-test/r/type_decimal.result b/mysql-test/r/type_decimal.result new file mode 100644 index 00000000000..0877424648b --- /dev/null +++ b/mysql-test/r/type_decimal.result @@ -0,0 +1,5 @@ +id datatype_id minvalue maxvalue valuename forecolor backcolor +143 16 -4.9000000000 -0.1000000000 NULL 15774720 +146 16 0.0000000000 1.9000000000 0 16769024 +id datatype_id minvalue maxvalue valuename forecolor backcolor +143 16 -4.9000000000 -0.1000000000 NULL 15774720 diff --git a/mysql-test/t/bdb.test b/mysql-test/t/bdb.test index ae341aa5155..cf6d28c47b0 100644 --- a/mysql-test/t/bdb.test +++ b/mysql-test/t/bdb.test @@ -45,6 +45,8 @@ explain select level,id from t1 where level=1; explain select level,id,parent_id from t1 where level=1; select level,id from t1 where level=1; select level,id,parent_id from t1 where level=1; +optimize table t1; +show keys from t1; drop table t1; # @@ -69,6 +71,14 @@ drop table t1; create table t1 (a int) type=bdb; insert into t1 values (1), (2); +optimize table t1; +delete from t1 where a = 1; +select * from t1; +check table t1; +drop table t1; + +create table t1 (a int,b varchar(20)) type=bdb; +insert into t1 values (1,""), (2,"testing"); delete from t1 where a = 1; select * from t1; drop table t1; @@ -85,6 +95,8 @@ insert into t1 (a) values ('k'),('d'); insert into t1 (a) values ("a"); insert into t1 values ("d",last_insert_id()); select * from t1; +flush tables; +select count(*) from t1; drop table t1; # @@ -251,10 +263,22 @@ CREATE TABLE t1 ( insert into t1 (ggid,passwd) values ('test1','xxx'); insert into t1 (ggid,passwd) values ('test2','yyy'); +-- error 1062 +insert into t1 (ggid,passwd) values ('test2','this will fail'); +-- error 1062 +insert into t1 (ggid,id) values ('this will fail',1); select * from t1 where ggid='test1'; select * from t1 where passwd='xxx'; select * from t1 where id=2; + +replace into t1 (ggid,id) values ('this will work',1); +replace into t1 (ggid,passwd) values ('test2','this will work'); +-- error 1062 +update t1 set id=100,ggid='test2' where id=1; +select * from t1; +select * from t1 where id=1; +select * from t1 where id=999; drop table t1; # @@ -324,27 +348,60 @@ CREATE TABLE t1 ( sca_pic varchar(100), sca_sdesc varchar(50), sca_sch_desc varchar(16), - PRIMARY KEY (sca_code, cat_code, lan_code) + PRIMARY KEY (sca_code, cat_code, lan_code), + INDEX sca_pic (sca_pic) ) type = bdb ; -INSERT INTO t1 ( sca_code, cat_code, sca_desc, lan_code, sca_pic, sca_sdesc, sca_sch_desc) VALUES ( 'PD', 'J', 'PENDANT', 'EN', NULL, NULL, 'PENDANT'),( 'RI', 'J', 'RING', 'EN', NULL, NULL, 'RING'); +INSERT INTO t1 ( sca_code, cat_code, sca_desc, lan_code, sca_pic, sca_sdesc, sca_sch_desc) VALUES ( 'PD', 'J', 'PENDANT', 'EN', NULL, NULL, 'PENDANT'),( 'RI', 'J', 'RING', 'EN', NULL, NULL, 'RING'),( 'QQ', 'J', 'RING', 'EN', 'not null', NULL, 'RING'); select count(*) from t1 where sca_code = 'PD'; +select count(*) from t1 where sca_code <= 'PD'; +select count(*) from t1 where sca_pic is null; +alter table t1 drop index sca_pic, add index sca_pic (cat_code, sca_pic); +select count(*) from t1 where sca_code='PD' and sca_pic is null; +alter table t1 drop index sca_pic, add index (sca_pic, cat_code); +select count(*) from t1 where sca_code='PD' and sca_pic is null; +select count(*) from t1 where sca_pic >= 'n'; +select sca_pic from t1 where sca_pic is null; +update t1 set sca_pic="test" where sca_pic is null; +delete from t1 where sca_code='pd'; drop table t1; # -# Test of opening table twice +# Test of opening table twice and timestamps # -CREATE TABLE t1 (a int not null, primary key (a)) type=bdb; -insert into t1 values(1),(2),(3); -select t1.a from t1 natural join t1 as t2 order by t1.a; +set @a:=now(); +CREATE TABLE t1 (a int not null, b timestamp not null, primary key (a)) type=bdb; +insert into t1 (a) values(1),(2),(3); +select t1.a from t1 natural join t1 as t2 where t1.b >= @a order by t1.a; +update t1 set a=5 where a=1; +select a from t1; drop table t1; # +# Test flushing of berkeley DB logs +# +flush logs; + +# # Test key on blob with null values # create table t1 (b blob, i int, key (b(100)), key (i), key (i, b(20))); -insert into t1 values ('this is a blob', 1), (null, -1), (null, null); +insert into t1 values ('this is a blob', 1), (null, -1), (null, null),("",1),("",2),("",3); select b from t1 where b = 'this is a blob'; select * from t1 where b like 't%'; select b, i from t1 where b is not null; select * from t1 where b is null and i > 0; +select * from t1 where i is NULL; +update t1 set b='updated' where i=1; +select * from t1; +drop table t1; + +# +# Test with variable length primary key +# +create table t1 (a varchar(100) not null, primary key(a), b int not null); +insert into t1 values("hello",1),("world",2); +select * from t1 order by b desc; +optimize table t1; +show keys from t1; +drop table t1; diff --git a/mysql-test/t/create.test b/mysql-test/t/create.test index ad8f733ca4f..a5224cd0318 100644 --- a/mysql-test/t/create.test +++ b/mysql-test/t/create.test @@ -33,7 +33,8 @@ drop table if exists t1; !$1171 create table t1 (ordid int(8), primary key (ordid)); !$1121 create table t1 (ordid int(8), unique (ordid)) type=isam; -!$1044 create table not_existing_database.test (a int); +-- error 1044,1 +create table not_existing_database.test (a int); !$1103 create table `a/a` (a int); !$1103 create table `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` (aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa int); !$1059 create table a (`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa` int); diff --git a/mysql-test/t/type_decimal.test b/mysql-test/t/type_decimal.test new file mode 100644 index 00000000000..8d4b50eec4d --- /dev/null +++ b/mysql-test/t/type_decimal.test @@ -0,0 +1,149 @@ +# bug in decimal() with negative numbers by kaido@tradenet.ee + +DROP TABLE IF EXISTS t1; +CREATE TABLE t1 ( + id int(11) DEFAULT '0' NOT NULL auto_increment, + datatype_id int(11) DEFAULT '0' NOT NULL, + minvalue decimal(20,10) DEFAULT '0.0000000000' NOT NULL, + maxvalue decimal(20,10) DEFAULT '0.0000000000' NOT NULL, + valuename varchar(20), + forecolor int(11), + backcolor int(11), + PRIMARY KEY (id), + UNIQUE datatype_id (datatype_id, minvalue, maxvalue) +); +INSERT INTO t1 VALUES ( '1', '4', '0.0000000000', '0.0000000000', 'Ei saja', '0', '16776960'); +INSERT INTO t1 VALUES ( '2', '4', '1.0000000000', '1.0000000000', 'Sajab', '16777215', '255'); +INSERT INTO t1 VALUES ( '3', '1', '2.0000000000', '49.0000000000', '', '0', '16777215'); +INSERT INTO t1 VALUES ( '60', '11', '0.0000000000', '0.0000000000', 'Rikkis', '16777215', '16711680'); +INSERT INTO t1 VALUES ( '4', '12', '1.0000000000', '1.0000000000', 'nork sadu', '65280', '14474460'); +INSERT INTO t1 VALUES ( '5', '12', '2.0000000000', '2.0000000000', 'keskmine sadu', '255', '14474460'); +INSERT INTO t1 VALUES ( '6', '12', '3.0000000000', '3.0000000000', 'tugev sadu', '127', '14474460'); +INSERT INTO t1 VALUES ( '43', '39', '6.0000000000', '6.0000000000', 'lobjakas', '13107327', '16763080'); +INSERT INTO t1 VALUES ( '40', '39', '2.0000000000', '2.0000000000', 'vihm', '8355839', '16777215'); +INSERT INTO t1 VALUES ( '53', '1', '-35.0000000000', '-5.0000000000', '', '0', '16777215'); +INSERT INTO t1 VALUES ( '41', '39', '3.0000000000', '3.0000000000', 'külm vihm', '120', '16763080'); +INSERT INTO t1 VALUES ( '12', '21', '21.0000000000', '21.0000000000', 'Kuiv', '13158600', '16777215'); +INSERT INTO t1 VALUES ( '13', '21', '13.0000000000', '13.0000000000', 'Märg', '5263615', '16777215'); +INSERT INTO t1 VALUES ( '14', '21', '22.0000000000', '22.0000000000', 'Niiske', '9869055', '16777215'); +INSERT INTO t1 VALUES ( '19', '21', '33.0000000000', '33.0000000000', 'Märg', '5263615', '16777215'); +INSERT INTO t1 VALUES ( '15', '21', '23.0000000000', '23.0000000000', 'Märg', '5263615', '16777215'); +INSERT INTO t1 VALUES ( '16', '21', '31.0000000000', '31.0000000000', 'Kuiv', '13158600', '16777215'); +INSERT INTO t1 VALUES ( '17', '21', '12.0000000000', '12.0000000000', 'Niiske', '9869055', '16777215'); +INSERT INTO t1 VALUES ( '18', '21', '32.0000000000', '32.0000000000', 'Niiske', '9869055', '16777215'); +INSERT INTO t1 VALUES ( '20', '21', '331.0000000000', '331.0000000000', 'Härmatise hoiatus!', '14448840', '13158600'); +INSERT INTO t1 VALUES ( '21', '21', '11.0000000000', '11.0000000000', 'Kuiv', '13158600', '16777215'); +INSERT INTO t1 VALUES ( '22', '33', '21.0000000000', '21.0000000000', 'Pilves, kuiv', '8355711', '12632256'); +INSERT INTO t1 VALUES ( '23', '33', '13.0000000000', '13.0000000000', 'Sajab, märg', '0', '8355839'); +INSERT INTO t1 VALUES ( '24', '33', '22.0000000000', '22.0000000000', 'Pilves, niiske', '8355711', '12632319'); +INSERT INTO t1 VALUES ( '29', '33', '33.0000000000', '33.0000000000', 'Selge, märg', '16777215', '8355839'); +INSERT INTO t1 VALUES ( '25', '33', '23.0000000000', '23.0000000000', 'Pilves, märg', '8355711', '8355839'); +INSERT INTO t1 VALUES ( '26', '33', '31.0000000000', '31.0000000000', 'Selge, kuiv', '16777215', '12632256'); +INSERT INTO t1 VALUES ( '27', '33', '12.0000000000', '12.0000000000', 'Sajab, niiske', '0', '12632319'); +INSERT INTO t1 VALUES ( '28', '33', '32.0000000000', '32.0000000000', 'Selge, niiske', '16777215', '12632319'); +INSERT INTO t1 VALUES ( '30', '33', '331.0000000000', '331.0000000000', 'Härmatis! selge,kuiv', '16711680', '12632256'); +INSERT INTO t1 VALUES ( '31', '33', '11.0000000000', '11.0000000000', 'Sajab, kuiv', '0', '12632256'); +INSERT INTO t1 VALUES ( '32', '11', '1.0000000000', '1.0000000000', 'Korras', '16777215', '49152'); +INSERT INTO t1 VALUES ( '33', '21', '335.0000000000', '335.0000000000', 'Härmatis!', '14448840', '11842740'); +INSERT INTO t1 VALUES ( '34', '21', '134.0000000000', '134.0000000000', 'Hoiatus, M+S!', '255', '13158600'); +INSERT INTO t1 VALUES ( '35', '21', '133.0000000000', '133.0000000000', 'Hoiatus, märg!', '5263615', '13158600'); +INSERT INTO t1 VALUES ( '36', '21', '135.0000000000', '135.0000000000', 'Härmatis!', '14448840', '11842740'); +INSERT INTO t1 VALUES ( '37', '21', '334.0000000000', '334.0000000000', 'Härmatise hoiatus!', '14448840', '13158600'); +INSERT INTO t1 VALUES ( '38', '21', '132.0000000000', '132.0000000000', 'Hoiatus, niiske!', '9869055', '13158600'); +INSERT INTO t1 VALUES ( '39', '39', '1.0000000000', '1.0000000000', 'ei saja', '11206570', '16777215'); +INSERT INTO t1 VALUES ( '44', '39', '4.0000000000', '5.0000000000', 'lumi', '16711680', '16763080'); +INSERT INTO t1 VALUES ( '45', '12', '0.0000000000', '0.0000000000', '', '16777215', '14474460'); +INSERT INTO t1 VALUES ( '46', '39', '8.0000000000', '8.0000000000', 'rahe', '9830400', '16763080'); +INSERT INTO t1 VALUES ( '47', '39', '9.0000000000', '9.0000000000', 'tüüp ebaselge', '12582912', '16777215'); +INSERT INTO t1 VALUES ( '48', '39', '7.0000000000', '7.0000000000', 'lumetuisk', '7209070', '16763080'); +INSERT INTO t1 VALUES ( '142', '15', '2.0000000000', '49.0000000000', '', '0', '16777215'); +INSERT INTO t1 VALUES ( '52', '1', '-4.9000000000', '-0.1000000000', '', '0', '15774720'); +INSERT INTO t1 VALUES ( '141', '15', '-4.9000000000', '-0.1000000000', '', '0', '15774720'); +INSERT INTO t1 VALUES ( '55', '8', '0.0000000000', '0.0000000000', '', '0', '16777215'); +INSERT INTO t1 VALUES ( '56', '8', '0.0100000000', '0.1000000000', '', '0', '16770560'); +INSERT INTO t1 VALUES ( '57', '8', '0.1100000000', '25.0000000000', '', '0', '15774720'); +INSERT INTO t1 VALUES ( '58', '2', '90.0000000000', '94.9000000000', '', NULL, '16770560'); +INSERT INTO t1 VALUES ( '59', '6', '0.0000000000', '360.0000000000', '', NULL, '16777215'); +INSERT INTO t1 VALUES ( '61', '21', '38.0000000000', '38.0000000000', 'Niiske', '9869055', '16777215'); +INSERT INTO t1 VALUES ( '62', '38', '500.0000000000', '999.0000000000', '', '0', '16770560'); +INSERT INTO t1 VALUES ( '63', '38', '1000.0000000000', '2000.0000000000', '', '0', '16777215'); +INSERT INTO t1 VALUES ( '64', '17', '0.0000000000', '0.0000000000', '', NULL, '16777215'); +INSERT INTO t1 VALUES ( '65', '17', '0.1000000000', '10.0000000000', '', NULL, '16770560'); +INSERT INTO t1 VALUES ( '67', '21', '412.0000000000', '412.0000000000', 'Niiske', '9869055', '16777215'); +INSERT INTO t1 VALUES ( '68', '21', '413.0000000000', '413.0000000000', 'Märg', '5263615', '16777215'); +INSERT INTO t1 VALUES ( '69', '21', '113.0000000000', '113.0000000000', 'Märg', '5263615', '16777215'); +INSERT INTO t1 VALUES ( '70', '21', '416.0000000000', '416.0000000000', 'Lumine!', '16711680', '11842740'); +INSERT INTO t1 VALUES ( '71', '38', '0.0000000000', '499.0000000000', '', NULL, '16711680'); +INSERT INTO t1 VALUES ( '72', '22', '-49.0000000000', '49.0000000000', '', NULL, '16777215'); +INSERT INTO t1 VALUES ( '73', '13', '0.0000000000', '9.9000000000', '', NULL, '16777215'); +INSERT INTO t1 VALUES ( '74', '13', '10.0000000000', '14.9000000000', '', NULL, '16770560'); +INSERT INTO t1 VALUES ( '75', '7', '0.0000000000', '50.0000000000', '', NULL, '16777215'); +INSERT INTO t1 VALUES ( '76', '18', '0.0000000000', '0.0000000000', '', NULL, '16777215'); +INSERT INTO t1 VALUES ( '77', '18', '0.1000000000', '10.0000000000', '', NULL, '16770560'); +INSERT INTO t1 VALUES ( '78', '19', '300.0000000000', '400.0000000000', '', NULL, '16777215'); +INSERT INTO t1 VALUES ( '79', '19', '0.0000000000', '299.0000000000', '', NULL, '16770560'); +INSERT INTO t1 VALUES ( '80', '23', '0.0000000000', '100.0000000000', '', NULL, '16777215'); +INSERT INTO t1 VALUES ( '81', '24', '0.0000000000', '200.0000000000', '', NULL, '16777215'); +INSERT INTO t1 VALUES ( '82', '26', '0.0000000000', '0.0000000000', '', NULL, '16777215'); +INSERT INTO t1 VALUES ( '83', '26', '0.1000000000', '5.0000000000', '', NULL, '16776960'); +INSERT INTO t1 VALUES ( '84', '21', '422.0000000000', '422.0000000000', 'Niiske', '9869055', '16777215'); +INSERT INTO t1 VALUES ( '85', '21', '411.0000000000', '411.0000000000', 'Saju hoiat.,kuiv!', '16777215', '13158600'); +INSERT INTO t1 VALUES ( '86', '21', '423.0000000000', '423.0000000000', 'Märg', '5263615', '16777215'); +INSERT INTO t1 VALUES ( '144', '16', '-49.0000000000', '-5.0000000000', '', NULL, '16777215'); +INSERT INTO t1 VALUES ( '88', '16', '2.0000000000', '49.0000000000', '', NULL, '16777215'); +INSERT INTO t1 VALUES ( '89', '21', '338.0000000000', '338.0000000000', 'Härm.hoiatus, N+S!', '16744319', '13158600'); +INSERT INTO t1 VALUES ( '90', '21', '332.0000000000', '332.0000000000', 'Härm.hoiat., niiske!', '16744319', '13158600'); +INSERT INTO t1 VALUES ( '91', '21', '114.0000000000', '114.0000000000', 'Hoiatus, M+S!', '255', '13158600'); +INSERT INTO t1 VALUES ( '92', '21', '117.0000000000', '117.0000000000', 'Hoiatus, JÄÄ!', '14448840', '16711680'); +INSERT INTO t1 VALUES ( '93', '21', '116.0000000000', '116.0000000000', 'Lumine!', '16711680', '11842740'); +INSERT INTO t1 VALUES ( '94', '21', '414.0000000000', '414.0000000000', 'Hoiatus, M+S!', '255', '13158600'); +INSERT INTO t1 VALUES ( '95', '21', '325.0000000000', '325.0000000000', 'Härmatis!', '14448840', '11842740'); +INSERT INTO t1 VALUES ( '96', '21', '321.0000000000', '321.0000000000', 'Härmatise hoiatus!', '14448840', '13158600'); +INSERT INTO t1 VALUES ( '97', '21', '328.0000000000', '328.0000000000', 'Härm.hoiatus, N+S!', '16744319', '13158600'); +INSERT INTO t1 VALUES ( '98', '21', '28.0000000000', '28.0000000000', 'Niiske ja sool', '9869055', '16777215'); +INSERT INTO t1 VALUES ( '99', '21', '118.0000000000', '118.0000000000', 'Hoiatus, N+S!', '9869055', '13158600'); +INSERT INTO t1 VALUES ( '100', '21', '418.0000000000', '418.0000000000', 'Hoiatus, N+S!', '9869055', '13158600'); +INSERT INTO t1 VALUES ( '101', '21', '322.0000000000', '322.0000000000', 'Härm.hoiat., niiske!', '16744319', '13158600'); +INSERT INTO t1 VALUES ( '102', '21', '428.0000000000', '428.0000000000', 'Hoiatus, N+S!', '9869055', '13158600'); +INSERT INTO t1 VALUES ( '103', '21', '432.0000000000', '432.0000000000', 'Hoiatus, niiske!', '7895240', '13158600'); +INSERT INTO t1 VALUES ( '104', '21', '421.0000000000', '421.0000000000', 'Saju hoiat.,kuiv!', '16777215', '13158600'); +INSERT INTO t1 VALUES ( '105', '21', '24.0000000000', '24.0000000000', 'Märg ja sool', '255', '16777215'); +INSERT INTO t1 VALUES ( '106', '21', '438.0000000000', '438.0000000000', 'Hoiatus, N+S!', '9869055', '13158600'); +INSERT INTO t1 VALUES ( '107', '21', '112.0000000000', '112.0000000000', 'Hoiatus, niiske!', '9869055', '13158600'); +INSERT INTO t1 VALUES ( '108', '21', '34.0000000000', '34.0000000000', 'Märg ja sool', '255', '16777215'); +INSERT INTO t1 VALUES ( '109', '21', '434.0000000000', '434.0000000000', 'Hoiatus, M+S!', '255', '13158600'); +INSERT INTO t1 VALUES ( '110', '21', '124.0000000000', '124.0000000000', 'Hoiatus, M+S!', '255', '13158600'); +INSERT INTO t1 VALUES ( '111', '21', '424.0000000000', '424.0000000000', 'Hoiatus, M+S!', '255', '13158600'); +INSERT INTO t1 VALUES ( '112', '21', '123.0000000000', '123.0000000000', 'Hoiatus, märg!', '5263615', '13158600'); +INSERT INTO t1 VALUES ( '140', '15', '-49.0000000000', '-5.0000000000', '', '0', '16777215'); +INSERT INTO t1 VALUES ( '114', '21', '18.0000000000', '18.0000000000', 'Niiske ja sool', '9869055', '16777215'); +INSERT INTO t1 VALUES ( '115', '21', '122.0000000000', '122.0000000000', 'Hoiatus, niiske!', '9869055', '13158600'); +INSERT INTO t1 VALUES ( '116', '21', '14.0000000000', '14.0000000000', 'Märg ja sool', '255', '16777215'); +INSERT INTO t1 VALUES ( '117', '21', '311.0000000000', '311.0000000000', 'Härmatise hoiatus!', '14448840', '13158600'); +INSERT INTO t1 VALUES ( '121', '2', '95.0000000000', '100.0000000000', '', NULL, '15774720'); +INSERT INTO t1 VALUES ( '118', '2', '0.0000000000', '89.9000000000', '', NULL, '16777215'); +INSERT INTO t1 VALUES ( '119', '21', '16.0000000000', '16.0000000000', 'Lumine!', '16711680', '11842740'); +INSERT INTO t1 VALUES ( '120', '21', '26.0000000000', '26.0000000000', 'Lumine!', '16711680', '11842740'); +INSERT INTO t1 VALUES ( '122', '13', '15.0000000000', '50.0000000000', '', NULL, '15774720'); +INSERT INTO t1 VALUES ( '123', '5', '0.0000000000', '9.9000000000', '', NULL, '16777215'); +INSERT INTO t1 VALUES ( '124', '5', '10.0000000000', '14.9000000000', '', NULL, '16770560'); +INSERT INTO t1 VALUES ( '125', '5', '15.0000000000', '50.0000000000', '', NULL, '15774720'); +INSERT INTO t1 VALUES ( '126', '21', '128.0000000000', '128.0000000000', 'Hoiatus, N+S!', '9869055', '13158600'); +INSERT INTO t1 VALUES ( '127', '21', '318.0000000000', '318.0000000000', 'Härm.hoiatus, N+S!', '16744319', '13158600'); +INSERT INTO t1 VALUES ( '128', '21', '312.0000000000', '312.0000000000', 'Härm.hoiat., niiske!', '16744319', '13158600'); +INSERT INTO t1 VALUES ( '129', '21', '126.0000000000', '126.0000000000', 'Lumine!', '16711680', '11842740'); +INSERT INTO t1 VALUES ( '130', '21', '324.0000000000', '324.0000000000', 'Härmatise hoiatus!', '14448840', '13158600'); +INSERT INTO t1 VALUES ( '131', '21', '316.0000000000', '316.0000000000', 'Lumine!', '16711680', '11842740'); +INSERT INTO t1 VALUES ( '132', '1', '0.0000000000', '1.9000000000', '', NULL, '16769024'); +INSERT INTO t1 VALUES ( '134', '3', '-50.0000000000', '50.0000000000', '', NULL, '16777215'); +INSERT INTO t1 VALUES ( '135', '8', '26.0000000000', '2000.0000000000', '', '9868950', '15774720'); +INSERT INTO t1 VALUES ( '136', '21', '426.0000000000', '426.0000000000', 'Lumine!', '16711680', '11842740'); +INSERT INTO t1 VALUES ( '137', '21', '127.0000000000', '127.0000000000', 'Hoiatus, JÄÄ!', '14448840', '16711680'); +INSERT INTO t1 VALUES ( '138', '21', '121.0000000000', '121.0000000000', 'Kuiv', '13158600', '16777215'); +INSERT INTO t1 VALUES ( '139', '21', '326.0000000000', '326.0000000000', 'Lumine!', '16711680', '11842740'); +INSERT INTO t1 VALUES ( '143', '16', '-4.9000000000', '-0.1000000000', '', NULL, '15774720'); +INSERT INTO t1 VALUES ( '145', '15', '0.0000000000', '1.9000000000', '', '0', '16769024'); +INSERT INTO t1 VALUES ( '146', '16', '0.0000000000', '1.9000000000', '', '0', '16769024'); +select * from t1 where minvalue<=1 and maxvalue>=-1 and datatype_id=16; +select * from t1 where minvalue<=-1 and maxvalue>=-1 and datatype_id=16; +drop table t1; diff --git a/sql/field.cc b/sql/field.cc index 67f93532e99..1c6aa32e167 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -597,24 +597,23 @@ String *Field_decimal::val_str(String *val_buffer __attribute__((unused)), int Field_decimal::cmp(const char *a_ptr,const char *b_ptr) { const char *end; + int swap=0; /* First remove prefixes '0', ' ', and '-' */ for (end=a_ptr+field_length; a_ptr != end && (*a_ptr == *b_ptr || ((isspace(*a_ptr) || *a_ptr == '+' || *a_ptr == '0') && (isspace(*b_ptr) || *b_ptr == '+' || *b_ptr == '0'))); - a_ptr++,b_ptr++) ; - + a_ptr++,b_ptr++) + { + if (*a_ptr == '-') // If both numbers are negative + swap= -1 ^ 1; // Swap result + } if (a_ptr == end) return 0; - int swap=0; if (*a_ptr == '-') - { - if (*b_ptr != '-') - return -1; - swap= -1 ^ 1; // Swap result - a_ptr++, b_ptr++; - } else if (*b_ptr == '-') + return -1; + else if (*b_ptr == '-') return 1; while (a_ptr != end) diff --git a/sql/filesort.cc b/sql/filesort.cc index b0333762515..3c137a81d05 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -343,11 +343,6 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, error= my_errno ? my_errno : -1; /* Abort */ break; } - if (TEST_IF_LASTREF(ref_pos,ref_length)) - { - error=HA_ERR_END_OF_FILE; - break; - } error=file->rnd_pos(sort_form->record[0],next_pos); } else diff --git a/sql/ha_berkeley.cc b/sql/ha_berkeley.cc index 0b76ddc8084..b26c3ad31de 100644 --- a/sql/ha_berkeley.cc +++ b/sql/ha_berkeley.cc @@ -200,13 +200,13 @@ bool berkeley_flush_logs() DBUG_ENTER("berkeley_flush_logs"); if ((error=log_flush(db_env,0))) { - my_error(ER_ERROR_DURING_FLUSH_LOGS,MYF(0),error); - result=1; + my_error(ER_ERROR_DURING_FLUSH_LOGS,MYF(0),error); /* purecov: inspected */ + result=1; /* purecov: inspected */ } if ((error=txn_checkpoint(db_env,0,0,0))) { - my_error(ER_ERROR_DURING_CHECKPOINT,MYF(0),error); - result=1; + my_error(ER_ERROR_DURING_CHECKPOINT,MYF(0),error); /* purecov: inspected */ + result=1; /* purecov: inspected */ } DBUG_RETURN(result); } @@ -220,7 +220,7 @@ int berkeley_commit(THD *thd, void *trans) int error=txn_commit((DB_TXN*) trans,0); #ifndef DBUG_OFF if (error) - DBUG_PRINT("error",("error: %d",error)); + DBUG_PRINT("error",("error: %d",error)); /* purecov: inspected */ #endif DBUG_RETURN(error); } @@ -283,7 +283,7 @@ err: static void berkeley_print_error(const char *db_errpfx, char *buffer) { - sql_print_error("%s: %s",db_errpfx,buffer); + sql_print_error("%s: %s",db_errpfx,buffer); /* purecov: tested */ } static void berkeley_noticecall(DB_ENV *db_env, db_notices notice) @@ -308,22 +308,22 @@ void berkeley_cleanup_log_files(void) /* XXX: Probably this should be done somewhere else, and * should be tunable by the user. */ if ((error = txn_checkpoint(db_env, 0, 0, 0))) - my_error(ER_ERROR_DURING_CHECKPOINT, MYF(0), error); + my_error(ER_ERROR_DURING_CHECKPOINT, MYF(0), error); /* purecov: inspected */ if ((error = log_archive(db_env, &names, DB_ARCH_ABS, NULL)) != 0) { - DBUG_PRINT("error", ("log_archive failed (error %d)", error)); - db_env->err(db_env, error, "log_archive: DB_ARCH_ABS"); - DBUG_VOID_RETURN; + DBUG_PRINT("error", ("log_archive failed (error %d)", error)); /* purecov: inspected */ + db_env->err(db_env, error, "log_archive: DB_ARCH_ABS"); /* purecov: inspected */ + DBUG_VOID_RETURN; /* purecov: inspected */ } if (names) - { - char **np; - for (np = names; *np; ++np) - my_delete(*np, MYF(MY_WME)); + { /* purecov: tested */ + char **np; /* purecov: tested */ + for (np = names; *np; ++np) /* purecov: tested */ + my_delete(*np, MYF(MY_WME)); /* purecov: tested */ - free(names); + free(names); /* purecov: tested */ } DBUG_VOID_RETURN; @@ -460,20 +460,20 @@ int ha_berkeley::open(const char *name, int mode, uint test_if_locked) (hidden_primary_key ? 0 : table->key_info[table->primary_key].key_length), NullS))) - DBUG_RETURN(1); + DBUG_RETURN(1); /* purecov: inspected */ if (!(rec_buff=my_malloc((alloced_rec_buff_length=table->rec_buff_length), MYF(MY_WME)))) { - my_free(alloc_ptr,MYF(0)); - DBUG_RETURN(1); + my_free(alloc_ptr,MYF(0)); /* purecov: inspected */ + DBUG_RETURN(1); /* purecov: inspected */ } /* Init shared structure */ if (!(share=get_share(name,table))) { - my_free(rec_buff,MYF(0)); - my_free(alloc_ptr,MYF(0)); - DBUG_RETURN(1); + my_free(rec_buff,MYF(0)); /* purecov: inspected */ + my_free(alloc_ptr,MYF(0)); /* purecov: inspected */ + DBUG_RETURN(1); /* purecov: inspected */ } thr_lock_data_init(&share->lock,&lock,(void*) 0); key_file = share->key_file; @@ -487,11 +487,11 @@ int ha_berkeley::open(const char *name, int mode, uint test_if_locked) { if ((error=db_create(&file, db_env, 0))) { - free_share(share,table, hidden_primary_key,1); - my_free(rec_buff,MYF(0)); - my_free(alloc_ptr,MYF(0)); - my_errno=error; - DBUG_RETURN(1); + free_share(share,table, hidden_primary_key,1); /* purecov: inspected */ + my_free(rec_buff,MYF(0)); /* purecov: inspected */ + my_free(alloc_ptr,MYF(0)); /* purecov: inspected */ + my_errno=error; /* purecov: inspected */ + DBUG_RETURN(1); /* purecov: inspected */ } share->file = file; @@ -504,11 +504,11 @@ int ha_berkeley::open(const char *name, int mode, uint test_if_locked) 2 | 4), "main", DB_BTREE, open_mode,0)))) { - free_share(share,table, hidden_primary_key,1); - my_free(rec_buff,MYF(0)); - my_free(alloc_ptr,MYF(0)); - my_errno=error; - DBUG_RETURN(1); + free_share(share,table, hidden_primary_key,1); /* purecov: inspected */ + my_free(rec_buff,MYF(0)); /* purecov: inspected */ + my_free(alloc_ptr,MYF(0)); /* purecov: inspected */ + my_errno=error; /* purecov: inspected */ + DBUG_RETURN(1); /* purecov: inspected */ } /* Open other keys; These are part of the share structure */ @@ -523,9 +523,9 @@ int ha_berkeley::open(const char *name, int mode, uint test_if_locked) { if ((error=db_create(ptr, db_env, 0))) { - close(); - my_errno=error; - DBUG_RETURN(1); + close(); /* purecov: inspected */ + my_errno=error; /* purecov: inspected */ + DBUG_RETURN(1); /* purecov: inspected */ } sprintf(part,"key%02d",++used_keys); key_type[i]=table->key_info[i].flags & HA_NOSAME ? DB_NOOVERWRITE : 0; @@ -536,9 +536,9 @@ int ha_berkeley::open(const char *name, int mode, uint test_if_locked) if ((error=((*ptr)->open(*ptr, name_buff, part, DB_BTREE, open_mode, 0)))) { - close(); - my_errno=error; - DBUG_RETURN(1); + close(); /* purecov: inspected */ + my_errno=error; /* purecov: inspected */ + DBUG_RETURN(1); /* purecov: inspected */ } } } @@ -590,7 +590,7 @@ bool ha_berkeley::fix_rec_buff_for_blob(ulong length) byte *newptr; if (!(newptr=(byte*) my_realloc((gptr) rec_buff, length, MYF(MY_ALLOW_ZERO_PTR)))) - return 1; + return 1; /* purecov: inspected */ rec_buff=newptr; alloced_rec_buff_length=length; } @@ -637,7 +637,7 @@ int ha_berkeley::pack_row(DBT *row, const byte *record, bool new_row) if (table->blob_fields) { if (fix_rec_buff_for_blob(max_row_length(record))) - return HA_ERR_OUT_OF_MEM; + return HA_ERR_OUT_OF_MEM; /* purecov: inspected */ } /* Copy null bits */ @@ -805,7 +805,7 @@ int ha_berkeley::write_row(byte * record) if (table->next_number_field && record == table->record[0]) update_auto_increment(); if ((error=pack_row(&row, record,1))) - DBUG_RETURN(error); + DBUG_RETURN(error); /* purecov: inspected */ if (table->keys == 1) { @@ -824,9 +824,9 @@ int ha_berkeley::write_row(byte * record) key_map changed_keys = 0; if (using_ignore && (thd_options & OPTION_INTERNAL_SUBTRANSACTIONS)) { - if ((error=txn_begin(db_env, transaction, &sub_trans, 0))) - break; - DBUG_PRINT("trans",("starting subtransaction")); + if ((error=txn_begin(db_env, transaction, &sub_trans, 0))) /* purecov: deadcode */ + break; /* purecov: deadcode */ + DBUG_PRINT("trans",("starting subtransaction")); /* purecov: deadcode */ } if (!(error=file->put(file, sub_trans, create_key(&prim_key, primary_key, key_buff, record), @@ -884,8 +884,8 @@ int ha_berkeley::write_row(byte * record) } else if (using_ignore && (thd_options & OPTION_INTERNAL_SUBTRANSACTIONS)) { - DBUG_PRINT("trans",("committing subtransaction")); - error=txn_commit(sub_trans, 0); + DBUG_PRINT("trans",("committing subtransaction")); /* purecov: deadcode */ + error=txn_commit(sub_trans, 0); /* purecov: deadcode */ } if (error != DB_LOCK_DEADLOCK) break; @@ -968,7 +968,7 @@ int ha_berkeley::update_primary_key(DB_TXN *trans, bool primary_key_changed, if ((new_error=pack_row(&row, old_row, 0)) || (new_error=file->put(file, trans, old_key, &row, key_type[primary_key]))) - error=new_error; // fatal error + error=new_error; // fatal error /* purecov: inspected */ } } } @@ -1003,7 +1003,7 @@ int ha_berkeley::restore_keys(DB_TXN *trans, key_map changed_keys, duplicate key failure */ if ((error=update_primary_key(trans, TRUE, new_row, new_key, old_row, old_key, thd_options, FALSE))) - goto err; + goto err; /* purecov: inspected */ /* Remove the new key, and put back the old key changed_keys is a map of all non-primary keys that need to be @@ -1016,12 +1016,12 @@ int ha_berkeley::restore_keys(DB_TXN *trans, key_map changed_keys, { if (changed_keys != 1 && (error = remove_key(trans, keynr, new_row, (DBT*) 0, new_key))) - break; + break; /* purecov: inspected */ if ((error = key_file[keynr]->put(key_file[keynr], trans, create_key(&tmp_key, keynr, key_buff2, old_row), old_key, key_type[keynr]))) - break; + break; /* purecov: inspected */ } } @@ -1069,9 +1069,9 @@ int ha_berkeley::update_row(const byte * old_row, byte * new_row) key_map changed_keys = 0; if (using_ignore && (thd_options & OPTION_INTERNAL_SUBTRANSACTIONS)) { - if ((error=txn_begin(db_env, transaction, &sub_trans, 0))) - break; - DBUG_PRINT("trans",("starting subtransaction")); + if ((error=txn_begin(db_env, transaction, &sub_trans, 0))) /* purecov: deadcode */ + break; /* purecov: deadcode */ + DBUG_PRINT("trans",("starting subtransaction")); /* purecov: deadcode */ } /* Start by updating the primary key */ if (!(error=update_primary_key(sub_trans, primary_key_changed, @@ -1089,7 +1089,7 @@ int ha_berkeley::update_row(const byte * old_row, byte * new_row) if ((error=remove_key(sub_trans, keynr, old_row, (DBT*) 0, &old_prim_key))) { - if (using_ignore && + if (using_ignore && /* purecov: inspected */ (thd_options & OPTION_INTERNAL_SUBTRANSACTIONS)) { int new_error; @@ -1098,7 +1098,7 @@ int ha_berkeley::update_row(const byte * old_row, byte * new_row) if (new_error) error = new_error; } - DBUG_RETURN(error); // Fatal error + DBUG_RETURN(error); // Fatal error /* purecov: inspected */ } changed_keys |= (key_map)1 << keynr; if ((error=key_file[keynr]->put(key_file[keynr], sub_trans, @@ -1121,8 +1121,8 @@ int ha_berkeley::update_row(const byte * old_row, byte * new_row) int new_error = 0; if (thd_options & OPTION_INTERNAL_SUBTRANSACTIONS) { - DBUG_PRINT("trans",("aborting subtransaction")); - new_error=txn_abort(sub_trans); + DBUG_PRINT("trans",("aborting subtransaction")); /* purecov: deadcode */ + new_error=txn_abort(sub_trans); /* purecov: deadcode */ } else if (changed_keys) new_error=restore_keys(transaction, changed_keys, primary_key, @@ -1130,15 +1130,15 @@ int ha_berkeley::update_row(const byte * old_row, byte * new_row) thd_options); if (new_error) { - error=new_error; // This shouldn't happen - break; + error=new_error; // This shouldn't happen /* purecov: inspected */ + break; /* purecov: inspected */ } } } else if (using_ignore && (thd_options & OPTION_INTERNAL_SUBTRANSACTIONS)) { - DBUG_PRINT("trans",("committing subtransaction")); - error=txn_commit(sub_trans, 0); + DBUG_PRINT("trans",("committing subtransaction")); /* purecov: deadcode */ + error=txn_commit(sub_trans, 0); /* purecov: deadcode */ } if (error != DB_LOCK_DEADLOCK) break; @@ -1219,8 +1219,8 @@ int ha_berkeley::remove_keys(DB_TXN *trans, const byte *record, int new_error=remove_key(trans, keynr, record, new_record, prim_key); if (new_error) { - result=new_error; // Return last error - break; // Let rollback correct things + result=new_error; // Return last error /* purecov: inspected */ + break; // Let rollback correct things /* purecov: inspected */ } } } @@ -1238,7 +1238,7 @@ int ha_berkeley::delete_row(const byte * record) statistic_increment(ha_delete_count,&LOCK_status); if ((error=pack_row(&row, record, 0))) - DBUG_RETURN((error)); + DBUG_RETURN((error)); /* purecov: inspected */ create_key(&prim_key, primary_key, key_buff, record); if (hidden_primary_key) keys|= (key_map) 1 << primary_key; @@ -1250,18 +1250,18 @@ int ha_berkeley::delete_row(const byte * record) { if (thd_options & OPTION_INTERNAL_SUBTRANSACTIONS) { - if ((error=txn_begin(db_env, transaction, &sub_trans, 0))) - break; - DBUG_PRINT("trans",("starting sub transaction")); + if ((error=txn_begin(db_env, transaction, &sub_trans, 0))) /* purecov: deadcode */ + break; /* purecov: deadcode */ + DBUG_PRINT("trans",("starting sub transaction")); /* purecov: deadcode */ } error=remove_keys(sub_trans, record, &row, &prim_key, keys); if (!error && (thd_options & OPTION_INTERNAL_SUBTRANSACTIONS)) { - DBUG_PRINT("trans",("ending sub transaction")); - error=txn_commit(sub_trans, 0); + DBUG_PRINT("trans",("ending sub transaction")); /* purecov: deadcode */ + error=txn_commit(sub_trans, 0); /* purecov: deadcode */ } if (error) - { + { /* purecov: inspected */ DBUG_PRINT("error",("Got error %d",error)); if (thd_options & OPTION_INTERNAL_SUBTRANSACTIONS) { @@ -1297,7 +1297,7 @@ int ha_berkeley::index_init(uint keynr) if ((error=file->cursor(key_file[keynr], transaction, &cursor, table->reginfo.lock_type > TL_WRITE_ALLOW_READ ? 0 : 0))) - cursor=0; // Safety + cursor=0; // Safety /* purecov: inspected */ bzero((char*) &last_key,sizeof(last_key)); DBUG_RETURN(error); } @@ -1346,9 +1346,9 @@ int ha_berkeley::read_row(int error, char *buf, uint keynr, DBT *row, } DBT key; bzero((char*) &key,sizeof(key)); - key.data=key_buff2; + key.data=key_buff; key.size=row->size; - memcpy(key_buff2,row->data,row->size); + memcpy(key_buff,row->data,row->size); /* Read the data into current_row */ current_row.flags=DB_DBT_REALLOC; if ((error=file->get(file, transaction, &key, ¤t_row, 0))) @@ -1628,8 +1628,8 @@ int ha_berkeley::external_lock(THD *thd, int lock_type) (DB_TXN**) &thd->transaction.all.bdb_tid, 0))) { - thd->transaction.bdb_lock_count--; // We didn't get the lock - DBUG_RETURN(error); + thd->transaction.bdb_lock_count--; // We didn't get the lock /* purecov: inspected */ + DBUG_RETURN(error); /* purecov: inspected */ } } DBUG_PRINT("trans",("starting transaction for statement")); @@ -1639,8 +1639,8 @@ int ha_berkeley::external_lock(THD *thd, int lock_type) 0))) { /* We leave the possible master transaction open */ - thd->transaction.bdb_lock_count--; // We didn't get the lock - DBUG_RETURN(error); + thd->transaction.bdb_lock_count--; // We didn't get the lock /* purecov: inspected */ + DBUG_RETURN(error); /* purecov: inspected */ } } transaction= (DB_TXN*) thd->transaction.stmt.bdb_tid; @@ -1741,19 +1741,19 @@ static int create_sub_table(const char *table_name, const char *sub_name, DB_THREAD | DB_CREATE, my_umask)); if (error) { - DBUG_PRINT("error",("Got error: %d when opening table '%s'",error, - table_name)); - (void) file->remove(file,table_name,NULL,0); + DBUG_PRINT("error",("Got error: %d when opening table '%s'",error, /* purecov: inspected */ + table_name)); /* purecov: inspected */ + (void) file->remove(file,table_name,NULL,0); /* purecov: inspected */ } else (void) file->close(file,0); } else { - DBUG_PRINT("error",("Got error: %d when creting table",error)); + DBUG_PRINT("error",("Got error: %d when creting table",error)); /* purecov: inspected */ } if (error) - my_errno=error; + my_errno=error; /* purecov: inspected */ DBUG_RETURN(error); } @@ -1771,7 +1771,7 @@ int ha_berkeley::create(const char *name, register TABLE *form, /* Create the main table that will hold the real rows */ if (create_sub_table(name_buff,"main",DB_BTREE,0)) - DBUG_RETURN(1); + DBUG_RETURN(1); /* purecov: inspected */ primary_key=table->primary_key; /* Create the keys */ @@ -1783,7 +1783,7 @@ int ha_berkeley::create(const char *name, register TABLE *form, if (create_sub_table(name_buff, part, DB_BTREE, (table->key_info[i].flags & HA_NOSAME) ? 0 : DB_DUP)) - DBUG_RETURN(1); + DBUG_RETURN(1); /* purecov: inspected */ } } @@ -1813,7 +1813,7 @@ int ha_berkeley::delete_table(const char *name) int error; char name_buff[FN_REFLEN]; if ((error=db_create(&file, db_env, 0))) - my_errno=error; + my_errno=error; /* purecov: inspected */ else error=file->remove(file,fn_format(name_buff,name,"",ha_berkeley_ext,2 | 4), NULL,0); @@ -1850,7 +1850,7 @@ ha_rows ha_berkeley::records_in_range(int keynr, pack_key(&key, keynr, key_buff, end_key, end_key_len), &end_range,0))) - DBUG_RETURN(HA_BERKELEY_RANGE_COUNT); // Better than returning an error + DBUG_RETURN(HA_BERKELEY_RANGE_COUNT); // Better than returning an error /* purecov: inspected */ if (!start_key) start_pos=0.0; @@ -2114,9 +2114,9 @@ static BDB_SHARE *get_share(const char *table_name, TABLE *table) share->key_type = key_type; if (hash_insert(&bdb_open_tables, (char*) share)) { - pthread_mutex_unlock(&bdb_mutex); - my_free((gptr) share,0); - return 0; + pthread_mutex_unlock(&bdb_mutex); /* purecov: inspected */ + my_free((gptr) share,0); /* purecov: inspected */ + return 0; /* purecov: inspected */ } thr_lock_init(&share->lock); pthread_mutex_init(&share->mutex,NULL); @@ -2133,7 +2133,7 @@ static int free_share(BDB_SHARE *share, TABLE *table, uint hidden_primary_key, uint keys=table->keys + test(hidden_primary_key); pthread_mutex_lock(&bdb_mutex); if (mutex_is_locked) - pthread_mutex_unlock(&share->mutex); + pthread_mutex_unlock(&share->mutex); /* purecov: inspected */ if (!--share->use_count) { DB **key_file = share->key_file; @@ -2142,11 +2142,11 @@ static int free_share(BDB_SHARE *share, TABLE *table, uint hidden_primary_key, for (uint i=0; i < keys; i++) { if (key_file[i] && (error=key_file[i]->close(key_file[i],0))) - result=error; + result=error; /* purecov: inspected */ } if (share->status_block && (error = share->status_block->close(share->status_block,0))) - result = error; + result = error; /* purecov: inspected */ hash_delete(&bdb_open_tables, (gptr) share); thr_lock_delete(&share->lock); pthread_mutex_destroy(&share->mutex); @@ -2187,8 +2187,8 @@ void ha_berkeley::get_status() if (share->status_block->open(share->status_block, name_buff, "status", DB_BTREE, open_mode, 0)) { - share->status_block->close(share->status_block, 0); - share->status_block=0; + share->status_block->close(share->status_block, 0); /* purecov: inspected */ + share->status_block=0; /* purecov: inspected */ } } } @@ -2257,16 +2257,16 @@ static void update_status(BDB_SHARE *share, TABLE *table) (This '*should*' always exist for table created with MySQL) */ - char name_buff[FN_REFLEN]; - if (db_create(&share->status_block, db_env, 0)) - goto end; - share->status_block->set_flags(share->status_block,0); + char name_buff[FN_REFLEN]; /* purecov: inspected */ + if (db_create(&share->status_block, db_env, 0)) /* purecov: inspected */ + goto end; /* purecov: inspected */ + share->status_block->set_flags(share->status_block,0); /* purecov: inspected */ if (share->status_block->open(share->status_block, fn_format(name_buff,share->table_name,"", ha_berkeley_ext,2 | 4), "status", DB_BTREE, - DB_THREAD | DB_CREATE, my_umask)) - goto end; + DB_THREAD | DB_CREATE, my_umask)) /* purecov: inspected */ + goto end; /* purecov: inspected */ } { char rec_buff[4+MAX_KEY*4], *pos=rec_buff; diff --git a/sql/init.cc b/sql/init.cc index 0103cd5038a..e6606b82b7c 100644 --- a/sql/init.cc +++ b/sql/init.cc @@ -39,7 +39,6 @@ void unireg_init(ulong options) #endif my_abort_hook=unireg_abort; /* Abort with close of databases */ f_fyllchar=' '; /* Input fill char */ - bfill(last_ref,MAX_REFLENGTH,(uchar) 255); /* This is indexfile-last-ref */ VOID(strmov(reg_ext,".frm")); for (i=0 ; i < 6 ; i++) // YYMMDDHHMMSS diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index 8afdbdc67eb..11e847d9b2b 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -523,7 +523,6 @@ extern bool low_priority_updates; extern bool opt_sql_bin_update, opt_safe_show_db; extern char language[LIBLEN],reg_ext[FN_EXTLEN],blob_newline; extern const char **errmesg; /* Error messages */ -extern byte last_ref[MAX_REFLENGTH]; /* Index ref of keys */ extern String empty_string; extern struct show_var_st init_vars[]; extern struct show_var_st status_vars[]; diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 18082c3ccc9..b6caa6c492c 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -279,7 +279,6 @@ char server_version[50]=MYSQL_SERVER_VERSION; const char *first_keyword="first"; const char **errmesg; /* Error messages */ const char *myisam_recover_options_str="OFF"; -byte last_ref[MAX_REFLENGTH]; /* Index ref of keys */ my_string mysql_unix_port=NULL,mysql_tmpdir=NULL; ulong my_bind_addr; /* the address we bind to */ DATE_FORMAT dayord; diff --git a/sql/records.cc b/sql/records.cc index 0493e4183eb..89eae81fe27 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -164,8 +164,6 @@ static int rr_from_tempfile(READ_RECORD *info) { if (my_b_read(info->io_cache,info->ref_pos,info->ref_length)) return -1; /* End of file */ - if (TEST_IF_LASTREF(info->ref_pos,info->ref_length)) - return -1; /* File ends with this */ int tmp=info->file->rnd_pos(info->record,info->ref_pos); if (tmp) { @@ -271,16 +269,6 @@ static int rr_from_cache(READ_RECORD *info) ref_position=info->read_positions; for (i=0 ; i < length ; i++,position+=info->ref_length) { - if (memcmp(position,last_ref,(size_s) info->ref_length) == 0) - { /* End of file */ - if (!i) - { - DBUG_PRINT("info",("Found end of file")); - return -1; /* Last record and no in buffert */ - } - length=i; // rows in buffer - break; - } memcpy(ref_position,position,(size_s) info->ref_length); ref_position+=MAX_REFLENGTH; int3store(ref_position,(long) i); diff --git a/sql/unireg.h b/sql/unireg.h index 9f078ef3766..7ad3bac2eab 100644 --- a/sql/unireg.h +++ b/sql/unireg.h @@ -105,12 +105,6 @@ bmove_allign((A)->record[0],(A)->record[2],(size_t) (A)->reclength); \ bfill((A)->null_flags,(A)->null_bytes,255);\ } -#if MAX_REFLENGTH == 4 -#define TEST_IF_LASTREF(A,B) ((long) *((int32*) (A)) == -1L) -#else -#define TEST_IF_LASTREF(A,B) (bcmp(A,last_ref,B) == 0) -#endif - /* Defines for use with openfrm, openprt and openfrd */ #define READ_ALL 1 /* openfrm: Read all parameters */ |