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

Fixes for mysqltest

parent 432adefd
...@@ -19317,10 +19317,11 @@ new @code{INSERT DELAYED} commands are received within ...@@ -19317,10 +19317,11 @@ new @code{INSERT DELAYED} commands are received within
@code{delayed_insert_timeout} seconds, the handler terminates. @code{delayed_insert_timeout} seconds, the handler terminates.
@item @item
If more than @code{delayed_queue_size} rows are pending already in a specific If more than @code{delayed_queue_size} rows are pending already in a
handler queue, the thread waits until there is room in the queue. This is specific handler queue, the thread requesting @code{INSERT DELAYED}
useful to ensure that the @code{mysqld} server doesn't use all memory for the waits until there is room in the queue. This is done to ensure that
delayed memory queue. the @code{mysqld} server doesn't use all memory for the delayed memory
queue.
@item @item
The handler thread will show up in the @strong{MySQL} process list The handler thread will show up in the @strong{MySQL} process list
...@@ -43,7 +43,7 @@ ...@@ -43,7 +43,7 @@
**********************************************************************/ **********************************************************************/
#define MTEST_VERSION "1.5" #define MTEST_VERSION "1.6"
#include <global.h> #include <global.h>
#include <my_sys.h> #include <my_sys.h>
...@@ -71,23 +71,24 @@ ...@@ -71,23 +71,24 @@
#define MIN_VAR_ALLOC 32 #define MIN_VAR_ALLOC 32
#define BLOCK_STACK_DEPTH 32 #define BLOCK_STACK_DEPTH 32
int record = 0, verbose = 0, silent = 0, opt_sleep=0; static int record = 0, verbose = 0, silent = 0, opt_sleep=0;
static char *db = 0, *pass=0; static char *db = 0, *pass=0;
const char* user = 0, *host = 0, *unix_sock = 0; const char* user = 0, *host = 0, *unix_sock = 0;
int port = 0; static int port = 0;
static uint start_lineno, *lineno; static uint start_lineno, *lineno;
static char **default_argv; static char **default_argv;
static const char *load_default_groups[]= { "mysqltest","client",0 }; static const char *load_default_groups[]= { "mysqltest","client",0 };
FILE* file_stack[MAX_INCLUDE_DEPTH]; static FILE* file_stack[MAX_INCLUDE_DEPTH];
FILE** cur_file; static FILE** cur_file;
FILE** file_stack_end; static FILE** file_stack_end;
uint lineno_stack[MAX_INCLUDE_DEPTH]; static uint lineno_stack[MAX_INCLUDE_DEPTH];
char TMPDIR[FN_REFLEN]; static char TMPDIR[FN_REFLEN];
int block_stack[BLOCK_STACK_DEPTH]; static int block_stack[BLOCK_STACK_DEPTH];
int *cur_block, *block_stack_end; static int *cur_block, *block_stack_end;
static uint global_expected_errno=0;
DYNAMIC_ARRAY q_lines; DYNAMIC_ARRAY q_lines;
...@@ -137,13 +138,13 @@ struct st_query ...@@ -137,13 +138,13 @@ struct st_query
enum { Q_CONNECTION=1, Q_QUERY, Q_CONNECT, enum { Q_CONNECTION=1, Q_QUERY, Q_CONNECT,
Q_SLEEP, Q_INC, Q_DEC,Q_SOURCE, Q_SLEEP, Q_INC, Q_DEC,Q_SOURCE,
Q_DISCONNECT,Q_LET, Q_ECHO, Q_WHILE, Q_END_BLOCK, Q_DISCONNECT,Q_LET, Q_ECHO, Q_WHILE, Q_END_BLOCK,
Q_SYSTEM, Q_RESULT, Q_REQUIRE, Q_SYSTEM, Q_RESULT, Q_REQUIRE, Q_ERROR,
Q_UNKNOWN, Q_COMMENT, Q_COMMENT_WITH_COMMAND} type; Q_UNKNOWN, Q_COMMENT, Q_COMMENT_WITH_COMMAND} type;
}; };
const char *command_names[] = { const char *command_names[] = {
"connection", "query","connect","sleep","inc","dec","source","disconnect", "connection", "query","connect","sleep","inc","dec","source","disconnect",
"let","echo","while","end","system","result", "require",0 "let","echo","while","end","system","result", "require","error",0
}; };
TYPELIB command_typelib= {array_elements(command_names),"", TYPELIB command_typelib= {array_elements(command_names),"",
...@@ -541,6 +542,20 @@ static void get_file_name(char *filename, struct st_query* q) ...@@ -541,6 +542,20 @@ static void get_file_name(char *filename, struct st_query* q)
} }
static int get_int(struct st_query* q)
{
char* p=q->first_argument;
int res;
DBUG_ENTER("get_int");
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);
}
int select_connection(struct st_query* q) int select_connection(struct st_query* q)
{ {
char* p=q->first_argument, *name; char* p=q->first_argument, *name;
...@@ -896,16 +911,16 @@ int read_query(struct st_query** q_ptr) ...@@ -896,16 +911,16 @@ int read_query(struct st_query** q_ptr)
get_dynamic(&q_lines, (gptr) q_ptr, parser.current_line) ; get_dynamic(&q_lines, (gptr) q_ptr, parser.current_line) ;
return 0; return 0;
} }
if (!(*q_ptr=q=(struct st_query*) my_malloc(sizeof(*q), MYF(MY_WME))) if (!(*q_ptr=q=(struct st_query*) my_malloc(sizeof(*q), MYF(MY_WME))) ||
|| insert_dynamic(&q_lines, (gptr) &q) insert_dynamic(&q_lines, (gptr) &q))
) die(NullS);
die("Out of memory");
q->record_file[0] = 0; q->record_file[0] = 0;
q->require_file=0; q->require_file=0;
q->abort_on_error = 1;
q->first_word_len = 0; q->first_word_len = 0;
q->expected_errno = 0; q->expected_errno = global_expected_errno;
q->abort_on_error = global_expected_errno == 0;
global_expected_errno=0;
q->type = Q_UNKNOWN; q->type = Q_UNKNOWN;
q->query=0; q->query=0;
if (read_line(read_query_buf, sizeof(read_query_buf))) if (read_line(read_query_buf, sizeof(read_query_buf)))
...@@ -1357,6 +1372,9 @@ int main(int argc, char** argv) ...@@ -1357,6 +1372,9 @@ int main(int argc, char** argv)
get_file_name(save_file,q); get_file_name(save_file,q);
require_file=0; require_file=0;
break; break;
case Q_ERROR:
global_expected_errno=get_int(q);
break;
case Q_REQUIRE: case Q_REQUIRE:
get_file_name(save_file,q); get_file_name(save_file,q);
require_file=1; require_file=1;
......
...@@ -588,11 +588,17 @@ run_testcase () ...@@ -588,11 +588,17 @@ run_testcase ()
if [ x$FORCE != x1 ] ; then if [ x$FORCE != x1 ] ; then
$ECHO "Aborting. To continue, re-run with '--force'." $ECHO "Aborting. To continue, re-run with '--force'."
$ECHO $ECHO
if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && [ -z "$DO_DDD" ]
then
mysql_stop mysql_stop
fi
exit 1 exit 1
fi fi
if [ -z "$DO_GDB" ] && [ -z "$USE_RUNNING_SERVER" ] && [ -z "$DO_DDD" ]
then
mysql_restart mysql_restart
fi
$ECHO "Resuming Tests" $ECHO "Resuming Tests"
$ECHO "" $ECHO ""
else else
......
...@@ -33,7 +33,8 @@ INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2), ...@@ -33,7 +33,8 @@ INSERT INTO t1 VALUES (1,0,0),(3,1,1),(4,1,1),(8,2,2),(9,2,2),(17,3,2),(22,4,2),
update t1 set parent_id=parent_id+100; update t1 set parent_id=parent_id+100;
select * from t1 where parent_id=102; select * from t1 where parent_id=102;
update t1 set id=id+1000; update t1 set id=id+1000;
!$1062 update t1 set id=1024 where id=1009; -- error 1062
update t1 set id=1024 where id=1009;
select * from t1; select * from t1;
update ignore t1 set id=id+1; # This will change all rows update ignore t1 set id=id+1; # This will change all rows
select * from t1; select * from t1;
...@@ -100,12 +101,14 @@ commit; ...@@ -100,12 +101,14 @@ commit;
select n, "after commit" from t1; select n, "after commit" from t1;
commit; commit;
insert into t1 values (5); insert into t1 values (5);
!$1062 insert into t1 values (4); -- error 1062
insert into t1 values (4);
commit; commit;
select n, "after commit" from t1; select n, "after commit" from t1;
set autocommit=1; set autocommit=1;
insert into t1 values (6); insert into t1 values (6);
!$1062 insert into t1 values (4); -- error 1062
insert into t1 values (4);
select n from t1; select n from t1;
# nop # nop
rollback; rollback;
...@@ -135,7 +138,8 @@ drop table t1; ...@@ -135,7 +138,8 @@ drop table t1;
CREATE TABLE t1 (id char(8) not null primary key, val int not null) type=bdb; CREATE TABLE t1 (id char(8) not null primary key, val int not null) type=bdb;
insert into t1 values ('pippo', 12); insert into t1 values ('pippo', 12);
!$1062 insert into t1 values ('pippo', 12); # Gives error -- error 1062
insert into t1 values ('pippo', 12); # Gives error
delete from t1; delete from t1;
delete from t1 where id = 'pippo'; delete from t1 where id = 'pippo';
select * from t1; select * from t1;
......
...@@ -69,7 +69,6 @@ int my_chsize(File fd, my_off_t newlength, myf MyFlags) ...@@ -69,7 +69,6 @@ int my_chsize(File fd, my_off_t newlength, myf MyFlags)
#endif #endif
/* Full file with 0 until it's as big as requested */ /* Full file with 0 until it's as big as requested */
bzero(buff,IO_SIZE); bzero(buff,IO_SIZE);
my_seek(fd, old_length, MY_SEEK_SET, MYF(MY_WME+MY_FAE));
while (newlength-oldsize > IO_SIZE) while (newlength-oldsize > IO_SIZE)
{ {
if (my_write(fd,(byte*) buff,IO_SIZE,MYF(MY_NABP))) if (my_write(fd,(byte*) buff,IO_SIZE,MYF(MY_NABP)))
......
...@@ -3949,7 +3949,12 @@ void Field_blob::get_key_image(char *buff,uint length) ...@@ -3949,7 +3949,12 @@ void Field_blob::get_key_image(char *buff,uint length)
ulong blob_length=get_length(ptr); ulong blob_length=get_length(ptr);
char *blob; char *blob;
if ((ulong) length > blob_length) if ((ulong) length > blob_length)
{
#ifdef HAVE_purify
bzero(buff+2+blob_length, (length-blob_length));
#endif
length=(uint) blob_length; length=(uint) blob_length;
}
int2store(buff,length); int2store(buff,length);
get_ptr(&blob); get_ptr(&blob);
memcpy(buff+2,blob,length); memcpy(buff+2,blob,length);
......
...@@ -140,7 +140,7 @@ bool berkeley_init(void) ...@@ -140,7 +140,7 @@ bool berkeley_init(void)
berkeley_log_file_size= max(berkeley_log_file_size, 10*1024*1024L); berkeley_log_file_size= max(berkeley_log_file_size, 10*1024*1024L);
if (db_env_create(&db_env,0)) if (db_env_create(&db_env,0))
DBUG_RETURN(1); DBUG_RETURN(1); /* purecov: inspected */
db_env->set_errcall(db_env,berkeley_print_error); db_env->set_errcall(db_env,berkeley_print_error);
db_env->set_errpfx(db_env,"bdb"); db_env->set_errpfx(db_env,"bdb");
db_env->set_noticecall(db_env, berkeley_noticecall); db_env->set_noticecall(db_env, berkeley_noticecall);
...@@ -148,7 +148,7 @@ bool berkeley_init(void) ...@@ -148,7 +148,7 @@ bool berkeley_init(void)
db_env->set_data_dir(db_env, mysql_data_home); db_env->set_data_dir(db_env, mysql_data_home);
db_env->set_flags(db_env, berkeley_env_flags, 1); db_env->set_flags(db_env, berkeley_env_flags, 1);
if (berkeley_logdir) if (berkeley_logdir)
db_env->set_lg_dir(db_env, berkeley_logdir); db_env->set_lg_dir(db_env, berkeley_logdir); /* purecov: tested */
if (opt_endinfo) if (opt_endinfo)
db_env->set_verbose(db_env, db_env->set_verbose(db_env,
...@@ -168,8 +168,8 @@ bool berkeley_init(void) ...@@ -168,8 +168,8 @@ bool berkeley_init(void)
DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN |
DB_CREATE | DB_THREAD, 0666)) DB_CREATE | DB_THREAD, 0666))
{ {
db_env->close(db_env,0); db_env->close(db_env,0); /* purecov: inspected */
db_env=0; db_env=0; /* purecov: inspected */
} }
(void) hash_init(&bdb_open_tables,32,0,0, (void) hash_init(&bdb_open_tables,32,0,0,
...@@ -184,7 +184,7 @@ bool berkeley_end(void) ...@@ -184,7 +184,7 @@ bool berkeley_end(void)
int error; int error;
DBUG_ENTER("berkeley_end"); DBUG_ENTER("berkeley_end");
if (!db_env) if (!db_env)
return 1; return 1; /* purecov: tested */
berkeley_cleanup_log_files(); berkeley_cleanup_log_files();
error=db_env->close(db_env,0); // Error is logged error=db_env->close(db_env,0); // Error is logged
db_env=0; db_env=0;
...@@ -1165,8 +1165,9 @@ int ha_berkeley::remove_key(DB_TXN *trans, uint keynr, const byte *record, ...@@ -1165,8 +1165,9 @@ int ha_berkeley::remove_key(DB_TXN *trans, uint keynr, const byte *record,
DBUG_ENTER("remove_key"); DBUG_ENTER("remove_key");
DBUG_PRINT("enter",("index: %d",keynr)); DBUG_PRINT("enter",("index: %d",keynr));
if ((table->key_info[keynr].flags & (HA_NOSAME | HA_NULL_PART_KEY)) == if (keynr == primary_key ||
HA_NOSAME || keynr == primary_key) ((table->key_info[keynr].flags & (HA_NOSAME | HA_NULL_PART_KEY)) ==
HA_NOSAME))
{ // Unique key { // Unique key
dbug_assert(keynr == primary_key || prim_key->data != key_buff2); dbug_assert(keynr == primary_key || prim_key->data != key_buff2);
error=key_file[keynr]->del(key_file[keynr], trans, error=key_file[keynr]->del(key_file[keynr], trans,
......
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