Commit c1b5a5b0 authored by monty@donna.mysql.com's avatar monty@donna.mysql.com

Removed not used variable 'last_ref'

Fixed problem with negative DECIMAL() keys
Fixed some bugs with NULL keys in BDB
More mysql-test tests
parent 3857c6a3
......@@ -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
......@@ -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);
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
......@@ -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)
......
......@@ -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;
......
......@@ -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 / ]
......
......@@ -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
database() user()
test test@localhost
test root@localhost
version()>="3.23.29"
1
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
......@@ -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;
......@@ -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);
......
This diff is collapsed.
......@@ -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)
......
......@@ -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
......
This diff is collapsed.
......@@ -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
......
......@@ -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[];
......
......@@ -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;
......
......@@ -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);
......
......@@ -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 */
......
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