diff options
| author | monty@donna.mysql.com <> | 2000-11-18 02:15:06 +0200 |
|---|---|---|
| committer | monty@donna.mysql.com <> | 2000-11-18 02:15:06 +0200 |
| commit | e5dcd8bed327259fa09cfe7e82fc4dbe7642b8bd (patch) | |
| tree | e47c14103d1588f6a27c229783e07d73438c96d0 /sql | |
| parent | 19a9f8f943ad93d0d607ff358cd7314a6ee262d2 (diff) | |
| download | mariadb-git-e5dcd8bed327259fa09cfe7e82fc4dbe7642b8bd.tar.gz | |
Portability fixes
Diffstat (limited to 'sql')
| -rw-r--r-- | sql/log.cc | 33 | ||||
| -rw-r--r-- | sql/log_event.h | 2 | ||||
| -rw-r--r-- | sql/mf_iocache.cc | 21 | ||||
| -rw-r--r-- | sql/mysqlbinlog.cc | 4 | ||||
| -rw-r--r-- | sql/mysqld.cc | 5 | ||||
| -rw-r--r-- | sql/slave.cc | 6 | ||||
| -rw-r--r-- | sql/sql_parse.cc | 2 | ||||
| -rw-r--r-- | sql/sql_table.cc | 27 |
8 files changed, 52 insertions, 48 deletions
diff --git a/sql/log.cc b/sql/log.cc index 4f25d758f19..3563b7b1a08 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -171,7 +171,7 @@ void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, sprintf(buff, "%s, Version: %s, started with:\nTcp port: %d Unix socket: %s\n", my_progname,server_version,mysql_port,mysql_unix_port); #endif end=strmov(strend(buff),"Time Id Command Argument\n"); - if (my_b_write(&log_file,buff,(uint) (end-buff)) || + if (my_b_write(&log_file, (byte*) buff,(uint) (end-buff)) || flush_io_cache(&log_file)) goto err; } @@ -188,7 +188,7 @@ void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, tm_tmp.tm_hour, tm_tmp.tm_min, tm_tmp.tm_sec); - if (my_b_write(&log_file,buff,(uint) strlen(buff)) || + if (my_b_write(&log_file, (byte*) buff,(uint) strlen(buff)) || flush_io_cache(&log_file)) goto err; } @@ -212,9 +212,9 @@ void MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, s.write(&log_file); flush_io_cache(&log_file); pthread_mutex_lock(&LOCK_index); - error=(my_write(index_file, log_file_name,strlen(log_file_name), + error=(my_write(index_file, (byte*) log_file_name, strlen(log_file_name), MYF(MY_NABP | MY_WME)) || - my_write(index_file, "\n", 1, MYF(MY_NABP | MY_WME))); + my_write(index_file, (byte*) "\n", 1, MYF(MY_NABP | MY_WME))); pthread_mutex_unlock(&LOCK_index); if (error) { @@ -444,8 +444,8 @@ during log purge for write"); { char* l; get_dynamic(&logs_to_keep, (gptr)&l, i); - if (my_write(index_file, l, strlen(l), MYF(MY_WME|MY_NABP)) || - my_write(index_file, "\n", 1, MYF(MY_WME|MY_NABP))) + if (my_write(index_file, (byte*) l, strlen(l), MYF(MY_WME|MY_NABP)) || + my_write(index_file, (byte*) "\n", 1, MYF(MY_WME|MY_NABP))) { error = LOG_INFO_FATAL; goto err; @@ -571,21 +571,21 @@ void MYSQL_LOG::write(THD *thd,enum enum_server_command command, start->tm_hour, start->tm_min, start->tm_sec); - if (my_b_write(&log_file,buff,16)) + if (my_b_write(&log_file, (byte*) buff,16)) error=errno; } - else if (my_b_write(&log_file,"\t\t",2) < 0) + else if (my_b_write(&log_file, (byte*) "\t\t",2) < 0) error=errno; sprintf(buff,"%7ld %-10.10s", id,command_name[(uint) command]); - if (my_b_write(&log_file,buff,strlen(buff))) + if (my_b_write(&log_file, (byte*) buff,strlen(buff))) error=errno; if (format) { - if (my_b_write(&log_file," ",1) || + if (my_b_write(&log_file, (byte*) " ",1) || my_b_vprintf(&log_file,format,args) == (uint) -1) error=errno; } - if (my_b_write(&log_file,"\n",1) || + if (my_b_write(&log_file, (byte*) "\n",1) || flush_io_cache(&log_file)) error=errno; if (error && ! write_error) @@ -711,7 +711,6 @@ void MYSQL_LOG::write(THD *thd,const char *query, uint query_length, last_time=current_time; struct tm tm_tmp; struct tm *start; - char buff[32]; localtime_r(¤t_time,&tm_tmp); start=&tm_tmp; /* Note that my_b_write() assumes it knows the length for this */ @@ -722,7 +721,7 @@ void MYSQL_LOG::write(THD *thd,const char *query, uint query_length, start->tm_hour, start->tm_min, start->tm_sec); - if (my_b_write(&log_file,buff,24)) + if (my_b_write(&log_file, (byte*) buff,24)) error=errno; } if (my_b_printf(&log_file, "# User@Host: %s [%s] @ %s [%s]\n", @@ -778,8 +777,8 @@ void MYSQL_LOG::write(THD *thd,const char *query, uint query_length, *end++=';'; *end++='\n'; *end=0; - if (my_b_write(&log_file,"SET ",4) || - my_b_write(&log_file,buff+1,(uint) (end-buff)-1)) + if (my_b_write(&log_file, (byte*) "SET ",4) || + my_b_write(&log_file, (byte*) buff+1,(uint) (end-buff)-1)) error=errno; } if (!query) @@ -787,8 +786,8 @@ void MYSQL_LOG::write(THD *thd,const char *query, uint query_length, query="#adminstrator command"; query_length=21; } - if (my_b_write(&log_file,(byte*) query,query_length) || - my_b_write(&log_file,";\n",2) || + if (my_b_write(&log_file, (byte*) query,query_length) || + my_b_write(&log_file, (byte*) ";\n",2) || flush_io_cache(&log_file)) error=errno; if (error && ! write_error) diff --git a/sql/log_event.h b/sql/log_event.h index fb71a52a82e..c956cfde396 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -363,7 +363,7 @@ public: Stop_log_event(IO_CACHE* file, time_t when_arg, uint32 server_id): Log_event(when_arg,0,0,server_id) { - char skip[4]; + byte skip[4]; my_b_read(file, skip, sizeof(skip)); // skip the event length } Stop_log_event(const char* buf):Log_event(buf) diff --git a/sql/mf_iocache.cc b/sql/mf_iocache.cc index c1e6b37a848..f723e35ca93 100644 --- a/sql/mf_iocache.cc +++ b/sql/mf_iocache.cc @@ -37,6 +37,7 @@ #include <errno.h> static void my_aiowait(my_aio_result *result); #endif +#include <assert.h> extern "C" { @@ -233,24 +234,28 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type, - /* Read buffered. Returns 1 if can't read requested characters */ - /* Returns 0 if record read */ + /* + Read buffered. Returns 1 if can't read requested characters + This function is only called from the my_b_read() macro + when there isn't enough characters in the buffer to + satisfy the request. + Returns 0 we succeeded in reading all data + */ int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count) { uint length,diff_length,left_length; my_off_t max_length, pos_in_file; - if((left_length=(uint) (info->rc_end-info->rc_pos))) + if ((left_length=(uint) (info->rc_end-info->rc_pos))) { - if(Count < left_length) - left_length = Count; - memcpy(Buffer,info->rc_pos, - (size_t) (left_length)); + dbug_assert(Count >= left_length); /* User is not using my_b_read() */ + memcpy(Buffer,info->rc_pos, (size_t) (left_length)); Buffer+=left_length; Count-=left_length; } - pos_in_file=info->pos_in_file+ left_length; + /* pos_in_file always point on where info->buffer was read */ + pos_in_file=info->pos_in_file+(uint) (info->rc_end - info->buffer); if (info->seek_not_done) { /* File touched, do seek */ VOID(my_seek(info->file,pos_in_file,MY_SEEK_SET,MYF(0))); diff --git a/sql/mysqlbinlog.cc b/sql/mysqlbinlog.cc index 12b8e71d017..dd1d6fe9765 100644 --- a/sql/mysqlbinlog.cc +++ b/sql/mysqlbinlog.cc @@ -330,12 +330,12 @@ static void dump_local_log_entries(const char* logname) if (position) { /* skip 'position' characters from stdout */ - char buff[IO_SIZE]; + byte buff[IO_SIZE]; my_off_t length,tmp; for (length=position ; length > 0 ; length-=tmp) { tmp=min(length,sizeof(buff)); - if (my_b_read(file,buff,tmp)) + if (my_b_read(file,buff, (uint) tmp)) exit(1); } } diff --git a/sql/mysqld.cc b/sql/mysqld.cc index ff0307bde1d..42221be9176 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -569,7 +569,6 @@ static sig_handler print_signal_warning(int sig) void unireg_end(int signal_number __attribute__((unused))) { - (void) my_delete(pidfile_name,MYF(0)); // This may not always exist clean_up(); pthread_exit(0); // Exit is in main thread } @@ -580,7 +579,6 @@ void unireg_abort(int exit_code) if (exit_code) sql_print_error("Aborting\n"); clean_up(); /* purecov: inspected */ - (void) my_delete(pidfile_name,MYF(0)); // This may not always exist exit(exit_code); /* purecov: inspected */ } @@ -610,6 +608,7 @@ void clean_up(void) free_defaults(defaults_argv); my_free(mysql_tmpdir,MYF(0)); x_free(opt_bin_logname); + (void) my_delete(pidfile_name,MYF(0)); // This may not always exist my_end(opt_endinfo ? MY_CHECK_ERROR | MY_GIVE_INFO : 0); /* Tell main we are ready */ @@ -1520,7 +1519,7 @@ int main(int argc, char **argv) sql_print_error("Can't init databases"); exit(1); } -#ifdef HAVE_MLOCKALL +#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) if (locked_in_memory && !geteuid()) { ha_key_cache(); diff --git a/sql/slave.cc b/sql/slave.cc index 785d4394845..aae2e6e40cb 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -42,7 +42,7 @@ static int create_table_from_dump(THD* thd, NET* net, const char* db, static inline char* rewrite_db(char* db); static void free_table_ent(TABLE_RULE_ENT* e) { - my_free((byte*)e, MYF(0)); + my_free((gptr) e, MYF(0)); } static byte* get_table_key(TABLE_RULE_ENT* e, uint* len, @@ -74,12 +74,12 @@ int tables_ok(THD* thd, TABLE_LIST* tables) uint len = strmov(p, tables->real_name) - hash_key ; if(do_table_inited) // if there are any do's { - if(hash_search(&replicate_do_table, hash_key, len)) + if(hash_search(&replicate_do_table, (byte*) hash_key, len)) return 1; } if(ignore_table_inited) // if there are any do's { - if(hash_search(&replicate_ignore_table, hash_key, len)) + if(hash_search(&replicate_ignore_table, (byte*) hash_key, len)) return 0; } } diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 467feaef6d8..79c36431cb1 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1559,7 +1559,7 @@ mysql_execute_command(void) /* Check if auto_commit mode changed */ if ((org_options ^ lex->options) & OPTION_AUTO_COMMIT) { - if (!org_options & OPTION_AUTO_COMMIT) + if (!(org_options & OPTION_AUTO_COMMIT)) { /* We changed to auto_commit mode */ thd->options&= ~(ulong) (OPTION_BEGIN); diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 7ae3b525609..173511083e4 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -48,6 +48,7 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists) bool some_tables_deleted=0; uint error; db_type table_type; + TABLE_LIST *table; DBUG_ENTER("mysql_rm_table"); /* mark for close and remove all cached entries */ @@ -59,22 +60,22 @@ int mysql_rm_table(THD *thd,TABLE_LIST *tables, my_bool if_exists) pthread_mutex_unlock(&thd->mysys_var->mutex); if(global_read_lock) + { + if(thd->global_read_lock) { - if(thd->global_read_lock) - { - my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,MYF(0), - tables->real_name); - error = 1; - goto err; - } - while (global_read_lock && ! thd->killed) - { - (void) pthread_cond_wait(&COND_refresh,&LOCK_open); - } - + my_error(ER_TABLE_NOT_LOCKED_FOR_WRITE,MYF(0), + tables->real_name); + error = 1; + goto err; } + while (global_read_lock && ! thd->killed) + { + (void) pthread_cond_wait(&COND_refresh,&LOCK_open); + } + + } - for (TABLE_LIST *table=tables ; table ; table=table->next) + for (table=tables ; table ; table=table->next) { char *db=table->db ? table->db : thd->db; if (!close_temporary_table(thd, db, table->real_name)) |
