diff options
author | unknown <monty@mashka.mysql.fi> | 2002-09-11 06:40:08 +0300 |
---|---|---|
committer | unknown <monty@mashka.mysql.fi> | 2002-09-11 06:40:08 +0300 |
commit | 8f232cb75f0dce72142e2b584f2cdac4a1de517d (patch) | |
tree | 6ef035adfec09ec1e444dd169712750e2de1efeb /client | |
parent | d99cab040c90913cc5186702166d3b91f58ef42a (diff) | |
download | mariadb-git-8f232cb75f0dce72142e2b584f2cdac4a1de517d.tar.gz |
Portability fixes.
Improve mysql-test to be more robust.
Fix that GRANT doesn't delete SSL options
Change innobase_flush_log_at_trx_commit to uint.
Don't rotate logs if we read a rotate log entry from the master.
Docs/manual.texi:
Changelog
client/mysqlbinlog.cc:
Handle empty binlogfiles gracefully
client/mysqltest.c:
Do a sleep after 'sync_with_master'
Cleaned up sleep() handling.
Free all memory on exit
configure.in:
Fix for Mac OS 10.2
include/my_sys.h:
Added my_strdup_with_length()
innobase/btr/btr0cur.c:
Fixed wrong printf()
libmysql/libmysql.c:
Added DBUG_PRINT statements.
Assume that mysql_...send() functions has correct query length.
mysql-test/mysql-test-run.sh:
Properly remove log files before starting new tests.
mysql-test/r/grant.result:
Update for new test results
mysql-test/r/innodb.result:
Update for new test results
mysql-test/r/myisam.result:
Update for new test results
mysql-test/r/rpl_log.result:
Update for new test results
mysql-test/r/rpl_rotate_logs.result:
Update for new test results
mysql-test/r/variables.result:
Update for new test results
mysql-test/t/grant.test:
Test that GRANT doesn't delete SSL options
mysql-test/t/myisam.test:
Test long key usage
mysql-test/t/rpl_log.test:
Disable 'show new master'
mysql-test/t/rpl_mystery22.test:
Longer sleep for more safety.
mysql-test/t/rpl_rotate_logs.test:
More comments
mysys/my_malloc.c:
Added my_strdup_with_length()
mysys/safemalloc.c:
Added my_strdup_with_length()
mysys/thr_alarm.c:
Fix of alarms for windows.
sql/ha_innodb.cc:
Change innobase_flush_log_at_trx_commit to uint
mysql-test/r/rpl_redirect.result:
Updated test results
mysql-test/t/rpl_redirect.test:
Added more tests to improve code coverage.
sql/ha_innodb.h:
Change innobase_flush_log_at_trx_commit to uint
sql/item_func.cc:
Return GLOBAL and SESSION as part of column names
sql/log.cc:
Only write STOP events when server goes down.
sql/log_event.cc:
Don't rotate logs if we read a rotate log entry from the master.
sql/log_event.h:
Change ident_len to uint (more efficient)
sql/mysqld.cc:
Change innobase_flush_log_at_trx_commit to uint
sql/net_serv.cc:
More debug output
sql/repl_failsafe.cc:
More DEBUG
Search until we find next position in binary log (and not only =)
sql/slave.cc:
More DBUG & comments
Don't rotate the binary log on master flush logs
sql/slave.h:
indentation change
sql/sql_acl.cc:
Test that GRANT doesn't delete SSL options
sql/sql_parse.cc:
Disable show_new_master.
sql/sql_repl.cc:
Chamger show_binlog_events() to use my_error()
sql/sql_table.cc:
Fixed check for too long keys in MyISAM
sql/sql_udf.cc:
Fix udf handling
Diffstat (limited to 'client')
-rw-r--r-- | client/mysqlbinlog.cc | 34 | ||||
-rw-r--r-- | client/mysqltest.c | 102 |
2 files changed, 56 insertions, 80 deletions
diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 4109fbd76d4..58b49a748ec 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -21,7 +21,7 @@ #include "log_event.h" #define BIN_LOG_HEADER_SIZE 4 -#define PROBE_HEADER_LEN (BIN_LOG_HEADER_SIZE+EVENT_LEN_OFFSET+4) +#define PROBE_HEADER_LEN (EVENT_LEN_OFFSET+4) #define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | CLIENT_LOCAL_FILES) @@ -378,31 +378,40 @@ static void dump_remote_log_entries(const char* logname) static int check_header(IO_CACHE* file) { + byte header[BIN_LOG_HEADER_SIZE]; byte buf[PROBE_HEADER_LEN]; int old_format=0; my_off_t pos = my_b_tell(file); my_b_seek(file, (my_off_t)0); - if (my_b_read(file, buf, sizeof(buf))) - die("Failed reading header"); - if (buf[EVENT_TYPE_OFFSET+4] == START_EVENT) + if (my_b_read(file, header, sizeof(header))) + die("Failed reading header; Probably an empty file"); + if (memcmp(header, BINLOG_MAGIC, sizeof(header))) + die("File is not a binary log file"); + if (!my_b_read(file, buf, sizeof(buf))) { - uint event_len; - event_len = uint4korr(buf + EVENT_LEN_OFFSET + 4); - old_format = (event_len < LOG_EVENT_HEADER_LEN + START_HEADER_LEN); + if (buf[4] == START_EVENT) + { + uint event_len; + event_len = uint4korr(buf + 4); + old_format = (event_len < LOG_EVENT_HEADER_LEN + START_HEADER_LEN); + } } my_b_seek(file, pos); return old_format; } + static void dump_local_log_entries(const char* logname) { File fd = -1; IO_CACHE cache,*file= &cache; ulonglong rec_count = 0; - char last_db[FN_REFLEN+1] = ""; + char last_db[FN_REFLEN+1], tmp_buff[BIN_LOG_HEADER_SIZE]; bool old_format = 0; + last_db[0]=0; + if (logname && logname[0] != '-') { if ((fd = my_open(logname, O_RDONLY | O_BINARY, MYF(MY_WME))) < 0) @@ -435,14 +444,7 @@ static void dump_local_log_entries(const char* logname) } if (!position) - { - char magic[BIN_LOG_HEADER_SIZE]; - if (my_b_read(file, (byte*) magic, sizeof(magic))) - die("I/O error reading binlog magic number"); - if (memcmp(magic, BINLOG_MAGIC, 4)) - die("Bad magic number; The file is probably not a MySQL binary log"); - } - + my_b_read(file, tmp_buff, BIN_LOG_HEADER_SIZE); // Skip header for (;;) { char llbuff[21]; diff --git a/client/mysqltest.c b/client/mysqltest.c index d9e964997cc..533713b4f43 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -87,11 +87,8 @@ #define CON_RETRY_SLEEP 2 #define MAX_CON_TRIES 5 -#ifndef OS2 #define SLAVE_POLL_INTERVAL 300000 /* 0.3 of a sec */ -#else -#defile SLAVE_POLL_INTERVAL 0.3 -#endif + enum {OPT_MANAGER_USER=256,OPT_MANAGER_HOST,OPT_MANAGER_PASSWD, OPT_MANAGER_PORT,OPT_MANAGER_WAIT_TIMEOUT}; @@ -423,6 +420,7 @@ static void free_used_memory() my_free(embedded_server_args[--embedded_server_arg_count],MYF(0)); delete_dynamic(&q_lines); dynstr_free(&ds_res); + free_replace(); my_free(pass,MYF(MY_ALLOW_ZERO_PTR)); free_defaults(default_argv); mysql_server_end(); @@ -687,13 +685,23 @@ int open_file(const char* name) return 0; } +static void my_sleep(ulong m_seconds) +{ +#ifndef OS2 + struct timeval t; + t.tv_sec= m_seconds / 1000000L; + t.tv_usec= m_seconds % 1000000L; + select(0,0,0,0,&t); /* sleep */ +#else + DosSleep(m_seconds/1000+1); +#endif +} + + /* ugly long name, but we are following the convention */ int do_wait_for_slave_to_stop(struct st_query* q __attribute__((unused))) { MYSQL* mysql = &cur_con->mysql; -#ifndef OS2 - struct timeval t; -#endif for (;;) { MYSQL_RES* res; @@ -714,15 +722,8 @@ int do_wait_for_slave_to_stop(struct st_query* q __attribute__((unused))) mysql_free_result(res); if (done) break; -#ifndef OS2 - t.tv_sec=0; - t.tv_usec=SLAVE_POLL_INTERVAL; - select(0,0,0,0,&t); /* sleep */ -#else - DosSleep(OS2_SLAVE_POLL_INTERVAL); -#endif + my_sleep(SLAVE_POLL_INTERVAL); } - return 0; } @@ -1000,10 +1001,18 @@ int do_sync_with_master2(const char* p) die("line %u: empty result in %s", start_lineno, query_buf); if (!row[0]) die("Error on slave while syncing with master"); - mysql_free_result(res); last_result=0; + mysql_free_result(res); + last_result=0; if (rpl_parse) mysql_enable_rpl_parse(mysql); +#ifndef TO_BE_REMOVED + /* + We need this because wait_for_pos() only waits for the relay log, + which doesn't guarantee that the slave has executed the statement. + */ + my_sleep(2*1000000L); +#endif return 0; } @@ -1082,53 +1091,15 @@ int do_disable_rpl_parse(struct st_query* q __attribute__((unused))) int do_sleep(struct st_query* q, my_bool real_sleep) { char* p=q->first_argument; - struct timeval t; - int dec_mul = 1000000; - while (*p && isspace(*p)) p++; + while (*p && isspace(*p)) + p++; if (!*p) die("Missing argument in sleep\n"); - t.tv_usec = 0; - -#ifdef OS2 - if (opt_sleep && !real_sleep) - DosSleep( opt_sleep * 1000); + my_sleep(opt_sleep * 1000000L); else - DosSleep( atof( p) * 1000); - + my_sleep((ulong) (atof(p) * 1000000L)); return 0; - -#else - if (opt_sleep && !real_sleep) - t.tv_sec = opt_sleep; - else - { - t.tv_sec = atoi(p); - while (*p && *p != '.' && !isspace(*p)) - p++; - if (*p == '.') - { - int c; - char *p_end; - p++; - p_end = p + 6; - - for (;p <= p_end; ++p) - { - c = (int) (*p - '0'); - if (c < 10 && (int) c >= 0) - { - t.tv_usec = t.tv_usec * 10 + c; - dec_mul /= 10; - } - else - break; - } - } - } - t.tv_usec *= dec_mul; - return select(0,0,0,0, &t); -#endif } static void get_file_name(char *filename, struct st_query* q) @@ -1261,8 +1232,7 @@ static void get_replace(struct st_query *q) POINTER_ARRAY to_array,from_array; DBUG_ENTER("get_replace"); - if (glob_replace) - free_replace(); + free_replace(); bzero((char*) &to_array,sizeof(to_array)); bzero((char*) &from_array,sizeof(from_array)); @@ -1298,9 +1268,12 @@ static void get_replace(struct st_query *q) void free_replace() { DBUG_ENTER("free_replace"); - my_free((char*) glob_replace,MYF(0)); - glob_replace=0; - free_replace_buffer(); + if (glob_replace) + { + my_free((char*) glob_replace,MYF(0)); + glob_replace=0; + free_replace_buffer(); + } DBUG_VOID_RETURN; } @@ -2077,7 +2050,7 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags) char* query; int query_len; DBUG_ENTER("run_query"); - + if (q->type != Q_EVAL) { query = q->query; @@ -2090,6 +2063,7 @@ int run_query(MYSQL* mysql, struct st_query* q, int flags) query = eval_query.str; query_len = eval_query.length; } + DBUG_PRINT("enter", ("query: '%-.60s'", query)); if (q->record_file[0]) { |