diff options
author | unknown <kostja@bodhi.(none)> | 2007-06-01 12:12:06 +0400 |
---|---|---|
committer | unknown <kostja@bodhi.(none)> | 2007-06-01 12:12:06 +0400 |
commit | a5e9cb87083a7ed86bbca79f4203eefb920ffe1f (patch) | |
tree | 2c2de88de3152746bd0ffaea698446ff1cede244 | |
parent | 328f3d7402f31cf0a9510f05986a54d742a68517 (diff) | |
parent | 4605d8f26cc496a4fa1e4a37ceffbcb772c177f6 (diff) | |
download | mariadb-git-a5e9cb87083a7ed86bbca79f4203eefb920ffe1f.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-5.1
into bodhi.(none):/opt/local/work/mysql-5.1-runtime
client/mysqlbinlog.cc:
Auto merged
include/config-win.h:
Auto merged
include/my_global.h:
Auto merged
include/my_pthread.h:
Auto merged
mysql-test/lib/mtr_report.pl:
Auto merged
mysql-test/t/disabled.def:
Auto merged
sql/event_data_objects.cc:
Auto merged
sql/event_queue.cc:
Auto merged
sql/field.h:
Auto merged
sql/filesort.cc:
Auto merged
sql/handler.cc:
Auto merged
sql/handler.h:
Auto merged
sql/item_func.h:
Auto merged
sql/item_xmlfunc.cc:
Auto merged
sql/log_event.cc:
Auto merged
sql/log_event.h:
Auto merged
sql/mysql_priv.h:
Auto merged
sql/mysqld.cc:
Auto merged
sql/set_var.cc:
Auto merged
sql/sp.h:
Auto merged
sql/sp_head.cc:
Auto merged
sql/sp_head.h:
Auto merged
sql/sql_acl.cc:
Auto merged
sql/sql_base.cc:
Auto merged
sql/sql_class.cc:
Auto merged
sql/sql_class.h:
Auto merged
sql/sql_db.cc:
Auto merged
sql/sql_insert.cc:
Auto merged
sql/sql_lex.cc:
Auto merged
sql/sql_lex.h:
Auto merged
sql/sql_list.h:
Auto merged
sql/sql_load.cc:
Auto merged
sql/sql_parse.cc:
Auto merged
sql/sql_partition.cc:
Auto merged
sql/sql_prepare.cc:
Auto merged
sql/sql_select.cc:
Auto merged
sql/sql_show.cc:
Auto merged
sql/sql_test.cc:
Auto merged
sql/sql_update.cc:
Auto merged
sql/sql_view.cc:
Auto merged
sql/sql_yacc.yy:
Auto merged
storage/heap/hp_hash.c:
Auto merged
tests/mysql_client_test.c:
Auto merged
sql/item_func.cc:
Manual merge.
sql/sp.cc:
Manual merge.
sql/sql_cache.cc:
Manual merge.
sql/sql_table.cc:
Manual merge.
strings/my_vsnprintf.c:
Manual merge.
482 files changed, 8807 insertions, 8444 deletions
diff --git a/.bzrignore b/.bzrignore index 12555768e30..f583ab382d9 100644 --- a/.bzrignore +++ b/.bzrignore @@ -489,6 +489,8 @@ dbug/main.r dbug/output*.r dbug/user.ps dbug/user.t +debian/control +debian/defs.mk depcomp emacs.h examples/*.ds? @@ -1071,6 +1073,7 @@ libmysqld/ha_myisam.cc libmysqld/ha_myisammrg.cc libmysqld/ha_ndbcluster.cc libmysqld/ha_ndbcluster_binlog.cc +libmysqld/ha_ndbcluster_cond.cc libmysqld/ha_partition.cc libmysqld/ha_tina.cc libmysqld/handler.cc @@ -2989,4 +2992,3 @@ win/vs71cache.txt win/vs8cache.txt zlib/*.ds? zlib/*.vcproj -libmysqld/ha_ndbcluster_cond.cc diff --git a/client/completion_hash.cc b/client/completion_hash.cc index 4c777f8a704..cd0ea17dfaf 100644 --- a/client/completion_hash.cc +++ b/client/completion_hash.cc @@ -213,7 +213,7 @@ void completion_hash_clean(HashTable *ht) void completion_hash_free(HashTable *ht) { completion_hash_clean(ht); - my_free((gptr) ht->arBuckets,MYF(0)); + my_free(ht->arBuckets, MYF(0)); } diff --git a/client/my_readline.h b/client/my_readline.h index 47be7fa9294..3ebe24b75b8 100644 --- a/client/my_readline.h +++ b/client/my_readline.h @@ -28,6 +28,6 @@ typedef struct st_line_buffer } LINE_BUFFER; extern LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file); -extern LINE_BUFFER *batch_readline_command(LINE_BUFFER *buffer, my_string str); +extern LINE_BUFFER *batch_readline_command(LINE_BUFFER *buffer, char * str); extern char *batch_readline(LINE_BUFFER *buffer); extern void batch_readline_end(LINE_BUFFER *buffer); diff --git a/client/mysql.cc b/client/mysql.cc index 31cb78de1fd..7970fa4db2f 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -51,7 +51,7 @@ const char *VER= "14.13"; /* Buffer to hold 'version' and 'version_comment' */ #define MAX_SERVER_VERSION_LENGTH 128 -gptr sql_alloc(unsigned size); // Don't use mysqld alloc for these +void* sql_alloc(unsigned size); // Don't use mysqld alloc for these void sql_element_free(void *ptr); #include "sql_string.h" @@ -142,7 +142,7 @@ static my_bool info_flag=0,ignore_errors=0,wait_flag=0,quick=0, static my_bool column_types_flag; static ulong opt_max_allowed_packet, opt_net_buffer_length; static uint verbose=0,opt_silent=0,opt_mysql_port=0, opt_local_infile=0; -static my_string opt_mysql_unix_port=0; +static char * opt_mysql_unix_port=0; static int connect_flag=CLIENT_INTERACTIVE; static char *current_host,*current_db,*current_user=0,*opt_password=0, *current_prompt=0, *delimiter_str= 0, @@ -587,7 +587,7 @@ static struct my_option my_long_options[] = #endif {"auto-rehash", OPT_AUTO_REHASH, "Enable automatic rehashing. One doesn't need to use 'rehash' to get table and field completion, but startup and reconnecting may take a longer time. Disable with --disable-auto-rehash.", - (gptr*) &opt_rehash, (gptr*) &opt_rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, + (uchar**) &opt_rehash, (uchar**) &opt_rehash, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"no-auto-rehash", 'A', "No automatic rehashing. One has to use 'rehash' to get table and field completion. This gives a quicker start of mysql and disables rehashing on reconnect. WARNING: options deprecated; use --disable-auto-rehash instead.", @@ -595,42 +595,42 @@ static struct my_option my_long_options[] = {"batch", 'B', "Don't use history file. Disable interactive behavior. (Enables --silent)", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are.", (gptr*) &charsets_dir, - (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Directory where character sets are.", (uchar**) &charsets_dir, + (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"column-type-info", OPT_COLUMN_TYPES, "Display column type information.", - (gptr*) &column_types_flag, (gptr*) &column_types_flag, + (uchar**) &column_types_flag, (uchar**) &column_types_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"compress", 'C', "Use compression in server/client protocol.", - (gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, + (uchar**) &opt_compress, (uchar**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef DBUG_OFF {"debug", '#', "This is a non-debug version. Catch this and exit", 0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, #else - {"debug", '#', "Output debug log", (gptr*) &default_dbug_option, - (gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"debug", '#', "Output debug log", (uchar**) &default_dbug_option, + (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"debug-info", 'T', "Print some debug info at exit.", (gptr*) &info_flag, - (gptr*) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"database", 'D', "Database to use.", (gptr*) ¤t_db, - (gptr*) ¤t_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-info", 'T', "Print some debug info at exit.", (uchar**) &info_flag, + (uchar**) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"database", 'D', "Database to use.", (uchar**) ¤t_db, + (uchar**) ¤t_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, - "Set the default character set.", (gptr*) &default_charset, - (gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"delimiter", OPT_DELIMITER, "Delimiter to be used.", (gptr*) &delimiter_str, - (gptr*) &delimiter_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Set the default character set.", (uchar**) &default_charset, + (uchar**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"delimiter", OPT_DELIMITER, "Delimiter to be used.", (uchar**) &delimiter_str, + (uchar**) &delimiter_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"execute", 'e', "Execute command and quit. (Disables --force and history file)", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"vertical", 'E', "Print the output of a query (rows) vertically.", - (gptr*) &vertical, (gptr*) &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, + (uchar**) &vertical, (uchar**) &vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', "Continue even if we get an sql error.", - (gptr*) &ignore_errors, (gptr*) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0, + (uchar**) &ignore_errors, (uchar**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"named-commands", 'G', "Enable named commands. Named commands mean this program's internal commands; see mysql> help . When enabled, the named commands can be used from any line of the query, otherwise only from the first line, before an enter. Disable with --disable-named-commands. This option is disabled by default.", - (gptr*) &named_cmds, (gptr*) &named_cmds, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + (uchar**) &named_cmds, (uchar**) &named_cmds, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"no-named-commands", 'g', "Named commands are disabled. Use \\* form only, or use named commands only in the beginning of a line ending with a semicolon (;) Since version 10.9 the client now starts with this option ENABLED by default! Disable with '-G'. Long format commands still work from the first line. WARNING: option deprecated; use --disable-named-commands instead.", @@ -638,25 +638,25 @@ static struct my_option my_long_options[] = {"ignore-spaces", 'i', "Ignore space after function names.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"local-infile", OPT_LOCAL_INFILE, "Enable/disable LOAD DATA LOCAL INFILE.", - (gptr*) &opt_local_infile, - (gptr*) &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"no-beep", 'b', "Turn off beep on error.", (gptr*) &opt_nobeep, - (gptr*) &opt_nobeep, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"host", 'h', "Connect to host.", (gptr*) ¤t_host, - (gptr*) ¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"html", 'H', "Produce HTML output.", (gptr*) &opt_html, (gptr*) &opt_html, + (uchar**) &opt_local_infile, + (uchar**) &opt_local_infile, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"no-beep", 'b', "Turn off beep on error.", (uchar**) &opt_nobeep, + (uchar**) &opt_nobeep, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"host", 'h', "Connect to host.", (uchar**) ¤t_host, + (uchar**) ¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"html", 'H', "Produce HTML output.", (uchar**) &opt_html, (uchar**) &opt_html, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"xml", 'X', "Produce XML output", (gptr*) &opt_xml, (gptr*) &opt_xml, 0, + {"xml", 'X', "Produce XML output", (uchar**) &opt_xml, (uchar**) &opt_xml, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"line-numbers", OPT_LINE_NUMBERS, "Write line numbers for errors.", - (gptr*) &line_numbers, (gptr*) &line_numbers, 0, GET_BOOL, + (uchar**) &line_numbers, (uchar**) &line_numbers, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"skip-line-numbers", 'L', "Don't write line number for errors. WARNING: -L is deprecated, use long version of this option instead.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"unbuffered", 'n', "Flush buffer after each query.", (gptr*) &unbuffered, - (gptr*) &unbuffered, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"unbuffered", 'n', "Flush buffer after each query.", (uchar**) &unbuffered, + (uchar**) &unbuffered, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"column-names", OPT_COLUMN_NAMES, "Write column names in results.", - (gptr*) &column_names, (gptr*) &column_names, 0, GET_BOOL, + (uchar**) &column_names, (uchar**) &column_names, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"skip-column-names", 'N', "Don't write column names in results. WARNING: -N is deprecated, use long version of this options instead.", @@ -665,7 +665,7 @@ static struct my_option my_long_options[] = "Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"sigint-ignore", OPT_SIGINT_IGNORE, "Ignore SIGINT (CTRL-C)", - (gptr*) &opt_sigint_ignore, (gptr*) &opt_sigint_ignore, 0, GET_BOOL, + (uchar**) &opt_sigint_ignore, (uchar**) &opt_sigint_ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"one-database", 'o', "Only update the default database. This is useful for skipping updates to other database in the update log.", @@ -685,49 +685,49 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, - (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, + {"port", 'P', "Port number to use for connection.", (uchar**) &opt_mysql_port, + (uchar**) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"prompt", OPT_PROMPT, "Set the mysql prompt to this value.", - (gptr*) ¤t_prompt, (gptr*) ¤t_prompt, 0, GET_STR_ALLOC, + (uchar**) ¤t_prompt, (uchar**) ¤t_prompt, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"quick", 'q', "Don't cache result, print it row by row. This may slow down the server if the output is suspended. Doesn't use history file.", - (gptr*) &quick, (gptr*) &quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + (uchar**) &quick, (uchar**) &quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"raw", 'r', "Write fields without conversion. Used with --batch.", - (gptr*) &opt_raw_data, (gptr*) &opt_raw_data, 0, GET_BOOL, NO_ARG, 0, 0, 0, + (uchar**) &opt_raw_data, (uchar**) &opt_raw_data, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"reconnect", OPT_RECONNECT, "Reconnect if the connection is lost. Disable with --disable-reconnect. This option is enabled by default.", - (gptr*) &opt_reconnect, (gptr*) &opt_reconnect, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, + (uchar**) &opt_reconnect, (uchar**) &opt_reconnect, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"silent", 's', "Be more silent. Print results with a tab as separator, each row on new line.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, - "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, + "Base name of shared memory.", (uchar**) &shared_memory_base_name, (uchar**) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif {"socket", 'S', "Socket file to use for connection.", - (gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR_ALLOC, + (uchar**) &opt_mysql_unix_port, (uchar**) &opt_mysql_unix_port, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include "sslopt-longopts.h" - {"table", 't', "Output in table format.", (gptr*) &output_tables, - (gptr*) &output_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"table", 't', "Output in table format.", (uchar**) &output_tables, + (uchar**) &output_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"tee", OPT_TEE, "Append everything into outfile. See interactive help (\\h) also. Does not work in batch mode. Disable with --disable-tee. This option is disabled by default.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"no-tee", OPT_NOTEE, "Disable outfile. See interactive help (\\h) also. WARNING: option deprecated; use --disable-tee instead", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifndef DONT_ALLOW_USER_CHANGE - {"user", 'u', "User for login if not current user.", (gptr*) ¤t_user, - (gptr*) ¤t_user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"user", 'u', "User for login if not current user.", (uchar**) ¤t_user, + (uchar**) ¤t_user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif {"safe-updates", 'U', "Only allow UPDATE and DELETE that uses keys.", - (gptr*) &safe_updates, (gptr*) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0, + (uchar**) &safe_updates, (uchar**) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"i-am-a-dummy", 'U', "Synonym for option --safe-updates, -U.", - (gptr*) &safe_updates, (gptr*) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0, + (uchar**) &safe_updates, (uchar**) &safe_updates, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"verbose", 'v', "Write more. (-v -v -v gives the table output format).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -737,32 +737,32 @@ static struct my_option my_long_options[] = NO_ARG, 0, 0, 0, 0, 0, 0}, {"connect_timeout", OPT_CONNECT_TIMEOUT, "Number of seconds before connection timeout.", - (gptr*) &opt_connect_timeout, - (gptr*) &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 3600*12, 0, + (uchar**) &opt_connect_timeout, + (uchar**) &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 3600*12, 0, 0, 0}, {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, "Max packet length to send to, or receive from server", - (gptr*) &opt_max_allowed_packet, (gptr*) &opt_max_allowed_packet, 0, GET_ULONG, + (uchar**) &opt_max_allowed_packet, (uchar**) &opt_max_allowed_packet, 0, GET_ULONG, REQUIRED_ARG, 16 *1024L*1024L, 4096, (longlong) 2*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0}, {"net_buffer_length", OPT_NET_BUFFER_LENGTH, "Buffer for TCP/IP and socket communication", - (gptr*) &opt_net_buffer_length, (gptr*) &opt_net_buffer_length, 0, GET_ULONG, + (uchar**) &opt_net_buffer_length, (uchar**) &opt_net_buffer_length, 0, GET_ULONG, REQUIRED_ARG, 16384, 1024, 512*1024*1024L, MALLOC_OVERHEAD, 1024, 0}, {"select_limit", OPT_SELECT_LIMIT, "Automatic limit for SELECT when using --safe-updates", - (gptr*) &select_limit, - (gptr*) &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ~0L, 0, 1, 0}, + (uchar**) &select_limit, + (uchar**) &select_limit, 0, GET_ULONG, REQUIRED_ARG, 1000L, 1, ~0L, 0, 1, 0}, {"max_join_size", OPT_MAX_JOIN_SIZE, "Automatic limit for rows in a join when using --safe-updates", - (gptr*) &max_join_size, - (gptr*) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ~0L, 0, 1, + (uchar**) &max_join_size, + (uchar**) &max_join_size, 0, GET_ULONG, REQUIRED_ARG, 1000000L, 1, ~0L, 0, 1, 0}, {"secure-auth", OPT_SECURE_AUTH, "Refuse client connecting to server if it" - " uses old (pre-4.1.1) protocol", (gptr*) &opt_secure_auth, - (gptr*) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + " uses old (pre-4.1.1) protocol", (uchar**) &opt_secure_auth, + (uchar**) &opt_secure_auth, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"show-warnings", OPT_SHOW_WARNINGS, "Show warnings after every statement.", - (gptr*) &show_warnings, (gptr*) &show_warnings, 0, GET_BOOL, NO_ARG, + (uchar**) &show_warnings, (uchar**) &show_warnings, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -1079,7 +1079,7 @@ static int read_and_execute(bool interactive) tmpbuf.alloc(65535); tmpbuf.length(0); buffer.length(0); - unsigned long clen; + size_t clen; do { line= my_cgets((char*)tmpbuf.ptr(), tmpbuf.alloced_length()-1, &clen); @@ -2443,7 +2443,7 @@ print_table_data(MYSQL_RES *result) (void) tee_fputs("\n", PAGER); } tee_puts((char*) separator.ptr(), PAGER); - my_afree((gptr) num_flag); + my_afree((uchar*) num_flag); } @@ -2842,10 +2842,10 @@ com_edit(String *buffer,char *line __attribute__((unused))) MYF(MY_WME))) < 0) goto err; if (buffer->is_empty() && !old_buffer.is_empty()) - (void) my_write(fd,(byte*) old_buffer.ptr(),old_buffer.length(), + (void) my_write(fd,(uchar*) old_buffer.ptr(),old_buffer.length(), MYF(MY_WME)); else - (void) my_write(fd,(byte*) buffer->ptr(),buffer->length(),MYF(MY_WME)); + (void) my_write(fd,(uchar*) buffer->ptr(),buffer->length(),MYF(MY_WME)); (void) my_close(fd,MYF(0)); if (!(editor = (char *)getenv("EDITOR")) && @@ -3893,13 +3893,13 @@ static int com_prompt(String *buffer, char *line) #ifndef EMBEDDED_LIBRARY /* Keep sql_string library happy */ -gptr sql_alloc(unsigned int Size) +void *sql_alloc(size_t Size) { return my_malloc(Size,MYF(MY_WME)); } void sql_element_free(void *ptr) { - my_free((gptr) ptr,MYF(0)); + my_free(ptr,MYF(0)); } #endif /* EMBEDDED_LIBRARY */ diff --git a/client/mysql_upgrade.c b/client/mysql_upgrade.c index 64de3d19882..504b4c95a8b 100644 --- a/client/mysql_upgrade.c +++ b/client/mysql_upgrade.c @@ -63,8 +63,8 @@ static struct my_option my_long_options[]= {"debug", '#', "This is a non-debug version. Catch this and exit", 0, 0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, #else - {"debug", '#', "Output debug log", (gptr *) & default_dbug_option, - (gptr *) & default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"debug", '#', "Output debug log", (uchar* *) & default_dbug_option, + (uchar* *) & default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif {"default-character-set", OPT_DEFAULT_CHARSET, "Set the default character set.", 0, @@ -73,16 +73,16 @@ static struct my_option my_long_options[]= "Directory where character sets are.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"compress", OPT_COMPRESS, "Use compression in server/client protocol.", - (gptr*)¬_used, (gptr*)¬_used, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + (uchar**)¬_used, (uchar**)¬_used, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', "Force execution of mysqlcheck even if mysql_upgrade " "has already been executed for the current version of MySQL.", - (gptr*)&opt_force, (gptr*)&opt_force, 0, + (uchar**)&opt_force, (uchar**)&opt_force, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"host",'h', "Connect to host.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server. If password is not given" - " it's solicited on the tty.", (gptr*) &opt_password,(gptr*) &opt_password, + " it's solicited on the tty.", (uchar**) &opt_password,(uchar**) &opt_password, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __WIN__ {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, @@ -100,11 +100,11 @@ static struct my_option my_long_options[]= #endif {"socket", 'S', "Socket file to use for connection.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"user", 'u', "User for login if not current user.", (gptr*) &opt_user, - (gptr*) &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"user", 'u', "User for login if not current user.", (uchar**) &opt_user, + (uchar**) &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include <sslopt-longopts.h> {"verbose", 'v', "Display more output about the process", - (gptr*) &opt_verbose, (gptr*) &opt_verbose, 0, + (uchar**) &opt_verbose, (uchar**) &opt_verbose, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -387,13 +387,14 @@ static void find_tool(char *tool_path, const char *tool_name) } do { + size_t path_len; DBUG_PRINT("enter", ("path: %s", path)); /* Chop off last char(since it might be a /) */ path[max((strlen(path)-1), 0)]= 0; /* Chop off last dir part */ - dirname_part(path, path); + dirname_part(path, path, &path_len); /* Format name of the tool to search for */ fn_format(tool_path, tool_name, diff --git a/client/mysqladmin.cc b/client/mysqladmin.cc index 03b37f2ba3a..f6ff44c7d56 100644 --- a/client/mysqladmin.cc +++ b/client/mysqladmin.cc @@ -44,7 +44,7 @@ static my_bool option_force=0,interrupted=0,new_line=0, static uint tcp_port = 0, option_wait = 0, option_silent=0, nr_iterations, opt_count_iterations= 0; static ulong opt_connect_timeout, opt_shutdown_timeout; -static my_string unix_port=0; +static char * unix_port=0; #ifdef LATER_HAVE_NDBCLUSTER_DB static my_bool opt_ndbcluster=0; static char *opt_ndb_connectstring=0; @@ -132,31 +132,31 @@ static struct my_option my_long_options[] = #endif {"count", 'c', "Number of iterations to make. This works with -i (--sleep) only.", - (gptr*) &nr_iterations, (gptr*) &nr_iterations, 0, GET_UINT, + (uchar**) &nr_iterations, (uchar**) &nr_iterations, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (gptr*) &info_flag, - (gptr*) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (uchar**) &info_flag, + (uchar**) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', "Don't ask for confirmation on drop database; with multiple commands, continue even if an error occurs.", - (gptr*) &option_force, (gptr*) &option_force, 0, GET_BOOL, NO_ARG, 0, 0, + (uchar**) &option_force, (uchar**) &option_force, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"compress", 'C', "Use compression in server/client protocol.", - (gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, + (uchar**) &opt_compress, (uchar**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are.", (gptr*) &charsets_dir, - (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Directory where character sets are.", (uchar**) &charsets_dir, + (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, - "Set the default character set.", (gptr*) &default_charset, - (gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Set the default character set.", (uchar**) &default_charset, + (uchar**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"host", 'h', "Connect to host.", (gptr*) &host, (gptr*) &host, 0, GET_STR, + {"host", 'h', "Connect to host.", (uchar**) &host, (uchar**) &host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"no-beep", 'b', "Turn off beep on error.", (gptr*) &opt_nobeep, - (gptr*) &opt_nobeep, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"no-beep", 'b', "Turn off beep on error.", (uchar**) &opt_nobeep, + (uchar**) &opt_nobeep, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server. If password is not given it's asked from the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, @@ -164,58 +164,58 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"port", 'P', "Port number to use for connection.", (gptr*) &tcp_port, - (gptr*) &tcp_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"port", 'P', "Port number to use for connection.", (uchar**) &tcp_port, + (uchar**) &tcp_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"relative", 'r', "Show difference between current and previous values when used with -i. Currently works only with extended-status.", - (gptr*) &opt_relative, (gptr*) &opt_relative, 0, GET_BOOL, NO_ARG, 0, 0, 0, + (uchar**) &opt_relative, (uchar**) &opt_relative, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"set-variable", 'O', "Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, - "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, + "Base name of shared memory.", (uchar**) &shared_memory_base_name, (uchar**) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif {"silent", 's', "Silently exit if one can't connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"socket", 'S', "Socket file to use for connection.", - (gptr*) &unix_port, (gptr*) &unix_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, + (uchar**) &unix_port, (uchar**) &unix_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"sleep", 'i', "Execute commands again and again with a sleep between.", - (gptr*) &interval, (gptr*) &interval, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, + (uchar**) &interval, (uchar**) &interval, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include <sslopt-longopts.h> #ifndef DONT_ALLOW_USER_CHANGE - {"user", 'u', "User for login if not current user.", (gptr*) &user, - (gptr*) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"user", 'u', "User for login if not current user.", (uchar**) &user, + (uchar**) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"verbose", 'v', "Write more information.", (gptr*) &opt_verbose, - (gptr*) &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"verbose", 'v', "Write more information.", (uchar**) &opt_verbose, + (uchar**) &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"vertical", 'E', "Print output vertically. Is similar to --relative, but prints output vertically.", - (gptr*) &opt_vertical, (gptr*) &opt_vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, + (uchar**) &opt_vertical, (uchar**) &opt_vertical, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"wait", 'w', "Wait and retry if connection is down.", 0, 0, 0, GET_UINT, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"connect_timeout", OPT_CONNECT_TIMEOUT, "", (gptr*) &opt_connect_timeout, - (gptr*) &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 3600*12, 0, + {"connect_timeout", OPT_CONNECT_TIMEOUT, "", (uchar**) &opt_connect_timeout, + (uchar**) &opt_connect_timeout, 0, GET_ULONG, REQUIRED_ARG, 3600*12, 0, 3600*12, 0, 1, 0}, - {"shutdown_timeout", OPT_SHUTDOWN_TIMEOUT, "", (gptr*) &opt_shutdown_timeout, - (gptr*) &opt_shutdown_timeout, 0, GET_ULONG, REQUIRED_ARG, + {"shutdown_timeout", OPT_SHUTDOWN_TIMEOUT, "", (uchar**) &opt_shutdown_timeout, + (uchar**) &opt_shutdown_timeout, 0, GET_ULONG, REQUIRED_ARG, SHUTDOWN_DEF_TIMEOUT, 0, 3600*12, 0, 1, 0}, #ifdef LATER_HAVE_NDBCLUSTER_DB {"ndbcluster", OPT_NDBCLUSTER, "" - "", (gptr*) &opt_ndbcluster, - (gptr*) &opt_ndbcluster, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + "", (uchar**) &opt_ndbcluster, + (uchar**) &opt_ndbcluster, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"ndb-connectstring", OPT_NDB_CONNECTSTRING, "" - "", (gptr*) &opt_ndb_connectstring, - (gptr*) &opt_ndb_connectstring, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "", (uchar**) &opt_ndb_connectstring, + (uchar**) &opt_ndb_connectstring, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/client/mysqlbinlog.cc b/client/mysqlbinlog.cc index 179d0e9fd9e..edade347783 100644 --- a/client/mysqlbinlog.cc +++ b/client/mysqlbinlog.cc @@ -296,7 +296,7 @@ File Load_log_processor::prepare_new_file_for_old_format(Load_log_event *le, int Load_log_processor::load_old_format_file(NET* net, const char*server_fname, uint server_fname_len, File file) { - char buf[FN_REFLEN+1]; + uchar buf[FN_REFLEN+1]; buf[0] = 0; memcpy(buf + 1, server_fname, server_fname_len + 1); if (my_net_write(net, buf, server_fname_len +2) || net_flush(net)) @@ -310,7 +310,7 @@ int Load_log_processor::load_old_format_file(NET* net, const char*server_fname, ulong packet_len = my_net_read(net); if (packet_len == 0) { - if (my_net_write(net, "", 0) || net_flush(net)) + if (my_net_write(net, (uchar*) "", 0) || net_flush(net)) { sql_print_error("Failed sending the ack packet"); return -1; @@ -334,7 +334,7 @@ int Load_log_processor::load_old_format_file(NET* net, const char*server_fname, sql_print_error("Illegal length of packet read from net"); return -1; } - if (my_write(file, (byte*) net->read_pos, + if (my_write(file, (uchar*) net->read_pos, (uint) packet_len, MYF(MY_WME|MY_NABP))) return -1; } @@ -379,7 +379,7 @@ int Load_log_processor::process_first_event(const char *bname, uint blen, File_name_record rec; DBUG_ENTER("Load_log_processor::process_first_event"); - if (!(fname= my_malloc(full_len,MYF(MY_WME)))) + if (!(fname= (char*) my_malloc(full_len,MYF(MY_WME)))) DBUG_RETURN(-1); memcpy(fname, target_dir_name, target_dir_name_len); @@ -398,7 +398,7 @@ int Load_log_processor::process_first_event(const char *bname, uint blen, rec.fname= fname; rec.event= ce; - if (set_dynamic(&file_names, (gptr)&rec, file_id)) + if (set_dynamic(&file_names, (uchar*)&rec, file_id)) { sql_print_error("Could not construct local filename %s%s", target_dir_name, bname); @@ -408,7 +408,7 @@ int Load_log_processor::process_first_event(const char *bname, uint blen, if (ce) ce->set_fname_outside_temp_buf(fname, strlen(fname)); - if (my_write(file, (byte*)block, block_len, MYF(MY_WME|MY_NABP))) + if (my_write(file, (uchar*)block, block_len, MYF(MY_WME|MY_NABP))) error= -1; if (my_close(file, MYF(MY_WME))) error= -1; @@ -447,7 +447,7 @@ int Load_log_processor::process(Append_block_log_event *ae) if (((file= my_open(fname, O_APPEND|O_BINARY|O_WRONLY,MYF(MY_WME))) < 0)) DBUG_RETURN(-1); - if (my_write(file,(byte*)ae->block,ae->block_len,MYF(MY_WME|MY_NABP))) + if (my_write(file,(uchar*)ae->block,ae->block_len,MYF(MY_WME|MY_NABP))) error= -1; if (my_close(file,MYF(MY_WME))) error= -1; @@ -709,7 +709,7 @@ static struct my_option my_long_options[] = "Print all binlog entries using base64 encoding. " "This is for debugging only. Logs produced using this option " "should not be applied on production systems.", - (gptr*) &opt_base64_output, (gptr*) &opt_base64_output, 0, GET_BOOL, + (uchar**) &opt_base64_output, (uchar**) &opt_base64_output, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, /* mysqlbinlog needs charsets knowledge, to be able to convert a charset @@ -718,47 +718,47 @@ static struct my_option my_long_options[] = SET @`a`:=_cp850 0x4DFC6C6C6572 COLLATE `cp850_general_ci`; */ {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are.", (gptr*) &charsets_dir, - (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Directory where character sets are.", (uchar**) &charsets_dir, + (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"database", 'd', "List entries for just this database (local log only).", - (gptr*) &database, (gptr*) &database, 0, GET_STR_ALLOC, REQUIRED_ARG, + (uchar**) &database, (uchar**) &database, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifndef DBUG_OFF - {"debug", '#', "Output debug log.", (gptr*) &default_dbug_option, - (gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"debug", '#', "Output debug log.", (uchar**) &default_dbug_option, + (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (gptr*) &info_flag, - (gptr*) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (uchar**) &info_flag, + (uchar**) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"disable-log-bin", 'D', "Disable binary log. This is useful, if you " "enabled --to-last-log and are sending the output to the same MySQL server. " "This way you could avoid an endless loop. You would also like to use it " "when restoring after a crash to avoid duplication of the statements you " "already have. NOTE: you will need a SUPER privilege to use this option.", - (gptr*) &disable_log_bin, (gptr*) &disable_log_bin, 0, GET_BOOL, + (uchar**) &disable_log_bin, (uchar**) &disable_log_bin, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"force-if-open", 'F', "Force if binlog was not closed properly.", - (gptr*) &force_if_open_opt, (gptr*) &force_if_open_opt, 0, GET_BOOL, NO_ARG, + (uchar**) &force_if_open_opt, (uchar**) &force_if_open_opt, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"force-read", 'f', "Force reading unknown binlog events.", - (gptr*) &force_opt, (gptr*) &force_opt, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + (uchar**) &force_opt, (uchar**) &force_opt, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"hexdump", 'H', "Augment output with hexadecimal and ASCII event dump.", - (gptr*) &opt_hexdump, (gptr*) &opt_hexdump, 0, GET_BOOL, NO_ARG, + (uchar**) &opt_hexdump, (uchar**) &opt_hexdump, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"host", 'h', "Get the binlog from server.", (gptr*) &host, (gptr*) &host, + {"host", 'h', "Get the binlog from server.", (uchar**) &host, (uchar**) &host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"local-load", 'l', "Prepare local temporary files for LOAD DATA INFILE in the specified directory.", - (gptr*) &dirname_for_local_load, (gptr*) &dirname_for_local_load, 0, + (uchar**) &dirname_for_local_load, (uchar**) &dirname_for_local_load, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"offset", 'o', "Skip the first N entries.", (gptr*) &offset, (gptr*) &offset, + {"offset", 'o', "Skip the first N entries.", (uchar**) &offset, (uchar**) &offset, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', "Password to connect to remote server.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"port", 'P', "Use port to connect to the remote server.", - (gptr*) &port, (gptr*) &port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, + (uchar**) &port, (uchar**) &port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"position", 'j', "Deprecated. Use --start-position instead.", - (gptr*) &start_position, (gptr*) &start_position, 0, GET_ULL, + (uchar**) &start_position, (uchar**) &start_position, 0, GET_ULL, REQUIRED_ARG, BIN_LOG_HEADER_SIZE, BIN_LOG_HEADER_SIZE, /* COM_BINLOG_DUMP accepts only 4 bytes for the position */ (ulonglong)(~(uint32)0), 0, 0, 0}, @@ -766,22 +766,22 @@ static struct my_option my_long_options[] = "The protocol of connection (tcp,socket,pipe,memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"read-from-remote-server", 'R', "Read binary logs from a MySQL server", - (gptr*) &remote_opt, (gptr*) &remote_opt, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + (uchar**) &remote_opt, (uchar**) &remote_opt, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"result-file", 'r', "Direct output to a given file.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"server-id", OPT_SERVER_ID, "Extract only binlog entries created by the server having the given id.", - (gptr*) &server_id, (gptr*) &server_id, 0, GET_ULONG, + (uchar**) &server_id, (uchar**) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"set-charset", OPT_SET_CHARSET, - "Add 'SET NAMES character_set' to the output.", (gptr*) &charset, - (gptr*) &charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Add 'SET NAMES character_set' to the output.", (uchar**) &charset, + (uchar**) &charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"short-form", 's', "Just show the queries, no extra info.", - (gptr*) &short_form, (gptr*) &short_form, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + (uchar**) &short_form, (uchar**) &short_form, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"socket", 'S', "Socket file to use for connection.", - (gptr*) &sock, (gptr*) &sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, + (uchar**) &sock, (uchar**) &sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"start-datetime", OPT_START_DATETIME, "Start reading the binlog at first event having a datetime equal or " @@ -789,12 +789,12 @@ static struct my_option my_long_options[] = "in the local time zone, in any format accepted by the MySQL server " "for DATETIME and TIMESTAMP types, for example: 2004-12-25 11:25:56 " "(you should probably use quotes for your shell to set it properly).", - (gptr*) &start_datetime_str, (gptr*) &start_datetime_str, + (uchar**) &start_datetime_str, (uchar**) &start_datetime_str, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"start-position", OPT_START_POSITION, "Start reading the binlog at position N. Applies to the first binlog " "passed on the command line.", - (gptr*) &start_position, (gptr*) &start_position, 0, GET_ULL, + (uchar**) &start_position, (uchar**) &start_position, 0, GET_ULL, REQUIRED_ARG, BIN_LOG_HEADER_SIZE, BIN_LOG_HEADER_SIZE, /* COM_BINLOG_DUMP accepts only 4 bytes for the position */ (ulonglong)(~(uint32)0), 0, 0, 0}, @@ -804,28 +804,28 @@ static struct my_option my_long_options[] = "in the local time zone, in any format accepted by the MySQL server " "for DATETIME and TIMESTAMP types, for example: 2004-12-25 11:25:56 " "(you should probably use quotes for your shell to set it properly).", - (gptr*) &stop_datetime_str, (gptr*) &stop_datetime_str, + (uchar**) &stop_datetime_str, (uchar**) &stop_datetime_str, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"stop-position", OPT_STOP_POSITION, "Stop reading the binlog at position N. Applies to the last binlog " "passed on the command line.", - (gptr*) &stop_position, (gptr*) &stop_position, 0, GET_ULL, + (uchar**) &stop_position, (uchar**) &stop_position, 0, GET_ULL, REQUIRED_ARG, (ulonglong)(~(my_off_t)0), BIN_LOG_HEADER_SIZE, (ulonglong)(~(my_off_t)0), 0, 0, 0}, {"to-last-log", 't', "Requires -R. Will not stop at the end of the \ requested binlog but rather continue printing until the end of the last \ binlog of the MySQL server. If you send the output to the same MySQL server, \ that may lead to an endless loop.", - (gptr*) &to_last_remote_log, (gptr*) &to_last_remote_log, 0, GET_BOOL, + (uchar**) &to_last_remote_log, (uchar**) &to_last_remote_log, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"user", 'u', "Connect to the remote server as username.", - (gptr*) &user, (gptr*) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, + (uchar**) &user, (uchar**) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Print version and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"open_files_limit", OPT_OPEN_FILES_LIMIT, "Used to reserve file descriptors for usage by this program", - (gptr*) &open_files_limit, (gptr*) &open_files_limit, 0, GET_ULONG, + (uchar**) &open_files_limit, (uchar**) &open_files_limit, 0, GET_ULONG, REQUIRED_ARG, MY_NFILE, 8, OS_FILE_LIMIT, 0, 1, 0}, {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -1103,7 +1103,7 @@ static int dump_remote_log_entries(PRINT_EVENT_INFO *print_event_info, const char* logname) { - char buf[128]; + uchar buf[128]; ulong len; uint logname_len; NET* net; @@ -1139,7 +1139,7 @@ could be out of memory"); int4store(buf, (uint32)start_position); int2store(buf + BIN_LOG_HEADER_SIZE, binlog_flags); - size_s tlen = strlen(logname); + size_t tlen = strlen(logname); if (tlen > UINT_MAX) { fprintf(stderr,"Log name too long\n"); @@ -1293,8 +1293,8 @@ err: static void check_header(IO_CACHE* file, Format_description_log_event **description_event) { - byte header[BIN_LOG_HEADER_SIZE]; - byte buf[PROBE_HEADER_LEN]; + uchar header[BIN_LOG_HEADER_SIZE]; + uchar buf[PROBE_HEADER_LEN]; my_off_t tmp_pos, pos; *description_event= new Format_description_log_event(3); @@ -1394,7 +1394,7 @@ static int dump_local_log_entries(PRINT_EVENT_INFO *print_event_info, { File fd = -1; IO_CACHE cache,*file= &cache; - byte tmp_buff[BIN_LOG_HEADER_SIZE]; + uchar tmp_buff[BIN_LOG_HEADER_SIZE]; int error= 0; if (logname && logname[0] != '-') @@ -1433,7 +1433,7 @@ static int dump_local_log_entries(PRINT_EVENT_INFO *print_event_info, if (start_position) { /* skip 'start_position' characters from stdin */ - byte buff[IO_SIZE]; + uchar buff[IO_SIZE]; my_off_t length,tmp; for (length= start_position_mot ; length > 0 ; length-=tmp) { diff --git a/client/mysqlcheck.c b/client/mysqlcheck.c index 43a938badbe..372dfe860df 100644 --- a/client/mysqlcheck.c +++ b/client/mysqlcheck.c @@ -37,7 +37,7 @@ static my_bool opt_alldbs = 0, opt_check_only_changed = 0, opt_extended = 0, opt_fix_table_names= 0, opt_fix_db_names= 0, opt_upgrade= 0, opt_write_binlog= 1; static uint verbose = 0, opt_mysql_port=0; -static my_string opt_mysql_unix_port = 0; +static char * opt_mysql_unix_port = 0; static char *opt_password = 0, *current_user = 0, *default_charset = (char *)MYSQL_DEFAULT_CHARSET_NAME, *current_host = 0; @@ -55,13 +55,13 @@ static struct my_option my_long_options[] = { {"all-databases", 'A', "Check all the databases. This will be same as --databases with all databases selected.", - (gptr*) &opt_alldbs, (gptr*) &opt_alldbs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + (uchar**) &opt_alldbs, (uchar**) &opt_alldbs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"analyze", 'a', "Analyze given tables.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"all-in-1", '1', "Instead of issuing one query for each table, use one query per database, naming all tables in the database in a comma-separated list.", - (gptr*) &opt_all_in_1, (gptr*) &opt_all_in_1, 0, GET_BOOL, NO_ARG, 0, 0, 0, + (uchar**) &opt_all_in_1, (uchar**) &opt_all_in_1, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __NETWARE__ {"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", @@ -69,11 +69,11 @@ static struct my_option my_long_options[] = #endif {"auto-repair", OPT_AUTO_REPAIR, "If a checked table is corrupted, automatically fix it. Repairing will be done after all tables have been checked, if corrupted ones were found.", - (gptr*) &opt_auto_repair, (gptr*) &opt_auto_repair, 0, GET_BOOL, NO_ARG, 0, + (uchar**) &opt_auto_repair, (uchar**) &opt_auto_repair, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are.", (gptr*) &charsets_dir, - (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Directory where character sets are.", (uchar**) &charsets_dir, + (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"check", 'c', "Check table for errors.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"check-only-changed", 'C', @@ -83,11 +83,11 @@ static struct my_option my_long_options[] = "Check tables for version-dependent changes. May be used with --auto-repair to correct tables requiring version-dependent updates.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"compress", OPT_COMPRESS, "Use compression in server/client protocol.", - (gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, + (uchar**) &opt_compress, (uchar**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"databases", 'B', "To check several databases. Note the difference in usage; In this case no tables are given. All name arguments are regarded as databasenames.", - (gptr*) &opt_databases, (gptr*) &opt_databases, 0, GET_BOOL, NO_ARG, + (uchar**) &opt_databases, (uchar**) &opt_databases, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef DBUG_OFF {"debug", '#', "This is a non-debug version. Catch this and exit.", @@ -96,37 +96,37 @@ static struct my_option my_long_options[] = {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (gptr*) &info_flag, - (gptr*) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (uchar**) &info_flag, + (uchar**) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, - "Set the default character set.", (gptr*) &default_charset, - (gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Set the default character set.", (uchar**) &default_charset, + (uchar**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"fast",'F', "Check only tables that haven't been closed properly.", - (gptr*) &opt_fast, (gptr*) &opt_fast, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, + (uchar**) &opt_fast, (uchar**) &opt_fast, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"fix-db-names", OPT_FIX_DB_NAMES, "Fix database names.", - (gptr*) &opt_fix_db_names, (gptr*) &opt_fix_db_names, + (uchar**) &opt_fix_db_names, (uchar**) &opt_fix_db_names, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"fix-table-names", OPT_FIX_TABLE_NAMES, "Fix table names.", - (gptr*) &opt_fix_table_names, (gptr*) &opt_fix_table_names, + (uchar**) &opt_fix_table_names, (uchar**) &opt_fix_table_names, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', "Continue even if we get an sql-error.", - (gptr*) &ignore_errors, (gptr*) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0, + (uchar**) &ignore_errors, (uchar**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"extended", 'e', "If you are using this option with CHECK TABLE, it will ensure that the table is 100 percent consistent, but will take a long time. If you are using this option with REPAIR TABLE, it will force using old slow repair with keycache method, instead of much faster repair by sorting.", - (gptr*) &opt_extended, (gptr*) &opt_extended, 0, GET_BOOL, NO_ARG, 0, 0, 0, + (uchar**) &opt_extended, (uchar**) &opt_extended, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"host",'h', "Connect to host.", (gptr*) ¤t_host, - (gptr*) ¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"host",'h', "Connect to host.", (uchar**) ¤t_host, + (uchar**) ¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"medium-check", 'm', "Faster than extended-check, but only finds 99.99 percent of all errors. Should be good enough for most cases.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"write-binlog", OPT_WRITE_BINLOG, "Log ANALYZE, OPTIMIZE and REPAIR TABLE commands. Enabled by default; use --skip-write-binlog when commands should not be sent to replication slaves.", - (gptr*) &opt_write_binlog, (gptr*) &opt_write_binlog, 0, GET_BOOL, NO_ARG, + (uchar**) &opt_write_binlog, (uchar**) &opt_write_binlog, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"optimize", 'o', "Optimize table.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -137,38 +137,38 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, - (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, + {"port", 'P', "Port number to use for connection.", (uchar**) &opt_mysql_port, + (uchar**) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"quick", 'q', "If you are using this option with CHECK TABLE, it prevents the check from scanning the rows to check for wrong links. This is the fastest check. If you are using this option with REPAIR TABLE, it will try to repair only the index tree. This is the fastest repair method for a table.", - (gptr*) &opt_quick, (gptr*) &opt_quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, + (uchar**) &opt_quick, (uchar**) &opt_quick, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"repair", 'r', "Can fix almost anything except unique keys that aren't unique.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, - "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, + "Base name of shared memory.", (uchar**) &shared_memory_base_name, (uchar**) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"silent", 's', "Print only error messages.", (gptr*) &opt_silent, - (gptr*) &opt_silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"silent", 's', "Print only error messages.", (uchar**) &opt_silent, + (uchar**) &opt_silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"socket", 'S', "Socket file to use for connection.", - (gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR, + (uchar**) &opt_mysql_unix_port, (uchar**) &opt_mysql_unix_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include <sslopt-longopts.h> {"tables", OPT_TABLES, "Overrides option --databases (-B).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"use-frm", OPT_FRM, "When used with REPAIR, get table structure from .frm file, so the table can be repaired even if .MYI header is corrupted.", - (gptr*) &opt_frm, (gptr*) &opt_frm, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, + (uchar**) &opt_frm, (uchar**) &opt_frm, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifndef DONT_ALLOW_USER_CHANGE - {"user", 'u', "User for login if not current user.", (gptr*) ¤t_user, - (gptr*) ¤t_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"user", 'u', "User for login if not current user.", (uchar**) ¤t_user, + (uchar**) ¤t_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif {"verbose", 'v', "Print info about the various stages.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/client/mysqldump.c b/client/mysqldump.c index 149e07ded90..4d320964e39 100644 --- a/client/mysqldump.c +++ b/client/mysqldump.c @@ -117,7 +117,7 @@ static ulong opt_compatible_mode= 0; #define MYSQL_OPT_MASTER_DATA_EFFECTIVE_SQL 1 #define MYSQL_OPT_MASTER_DATA_COMMENTED_SQL 2 static uint opt_mysql_port= 0, opt_master_data; -static my_string opt_mysql_unix_port=0; +static char * opt_mysql_unix_port=0; static int first_error=0; static DYNAMIC_STRING extended_row; #include <sslopt-vars.h> @@ -177,106 +177,106 @@ HASH ignore_table; static struct my_option my_long_options[] = { {"all", 'a', "Deprecated. Use --create-options instead.", - (gptr*) &create_options, (gptr*) &create_options, 0, GET_BOOL, NO_ARG, 1, + (uchar**) &create_options, (uchar**) &create_options, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"all-databases", 'A', "Dump all the databases. This will be same as --databases with all databases selected.", - (gptr*) &opt_alldbs, (gptr*) &opt_alldbs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + (uchar**) &opt_alldbs, (uchar**) &opt_alldbs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"all-tablespaces", 'Y', "Dump all the tablespaces.", - (gptr*) &opt_alltspcs, (gptr*) &opt_alltspcs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + (uchar**) &opt_alltspcs, (uchar**) &opt_alltspcs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"no-tablespaces", 'y', "Do not dump any tablespace information.", - (gptr*) &opt_notspcs, (gptr*) &opt_notspcs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + (uchar**) &opt_notspcs, (uchar**) &opt_notspcs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"add-drop-database", OPT_DROP_DATABASE, "Add a 'DROP DATABASE' before each create.", - (gptr*) &opt_drop_database, (gptr*) &opt_drop_database, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, + (uchar**) &opt_drop_database, (uchar**) &opt_drop_database, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"add-drop-table", OPT_DROP, "Add a 'drop table' before each create.", - (gptr*) &opt_drop, (gptr*) &opt_drop, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, + (uchar**) &opt_drop, (uchar**) &opt_drop, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"add-locks", OPT_LOCKS, "Add locks around insert statements.", - (gptr*) &opt_lock, (gptr*) &opt_lock, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, + (uchar**) &opt_lock, (uchar**) &opt_lock, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"allow-keywords", OPT_KEYWORDS, - "Allow creation of column names that are keywords.", (gptr*) &opt_keywords, - (gptr*) &opt_keywords, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + "Allow creation of column names that are keywords.", (uchar**) &opt_keywords, + (uchar**) &opt_keywords, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __NETWARE__ {"autoclose", OPT_AUTO_CLOSE, "Auto close the screen on exit for Netware.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are.", (gptr*) &charsets_dir, - (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Directory where character sets are.", (uchar**) &charsets_dir, + (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"comments", 'i', "Write additional information.", - (gptr*) &opt_comments, (gptr*) &opt_comments, 0, GET_BOOL, NO_ARG, + (uchar**) &opt_comments, (uchar**) &opt_comments, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"compatible", OPT_COMPATIBLE, "Change the dump to be compatible with a given mode. By default tables are dumped in a format optimized for MySQL. Legal modes are: ansi, mysql323, mysql40, postgresql, oracle, mssql, db2, maxdb, no_key_options, no_table_options, no_field_options. One can use several modes separated by commas. Note: Requires MySQL server version 4.1.0 or higher. This option is ignored with earlier server versions.", - (gptr*) &opt_compatible_mode_str, (gptr*) &opt_compatible_mode_str, 0, + (uchar**) &opt_compatible_mode_str, (uchar**) &opt_compatible_mode_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"compact", OPT_COMPACT, "Give less verbose output (useful for debugging). Disables structure comments and header/footer constructs. Enables options --skip-add-drop-table --no-set-names --skip-disable-keys --skip-add-locks", - (gptr*) &opt_compact, (gptr*) &opt_compact, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + (uchar**) &opt_compact, (uchar**) &opt_compact, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"complete-insert", 'c', "Use complete insert statements.", - (gptr*) &opt_complete_insert, (gptr*) &opt_complete_insert, 0, GET_BOOL, + (uchar**) &opt_complete_insert, (uchar**) &opt_complete_insert, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"compress", 'C', "Use compression in server/client protocol.", - (gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, + (uchar**) &opt_compress, (uchar**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"create-options", OPT_CREATE_OPTIONS, "Include all MySQL specific create options.", - (gptr*) &create_options, (gptr*) &create_options, 0, GET_BOOL, NO_ARG, 1, + (uchar**) &create_options, (uchar**) &create_options, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"databases", 'B', "To dump several databases. Note the difference in usage; In this case no tables are given. All name arguments are regarded as databasenames. 'USE db_name;' will be included in the output.", - (gptr*) &opt_databases, (gptr*) &opt_databases, 0, GET_BOOL, NO_ARG, 0, 0, + (uchar**) &opt_databases, (uchar**) &opt_databases, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef DBUG_OFF {"debug", '#', "This is a non-debug version. Catch this and exit", 0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, #else - {"debug", '#', "Output debug log", (gptr*) &default_dbug_option, - (gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"debug", '#', "Output debug log", (uchar**) &default_dbug_option, + (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (gptr*) &info_flag, - (gptr*) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (uchar**) &info_flag, + (uchar**) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, - "Set the default character set.", (gptr*) &default_charset, - (gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Set the default character set.", (uchar**) &default_charset, + (uchar**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"delayed-insert", OPT_DELAYED, "Insert rows with INSERT DELAYED; ", - (gptr*) &opt_delayed, (gptr*) &opt_delayed, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + (uchar**) &opt_delayed, (uchar**) &opt_delayed, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"delete-master-logs", OPT_DELETE_MASTER_LOGS, "Delete logs on master after backup. This automatically enables --master-data.", - (gptr*) &opt_delete_master_logs, (gptr*) &opt_delete_master_logs, 0, + (uchar**) &opt_delete_master_logs, (uchar**) &opt_delete_master_logs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"disable-keys", 'K', - "'/*!40000 ALTER TABLE tb_name DISABLE KEYS */; and '/*!40000 ALTER TABLE tb_name ENABLE KEYS */; will be put in the output.", (gptr*) &opt_disable_keys, - (gptr*) &opt_disable_keys, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, + "'/*!40000 ALTER TABLE tb_name DISABLE KEYS */; and '/*!40000 ALTER TABLE tb_name ENABLE KEYS */; will be put in the output.", (uchar**) &opt_disable_keys, + (uchar**) &opt_disable_keys, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"events", 'E', "Dump events.", - (gptr*) &opt_events, (gptr*) &opt_events, 0, GET_BOOL, + (uchar**) &opt_events, (uchar**) &opt_events, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"extended-insert", 'e', "Allows utilization of the new, much faster INSERT syntax.", - (gptr*) &extended_insert, (gptr*) &extended_insert, 0, GET_BOOL, NO_ARG, + (uchar**) &extended_insert, (uchar**) &extended_insert, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"fields-terminated-by", OPT_FTB, - "Fields in the textfile are terminated by ...", (gptr*) &fields_terminated, - (gptr*) &fields_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Fields in the textfile are terminated by ...", (uchar**) &fields_terminated, + (uchar**) &fields_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"fields-enclosed-by", OPT_ENC, - "Fields in the importfile are enclosed by ...", (gptr*) &enclosed, - (gptr*) &enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0 ,0, 0}, + "Fields in the importfile are enclosed by ...", (uchar**) &enclosed, + (uchar**) &enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0 ,0, 0}, {"fields-optionally-enclosed-by", OPT_O_ENC, - "Fields in the i.file are opt. enclosed by ...", (gptr*) &opt_enclosed, - (gptr*) &opt_enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0 ,0, 0}, + "Fields in the i.file are opt. enclosed by ...", (uchar**) &opt_enclosed, + (uchar**) &opt_enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0 ,0, 0}, {"fields-escaped-by", OPT_ESC, "Fields in the i.file are escaped by ...", - (gptr*) &escaped, (gptr*) &escaped, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + (uchar**) &escaped, (uchar**) &escaped, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"first-slave", 'x', "Deprecated, renamed to --lock-all-tables.", - (gptr*) &opt_lock_all_tables, (gptr*) &opt_lock_all_tables, 0, GET_BOOL, NO_ARG, + (uchar**) &opt_lock_all_tables, (uchar**) &opt_lock_all_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"flush-logs", 'F', "Flush logs file in server before starting dump. " "Note that if you dump many databases at once (using the option " @@ -287,44 +287,44 @@ static struct my_option my_long_options[] = "to the moment all tables are locked. So if you want your dump and " "the log flush to happen at the same exact moment you should use " "--lock-all-tables or --master-data with --flush-logs", - (gptr*) &flush_logs, (gptr*) &flush_logs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + (uchar**) &flush_logs, (uchar**) &flush_logs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"flush-privileges", OPT_ESC, "Emit a FLUSH PRIVILEGES statement " "after dumping the mysql database. This option should be used any " "time the dump contains the mysql database and any other database " "that depends on the data in the mysql database for proper restore. ", - (gptr*) &flush_privileges, (gptr*) &flush_privileges, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + (uchar**) &flush_privileges, (uchar**) &flush_privileges, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', "Continue even if we get an sql-error.", - (gptr*) &ignore_errors, (gptr*) &ignore_errors, 0, GET_BOOL, NO_ARG, + (uchar**) &ignore_errors, (uchar**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help message and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"hex-blob", OPT_HEXBLOB, "Dump binary strings (BINARY, " "VARBINARY, BLOB) in hexadecimal format.", - (gptr*) &opt_hex_blob, (gptr*) &opt_hex_blob, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"host", 'h', "Connect to host.", (gptr*) ¤t_host, - (gptr*) ¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + (uchar**) &opt_hex_blob, (uchar**) &opt_hex_blob, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"host", 'h', "Connect to host.", (uchar**) ¤t_host, + (uchar**) ¤t_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"ignore-table", OPT_IGNORE_TABLE, "Do not dump the specified table. To specify more than one table to ignore, " "use the directive multiple times, once for each table. Each table must " "be specified with both database and table names, e.g. --ignore-table=database.table", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"insert-ignore", OPT_INSERT_IGNORE, "Insert rows with INSERT IGNORE.", - (gptr*) &opt_ignore, (gptr*) &opt_ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + (uchar**) &opt_ignore, (uchar**) &opt_ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"lines-terminated-by", OPT_LTB, "Lines in the i.file are terminated by ...", - (gptr*) &lines_terminated, (gptr*) &lines_terminated, 0, GET_STR, + (uchar**) &lines_terminated, (uchar**) &lines_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"lock-all-tables", 'x', "Locks all tables across all databases. This " "is achieved by taking a global read lock for the duration of the whole " "dump. Automatically turns --single-transaction and --lock-tables off.", - (gptr*) &opt_lock_all_tables, (gptr*) &opt_lock_all_tables, 0, GET_BOOL, NO_ARG, + (uchar**) &opt_lock_all_tables, (uchar**) &opt_lock_all_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"lock-tables", 'l', "Lock all tables for read.", (gptr*) &lock_tables, - (gptr*) &lock_tables, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, + {"lock-tables", 'l', "Lock all tables for read.", (uchar**) &lock_tables, + (uchar**) &lock_tables, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"log-error", OPT_ERROR_LOG_FILE, "Append warnings and errors to given file.", - (gptr*) &log_error_file, (gptr*) &log_error_file, 0, GET_STR, + (uchar**) &log_error_file, (uchar**) &log_error_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"master-data", OPT_MASTER_DATA, "This causes the binary log position and filename to be appended to the " @@ -336,29 +336,29 @@ static struct my_option my_long_options[] = "- don't forget to read about --single-transaction below). In all cases " "any action on logs will happen at the exact moment of the dump." "Option automatically turns --lock-tables off.", - (gptr*) &opt_master_data, (gptr*) &opt_master_data, 0, + (uchar**) &opt_master_data, (uchar**) &opt_master_data, 0, GET_UINT, OPT_ARG, 0, 0, MYSQL_OPT_MASTER_DATA_COMMENTED_SQL, 0, 0, 0}, {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, "", - (gptr*) &opt_max_allowed_packet, (gptr*) &opt_max_allowed_packet, 0, + (uchar**) &opt_max_allowed_packet, (uchar**) &opt_max_allowed_packet, 0, GET_ULONG, REQUIRED_ARG, 24*1024*1024, 4096, (longlong) 2L*1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0}, {"net_buffer_length", OPT_NET_BUFFER_LENGTH, "", - (gptr*) &opt_net_buffer_length, (gptr*) &opt_net_buffer_length, 0, + (uchar**) &opt_net_buffer_length, (uchar**) &opt_net_buffer_length, 0, GET_ULONG, REQUIRED_ARG, 1024*1024L-1025, 4096, 16*1024L*1024L, MALLOC_OVERHEAD-1024, 1024, 0}, {"no-autocommit", OPT_AUTOCOMMIT, "Wrap tables with autocommit/commit statements.", - (gptr*) &opt_autocommit, (gptr*) &opt_autocommit, 0, GET_BOOL, NO_ARG, + (uchar**) &opt_autocommit, (uchar**) &opt_autocommit, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"no-create-db", 'n', "'CREATE DATABASE /*!32312 IF NOT EXISTS*/ db_name;' will not be put in the output. The above line will be added otherwise, if --databases or --all-databases option was given.}.", - (gptr*) &opt_create_db, (gptr*) &opt_create_db, 0, GET_BOOL, NO_ARG, 0, 0, + (uchar**) &opt_create_db, (uchar**) &opt_create_db, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"no-create-info", 't', "Don't write table creation info.", - (gptr*) &opt_no_create_info, (gptr*) &opt_no_create_info, 0, GET_BOOL, + (uchar**) &opt_no_create_info, (uchar**) &opt_no_create_info, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"no-data", 'd', "No row information.", (gptr*) &opt_no_data, - (gptr*) &opt_no_data, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"no-data", 'd', "No row information.", (uchar**) &opt_no_data, + (uchar**) &opt_no_data, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"no-set-names", 'N', "Deprecated. Use --skip-set-charset instead.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -367,7 +367,7 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"order-by-primary", OPT_ORDER_BY_PRIMARY, "Sorts each table's rows by primary key, or first unique key, if such a key exists. Useful when dumping a MyISAM table to be loaded into an InnoDB table, but will make the dump itself take considerably longer.", - (gptr*) &opt_order_by_primary, (gptr*) &opt_order_by_primary, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + (uchar**) &opt_order_by_primary, (uchar**) &opt_order_by_primary, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server. If password is not given it's solicited on the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, @@ -375,35 +375,35 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, - (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, + {"port", 'P', "Port number to use for connection.", (uchar**) &opt_mysql_port, + (uchar**) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"quick", 'q', "Don't buffer query, dump directly to stdout.", - (gptr*) &quick, (gptr*) &quick, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, + (uchar**) &quick, (uchar**) &quick, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"quote-names",'Q', "Quote table and column names with backticks (`).", - (gptr*) &opt_quoted, (gptr*) &opt_quoted, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, + (uchar**) &opt_quoted, (uchar**) &opt_quoted, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"replace", OPT_MYSQL_REPLACE_INTO, "Use REPLACE INTO instead of INSERT INTO.", - (gptr*) &opt_replace_into, (gptr*) &opt_replace_into, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + (uchar**) &opt_replace_into, (uchar**) &opt_replace_into, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"result-file", 'r', "Direct output to a given file. This option should be used in MSDOS, because it prevents new line '\\n' from being converted to '\\r\\n' (carriage return + line feed).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"routines", 'R', "Dump stored routines (functions and procedures).", - (gptr*) &opt_routines, (gptr*) &opt_routines, 0, GET_BOOL, + (uchar**) &opt_routines, (uchar**) &opt_routines, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"set-charset", OPT_SET_CHARSET, "Add 'SET NAMES default_character_set' to the output. Enabled by default; suppress with --skip-set-charset.", - (gptr*) &opt_set_charset, (gptr*) &opt_set_charset, 0, GET_BOOL, NO_ARG, 1, + (uchar**) &opt_set_charset, (uchar**) &opt_set_charset, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"set-variable", 'O', "Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, - "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, + "Base name of shared memory.", (uchar**) &shared_memory_base_name, (uchar**) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif /* @@ -417,37 +417,37 @@ static struct my_option my_long_options[] = "support multiversioning (currently only InnoDB does); the dump is NOT " "guaranteed to be consistent for other storage engines. Option " "automatically turns off --lock-tables.", - (gptr*) &opt_single_transaction, (gptr*) &opt_single_transaction, 0, + (uchar**) &opt_single_transaction, (uchar**) &opt_single_transaction, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"skip-opt", OPT_SKIP_OPTIMIZATION, "Disable --opt. Disables --add-drop-table, --add-locks, --create-options, --quick, --extended-insert, --lock-tables, --set-charset, and --disable-keys.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"socket", 'S', "Socket file to use for connection.", - (gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR, + (uchar**) &opt_mysql_unix_port, (uchar**) &opt_mysql_unix_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include <sslopt-longopts.h> {"tab",'T', "Creates tab separated textfile for each table to given path. (creates .sql and .txt files). NOTE: This only works if mysqldump is run on the same machine as the mysqld daemon.", - (gptr*) &path, (gptr*) &path, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + (uchar**) &path, (uchar**) &path, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"tables", OPT_TABLES, "Overrides option --databases (-B).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"triggers", OPT_TRIGGERS, "Dump triggers for each dumped table", - (gptr*) &opt_dump_triggers, (gptr*) &opt_dump_triggers, 0, GET_BOOL, + (uchar**) &opt_dump_triggers, (uchar**) &opt_dump_triggers, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"tz-utc", OPT_TZ_UTC, "SET TIME_ZONE='+00:00' at top of dump to allow dumping of TIMESTAMP data when a server has data in different time zones or data is being moved between servers with different time zones.", - (gptr*) &opt_tz_utc, (gptr*) &opt_tz_utc, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, + (uchar**) &opt_tz_utc, (uchar**) &opt_tz_utc, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, #ifndef DONT_ALLOW_USER_CHANGE {"user", 'u', "User for login if not current user.", - (gptr*) ¤t_user, (gptr*) ¤t_user, 0, GET_STR, REQUIRED_ARG, + (uchar**) ¤t_user, (uchar**) ¤t_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif {"verbose", 'v', "Print info about the various stages.", - (gptr*) &verbose, (gptr*) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + (uchar**) &verbose, (uchar**) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version",'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"where", 'w', "Dump only selected records; QUOTES mandatory!", - (gptr*) &where, (gptr*) &where, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + (uchar**) &where, (uchar**) &where, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"xml", 'X', "Dump a database as well formed XML.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} @@ -655,18 +655,18 @@ static void write_footer(FILE *sql_file) } } /* write_footer */ -static void free_table_ent(char *key) +static void free_table_ent(char *key) { - my_free((gptr) key, MYF(0)); + my_free(key, MYF(0)); } -byte* get_table_key(const char *entry, uint *length, - my_bool not_used __attribute__((unused))) +uchar* get_table_key(const char *entry, size_t *length, + my_bool not_used __attribute__((unused))) { *length= strlen(entry); - return (byte*) entry; + return (uchar*) entry; } @@ -753,7 +753,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), fprintf(stderr, "Illegal use of option --ignore-table=<database>.<table>\n"); exit(1); } - if (my_hash_insert(&ignore_table, (byte*)my_strdup(argument, MYF(0)))) + if (my_hash_insert(&ignore_table, (uchar*)my_strdup(argument, MYF(0)))) exit(EX_EOM); break; } @@ -832,13 +832,13 @@ static int get_options(int *argc, char ***argv) return(EX_EOM); /* Don't copy internal log tables */ if (my_hash_insert(&ignore_table, - (byte*) my_strdup("mysql.apply_status", MYF(MY_WME))) || + (uchar*) my_strdup("mysql.apply_status", MYF(MY_WME))) || my_hash_insert(&ignore_table, - (byte*) my_strdup("mysql.schema", MYF(MY_WME))) || + (uchar*) my_strdup("mysql.schema", MYF(MY_WME))) || my_hash_insert(&ignore_table, - (byte*) my_strdup("mysql.general_log", MYF(MY_WME))) || + (uchar*) my_strdup("mysql.general_log", MYF(MY_WME))) || my_hash_insert(&ignore_table, - (byte*) my_strdup("mysql.slow_log", MYF(MY_WME)))) + (uchar*) my_strdup("mysql.slow_log", MYF(MY_WME)))) return(EX_EOM); if ((ho_error= handle_options(argc, argv, my_long_options, get_one_option))) @@ -2287,10 +2287,10 @@ static void dump_triggers_for_table(char *table, we should check if we have this column before accessing it. */ - uint user_name_len; + size_t user_name_len; char user_name_str[USERNAME_LENGTH + 1]; char quoted_user_name_str[USERNAME_LENGTH * 2 + 3]; - uint host_name_len; + size_t host_name_len; char host_name_str[HOSTNAME_LENGTH + 1]; char quoted_host_name_str[HOSTNAME_LENGTH * 2 + 3]; @@ -3342,9 +3342,9 @@ static int init_dumping(char *database, int init_func(char*)) /* Return 1 if we should copy the table */ -my_bool include_table(byte* hash_key, uint len) +my_bool include_table(uchar* hash_key, uint len) { - return !hash_search(&ignore_table, (byte*) hash_key, len); + return !hash_search(&ignore_table, (uchar*) hash_key, len); } @@ -4132,10 +4132,10 @@ static my_bool get_view_structure(char *table, char* db) Surround it with !50013 comments */ { - uint user_name_len; + size_t user_name_len; char user_name_str[USERNAME_LENGTH + 1]; char quoted_user_name_str[USERNAME_LENGTH * 2 + 3]; - uint host_name_len; + size_t host_name_len; char host_name_str[HOSTNAME_LENGTH + 1]; char quoted_host_name_str[HOSTNAME_LENGTH * 2 + 3]; diff --git a/client/mysqlimport.c b/client/mysqlimport.c index c037da9c0b9..396063731cf 100644 --- a/client/mysqlimport.c +++ b/client/mysqlimport.c @@ -57,7 +57,7 @@ static char *opt_password=0, *current_user=0, *escaped=0, *opt_columns=0, *default_charset= (char*) MYSQL_DEFAULT_CHARSET_NAME; static uint opt_mysql_port= 0, opt_protocol= 0; -static my_string opt_mysql_unix_port=0; +static char * opt_mysql_unix_port=0; static longlong opt_ignore_lines= -1; static CHARSET_INFO *charset_info= &my_charset_latin1; #include <sslopt-vars.h> @@ -73,59 +73,59 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are.", (gptr*) &charsets_dir, - (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Directory where character sets are.", (uchar**) &charsets_dir, + (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, - "Set the default character set.", (gptr*) &default_charset, - (gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Set the default character set.", (uchar**) &default_charset, + (uchar**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"columns", 'c', "Use only these columns to import the data to. Give the column names in a comma separated list. This is same as giving columns to LOAD DATA INFILE.", - (gptr*) &opt_columns, (gptr*) &opt_columns, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, + (uchar**) &opt_columns, (uchar**) &opt_columns, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"compress", 'C', "Use compression in server/client protocol.", - (gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, + (uchar**) &opt_compress, (uchar**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"debug",'#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (gptr*) &info_flag, - (gptr*) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"delete", 'd', "First delete all rows from table.", (gptr*) &opt_delete, - (gptr*) &opt_delete, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (uchar**) &info_flag, + (uchar**) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"delete", 'd', "First delete all rows from table.", (uchar**) &opt_delete, + (uchar**) &opt_delete, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"fields-terminated-by", OPT_FTB, - "Fields in the textfile are terminated by ...", (gptr*) &fields_terminated, - (gptr*) &fields_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Fields in the textfile are terminated by ...", (uchar**) &fields_terminated, + (uchar**) &fields_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"fields-enclosed-by", OPT_ENC, - "Fields in the importfile are enclosed by ...", (gptr*) &enclosed, - (gptr*) &enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Fields in the importfile are enclosed by ...", (uchar**) &enclosed, + (uchar**) &enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"fields-optionally-enclosed-by", OPT_O_ENC, - "Fields in the i.file are opt. enclosed by ...", (gptr*) &opt_enclosed, - (gptr*) &opt_enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Fields in the i.file are opt. enclosed by ...", (uchar**) &opt_enclosed, + (uchar**) &opt_enclosed, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"fields-escaped-by", OPT_ESC, "Fields in the i.file are escaped by ...", - (gptr*) &escaped, (gptr*) &escaped, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, + (uchar**) &escaped, (uchar**) &escaped, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', "Continue even if we get an sql-error.", - (gptr*) &ignore_errors, (gptr*) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0, + (uchar**) &ignore_errors, (uchar**) &ignore_errors, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Displays this help and exits.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"host", 'h', "Connect to host.", (gptr*) ¤t_host, - (gptr*) ¤t_host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"host", 'h', "Connect to host.", (uchar**) ¤t_host, + (uchar**) ¤t_host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"ignore", 'i', "If duplicate unique key was found, keep old row.", - (gptr*) &ignore, (gptr*) &ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + (uchar**) &ignore, (uchar**) &ignore, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"ignore-lines", OPT_IGN_LINES, "Ignore first n lines of data infile.", - (gptr*) &opt_ignore_lines, (gptr*) &opt_ignore_lines, 0, GET_LL, + (uchar**) &opt_ignore_lines, (uchar**) &opt_ignore_lines, 0, GET_LL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"lines-terminated-by", OPT_LTB, "Lines in the i.file are terminated by ...", - (gptr*) &lines_terminated, (gptr*) &lines_terminated, 0, GET_STR, + (uchar**) &lines_terminated, (uchar**) &lines_terminated, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"local", 'L', "Read all files through the client.", (gptr*) &opt_local_file, - (gptr*) &opt_local_file, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"local", 'L', "Read all files through the client.", (uchar**) &opt_local_file, + (uchar**) &opt_local_file, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"lock-tables", 'l', "Lock all tables for write (this disables threads).", - (gptr*) &lock_tables, (gptr*) &lock_tables, 0, GET_BOOL, NO_ARG, + (uchar**) &lock_tables, (uchar**) &lock_tables, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"low-priority", OPT_LOW_PRIORITY, - "Use LOW_PRIORITY when updating the table.", (gptr*) &opt_low_priority, - (gptr*) &opt_low_priority, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + "Use LOW_PRIORITY when updating the table.", (uchar**) &opt_low_priority, + (uchar**) &opt_low_priority, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server. If password is not given it's asked from the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, @@ -133,35 +133,35 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, - (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, + {"port", 'P', "Port number to use for connection.", (uchar**) &opt_mysql_port, + (uchar**) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"replace", 'r', "If duplicate unique key was found, replace old row.", - (gptr*) &replace, (gptr*) &replace, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + (uchar**) &replace, (uchar**) &replace, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, - "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, + "Base name of shared memory.", (uchar**) &shared_memory_base_name, (uchar**) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"silent", 's', "Be more silent.", (gptr*) &silent, (gptr*) &silent, 0, + {"silent", 's', "Be more silent.", (uchar**) &silent, (uchar**) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"socket", 'S', "Socket file to use for connection.", - (gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR, + (uchar**) &opt_mysql_unix_port, (uchar**) &opt_mysql_unix_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include <sslopt-longopts.h> {"use-threads", OPT_USE_THREADS, "Load files in parallel. The argument is the number " "of threads to use for loading data.", - (gptr*) &opt_use_threads, (gptr*) &opt_use_threads, 0, + (uchar**) &opt_use_threads, (uchar**) &opt_use_threads, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifndef DONT_ALLOW_USER_CHANGE - {"user", 'u', "User for login if not current user.", (gptr*) ¤t_user, - (gptr*) ¤t_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"user", 'u', "User for login if not current user.", (uchar**) ¤t_user, + (uchar**) ¤t_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"verbose", 'v', "Print info about the various stages.", (gptr*) &verbose, - (gptr*) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"verbose", 'v', "Print info about the various stages.", (uchar**) &verbose, + (uchar**) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} diff --git a/client/mysqlshow.c b/client/mysqlshow.c index 0c6a6229964..649658d6223 100644 --- a/client/mysqlshow.c +++ b/client/mysqlshow.c @@ -26,7 +26,7 @@ #include <stdarg.h> #include <sslopt-vars.h> -static my_string host=0,opt_password=0,user=0; +static char * host=0, *opt_password=0, *user=0; static my_bool opt_show_keys= 0, opt_compress= 0, opt_count=0, opt_status= 0; static my_bool tty_password= 0, opt_table_type= 0, info_flag= 0; static uint opt_verbose=0; @@ -52,7 +52,7 @@ static void print_res_top(MYSQL_RES *result); static void print_res_row(MYSQL_RES *result,MYSQL_ROW cur); static const char *load_default_groups[]= { "mysqlshow","client",0 }; -static my_string opt_mysql_unix_port=0; +static char * opt_mysql_unix_port=0; int main(int argc, char **argv) { @@ -120,7 +120,8 @@ int main(int argc, char **argv) mysql_options(&mysql, MYSQL_SET_CHARSET_NAME, default_charset); if (!(mysql_real_connect(&mysql,host,user,opt_password, - (first_argument_uses_wildcards) ? "" : argv[0],opt_mysql_port,opt_mysql_unix_port, + (first_argument_uses_wildcards) ? "" : + argv[0],opt_mysql_port,opt_mysql_unix_port, 0))) { fprintf(stderr,"%s: %s\n",my_progname,mysql_error(&mysql)); @@ -161,36 +162,36 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"character-sets-dir", 'c', "Directory where character sets are.", - (gptr*) &charsets_dir, (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, + (uchar**) &charsets_dir, (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"default-character-set", OPT_DEFAULT_CHARSET, - "Set the default character set.", (gptr*) &default_charset, - (gptr*) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Set the default character set.", (uchar**) &default_charset, + (uchar**) &default_charset, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"count", OPT_COUNT, "Show number of rows per table (may be slow for not MyISAM tables)", - (gptr*) &opt_count, (gptr*) &opt_count, 0, GET_BOOL, NO_ARG, 0, 0, 0, + (uchar**) &opt_count, (uchar**) &opt_count, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"compress", 'C', "Use compression in server/client protocol.", - (gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, + (uchar**) &opt_compress, (uchar**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (gptr*) &info_flag, - (gptr*) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-info", OPT_DEBUG_INFO, "Print some debug info at exit.", (uchar**) &info_flag, + (uchar**) &info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"host", 'h', "Connect to host.", (gptr*) &host, (gptr*) &host, 0, GET_STR, + {"host", 'h', "Connect to host.", (uchar**) &host, (uchar**) &host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"status", 'i', "Shows a lot of extra information about each table.", - (gptr*) &opt_status, (gptr*) &opt_status, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + (uchar**) &opt_status, (uchar**) &opt_status, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"keys", 'k', "Show keys for table.", (gptr*) &opt_show_keys, - (gptr*) &opt_show_keys, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"keys", 'k', "Show keys for table.", (uchar**) &opt_show_keys, + (uchar**) &opt_show_keys, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server. If password is not given it's asked from the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, - (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, + {"port", 'P', "Port number to use for connection.", (uchar**) &opt_mysql_port, + (uchar**) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __WIN__ {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, @@ -200,19 +201,19 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, - "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, + "Base name of shared memory.", (uchar**) &shared_memory_base_name, (uchar**) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif {"show-table-type", 't', "Show table type column.", - (gptr*) &opt_table_type, (gptr*) &opt_table_type, 0, GET_BOOL, + (uchar**) &opt_table_type, (uchar**) &opt_table_type, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"socket", 'S', "Socket file to use for connection.", - (gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR, + (uchar**) &opt_mysql_unix_port, (uchar**) &opt_mysql_unix_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include <sslopt-longopts.h> #ifndef DONT_ALLOW_USER_CHANGE - {"user", 'u', "User for login if not current user.", (gptr*) &user, - (gptr*) &user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"user", 'u', "User for login if not current user.", (uchar**) &user, + (uchar**) &user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif {"verbose", 'v', "More verbose output; You can use this multiple times to get even more verbose output.", @@ -733,7 +734,7 @@ print_header(const char *header,uint head_length,...) for (i=0 ; i < length+2 ; i++) putchar('-'); putchar('+'); - if (!(field=va_arg(args,my_string))) + if (!(field=va_arg(args,char *))) break; length=va_arg(args,uint); } @@ -757,7 +758,7 @@ print_header(const char *header,uint head_length,...) for (i=0 ; i < length ; i++) putchar(' '); putchar('|'); - if (!(field=va_arg(args,my_string))) + if (!(field=va_arg(args,char *))) break; length=va_arg(args,uint); } @@ -772,7 +773,7 @@ print_header(const char *header,uint head_length,...) for (i=0 ; i < length+2 ; i++) putchar('-'); putchar('+'); - if (!(field=va_arg(args,my_string))) + if (!(field=va_arg(args,char *))) break; length=va_arg(args,uint); } @@ -798,7 +799,7 @@ print_row(const char *header,uint head_length,...) field_length=(uint) strlen(field); for (i=field_length ; i <= length ; i++) putchar(' '); - if (!(field=va_arg(args,my_string))) + if (!(field=va_arg(args,char *))) break; length=va_arg(args,uint); } diff --git a/client/mysqlslap.c b/client/mysqlslap.c index 0335922881a..86f024a9b6f 100644 --- a/client/mysqlslap.c +++ b/client/mysqlslap.c @@ -387,9 +387,9 @@ int main(int argc, char **argv) /* now free all the strings we created */ if (opt_password) - my_free((gptr)opt_password, MYF(0)); + my_free(opt_password, MYF(0)); - my_free((gptr)concurrency, MYF(0)); + my_free(concurrency, MYF(0)); statement_cleanup(create_statements); statement_cleanup(query_statements); @@ -399,7 +399,7 @@ int main(int argc, char **argv) #ifdef HAVE_SMEM if (shared_memory_base_name) - my_free((gptr)shared_memory_base_name, MYF(MY_ALLOW_ZERO_PTR)); + my_free(shared_memory_base_name, MYF(MY_ALLOW_ZERO_PTR)); #endif free_defaults(defaults_argv); my_end(0); @@ -473,7 +473,7 @@ void concurrency_loop(MYSQL *mysql, uint current, option_string *eptr) if (opt_csv_str) print_conclusions_csv(&conclusion); - my_free((gptr)head_sptr, MYF(0)); + my_free(head_sptr, MYF(0)); } @@ -484,94 +484,94 @@ static struct my_option my_long_options[] = 0, 0, 0, 0, 0, 0}, {"auto-generate-sql", 'a', "Generate SQL where not supplied by file or command line.", - (gptr*) &auto_generate_sql, (gptr*) &auto_generate_sql, + (uchar**) &auto_generate_sql, (uchar**) &auto_generate_sql, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"auto-generate-sql-add-autoincrement", OPT_SLAP_AUTO_GENERATE_ADD_AUTO, "Add autoincrement to auto-generated tables.", - (gptr*) &auto_generate_sql_autoincrement, - (gptr*) &auto_generate_sql_autoincrement, + (uchar**) &auto_generate_sql_autoincrement, + (uchar**) &auto_generate_sql_autoincrement, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"auto-generate-sql-execute-number", OPT_SLAP_AUTO_GENERATE_EXECUTE_QUERIES, "Set this number to generate a set number of queries to run.\n", - (gptr*) &auto_actual_queries, (gptr*) &auto_actual_queries, + (uchar**) &auto_actual_queries, (uchar**) &auto_actual_queries, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"auto-generate-sql-guid-primary", OPT_SLAP_AUTO_GENERATE_GUID_PRIMARY, "Add GUID based primary keys to auto-generated tables.", - (gptr*) &auto_generate_sql_guid_primary, - (gptr*) &auto_generate_sql_guid_primary, + (uchar**) &auto_generate_sql_guid_primary, + (uchar**) &auto_generate_sql_guid_primary, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"auto-generate-sql-load-type", OPT_SLAP_AUTO_GENERATE_SQL_LOAD_TYPE, "Load types are mixed, update, write, key, or read. Default is mixed\n", - (gptr*) &auto_generate_sql_type, (gptr*) &auto_generate_sql_type, + (uchar**) &auto_generate_sql_type, (uchar**) &auto_generate_sql_type, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"auto-generate-sql-secondary-indexes", OPT_SLAP_AUTO_GENERATE_SECONDARY_INDEXES, "Number of secondary indexes to add auto-generated tables.", - (gptr*) &auto_generate_sql_secondary_indexes, - (gptr*) &auto_generate_sql_secondary_indexes, 0, + (uchar**) &auto_generate_sql_secondary_indexes, + (uchar**) &auto_generate_sql_secondary_indexes, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"auto-generate-sql-unique-query-number", OPT_SLAP_AUTO_GENERATE_UNIQUE_QUERY_NUM, "Number of unique queries auto tests", - (gptr*) &auto_generate_sql_unique_query_number, - (gptr*) &auto_generate_sql_unique_query_number, + (uchar**) &auto_generate_sql_unique_query_number, + (uchar**) &auto_generate_sql_unique_query_number, 0, GET_ULL, REQUIRED_ARG, 10, 0, 0, 0, 0, 0}, {"auto-generate-sql-unique-write-number", OPT_SLAP_AUTO_GENERATE_UNIQUE_WRITE_NUM, "Number of unique queries for auto-generate-sql-write-number", - (gptr*) &auto_generate_sql_unique_write_number, - (gptr*) &auto_generate_sql_unique_write_number, + (uchar**) &auto_generate_sql_unique_write_number, + (uchar**) &auto_generate_sql_unique_write_number, 0, GET_ULL, REQUIRED_ARG, 10, 0, 0, 0, 0, 0}, {"auto-generate-sql-write-number", OPT_SLAP_AUTO_GENERATE_WRITE_NUM, "Number of rows to insert to used in read and write loads (default is 100).\n", - (gptr*) &auto_generate_sql_number, (gptr*) &auto_generate_sql_number, + (uchar**) &auto_generate_sql_number, (uchar**) &auto_generate_sql_number, 0, GET_ULL, REQUIRED_ARG, 100, 0, 0, 0, 0, 0}, {"compress", 'C', "Use compression in server/client protocol.", - (gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, + (uchar**) &opt_compress, (uchar**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"concurrency", 'c', "Number of clients to simulate for query to run.", - (gptr*) &concurrency_str, (gptr*) &concurrency_str, 0, GET_STR, + (uchar**) &concurrency_str, (uchar**) &concurrency_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"create", OPT_SLAP_CREATE_STRING, "File or string to use create tables.", - (gptr*) &create_string, (gptr*) &create_string, 0, GET_STR, REQUIRED_ARG, + (uchar**) &create_string, (uchar**) &create_string, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"create-schema", OPT_CREATE_SLAP_SCHEMA, "Schema to run tests in.", - (gptr*) &create_schema_string, (gptr*) &create_schema_string, 0, GET_STR, + (uchar**) &create_schema_string, (uchar**) &create_schema_string, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"csv", OPT_SLAP_CSV, "Generate CSV output to named file or to stdout if no file is named.", - (gptr*) &opt_csv_str, (gptr*) &opt_csv_str, 0, GET_STR, + (uchar**) &opt_csv_str, (uchar**) &opt_csv_str, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", - (gptr*) &default_dbug_option, (gptr*) &default_dbug_option, 0, GET_STR, + (uchar**) &default_dbug_option, (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"delimiter", 'F', "Delimiter to use in SQL statements supplied in file or command line.", - (gptr*) &delimiter, (gptr*) &delimiter, 0, GET_STR, REQUIRED_ARG, + (uchar**) &delimiter, (uchar**) &delimiter, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"engine", 'e', "Storage engine to use for creating the table.", - (gptr*) &default_engine, (gptr*) &default_engine, 0, + (uchar**) &default_engine, (uchar**) &default_engine, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"host", 'h', "Connect to host.", (gptr*) &host, (gptr*) &host, 0, GET_STR, + {"host", 'h', "Connect to host.", (uchar**) &host, (uchar**) &host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"iterations", 'i', "Number of times too run the tests.", (gptr*) &iterations, - (gptr*) &iterations, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0}, + {"iterations", 'i', "Number of times too run the tests.", (uchar**) &iterations, + (uchar**) &iterations, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0}, {"number-char-cols", 'x', "Number of VARCHAR columns to create table with if specifying --auto-generate-sql ", - (gptr*) &num_char_cols_opt, (gptr*) &num_char_cols_opt, 0, GET_STR, REQUIRED_ARG, + (uchar**) &num_char_cols_opt, (uchar**) &num_char_cols_opt, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"number-int-cols", 'y', "Number of INT columns to create table with if specifying --auto-generate-sql.", - (gptr*) &num_int_cols_opt, (gptr*) &num_int_cols_opt, 0, GET_STR, REQUIRED_ARG, + (uchar**) &num_int_cols_opt, (uchar**) &num_int_cols_opt, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"number-of-queries", OPT_MYSQL_NUMBER_OF_QUERY, "Limit each client to this number of queries (this is not exact).", - (gptr*) &num_of_query, (gptr*) &num_of_query, 0, + (uchar**) &num_of_query, (uchar**) &num_of_query, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"only-print", OPT_MYSQL_ONLY_PRINT, "This causes mysqlslap to not connect to the databases, but instead print " "out what it would have done instead.", - (gptr*) &opt_only_print, (gptr*) &opt_only_print, 0, GET_BOOL, NO_ARG, + (uchar**) &opt_only_print, (uchar**) &opt_only_print, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server. If password is not given it's " @@ -580,50 +580,50 @@ static struct my_option my_long_options[] = {"pipe", 'W', "Use named pipes to connect to server.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"port", 'P', "Port number to use for connection.", (gptr*) &opt_mysql_port, - (gptr*) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, + {"port", 'P', "Port number to use for connection.", (uchar**) &opt_mysql_port, + (uchar**) &opt_mysql_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0}, {"post-query", OPT_SLAP_POST_QUERY, "Query to run or file containing query to run after executing.", - (gptr*) &user_supplied_post_statements, - (gptr*) &user_supplied_post_statements, + (uchar**) &user_supplied_post_statements, + (uchar**) &user_supplied_post_statements, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"pre-query", OPT_SLAP_PRE_QUERY, "Query to run or file containing query to run before executing.", - (gptr*) &user_supplied_pre_statements, - (gptr*) &user_supplied_pre_statements, + (uchar**) &user_supplied_pre_statements, + (uchar**) &user_supplied_pre_statements, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"preserve-schema", OPT_MYSQL_PRESERVE_SCHEMA, "Preserve the schema from the mysqlslap run, this happens unless " "--auto-generate-sql or --create are used.", - (gptr*) &opt_preserve, (gptr*) &opt_preserve, 0, GET_BOOL, + (uchar**) &opt_preserve, (uchar**) &opt_preserve, 0, GET_BOOL, NO_ARG, TRUE, 0, 0, 0, 0, 0}, {"protocol", OPT_MYSQL_PROTOCOL, "The protocol of connection (tcp,socket,pipe,memory).", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"query", 'q', "Query to run or file containing query to run.", - (gptr*) &user_supplied_query, (gptr*) &user_supplied_query, + (uchar**) &user_supplied_query, (uchar**) &user_supplied_query, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, - "Base name of shared memory.", (gptr*) &shared_memory_base_name, - (gptr*) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, + "Base name of shared memory.", (uchar**) &shared_memory_base_name, + (uchar**) &shared_memory_base_name, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif {"silent", 's', "Run program in silent mode - no output.", - (gptr*) &opt_silent, (gptr*) &opt_silent, 0, GET_BOOL, NO_ARG, + (uchar**) &opt_silent, (uchar**) &opt_silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"socket", 'S', "Socket file to use for connection.", - (gptr*) &opt_mysql_unix_port, (gptr*) &opt_mysql_unix_port, 0, GET_STR, + (uchar**) &opt_mysql_unix_port, (uchar**) &opt_mysql_unix_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #include <sslopt-longopts.h> #ifndef DONT_ALLOW_USER_CHANGE - {"user", 'u', "User for login if not current user.", (gptr*) &user, - (gptr*) &user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"user", 'u', "User for login if not current user.", (uchar**) &user, + (uchar**) &user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif {"verbose", 'v', "More verbose output; You can use this multiple times to get even more " - "verbose output.", (gptr*) &verbose, (gptr*) &verbose, 0, + "verbose output.", (uchar**) &verbose, (uchar**) &verbose, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -673,7 +673,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), if (argument) { char *start= argument; - my_free((gptr)opt_password, MYF(MY_ALLOW_ZERO_PTR)); + my_free(opt_password, MYF(MY_ALLOW_ZERO_PTR)); opt_password= my_strdup(argument,MYF(MY_FAE)); while (*argument) *argument++= 'x'; /* Destroy argument */ if (*start) @@ -1312,7 +1312,7 @@ get_options(int *argc,char ***argv) tmp_string[sbuf.st_size]= '\0'; my_close(data_file,MYF(0)); parse_delimiter(tmp_string, &create_statements, delimiter[0]); - my_free((gptr)tmp_string, MYF(0)); + my_free(tmp_string, MYF(0)); } else if (create_string) { @@ -1341,7 +1341,7 @@ get_options(int *argc,char ***argv) if (user_supplied_query) actual_queries= parse_delimiter(tmp_string, &query_statements, delimiter[0]); - my_free((gptr)tmp_string, MYF(0)); + my_free(tmp_string, MYF(0)); } else if (user_supplied_query) { @@ -1372,11 +1372,12 @@ get_options(int *argc,char ***argv) if (user_supplied_pre_statements) actual_queries= parse_delimiter(tmp_string, &pre_statements, delimiter[0]); - my_free((gptr)tmp_string, MYF(0)); + my_free(tmp_string, MYF(0)); } else if (user_supplied_pre_statements) { - actual_queries= parse_delimiter(user_supplied_pre_statements, &pre_statements, + actual_queries= parse_delimiter(user_supplied_pre_statements, + &pre_statements, delimiter[0]); } @@ -1402,7 +1403,7 @@ get_options(int *argc,char ***argv) if (user_supplied_post_statements) parse_delimiter(tmp_string, &post_statements, delimiter[0]); - my_free((gptr)tmp_string, MYF(0)); + my_free(tmp_string, MYF(0)); } else if (user_supplied_post_statements) { @@ -1499,9 +1500,9 @@ drop_primary_key_list(void) if (primary_keys_number_of) { for (counter= 0; counter < primary_keys_number_of; counter++) - my_free((gptr)primary_keys[counter], MYF(0)); + my_free(primary_keys[counter], MYF(0)); - my_free((gptr)primary_keys, MYF(0)); + my_free(primary_keys, MYF(0)); } return 0; @@ -2080,10 +2081,10 @@ option_cleanup(option_string *stmt) { nptr= ptr->next; if (ptr->string) - my_free((gptr)ptr->string, MYF(0)); + my_free(ptr->string, MYF(0)); if (ptr->option) - my_free((gptr)ptr->option, MYF(0)); - my_free((gptr)(byte *)ptr, MYF(0)); + my_free(ptr->option, MYF(0)); + my_free(ptr, MYF(0)); } } @@ -2098,7 +2099,7 @@ statement_cleanup(statement *stmt) { nptr= ptr->next; if (ptr->string) - my_free((gptr)ptr->string, MYF(0)); - my_free((gptr)(byte *)ptr, MYF(0)); + my_free(ptr->string, MYF(0)); + my_free(ptr, MYF(0)); } } diff --git a/client/mysqltest.c b/client/mysqltest.c index 1ba20c8929f..50080636054 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -747,7 +747,7 @@ void close_files() DBUG_PRINT("info", ("closing file: %s", cur_file->file_name)); my_fclose(cur_file->file, MYF(0)); } - my_free((gptr)cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR)); + my_free((uchar*) cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR)); cur_file->file_name= 0; } DBUG_VOID_RETURN; @@ -766,8 +766,8 @@ void free_used_memory() for (i= 0 ; i < q_lines.elements ; i++) { struct st_command **q= dynamic_element(&q_lines, i, struct st_command**); - my_free((gptr) (*q)->query_buf,MYF(MY_ALLOW_ZERO_PTR)); - my_free((gptr) (*q),MYF(0)); + my_free((*q)->query_buf,MYF(MY_ALLOW_ZERO_PTR)); + my_free((*q),MYF(0)); } for (i= 0; i < 10; i++) { @@ -1014,7 +1014,7 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname) if (!eval_result && (uint) stat_info.st_size != ds->length) { DBUG_PRINT("info",("Size differs: result size: %u file size: %lu", - ds->length, (ulong) stat_info.st_size)); + (uint) ds->length, (ulong) stat_info.st_size)); DBUG_PRINT("info",("result: '%s'", ds->str)); DBUG_RETURN(RESULT_LENGTH_MISMATCH); } @@ -1023,7 +1023,7 @@ int dyn_string_cmp(DYNAMIC_STRING* ds, const char *fname) if ((fd = my_open(eval_file, O_RDONLY, MYF(MY_WME))) < 0) die("Failed to open file %s", eval_file); - if (my_read(fd, (byte*)tmp, stat_info.st_size, MYF(MY_WME|MY_NABP))) + if (my_read(fd, (uchar*)tmp, stat_info.st_size, MYF(MY_WME|MY_NABP))) die("Failed to read from file %s, errno: %d", eval_file, errno); tmp[stat_info.st_size] = 0; init_dynamic_string(&res_ds, "", stat_info.st_size+256, 256); @@ -1054,7 +1054,7 @@ err: res_ptr, res_len); dynstr_free(&res_ds); - my_free((gptr) tmp, MYF(0)); + my_free(tmp, MYF(0)); my_close(fd, MYF(MY_WME)); DBUG_RETURN(res); @@ -1127,13 +1127,13 @@ void check_require(DYNAMIC_STRING* ds, const char *fname) } -static byte *get_var_key(const byte* var, uint* len, - my_bool __attribute__((unused)) t) +static uchar *get_var_key(const uchar* var, size_t *len, + my_bool __attribute__((unused)) t) { register char* key; key = ((VAR*)var)->name; *len = ((VAR*)var)->name_len; - return (byte*)key; + return (uchar*)key; } @@ -1177,7 +1177,7 @@ void var_free(void *v) { my_free(((VAR*) v)->str_val, MYF(MY_WME)); if (((VAR*)v)->alloced) - my_free((char*) v, MYF(MY_WME)); + my_free(v, MYF(MY_WME)); } @@ -1189,7 +1189,7 @@ VAR* var_from_env(const char *name, const char *def_val) tmp = def_val; v = var_init(0, name, strlen(name), tmp, strlen(tmp)); - my_hash_insert(&var_hash, (byte*)v); + my_hash_insert(&var_hash, (uchar*)v); return v; } @@ -1222,7 +1222,8 @@ VAR* var_get(const char *var_name, const char **var_name_end, my_bool raw, if (length >= MAX_VAR_NAME_LENGTH) die("Too long variable name: %s", save_var_name); - if (!(v = (VAR*) hash_search(&var_hash, save_var_name, length))) + if (!(v = (VAR*) hash_search(&var_hash, (const uchar*) save_var_name, + length))) { char buff[MAX_VAR_NAME_LENGTH+1]; strmake(buff, save_var_name, length); @@ -1253,10 +1254,10 @@ err: VAR *var_obtain(const char *name, int len) { VAR* v; - if ((v = (VAR*)hash_search(&var_hash, name, len))) + if ((v = (VAR*)hash_search(&var_hash, (const uchar *) name, len))) return v; v = var_init(0, name, len, "", 0); - my_hash_insert(&var_hash, (byte*)v); + my_hash_insert(&var_hash, (uchar*)v); return v; } @@ -1308,7 +1309,7 @@ void var_set(const char *var_name, const char *var_name_end, if (!(v->env_s= my_strdup(buf, MYF(MY_WME)))) die("Out of memory"); putenv(v->env_s); - my_free((gptr)old_env_s, MYF(MY_ALLOW_ZERO_PTR)); + my_free(old_env_s, MYF(MY_ALLOW_ZERO_PTR)); } DBUG_VOID_RETURN; } @@ -1613,9 +1614,10 @@ FILE* my_popen(DYNAMIC_STRING *ds_cmd, const char *mode) static void init_builtin_echo(void) { #ifdef __WIN__ + size_t echo_length; /* Look for "echo.exe" in same dir as mysqltest was started from */ - dirname_part(builtin_echo, my_progname); + dirname_part(builtin_echo, my_progname, &echo_length); fn_format(builtin_echo, ".\\echo.exe", builtin_echo, "", MYF(MY_REPLACE_DIR)); @@ -2087,8 +2089,8 @@ void read_until_delimiter(DYNAMIC_STRING *ds, { char c; DBUG_ENTER("read_until_delimiter"); - DBUG_PRINT("enter", ("delimiter: %s, length: %d", - ds_delimiter->str, ds_delimiter->length)); + DBUG_PRINT("enter", ("delimiter: %s, length: %u", + ds_delimiter->str, (uint) ds_delimiter->length)); if (ds_delimiter->length > MAX_DELIMITER_LENGTH) die("Max delimiter length(%d) exceeded", MAX_DELIMITER_LENGTH); @@ -2246,7 +2248,7 @@ void do_cat_file(struct st_command *command) if ((fd= my_open(ds_filename.str, O_RDONLY, MYF(0))) < 0) die("Failed to open file %s", ds_filename.str); - while((len= my_read(fd, (byte*)&buff, + while((len= my_read(fd, (uchar*)&buff, sizeof(buff), MYF(0))) > 0) { char *p= buff, *start= buff; @@ -2314,10 +2316,10 @@ void do_diff_files(struct st_command *command) my_close(fd, MYF(0)); die("Failed to open second file %s", ds_filename2.str); } - while((len= my_read(fd, (byte*)&buff, + while((len= my_read(fd, (uchar*)&buff, sizeof(buff), MYF(0))) > 0) { - if ((len2= my_read(fd2, (byte*)&buff2, + if ((len2= my_read(fd2, (uchar*)&buff2, sizeof(buff2), MYF(0))) != len) { /* File 2 was smaller */ @@ -2331,7 +2333,7 @@ void do_diff_files(struct st_command *command) break; } } - if (my_read(fd2, (byte*)&buff2, + if (my_read(fd2, (uchar*)&buff2, sizeof(buff2), MYF(0)) > 0) { /* File 1 was smaller */ @@ -3819,7 +3821,7 @@ int read_line(char *buf, int size) my_fclose(cur_file->file, MYF(0)); cur_file->file= 0; } - my_free((gptr)cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR)); + my_free((uchar*) cur_file->file_name, MYF(MY_ALLOW_ZERO_PTR)); cur_file->file_name= 0; if (cur_file == file_stack) { @@ -4172,12 +4174,12 @@ int read_command(struct st_command** command_ptr) if (parser.current_line < parser.read_lines) { - get_dynamic(&q_lines, (gptr) command_ptr, parser.current_line) ; + get_dynamic(&q_lines, (uchar*) command_ptr, parser.current_line) ; DBUG_RETURN(0); } if (!(*command_ptr= command= (struct st_command*) my_malloc(sizeof(*command), MYF(MY_WME))) || - insert_dynamic(&q_lines, (gptr) &command)) + insert_dynamic(&q_lines, (uchar*) &command)) die(NullS); command->require_file[0]= 0; @@ -4233,18 +4235,18 @@ static struct my_option my_long_options[] = { {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"basedir", 'b', "Basedir for tests.", (gptr*) &opt_basedir, - (gptr*) &opt_basedir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"basedir", 'b', "Basedir for tests.", (uchar**) &opt_basedir, + (uchar**) &opt_basedir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are.", (gptr*) &opt_charsets_dir, - (gptr*) &opt_charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Directory where character sets are.", (uchar**) &opt_charsets_dir, + (uchar**) &opt_charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"compress", 'C', "Use the compressed server/client protocol.", - (gptr*) &opt_compress, (gptr*) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, + (uchar**) &opt_compress, (uchar**) &opt_compress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"cursor-protocol", OPT_CURSOR_PROTOCOL, "Use cursors for prepared statements.", - (gptr*) &cursor_protocol, (gptr*) &cursor_protocol, 0, + (uchar**) &cursor_protocol, (uchar**) &cursor_protocol, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"database", 'D', "Database to use.", (gptr*) &opt_db, (gptr*) &opt_db, 0, + {"database", 'D', "Database to use.", (uchar**) &opt_db, (uchar**) &opt_db, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef DBUG_OFF {"debug", '#', "This is a non-debug version. Catch this and exit", @@ -4253,51 +4255,51 @@ static struct my_option my_long_options[] = {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"host", 'h', "Connect to host.", (gptr*) &opt_host, (gptr*) &opt_host, 0, + {"host", 'h', "Connect to host.", (uchar**) &opt_host, (uchar**) &opt_host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"include", 'i', "Include SQL before each test case.", (gptr*) &opt_include, - (gptr*) &opt_include, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"logdir", OPT_LOG_DIR, "Directory for log files", (gptr*) &opt_logdir, - (gptr*) &opt_logdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"include", 'i', "Include SQL before each test case.", (uchar**) &opt_include, + (uchar**) &opt_include, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"logdir", OPT_LOG_DIR, "Directory for log files", (uchar**) &opt_logdir, + (uchar**) &opt_logdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"mark-progress", OPT_MARK_PROGRESS, "Write linenumber and elapsed time to <testname>.progress ", - (gptr*) &opt_mark_progress, (gptr*) &opt_mark_progress, 0, + (uchar**) &opt_mark_progress, (uchar**) &opt_mark_progress, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"max-connect-retries", OPT_MAX_CONNECT_RETRIES, "Max number of connection attempts when connecting to server", - (gptr*) &opt_max_connect_retries, (gptr*) &opt_max_connect_retries, 0, + (uchar**) &opt_max_connect_retries, (uchar**) &opt_max_connect_retries, 0, GET_INT, REQUIRED_ARG, 500, 1, 10000, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Port number to use for connection.", (gptr*) &opt_port, - (gptr*) &opt_port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"port", 'P', "Port number to use for connection.", (uchar**) &opt_port, + (uchar**) &opt_port, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"ps-protocol", OPT_PS_PROTOCOL, "Use prepared statements protocol for communication", - (gptr*) &ps_protocol, (gptr*) &ps_protocol, 0, + (uchar**) &ps_protocol, (uchar**) &ps_protocol, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"quiet", 's', "Suppress all normal output.", (gptr*) &silent, - (gptr*) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"quiet", 's', "Suppress all normal output.", (uchar**) &silent, + (uchar**) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"record", 'r', "Record output of test_file into result file.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"result-file", 'R', "Read/Store result from/in this file.", - (gptr*) &result_file_name, (gptr*) &result_file_name, 0, + (uchar**) &result_file_name, (uchar**) &result_file_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"server-arg", 'A', "Send option value to embedded server as a parameter.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"server-file", 'F', "Read embedded server arguments from file.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"silent", 's', "Suppress all normal output. Synonym for --quiet.", - (gptr*) &silent, (gptr*) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + (uchar**) &silent, (uchar**) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"skip-safemalloc", OPT_SKIP_SAFEMALLOC, "Don't use the memory allocation checking.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"sleep", 'T', "Sleep always this many seconds on sleep commands.", - (gptr*) &opt_sleep, (gptr*) &opt_sleep, 0, GET_INT, REQUIRED_ARG, -1, 0, 0, + (uchar**) &opt_sleep, (uchar**) &opt_sleep, 0, GET_INT, REQUIRED_ARG, -1, 0, 0, 0, 0, 0}, {"socket", 'S', "Socket file to use for connection.", - (gptr*) &unix_sock, (gptr*) &unix_sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, + (uchar**) &unix_sock, (uchar**) &unix_sock, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"sp-protocol", OPT_SP_PROTOCOL, "Use stored procedures for select", - (gptr*) &sp_protocol, (gptr*) &sp_protocol, 0, + (uchar**) &sp_protocol, (uchar**) &sp_protocol, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #include "sslopt-longopts.h" {"test-file", 'x', "Read test from/in this file (default stdin).", @@ -4306,14 +4308,14 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"tmpdir", 't', "Temporary directory where sockets are put.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"user", 'u', "User for login.", (gptr*) &opt_user, (gptr*) &opt_user, 0, + {"user", 'u', "User for login.", (uchar**) &opt_user, (uchar**) &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"verbose", 'v', "Write more.", (gptr*) &verbose, (gptr*) &verbose, 0, + {"verbose", 'v', "Write more.", (uchar**) &verbose, (uchar**) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"view-protocol", OPT_VIEW_PROTOCOL, "Use views for select", - (gptr*) &view_protocol, (gptr*) &view_protocol, 0, + (uchar**) &view_protocol, (uchar**) &view_protocol, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -4529,7 +4531,7 @@ void str_to_file2(const char *fname, char *str, int size, my_bool append) die("Could not open %s: errno = %d", buff, errno); if (append && my_seek(fd, 0, SEEK_END, MYF(0)) == MY_FILEPOS_ERROR) die("Could not find end of file %s: errno = %d", buff, errno); - if (my_write(fd, (byte*)str, size, MYF(MY_WME|MY_FNABP))) + if (my_write(fd, (uchar*)str, size, MYF(MY_WME|MY_FNABP))) die("write failed"); my_close(fd, MYF(0)); } @@ -4646,7 +4648,7 @@ void init_win_path_patterns() continue; } - if (insert_dynamic(&patterns, (gptr) &p)) + if (insert_dynamic(&patterns, (uchar*) &p)) die(NullS); DBUG_PRINT("info", ("p: %s", p)); @@ -4666,7 +4668,7 @@ void free_win_path_patterns() for (i=0 ; i < patterns.elements ; i++) { const char** pattern= dynamic_element(&patterns, i, const char**); - my_free((gptr) *pattern, MYF(0)); + my_free((char*) *pattern, MYF(0)); } delete_dynamic(&patterns); } @@ -4848,12 +4850,12 @@ void append_stmt_result(DYNAMIC_STRING *ds, MYSQL_STMT *stmt, for (i= 0; i < num_fields; i++) { /* Free data for output */ - my_free((gptr)my_bind[i].buffer, MYF(MY_WME | MY_FAE)); + my_free(my_bind[i].buffer, MYF(MY_WME | MY_FAE)); } /* Free array with bind structs, lengths and NULL flags */ - my_free((gptr)my_bind , MYF(MY_WME | MY_FAE)); - my_free((gptr)length , MYF(MY_WME | MY_FAE)); - my_free((gptr)is_null , MYF(MY_WME | MY_FAE)); + my_free(my_bind , MYF(MY_WME | MY_FAE)); + my_free(length , MYF(MY_WME | MY_FAE)); + my_free(is_null , MYF(MY_WME | MY_FAE)); } @@ -6561,15 +6563,15 @@ void free_replace_column() typedef struct st_pointer_array { /* when using array-strings */ TYPELIB typelib; /* Pointer to strings */ - byte *str; /* Strings is here */ + uchar *str; /* Strings is here */ int7 *flag; /* Flag about each var. */ uint array_allocs,max_count,length,max_length; } POINTER_ARRAY; struct st_replace; -struct st_replace *init_replace(my_string *from, my_string *to, uint count, - my_string word_end_chars); -int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name); +struct st_replace *init_replace(char * *from, char * *to, uint count, + char * word_end_chars); +int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name); void replace_strings_append(struct st_replace *rep, DYNAMIC_STRING* ds, const char *from, int len); void free_pointer_array(POINTER_ARRAY *pa); @@ -6633,7 +6635,7 @@ void free_replace() DBUG_ENTER("free_replace"); if (glob_replace) { - my_free((char*) glob_replace,MYF(0)); + my_free(glob_replace,MYF(0)); glob_replace=0; } DBUG_VOID_RETURN; @@ -6844,7 +6846,7 @@ struct st_replace_regex* init_replace_regex(char* expr) reg.icase= 1; /* done parsing the statement, now place it in regex_arr */ - if (insert_dynamic(&res->regex_arr,(gptr) ®)) + if (insert_dynamic(&res->regex_arr,(uchar*) ®)) die("Out of memory"); } res->odd_buf_len= res->even_buf_len= 8192; @@ -6855,7 +6857,7 @@ struct st_replace_regex* init_replace_regex(char* expr) return res; err: - my_free((gptr)res,0); + my_free(res,0); die("Error parsing replace_regex \"%s\"", expr); return 0; } @@ -6896,7 +6898,7 @@ int multi_reg_replace(struct st_replace_regex* r,char* val) struct st_regex re; char* save_out_buf= out_buf; - get_dynamic(&r->regex_arr,(gptr)&re,i); + get_dynamic(&r->regex_arr,(uchar*)&re,i); if (!reg_replace(&out_buf, buf_len_p, re.pattern, re.replace, in_buf, re.icase)) @@ -6949,7 +6951,7 @@ void free_replace_regex() delete_dynamic(&glob_replace_regex->regex_arr); my_free(glob_replace_regex->even_buf,MYF(MY_ALLOW_ZERO_PTR)); my_free(glob_replace_regex->odd_buf,MYF(MY_ALLOW_ZERO_PTR)); - my_free((char*) glob_replace_regex,MYF(0)); + my_free(glob_replace_regex,MYF(0)); glob_replace_regex=0; } } @@ -7144,7 +7146,7 @@ int reg_replace(char** buf_p, int* buf_len_p, char *pattern, str_p= str_end; } } - my_free((gptr)subs, MYF(0)); + my_free(subs, MYF(0)); my_regfree(&r); *res_p= 0; *buf_p= buf; @@ -7204,13 +7206,13 @@ int get_next_bit(REP_SET *set,uint lastpos); int find_set(REP_SETS *sets,REP_SET *find); int find_found(FOUND_SET *found_set,uint table_offset, int found_offset); -uint start_at_word(my_string pos); -uint end_of_word(my_string pos); +uint start_at_word(char * pos); +uint end_of_word(char * pos); static uint found_sets=0; -uint replace_len(my_string str) +uint replace_len(char * str) { uint len=0; while (*str) @@ -7225,8 +7227,8 @@ uint replace_len(my_string str) /* Init a replace structure for further calls */ -REPLACE *init_replace(my_string *from, my_string *to,uint count, - my_string word_end_chars) +REPLACE *init_replace(char * *from, char * *to,uint count, + char * word_end_chars) { static const int SPACE_CHAR= 256; static const int START_OF_LINE= 257; @@ -7235,7 +7237,7 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count, uint i,j,states,set_nr,len,result_len,max_length,found_end,bits_set,bit_nr; int used_sets,chr,default_state; char used_chars[LAST_CHAR_CODE],is_word_end[256]; - my_string pos,to_pos,*to_array; + char * pos, *to_pos, **to_array; REP_SETS sets; REP_SET *set,*start_states,*word_states,*new_set; FOLLOWS *follow,*follow_ptr; @@ -7280,7 +7282,7 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count, if (!(follow=(FOLLOWS*) my_malloc((states+2)*sizeof(FOLLOWS),MYF(MY_WME)))) { free_sets(&sets); - my_free((gptr) found_set,MYF(0)); + my_free(found_set,MYF(0)); DBUG_RETURN(0); } @@ -7471,12 +7473,12 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count, if ((replace=(REPLACE*) my_malloc(sizeof(REPLACE)*(sets.count)+ sizeof(REPLACE_STRING)*(found_sets+1)+ - sizeof(my_string)*count+result_len, + sizeof(char *)*count+result_len, MYF(MY_WME | MY_ZEROFILL)))) { rep_str=(REPLACE_STRING*) (replace+sets.count); - to_array=(my_string*) (rep_str+found_sets+1); - to_pos=(my_string) (to_array+count); + to_array= (char **) (rep_str+found_sets+1); + to_pos=(char *) (to_array+count); for (i=0 ; i < count ; i++) { to_array[i]=to_pos; @@ -7487,7 +7489,8 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count, for (i=1 ; i <= found_sets ; i++) { pos=from[found_set[i-1].table_offset]; - rep_str[i].found= !bcmp(pos,"\\^",3) ? 2 : 1; + rep_str[i].found= !bcmp((const uchar*) pos, + (const uchar*) "\\^", 3) ? 2 : 1; rep_str[i].replace_string=to_array[found_set[i-1].table_offset]; rep_str[i].to_offset=found_set[i-1].found_offset-start_at_word(pos); rep_str[i].from_offset=found_set[i-1].found_offset-replace_len(pos)+ @@ -7502,9 +7505,9 @@ REPLACE *init_replace(my_string *from, my_string *to,uint count, replace[i].next[j]=(REPLACE*) (rep_str+(-sets.set[i].next[j]-1)); } } - my_free((gptr) follow,MYF(0)); + my_free(follow,MYF(0)); free_sets(&sets); - my_free((gptr) found_set,MYF(0)); + my_free(found_set,MYF(0)); DBUG_PRINT("exit",("Replace table has %d states",sets.count)); DBUG_RETURN(replace); } @@ -7520,7 +7523,7 @@ int init_sets(REP_SETS *sets,uint states) if (!(sets->bit_buffer=(uint*) my_malloc(sizeof(uint)*sets->size_of_bits* SET_MALLOC_HUNC,MYF(MY_WME)))) { - my_free((gptr) sets->set,MYF(0)); + my_free(sets->set,MYF(0)); return 1; } return 0; @@ -7552,13 +7555,13 @@ REP_SET *make_new_set(REP_SETS *sets) return set; } count=sets->count+sets->invisible+SET_MALLOC_HUNC; - if (!(set=(REP_SET*) my_realloc((gptr) sets->set_buffer, + if (!(set=(REP_SET*) my_realloc((uchar*) sets->set_buffer, sizeof(REP_SET)*count, MYF(MY_WME)))) return 0; sets->set_buffer=set; sets->set=set+sets->invisible; - if (!(bit_buffer=(uint*) my_realloc((gptr) sets->bit_buffer, + if (!(bit_buffer=(uint*) my_realloc((uchar*) sets->bit_buffer, (sizeof(uint)*sets->size_of_bits)*count, MYF(MY_WME)))) return 0; @@ -7581,8 +7584,8 @@ void free_last_set(REP_SETS *sets) void free_sets(REP_SETS *sets) { - my_free((gptr)sets->set_buffer,MYF(0)); - my_free((gptr)sets->bit_buffer,MYF(0)); + my_free(sets->set_buffer,MYF(0)); + my_free(sets->bit_buffer,MYF(0)); return; } @@ -7609,13 +7612,13 @@ void or_bits(REP_SET *to,REP_SET *from) void copy_bits(REP_SET *to,REP_SET *from) { - memcpy((byte*) to->bits,(byte*) from->bits, + memcpy((uchar*) to->bits,(uchar*) from->bits, (size_t) (sizeof(uint) * to->size_of_bits)); } int cmp_bits(REP_SET *set1,REP_SET *set2) { - return bcmp((byte*) set1->bits,(byte*) set2->bits, + return bcmp((uchar*) set1->bits,(uchar*) set2->bits, sizeof(uint) * set1->size_of_bits); } @@ -7683,17 +7686,19 @@ int find_found(FOUND_SET *found_set,uint table_offset, int found_offset) /* Return 1 if regexp starts with \b or ends with \b*/ -uint start_at_word(my_string pos) +uint start_at_word(char * pos) { - return (((!bcmp(pos,"\\b",2) && pos[2]) || !bcmp(pos,"\\^",2)) ? 1 : 0); + return (((!bcmp((const uchar*) pos, (const uchar*) "\\b",2) && pos[2]) || + !bcmp((const uchar*) pos, (const uchar*) "\\^", 2)) ? 1 : 0); } -uint end_of_word(my_string pos) +uint end_of_word(char * pos) { - my_string end=strend(pos); - return ((end > pos+2 && !bcmp(end-2,"\\b",2)) || - (end >= pos+2 && !bcmp(end-2,"\\$",2))) ? - 1 : 0; + char * end=strend(pos); + return ((end > pos+2 && !bcmp((const uchar*) end-2, + (const uchar*) "\\b", 2)) || + (end >= pos+2 && !bcmp((const uchar*) end-2, + (const uchar*) "\\$",2))) ? 1 : 0; } /**************************************************************************** @@ -7703,10 +7708,10 @@ uint end_of_word(my_string pos) #define PC_MALLOC 256 /* Bytes for pointers */ #define PS_MALLOC 512 /* Bytes for data */ -int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name) +int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name) { uint i,length,old_count; - byte *new_pos; + uchar *new_pos; const char **new_array; DBUG_ENTER("insert_pointer_name"); @@ -7714,16 +7719,16 @@ int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name) { if (!(pa->typelib.type_names=(const char **) my_malloc(((PC_MALLOC-MALLOC_OVERHEAD)/ - (sizeof(my_string)+sizeof(*pa->flag))* - (sizeof(my_string)+sizeof(*pa->flag))),MYF(MY_WME)))) + (sizeof(char *)+sizeof(*pa->flag))* + (sizeof(char *)+sizeof(*pa->flag))),MYF(MY_WME)))) DBUG_RETURN(-1); - if (!(pa->str= (byte*) my_malloc((uint) (PS_MALLOC-MALLOC_OVERHEAD), + if (!(pa->str= (uchar*) my_malloc((uint) (PS_MALLOC-MALLOC_OVERHEAD), MYF(MY_WME)))) { - my_free((gptr) pa->typelib.type_names,MYF(0)); + my_free((char*) pa->typelib.type_names,MYF(0)); DBUG_RETURN (-1); } - pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(byte*)+ + pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(uchar*)+ sizeof(*pa->flag)); pa->flag= (int7*) (pa->typelib.type_names+pa->max_count); pa->length=0; @@ -7733,7 +7738,7 @@ int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name) length=(uint) strlen(name)+1; if (pa->length+length >= pa->max_length) { - if (!(new_pos= (byte*) my_realloc((gptr) pa->str, + if (!(new_pos= (uchar*) my_realloc((uchar*) pa->str, (uint) (pa->max_length+PS_MALLOC), MYF(MY_WME)))) DBUG_RETURN(1); @@ -7752,23 +7757,23 @@ int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name) int len; pa->array_allocs++; len=(PC_MALLOC*pa->array_allocs - MALLOC_OVERHEAD); - if (!(new_array=(const char **) my_realloc((gptr) pa->typelib.type_names, + if (!(new_array=(const char **) my_realloc((uchar*) pa->typelib.type_names, (uint) len/ - (sizeof(byte*)+sizeof(*pa->flag))* - (sizeof(byte*)+sizeof(*pa->flag)), + (sizeof(uchar*)+sizeof(*pa->flag))* + (sizeof(uchar*)+sizeof(*pa->flag)), MYF(MY_WME)))) DBUG_RETURN(1); pa->typelib.type_names=new_array; old_count=pa->max_count; - pa->max_count=len/(sizeof(byte*) + sizeof(*pa->flag)); + pa->max_count=len/(sizeof(uchar*) + sizeof(*pa->flag)); pa->flag= (int7*) (pa->typelib.type_names+pa->max_count); - memcpy((byte*) pa->flag,(my_string) (pa->typelib.type_names+old_count), + memcpy((uchar*) pa->flag,(char *) (pa->typelib.type_names+old_count), old_count*sizeof(*pa->flag)); } pa->flag[pa->typelib.count]=0; /* Reset flag */ - pa->typelib.type_names[pa->typelib.count++]= pa->str+pa->length; + pa->typelib.type_names[pa->typelib.count++]= (char*) pa->str+pa->length; pa->typelib.type_names[pa->typelib.count]= NullS; /* Put end-mark */ - VOID(strmov(pa->str+pa->length,name)); + VOID(strmov((char*) pa->str+pa->length,name)); pa->length+=length; DBUG_RETURN(0); } /* insert_pointer_name */ @@ -7781,9 +7786,9 @@ void free_pointer_array(POINTER_ARRAY *pa) if (pa->typelib.count) { pa->typelib.count=0; - my_free((gptr) pa->typelib.type_names,MYF(0)); + my_free((char*) pa->typelib.type_names,MYF(0)); pa->typelib.type_names=0; - my_free((gptr) pa->str,MYF(0)); + my_free(pa->str,MYF(0)); } } /* free_pointer_array */ @@ -7880,7 +7885,7 @@ void dynstr_append_sorted(DYNAMIC_STRING* ds, DYNAMIC_STRING *ds_input) *line_end= 0; /* Insert pointer to the line in array */ - if (insert_dynamic(&lines, (gptr) &start)) + if (insert_dynamic(&lines, (uchar*) &start)) die("Out of memory inserting lines to sort"); start= line_end+1; diff --git a/client/readline.cc b/client/readline.cc index ad42ed2ee10..7afdbc9531e 100644 --- a/client/readline.cc +++ b/client/readline.cc @@ -22,8 +22,8 @@ static bool init_line_buffer(LINE_BUFFER *buffer,File file,ulong size, ulong max_size); -static bool init_line_buffer_from_string(LINE_BUFFER *buffer,my_string str); -static uint fill_buffer(LINE_BUFFER *buffer); +static bool init_line_buffer_from_string(LINE_BUFFER *buffer,char * str); +static size_t fill_buffer(LINE_BUFFER *buffer); static char *intern_read_line(LINE_BUFFER *buffer,ulong *out_length); @@ -35,7 +35,7 @@ LINE_BUFFER *batch_readline_init(ulong max_size,FILE *file) return 0; if (init_line_buffer(line_buff,fileno(file),IO_SIZE,max_size)) { - my_free((char*) line_buff,MYF(0)); + my_free(line_buff,MYF(0)); return 0; } return line_buff; @@ -62,13 +62,13 @@ void batch_readline_end(LINE_BUFFER *line_buff) { if (line_buff) { - my_free((gptr) line_buff->buffer,MYF(MY_ALLOW_ZERO_PTR)); - my_free((char*) line_buff,MYF(0)); + my_free(line_buff->buffer,MYF(MY_ALLOW_ZERO_PTR)); + my_free(line_buff,MYF(0)); } } -LINE_BUFFER *batch_readline_command(LINE_BUFFER *line_buff, my_string str) +LINE_BUFFER *batch_readline_command(LINE_BUFFER *line_buff, char * str) { if (!line_buff) if (!(line_buff=(LINE_BUFFER*) @@ -76,7 +76,7 @@ LINE_BUFFER *batch_readline_command(LINE_BUFFER *line_buff, my_string str) return 0; if (init_line_buffer_from_string(line_buff,str)) { - my_free((char*) line_buff,MYF(0)); + my_free(line_buff,MYF(0)); return 0; } return line_buff; @@ -106,13 +106,13 @@ init_line_buffer(LINE_BUFFER *buffer,File file,ulong size,ulong max_buffer) several times. the resulting buffer will contain a concatenation of all strings separated by spaces */ -static bool init_line_buffer_from_string(LINE_BUFFER *buffer,my_string str) +static bool init_line_buffer_from_string(LINE_BUFFER *buffer,char * str) { uint old_length=(uint)(buffer->end - buffer->buffer); uint length= (uint) strlen(str); if (!(buffer->buffer= buffer->start_of_line= buffer->end_of_line= - (char*)my_realloc(buffer->buffer, old_length+length+2, - MYF(MY_FAE|MY_ALLOW_ZERO_PTR)))) + (char*) my_realloc((uchar*) buffer->buffer, old_length+length+2, + MYF(MY_FAE|MY_ALLOW_ZERO_PTR)))) return 1; buffer->end= buffer->buffer + old_length; if (old_length) @@ -133,9 +133,9 @@ static bool init_line_buffer_from_string(LINE_BUFFER *buffer,my_string str) bytes read from disk. */ -static uint fill_buffer(LINE_BUFFER *buffer) +static size_t fill_buffer(LINE_BUFFER *buffer) { - uint read_count; + size_t read_count; uint bufbytes= (uint) (buffer->end - buffer->start_of_line); if (buffer->eof) @@ -166,11 +166,11 @@ static uint fill_buffer(LINE_BUFFER *buffer) } /* Read in new stuff. */ - if ((read_count= my_read(buffer->file, (byte*) buffer->end, read_count, + if ((read_count= my_read(buffer->file, (uchar*) buffer->end, read_count, MYF(MY_WME))) == MY_FILE_ERROR) - return read_count; + return (size_t) -1; - DBUG_PRINT("fill_buff", ("Got %d bytes", read_count)); + DBUG_PRINT("fill_buff", ("Got %lu bytes", (ulong) read_count)); /* Kludge to pretend every nonempty file ends with a newline. */ if (!read_count && bufbytes && buffer->end[-1] != '\n') @@ -189,7 +189,7 @@ static uint fill_buffer(LINE_BUFFER *buffer) char *intern_read_line(LINE_BUFFER *buffer,ulong *out_length) { char *pos; - uint length; + size_t length; DBUG_ENTER("intern_read_line"); buffer->start_of_line=buffer->end_of_line; @@ -202,7 +202,7 @@ char *intern_read_line(LINE_BUFFER *buffer,ulong *out_length) { if ((uint) (pos - buffer->start_of_line) < buffer->max_size) { - if (!(length=fill_buffer(buffer)) || length == (uint) -1) + if (!(length=fill_buffer(buffer)) || length == (size_t) -1) DBUG_RETURN(0); continue; } diff --git a/client/sql_string.cc b/client/sql_string.cc index 9d887ff031c..57a5df7ce96 100644 --- a/client/sql_string.cc +++ b/client/sql_string.cc @@ -32,7 +32,7 @@ required by the string function */ -extern gptr sql_alloc(unsigned size); +extern void sql_alloc(size_t size); extern void sql_element_free(void *ptr); #include "sql_string.h" @@ -506,7 +506,7 @@ bool String::append(FILE* file, uint32 arg_length, myf my_flags) { if (realloc(str_length+arg_length)) return TRUE; - if (my_fread(file, (byte*) Ptr + str_length, arg_length, my_flags)) + if (my_fread(file, (uchar*) Ptr + str_length, arg_length, my_flags)) { shrink(str_length); return TRUE; @@ -520,7 +520,7 @@ bool String::append(IO_CACHE* file, uint32 arg_length) { if (realloc(str_length+arg_length)) return TRUE; - if (my_b_read(file, (byte*) Ptr + str_length, arg_length)) + if (my_b_read(file, (uchar*) Ptr + str_length, arg_length)) { shrink(str_length); return TRUE; @@ -645,7 +645,7 @@ bool String::replace(uint32 offset,uint32 arg_length, { if (realloc(str_length+(uint32) diff)) return TRUE; - bmove_upp(Ptr+str_length+diff,Ptr+str_length, + bmove_upp((uchar*) Ptr+str_length+diff, (uchar*) Ptr+str_length, str_length-offset-arg_length); } if (to_length) diff --git a/dbug/dbug.c b/dbug/dbug.c index e482fd95073..83c9ea37de1 100644 --- a/dbug/dbug.c +++ b/dbug/dbug.c @@ -264,7 +264,7 @@ static BOOLEAN DoTrace(CODE_STATE *cs); /* Test to see if file is writable */ #if !(!defined(HAVE_ACCESS) || defined(MSDOS)) -static BOOLEAN Writable(char *pathname); +static BOOLEAN Writable(const char *pathname); /* Change file owner and group */ static void ChangeOwner(CODE_STATE *cs, char *pathname); /* Allocate memory for runtime support */ @@ -343,12 +343,12 @@ static CODE_STATE *code_state(void) if (!(cs=(CODE_STATE *) tmp->dbug)) { cs=(CODE_STATE*) DbugMalloc(sizeof(*cs)); - bzero((char*) cs,sizeof(*cs)); + bzero((uchar*) cs,sizeof(*cs)); cs->process= db_process ? db_process : "dbug"; cs->func="?func"; cs->file="?file"; cs->stack=&init_settings; - tmp->dbug=(gptr) cs; + tmp->dbug= (void*) cs; } } return cs; @@ -715,7 +715,7 @@ void _db_push_(const char *control) void _db_set_init_(const char *control) { CODE_STATE tmp_cs; - bzero((char*) &tmp_cs, sizeof(tmp_cs)); + bzero((uchar*) &tmp_cs, sizeof(tmp_cs)); tmp_cs.stack= &init_settings; _db_set_(&tmp_cs, control); } @@ -830,7 +830,7 @@ void _db_pop_() } \ } while (0) -int _db_explain_ (CODE_STATE *cs, char *buf, int len) +int _db_explain_ (CODE_STATE *cs, char *buf, size_t len) { char *start=buf, *end=buf+len-4; @@ -887,10 +887,10 @@ overflow: * see _db_explain_ */ -int _db_explain_init_(char *buf, int len) +int _db_explain_init_(char *buf, size_t len) { CODE_STATE cs; - bzero((char*) &cs,sizeof(cs)); + bzero((uchar*) &cs,sizeof(cs)); cs.stack=&init_settings; return _db_explain_(&cs, buf, len); } @@ -1083,7 +1083,7 @@ void _db_pargs_(uint _line_, const char *keyword) CODE_STATE *cs=0; get_code_state_or_return; cs->u_line= _line_; - cs->u_keyword= (char*) keyword; + cs->u_keyword= keyword; } @@ -1160,7 +1160,8 @@ void _db_doprnt_(const char *format,...) * Is used to examine corrputed memory or arrays. */ -void _db_dump_(uint _line_, const char *keyword, const char *memory, uint length) +void _db_dump_(uint _line_, const char *keyword, + const unsigned char *memory, size_t length) { int pos; char dbuff[90]; @@ -1168,7 +1169,7 @@ void _db_dump_(uint _line_, const char *keyword, const char *memory, uint length CODE_STATE *cs=0; get_code_state_or_return; - if (_db_keyword_(cs, (char*) keyword)) + if (_db_keyword_(cs, keyword)) { if (!cs->locked) pthread_mutex_lock(&THR_LOCK_dbug); @@ -1182,7 +1183,7 @@ void _db_dump_(uint _line_, const char *keyword, const char *memory, uint length { fprintf(cs->stack->out_file, "%s: ", cs->func); } - sprintf(dbuff,"%s: Memory: 0x%lx Bytes: (%d)\n", + sprintf(dbuff,"%s: Memory: 0x%lx Bytes: (%ld)\n", keyword,(ulong) memory, length); (void) fputs(dbuff,cs->stack->out_file); @@ -1292,7 +1293,7 @@ static struct link *ListDel(struct link *head, { struct link *delme=*cur; *cur=(*cur)->next_link; - free((char*)delme); + free((void*) delme); } } while (*cur && *(cur=&((*cur)->next_link))); } @@ -1451,7 +1452,7 @@ static void FreeState(CODE_STATE *cs, struct settings *state, int free_state) if (state->prof_file) DBUGCloseFile(cs, state->prof_file); if (free_state) - free((char *) state); + free((void*) state); } @@ -1696,7 +1697,7 @@ static void FreeList(struct link *linkp) { old= linkp; linkp= linkp->next_link; - free((char *) old); + free((void*) old); } } @@ -1815,7 +1816,7 @@ static void DBUGOpenFile(CODE_STATE *cs, } else { - if (!Writable((char*)name)) + if (!Writable(name)) { (void) fprintf(stderr, ERR_OPEN, cs->process, name); perror(""); @@ -1988,7 +1989,7 @@ static char *DbugMalloc(size_t size) { register char *new_malloc; - if (!(new_malloc= (char*) malloc((size_t) size))) + if (!(new_malloc= (char*) malloc(size))) DbugExit("out of memory"); return new_malloc; } @@ -2062,7 +2063,7 @@ static const char *BaseName(const char *pathname) #ifndef Writable -static BOOLEAN Writable(char *pathname) +static BOOLEAN Writable(const char *pathname) { REGISTER BOOLEAN granted; REGISTER char *lastslash; diff --git a/extra/comp_err.c b/extra/comp_err.c index 71009039bb4..3e540d8f481 100644 --- a/extra/comp_err.c +++ b/extra/comp_err.c @@ -99,31 +99,31 @@ static struct my_option my_long_options[]= {"debug", '#', "This is a non-debug version. Catch this and exit", 0, 0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, #else - {"debug", '#', "Output debug log", (gptr *) & default_dbug_option, - (gptr *) & default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"debug", '#', "Output debug log", (uchar**) & default_dbug_option, + (uchar**) & default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"debug-info", 'T', "Print some debug info at exit.", (gptr *) & info_flag, - (gptr *) & info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"debug-info", 'T', "Print some debug info at exit.", (uchar**) & info_flag, + (uchar**) & info_flag, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Displays this help and exits.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Prints version", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"charset", 'C', "Charset dir", (gptr *) & charsets_dir, - (gptr *) & charsets_dir, + {"charset", 'C', "Charset dir", (uchar**) & charsets_dir, + (uchar**) & charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"in_file", 'F', "Input file", (gptr *) & TXTFILE, (gptr *) & TXTFILE, + {"in_file", 'F', "Input file", (uchar**) & TXTFILE, (uchar**) & TXTFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"out_dir", 'D', "Output base directory", (gptr *) & DATADIRECTORY, - (gptr *) & DATADIRECTORY, + {"out_dir", 'D', "Output base directory", (uchar**) & DATADIRECTORY, + (uchar**) & DATADIRECTORY, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"out_file", 'O', "Output filename (errmsg.sys)", (gptr *) & OUTFILE, - (gptr *) & OUTFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"header_file", 'H', "mysqld_error.h file ", (gptr *) & HEADERFILE, - (gptr *) & HEADERFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"name_file", 'N', "mysqld_ername.h file ", (gptr *) & NAMEFILE, - (gptr *) & NAMEFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"state_file", 'S', "sql_state.h file", (gptr *) & STATEFILE, - (gptr *) & STATEFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"out_file", 'O', "Output filename (errmsg.sys)", (uchar**) & OUTFILE, + (uchar**) & OUTFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"header_file", 'H', "mysqld_error.h file ", (uchar**) & HEADERFILE, + (uchar**) & HEADERFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"name_file", 'N', "mysqld_ername.h file ", (uchar**) & NAMEFILE, + (uchar**) & NAMEFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"state_file", 'S', "sql_state.h file", (uchar**) & STATEFILE, + (uchar**) & STATEFILE, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -329,21 +329,21 @@ static int create_sys_files(struct languages *lang_head, /* continue with header of the errmsg.sys file */ length= ftell(to) - HEADER_LENGTH - row_count * 2; - bzero((gptr) head, HEADER_LENGTH); - bmove((byte *) head, (byte *) file_head, 4); + bzero((uchar*) head, HEADER_LENGTH); + bmove((uchar *) head, (uchar *) file_head, 4); head[4]= 1; int2store(head + 6, length); int2store(head + 8, row_count); head[30]= csnum; my_fseek(to, 0l, MY_SEEK_SET, MYF(0)); - if (my_fwrite(to, (byte*) head, HEADER_LENGTH, MYF(MY_WME | MY_FNABP))) + if (my_fwrite(to, (uchar*) head, HEADER_LENGTH, MYF(MY_WME | MY_FNABP))) goto err; for (i= 0; i < row_count; i++) { int2store(head, file_pos[i]); - if (my_fwrite(to, (byte*) head, 2, MYF(MY_WME | MY_FNABP))) + if (my_fwrite(to, (uchar*) head, 2, MYF(MY_WME | MY_FNABP))) goto err; } my_fclose(to, MYF(0)); @@ -362,7 +362,7 @@ static void clean_up(struct languages *lang_head, struct errors *error_head) struct errors *tmp_error, *next_error; uint count, i; - my_free((gptr) default_language, MYF(0)); + my_free((uchar*) default_language, MYF(0)); for (tmp_lang= lang_head; tmp_lang; tmp_lang= next_language) { @@ -370,7 +370,7 @@ static void clean_up(struct languages *lang_head, struct errors *error_head) my_free(tmp_lang->lang_short_name, MYF(0)); my_free(tmp_lang->lang_long_name, MYF(0)); my_free(tmp_lang->charset, MYF(0)); - my_free((gptr) tmp_lang, MYF(0)); + my_free((uchar*) tmp_lang, MYF(0)); } for (tmp_error= error_head; tmp_error; tmp_error= next_error) @@ -381,17 +381,17 @@ static void clean_up(struct languages *lang_head, struct errors *error_head) { struct message *tmp; tmp= dynamic_element(&tmp_error->msg, i, struct message*); - my_free((gptr) tmp->lang_short_name, MYF(0)); - my_free((gptr) tmp->text, MYF(0)); + my_free((uchar*) tmp->lang_short_name, MYF(0)); + my_free((uchar*) tmp->text, MYF(0)); } delete_dynamic(&tmp_error->msg); if (tmp_error->sql_code1[0]) - my_free((gptr) tmp_error->sql_code1, MYF(0)); + my_free((uchar*) tmp_error->sql_code1, MYF(0)); if (tmp_error->sql_code2[0]) - my_free((gptr) tmp_error->sql_code2, MYF(0)); - my_free((gptr) tmp_error->er_name, MYF(0)); - my_free((gptr) tmp_error, MYF(0)); + my_free((uchar*) tmp_error->sql_code2, MYF(0)); + my_free((uchar*) tmp_error->er_name, MYF(0)); + my_free((uchar*) tmp_error, MYF(0)); } } @@ -471,7 +471,7 @@ static int parse_input_file(const char *file_name, struct errors **top_error, current_error->er_name, current_message.lang_short_name); DBUG_RETURN(0); } - if (insert_dynamic(¤t_error->msg, (byte *) & current_message)) + if (insert_dynamic(¤t_error->msg, (uchar *) & current_message)) DBUG_RETURN(0); continue; } @@ -534,7 +534,7 @@ static uint parse_error_offset(char *str) end= 0; ioffset= (uint) my_strtoll10(soffset, &end, &error); - my_free((gptr) soffset, MYF(0)); + my_free((uchar*) soffset, MYF(0)); DBUG_RETURN(ioffset); } diff --git a/extra/innochecksum.c b/extra/innochecksum.c index 33f925a4cad..524637a1729 100644 --- a/extra/innochecksum.c +++ b/extra/innochecksum.c @@ -51,10 +51,10 @@ /* another argument to specify page ranges... seek to right spot and go from there */ typedef unsigned long int ulint; -typedef unsigned char byte; +typedef unsigned char uchar; /* innodb function in name; modified slightly to not have the ASM version (lots of #ifs that didn't apply) */ -ulint mach_read_from_4(byte *b) +ulint mach_read_from_4(uchar *b) { return( ((ulint)(b[0]) << 24) + ((ulint)(b[1]) << 16) @@ -78,7 +78,7 @@ ulint ut_fold_binary( /*===========*/ /* out: folded value */ - byte* str, /* in: string of bytes */ + uchar* str, /* in: string of bytes */ ulint len) /* in: length */ { ulint i; @@ -98,7 +98,7 @@ ulint buf_calc_page_new_checksum( /*=======================*/ /* out: checksum */ - byte* page) /* in: buffer page */ + uchar* page) /* in: buffer page */ { ulint checksum; @@ -123,7 +123,7 @@ ulint buf_calc_page_old_checksum( /*=======================*/ /* out: checksum */ - byte* page) /* in: buffer page */ + uchar* page) /* in: buffer page */ { ulint checksum; @@ -138,7 +138,7 @@ buf_calc_page_old_checksum( int main(int argc, char **argv) { FILE *f; /* our input file */ - byte *p; /* storage of pages read */ + uchar *p; /* storage of pages read */ int bytes; /* bytes read count */ ulint ct; /* current page number (0 based) */ int now; /* current time */ @@ -256,7 +256,7 @@ int main(int argc, char **argv) } /* allocate buffer for reading (so we don't realloc every time) */ - p= (byte *)malloc(UNIV_PAGE_SIZE); + p= (uchar *)malloc(UNIV_PAGE_SIZE); /* main checksumming loop */ ct= start_page; diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c index f5f7e68c9e6..06f7e51c380 100644 --- a/extra/my_print_defaults.c +++ b/extra/my_print_defaults.c @@ -47,30 +47,30 @@ static struct my_option my_long_options[] = added if the file has no extension) */ {"config-file", 'c', "Deprecated, please use --defaults-file instead. Name of config file to read; if no extension is given, default extension (e.g., .ini or .cnf) will be added", - (gptr*) &config_file, (gptr*) &config_file, 0, GET_STR, REQUIRED_ARG, + (uchar**) &config_file, (uchar**) &config_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef DBUG_OFF {"debug", '#', "This is a non-debug version. Catch this and exit", 0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, #else - {"debug", '#', "Output debug log", (gptr*) &default_dbug_option, - (gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"debug", '#', "Output debug log", (uchar**) &default_dbug_option, + (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif {"defaults-file", 'c', "Like --config-file, except: if first option, then read this file only, do not read global or per-user config files; should be the first option", - (gptr*) &config_file, (gptr*) &config_file, 0, GET_STR, REQUIRED_ARG, + (uchar**) &config_file, (uchar**) &config_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"defaults-extra-file", 'e', "Read this file after the global config file and before the config file in the users home directory; should be the first option", - (gptr*) &my_defaults_extra_file, (gptr*) &my_defaults_extra_file, 0, + (uchar**) &my_defaults_extra_file, (uchar**) &my_defaults_extra_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"defaults-group-suffix", 'g', "In addition to the given groups, read also groups with this suffix", - (gptr*) &my_defaults_group_suffix, (gptr*) &my_defaults_group_suffix, + (uchar**) &my_defaults_group_suffix, (uchar**) &my_defaults_group_suffix, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"extra-file", 'e', "Deprecated. Synonym for --defaults-extra-file.", - (gptr*) &my_defaults_extra_file, - (gptr*) &my_defaults_extra_file, 0, GET_STR, + (uchar**) &my_defaults_extra_file, + (uchar**) &my_defaults_extra_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"no-defaults", 'n', "Return an empty string (useful for scripts).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/extra/mysql_waitpid.c b/extra/mysql_waitpid.c index a166e6b15af..42465998862 100644 --- a/extra/mysql_waitpid.c +++ b/extra/mysql_waitpid.c @@ -38,7 +38,7 @@ static struct my_option my_long_options[] = 0, 0, 0, 0, 0}, {"verbose", 'v', "Be more verbose. Give a warning, if kill can't handle signal 0.", - (gptr*) &verbose, (gptr*) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + (uchar**) &verbose, (uchar**) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Print version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} diff --git a/extra/perror.c b/extra/perror.c index c49869be681..9b87bfa3d2a 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -41,18 +41,18 @@ static struct my_option my_long_options[] = {"info", 'I', "Synonym for --help.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE - {"ndb", 257, "Ndbcluster storage engine specific error codes.", (gptr*) &ndb_code, - (gptr*) &ndb_code, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"ndb", 257, "Ndbcluster storage engine specific error codes.", (uchar**) &ndb_code, + (uchar**) &ndb_code, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif #ifdef HAVE_SYS_ERRLIST {"all", 'a', "Print all the error messages and the number.", - (gptr*) &print_all_codes, (gptr*) &print_all_codes, 0, GET_BOOL, NO_ARG, + (uchar**) &print_all_codes, (uchar**) &print_all_codes, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"silent", 's', "Only print the error message.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"verbose", 'v', "Print error code and message (default).", (gptr*) &verbose, - (gptr*) &verbose, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, + {"verbose", 'v', "Print error code and message (default).", (uchar**) &verbose, + (uchar**) &verbose, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"version", 'V', "Displays version information and exits.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} diff --git a/extra/replace.c b/extra/replace.c index de0a4b05764..f7112403b06 100644 --- a/extra/replace.c +++ b/extra/replace.c @@ -51,7 +51,7 @@ typedef struct st_pointer_array { /* when using array-strings */ TYPELIB typelib; /* Pointer to strings */ - byte *str; /* Strings is here */ + uchar *str; /* Strings is here */ int7 *flag; /* Flag about each var. */ uint array_allocs,max_count,length,max_length; } POINTER_ARRAY; @@ -83,14 +83,14 @@ static int static_get_options(int *argc,char * * *argv); static int get_replace_strings(int *argc,char * * *argv, POINTER_ARRAY *from_array, POINTER_ARRAY *to_array); -static int insert_pointer_name(POINTER_ARRAY *pa, my_string name); +static int insert_pointer_name(POINTER_ARRAY *pa, char * name); static void free_pointer_array(POINTER_ARRAY *pa); static int convert_pipe(REPLACE *,FILE *,FILE *); -static int convert_file(REPLACE *, my_string); -static REPLACE *init_replace(my_string *from, my_string *to,uint count, - my_string word_end_chars); -static uint replace_strings(REPLACE *rep, my_string *start,uint *max_length, - my_string from); +static int convert_file(REPLACE *, char *); +static REPLACE *init_replace(char * *from, char * *to,uint count, + char * word_end_chars); +static uint replace_strings(REPLACE *rep, char * *start,uint *max_length, + char * from); static int initialize_buffer(void); static void reset_buffer(void); static void free_buffer(void); @@ -245,10 +245,10 @@ POINTER_ARRAY *from_array,*to_array; return 0; } -static int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name) +static int insert_pointer_name(reg1 POINTER_ARRAY *pa,char * name) { uint i,length,old_count; - byte *new_pos; + uchar *new_pos; const char **new_array; DBUG_ENTER("insert_pointer_name"); @@ -256,16 +256,16 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name) { if (!(pa->typelib.type_names=(const char **) my_malloc(((PC_MALLOC-MALLOC_OVERHEAD)/ - (sizeof(my_string)+sizeof(*pa->flag))* - (sizeof(my_string)+sizeof(*pa->flag))),MYF(MY_WME)))) + (sizeof(char *)+sizeof(*pa->flag))* + (sizeof(char *)+sizeof(*pa->flag))),MYF(MY_WME)))) DBUG_RETURN(-1); - if (!(pa->str= (byte*) my_malloc((uint) (PS_MALLOC-MALLOC_OVERHEAD), + if (!(pa->str= (uchar*) my_malloc((uint) (PS_MALLOC-MALLOC_OVERHEAD), MYF(MY_WME)))) { - my_free((gptr) pa->typelib.type_names,MYF(0)); + my_free((uchar*) pa->typelib.type_names,MYF(0)); DBUG_RETURN (-1); } - pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(byte*)+ + pa->max_count=(PC_MALLOC-MALLOC_OVERHEAD)/(sizeof(uchar*)+ sizeof(*pa->flag)); pa->flag= (int7*) (pa->typelib.type_names+pa->max_count); pa->length=0; @@ -277,7 +277,7 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name) { pa->max_length=(pa->length+length+MALLOC_OVERHEAD+PS_MALLOC-1)/PS_MALLOC; pa->max_length=pa->max_length*PS_MALLOC-MALLOC_OVERHEAD; - if (!(new_pos= (byte*) my_realloc((gptr) pa->str, + if (!(new_pos= (uchar*) my_realloc((uchar*) pa->str, (uint) pa->max_length, MYF(MY_WME)))) DBUG_RETURN(1); @@ -295,17 +295,17 @@ static int insert_pointer_name(reg1 POINTER_ARRAY *pa,my_string name) int len; pa->array_allocs++; len=(PC_MALLOC*pa->array_allocs - MALLOC_OVERHEAD); - if (!(new_array=(const char **) my_realloc((gptr) pa->typelib.type_names, + if (!(new_array=(const char **) my_realloc((uchar*) pa->typelib.type_names, (uint) len/ - (sizeof(byte*)+sizeof(*pa->flag))* - (sizeof(byte*)+sizeof(*pa->flag)), + (sizeof(uchar*)+sizeof(*pa->flag))* + (sizeof(uchar*)+sizeof(*pa->flag)), MYF(MY_WME)))) DBUG_RETURN(1); pa->typelib.type_names=new_array; old_count=pa->max_count; - pa->max_count=len/(sizeof(byte*) + sizeof(*pa->flag)); + pa->max_count=len/(sizeof(uchar*) + sizeof(*pa->flag)); pa->flag= (int7*) (pa->typelib.type_names+pa->max_count); - memcpy((byte*) pa->flag,(my_string) (pa->typelib.type_names+old_count), + memcpy((uchar*) pa->flag,(char *) (pa->typelib.type_names+old_count), old_count*sizeof(*pa->flag)); } pa->flag[pa->typelib.count]=0; /* Reset flag */ @@ -324,9 +324,9 @@ static void free_pointer_array(reg1 POINTER_ARRAY *pa) if (pa->typelib.count) { pa->typelib.count=0; - my_free((gptr) pa->typelib.type_names,MYF(0)); + my_free((uchar*) pa->typelib.type_names,MYF(0)); pa->typelib.type_names=0; - my_free((gptr) pa->str,MYF(0)); + my_free((uchar*) pa->str,MYF(0)); } return; } /* free_pointer_array */ @@ -380,23 +380,23 @@ static int get_next_bit(REP_SET *set,uint lastpos); static short find_set(REP_SETS *sets,REP_SET *find); static short find_found(FOUND_SET *found_set,uint table_offset, int found_offset); -static uint start_at_word(my_string pos); -static uint end_of_word(my_string pos); -static uint replace_len(my_string pos); +static uint start_at_word(char * pos); +static uint end_of_word(char * pos); +static uint replace_len(char * pos); static uint found_sets=0; /* Init a replace structure for further calls */ -static REPLACE *init_replace(my_string *from, my_string *to,uint count, - my_string word_end_chars) +static REPLACE *init_replace(char * *from, char * *to,uint count, + char * word_end_chars) { uint i,j,states,set_nr,len,result_len,max_length,found_end,bits_set,bit_nr; int used_sets,chr; short default_state; char used_chars[LAST_CHAR_CODE],is_word_end[256]; - my_string pos,to_pos,*to_array; + char * pos, *to_pos, **to_array; REP_SETS sets; REP_SET *set,*start_states,*word_states,*new_set; FOLLOWS *follow,*follow_ptr; @@ -441,7 +441,7 @@ static REPLACE *init_replace(my_string *from, my_string *to,uint count, if (!(follow=(FOLLOWS*) my_malloc((states+2)*sizeof(FOLLOWS),MYF(MY_WME)))) { free_sets(&sets); - my_free((gptr) found_set,MYF(0)); + my_free((uchar*) found_set,MYF(0)); DBUG_RETURN(0); } @@ -632,12 +632,12 @@ static REPLACE *init_replace(my_string *from, my_string *to,uint count, if ((replace=(REPLACE*) my_malloc(sizeof(REPLACE)*(sets.count)+ sizeof(REPLACE_STRING)*(found_sets+1)+ - sizeof(my_string)*count+result_len, + sizeof(char *)*count+result_len, MYF(MY_WME | MY_ZEROFILL)))) { rep_str=(REPLACE_STRING*) (replace+sets.count); - to_array=(my_string*) (rep_str+found_sets+1); - to_pos=(my_string) (to_array+count); + to_array=(char **) (rep_str+found_sets+1); + to_pos=(char *) (to_array+count); for (i=0 ; i < count ; i++) { to_array[i]=to_pos; @@ -663,9 +663,9 @@ static REPLACE *init_replace(my_string *from, my_string *to,uint count, replace[i].next[j]=(REPLACE*) (rep_str+(-sets.set[i].next[j]-1)); } } - my_free((gptr) follow,MYF(0)); + my_free((uchar*) follow,MYF(0)); free_sets(&sets); - my_free((gptr) found_set,MYF(0)); + my_free((uchar*) found_set,MYF(0)); DBUG_PRINT("exit",("Replace table has %d states",sets.count)); DBUG_RETURN(replace); } @@ -681,7 +681,7 @@ static int init_sets(REP_SETS *sets,uint states) if (!(sets->bit_buffer=(uint*) my_malloc(sizeof(uint)*sets->size_of_bits* SET_MALLOC_HUNC,MYF(MY_WME)))) { - my_free((gptr) sets->set,MYF(0)); + my_free((uchar*) sets->set,MYF(0)); return 1; } return 0; @@ -713,13 +713,13 @@ static REP_SET *make_new_set(REP_SETS *sets) return set; } count=sets->count+sets->invisible+SET_MALLOC_HUNC; - if (!(set=(REP_SET*) my_realloc((gptr) sets->set_buffer, + if (!(set=(REP_SET*) my_realloc((uchar*) sets->set_buffer, sizeof(REP_SET)*count, MYF(MY_WME)))) return 0; sets->set_buffer=set; sets->set=set+sets->invisible; - if (!(bit_buffer=(uint*) my_realloc((gptr) sets->bit_buffer, + if (!(bit_buffer=(uint*) my_realloc((uchar*) sets->bit_buffer, (sizeof(uint)*sets->size_of_bits)*count, MYF(MY_WME)))) return 0; @@ -742,8 +742,8 @@ static void free_last_set(REP_SETS *sets) static void free_sets(REP_SETS *sets) { - my_free((gptr)sets->set_buffer,MYF(0)); - my_free((gptr)sets->bit_buffer,MYF(0)); + my_free((uchar*)sets->set_buffer,MYF(0)); + my_free((uchar*)sets->bit_buffer,MYF(0)); return; } @@ -770,13 +770,13 @@ static void or_bits(REP_SET *to,REP_SET *from) static void copy_bits(REP_SET *to,REP_SET *from) { - memcpy((byte*) to->bits,(byte*) from->bits, + memcpy((uchar*) to->bits,(uchar*) from->bits, (size_t) (sizeof(uint) * to->size_of_bits)); } static int cmp_bits(REP_SET *set1,REP_SET *set2) { - return bcmp((byte*) set1->bits,(byte*) set2->bits, + return bcmp((uchar*) set1->bits,(uchar*) set2->bits, sizeof(uint) * set1->size_of_bits); } @@ -847,21 +847,21 @@ static short find_found(FOUND_SET *found_set,uint table_offset, /* Return 1 if regexp starts with \b or ends with \b*/ -static uint start_at_word(my_string pos) +static uint start_at_word(char * pos) { return (((!bcmp(pos,"\\b",2) && pos[2]) || !bcmp(pos,"\\^",2)) ? 1 : 0); } -static uint end_of_word(my_string pos) +static uint end_of_word(char * pos) { - my_string end=strend(pos); + char * end=strend(pos); return ((end > pos+2 && !bcmp(end-2,"\\b",2)) || (end >= pos+2 && !bcmp(end-2,"\\$",2))) ? 1 : 0; } -static uint replace_len(my_string str) +static uint replace_len(char * str) { uint len=0; while (*str) @@ -877,12 +877,12 @@ static uint replace_len(my_string str) /* The actual loop */ -static uint replace_strings(REPLACE *rep, my_string *start,uint *max_length, - my_string from) +static uint replace_strings(REPLACE *rep, char **start, uint *max_length, + char *from) { reg1 REPLACE *rep_pos; reg2 REPLACE_STRING *rep_str; - my_string to,end,pos,new; + char *to, *end, *pos, *new; end=(to= *start) + *max_length-1; rep_pos=rep+1; @@ -903,7 +903,7 @@ static uint replace_strings(REPLACE *rep, my_string *start,uint *max_length, } if (!(rep_str = ((REPLACE_STRING*) rep_pos))->replace_string) return (uint) (to - *start)-1; - updated=1; /* Some my_string is replaced */ + updated=1; /* Some char * is replaced */ to-=rep_str->to_offset; for (pos=rep_str->replace_string; *pos ; pos++) { @@ -1047,7 +1047,7 @@ FILE *in,*out; } -static int convert_file(REPLACE *rep, my_string name) +static int convert_file(REPLACE *rep, char * name) { int error; FILE *in,*out; @@ -1056,6 +1056,7 @@ static int convert_file(REPLACE *rep, my_string name) char link_name[FN_REFLEN]; #endif File temp_file; + size_t dir_buff_length; DBUG_ENTER("convert_file"); /* check if name is a symlink */ @@ -1065,7 +1066,7 @@ static int convert_file(REPLACE *rep, my_string name) #endif if (!(in= my_fopen(org_name,O_RDONLY,MYF(MY_WME)))) DBUG_RETURN(1); - dirname_part(dir_buff,org_name); + dirname_part(dir_buff, org_name, &dir_buff_length); if ((temp_file= create_temp_file(tempname, dir_buff, "PR", O_WRONLY, MYF(MY_WME))) < 0) { diff --git a/extra/resolve_stack_dump.c b/extra/resolve_stack_dump.c index 04ab8a30f0d..5606c17ecf3 100644 --- a/extra/resolve_stack_dump.c +++ b/extra/resolve_stack_dump.c @@ -53,10 +53,10 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"symbols-file", 's', "Use specified symbols file.", (gptr*) &sym_fname, - (gptr*) &sym_fname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"symbols-file", 's', "Use specified symbols file.", (uchar**) &sym_fname, + (uchar**) &sym_fname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"numeric-dump-file", 'n', "Read the dump from specified file.", - (gptr*) &dump_fname, (gptr*) &dump_fname, 0, GET_STR, REQUIRED_ARG, + (uchar**) &dump_fname, (uchar**) &dump_fname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -235,7 +235,7 @@ static void init_sym_table() SYM_ENTRY se; if (init_sym_entry(&se, buf)) continue; - if (insert_dynamic(&sym_table, (gptr)&se)) + if (insert_dynamic(&sym_table, (uchar*)&se)) die("insert_dynamic() failed - looks like we are out of memory"); } @@ -255,7 +255,7 @@ static void verify_sort() for (i = 0; i < sym_table.elements; i++) { SYM_ENTRY se; - get_dynamic(&sym_table, (gptr)&se, i); + get_dynamic(&sym_table, (uchar*)&se, i); if (se.addr < last) die("sym table does not appear to be sorted, did you forget \ --numeric-sort arg to nm? trouble addr = %p, last = %p", se.addr, last); @@ -267,16 +267,16 @@ static void verify_sort() static SYM_ENTRY* resolve_addr(uchar* addr, SYM_ENTRY* se) { uint i; - get_dynamic(&sym_table, (gptr)se, 0); + get_dynamic(&sym_table, (uchar*)se, 0); if (addr < se->addr) return 0; for (i = 1; i < sym_table.elements; i++) { - get_dynamic(&sym_table, (gptr)se, i); + get_dynamic(&sym_table, (uchar*)se, i); if (addr < se->addr) { - get_dynamic(&sym_table, (gptr)se, i - 1); + get_dynamic(&sym_table, (uchar*)se, i - 1); return se; } } diff --git a/extra/resolveip.c b/extra/resolveip.c index 5bbecab5e6b..b61c0871aaf 100644 --- a/extra/resolveip.c +++ b/extra/resolveip.c @@ -43,7 +43,7 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"info", 'I', "Synonym for --help.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"silent", 's', "Be more silent.", (gptr*) &silent, (gptr*) &silent, + {"silent", 's', "Be more silent.", (uchar**) &silent, (uchar**) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Displays version information and exits.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -83,7 +83,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), return 0; } -/*static my_string load_default_groups[]= { "resolveip","client",0 }; */ +/*static char * load_default_groups[]= { "resolveip","client",0 }; */ static int get_options(int *argc,char ***argv) { diff --git a/include/config-win.h b/include/config-win.h index 4b8913c8f5d..bc2ae60f137 100644 --- a/include/config-win.h +++ b/include/config-win.h @@ -310,10 +310,10 @@ inline double ulonglong2double(ulonglong value) #define doublestore(T,V) do { *((long *) T) = *((long*) &V); \ *(((long *) T)+1) = *(((long*) &V)+1); } while(0) #define float4get(V,M) { *((long *) &(V)) = *((long*) (M)); } -#define floatstore(T,V) memcpy((byte*)(T), (byte*)(&V), sizeof(float)) -#define floatget(V,M) memcpy((byte*)(&V), (byte*)(M), sizeof(float)) +#define floatstore(T,V) memcpy((uchar*)(T), (uchar*)(&V), sizeof(float)) +#define floatget(V,M) memcpy((uchar*)(&V), (uchar*)(M), sizeof(float)) #define float8get(V,M) doubleget((V),(M)) -#define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float)) +#define float4store(V,M) memcpy((uchar*) V,(uchar*) (&M),sizeof(float)) #define float8store(V,M) doublestore((V),(M)) #endif /* _WIN64 */ diff --git a/include/decimal.h b/include/decimal.h index c5385b58658..530ed9e1757 100644 --- a/include/decimal.h +++ b/include/decimal.h @@ -39,8 +39,8 @@ int longlong2decimal(longlong from, decimal_t *to); int decimal2double(decimal_t *from, double *to); int double2decimal(double from, decimal_t *to); int decimal_actual_fraction(decimal_t *from); -int decimal2bin(decimal_t *from, char *to, int precision, int scale); -int bin2decimal(char *from, decimal_t *to, int precision, int scale); +int decimal2bin(decimal_t *from, uchar *to, int precision, int scale); +int bin2decimal(const uchar *from, decimal_t *to, int precision, int scale); int decimal_size(int precision, int scale); int decimal_bin_size(int precision, int scale); diff --git a/include/ft_global.h b/include/ft_global.h index 6c3457541a5..752371d6bc6 100644 --- a/include/ft_global.h +++ b/include/ft_global.h @@ -32,7 +32,7 @@ typedef struct st_ft_info FT_INFO; struct _ft_vft { int (*read_next)(FT_INFO *, char *); - float (*find_relevance)(FT_INFO *, byte *, uint); + float (*find_relevance)(FT_INFO *, uchar *, uint); void (*close_search)(FT_INFO *); float (*get_relevance)(FT_INFO *); void (*reinit_search)(FT_INFO *); @@ -62,8 +62,8 @@ void ft_free_stopwords(void); #define FT_SORTED 2 #define FT_EXPAND 4 /* query expansion */ -FT_INFO *ft_init_search(uint,void *, uint, byte *, uint,CHARSET_INFO *, byte *); -my_bool ft_boolean_check_syntax_string(const byte *); +FT_INFO *ft_init_search(uint,void *, uint, uchar *, uint,CHARSET_INFO *, uchar *); +my_bool ft_boolean_check_syntax_string(const uchar *); #ifdef __cplusplus } diff --git a/include/hash.h b/include/hash.h index 78499a4f810..d924e62a0ec 100644 --- a/include/hash.h +++ b/include/hash.h @@ -30,12 +30,13 @@ extern "C" { /* flags for hash_init */ #define HASH_UNIQUE 1 /* hash_insert fails on duplicate key */ -typedef byte *(*hash_get_key)(const byte *,uint*,my_bool); +typedef uchar *(*hash_get_key)(const uchar *,size_t*,my_bool); typedef void (*hash_free_key)(void *); typedef struct st_hash { - uint key_offset,key_length; /* Length of key if const length */ - uint records, blength; + size_t key_offset,key_length; /* Length of key if const length */ + size_t blength; + ulong records; uint flags; DYNAMIC_ARRAY array; /* Place for hash_keys */ hash_get_key get_key; @@ -48,21 +49,21 @@ typedef uint HASH_SEARCH_STATE; #define hash_init(A,B,C,D,E,F,G,H) _hash_init(A,B,C,D,E,F,G, H CALLER_INFO) my_bool _hash_init(HASH *hash, CHARSET_INFO *charset, - uint default_array_elements, uint key_offset, - uint key_length, hash_get_key get_key, + ulong default_array_elements, size_t key_offset, + size_t key_length, hash_get_key get_key, void (*free_element)(void*), uint flags CALLER_INFO_PROTO); void hash_free(HASH *tree); void my_hash_reset(HASH *hash); -byte *hash_element(HASH *hash,uint idx); -gptr hash_search(const HASH *info, const byte *key, uint length); -gptr hash_first(const HASH *info, const byte *key, uint length, +uchar *hash_element(HASH *hash,ulong idx); +uchar *hash_search(const HASH *info, const uchar *key, size_t length); +uchar *hash_first(const HASH *info, const uchar *key, size_t length, HASH_SEARCH_STATE *state); -gptr hash_next(const HASH *info, const byte *key, uint length, - HASH_SEARCH_STATE *state); -my_bool my_hash_insert(HASH *info,const byte *data); -my_bool hash_delete(HASH *hash,byte *record); -my_bool hash_update(HASH *hash,byte *record,byte *old_key,uint old_key_length); -void hash_replace(HASH *hash, HASH_SEARCH_STATE *state, byte *new_row); +uchar *hash_next(const HASH *info, const uchar *key, size_t length, + HASH_SEARCH_STATE *state); +my_bool my_hash_insert(HASH *info,const uchar *data); +my_bool hash_delete(HASH *hash,uchar *record); +my_bool hash_update(HASH *hash,uchar *record,uchar *old_key,size_t old_key_length); +void hash_replace(HASH *hash, HASH_SEARCH_STATE *state, uchar *new_row); my_bool hash_check(HASH *hash); /* Only in debug library */ #define hash_clear(H) bzero((char*) (H),sizeof(*(H))) diff --git a/include/heap.h b/include/heap.h index 6cacb7fc529..d309fb4f162 100644 --- a/include/heap.h +++ b/include/heap.h @@ -57,7 +57,7 @@ typedef struct st_heapinfo /* Struct from heap_info */ typedef struct st_heap_ptrs { - byte *blocks[HP_PTRS_IN_NOD]; /* pointers to HP_PTRS or records */ + uchar *blocks[HP_PTRS_IN_NOD]; /* pointers to HP_PTRS or records */ } HP_PTRS; struct st_level_info @@ -70,7 +70,7 @@ struct st_level_info of last_blocks array. For level 0 - 1, for level 1 - HP_PTRS_IN_NOD, for level 2 - HP_PTRS_IN_NOD^2 and so forth. */ - uint records_under_level; + ulong records_under_level; /* Ptr to last allocated HP_PTRS (or records buffer for level 0) on this @@ -123,10 +123,10 @@ typedef struct st_hp_keydef /* Key definition with open */ ha_rows hash_buckets; TREE rb_tree; int (*write_key)(struct st_heap_info *info, struct st_hp_keydef *keyinfo, - const byte *record, byte *recpos); + const uchar *record, uchar *recpos); int (*delete_key)(struct st_heap_info *info, struct st_hp_keydef *keyinfo, - const byte *record, byte *recpos, int flag); - uint (*get_key_length)(struct st_hp_keydef *keydef, const byte *key); + const uchar *record, uchar *recpos, int flag); + uint (*get_key_length)(struct st_hp_keydef *keydef, const uchar *key); } HP_KEYDEF; typedef struct st_heap_share @@ -144,8 +144,8 @@ typedef struct st_heap_share uint keys,max_key_length; uint currently_disabled_keys; /* saved value from "keys" when disabled */ uint open_count; - byte *del_link; /* Link to next block with del. rec */ - my_string name; /* Name of "memory-file" */ + uchar *del_link; /* Link to next block with del. rec */ + char * name; /* Name of "memory-file" */ #ifdef THREAD THR_LOCK lock; pthread_mutex_t intern_lock; /* Locking for use with _locking */ @@ -162,14 +162,14 @@ struct st_hp_hash_info; typedef struct st_heap_info { HP_SHARE *s; - byte *current_ptr; + uchar *current_ptr; struct st_hp_hash_info *current_hash_ptr; ulong current_record,next_block; int lastinx,errkey; int mode; /* Mode of file (READONLY..) */ uint opt_flag,update; - byte *lastkey; /* Last used key with rkey */ - byte *recbuf; /* Record buffer for rb-tree keys */ + uchar *lastkey; /* Last used key with rkey */ + uchar *recbuf; /* Record buffer for rb-tree keys */ enum ha_rkey_function last_find_flag; TREE_ELEMENT *parents[MAX_TREE_HEIGHT+1]; TREE_ELEMENT **last_pos; @@ -195,12 +195,12 @@ typedef struct st_heap_create_info extern HP_INFO *heap_open(const char *name, int mode); extern int heap_close(HP_INFO *info); -extern int heap_write(HP_INFO *info,const byte *buff); -extern int heap_update(HP_INFO *info,const byte *old,const byte *newdata); -extern int heap_rrnd(HP_INFO *info,byte *buf,byte *pos); +extern int heap_write(HP_INFO *info,const uchar *buff); +extern int heap_update(HP_INFO *info,const uchar *old,const uchar *newdata); +extern int heap_rrnd(HP_INFO *info,uchar *buf,uchar *pos); extern int heap_scan_init(HP_INFO *info); -extern int heap_scan(register HP_INFO *info, byte *record); -extern int heap_delete(HP_INFO *info,const byte *buff); +extern int heap_scan(register HP_INFO *info, uchar *record); +extern int heap_delete(HP_INFO *info,const uchar *buff); extern int heap_info(HP_INFO *info,HEAPINFO *x,int flag); extern int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, uint reclength, ulong max_records, ulong min_records, @@ -211,32 +211,32 @@ extern int heap_extra(HP_INFO *info,enum ha_extra_function function); extern int heap_reset(HP_INFO *info); extern int heap_rename(const char *old_name,const char *new_name); extern int heap_panic(enum ha_panic_function flag); -extern int heap_rsame(HP_INFO *info,byte *record,int inx); -extern int heap_rnext(HP_INFO *info,byte *record); -extern int heap_rprev(HP_INFO *info,byte *record); -extern int heap_rfirst(HP_INFO *info,byte *record,int inx); -extern int heap_rlast(HP_INFO *info,byte *record,int inx); +extern int heap_rsame(HP_INFO *info,uchar *record,int inx); +extern int heap_rnext(HP_INFO *info,uchar *record); +extern int heap_rprev(HP_INFO *info,uchar *record); +extern int heap_rfirst(HP_INFO *info,uchar *record,int inx); +extern int heap_rlast(HP_INFO *info,uchar *record,int inx); extern void heap_clear(HP_INFO *info); extern void heap_clear_keys(HP_INFO *info); extern int heap_disable_indexes(HP_INFO *info); extern int heap_enable_indexes(HP_INFO *info); extern int heap_indexes_are_disabled(HP_INFO *info); -extern void heap_update_auto_increment(HP_INFO *info, const byte *record); +extern void heap_update_auto_increment(HP_INFO *info, const uchar *record); ha_rows hp_rb_records_in_range(HP_INFO *info, int inx, key_range *min_key, key_range *max_key); int hp_panic(enum ha_panic_function flag); -int heap_rkey(HP_INFO *info, byte *record, int inx, const byte *key, +int heap_rkey(HP_INFO *info, uchar *record, int inx, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag); -extern gptr heap_find(HP_INFO *info,int inx,const byte *key); +extern uchar * heap_find(HP_INFO *info,int inx,const uchar *key); extern int heap_check_heap(HP_INFO *info, my_bool print_status); -extern byte *heap_position(HP_INFO *info); +extern uchar *heap_position(HP_INFO *info); /* The following is for programs that uses the old HEAP interface where - pointer to rows where a long instead of a (byte*). + pointer to rows where a long instead of a (uchar*). */ #if defined(WANT_OLD_HEAP_VERSION) || defined(OLD_HEAP_VERSION) -extern int heap_rrnd_old(HP_INFO *info,byte *buf,ulong pos); +extern int heap_rrnd_old(HP_INFO *info,uchar *buf,ulong pos); extern ulong heap_position_old(HP_INFO *info); #endif #ifdef OLD_HEAP_VERSION @@ -244,7 +244,7 @@ typedef ulong HEAP_PTR; #define heap_position(A) heap_position_old(A) #define heap_rrnd(A,B,C) heap_rrnd_old(A,B,C) #else -typedef byte *HEAP_PTR; +typedef uchar *HEAP_PTR; #endif #ifdef __cplusplus diff --git a/include/keycache.h b/include/keycache.h index 4d99c68844f..9ebb7d5b992 100644 --- a/include/keycache.h +++ b/include/keycache.h @@ -66,9 +66,9 @@ typedef struct st_key_cache HASH_LINK **hash_root; /* arr. of entries into hash table buckets */ HASH_LINK *hash_link_root; /* memory for hash table links */ HASH_LINK *free_hash_list; /* list of free hash links */ - BLOCK_LINK *free_block_list; /* list of free blocks */ + BLOCK_LINK *free_block_list; /* list of free blocks */ BLOCK_LINK *block_root; /* memory for block links */ - byte HUGE_PTR *block_mem; /* memory for block buffers */ + uchar HUGE_PTR *block_mem; /* memory for block buffers */ BLOCK_LINK *used_last; /* ptr to the last block of the LRU chain */ BLOCK_LINK *used_ins; /* ptr to the insertion block in LRU chain */ pthread_mutex_t cache_lock; /* to lock access to the cache structure */ @@ -115,16 +115,16 @@ extern int resize_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, uint age_threshold); extern void change_key_cache_param(KEY_CACHE *keycache, uint division_limit, uint age_threshold); -extern byte *key_cache_read(KEY_CACHE *keycache, +extern uchar *key_cache_read(KEY_CACHE *keycache, File file, my_off_t filepos, int level, - byte *buff, uint length, + uchar *buff, uint length, uint block_length,int return_buffer); extern int key_cache_insert(KEY_CACHE *keycache, File file, my_off_t filepos, int level, - byte *buff, uint length); + uchar *buff, uint length); extern int key_cache_write(KEY_CACHE *keycache, File file, my_off_t filepos, int level, - byte *buff, uint length, + uchar *buff, uint length, uint block_length,int force_write); extern int flush_key_blocks(KEY_CACHE *keycache, int file, enum flush_type type); @@ -133,8 +133,8 @@ extern void end_key_cache(KEY_CACHE *keycache, my_bool cleanup); /* Functions to handle multiple key caches */ extern my_bool multi_keycache_init(void); extern void multi_keycache_free(void); -extern KEY_CACHE *multi_key_cache_search(byte *key, uint length); -extern my_bool multi_key_cache_set(const byte *key, uint length, +extern KEY_CACHE *multi_key_cache_search(uchar *key, uint length); +extern my_bool multi_key_cache_set(const uchar *key, uint length, KEY_CACHE *key_cache); extern void multi_key_cache_change(KEY_CACHE *old_data, KEY_CACHE *new_data); diff --git a/include/m_ctype.h b/include/m_ctype.h index f2b49c63fe3..e5debc6e032 100644 --- a/include/m_ctype.h +++ b/include/m_ctype.h @@ -51,8 +51,8 @@ extern MY_UNICASE_INFO *my_unicase_turkish[256]; typedef struct uni_ctype_st { - unsigned char pctype; - unsigned char *ctype; + uchar pctype; + uchar *ctype; } MY_UNI_CTYPE; extern MY_UNI_CTYPE my_uni_ctype[256]; @@ -125,22 +125,22 @@ struct charset_info_st; /* See strings/CHARSET_INFO.txt for information about this structure */ typedef struct my_collation_handler_st { - my_bool (*init)(struct charset_info_st *, void *(*alloc)(uint)); + my_bool (*init)(struct charset_info_st *, void *(*alloc)(size_t)); /* Collation routines */ int (*strnncoll)(struct charset_info_st *, - const uchar *, uint, const uchar *, uint, my_bool); + const uchar *, size_t, const uchar *, size_t, my_bool); int (*strnncollsp)(struct charset_info_st *, - const uchar *, uint, const uchar *, uint, + const uchar *, size_t, const uchar *, size_t, my_bool diff_if_only_endspace_difference); - int (*strnxfrm)(struct charset_info_st *, - uchar *, uint, const uchar *, uint); - uint (*strnxfrmlen)(struct charset_info_st *, uint); + size_t (*strnxfrm)(struct charset_info_st *, + uchar *, size_t, const uchar *, size_t); + size_t (*strnxfrmlen)(struct charset_info_st *, size_t); my_bool (*like_range)(struct charset_info_st *, - const char *s, uint s_length, + const char *s, size_t s_length, pchar w_prefix, pchar w_one, pchar w_many, - uint res_length, + size_t res_length, char *min_str, char *max_str, - uint *min_len, uint *max_len); + size_t *min_len, size_t *max_len); int (*wildcmp)(struct charset_info_st *, const char *str,const char *str_end, const char *wildstr,const char *wildend, @@ -149,14 +149,14 @@ typedef struct my_collation_handler_st int (*strcasecmp)(struct charset_info_st *, const char *, const char *); uint (*instr)(struct charset_info_st *, - const char *b, uint b_length, - const char *s, uint s_length, + const char *b, size_t b_length, + const char *s, size_t s_length, my_match_t *match, uint nmatch); /* Hash calculation */ - void (*hash_sort)(struct charset_info_st *cs, const uchar *key, uint len, + void (*hash_sort)(struct charset_info_st *cs, const uchar *key, size_t len, ulong *nr1, ulong *nr2); - my_bool (*propagate)(struct charset_info_st *cs, const uchar *str, uint len); + my_bool (*propagate)(struct charset_info_st *cs, const uchar *str, size_t len); } MY_COLLATION_HANDLER; extern MY_COLLATION_HANDLER my_collation_mb_bin_handler; @@ -168,64 +168,67 @@ extern MY_COLLATION_HANDLER my_collation_ucs2_uca_handler; /* See strings/CHARSET_INFO.txt about information on this structure */ typedef struct my_charset_handler_st { - my_bool (*init)(struct charset_info_st *, void *(*alloc)(uint)); + my_bool (*init)(struct charset_info_st *, void *(*alloc)(size_t)); /* Multibyte routines */ - int (*ismbchar)(struct charset_info_st *, const char *, const char *); - int (*mbcharlen)(struct charset_info_st *, uint); - uint (*numchars)(struct charset_info_st *, const char *b, const char *e); - uint (*charpos)(struct charset_info_st *, const char *b, const char *e, uint pos); - uint (*well_formed_len)(struct charset_info_st *, + uint (*ismbchar)(struct charset_info_st *, const char *, const char *); + uint (*mbcharlen)(struct charset_info_st *, uint c); + size_t (*numchars)(struct charset_info_st *, const char *b, const char *e); + size_t (*charpos)(struct charset_info_st *, const char *b, const char *e, + size_t pos); + size_t (*well_formed_len)(struct charset_info_st *, const char *b,const char *e, - uint nchars, int *error); - uint (*lengthsp)(struct charset_info_st *, const char *ptr, uint length); - uint (*numcells)(struct charset_info_st *, const char *b, const char *e); + size_t nchars, int *error); + size_t (*lengthsp)(struct charset_info_st *, const char *ptr, size_t length); + size_t (*numcells)(struct charset_info_st *, const char *b, const char *e); /* Unicode conversion */ int (*mb_wc)(struct charset_info_st *cs,my_wc_t *wc, - const unsigned char *s,const unsigned char *e); + const uchar *s,const uchar *e); int (*wc_mb)(struct charset_info_st *cs,my_wc_t wc, - unsigned char *s,unsigned char *e); + uchar *s,uchar *e); /* CTYPE scanner */ int (*ctype)(struct charset_info_st *cs, int *ctype, - const unsigned char *s, const unsigned char *e); + const uchar *s, const uchar *e); /* Functions for case and sort conversion */ - uint (*caseup_str)(struct charset_info_st *, char *); - uint (*casedn_str)(struct charset_info_st *, char *); - uint (*caseup)(struct charset_info_st *, char *src, uint srclen, - char *dst, uint dstlen); - uint (*casedn)(struct charset_info_st *, char *src, uint srclen, - char *dst, uint dstlen); + size_t (*caseup_str)(struct charset_info_st *, char *); + size_t (*casedn_str)(struct charset_info_st *, char *); + size_t (*caseup)(struct charset_info_st *, char *src, size_t srclen, + char *dst, size_t dstlen); + size_t (*casedn)(struct charset_info_st *, char *src, size_t srclen, + char *dst, size_t dstlen); /* Charset dependant snprintf() */ - int (*snprintf)(struct charset_info_st *, char *to, uint n, const char *fmt, - ...) ATTRIBUTE_FORMAT_FPTR(printf, 4, 5); - int (*long10_to_str)(struct charset_info_st *, char *to, uint n, int radix, - long int val); - int (*longlong10_to_str)(struct charset_info_st *, char *to, uint n, - int radix, longlong val); + size_t (*snprintf)(struct charset_info_st *, char *to, size_t n, + const char *fmt, + ...) ATTRIBUTE_FORMAT_FPTR(printf, 4, 5); + size_t (*long10_to_str)(struct charset_info_st *, char *to, size_t n, + int radix, long int val); + size_t (*longlong10_to_str)(struct charset_info_st *, char *to, size_t n, + int radix, longlong val); - void (*fill)(struct charset_info_st *, char *to, uint len, int fill); + void (*fill)(struct charset_info_st *, char *to, size_t len, int fill); /* String-to-number conversion routines */ - long (*strntol)(struct charset_info_st *, const char *s, uint l, + long (*strntol)(struct charset_info_st *, const char *s, size_t l, int base, char **e, int *err); - ulong (*strntoul)(struct charset_info_st *, const char *s, uint l, + ulong (*strntoul)(struct charset_info_st *, const char *s, size_t l, int base, char **e, int *err); - longlong (*strntoll)(struct charset_info_st *, const char *s, uint l, + longlong (*strntoll)(struct charset_info_st *, const char *s, size_t l, int base, char **e, int *err); - ulonglong (*strntoull)(struct charset_info_st *, const char *s, uint l, + ulonglong (*strntoull)(struct charset_info_st *, const char *s, size_t l, int base, char **e, int *err); - double (*strntod)(struct charset_info_st *, char *s, uint l, char **e, + double (*strntod)(struct charset_info_st *, char *s, size_t l, char **e, int *err); longlong (*strtoll10)(struct charset_info_st *cs, const char *nptr, char **endptr, int *error); ulonglong (*strntoull10rnd)(struct charset_info_st *cs, - const char *str, uint length, int unsigned_fl, + const char *str, size_t length, + int unsigned_fl, char **endptr, int *error); - ulong (*scan)(struct charset_info_st *, const char *b, const char *e, - int sq); + size_t (*scan)(struct charset_info_st *, const char *b, const char *e, + int sq); } MY_CHARSET_HANDLER; extern MY_CHARSET_HANDLER my_charset_8bit_handler; @@ -302,35 +305,35 @@ extern CHARSET_INFO my_charset_cp1250_czech_ci; extern CHARSET_INFO my_charset_filename; /* declarations for simple charsets */ -extern int my_strnxfrm_simple(CHARSET_INFO *, uchar *, uint, const uchar *, - uint); -uint my_strnxfrmlen_simple(CHARSET_INFO *, uint); -extern int my_strnncoll_simple(CHARSET_INFO *, const uchar *, uint, - const uchar *, uint, my_bool); - -extern int my_strnncollsp_simple(CHARSET_INFO *, const uchar *, uint, - const uchar *, uint, +extern size_t my_strnxfrm_simple(CHARSET_INFO *, uchar *, size_t, + const uchar *, size_t); +size_t my_strnxfrmlen_simple(CHARSET_INFO *, size_t); +extern int my_strnncoll_simple(CHARSET_INFO *, const uchar *, size_t, + const uchar *, size_t, my_bool); + +extern int my_strnncollsp_simple(CHARSET_INFO *, const uchar *, size_t, + const uchar *, size_t, my_bool diff_if_only_endspace_difference); extern void my_hash_sort_simple(CHARSET_INFO *cs, - const uchar *key, uint len, + const uchar *key, size_t len, ulong *nr1, ulong *nr2); -extern uint my_lengthsp_8bit(CHARSET_INFO *cs, const char *ptr, uint length); +extern size_t my_lengthsp_8bit(CHARSET_INFO *cs, const char *ptr, size_t length); extern uint my_instr_simple(struct charset_info_st *, - const char *b, uint b_length, - const char *s, uint s_length, + const char *b, size_t b_length, + const char *s, size_t s_length, my_match_t *match, uint nmatch); /* Functions for 8bit */ -extern uint my_caseup_str_8bit(CHARSET_INFO *, char *); -extern uint my_casedn_str_8bit(CHARSET_INFO *, char *); -extern uint my_caseup_8bit(CHARSET_INFO *, char *src, uint srclen, - char *dst, uint dstlen); -extern uint my_casedn_8bit(CHARSET_INFO *, char *src, uint srclen, - char *dst, uint dstlen); +extern size_t my_caseup_str_8bit(CHARSET_INFO *, char *); +extern size_t my_casedn_str_8bit(CHARSET_INFO *, char *); +extern size_t my_caseup_8bit(CHARSET_INFO *, char *src, size_t srclen, + char *dst, size_t dstlen); +extern size_t my_casedn_8bit(CHARSET_INFO *, char *src, size_t srclen, + char *dst, size_t dstlen); extern int my_strcasecmp_8bit(CHARSET_INFO * cs, const char *, const char *); @@ -340,26 +343,26 @@ int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc, uchar *s, uchar *e); int my_mb_ctype_8bit(CHARSET_INFO *,int *, const uchar *,const uchar *); int my_mb_ctype_mb(CHARSET_INFO *,int *, const uchar *,const uchar *); -ulong my_scan_8bit(CHARSET_INFO *cs, const char *b, const char *e, int sq); +size_t my_scan_8bit(CHARSET_INFO *cs, const char *b, const char *e, int sq); -int my_snprintf_8bit(struct charset_info_st *, char *to, uint n, - const char *fmt, ...) +size_t my_snprintf_8bit(struct charset_info_st *, char *to, size_t n, + const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 4, 5); -long my_strntol_8bit(CHARSET_INFO *, const char *s, uint l, int base, +long my_strntol_8bit(CHARSET_INFO *, const char *s, size_t l, int base, + char **e, int *err); +ulong my_strntoul_8bit(CHARSET_INFO *, const char *s, size_t l, int base, char **e, int *err); -ulong my_strntoul_8bit(CHARSET_INFO *, const char *s, uint l, int base, +longlong my_strntoll_8bit(CHARSET_INFO *, const char *s, size_t l, int base, char **e, int *err); -longlong my_strntoll_8bit(CHARSET_INFO *, const char *s, uint l, int base, +ulonglong my_strntoull_8bit(CHARSET_INFO *, const char *s, size_t l, int base, char **e, int *err); -ulonglong my_strntoull_8bit(CHARSET_INFO *, const char *s, uint l, int base, - char **e, int *err); -double my_strntod_8bit(CHARSET_INFO *, char *s, uint l,char **e, +double my_strntod_8bit(CHARSET_INFO *, char *s, size_t l,char **e, int *err); -int my_long10_to_str_8bit(CHARSET_INFO *, char *to, uint l, int radix, - long int val); -int my_longlong10_to_str_8bit(CHARSET_INFO *, char *to, uint l, int radix, - longlong val); +size_t my_long10_to_str_8bit(CHARSET_INFO *, char *to, size_t l, int radix, + long int val); +size_t my_longlong10_to_str_8bit(CHARSET_INFO *, char *to, size_t l, int radix, + longlong val); longlong my_strtoll10_8bit(CHARSET_INFO *cs, const char *nptr, char **endptr, int *error); @@ -367,34 +370,34 @@ longlong my_strtoll10_ucs2(CHARSET_INFO *cs, const char *nptr, char **endptr, int *error); ulonglong my_strntoull10rnd_8bit(CHARSET_INFO *cs, - const char *str, uint length, int unsigned_fl, - char **endptr, int *error); + const char *str, size_t length, int + unsigned_fl, char **endptr, int *error); ulonglong my_strntoull10rnd_ucs2(CHARSET_INFO *cs, - const char *str, uint length, int unsigned_fl, - char **endptr, int *error); + const char *str, size_t length, + int unsigned_fl, char **endptr, int *error); -void my_fill_8bit(CHARSET_INFO *cs, char* to, uint l, int fill); +void my_fill_8bit(CHARSET_INFO *cs, char* to, size_t l, int fill); my_bool my_like_range_simple(CHARSET_INFO *cs, - const char *ptr, uint ptr_length, + const char *ptr, size_t ptr_length, pbool escape, pbool w_one, pbool w_many, - uint res_length, + size_t res_length, char *min_str, char *max_str, - uint *min_length, uint *max_length); + size_t *min_length, size_t *max_length); my_bool my_like_range_mb(CHARSET_INFO *cs, - const char *ptr, uint ptr_length, + const char *ptr, size_t ptr_length, pbool escape, pbool w_one, pbool w_many, - uint res_length, + size_t res_length, char *min_str, char *max_str, - uint *min_length, uint *max_length); + size_t *min_length, size_t *max_length); my_bool my_like_range_ucs2(CHARSET_INFO *cs, - const char *ptr, uint ptr_length, + const char *ptr, size_t ptr_length, pbool escape, pbool w_one, pbool w_many, - uint res_length, + size_t res_length, char *min_str, char *max_str, - uint *min_length, uint *max_length); + size_t *min_length, size_t *max_length); int my_wildcmp_8bit(CHARSET_INFO *, @@ -407,35 +410,35 @@ int my_wildcmp_bin(CHARSET_INFO *, const char *wildstr,const char *wildend, int escape, int w_one, int w_many); -uint my_numchars_8bit(CHARSET_INFO *, const char *b, const char *e); -uint my_numcells_8bit(CHARSET_INFO *, const char *b, const char *e); -uint my_charpos_8bit(CHARSET_INFO *, const char *b, const char *e, uint pos); -uint my_well_formed_len_8bit(CHARSET_INFO *, const char *b, const char *e, - uint pos, int *error); -int my_mbcharlen_8bit(CHARSET_INFO *, uint c); +size_t my_numchars_8bit(CHARSET_INFO *, const char *b, const char *e); +size_t my_numcells_8bit(CHARSET_INFO *, const char *b, const char *e); +size_t my_charpos_8bit(CHARSET_INFO *, const char *b, const char *e, size_t pos); +size_t my_well_formed_len_8bit(CHARSET_INFO *, const char *b, const char *e, + size_t pos, int *error); +uint my_mbcharlen_8bit(CHARSET_INFO *, uint c); /* Functions for multibyte charsets */ -extern uint my_caseup_str_mb(CHARSET_INFO *, char *); -extern uint my_casedn_str_mb(CHARSET_INFO *, char *); -extern uint my_caseup_mb(CHARSET_INFO *, char *src, uint srclen, - char *dst, uint dstlen); -extern uint my_casedn_mb(CHARSET_INFO *, char *src, uint srclen, - char *dst, uint dstlen); +extern size_t my_caseup_str_mb(CHARSET_INFO *, char *); +extern size_t my_casedn_str_mb(CHARSET_INFO *, char *); +extern size_t my_caseup_mb(CHARSET_INFO *, char *src, size_t srclen, + char *dst, size_t dstlen); +extern size_t my_casedn_mb(CHARSET_INFO *, char *src, size_t srclen, + char *dst, size_t dstlen); extern int my_strcasecmp_mb(CHARSET_INFO * cs,const char *, const char *); int my_wildcmp_mb(CHARSET_INFO *, const char *str,const char *str_end, const char *wildstr,const char *wildend, int escape, int w_one, int w_many); -uint my_numchars_mb(CHARSET_INFO *, const char *b, const char *e); -uint my_numcells_mb(CHARSET_INFO *, const char *b, const char *e); -uint my_charpos_mb(CHARSET_INFO *, const char *b, const char *e, uint pos); -uint my_well_formed_len_mb(CHARSET_INFO *, const char *b, const char *e, - uint pos, int *error); +size_t my_numchars_mb(CHARSET_INFO *, const char *b, const char *e); +size_t my_numcells_mb(CHARSET_INFO *, const char *b, const char *e); +size_t my_charpos_mb(CHARSET_INFO *, const char *b, const char *e, size_t pos); +size_t my_well_formed_len_mb(CHARSET_INFO *, const char *b, const char *e, + size_t pos, int *error); uint my_instr_mb(struct charset_info_st *, - const char *b, uint b_length, - const char *s, uint s_length, + const char *b, size_t b_length, + const char *s, size_t s_length, my_match_t *match, uint nmatch); int my_wildcmp_unicode(CHARSET_INFO *cs, @@ -444,13 +447,13 @@ int my_wildcmp_unicode(CHARSET_INFO *cs, int escape, int w_one, int w_many, MY_UNICASE_INFO **weights); -extern my_bool my_parse_charset_xml(const char *bug, uint len, +extern my_bool my_parse_charset_xml(const char *bug, size_t len, int (*add)(CHARSET_INFO *cs)); extern char *my_strchr(CHARSET_INFO *cs, const char *str, const char *end, pchar c); -my_bool my_propagate_simple(CHARSET_INFO *cs, const uchar *str, uint len); -my_bool my_propagate_complex(CHARSET_INFO *cs, const uchar *str, uint len); +my_bool my_propagate_simple(CHARSET_INFO *cs, const uchar *str, size_t len); +my_bool my_propagate_complex(CHARSET_INFO *cs, const uchar *str, size_t len); #define _MY_U 01 /* Upper case */ diff --git a/include/m_string.h b/include/m_string.h index 4f098c3206d..ea5e04f48bc 100644 --- a/include/m_string.h +++ b/include/m_string.h @@ -112,59 +112,59 @@ extern char NEAR _dig_vec_lower[]; /* Prototypes for string functions */ #if !defined(bfill) && !defined(HAVE_BFILL) -extern void bfill(gptr dst,uint len,pchar fill); +extern void bfill(uchar *dst,size_t len,pchar fill); #endif #if !defined(bzero) && !defined(HAVE_BZERO) -extern void bzero(gptr dst,uint len); +extern void bzero(uchar * dst,size_t len); #endif #if !defined(bcmp) && !defined(HAVE_BCMP) -extern int bcmp(const char *s1,const char *s2,uint len); +extern size_t bcmp(const uchar *s1,const uchar *s2,size_t len); #endif #ifdef HAVE_purify -extern int my_bcmp(const char *s1,const char *s2,uint len); +extern size_t my_bcmp(const uchar *s1,const uchar *s2,size_t len); #undef bcmp #define bcmp(A,B,C) my_bcmp((A),(B),(C)) #endif #ifndef bmove512 -extern void bmove512(gptr dst,const gptr src,uint len); +extern void bmove512(uchar *dst,const uchar *src,size_t len); #endif #if !defined(HAVE_BMOVE) && !defined(bmove) -extern void bmove(char *dst, const char *src,uint len); +extern void bmove(uuchar *dst, const uchar *src,size_t len); #endif -extern void bmove_upp(char *dst,const char *src,uint len); -extern void bchange(char *dst,uint old_len,const char *src, - uint new_len,uint tot_len); -extern void strappend(char *s,uint len,pchar fill); +extern void bmove_upp(uchar *dst,const uchar *src,size_t len); +extern void bchange(uchar *dst,size_t old_len,const uchar *src, + size_t new_len,size_t tot_len); +extern void strappend(char *s,size_t len,pchar fill); extern char *strend(const char *s); extern char *strcend(const char *, pchar); extern char *strfield(char *src,int fields,int chars,int blanks, int tabch); -extern char *strfill(my_string s,uint len,pchar fill); -extern uint strinstr(const char *str,const char *search); -extern uint r_strinstr(reg1 my_string str,int from, reg4 my_string search); +extern char *strfill(char * s,size_t len,pchar fill); +extern size_t strinstr(const char *str,const char *search); +extern size_t r_strinstr(const char *str, size_t from, const char *search); extern char *strkey(char *dst,char *head,char *tail,char *flags); -extern char *strmake(char *dst,const char *src,uint length); +extern char *strmake(char *dst,const char *src,size_t length); #ifndef strmake_overlapp -extern char *strmake_overlapp(char *dst,const char *src, uint length); +extern char *strmake_overlapp(char *dst,const char *src, size_t length); #endif #ifndef strmov extern char *strmov(char *dst,const char *src); #endif -extern char *strnmov(char *dst,const char *src,uint n); +extern char *strnmov(char *dst,const char *src,size_t n); extern char *strsuff(const char *src,const char *suffix); extern char *strcont(const char *src,const char *set); extern char *strxcat _VARARGS((char *dst,const char *src, ...)); extern char *strxmov _VARARGS((char *dst,const char *src, ...)); extern char *strxcpy _VARARGS((char *dst,const char *src, ...)); -extern char *strxncat _VARARGS((char *dst,uint len, const char *src, ...)); -extern char *strxnmov _VARARGS((char *dst,uint len, const char *src, ...)); -extern char *strxncpy _VARARGS((char *dst,uint len, const char *src, ...)); +extern char *strxncat _VARARGS((char *dst,size_t len, const char *src, ...)); +extern char *strxnmov _VARARGS((char *dst,size_t len, const char *src, ...)); +extern char *strxncpy _VARARGS((char *dst,size_t len, const char *src, ...)); /* Prototypes of normal stringfunctions (with may ours) */ @@ -179,7 +179,7 @@ extern size_t strlen(const char *); #endif #endif #ifndef HAVE_STRNLEN -extern uint strnlen(const char *s, uint n); +extern size_t strnlen(const char *s, size_t n); #endif #if !defined(__cplusplus) @@ -232,9 +232,9 @@ extern ulonglong strtoull(const char *str, char **ptr, int base); /* my_vsnprintf.c */ -extern int my_vsnprintf( char *str, size_t n, - const char *format, va_list ap ); -extern int my_snprintf(char *to, size_t n, const char *fmt, ...) +extern size_t my_vsnprintf(char *str, size_t n, + const char *format, va_list ap); +extern size_t my_snprintf(char *to, size_t n, const char *fmt, ...) ATTRIBUTE_FORMAT(printf, 3, 4); #if defined(__cplusplus) @@ -245,17 +245,18 @@ extern int my_snprintf(char *to, size_t n, const char *fmt, ...) LEX_STRING -- a pair of a C-string and its length. NOTE: this exactly form of declaration is required for some C-compilers - (for one, Sun C 5.7 2005/01/07). Unfortunatelt with such declaration + (for one, Sun C 5.7 2005/01/07). Unfortunately with such declaration LEX_STRING can not be forward declared. */ typedef struct { char *str; - uint length; + size_t length; } LEX_STRING; -#define STRING_WITH_LEN(X) (X), ((uint) (sizeof(X) - 1)) -#define C_STRING_WITH_LEN(X) ((char *) (X)), ((uint) (sizeof(X) - 1)) +#define STRING_WITH_LEN(X) (X), ((size_t) (sizeof(X) - 1)) +#define USTRING_WITH_LEN(X) ((uchar*) X), ((size_t) (sizeof(X) - 1)) +#define C_STRING_WITH_LEN(X) ((char *) (X)), ((size_t) (sizeof(X) - 1)) #endif diff --git a/include/my_alloc.h b/include/my_alloc.h index 657394a363b..93b7438a1df 100644 --- a/include/my_alloc.h +++ b/include/my_alloc.h @@ -37,8 +37,8 @@ typedef struct st_mem_root USED_MEM *used; /* blocks almost without free memory */ USED_MEM *pre_alloc; /* preallocated block */ /* if block have less memory it will be put in 'used' list */ - unsigned int min_malloc; - unsigned int block_size; /* initial block size */ + size_t min_malloc; + size_t block_size; /* initial block size */ unsigned int block_num; /* allocated blocks counter */ /* first free block in queue test counter (if it exceed diff --git a/include/my_base.h b/include/my_base.h index 37110810558..617cdb8c3f0 100644 --- a/include/my_base.h +++ b/include/my_base.h @@ -478,7 +478,7 @@ enum data_file_type { typedef struct st_key_range { - const byte *key; + const uchar *key; uint length; key_part_map keypart_map; enum ha_rkey_function flag; diff --git a/include/my_dbug.h b/include/my_dbug.h index 0541cf00c29..514cd17099b 100644 --- a/include/my_dbug.h +++ b/include/my_dbug.h @@ -23,8 +23,8 @@ extern "C" { struct _db_code_state_; extern int _db_keyword_(struct _db_code_state_ *cs, const char *keyword); extern int _db_strict_keyword_(const char *keyword); -extern int _db_explain_(struct _db_code_state_ *cs, char *buf, int len); -extern int _db_explain_init_(char *buf, int len); +extern int _db_explain_(struct _db_code_state_ *cs, char *buf, size_t len); +extern int _db_explain_init_(char *buf, size_t len); extern void _db_setjmp_(void); extern void _db_longjmp_(void); extern void _db_process_(const char *name); @@ -40,8 +40,8 @@ extern void _db_return_(uint _line_,const char **_sfunc_,const char **_sfile_, extern void _db_pargs_(uint _line_,const char *keyword); extern void _db_doprnt_ _VARARGS((const char *format,...)) ATTRIBUTE_FORMAT(printf, 1, 2); -extern void _db_dump_(uint _line_,const char *keyword,const char *memory, - uint length); +extern void _db_dump_(uint _line_,const char *keyword, + const unsigned char *memory, size_t length); extern void _db_end_(void); extern void _db_lock_file_(void); extern void _db_unlock_file_(void); diff --git a/include/my_getopt.h b/include/my_getopt.h index a14507847be..115abf00618 100644 --- a/include/my_getopt.h +++ b/include/my_getopt.h @@ -44,8 +44,8 @@ struct my_option const char *name; /* Name of the option */ int id; /* unique id or short option */ const char *comment; /* option comment, for autom. --help */ - gptr *value; /* The variable value */ - gptr *u_max_value; /* The user def. max variable value */ + uchar **value; /* The variable value */ + uchar **u_max_value; /* The user def. max variable value */ struct st_typelib *typelib; /* Pointer to possible values */ ulong var_type; enum get_opt_arg_type arg_type; @@ -69,7 +69,7 @@ extern int handle_options (int *argc, char ***argv, const struct my_option *longopts, my_get_one_option); extern void my_print_help(const struct my_option *options); extern void my_print_variables(const struct my_option *options); -extern void my_getopt_register_get_addr(gptr* (*func_addr)(const char *, uint, +extern void my_getopt_register_get_addr(uchar ** (*func_addr)(const char *, uint, const struct my_option *)); ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp); diff --git a/include/my_global.h b/include/my_global.h index 81739979d48..ac6d48b68f2 100644 --- a/include/my_global.h +++ b/include/my_global.h @@ -885,21 +885,14 @@ typedef long my_ptrdiff_t; typedef long long my_ptrdiff_t; #endif -/* We can't set my_size_t to size_t as we want my_size_t to be unsigned */ -#if SIZEOF_CHARP <= SIZEOF_LONG -typedef unsigned long my_size_t; -#else -typedef unsigned long long my_size_t; -#endif - #define MY_ALIGN(A,L) (((A) + (L) - 1) & ~((L) - 1)) #define ALIGN_SIZE(A) MY_ALIGN((A),sizeof(double)) /* Size to make adressable obj. */ #define ALIGN_PTR(A, t) ((t*) MY_ALIGN((A),sizeof(t))) /* Offset of field f in structure t */ #define OFFSET(t, f) ((size_t)(char *)&((t *)0)->f) -#define ADD_TO_PTR(ptr,size,type) (type) ((byte*) (ptr)+size) -#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((byte*) (A) - (byte*) (B)) +#define ADD_TO_PTR(ptr,size,type) (type) ((uchar*) (ptr)+size) +#define PTR_BYTE_DIFF(A,B) (my_ptrdiff_t) ((uchar*) (A) - (uchar*) (B)) /* Custom version of standard offsetof() macro which can be used to get @@ -934,11 +927,6 @@ typedef unsigned long long my_size_t; /* Typdefs for easyier portability */ -#if defined(VOIDTYPE) -typedef void *gptr; /* Generic pointer */ -#else -typedef char *gptr; /* Generic pointer */ -#endif #ifndef HAVE_UCHAR typedef unsigned char uchar; /* Short for unsigned char */ #endif @@ -1059,12 +1047,7 @@ typedef off_t os_off_t; typedef uint8 int7; /* Most effective integer 0 <= x <= 127 */ typedef short int15; /* Most effective integer 0 <= x <= 32767 */ -typedef char *my_string; /* String of characters */ -typedef unsigned long size_s; /* Size of strings (In string-funcs) */ typedef int myf; /* Type of MyFlags in my_funcs */ -#ifndef byte_defined -typedef char byte; /* Smallest addressable unit */ -#endif typedef char my_bool; /* Small bool */ #if !defined(bool) && !defined(bool_defined) && (!defined(HAVE_BOOL) || !defined(__cplusplus)) typedef char bool; /* Ordinary boolean values 0 1 */ @@ -1210,9 +1193,9 @@ do { doubleget_union _tmp; \ } while (0) #define float4get(V,M) do { *((float *) &(V)) = *((float*) (M)); } while(0) #define float8get(V,M) doubleget((V),(M)) -#define float4store(V,M) memcpy((byte*) V,(byte*) (&M),sizeof(float)) -#define floatstore(T,V) memcpy((byte*)(T), (byte*)(&V),sizeof(float)) -#define floatget(V,M) memcpy((byte*) &V,(byte*) (M),sizeof(float)) +#define float4store(V,M) memcpy((uchar*) V,(uchar*) (&M),sizeof(float)) +#define floatstore(T,V) memcpy((uchar*)(T), (uchar*)(&V),sizeof(float)) +#define floatget(V,M) memcpy((uchar*) &V,(uchar*) (M),sizeof(float)) #define float8store(V,M) doublestore((V),(M)) #endif /* __i386__ */ @@ -1295,59 +1278,59 @@ do { doubleget_union _tmp; \ int4store((T),def_temp); \ int4store((T+4),def_temp2); } while(0) #ifdef WORDS_BIGENDIAN -#define float4store(T,A) do { *(T)= ((byte *) &A)[3];\ - *((T)+1)=(char) ((byte *) &A)[2];\ - *((T)+2)=(char) ((byte *) &A)[1];\ - *((T)+3)=(char) ((byte *) &A)[0]; } while(0) +#define float4store(T,A) do { *(T)= ((uchar *) &A)[3];\ + *((T)+1)=(char) ((uchar *) &A)[2];\ + *((T)+2)=(char) ((uchar *) &A)[1];\ + *((T)+3)=(char) ((uchar *) &A)[0]; } while(0) #define float4get(V,M) do { float def_temp;\ - ((byte*) &def_temp)[0]=(M)[3];\ - ((byte*) &def_temp)[1]=(M)[2];\ - ((byte*) &def_temp)[2]=(M)[1];\ - ((byte*) &def_temp)[3]=(M)[0];\ + ((uchar*) &def_temp)[0]=(M)[3];\ + ((uchar*) &def_temp)[1]=(M)[2];\ + ((uchar*) &def_temp)[2]=(M)[1];\ + ((uchar*) &def_temp)[3]=(M)[0];\ (V)=def_temp; } while(0) -#define float8store(T,V) do { *(T)= ((byte *) &V)[7];\ - *((T)+1)=(char) ((byte *) &V)[6];\ - *((T)+2)=(char) ((byte *) &V)[5];\ - *((T)+3)=(char) ((byte *) &V)[4];\ - *((T)+4)=(char) ((byte *) &V)[3];\ - *((T)+5)=(char) ((byte *) &V)[2];\ - *((T)+6)=(char) ((byte *) &V)[1];\ - *((T)+7)=(char) ((byte *) &V)[0]; } while(0) +#define float8store(T,V) do { *(T)= ((uchar *) &V)[7];\ + *((T)+1)=(char) ((uchar *) &V)[6];\ + *((T)+2)=(char) ((uchar *) &V)[5];\ + *((T)+3)=(char) ((uchar *) &V)[4];\ + *((T)+4)=(char) ((uchar *) &V)[3];\ + *((T)+5)=(char) ((uchar *) &V)[2];\ + *((T)+6)=(char) ((uchar *) &V)[1];\ + *((T)+7)=(char) ((uchar *) &V)[0]; } while(0) #define float8get(V,M) do { double def_temp;\ - ((byte*) &def_temp)[0]=(M)[7];\ - ((byte*) &def_temp)[1]=(M)[6];\ - ((byte*) &def_temp)[2]=(M)[5];\ - ((byte*) &def_temp)[3]=(M)[4];\ - ((byte*) &def_temp)[4]=(M)[3];\ - ((byte*) &def_temp)[5]=(M)[2];\ - ((byte*) &def_temp)[6]=(M)[1];\ - ((byte*) &def_temp)[7]=(M)[0];\ + ((uchar*) &def_temp)[0]=(M)[7];\ + ((uchar*) &def_temp)[1]=(M)[6];\ + ((uchar*) &def_temp)[2]=(M)[5];\ + ((uchar*) &def_temp)[3]=(M)[4];\ + ((uchar*) &def_temp)[4]=(M)[3];\ + ((uchar*) &def_temp)[5]=(M)[2];\ + ((uchar*) &def_temp)[6]=(M)[1];\ + ((uchar*) &def_temp)[7]=(M)[0];\ (V) = def_temp; } while(0) #else -#define float4get(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float)) -#define float4store(V,M) memcpy_fixed((byte*) V,(byte*) (&M),sizeof(float)) +#define float4get(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(float)) +#define float4store(V,M) memcpy_fixed((uchar*) V,(uchar*) (&M),sizeof(float)) #if defined(__FLOAT_WORD_ORDER) && (__FLOAT_WORD_ORDER == __BIG_ENDIAN) -#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((byte *) &V)[4];\ - *(((char*)T)+1)=(char) ((byte *) &V)[5];\ - *(((char*)T)+2)=(char) ((byte *) &V)[6];\ - *(((char*)T)+3)=(char) ((byte *) &V)[7];\ - *(((char*)T)+4)=(char) ((byte *) &V)[0];\ - *(((char*)T)+5)=(char) ((byte *) &V)[1];\ - *(((char*)T)+6)=(char) ((byte *) &V)[2];\ - *(((char*)T)+7)=(char) ((byte *) &V)[3]; }\ +#define doublestore(T,V) do { *(((char*)T)+0)=(char) ((uchar *) &V)[4];\ + *(((char*)T)+1)=(char) ((uchar *) &V)[5];\ + *(((char*)T)+2)=(char) ((uchar *) &V)[6];\ + *(((char*)T)+3)=(char) ((uchar *) &V)[7];\ + *(((char*)T)+4)=(char) ((uchar *) &V)[0];\ + *(((char*)T)+5)=(char) ((uchar *) &V)[1];\ + *(((char*)T)+6)=(char) ((uchar *) &V)[2];\ + *(((char*)T)+7)=(char) ((uchar *) &V)[3]; }\ while(0) #define doubleget(V,M) do { double def_temp;\ - ((byte*) &def_temp)[0]=(M)[4];\ - ((byte*) &def_temp)[1]=(M)[5];\ - ((byte*) &def_temp)[2]=(M)[6];\ - ((byte*) &def_temp)[3]=(M)[7];\ - ((byte*) &def_temp)[4]=(M)[0];\ - ((byte*) &def_temp)[5]=(M)[1];\ - ((byte*) &def_temp)[6]=(M)[2];\ - ((byte*) &def_temp)[7]=(M)[3];\ + ((uchar*) &def_temp)[0]=(M)[4];\ + ((uchar*) &def_temp)[1]=(M)[5];\ + ((uchar*) &def_temp)[2]=(M)[6];\ + ((uchar*) &def_temp)[3]=(M)[7];\ + ((uchar*) &def_temp)[4]=(M)[0];\ + ((uchar*) &def_temp)[5]=(M)[1];\ + ((uchar*) &def_temp)[6]=(M)[2];\ + ((uchar*) &def_temp)[7]=(M)[3];\ (V) = def_temp; } while(0) #endif /* __FLOAT_WORD_ORDER */ @@ -1378,16 +1361,16 @@ do { doubleget_union _tmp; \ #define shortget(V,M) do { V = (short) (((short) ((uchar) (M)[1]))+\ ((short) ((short) (M)[0]) << 8)); } while(0) #define longget(V,M) do { int32 def_temp;\ - ((byte*) &def_temp)[0]=(M)[0];\ - ((byte*) &def_temp)[1]=(M)[1];\ - ((byte*) &def_temp)[2]=(M)[2];\ - ((byte*) &def_temp)[3]=(M)[3];\ + ((uchar*) &def_temp)[0]=(M)[0];\ + ((uchar*) &def_temp)[1]=(M)[1];\ + ((uchar*) &def_temp)[2]=(M)[2];\ + ((uchar*) &def_temp)[3]=(M)[3];\ (V)=def_temp; } while(0) #define ulongget(V,M) do { uint32 def_temp;\ - ((byte*) &def_temp)[0]=(M)[0];\ - ((byte*) &def_temp)[1]=(M)[1];\ - ((byte*) &def_temp)[2]=(M)[2];\ - ((byte*) &def_temp)[3]=(M)[3];\ + ((uchar*) &def_temp)[0]=(M)[0];\ + ((uchar*) &def_temp)[1]=(M)[1];\ + ((uchar*) &def_temp)[2]=(M)[2];\ + ((uchar*) &def_temp)[3]=(M)[3];\ (V)=def_temp; } while(0) #define shortstore(T,A) do { uint def_temp=(uint) (A) ;\ *(((char*)T)+1)=(char)(def_temp); \ @@ -1397,12 +1380,12 @@ do { doubleget_union _tmp; \ *(((char*)T)+1)=(((A) >> 16));\ *(((char*)T)+0)=(((A) >> 24)); } while(0) -#define floatget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(float)) -#define floatstore(T,V) memcpy_fixed((byte*) (T),(byte*)(&V),sizeof(float)) -#define doubleget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double)) -#define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double)) -#define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong)) -#define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong)) +#define floatget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(float)) +#define floatstore(T,V) memcpy_fixed((uchar*) (T),(uchar*)(&V),sizeof(float)) +#define doubleget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(double)) +#define doublestore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(double)) +#define longlongget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(ulonglong)) +#define longlongstore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(ulonglong)) #else @@ -1413,15 +1396,15 @@ do { doubleget_union _tmp; \ #define shortstore(T,V) int2store(T,V) #define longstore(T,V) int4store(T,V) #ifndef floatstore -#define floatstore(T,V) memcpy_fixed((byte*) (T),(byte*) (&V),sizeof(float)) -#define floatget(V,M) memcpy_fixed((byte*) &V, (byte*) (M), sizeof(float)) +#define floatstore(T,V) memcpy_fixed((uchar*) (T),(uchar*) (&V),sizeof(float)) +#define floatget(V,M) memcpy_fixed((uchar*) &V, (uchar*) (M), sizeof(float)) #endif #ifndef doubleget -#define doubleget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(double)) -#define doublestore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(double)) +#define doubleget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(double)) +#define doublestore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(double)) #endif /* doubleget */ -#define longlongget(V,M) memcpy_fixed((byte*) &V,(byte*) (M),sizeof(ulonglong)) -#define longlongstore(T,V) memcpy_fixed((byte*) (T),(byte*) &V,sizeof(ulonglong)) +#define longlongget(V,M) memcpy_fixed((uchar*) &V,(uchar*) (M),sizeof(ulonglong)) +#define longlongstore(T,V) memcpy_fixed((uchar*) (T),(uchar*) &V,sizeof(ulonglong)) #endif /* WORDS_BIGENDIAN */ diff --git a/include/my_list.h b/include/my_list.h index 4a1737d4c53..775b56587b8 100644 --- a/include/my_list.h +++ b/include/my_list.h @@ -33,11 +33,11 @@ extern LIST *list_cons(void *data,LIST *root); extern LIST *list_reverse(LIST *root); extern void list_free(LIST *root,unsigned int free_data); extern unsigned int list_length(LIST *); -extern int list_walk(LIST *,list_walk_action action,gptr argument); +extern int list_walk(LIST *,list_walk_action action,unsigned char * argument); #define list_rest(a) ((a)->next) #define list_push(a,b) (a)=list_cons((b),(a)) -#define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old) ; my_free((gptr) old,MYF(MY_FAE)); } +#define list_pop(A) {LIST *old=(A); (A)=list_delete(old,old) ; my_free((unsigned char *) old,MYF(MY_FAE)); } #ifdef __cplusplus } diff --git a/include/my_nosys.h b/include/my_nosys.h index f8422699041..df5639b81e2 100644 --- a/include/my_nosys.h +++ b/include/my_nosys.h @@ -35,8 +35,9 @@ extern "C" { #undef my_seek #define my_read(a,b,c,d) my_quick_read(a,b,c,d) #define my_write(a,b,c,d) my_quick_write(a,b,c) -extern uint my_quick_read(File Filedes,byte *Buffer,uint Count,myf myFlags); -extern uint my_quick_write(File Filedes,const byte *Buffer,uint Count); +extern size_t my_quick_read(File Filedes,uchar *Buffer,size_t Count, + myf myFlags); +extern size_t my_quick_write(File Filedes,const uchar *Buffer,size_t Count); #if !defined(SAFEMALLOC) && defined(USE_HALLOC) #define my_malloc(a,b) halloc(a,1) diff --git a/include/my_pthread.h b/include/my_pthread.h index e282d16fa12..e2cce40182d 100644 --- a/include/my_pthread.h +++ b/include/my_pthread.h @@ -688,7 +688,7 @@ struct st_my_thread_var struct st_my_thread_var *next,**prev; void *opt_info; #ifndef DBUG_OFF - gptr dbug; + void *dbug; char name[THREAD_NAME_SIZE+1]; #endif }; diff --git a/include/my_sys.h b/include/my_sys.h index d9e16b5f917..a8633982f84 100644 --- a/include/my_sys.h +++ b/include/my_sys.h @@ -41,7 +41,7 @@ extern int NEAR my_errno; /* Last error in mysys */ #define ERRMSGSIZE (SC_MAXWIDTH) /* Max length of a error message */ #define NRERRBUFFS (2) /* Buffers for parameters */ -#define MY_FILE_ERROR ((uint) ~0) +#define MY_FILE_ERROR ((size_t) -1) /* General bitmaps for my_func's */ #define MY_FFNF 1 /* Fatal if file not found */ @@ -153,13 +153,13 @@ extern ulonglong sf_malloc_mem_limit; #define TERMINATE(A) {} #define QUICK_SAFEMALLOC #define NORMAL_SAFEMALLOC -extern gptr my_malloc(uint Size,myf MyFlags); +extern void *my_malloc(size_t Size,myf MyFlags); #define my_malloc_ci(SZ,FLAG) my_malloc( SZ, FLAG ) -extern gptr my_realloc(gptr oldpoint,uint Size,myf MyFlags); -extern void my_no_flags_free(gptr ptr); -extern gptr my_memdup(const byte *from,uint length,myf MyFlags); +extern void *my_realloc(void *oldpoint, size_t Size, myf MyFlags); +extern void my_no_flags_free(void *ptr); +extern void *my_memdup(const void *from,size_t length,myf MyFlags); extern char *my_strdup(const char *from,myf MyFlags); -extern char *my_strndup(const char *from, uint length, +extern char *my_strndup(const char *from, size_t length, myf MyFlags); /* we do use FG (as a no-op) in below so that a typo on FG is caught */ #define my_free(PTR,FG) ((void)FG,my_no_flags_free(PTR)) @@ -171,8 +171,8 @@ extern char *my_strndup(const char *from, uint length, #ifdef HAVE_LARGE_PAGES extern uint my_get_large_page_size(void); -extern gptr my_large_malloc(uint size, myf my_flags); -extern void my_large_free(gptr ptr, myf my_flags); +extern uchar * my_large_malloc(size_t size, myf my_flags); +extern void my_large_free(uchar * ptr, myf my_flags); #else #define my_get_large_page_size() (0) #define my_large_malloc(A,B) my_malloc_lock((A),(B)) @@ -258,7 +258,7 @@ typedef struct wild_file_pack /* Struct to hold info when selecting files */ { uint wilds; /* How many wildcards */ uint not_pos; /* Start of not-theese-files */ - my_string *wild; /* Pointer to wildcards */ + char * *wild; /* Pointer to wildcards */ } WF_PACK; enum loglevel { @@ -284,7 +284,7 @@ typedef struct st_record_cache /* Used when cacheing records */ int rc_seek,error,inited; uint rc_length,read_length,reclength; my_off_t rc_record_pos,end_of_file; - byte *rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos; + uchar *rc_buff,*rc_buff2,*rc_pos,*rc_end,*rc_request_pos; #ifdef HAVE_AIOWAIT int use_async_io; my_aio_result aio_result; @@ -300,7 +300,7 @@ enum file_type struct st_my_file_info { - my_string name; + char * name; enum file_type type; #if defined(THREAD) && !defined(HAVE_PREAD) pthread_mutex_t mutex; @@ -311,7 +311,7 @@ extern struct st_my_file_info *my_file_info; typedef struct st_dynamic_array { - char *buffer; + uchar *buffer; uint elements,max_element; uint alloc_increment; uint size_of_element; @@ -330,7 +330,7 @@ typedef struct st_my_tmpdir typedef struct st_dynamic_string { char *str; - uint length,max_length,alloc_increment; + size_t length,max_length,alloc_increment; } DYNAMIC_STRING; struct st_io_cache; @@ -346,8 +346,8 @@ typedef struct st_io_cache_share my_off_t pos_in_file; /* If a synchronized write cache is the source of the data. */ struct st_io_cache *source_cache; - byte *buffer; /* The read buffer. */ - byte *read_end; /* Behind last valid byte of buffer. */ + uchar *buffer; /* The read buffer. */ + uchar *read_end; /* Behind last valid byte of buffer. */ int running_threads; /* threads not in lock. */ int total_threads; /* threads sharing the cache. */ int error; /* Last error. */ @@ -360,7 +360,7 @@ typedef struct st_io_cache_share typedef struct st_io_cache /* Used when cacheing files */ { - /* Offset in file corresponding to the first byte of byte* buffer. */ + /* Offset in file corresponding to the first byte of uchar* buffer. */ my_off_t pos_in_file; /* The offset of end of file for READ_CACHE and WRITE_CACHE. @@ -369,26 +369,26 @@ typedef struct st_io_cache /* Used when cacheing files */ */ my_off_t end_of_file; /* Points to current read position in the buffer */ - byte *read_pos; + uchar *read_pos; /* the non-inclusive boundary in the buffer for the currently valid read */ - byte *read_end; - byte *buffer; /* The read buffer */ + uchar *read_end; + uchar *buffer; /* The read buffer */ /* Used in ASYNC_IO */ - byte *request_pos; + uchar *request_pos; /* Only used in WRITE caches and in SEQ_READ_APPEND to buffer writes */ - byte *write_buffer; + uchar *write_buffer; /* Only used in SEQ_READ_APPEND, and points to the current read position in the write buffer. Note that reads in SEQ_READ_APPEND caches can - happen from both read buffer (byte* buffer) and write buffer - (byte* write_buffer). + happen from both read buffer (uchar* buffer) and write buffer + (uchar* write_buffer). */ - byte *append_read_pos; + uchar *append_read_pos; /* Points to current write position in the write buffer */ - byte *write_pos; + uchar *write_pos; /* The non-inclusive boundary of the valid write area */ - byte *write_end; + uchar *write_end; /* Current_pos and current_end are convenience variables used by @@ -396,7 +396,7 @@ typedef struct st_io_cache /* Used when cacheing files */ current_pos points to &write_pos, and current_end to &write_end in a WRITE_CACHE, and &read_pos and &read_end respectively otherwise */ - byte **current_pos, **current_end; + uchar **current_pos, **current_end; #ifdef THREAD /* The lock is for append buffer used in SEQ_READ_APPEND cache @@ -420,12 +420,12 @@ typedef struct st_io_cache /* Used when cacheing files */ my_b_read() will call read_function to fetch the data. read_function must never be invoked directly. */ - int (*read_function)(struct st_io_cache *,byte *,uint); + int (*read_function)(struct st_io_cache *,uchar *,size_t); /* Same idea as in the case of read_function, except my_b_write() needs to be replaced with my_b_append() for a SEQ_READ_APPEND cache */ - int (*write_function)(struct st_io_cache *,const byte *,uint); + int (*write_function)(struct st_io_cache *,const uchar *,size_t); /* Specifies the type of the cache. Depending on the type of the cache certain operations might not be available and yield unpredicatable @@ -460,9 +460,9 @@ typedef struct st_io_cache /* Used when cacheing files */ */ int seek_not_done,error; /* buffer_length is memory size allocated for buffer or write_buffer */ - uint buffer_length; + size_t buffer_length; /* read_length is the same as buffer_length except when we use async io */ - uint read_length; + size_t read_length; myf myflags; /* Flags used to my_read/my_write */ /* alloced_buffer is 1 if the buffer was allocated by init_io_cache() and @@ -518,14 +518,14 @@ typedef int (*qsort2_cmp)(const void *, const void *, const void *); (((info)->read_end=(info)->read_pos),(*(info)->read_function)(info,0,0)) #define my_b_tell(info) ((info)->pos_in_file + \ - (uint) (*(info)->current_pos - (info)->request_pos)) + (size_t) (*(info)->current_pos - (info)->request_pos)) /* tell write offset in the SEQ_APPEND cache */ int my_b_copy_to_file(IO_CACHE *cache, FILE *file); my_off_t my_b_append_tell(IO_CACHE* info); my_off_t my_b_safe_tell(IO_CACHE* info); /* picks the correct tell() */ -#define my_b_bytes_in_cache(info) (uint) (*(info)->current_end - \ +#define my_b_bytes_in_cache(info) (size_t) (*(info)->current_end - \ *(info)->current_pos) typedef uint32 ha_checksum; @@ -542,13 +542,13 @@ typedef int (*Process_option_func)(void *ctx, const char *group_name, extern int my_copy(const char *from,const char *to,myf MyFlags); extern int my_append(const char *from,const char *to,myf MyFlags); extern int my_delete(const char *name,myf MyFlags); -extern int my_getwd(my_string buf,uint size,myf MyFlags); +extern int my_getwd(char * buf,size_t size,myf MyFlags); extern int my_setwd(const char *dir,myf MyFlags); extern int my_lock(File fd,int op,my_off_t start, my_off_t length,myf MyFlags); -extern gptr my_once_alloc(uint Size,myf MyFlags); +extern void *my_once_alloc(size_t Size,myf MyFlags); extern void my_once_free(void); extern char *my_once_strdup(const char *src,myf myflags); -extern char *my_once_memdup(const char *src, uint len, myf myflags); +extern void *my_once_memdup(const void *src, size_t len, myf myflags); extern File my_open(const char *FileName,int Flags,myf MyFlags); extern File my_register_filename(File fd, const char *FileName, enum file_type type_of_file, @@ -566,39 +566,39 @@ extern File my_create_with_symlink(const char *linkname, const char *filename, extern int my_delete_with_symlink(const char *name, myf MyFlags); extern int my_rename_with_symlink(const char *from,const char *to,myf MyFlags); extern int my_symlink(const char *content, const char *linkname, myf MyFlags); -extern uint my_read(File Filedes,byte *Buffer,uint Count,myf MyFlags); -extern uint my_pread(File Filedes,byte *Buffer,uint Count,my_off_t offset, +extern size_t my_read(File Filedes,uchar *Buffer,size_t Count,myf MyFlags); +extern size_t my_pread(File Filedes,uchar *Buffer,size_t Count,my_off_t offset, myf MyFlags); extern int my_rename(const char *from,const char *to,myf MyFlags); extern my_off_t my_seek(File fd,my_off_t pos,int whence,myf MyFlags); extern my_off_t my_tell(File fd,myf MyFlags); -extern uint my_write(File Filedes,const byte *Buffer,uint Count, +extern size_t my_write(File Filedes,const uchar *Buffer,size_t Count, myf MyFlags); -extern uint my_pwrite(File Filedes,const byte *Buffer,uint Count, +extern size_t my_pwrite(File Filedes,const uchar *Buffer,size_t Count, my_off_t offset,myf MyFlags); -extern uint my_fread(FILE *stream,byte *Buffer,uint Count,myf MyFlags); -extern uint my_fwrite(FILE *stream,const byte *Buffer,uint Count, +extern size_t my_fread(FILE *stream,uchar *Buffer,size_t Count,myf MyFlags); +extern size_t my_fwrite(FILE *stream,const uchar *Buffer,size_t Count, myf MyFlags); extern my_off_t my_fseek(FILE *stream,my_off_t pos,int whence,myf MyFlags); extern my_off_t my_ftell(FILE *stream,myf MyFlags); -extern gptr _mymalloc(uint uSize,const char *sFile, - uint uLine, myf MyFlag); -extern gptr _myrealloc(gptr pPtr,uint uSize,const char *sFile, +extern void *_mymalloc(size_t uSize,const char *sFile, + uint uLine, myf MyFlag); +extern void *_myrealloc(void *pPtr,size_t uSize,const char *sFile, uint uLine, myf MyFlag); -extern gptr my_multi_malloc _VARARGS((myf MyFlags, ...)); -extern void _myfree(gptr pPtr,const char *sFile,uint uLine, myf MyFlag); -extern int _sanity(const char *sFile,unsigned int uLine); -extern gptr _my_memdup(const byte *from,uint length, - const char *sFile, uint uLine,myf MyFlag); -extern my_string _my_strdup(const char *from, const char *sFile, uint uLine, - myf MyFlag); -extern char *_my_strndup(const char *from, uint length, - const char *sFile, uint uLine, - myf MyFlag); +extern void * my_multi_malloc _VARARGS((myf MyFlags, ...)); +extern void _myfree(void *pPtr,const char *sFile,uint uLine, myf MyFlag); +extern int _sanity(const char *sFile, uint uLine); +extern void *_my_memdup(const void *from, size_t length, + const char *sFile, uint uLine,myf MyFlag); +extern char * _my_strdup(const char *from, const char *sFile, uint uLine, + myf MyFlag); +extern char *_my_strndup(const char *from, size_t length, + const char *sFile, uint uLine, + myf MyFlag); /* implemented in my_memmem.c */ extern void *my_memmem(const void *haystack, size_t haystacklen, - const void *needle, size_t needlelen); + const void *needle, size_t needlelen); #ifdef __WIN__ @@ -639,7 +639,7 @@ extern my_bool my_init(void); extern void my_end(int infoflag); extern int my_redel(const char *from, const char *to, int MyFlags); extern int my_copystat(const char *from, const char *to, int MyFlags); -extern my_string my_filename(File fd); +extern char * my_filename(File fd); #ifndef THREAD extern void dont_break(void); @@ -660,97 +660,97 @@ extern char *my_tmpdir(MY_TMPDIR *tmpdir); extern void free_tmpdir(MY_TMPDIR *tmpdir); extern void my_remember_signal(int signal_number,sig_handler (*func)(int)); -extern uint dirname_part(my_string to,const char *name); -extern uint dirname_length(const char *name); +extern size_t dirname_part(char * to, const char *name, size_t *to_res_length); +extern size_t dirname_length(const char *name); #define base_name(A) (A+dirname_length(A)) extern int test_if_hard_path(const char *dir_name); extern my_bool has_path(const char *name); extern char *convert_dirname(char *to, const char *from, const char *from_end); -extern void to_unix_path(my_string name); -extern my_string fn_ext(const char *name); -extern my_string fn_same(my_string toname,const char *name,int flag); -extern my_string fn_format(my_string to,const char *name,const char *dir, +extern void to_unix_path(char * name); +extern char * fn_ext(const char *name); +extern char * fn_same(char * toname,const char *name,int flag); +extern char * fn_format(char * to,const char *name,const char *dir, const char *form, uint flag); -extern size_s strlength(const char *str); -extern void pack_dirname(my_string to,const char *from); -extern uint unpack_dirname(my_string to,const char *from); -extern uint cleanup_dirname(my_string to,const char *from); -extern uint system_filename(my_string to,const char *from); -extern uint unpack_filename(my_string to,const char *from); -extern my_string intern_filename(my_string to,const char *from); -extern my_string directory_file_name(my_string dst, const char *src); -extern int pack_filename(my_string to, const char *name, size_s max_length); -extern my_string my_path(my_string to,const char *progname, +extern size_t strlength(const char *str); +extern void pack_dirname(char * to,const char *from); +extern size_t unpack_dirname(char * to,const char *from); +extern size_t cleanup_dirname(char * to,const char *from); +extern size_t system_filename(char * to,const char *from); +extern size_t unpack_filename(char * to,const char *from); +extern char * intern_filename(char * to,const char *from); +extern char * directory_file_name(char * dst, const char *src); +extern int pack_filename(char * to, const char *name, size_t max_length); +extern char * my_path(char * to,const char *progname, const char *own_pathname_part); -extern my_string my_load_path(my_string to, const char *path, +extern char * my_load_path(char * to, const char *path, const char *own_path_prefix); extern int wild_compare(const char *str,const char *wildstr, pbool str_is_pattern); -extern WF_PACK *wf_comp(my_string str); +extern WF_PACK *wf_comp(char * str); extern int wf_test(struct wild_file_pack *wf_pack,const char *name); extern void wf_end(struct wild_file_pack *buffer); -extern size_s strip_sp(my_string str); -extern void get_date(my_string to,int timeflag,time_t use_time); -extern void soundex(CHARSET_INFO *, my_string out_pntr, my_string in_pntr, +extern size_t strip_sp(char * str); +extern void get_date(char * to,int timeflag,time_t use_time); +extern void soundex(CHARSET_INFO *, char * out_pntr, char * in_pntr, pbool remove_garbage); -extern int init_record_cache(RECORD_CACHE *info,uint cachesize,File file, - uint reclength,enum cache_type type, +extern int init_record_cache(RECORD_CACHE *info,size_t cachesize,File file, + size_t reclength,enum cache_type type, pbool use_async_io); -extern int read_cache_record(RECORD_CACHE *info,byte *to); +extern int read_cache_record(RECORD_CACHE *info,uchar *to); extern int end_record_cache(RECORD_CACHE *info); extern int write_cache_record(RECORD_CACHE *info,my_off_t filepos, - const byte *record,uint length); + const uchar *record,size_t length); extern int flush_write_cache(RECORD_CACHE *info); extern long my_clock(void); extern sig_handler sigtstp_handler(int signal_number); extern void handle_recived_signals(void); extern sig_handler my_set_alarm_variable(int signo); -extern void my_string_ptr_sort(void *base,uint items,size_s size); +extern void my_string_ptr_sort(uchar *base, uint items, size_t size); extern void radixsort_for_str_ptr(uchar* base[], uint number_of_elements, - size_s size_of_element,uchar *buffer[]); + size_t size_of_element,uchar *buffer[]); extern qsort_t qsort2(void *base_ptr, size_t total_elems, size_t size, qsort2_cmp cmp, void *cmp_argument); -extern qsort2_cmp get_ptr_compare(uint); -void my_store_ptr(byte *buff, uint pack_length, my_off_t pos); -my_off_t my_get_ptr(byte *ptr, uint pack_length); -extern int init_io_cache(IO_CACHE *info,File file,uint cachesize, +extern qsort2_cmp get_ptr_compare(size_t); +void my_store_ptr(uchar *buff, size_t pack_length, my_off_t pos); +my_off_t my_get_ptr(uchar *ptr, size_t pack_length); +extern int init_io_cache(IO_CACHE *info,File file,size_t cachesize, enum cache_type type,my_off_t seek_offset, pbool use_async_io, myf cache_myflags); extern my_bool reinit_io_cache(IO_CACHE *info,enum cache_type type, my_off_t seek_offset,pbool use_async_io, pbool clear_cache); extern void setup_io_cache(IO_CACHE* info); -extern int _my_b_read(IO_CACHE *info,byte *Buffer,uint Count); +extern int _my_b_read(IO_CACHE *info,uchar *Buffer,size_t Count); #ifdef THREAD -extern int _my_b_read_r(IO_CACHE *info,byte *Buffer,uint Count); +extern int _my_b_read_r(IO_CACHE *info,uchar *Buffer,size_t Count); extern void init_io_cache_share(IO_CACHE *read_cache, IO_CACHE_SHARE *cshare, IO_CACHE *write_cache, uint num_threads); extern void remove_io_thread(IO_CACHE *info); #endif -extern int _my_b_seq_read(IO_CACHE *info,byte *Buffer,uint Count); -extern int _my_b_net_read(IO_CACHE *info,byte *Buffer,uint Count); +extern int _my_b_seq_read(IO_CACHE *info,uchar *Buffer,size_t Count); +extern int _my_b_net_read(IO_CACHE *info,uchar *Buffer,size_t Count); extern int _my_b_get(IO_CACHE *info); -extern int _my_b_async_read(IO_CACHE *info,byte *Buffer,uint Count); -extern int _my_b_write(IO_CACHE *info,const byte *Buffer,uint Count); -extern int my_b_append(IO_CACHE *info,const byte *Buffer,uint Count); -extern int my_b_safe_write(IO_CACHE *info,const byte *Buffer,uint Count); +extern int _my_b_async_read(IO_CACHE *info,uchar *Buffer,size_t Count); +extern int _my_b_write(IO_CACHE *info,const uchar *Buffer,size_t Count); +extern int my_b_append(IO_CACHE *info,const uchar *Buffer,size_t Count); +extern int my_b_safe_write(IO_CACHE *info,const uchar *Buffer,size_t Count); -extern int my_block_write(IO_CACHE *info, const byte *Buffer, - uint Count, my_off_t pos); +extern int my_block_write(IO_CACHE *info, const uchar *Buffer, + size_t Count, my_off_t pos); extern int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock); #define flush_io_cache(info) my_b_flush_io_cache((info),1) extern int end_io_cache(IO_CACHE *info); -extern uint my_b_fill(IO_CACHE *info); +extern size_t my_b_fill(IO_CACHE *info); extern void my_b_seek(IO_CACHE *info,my_off_t pos); -extern uint my_b_gets(IO_CACHE *info, char *to, uint max_length); +extern size_t my_b_gets(IO_CACHE *info, char *to, size_t max_length); extern my_off_t my_b_filelength(IO_CACHE *info); -extern uint my_b_printf(IO_CACHE *info, const char* fmt, ...); -extern uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap); +extern size_t my_b_printf(IO_CACHE *info, const char* fmt, ...); +extern size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list ap); extern my_bool open_cached_file(IO_CACHE *cache,const char *dir, - const char *prefix, uint cache_size, + const char *prefix, size_t cache_size, myf cache_myflags); extern my_bool real_open_cached_file(IO_CACHE *cache); extern void close_cached_file(IO_CACHE *cache); @@ -768,15 +768,15 @@ extern my_bool init_dynamic_array2(DYNAMIC_ARRAY *array,uint element_size, extern my_bool init_dynamic_array(DYNAMIC_ARRAY *array,uint element_size, uint init_alloc,uint alloc_increment CALLER_INFO_PROTO); -extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,gptr element); -extern byte *alloc_dynamic(DYNAMIC_ARRAY *array); -extern byte *pop_dynamic(DYNAMIC_ARRAY*); -extern my_bool set_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index); -extern void get_dynamic(DYNAMIC_ARRAY *array,gptr element,uint array_index); +extern my_bool insert_dynamic(DYNAMIC_ARRAY *array,uchar * element); +extern uchar *alloc_dynamic(DYNAMIC_ARRAY *array); +extern uchar *pop_dynamic(DYNAMIC_ARRAY*); +extern my_bool set_dynamic(DYNAMIC_ARRAY *array,uchar * element,uint array_index); +extern void get_dynamic(DYNAMIC_ARRAY *array,uchar * element,uint array_index); extern void delete_dynamic(DYNAMIC_ARRAY *array); extern void delete_dynamic_element(DYNAMIC_ARRAY *array, uint array_index); extern void freeze_size(DYNAMIC_ARRAY *array); -extern int get_index_dynamic(DYNAMIC_ARRAY *array, gptr element); +extern int get_index_dynamic(DYNAMIC_ARRAY *array, uchar * element); #define dynamic_array_ptr(array,array_index) ((array)->buffer+(array_index)*(array)->size_of_element) #define dynamic_element(array,array_index,type) ((type)((array)->buffer) +(array_index)) #define push_dynamic(A,B) insert_dynamic((A),(B)) @@ -784,19 +784,19 @@ extern int get_index_dynamic(DYNAMIC_ARRAY *array, gptr element); #define sort_dynamic(A,cmp) qsort((A)->buffer, (A)->elements, (A)->size_of_element, (cmp)) extern my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str, - uint init_alloc,uint alloc_increment); + size_t init_alloc,size_t alloc_increment); extern my_bool dynstr_append(DYNAMIC_STRING *str, const char *append); my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append, - uint length); + size_t length); extern my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, ...); extern my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str); -extern my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size); -extern my_bool dynstr_trunc(DYNAMIC_STRING *str, int n); +extern my_bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size); +extern my_bool dynstr_trunc(DYNAMIC_STRING *str, size_t n); extern void dynstr_free(DYNAMIC_STRING *str); #ifdef HAVE_MLOCK -extern byte *my_malloc_lock(uint length,myf flags); -extern void my_free_lock(byte *ptr,myf flags); +extern void *my_malloc_lock(size_t length,myf flags); +extern void my_free_lock(void *ptr,myf flags); #else #define my_malloc_lock(A,B) my_malloc((A),(B)) #define my_free_lock(A,B) my_free((A),(B)) @@ -804,17 +804,17 @@ extern void my_free_lock(byte *ptr,myf flags); #define alloc_root_inited(A) ((A)->min_malloc != 0) #define ALLOC_ROOT_MIN_BLOCK_SIZE (MALLOC_OVERHEAD + sizeof(USED_MEM) + 8) #define clear_alloc_root(A) do { (A)->free= (A)->used= (A)->pre_alloc= 0; (A)->min_malloc=0;} while(0) -extern void init_alloc_root(MEM_ROOT *mem_root, uint block_size, - uint pre_alloc_size); -extern gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size); -extern gptr multi_alloc_root(MEM_ROOT *mem_root, ...); +extern void init_alloc_root(MEM_ROOT *mem_root, size_t block_size, + size_t pre_alloc_size); +extern void *alloc_root(MEM_ROOT *mem_root, size_t Size); +extern void *multi_alloc_root(MEM_ROOT *mem_root, ...); extern void free_root(MEM_ROOT *root, myf MyFLAGS); extern void set_prealloc_root(MEM_ROOT *root, char *ptr); -extern void reset_root_defaults(MEM_ROOT *mem_root, uint block_size, - uint prealloc_size); +extern void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size, + size_t prealloc_size); extern char *strdup_root(MEM_ROOT *root,const char *str); -extern char *strmake_root(MEM_ROOT *root,const char *str,uint len); -extern char *memdup_root(MEM_ROOT *root,const char *str,uint len); +extern char *strmake_root(MEM_ROOT *root,const char *str,size_t len); +extern void *memdup_root(MEM_ROOT *root,const void *str, size_t len); extern int get_defaults_options(int argc, char **argv, char **defaults, char **extra_defaults, char **group_suffix); @@ -829,19 +829,20 @@ extern int my_search_option_files(const char *conf_file, int *argc, extern void free_defaults(char **argv); extern void my_print_default_files(const char *conf_file); extern void print_defaults(const char *conf_file, const char **groups); -extern my_bool my_compress(byte *, ulong *, ulong *); -extern my_bool my_uncompress(byte *, ulong *, ulong *); -extern byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen); -extern int packfrm(const void *, uint, const void **, uint *); -extern int unpackfrm(const void **, uint *, const void *); - -extern ha_checksum my_checksum(ha_checksum crc, const byte *mem, uint count); +extern my_bool my_compress(uchar *, size_t *, size_t *); +extern my_bool my_uncompress(uchar *, size_t , size_t *); +extern uchar *my_compress_alloc(const uchar *packet, size_t *len, + size_t *complen); +extern int packfrm(const uchar *, size_t, uchar **, size_t *); +extern int unpackfrm(uchar **, size_t *, const uchar *); + +extern ha_checksum my_checksum(ha_checksum crc, const uchar *mem, + size_t count); extern uint my_bit_log2(ulong value); extern uint32 my_round_up_to_next_power(uint32 v); extern uint my_count_bits(ulonglong v); extern uint my_count_bits_ushort(ushort v); extern void my_sleep(ulong m_seconds); -extern ulong crc32(ulong crc, const uchar *buf, uint len); extern uint my_set_max_open_files(uint files); void my_free_open_file_info(void); @@ -908,17 +909,17 @@ extern char *get_charsets_dir(char *buf); extern my_bool my_charset_same(CHARSET_INFO *cs1, CHARSET_INFO *cs2); extern my_bool init_compiled_charsets(myf flags); extern void add_compiled_collation(CHARSET_INFO *cs); -extern ulong escape_string_for_mysql(CHARSET_INFO *charset_info, - char *to, ulong to_length, - const char *from, ulong length); +extern size_t escape_string_for_mysql(CHARSET_INFO *charset_info, + char *to, size_t to_length, + const char *from, size_t length); #ifdef __WIN__ #define BACKSLASH_MBTAIL /* File system character set */ extern CHARSET_INFO *fs_character_set(void); #endif -extern ulong escape_quotes_for_mysql(CHARSET_INFO *charset_info, - char *to, ulong to_length, - const char *from, ulong length); +extern size_t escape_quotes_for_mysql(CHARSET_INFO *charset_info, + char *to, size_t to_length, + const char *from, size_t length); extern void thd_increment_bytes_sent(ulong length); extern void thd_increment_bytes_received(ulong length); @@ -935,7 +936,7 @@ int my_security_attr_create(SECURITY_ATTRIBUTES **psa, const char **perror, void my_security_attr_free(SECURITY_ATTRIBUTES *sa); /* implemented in my_conio.c */ -char* my_cgets(char *string, unsigned long clen, unsigned long* plen); +char* my_cgets(char *string, size_t clen, size_t* plen); #endif #ifdef __NETWARE__ diff --git a/include/my_tree.h b/include/my_tree.h index 380fc1c9b26..24bbdd54019 100644 --- a/include/my_tree.h +++ b/include/my_tree.h @@ -25,10 +25,10 @@ extern "C" { #define MAX_TREE_HEIGHT 64 #define ELEMENT_KEY(tree,element)\ -(tree->offset_to_key ? (void*)((byte*) element+tree->offset_to_key) :\ +(tree->offset_to_key ? (void*)((uchar*) element+tree->offset_to_key) :\ *((void**) (element+1))) -#define tree_set_pointer(element,ptr) *((byte **) (element+1))=((byte*) (ptr)) +#define tree_set_pointer(element,ptr) *((uchar **) (element+1))=((uchar*) (ptr)) #define TREE_NO_DUPS 1 diff --git a/include/my_trie.h b/include/my_trie.h index 264a2595c52..72dd485af04 100644 --- a/include/my_trie.h +++ b/include/my_trie.h @@ -22,7 +22,7 @@ extern "C" { typedef struct st_trie_node { uint16 leaf; /* Depth from root node if match, 0 else */ - byte c; /* Label on this edge */ + uchar c; /* Label on this edge */ struct st_trie_node *next; /* Next label */ struct st_trie_node *links; /* Array of edges leaving this node */ struct st_trie_node *fail; /* AC failure function */ @@ -45,14 +45,14 @@ typedef struct st_ac_trie_state extern TRIE *trie_init (TRIE *trie, CHARSET_INFO *charset); extern void trie_free (TRIE *trie); -extern my_bool trie_insert (TRIE *trie, const byte *key, uint keylen); +extern my_bool trie_insert (TRIE *trie, const uchar *key, uint keylen); extern my_bool ac_trie_prepare (TRIE *trie); extern void ac_trie_init (TRIE *trie, AC_TRIE_STATE *state); /* `trie_goto' is internal function and shouldn't be used. */ -static inline TRIE_NODE *trie_goto (TRIE_NODE *root, TRIE_NODE *node, byte c) +static inline TRIE_NODE *trie_goto (TRIE_NODE *root, TRIE_NODE *node, uchar c) { TRIE_NODE *next; DBUG_ENTER("trie_goto"); @@ -67,7 +67,7 @@ static inline TRIE_NODE *trie_goto (TRIE_NODE *root, TRIE_NODE *node, byte c) /* SYNOPSIS - int ac_trie_next (AC_TRIE_STATE *state, byte *c); + int ac_trie_next (AC_TRIE_STATE *state, uchar *c); state - valid pointer to `AC_TRIE_STATE' c - character to lookup @@ -79,7 +79,7 @@ static inline TRIE_NODE *trie_goto (TRIE_NODE *root, TRIE_NODE *node, byte c) `ac_trie_next' returns length of matched word or 0. */ -static inline int ac_trie_next (AC_TRIE_STATE *state, byte *c) +static inline int ac_trie_next (AC_TRIE_STATE *state, uchar *c) { TRIE_NODE *root, *node; DBUG_ENTER("ac_trie_next"); @@ -94,7 +94,7 @@ static inline int ac_trie_next (AC_TRIE_STATE *state, byte *c) /* SYNOPSIS - my_bool trie_search (TRIE *trie, const byte *key, uint keylen); + my_bool trie_search (TRIE *trie, const uchar *key, uint keylen); trie - valid pointer to `TRIE' key - valid pointer to key to insert keylen - non-0 key length @@ -113,7 +113,7 @@ static inline int ac_trie_next (AC_TRIE_STATE *state, byte *c) consecutive loop better (tested) */ -static inline my_bool trie_search (TRIE *trie, const byte *key, uint keylen) +static inline my_bool trie_search (TRIE *trie, const uchar *key, uint keylen) { TRIE_NODE *node; uint k; @@ -123,7 +123,7 @@ static inline my_bool trie_search (TRIE *trie, const byte *key, uint keylen) for (k= 0; k < keylen; k++) { - byte p; + uchar p; if (! (node= node->links)) DBUG_RETURN(FALSE); p= key[k]; diff --git a/include/my_user.h b/include/my_user.h index 0c86d0f90f6..44eebf1551d 100644 --- a/include/my_user.h +++ b/include/my_user.h @@ -25,9 +25,9 @@ C_MODE_START -void parse_user(const char *user_id_str, uint user_id_len, - char *user_name_str, uint *user_name_len, - char *host_name_str, uint *host_name_len); +void parse_user(const char *user_id_str, size_t user_id_len, + char *user_name_str, size_t *user_name_len, + char *host_name_str, size_t *host_name_len); C_MODE_END diff --git a/include/my_vle.h b/include/my_vle.h index 21db8eeb6e1..c09f82229c4 100644 --- a/include/my_vle.h +++ b/include/my_vle.h @@ -28,8 +28,8 @@ extern "C" { */ #define my_vle_sizeof(ITEM) (((sizeof(ITEM) * CHAR_BIT) + 6) / 7) -byte *my_vle_encode(byte *vle, my_size_t max, ulong value); -byte const *my_vle_decode(ulong *value_ptr, byte const *vle); +uchar *my_vle_encode(uchar *vle, size_t max, ulong value); +uchar const *my_vle_decode(ulong *value_ptr, uchar const *vle); #ifdef __cplusplus } diff --git a/include/my_xml.h b/include/my_xml.h index 114805c7cc0..6a453ee90be 100644 --- a/include/my_xml.h +++ b/include/my_xml.h @@ -57,27 +57,27 @@ typedef struct xml_stack_st const char *cur; const char *end; void *user_data; - int (*enter)(struct xml_stack_st *st,const char *val, uint len); - int (*value)(struct xml_stack_st *st,const char *val, uint len); - int (*leave_xml)(struct xml_stack_st *st,const char *val, uint len); + int (*enter)(struct xml_stack_st *st,const char *val, size_t len); + int (*value)(struct xml_stack_st *st,const char *val, size_t len); + int (*leave_xml)(struct xml_stack_st *st,const char *val, size_t len); } MY_XML_PARSER; void my_xml_parser_create(MY_XML_PARSER *st); void my_xml_parser_free(MY_XML_PARSER *st); -int my_xml_parse(MY_XML_PARSER *st,const char *str, uint len); +int my_xml_parse(MY_XML_PARSER *st,const char *str, size_t len); void my_xml_set_value_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *, const char *, - uint len)); + size_t len)); void my_xml_set_enter_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *, const char *, - uint len)); + size_t len)); void my_xml_set_leave_handler(MY_XML_PARSER *st, int (*)(MY_XML_PARSER *, const char *, - uint len)); + size_t len)); void my_xml_set_user_data(MY_XML_PARSER *st, void *); -uint my_xml_error_pos(MY_XML_PARSER *st); +size_t my_xml_error_pos(MY_XML_PARSER *st); uint my_xml_error_lineno(MY_XML_PARSER *st); const char *my_xml_error_string(MY_XML_PARSER *st); diff --git a/include/myisam.h b/include/myisam.h index b05440e5ae4..5d93ded3d6e 100644 --- a/include/myisam.h +++ b/include/myisam.h @@ -227,7 +227,7 @@ typedef struct st_mi_decode_tree /* Decode huff-table */ { uint16 *table; uint quick_table_bits; - byte *intervalls; + uchar *intervalls; } MI_DECODE_TREE; @@ -259,7 +259,7 @@ typedef struct st_columndef /* column information */ /* invalidator function reference for Query Cache */ typedef void (* invalidator_by_filename)(const char * filename); -extern my_string myisam_log_filename; /* Name of logfile */ +extern char * myisam_log_filename; /* Name of logfile */ extern ulong myisam_block_size; extern ulong myisam_concurrent_insert; extern my_bool myisam_flush,myisam_delay_key_write,myisam_single_user; @@ -269,26 +269,26 @@ extern ulong myisam_bulk_insert_tree_size, myisam_data_pointer_size; /* Prototypes for myisam-functions */ extern int mi_close(struct st_myisam_info *file); -extern int mi_delete(struct st_myisam_info *file,const byte *buff); +extern int mi_delete(struct st_myisam_info *file,const uchar *buff); extern struct st_myisam_info *mi_open(const char *name,int mode, uint wait_if_locked); extern int mi_panic(enum ha_panic_function function); -extern int mi_rfirst(struct st_myisam_info *file,byte *buf,int inx); -extern int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, +extern int mi_rfirst(struct st_myisam_info *file,uchar *buf,int inx); +extern int mi_rkey(MI_INFO *info, uchar *buf, int inx, const uchar *key, key_part_map keypart_map, enum ha_rkey_function search_flag); -extern int mi_rlast(struct st_myisam_info *file,byte *buf,int inx); -extern int mi_rnext(struct st_myisam_info *file,byte *buf,int inx); -extern int mi_rnext_same(struct st_myisam_info *info, byte *buf); -extern int mi_rprev(struct st_myisam_info *file,byte *buf,int inx); -extern int mi_rrnd(struct st_myisam_info *file,byte *buf, my_off_t pos); +extern int mi_rlast(struct st_myisam_info *file,uchar *buf,int inx); +extern int mi_rnext(struct st_myisam_info *file,uchar *buf,int inx); +extern int mi_rnext_same(struct st_myisam_info *info, uchar *buf); +extern int mi_rprev(struct st_myisam_info *file,uchar *buf,int inx); +extern int mi_rrnd(struct st_myisam_info *file,uchar *buf, my_off_t pos); extern int mi_scan_init(struct st_myisam_info *file); -extern int mi_scan(struct st_myisam_info *file,byte *buf); -extern int mi_rsame(struct st_myisam_info *file,byte *record,int inx); -extern int mi_rsame_with_pos(struct st_myisam_info *file,byte *record, +extern int mi_scan(struct st_myisam_info *file,uchar *buf); +extern int mi_rsame(struct st_myisam_info *file,uchar *record,int inx); +extern int mi_rsame_with_pos(struct st_myisam_info *file,uchar *record, int inx, my_off_t pos); -extern int mi_update(struct st_myisam_info *file,const byte *old, - byte *new_record); -extern int mi_write(struct st_myisam_info *file,byte *buff); +extern int mi_update(struct st_myisam_info *file,const uchar *old, + uchar *new_record); +extern int mi_write(struct st_myisam_info *file,uchar *buff); extern my_off_t mi_position(struct st_myisam_info *file); extern int mi_status(struct st_myisam_info *info, MI_ISAMINFO *x, uint flag); extern int mi_lock_database(struct st_myisam_info *file,int lock_type); @@ -307,7 +307,7 @@ extern ha_rows mi_records_in_range(MI_INFO *info, int inx, extern int mi_log(int activate_log); extern int mi_is_changed(struct st_myisam_info *info); extern int mi_delete_all_rows(struct st_myisam_info *info); -extern ulong _mi_calc_blob_length(uint length , const byte *pos); +extern ulong _mi_calc_blob_length(uint length , const uchar *pos); extern uint mi_get_pointer_length(ulonglong file_length, uint def); /* this is used to pass to mysql_myisamchk_table -- by Sasha Pachev */ @@ -474,8 +474,8 @@ int chk_size(MI_CHECK *param, MI_INFO *info); int chk_key(MI_CHECK *param, MI_INFO *info); int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend); int mi_repair(MI_CHECK *param, register MI_INFO *info, - my_string name, int rep_quick); -int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name); + char * name, int rep_quick); +int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name); int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, const char * name, int rep_quick); int mi_repair_parallel(MI_CHECK *param, register MI_INFO *info, @@ -494,7 +494,7 @@ void update_key_parts(MI_KEYDEF *keyinfo, ulong *rec_per_key_part, ulonglong records); int filecopy(MI_CHECK *param, File to,File from,my_off_t start, my_off_t length, const char *type); -int movepoint(MI_INFO *info,byte *record,my_off_t oldpos, +int movepoint(MI_INFO *info,uchar *record,my_off_t oldpos, my_off_t newpos, uint prot_key); int write_data_suffix(SORT_INFO *sort_info, my_bool fix_datafile); int test_if_almost_full(MI_INFO *info); diff --git a/include/myisammrg.h b/include/myisammrg.h index 02e81cf806d..eed50bebaee 100644 --- a/include/myisammrg.h +++ b/include/myisammrg.h @@ -78,20 +78,20 @@ typedef struct st_myrg_info /* Prototypes for merge-functions */ extern int myrg_close(MYRG_INFO *file); -extern int myrg_delete(MYRG_INFO *file,const byte *buff); +extern int myrg_delete(MYRG_INFO *file,const uchar *buff); extern MYRG_INFO *myrg_open(const char *name,int mode,int wait_if_locked); extern int myrg_panic(enum ha_panic_function function); -extern int myrg_rfirst(MYRG_INFO *file,byte *buf,int inx); -extern int myrg_rlast(MYRG_INFO *file,byte *buf,int inx); -extern int myrg_rnext(MYRG_INFO *file,byte *buf,int inx); -extern int myrg_rprev(MYRG_INFO *file,byte *buf,int inx); -extern int myrg_rnext_same(MYRG_INFO *file,byte *buf); -extern int myrg_rkey(MYRG_INFO *info,byte *buf,int inx, const byte *key, +extern int myrg_rfirst(MYRG_INFO *file,uchar *buf,int inx); +extern int myrg_rlast(MYRG_INFO *file,uchar *buf,int inx); +extern int myrg_rnext(MYRG_INFO *file,uchar *buf,int inx); +extern int myrg_rprev(MYRG_INFO *file,uchar *buf,int inx); +extern int myrg_rnext_same(MYRG_INFO *file,uchar *buf); +extern int myrg_rkey(MYRG_INFO *info,uchar *buf,int inx, const uchar *key, key_part_map keypart_map, enum ha_rkey_function search_flag); -extern int myrg_rrnd(MYRG_INFO *file,byte *buf,ulonglong pos); -extern int myrg_rsame(MYRG_INFO *file,byte *record,int inx); -extern int myrg_update(MYRG_INFO *file,const byte *old,byte *new_rec); -extern int myrg_write(MYRG_INFO *info,byte *rec); +extern int myrg_rrnd(MYRG_INFO *file,uchar *buf,ulonglong pos); +extern int myrg_rsame(MYRG_INFO *file,uchar *record,int inx); +extern int myrg_update(MYRG_INFO *file,const uchar *old,uchar *new_rec); +extern int myrg_write(MYRG_INFO *info,uchar *rec); extern int myrg_status(MYRG_INFO *file,MYMERGE_INFO *x,int flag); extern int myrg_lock_database(MYRG_INFO *file,int lock_type); extern int myrg_create(const char *name, const char **table_names, diff --git a/include/mysql.h b/include/mysql.h index f657e1ae64b..489813bc154 100644 --- a/include/mysql.h +++ b/include/mysql.h @@ -53,7 +53,6 @@ typedef char my_bool; #else #define STDCALL __stdcall #endif -typedef char * gptr; #ifndef my_socket_defined #ifdef __WIN__ @@ -252,9 +251,9 @@ struct st_mysql_stmt; typedef struct st_mysql { NET net; /* Communication parameters */ - gptr connector_fd; /* ConnectorFd for SSL */ - char *host,*user,*passwd,*unix_socket,*server_version,*host_info,*info; - char *db; + unsigned char *connector_fd; /* ConnectorFd for SSL */ + char *host,*user,*passwd,*unix_socket,*server_version,*host_info; + char *info, *db; struct charset_info_st *charset; MYSQL_FIELD *fields; MEM_ROOT field_alloc; @@ -753,9 +752,9 @@ typedef struct st_mysql_methods my_bool (*read_query_result)(MYSQL *mysql); my_bool (*advanced_command)(MYSQL *mysql, enum enum_server_command command, - const char *header, + const unsigned char *header, unsigned long header_length, - const char *arg, + const unsigned char *arg, unsigned long arg_length, my_bool skip_check, MYSQL_STMT *stmt); @@ -848,10 +847,10 @@ int STDCALL mysql_drop_db(MYSQL *mysql, const char *DB); */ #define simple_command(mysql, command, arg, length, skip_check) \ - (*(mysql)->methods->advanced_command)(mysql, command, NullS, \ + (*(mysql)->methods->advanced_command)(mysql, command, 0, \ 0, arg, length, skip_check, NULL) #define stmt_command(mysql, command, arg, length, stmt) \ - (*(mysql)->methods->advanced_command)(mysql, command, NullS, \ + (*(mysql)->methods->advanced_command)(mysql, command, 0, \ 0, arg, length, 1, stmt) #ifdef __NETWARE__ diff --git a/include/mysql_com.h b/include/mysql_com.h index 2223dbad6ab..acfc326bc9c 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -223,7 +223,7 @@ typedef struct st_net { 'query_cache_query' should be accessed only via query cache functions and methods to maintain proper locking. */ - gptr query_cache_query; + unsigned char *query_cache_query; my_bool report_error; /* We should report error (we have unreported error) */ my_bool return_errno; @@ -344,13 +344,13 @@ my_bool my_net_init(NET *net, Vio* vio); void my_net_local_init(NET *net); void net_end(NET *net); void net_clear(NET *net, my_bool clear_buffer); -my_bool net_realloc(NET *net, unsigned long length); +my_bool net_realloc(NET *net, size_t length); my_bool net_flush(NET *net); -my_bool my_net_write(NET *net,const char *packet,unsigned long len); +my_bool my_net_write(NET *net,const unsigned char *packet, size_t len); my_bool net_write_command(NET *net,unsigned char command, - const char *header, unsigned long head_len, - const char *packet, unsigned long len); -int net_real_write(NET *net,const char *packet,unsigned long len); + const unsigned char *header, size_t head_len, + const unsigned char *packet, size_t len); +int net_real_write(NET *net,const unsigned char *packet, size_t len); unsigned long my_net_read(NET *net); /* @@ -446,7 +446,7 @@ void my_thread_end(void); #ifdef _global_h ulong STDCALL net_field_length(uchar **packet); my_ulonglong net_field_length_ll(uchar **packet); -char *net_store_length(char *pkg, ulonglong length); +uchar *net_store_length(uchar *pkg, ulonglong length); #endif #ifdef __cplusplus diff --git a/include/queues.h b/include/queues.h index d46f867f3bf..4fd0f72484e 100644 --- a/include/queues.h +++ b/include/queues.h @@ -27,13 +27,13 @@ extern "C" { #endif typedef struct st_queue { - byte **root; + uchar **root; void *first_cmp_arg; uint elements; uint max_elements; uint offset_to_key; /* compare is done on element+offset */ int max_at_top; /* Set if queue_top gives max */ - int (*compare)(void *, byte *,byte *); + int (*compare)(void *, uchar *,uchar *); uint auto_extent; } QUEUE; @@ -44,7 +44,7 @@ typedef struct st_queue { #define queue_set_cmp_arg(queue, set_arg) (queue)->first_cmp_arg= set_arg #define queue_set_max_at_top(queue, set_arg) \ (queue)->max_at_top= set_arg ? (-1 ^ 1) : 0 -typedef int (*queue_compare)(void *,byte *, byte *); +typedef int (*queue_compare)(void *,uchar *, uchar *); int init_queue(QUEUE *queue,uint max_elements,uint offset_to_key, pbool max_at_top, queue_compare compare, @@ -57,9 +57,9 @@ int reinit_queue(QUEUE *queue,uint max_elements,uint offset_to_key, void *first_cmp_arg); int resize_queue(QUEUE *queue, uint max_elements); void delete_queue(QUEUE *queue); -void queue_insert(QUEUE *queue,byte *element); -int queue_insert_safe(QUEUE *queue, byte *element); -byte *queue_remove(QUEUE *queue,uint idx); +void queue_insert(QUEUE *queue,uchar *element); +int queue_insert_safe(QUEUE *queue, uchar *element); +uchar *queue_remove(QUEUE *queue,uint idx); #define queue_remove_all(queue) { (queue)->elements= 0; } #define queue_is_full(queue) (queue->elements == queue->max_elements) void _downheap(QUEUE *queue,uint idx); diff --git a/include/sql_common.h b/include/sql_common.h index a549fe6aeb5..80504140fae 100644 --- a/include/sql_common.h +++ b/include/sql_common.h @@ -32,9 +32,9 @@ void mysql_read_default_options(struct st_mysql_options *options, const char *filename,const char *group); my_bool cli_advanced_command(MYSQL *mysql, enum enum_server_command command, - const char *header, ulong header_length, - const char *arg, ulong arg_length, my_bool skip_check, - MYSQL_STMT *stmt); + const unsigned char *header, ulong header_length, + const unsigned char *arg, ulong arg_length, + my_bool skip_check, MYSQL_STMT *stmt); unsigned long cli_safe_read(MYSQL *mysql); void set_stmt_errmsg(MYSQL_STMT * stmt, const char *err, int errcode, const char *sqlstate); diff --git a/include/sslopt-longopts.h b/include/sslopt-longopts.h index d4aaf50992d..c76b5dcd252 100644 --- a/include/sslopt-longopts.h +++ b/include/sslopt-longopts.h @@ -17,29 +17,29 @@ {"ssl", OPT_SSL_SSL, "Enable SSL for connection (automatically enabled with other flags). Disable with --skip-ssl.", - (gptr*) &opt_use_ssl, (gptr*) &opt_use_ssl, 0, GET_BOOL, NO_ARG, 0, 0, 0, + (uchar **) &opt_use_ssl, (uchar **) &opt_use_ssl, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"ssl-ca", OPT_SSL_CA, "CA file in PEM format (check OpenSSL docs, implies --ssl).", - (gptr*) &opt_ssl_ca, (gptr*) &opt_ssl_ca, 0, GET_STR, REQUIRED_ARG, + (uchar **) &opt_ssl_ca, (uchar **) &opt_ssl_ca, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"ssl-capath", OPT_SSL_CAPATH, "CA directory (check OpenSSL docs, implies --ssl).", - (gptr*) &opt_ssl_capath, (gptr*) &opt_ssl_capath, 0, GET_STR, REQUIRED_ARG, + (uchar **) &opt_ssl_capath, (uchar **) &opt_ssl_capath, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"ssl-cert", OPT_SSL_CERT, "X509 cert in PEM format (implies --ssl).", - (gptr*) &opt_ssl_cert, (gptr*) &opt_ssl_cert, 0, GET_STR, REQUIRED_ARG, + (uchar **) &opt_ssl_cert, (uchar **) &opt_ssl_cert, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"ssl-cipher", OPT_SSL_CIPHER, "SSL cipher to use (implies --ssl).", - (gptr*) &opt_ssl_cipher, (gptr*) &opt_ssl_cipher, 0, GET_STR, REQUIRED_ARG, + (uchar **) &opt_ssl_cipher, (uchar **) &opt_ssl_cipher, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"ssl-key", OPT_SSL_KEY, "X509 key in PEM format (implies --ssl).", - (gptr*) &opt_ssl_key, (gptr*) &opt_ssl_key, 0, GET_STR, REQUIRED_ARG, + (uchar **) &opt_ssl_key, (uchar **) &opt_ssl_key, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef MYSQL_CLIENT {"ssl-verify-server-cert", OPT_SSL_VERIFY_SERVER_CERT, "Verify server's \"Common Name\" in its cert against hostname used when connecting. This option is disabled by default.", - (gptr*) &opt_ssl_verify_server_cert, (gptr*) &opt_ssl_verify_server_cert, + (uchar **) &opt_ssl_verify_server_cert, (uchar **) &opt_ssl_verify_server_cert, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif #endif /* HAVE_OPENSSL */ diff --git a/include/violite.h b/include/violite.h index 04365213ec0..0e9c97bf215 100644 --- a/include/violite.h +++ b/include/violite.h @@ -51,8 +51,8 @@ Vio* vio_new_win32shared_memory(NET *net,HANDLE handle_file_map, HANDLE event_client_wrote, HANDLE event_client_read, HANDLE event_conn_closed); -int vio_read_pipe(Vio *vio, gptr buf, int size); -int vio_write_pipe(Vio *vio, const gptr buf, int size); +size_t vio_read_pipe(Vio *vio, uchar * buf, size_t size); +size_t vio_write_pipe(Vio *vio, const uchar * buf, size_t size); int vio_close_pipe(Vio * vio); #else #define HANDLE void * @@ -62,9 +62,9 @@ void vio_delete(Vio* vio); int vio_close(Vio* vio); void vio_reset(Vio* vio, enum enum_vio_type type, my_socket sd, HANDLE hPipe, uint flags); -int vio_read(Vio *vio, gptr buf, int size); -int vio_read_buff(Vio *vio, gptr buf, int size); -int vio_write(Vio *vio, const gptr buf, int size); +size_t vio_read(Vio *vio, uchar * buf, size_t size); +size_t vio_read_buff(Vio *vio, uchar * buf, size_t size); +size_t vio_write(Vio *vio, const uchar * buf, size_t size); int vio_blocking(Vio *vio, my_bool onoff, my_bool *old_mode); my_bool vio_is_blocking(Vio *vio); /* setsockopt TCP_NODELAY at IPPROTO_TCP level, when possible */ @@ -128,8 +128,8 @@ void free_vio_ssl_acceptor_fd(struct st_VioSSLFd *fd); #endif /* HAVE_OPENSSL */ #ifdef HAVE_SMEM -int vio_read_shared_memory(Vio *vio, gptr buf, int size); -int vio_write_shared_memory(Vio *vio, const gptr buf, int size); +size_t vio_read_shared_memory(Vio *vio, uchar * buf, size_t size); +size_t vio_write_shared_memory(Vio *vio, const uchar * buf, size_t size); int vio_close_shared_memory(Vio * vio); #endif @@ -187,8 +187,8 @@ struct st_vio /* function pointers. They are similar for socket/SSL/whatever */ void (*viodelete)(Vio*); int (*vioerrno)(Vio*); - int (*read)(Vio*, gptr, int); - int (*write)(Vio*, const gptr, int); + size_t (*read)(Vio*, uchar *, size_t); + size_t (*write)(Vio*, const uchar *, size_t); int (*vioblocking)(Vio*, my_bool, my_bool *); my_bool (*is_blocking)(Vio*); int (*viokeepalive)(Vio*, my_bool); @@ -210,7 +210,7 @@ struct st_vio HANDLE event_client_wrote; HANDLE event_client_read; HANDLE event_conn_closed; - long shared_memory_remain; + size_t shared_memory_remain; char *shared_memory_pos; NET *net; #endif /* HAVE_SMEM */ diff --git a/libmysql/client_settings.h b/libmysql/client_settings.h index 4bc4bda5b63..1d415488037 100644 --- a/libmysql/client_settings.h +++ b/libmysql/client_settings.h @@ -14,7 +14,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ extern uint mysql_port; -extern my_string mysql_unix_port; +extern char * mysql_unix_port; #define CLIENT_CAPABILITIES (CLIENT_LONG_PASSWORD | CLIENT_LONG_FLAG | \ CLIENT_TRANSACTIONS | \ diff --git a/libmysql/libmysql.c b/libmysql/libmysql.c index 374676ebe32..d33278819de 100644 --- a/libmysql/libmysql.c +++ b/libmysql/libmysql.c @@ -625,7 +625,7 @@ mysql_connect(MYSQL *mysql,const char *host, if (!(res=mysql_real_connect(mysql,host,user,passwd,NullS,0,NullS,0))) { if (mysql->free_me) - my_free((gptr) mysql,MYF(0)); + my_free((uchar*) mysql,MYF(0)); } mysql->reconnect= 1; DBUG_RETURN(res); @@ -946,7 +946,7 @@ static int default_local_infile_read(void *ptr, char *buf, uint buf_len) int count; default_local_infile_data*data = (default_local_infile_data *) ptr; - if ((count= (int) my_read(data->fd, (byte *) buf, buf_len, MYF(0))) < 0) + if ((count= (int) my_read(data->fd, (uchar *) buf, buf_len, MYF(0))) < 0) { data->error_num= EE_READ; /* the errmsg for not entire file read */ my_snprintf(data->error_msg, sizeof(data->error_msg)-1, @@ -4539,7 +4539,7 @@ static int stmt_fetch_row(MYSQL_STMT *stmt, uchar *row) } if (!((bit<<=1) & 255)) { - bit= 1; /* To next byte */ + bit= 1; /* To next uchar */ null_ptr++; } } @@ -4732,7 +4732,7 @@ static void stmt_update_metadata(MYSQL_STMT *stmt, MYSQL_ROWS *data) DBUG_ASSERT(row <= row_end); if (!((bit<<=1) & 255)) { - bit= 1; /* To next byte */ + bit= 1; /* To next uchar */ null_ptr++; } } @@ -5043,7 +5043,7 @@ my_bool STDCALL mysql_stmt_close(MYSQL_STMT *stmt) } } - my_free((gptr) stmt, MYF(MY_WME)); + my_free((uchar*) stmt, MYF(MY_WME)); DBUG_RETURN(test(rc)); } diff --git a/libmysql/manager.c b/libmysql/manager.c index a88c63123b0..2989c9dcccf 100644 --- a/libmysql/manager.c +++ b/libmysql/manager.c @@ -206,10 +206,10 @@ void STDCALL mysql_manager_close(MYSQL_MANAGER* con) allocated in my_multimalloc() along with con->host, freeing con->hosts frees the whole block */ - my_free((gptr)con->host,MYF(MY_ALLOW_ZERO_PTR)); + my_free((uchar*)con->host,MYF(MY_ALLOW_ZERO_PTR)); net_end(&con->net); if (con->free_me) - my_free((gptr)con,MYF(0)); + my_free((uchar*)con,MYF(0)); } diff --git a/libmysqld/emb_qcache.cc b/libmysqld/emb_qcache.cc index e6f35aa33a0..17549bfa96b 100644 --- a/libmysqld/emb_qcache.cc +++ b/libmysqld/emb_qcache.cc @@ -47,9 +47,9 @@ void Querycache_stream::store_short(ushort s) cur_data+= 2; return; } - *cur_data= ((byte *)(&s))[0]; + *cur_data= ((uchar *)(&s))[0]; use_next_block(TRUE); - *(cur_data++)= ((byte *)(&s))[1]; + *(cur_data++)= ((uchar *)(&s))[1]; } void Querycache_stream::store_int(uint i) @@ -100,7 +100,7 @@ void Querycache_stream::store_ll(ulonglong ll) } memcpy(cur_data, &ll, rest_len); use_next_block(TRUE); - memcpy(cur_data, ((byte*)&ll)+rest_len, 8-rest_len); + memcpy(cur_data, ((uchar*)&ll)+rest_len, 8-rest_len); cur_data+= 8-rest_len; } @@ -165,9 +165,9 @@ ushort Querycache_stream::load_short() cur_data+= 2; return result; } - ((byte*)&result)[0]= *cur_data; + ((uchar*)&result)[0]= *cur_data; use_next_block(FALSE); - ((byte*)&result)[1]= *(cur_data++); + ((uchar*)&result)[1]= *(cur_data++); return result; } @@ -216,7 +216,7 @@ ulonglong Querycache_stream::load_ll() } memcpy(&result, cur_data, rest_len); use_next_block(FALSE); - memcpy(((byte*)&result)+rest_len, cur_data, 8-rest_len); + memcpy(((uchar*)&result)+rest_len, cur_data, 8-rest_len); cur_data+= 8-rest_len; return result; } @@ -245,7 +245,7 @@ char *Querycache_stream::load_str(MEM_ROOT *alloc, uint *str_len) { char *result; *str_len= load_int(); - if (!(result= alloc_root(alloc, *str_len + 1))) + if (!(result= (char*) alloc_root(alloc, *str_len + 1))) return 0; load_str_only(result, *str_len); return result; @@ -259,7 +259,7 @@ int Querycache_stream::load_safe_str(MEM_ROOT *alloc, char **str, uint *str_len) return 0; } (*str_len)--; - if (!(*str= alloc_root(alloc, *str_len + 1))) + if (!(*str= (char*) alloc_root(alloc, *str_len + 1))) return 1; load_str_only(*str, *str_len); return 0; diff --git a/libmysqld/emb_qcache.h b/libmysqld/emb_qcache.h index 5c5209902a1..6e320fbd967 100644 --- a/libmysqld/emb_qcache.h +++ b/libmysqld/emb_qcache.h @@ -15,8 +15,8 @@ class Querycache_stream { - byte *cur_data; - byte *data_end; + uchar *cur_data; + uchar *data_end; Query_cache_block *block; uint headers_len; public: @@ -27,7 +27,7 @@ public: Querycache_stream(Query_cache_block *ini_block, uint ini_headers_len) : block(ini_block), headers_len(ini_headers_len) { - cur_data= ((byte*)block)+headers_len; + cur_data= ((uchar*)block)+headers_len; data_end= cur_data + (block->used-headers_len); #ifndef DBUG_OFF first_block= ini_block; @@ -54,7 +54,7 @@ public: else DBUG_ASSERT(block->type == Query_cache_block::RES_CONT); - cur_data= ((byte*)block)+headers_len; + cur_data= ((uchar*)block)+headers_len; data_end= cur_data + (block->used-headers_len); } diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc index dbec5bf6bbf..0ce9efca0cc 100644 --- a/libmysqld/lib_sql.cc +++ b/libmysqld/lib_sql.cc @@ -68,13 +68,13 @@ void embedded_get_error(MYSQL *mysql, MYSQL_DATA *data) net->last_errno= ei->last_errno; strmake(net->last_error, ei->info, sizeof(net->last_error)); memcpy(net->sqlstate, ei->sqlstate, sizeof(net->sqlstate)); - my_free((gptr) data, MYF(0)); + my_free(data, MYF(0)); } static my_bool emb_advanced_command(MYSQL *mysql, enum enum_server_command command, - const char *header, ulong header_length, - const char *arg, ulong arg_length, my_bool skip_check, + const uchar *header, ulong header_length, + const uchar *arg, ulong arg_length, my_bool skip_check, MYSQL_STMT *stmt) { my_bool result= 1; @@ -180,7 +180,7 @@ static MYSQL_FIELD *emb_list_fields(MYSQL *mysql) res= ((THD*) mysql->thd)->cur_data; ((THD*) mysql->thd)->cur_data= 0; mysql->field_alloc= res->alloc; - my_free((gptr) res,MYF(0)); + my_free(res,MYF(0)); mysql->status= MYSQL_STATUS_READY; return mysql->fields; } @@ -209,7 +209,7 @@ static my_bool emb_read_prepare_result(MYSQL *mysql, MYSQL_STMT *stmt) stmt->fields= mysql->fields; stmt->mem_root= res->alloc; mysql->fields= NULL; - my_free((gptr) res,MYF(0)); + my_free(res,MYF(0)); } return 0; @@ -265,7 +265,7 @@ static my_bool emb_read_query_result(MYSQL *mysql) thd->cur_data= res; } else - my_free((gptr) res, MYF(0)); + my_free(res, MYF(0)); return 0; } @@ -273,7 +273,7 @@ static my_bool emb_read_query_result(MYSQL *mysql) static int emb_stmt_execute(MYSQL_STMT *stmt) { DBUG_ENTER("emb_stmt_execute"); - char header[5]; + uchar header[5]; THD *thd; my_bool res; @@ -1063,22 +1063,22 @@ bool Protocol_text::store_null() return false; } -bool Protocol::net_store_data(const char *from, uint length) +bool Protocol::net_store_data(const uchar *from, size_t length) { char *field_buf; if (!thd->mysql) // bootstrap file handling - return false; + return FALSE; - if (!(field_buf=alloc_root(alloc, length + sizeof(uint) + 1))) - return true; + if (!(field_buf= (char*) alloc_root(alloc, length + sizeof(uint) + 1))) + return TRUE; *(uint *)field_buf= length; *next_field= field_buf + sizeof(uint); - memcpy(*next_field, from, length); + memcpy((uchar*) *next_field, from, length); (*next_field)[length]= 0; if (next_mysql_field->max_length < length) next_mysql_field->max_length=length; ++next_field; ++next_mysql_field; - return false; + return FALSE; } diff --git a/mysql-test/lib/mtr_report.pl b/mysql-test/lib/mtr_report.pl index d3b38573ae2..d1b23e973b2 100644 --- a/mysql-test/lib/mtr_report.pl +++ b/mysql-test/lib/mtr_report.pl @@ -265,8 +265,13 @@ sub mtr_report_stats ($) { else { # We report different types of problems in order - foreach my $pattern ( "^Warning:", "^Error:", "^==.* at 0x", - "InnoDB: Warning", "missing DBUG_RETURN", + foreach my $pattern ( "^Warning:", + "\\[Warning\\]", + "\\[ERROR\\]", + "^Error:", "^==.* at 0x", + "InnoDB: Warning", + "^safe_mutex:", + "missing DBUG_RETURN", "mysqld: Warning", "allocated at line", "Attempting backtrace", "Assertion .* failed" ) @@ -292,10 +297,69 @@ sub mtr_report_stats ($) { } # Skip some non fatal warnings from the log files - if ( /Warning:\s+Table:.* on (delete|rename)/ or - /Warning:\s+Setting lower_case_table_names=2/ or - /Warning:\s+One can only use the --user.*root/ or - /InnoDB: Warning: we did not need to do crash recovery/) + if ( + /\"SELECT UNIX_TIMESTAMP\(\)\" failed on master/ or + /Aborted connection/ or + /Client requested master to start replication from impossible position/ or + /Could not find first log file name in binary log/ or + /Enabling keys got errno/ or + /Error reading master configuration/ or + /Error reading packet/ or + /Event Scheduler/ or + /Failed to open log/ or + /Failed to open the existing master info file/ or + /Forcing shutdown of [0-9]* plugins/ or + /Got error [0-9]* when reading table/ or + /Incorrect definition of table/ or + /Incorrect information in file/ or + /InnoDB: Warning: we did not need to do crash recovery/ or + /Invalid \(old\?\) table or database name/ or + /Lock wait timeout exceeded/ or + /Log entry on master is longer than max_allowed_packet/ or + /unknown option '--loose-/ or + /unknown variable 'loose-/ or + /You have forced lower_case_table_names to 0 through a command-line option/ or + /Setting lower_case_table_names=2/ or + /NDB Binlog:/ or + /NDB: failed to setup table/ or + /NDB: only row based binary logging/ or + /Neither --relay-log nor --relay-log-index were used/ or + /Query partially completed/ or + /Slave I.O thread aborted while waiting for relay log/ or + /Slave SQL thread is stopped because UNTIL condition/ or + /Slave SQL thread retried transaction/ or + /Slave \(additional info\)/ or + /Slave: .*Duplicate column name/ or + /Slave: .*master may suffer from/ or + /Slave: According to the master's version/ or + /Slave: Column [0-9]* type mismatch/ or + /Slave: Error .* doesn't exist/ or + /Slave: Error .*Deadlock found/ or + /Slave: Error .*Unknown table/ or + /Slave: Error in Write_rows event: / or + /Slave: Field .* of table .* has no default value/ or + /Slave: Query caused different errors on master and slave/ or + /Slave: Table .* doesn't exist/ or + /Slave: Table width mismatch/ or + /Slave: The incident LOST_EVENTS occured on the master/ or + /Slave: Unknown error.* 1105/ or + /Slave: Can't drop database.* database doesn't exist/ or + /Sort aborted/ or + /Time-out in NDB/ or + /Warning:\s+One can only use the --user.*root/ or + /Warning:\s+Setting lower_case_table_names=2/ or + /Warning:\s+Table:.* on (delete|rename)/ or + /You have an error in your SQL syntax/ or + /deprecated/ or + /description of time zone/ or + /equal MySQL server ids/ or + /error .*connecting to master/ or + /error reading log entry/ or + /lower_case_table_names is set/ or + /skip-name-resolve mode/ or + /slave SQL thread aborted/ or + /Slave: .*Duplicate entry/ + ) { next; # Skip these lines } diff --git a/mysql-test/mysql-test-run-shell.sh b/mysql-test/mysql-test-run-shell.sh index 953478fa9f4..54323c878a9 100644 --- a/mysql-test/mysql-test-run-shell.sh +++ b/mysql-test/mysql-test-run-shell.sh @@ -629,6 +629,11 @@ else TEST_MODE=`echo $TEST_MODE | sed 's/^ *//'` fi +# +# Skip tests that doesn't work with shell version +# +SKIP_TEST="$SKIP_TEST bootstrap" + #++ # mysqld Environment Parameters #-- @@ -900,8 +905,8 @@ MYSQL_DUMP="$MYSQL_DUMP --no-defaults --debug-info -uroot --socket=$MASTER_MYSOC MYSQL_SLAP="$MYSQL_SLAP -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLSLAP_OPT" MYSQL_DUMP_SLAVE="$MYSQL_DUMP_DIR --no-defaults -uroot --socket=$SLAVE_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT" MYSQL_SHOW="$MYSQL_SHOW --no-defaults --debug-info -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLSHOW_OPT" -MYSQL_BINLOG="$MYSQL_BINLOG --debug-info --no-defaults --local-load=$MYSQL_TMP_DIR --character-sets-dir=$CHARSETSDIR $EXTRA_MYSQLBINLOG_OPT" -MYSQL_IMPORT="$MYSQL_IMPORT --debug-info -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT" +MYSQL_BINLOG="$MYSQL_BINLOG --no-defaults --debug-info --local-load=$MYSQL_TMP_DIR --character-sets-dir=$CHARSETSDIR $EXTRA_MYSQLBINLOG_OPT" +MYSQL_IMPORT="$MYSQL_IMPORT --no-defaults --debug-info -uroot --socket=$MASTER_MYSOCK --password=$DBPASSWD $EXTRA_MYSQLDUMP_OPT" MYSQL_FIX_SYSTEM_TABLES="$MYSQL_FIX_SYSTEM_TABLES --no-defaults --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD --basedir=$BASEDIR --bindir=$CLIENT_BINDIR --verbose" MYSQL="$MYSQL --no-defaults --debug-info --host=localhost --port=$MASTER_MYPORT --socket=$MASTER_MYSOCK --user=root --password=$DBPASSWD" export MYSQL MYSQL_CHECK MYSQL_DUMP MYSQL_DUMP_SLAVE MYSQL_SHOW MYSQL_BINLOG MYSQL_FIX_SYSTEM_TABLES MYSQL_IMPORT diff --git a/mysql-test/r/func_misc.result b/mysql-test/r/func_misc.result index b4c6f0f6699..86b237d9afe 100644 --- a/mysql-test/r/func_misc.result +++ b/mysql-test/r/func_misc.result @@ -22,6 +22,11 @@ hex(inet_aton('127.1.1')) select length(uuid()), charset(uuid()), length(unhex(replace(uuid(),_utf8'-',_utf8''))); length(uuid()) charset(uuid()) length(unhex(replace(uuid(),_utf8'-',_utf8''))) 36 utf8 16 +set @a= uuid_short(); +set @b= uuid_short(); +select cast(@a - @b as signed); +cast(@a - @b as signed) +-1 select length(format('nan', 2)) > 0; length(format('nan', 2)) > 0 1 diff --git a/mysql-test/r/sql_mode.result b/mysql-test/r/sql_mode.result index c7be653ca2e..9998a51fdc8 100644 --- a/mysql-test/r/sql_mode.result +++ b/mysql-test/r/sql_mode.result @@ -475,9 +475,24 @@ set sql_mode=16384+(65536*4); select @@sql_mode; @@sql_mode REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,NO_TABLE_OPTIONS,ANSI -set sql_mode=2147483648; -ERROR 42000: Variable 'sql_mode' can't be set to the value of '2147483648' +set sql_mode=2147483648*2; +ERROR 42000: Variable 'sql_mode' can't be set to the value of '4294967296' select @@sql_mode; @@sql_mode REAL_AS_FLOAT,PIPES_AS_CONCAT,ANSI_QUOTES,IGNORE_SPACE,NO_TABLE_OPTIONS,ANSI +set sql_mode=PAD_CHAR_TO_FULL_LENGTH; +create table t1 (a int auto_increment primary key, b char(5)); +insert into t1 (b) values('a'),('b\t'),('c '); +select concat('x',b,'x') from t1; +concat('x',b,'x') +xa x +xb x +xc x +set sql_mode=0; +select concat('x',b,'x') from t1; +concat('x',b,'x') +xax +xb x +xcx +drop table t1; SET @@SQL_MODE=@OLD_SQL_MODE; diff --git a/mysql-test/t/disabled.def b/mysql-test/t/disabled.def index 1f96de1ea85..1b8d68b26ef 100644 --- a/mysql-test/t/disabled.def +++ b/mysql-test/t/disabled.def @@ -17,6 +17,9 @@ im_cmd_line : Bug#20294 2007-05-14 alik Instance manager tests im_utils : Bug#20294 2007-05-30 alik Instance manager tests fail randomly im_instance_conf : Bug#20294 2007-05-30 alik Instance manager tests fail randomly im_life_cycle : BUG#27851 Instance manager dies on ASSERT in ~Thread_registry() or from not being able to close a mysqld instance. +im_instance_conf : BUG#28743 Instance manager generates warnings in test suite +im_utils : BUG#28743 Instance manager generates warnings in test suite + concurrent_innodb : BUG#21579 2006-08-11 mleich innodb_concurrent random failures with varying differences ndb_autodiscover : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog ndb_autodiscover2 : BUG#18952 2006-02-16 jmiller Needs to be fixed w.r.t binlog diff --git a/mysql-test/t/func_misc.test b/mysql-test/t/func_misc.test index 8ff62f68e45..4d28ebf9404 100644 --- a/mysql-test/t/func_misc.test +++ b/mysql-test/t/func_misc.test @@ -14,6 +14,12 @@ select hex(inet_aton('127.1.1')); select length(uuid()), charset(uuid()), length(unhex(replace(uuid(),_utf8'-',_utf8''))); +# As we can assume we are the only user for the mysqld server, the difference +# between two calls should be -1 +set @a= uuid_short(); +set @b= uuid_short(); +select cast(@a - @b as signed); + # # Test for core dump with nan # diff --git a/mysql-test/t/sql_mode.test b/mysql-test/t/sql_mode.test index 8542c2b7927..7a9036c8621 100644 --- a/mysql-test/t/sql_mode.test +++ b/mysql-test/t/sql_mode.test @@ -264,7 +264,18 @@ select @@sql_mode; set sql_mode=16384+(65536*4); select @@sql_mode; --error 1231 -set sql_mode=2147483648; # that mode does not exist +set sql_mode=2147483648*2; # that mode does not exist select @@sql_mode; +# +# Test WL921: Retain spaces when retrieving CHAR column values + +set sql_mode=PAD_CHAR_TO_FULL_LENGTH; +create table t1 (a int auto_increment primary key, b char(5)); +insert into t1 (b) values('a'),('b\t'),('c '); +select concat('x',b,'x') from t1; +set sql_mode=0; +select concat('x',b,'x') from t1; +drop table t1; + SET @@SQL_MODE=@OLD_SQL_MODE; diff --git a/mysys/array.c b/mysys/array.c index 130a8f358de..8a539f18a20 100644 --- a/mysys/array.c +++ b/mysys/array.c @@ -41,8 +41,8 @@ */ my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size, - void *init_buffer, uint init_alloc, - uint alloc_increment CALLER_INFO_PROTO) + void *init_buffer, uint init_alloc, + uint alloc_increment CALLER_INFO_PROTO) { DBUG_ENTER("init_dynamic_array"); if (!alloc_increment) @@ -63,7 +63,7 @@ my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size, array->size_of_element=element_size; if ((array->buffer= init_buffer)) DBUG_RETURN(FALSE); - if (!(array->buffer=(char*) my_malloc_ci(element_size*init_alloc,MYF(MY_WME)))) + if (!(array->buffer=(uchar*) my_malloc_ci(element_size*init_alloc,MYF(MY_WME)))) { array->max_element=0; DBUG_RETURN(TRUE); @@ -72,8 +72,8 @@ my_bool init_dynamic_array2(DYNAMIC_ARRAY *array, uint element_size, } my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size, - uint init_alloc, - uint alloc_increment CALLER_INFO_PROTO) + uint init_alloc, + uint alloc_increment CALLER_INFO_PROTO) { /* placeholder to preserve ABI */ return my_init_dynamic_array_ci(array, element_size, init_alloc, @@ -92,9 +92,9 @@ my_bool init_dynamic_array(DYNAMIC_ARRAY *array, uint element_size, FALSE Ok */ -my_bool insert_dynamic(DYNAMIC_ARRAY *array, gptr element) +my_bool insert_dynamic(DYNAMIC_ARRAY *array, uchar* element) { - gptr buffer; + uchar* buffer; if (array->elements == array->max_element) { /* Call only when nessesary */ if (!(buffer=alloc_dynamic(array))) @@ -127,32 +127,32 @@ my_bool insert_dynamic(DYNAMIC_ARRAY *array, gptr element) 0 Error */ -byte *alloc_dynamic(DYNAMIC_ARRAY *array) +uchar *alloc_dynamic(DYNAMIC_ARRAY *array) { if (array->elements == array->max_element) { char *new_ptr; - if (array->buffer == (char *)(array + 1)) + if (array->buffer == (uchar *)(array + 1)) { /* In this senerio, the buffer is statically preallocated, so we have to create an all-new malloc since we overflowed */ if (!(new_ptr= (char *) my_malloc((array->max_element+ - array->alloc_increment) * - array->size_of_element, - MYF(MY_WME)))) + array->alloc_increment) * + array->size_of_element, + MYF(MY_WME)))) return 0; memcpy(new_ptr, array->buffer, array->elements * array->size_of_element); } else if (!(new_ptr=(char*) my_realloc(array->buffer,(array->max_element+ - array->alloc_increment)* - array->size_of_element, - MYF(MY_WME | MY_ALLOW_ZERO_PTR)))) + array->alloc_increment)* + array->size_of_element, + MYF(MY_WME | MY_ALLOW_ZERO_PTR)))) return 0; - array->buffer=new_ptr; + array->buffer= (uchar*) new_ptr; array->max_element+=array->alloc_increment; } return array->buffer+(array->elements++ * array->size_of_element); @@ -171,7 +171,7 @@ byte *alloc_dynamic(DYNAMIC_ARRAY *array) 0 Array is empty */ -byte *pop_dynamic(DYNAMIC_ARRAY *array) +uchar *pop_dynamic(DYNAMIC_ARRAY *array) { if (array->elements) return array->buffer+(--array->elements * array->size_of_element); @@ -196,7 +196,7 @@ byte *pop_dynamic(DYNAMIC_ARRAY *array) FALSE Ok */ -my_bool set_dynamic(DYNAMIC_ARRAY *array, gptr element, uint idx) +my_bool set_dynamic(DYNAMIC_ARRAY *array, uchar* element, uint idx) { if (idx >= array->elements) { @@ -206,33 +206,33 @@ my_bool set_dynamic(DYNAMIC_ARRAY *array, gptr element, uint idx) char *new_ptr; size=(idx+array->alloc_increment)/array->alloc_increment; size*= array->alloc_increment; - if (array->buffer == (char *)(array + 1)) + if (array->buffer == (uchar *)(array + 1)) { /* In this senerio, the buffer is statically preallocated, so we have to create an all-new malloc since we overflowed */ if (!(new_ptr= (char *) my_malloc(size * - array->size_of_element, - MYF(MY_WME)))) + array->size_of_element, + MYF(MY_WME)))) return 0; memcpy(new_ptr, array->buffer, array->elements * array->size_of_element); } else if (!(new_ptr=(char*) my_realloc(array->buffer,size* - array->size_of_element, - MYF(MY_WME | MY_ALLOW_ZERO_PTR)))) + array->size_of_element, + MYF(MY_WME | MY_ALLOW_ZERO_PTR)))) return TRUE; - array->buffer=new_ptr; + array->buffer= (uchar*) new_ptr; array->max_element=size; } - bzero((gptr) (array->buffer+array->elements*array->size_of_element), - (idx - array->elements)*array->size_of_element); + bzero((uchar*) (array->buffer+array->elements*array->size_of_element), + (idx - array->elements)*array->size_of_element); array->elements=idx+1; } memcpy(array->buffer+(idx * array->size_of_element),element, - (size_t) array->size_of_element); + (size_t) array->size_of_element); return FALSE; } @@ -242,21 +242,21 @@ my_bool set_dynamic(DYNAMIC_ARRAY *array, gptr element, uint idx) SYNOPSIS get_dynamic() array - gptr Element to be returned. If idx > elements contain zeroes. + uchar* Element to be returned. If idx > elements contain zeroes. idx Index of element wanted. */ -void get_dynamic(DYNAMIC_ARRAY *array, gptr element, uint idx) +void get_dynamic(DYNAMIC_ARRAY *array, uchar* element, uint idx) { if (idx >= array->elements) { DBUG_PRINT("warning",("To big array idx: %d, array size is %d", - idx,array->elements)); + idx,array->elements)); bzero(element,array->size_of_element); return; } memcpy(element,array->buffer+idx*array->size_of_element, - (size_t) array->size_of_element); + (size_t) array->size_of_element); } @@ -273,7 +273,7 @@ void delete_dynamic(DYNAMIC_ARRAY *array) /* Just mark as empty if we are using a static buffer */ - if (array->buffer == (char *)(array + 1)) + if (array->buffer == (uchar *)(array + 1)) array->elements= 0; else if (array->buffer) @@ -290,15 +290,15 @@ void delete_dynamic(DYNAMIC_ARRAY *array) SYNOPSIS delete_dynamic_element() array - idx Index of element to be deleted + idx Index of element to be deleted */ void delete_dynamic_element(DYNAMIC_ARRAY *array, uint idx) { - char *ptr=array->buffer+array->size_of_element*idx; + char *ptr= (char*) array->buffer+array->size_of_element*idx; array->elements--; memmove(ptr,ptr+array->size_of_element, - (array->elements-idx)*array->size_of_element); + (array->elements-idx)*array->size_of_element); } @@ -318,14 +318,14 @@ void freeze_size(DYNAMIC_ARRAY *array) /* Do nothing if we are using a static buffer */ - if (array->buffer == (char *)(array + 1)) + if (array->buffer == (uchar *)(array + 1)) return; if (array->buffer && array->max_element != elements) { - array->buffer=(char*) my_realloc(array->buffer, - elements*array->size_of_element, - MYF(MY_WME)); + array->buffer=(uchar*) my_realloc(array->buffer, + elements*array->size_of_element, + MYF(MY_WME)); array->max_element=elements; } } @@ -341,7 +341,7 @@ void freeze_size(DYNAMIC_ARRAY *array) */ -int get_index_dynamic(DYNAMIC_ARRAY *array, gptr element) +int get_index_dynamic(DYNAMIC_ARRAY *array, uchar* element) { uint ret; if (array->buffer > element) diff --git a/mysys/charset.c b/mysys/charset.c index cce97677b14..c6065f87df3 100644 --- a/mysys/charset.c +++ b/mysys/charset.c @@ -376,7 +376,7 @@ void add_compiled_collation(CHARSET_INFO *cs) cs->state|= MY_CS_AVAILABLE; } -static void *cs_alloc(uint size) +static void *cs_alloc(size_t size) { return my_once_alloc(size, MYF(MY_WME)); } @@ -594,13 +594,13 @@ CHARSET_INFO *get_charset_by_csname(const char *cs_name, "big enough" RETURN VALUES - ~0 The escaped string did not fit in the to buffer - >=0 The length of the escaped string + (size_t) -1 The escaped string did not fit in the to buffer + # The length of the escaped string */ -ulong escape_string_for_mysql(CHARSET_INFO *charset_info, - char *to, ulong to_length, - const char *from, ulong length) +size_t escape_string_for_mysql(CHARSET_INFO *charset_info, + char *to, size_t to_length, + const char *from, size_t length) { const char *to_start= to; const char *end, *to_end=to_start + (to_length ? to_length-1 : 2*length); @@ -684,7 +684,7 @@ ulong escape_string_for_mysql(CHARSET_INFO *charset_info, } } *to= 0; - return overflow ? (ulong)~0 : (ulong) (to - to_start); + return overflow ? (size_t) -1 : (size_t) (to - to_start); } @@ -738,9 +738,9 @@ CHARSET_INFO *fs_character_set() >=0 The length of the escaped string */ -ulong escape_quotes_for_mysql(CHARSET_INFO *charset_info, - char *to, ulong to_length, - const char *from, ulong length) +size_t escape_quotes_for_mysql(CHARSET_INFO *charset_info, + char *to, size_t to_length, + const char *from, size_t length) { const char *to_start= to; const char *end, *to_end=to_start + (to_length ? to_length-1 : 2*length); diff --git a/mysys/checksum.c b/mysys/checksum.c index 09e9c5b3730..4f86f6845f0 100644 --- a/mysys/checksum.c +++ b/mysys/checksum.c @@ -15,7 +15,8 @@ #include <my_global.h> -#include "my_sys.h" +#include <my_sys.h> +#include <zlib.h> /* Calculate a long checksum for a memoryblock. @@ -27,15 +28,15 @@ length length of the block */ -ha_checksum my_checksum(ha_checksum crc, const byte *pos, uint length) +ha_checksum my_checksum(ha_checksum crc, const uchar *pos, size_t length) { #ifdef NOT_USED - const byte *end=pos+length; + const uchar *end=pos+length; for ( ; pos != end ; pos++) crc=((crc << 8) + *((uchar*) pos)) + (crc >> (8*sizeof(ha_checksum)-8)); return crc; #else - return (ha_checksum)crc32((uint)crc, (const uchar *)pos, length); + return (ha_checksum)crc32((uint)crc, pos, length); #endif } diff --git a/mysys/default.c b/mysys/default.c index 926a8f530bf..3cc5b08e77c 100644 --- a/mysys/default.c +++ b/mysys/default.c @@ -268,9 +268,9 @@ static int handle_default_option(void *in_ctx, const char *group_name, if (find_type((char *)group_name, ctx->group, 3)) { - if (!(tmp= alloc_root(ctx->alloc, (uint) strlen(option) + 1))) + if (!(tmp= alloc_root(ctx->alloc, strlen(option) + 1))) return 1; - if (insert_dynamic(ctx->args, (gptr) &tmp)) + if (insert_dynamic(ctx->args, (uchar*) &tmp)) return 1; strmov(tmp, option); } @@ -426,7 +426,7 @@ int load_defaults(const char *conf_file, const char **groups, /* copy name + found arguments + command line arguments to new array */ res[0]= argv[0][0]; /* Name MUST be set, even by embedded library */ - memcpy((gptr) (res+1), args.buffer, args.elements*sizeof(char*)); + memcpy((uchar*) (res+1), args.buffer, args.elements*sizeof(char*)); /* Skip --defaults-xxx options */ (*argc)-= args_used; (*argv)+= args_used; @@ -442,7 +442,7 @@ int load_defaults(const char *conf_file, const char **groups, } if (*argc) - memcpy((gptr) (res+1+args.elements), (char*) ((*argv)+1), + memcpy((uchar*) (res+1+args.elements), (char*) ((*argv)+1), (*argc-1)*sizeof(char*)); res[args.elements+ *argc]=0; /* last null */ @@ -514,7 +514,7 @@ static int search_default_file(Process_option_func opt_handler, # Returns pointer to the argument after the keyword. */ -static char *get_argument(const char *keyword, uint kwlen, +static char *get_argument(const char *keyword, size_t kwlen, char *ptr, char *name, uint line) { char *end; @@ -718,10 +718,11 @@ static int search_default_file_with_ext(Process_option_func opt_handler, name,line); goto err; } - for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ;/* Remove end space */ + /* Remove end space */ + for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ; end[0]=0; - strnmov(curr_gr, ptr, min((uint) (end-ptr)+1, 4096)); + strmake(curr_gr, ptr, min((size_t) (end-ptr)+1, sizeof(curr_gr)-1)); /* signal that a new group is found */ opt_handler(handler_ctx, curr_gr, NULL); @@ -743,7 +744,7 @@ static int search_default_file_with_ext(Process_option_func opt_handler, for ( ; my_isspace(&my_charset_latin1,end[-1]) ; end--) ; if (!value) { - strmake(strmov(option,"--"),ptr,(uint) (end-ptr)); + strmake(strmov(option,"--"),ptr, (size_t) (end-ptr)); if (opt_handler(handler_ctx, curr_gr, option)) goto err; } @@ -769,7 +770,7 @@ static int search_default_file_with_ext(Process_option_func opt_handler, value++; value_end--; } - ptr=strnmov(strmov(option,"--"),ptr,(uint) (end-ptr)); + ptr=strnmov(strmov(option,"--"),ptr,(size_t) (end-ptr)); *ptr++= '='; for ( ; value != value_end; value++) @@ -931,9 +932,9 @@ void print_defaults(const char *conf_file, const char **groups) typedef UINT (WINAPI *GET_SYSTEM_WINDOWS_DIRECTORY)(LPSTR, UINT); -static uint my_get_system_windows_directory(char *buffer, uint size) +static size_t my_get_system_windows_directory(char *buffer, size_t size) { - uint count; + size_t count; GET_SYSTEM_WINDOWS_DIRECTORY func_ptr= (GET_SYSTEM_WINDOWS_DIRECTORY) GetProcAddress(GetModuleHandle("kernel32.dll"), diff --git a/mysys/default_modify.c b/mysys/default_modify.c index f58d3e0da86..b2a43f511b9 100644 --- a/mysys/default_modify.c +++ b/mysys/default_modify.c @@ -68,9 +68,8 @@ int modify_defaults_file(const char *file_location, const char *option, FILE *cnf_file; MY_STAT file_stat; char linebuff[BUFF_SIZE], *src_ptr, *dst_ptr, *file_buffer; - uint opt_len= 0; - uint optval_len= 0; - uint sect_len, nr_newlines= 0, buffer_size; + size_t opt_len= 0, optval_len= 0, sect_len; + uint nr_newlines= 0, buffer_size; my_bool in_section= FALSE, opt_applied= 0; uint reserve_extended; uint new_opt_len; @@ -86,8 +85,8 @@ int modify_defaults_file(const char *file_location, const char *option, if (option && option_value) { - opt_len= (uint) strlen(option); - optval_len= (uint) strlen(option_value); + opt_len= strlen(option); + optval_len= strlen(option_value); } new_opt_len= opt_len + 1 + optval_len + NEWLINE_LEN; @@ -110,7 +109,7 @@ int modify_defaults_file(const char *file_location, const char *option, MYF(MY_WME)))) goto malloc_err; - sect_len= (uint) strlen(section_name); + sect_len= strlen(section_name); for (dst_ptr= file_buffer; fgets(linebuff, BUFF_SIZE, cnf_file); ) { @@ -219,7 +218,7 @@ int modify_defaults_file(const char *file_location, const char *option, if (my_chsize(fileno(cnf_file), (my_off_t) (dst_ptr - file_buffer), 0, MYF(MY_WME)) || my_fseek(cnf_file, 0, MY_SEEK_SET, MYF(0)) || - my_fwrite(cnf_file, file_buffer, (uint) (dst_ptr - file_buffer), + my_fwrite(cnf_file, file_buffer, (size_t) (dst_ptr - file_buffer), MYF(MY_NABP))) goto err; } diff --git a/mysys/hash.c b/mysys/hash.c index 964ba6b1ca3..d8c914d13dd 100644 --- a/mysys/hash.c +++ b/mysys/hash.c @@ -30,15 +30,15 @@ typedef struct st_hash_info { uint next; /* index to next key */ - byte *data; /* data for current entry */ + uchar *data; /* data for current entry */ } HASH_LINK; static uint hash_mask(uint hashnr,uint buffmax,uint maxlength); static void movelink(HASH_LINK *array,uint pos,uint next_link,uint newlink); -static int hashcmp(const HASH *hash, HASH_LINK *pos, const byte *key, - uint length); +static int hashcmp(const HASH *hash, HASH_LINK *pos, const uchar *key, + size_t length); -static uint calc_hash(const HASH *hash, const byte *key, uint length) +static uint calc_hash(const HASH *hash, const uchar *key, size_t length) { ulong nr1=1, nr2=4; hash->charset->coll->hash_sort(hash->charset,(uchar*) key,length,&nr1,&nr2); @@ -47,12 +47,12 @@ static uint calc_hash(const HASH *hash, const byte *key, uint length) my_bool _hash_init(HASH *hash,CHARSET_INFO *charset, - uint size,uint key_offset,uint key_length, + ulong size, size_t key_offset, size_t key_length, hash_get_key get_key, void (*free_element)(void*),uint flags CALLER_INFO_PROTO) { DBUG_ENTER("hash_init"); - DBUG_PRINT("enter",("hash: 0x%lx size: %d", (long) hash, size)); + DBUG_PRINT("enter",("hash: 0x%lx size: %u", (long) hash, (uint) size)); hash->records=0; if (my_init_dynamic_array_ci(&hash->array,sizeof(HASH_LINK),size,0)) @@ -140,18 +140,18 @@ void my_hash_reset(HASH *hash) /* some helper functions */ /* - This function is char* instead of byte* as HPUX11 compiler can't + This function is char* instead of uchar* as HPUX11 compiler can't handle inline functions that are not defined as native types */ static inline char* -hash_key(const HASH *hash, const byte *record, uint *length, +hash_key(const HASH *hash, const uchar *record, size_t *length, my_bool first) { if (hash->get_key) return (*hash->get_key)(record,length,first); *length=hash->key_length; - return (byte*) record+hash->key_offset; + return (uchar*) record+hash->key_offset; } /* Calculate pos according to keys */ @@ -165,8 +165,8 @@ static uint hash_mask(uint hashnr,uint buffmax,uint maxlength) static uint hash_rec_mask(const HASH *hash, HASH_LINK *pos, uint buffmax, uint maxlength) { - uint length; - byte *key= (byte*) hash_key(hash,pos->data,&length,0); + size_t length; + uchar *key= (uchar*) hash_key(hash,pos->data,&length,0); return hash_mask(calc_hash(hash,key,length),buffmax,maxlength); } @@ -177,15 +177,15 @@ static #if !defined(__USLC__) && !defined(__sgi) inline #endif -unsigned int rec_hashnr(HASH *hash,const byte *record) +unsigned int rec_hashnr(HASH *hash,const uchar *record) { - uint length; - byte *key= (byte*) hash_key(hash,record,&length,0); + size_t length; + uchar *key= (uchar*) hash_key(hash,record,&length,0); return calc_hash(hash,key,length); } -gptr hash_search(const HASH *hash, const byte *key, uint length) +uchar* hash_search(const HASH *hash, const uchar *key, size_t length) { HASH_SEARCH_STATE state; return hash_first(hash, key, length, &state); @@ -198,7 +198,7 @@ gptr hash_search(const HASH *hash, const byte *key, uint length) Assigns the number of the found record to HASH_SEARCH_STATE state */ -gptr hash_first(const HASH *hash, const byte *key, uint length, +uchar* hash_first(const HASH *hash, const uchar *key, size_t length, HASH_SEARCH_STATE *current_record) { HASH_LINK *pos; @@ -235,7 +235,7 @@ gptr hash_first(const HASH *hash, const byte *key, uint length, /* Get next record with identical key */ /* Can only be called if previous calls was hash_search */ -gptr hash_next(const HASH *hash, const byte *key, uint length, +uchar* hash_next(const HASH *hash, const uchar *key, size_t length, HASH_SEARCH_STATE *current_record) { HASH_LINK *pos; @@ -292,11 +292,11 @@ static void movelink(HASH_LINK *array,uint find,uint next_link,uint newlink) != 0 key of record != key */ -static int hashcmp(const HASH *hash, HASH_LINK *pos, const byte *key, - uint length) +static int hashcmp(const HASH *hash, HASH_LINK *pos, const uchar *key, + size_t length) { - uint rec_keylength; - byte *rec_key= (byte*) hash_key(hash,pos->data,&rec_keylength,1); + size_t rec_keylength; + uchar *rec_key= (uchar*) hash_key(hash,pos->data,&rec_keylength,1); return ((length && length != rec_keylength) || my_strnncoll(hash->charset, (uchar*) rec_key, rec_keylength, (uchar*) key, rec_keylength)); @@ -305,11 +305,12 @@ static int hashcmp(const HASH *hash, HASH_LINK *pos, const byte *key, /* Write a hash-key to the hash-index */ -my_bool my_hash_insert(HASH *info,const byte *record) +my_bool my_hash_insert(HASH *info,const uchar *record) { int flag; - uint halfbuff,hash_nr,first_index,idx; - byte *ptr_to_rec,*ptr_to_rec2; + size_t idx; + uint halfbuff,hash_nr,first_index; + uchar *ptr_to_rec,*ptr_to_rec2; HASH_LINK *data,*empty,*gpos,*gpos2,*pos; LINT_INIT(gpos); LINT_INIT(gpos2); @@ -317,7 +318,7 @@ my_bool my_hash_insert(HASH *info,const byte *record) if (HASH_UNIQUE & info->flags) { - byte *key= (byte*) hash_key(info, record, &idx, 1); + char *key= (char*) hash_key(info, record, &idx, 1); if (hash_search(info, key, idx)) return(TRUE); /* Duplicate entry */ } @@ -364,7 +365,7 @@ my_bool my_hash_insert(HASH *info,const byte *record) { /* Change link of previous LOW-key */ gpos->data=ptr_to_rec; - gpos->next=(uint) (pos-data); + gpos->next= (uint) (pos-data); flag= (flag & HIGHFIND) | (LOWFIND | LOWUSED); } gpos=pos; @@ -413,7 +414,7 @@ my_bool my_hash_insert(HASH *info,const byte *record) pos=data+idx; if (pos == empty) { - pos->data=(byte*) record; + pos->data=(uchar*) record; pos->next=NO_RECORD; } else @@ -423,12 +424,12 @@ my_bool my_hash_insert(HASH *info,const byte *record) gpos=data+hash_rec_mask(info,pos,info->blength,info->records+1); if (pos == gpos) { - pos->data=(byte*) record; + pos->data=(uchar*) record; pos->next=(uint) (empty - data); } else { - pos->data=(byte*) record; + pos->data=(uchar*) record; pos->next=NO_RECORD; movelink(data,(uint) (pos-data),(uint) (gpos-data),(uint) (empty-data)); } @@ -445,7 +446,7 @@ my_bool my_hash_insert(HASH *info,const byte *record) ** if there is a free-function it's called for record if found ******************************************************************************/ -my_bool hash_delete(HASH *hash,byte *record) +my_bool hash_delete(HASH *hash,uchar *record) { uint blength,pos2,pos_hashnr,lastpos_hashnr,idx,empty_index; HASH_LINK *data,*lastpos,*gpos,*pos,*pos3,*empty; @@ -523,7 +524,7 @@ my_bool hash_delete(HASH *hash,byte *record) exit: VOID(pop_dynamic(&hash->array)); if (hash->free) - (*hash->free)((byte*) record); + (*hash->free)((uchar*) record); DBUG_RETURN(0); } @@ -532,20 +533,22 @@ exit: This is much more efficent than using a delete & insert. */ -my_bool hash_update(HASH *hash,byte *record,byte *old_key,uint old_key_length) +my_bool hash_update(HASH *hash, uchar *record, uchar *old_key, + size_t old_key_length) { - uint idx,new_index,new_pos_index,blength,records,empty; + uint new_index,new_pos_index,blength,records,empty; + size_t idx; HASH_LINK org_link,*data,*previous,*pos; DBUG_ENTER("hash_update"); if (HASH_UNIQUE & hash->flags) { HASH_SEARCH_STATE state; - byte *found, *new_key= hash_key(hash, record, &idx, 1); + char *found, *new_key= hash_key(hash, record, &idx, 1); if ((found= hash_first(hash, new_key, idx, &state))) do { - if (found != record) + if (found != (char*) record) DBUG_RETURN(1); /* Duplicate entry */ } while ((found= hash_next(hash, new_key, idx, &state))); @@ -609,7 +612,7 @@ my_bool hash_update(HASH *hash,byte *record,byte *old_key,uint old_key_length) } -byte *hash_element(HASH *hash,uint idx) +uchar *hash_element(HASH *hash,ulong idx) { if (idx < hash->records) return dynamic_element(&hash->array,idx,HASH_LINK*)->data; @@ -622,7 +625,7 @@ byte *hash_element(HASH *hash,uint idx) isn't changed */ -void hash_replace(HASH *hash, HASH_SEARCH_STATE *current_record, byte *new_row) +void hash_replace(HASH *hash, HASH_SEARCH_STATE *current_record, uchar *new_row) { if (*current_record != NO_RECORD) /* Safety */ dynamic_element(&hash->array, *current_record, HASH_LINK*)->data= new_row; diff --git a/mysys/list.c b/mysys/list.c index ccc3f495093..aaadd686365 100644 --- a/mysys/list.c +++ b/mysys/list.c @@ -61,8 +61,8 @@ void list_free(LIST *root, uint free_data) { next=root->next; if (free_data) - my_free((gptr) root->data,MYF(0)); - my_free((gptr) root,MYF(0)); + my_free((uchar*) root->data,MYF(0)); + my_free((uchar*) root,MYF(0)); root=next; } } @@ -101,7 +101,7 @@ uint list_length(LIST *list) } -int list_walk(LIST *list, list_walk_action action, gptr argument) +int list_walk(LIST *list, list_walk_action action, uchar* argument) { int error=0; while (list) diff --git a/mysys/mf_cache.c b/mysys/mf_cache.c index a3abb3bc974..f0df0f3fa77 100644 --- a/mysys/mf_cache.c +++ b/mysys/mf_cache.c @@ -58,7 +58,7 @@ static my_bool cache_remove_open_tmp(IO_CACHE *cache __attribute__((unused)), */ my_bool open_cached_file(IO_CACHE *cache, const char* dir, const char *prefix, - uint cache_size, myf cache_myflags) + size_t cache_size, myf cache_myflags) { DBUG_ENTER("open_cached_file"); cache->dir= dir ? my_strdup(dir,MYF(cache_myflags & MY_WME)) : (char*) 0; diff --git a/mysys/mf_dirname.c b/mysys/mf_dirname.c index 87a4a453734..1b428ded751 100644 --- a/mysys/mf_dirname.c +++ b/mysys/mf_dirname.c @@ -18,9 +18,9 @@ /* Functions definied in this file */ -uint dirname_length(const char *name) +size_t dirname_length(const char *name) { - register my_string pos,gpos; + register char *pos, *gpos; #ifdef BASKSLASH_MBTAIL CHARSET_INFO *fs= fs_character_set(); #endif @@ -47,21 +47,31 @@ uint dirname_length(const char *name) ) gpos=pos; } - return ((uint) (uint) (gpos+1-(char*) name)); + return (size_t) (gpos+1-(char*) name); } - /* Gives directory part of filename. Directory ends with '/' */ - /* Returns length of directory part */ +/* + Gives directory part of filename. Directory ends with '/' + + SYNOPSIS + dirname_part() + to Store directory name here + name Original name + to_length Store length of 'to' here + + RETURN + # Length of directory part in 'name' +*/ -uint dirname_part(my_string to, const char *name) +size_t dirname_part(char *to, const char *name, size_t *to_res_length) { - uint length; + size_t length; DBUG_ENTER("dirname_part"); DBUG_PRINT("enter",("'%s'",name)); length=dirname_length(name); - convert_dirname(to, name, name+length); + *to_res_length= (size_t) (convert_dirname(to, name, name+length) - to); DBUG_RETURN(length); } /* dirname */ @@ -142,7 +152,7 @@ char *convert_dirname(char *to, const char *from, const char *from_end) } #else /* This is ok even if to == from, becasue we need to cut the string */ - to= strmake(to, from, (uint) (from_end-from)); + to= strmake(to, from, (size_t) (from_end-from)); #endif /* Add FN_LIBCHAR to the end of directory path */ diff --git a/mysys/mf_fn_ext.c b/mysys/mf_fn_ext.c index 20e835fe641..da7fac3de73 100644 --- a/mysys/mf_fn_ext.c +++ b/mysys/mf_fn_ext.c @@ -33,21 +33,22 @@ points at the end ASCII(0) of the filename. */ -my_string fn_ext(const char *name) +char *fn_ext(const char *name) { - register my_string pos,gpos; + register const char *pos, *gpos; DBUG_ENTER("fn_ext"); DBUG_PRINT("mfunkt",("name: '%s'",name)); #if defined(FN_DEVCHAR) || defined(FN_C_AFTER_DIR) || defined(BASKSLASH_MBTAIL) { char buff[FN_REFLEN]; - gpos=(my_string) name+dirname_part(buff,(char*) name); + size_t res_length; + gpos= name+ dirname_part(buff,(char*) name, &res_length); } #else if (!(gpos= strrchr(name, FN_LIBCHAR))) - gpos= (my_string) name; + gpos= name; #endif pos=strchr(gpos,FN_EXTCHAR); - DBUG_RETURN (pos ? pos : strend(gpos)); + DBUG_RETURN((char*) (pos ? pos : strend(gpos))); } /* fn_ext */ diff --git a/mysys/mf_format.c b/mysys/mf_format.c index 3e5eeef6420..f199132626b 100644 --- a/mysys/mf_format.c +++ b/mysys/mf_format.c @@ -23,18 +23,19 @@ The arguments should be in unix format. */ -my_string fn_format(my_string to, const char *name, const char *dir, +char * fn_format(char * to, const char *name, const char *dir, const char *extension, uint flag) { - reg1 uint length; char dev[FN_REFLEN], buff[FN_REFLEN], *pos, *startpos; const char *ext; + reg1 size_t length; + size_t dev_length; DBUG_ENTER("fn_format"); DBUG_PRINT("enter",("name: %s dir: %s extension: %s flag: %d", name,dir,extension,flag)); /* Copy and skip directory */ - name+=(length=dirname_part(dev,(startpos=(my_string) name))); + name+=(length=dirname_part(dev, (startpos=(char *) name), &dev_length)); if (length == 0 || (flag & MY_REPLACE_DIR)) { /* Use given directory */ @@ -63,7 +64,7 @@ my_string fn_format(my_string to, const char *name, const char *dir, } else { - length=(uint) (pos-(char*) name); /* Change extension */ + length= (size_t) (pos-(char*) name); /* Change extension */ ext= extension; } } @@ -76,18 +77,19 @@ my_string fn_format(my_string to, const char *name, const char *dir, if (strlen(dev)+length+strlen(ext) >= FN_REFLEN || length >= FN_LEN ) { /* To long path, return original or NULL */ - uint tmp_length; + size_t tmp_length; if (flag & MY_SAFE_PATH) return NullS; - tmp_length=strlength(startpos); - DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %d",dev,ext,length)); + tmp_length= strlength(startpos); + DBUG_PRINT("error",("dev: '%s' ext: '%s' length: %u",dev,ext, + (uint) length)); (void) strmake(to,startpos,min(tmp_length,FN_REFLEN-1)); } else { if (to == startpos) { - bmove(buff,(char*) name,length); /* Save name for last copy */ + bmove(buff,(uchar*) name,length); /* Save name for last copy */ name=buff; } pos=strmake(strmov(to,dev),name,length); @@ -109,18 +111,18 @@ my_string fn_format(my_string to, const char *name, const char *dir, } /* fn_format */ - /* - strlength(const string str) - Return length of string with end-space:s not counted. - */ +/* + strlength(const string str) + Return length of string with end-space:s not counted. +*/ -size_s strlength(const char *str) +size_t strlength(const char *str) { - reg1 my_string pos; - reg2 my_string found; + reg1 const char * pos; + reg2 const char * found; DBUG_ENTER("strlength"); - pos=found=(char*) str; + pos= found= str; while (*pos) { @@ -136,5 +138,5 @@ size_s strlength(const char *str) found=pos; while (*++pos == ' ') {}; } - DBUG_RETURN((size_s) (found-(char*) str)); + DBUG_RETURN((size_t) (found - str)); } /* strlength */ diff --git a/mysys/mf_getdate.c b/mysys/mf_getdate.c index 1ced312848e..2f08027a477 100644 --- a/mysys/mf_getdate.c +++ b/mysys/mf_getdate.c @@ -34,7 +34,7 @@ */ -void get_date(register my_string to, int flag, time_t date) +void get_date(register char * to, int flag, time_t date) { reg2 struct tm *start_time; time_t skr; diff --git a/mysys/mf_iocache.c b/mysys/mf_iocache.c index d2ace12da4d..58650733490 100644 --- a/mysys/mf_iocache.c +++ b/mysys/mf_iocache.c @@ -152,11 +152,11 @@ init_functions(IO_CACHE* info) # error */ -int init_io_cache(IO_CACHE *info, File file, uint cachesize, +int init_io_cache(IO_CACHE *info, File file, size_t cachesize, enum cache_type type, my_off_t seek_offset, pbool use_async_io, myf cache_myflags) { - uint min_cache; + size_t min_cache; my_off_t pos; my_off_t end_of_file= ~(my_off_t) 0; DBUG_ENTER("init_io_cache"); @@ -214,7 +214,7 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, /* Trim cache size if the file is very small */ if ((my_off_t) cachesize > end_of_file-seek_offset+IO_SIZE*2-1) { - cachesize=(uint) (end_of_file-seek_offset)+IO_SIZE*2-1; + cachesize= (size_t) (end_of_file-seek_offset)+IO_SIZE*2-1; use_async_io=0; /* No need to use async */ } } @@ -223,18 +223,17 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, if (type != READ_NET && type != WRITE_NET) { /* Retry allocating memory in smaller blocks until we get one */ - cachesize=(uint) ((ulong) (cachesize + min_cache-1) & - (ulong) ~(min_cache-1)); + cachesize= ((cachesize + min_cache-1) & ~(min_cache-1)); for (;;) { - uint buffer_block; + size_t buffer_block; if (cachesize < min_cache) cachesize = min_cache; - buffer_block = cachesize; + buffer_block= cachesize; if (type == SEQ_READ_APPEND) buffer_block *= 2; if ((info->buffer= - (byte*) my_malloc(buffer_block, + (uchar*) my_malloc(buffer_block, MYF((cache_myflags & ~ MY_WME) | (cachesize == min_cache ? MY_WME : 0)))) != 0) { @@ -247,11 +246,11 @@ int init_io_cache(IO_CACHE *info, File file, uint cachesize, if (cachesize == min_cache) DBUG_RETURN(2); /* Can't alloc cache */ /* Try with less memory */ - cachesize= (uint) ((ulong) cachesize*3/4 & (ulong)~(min_cache-1)); + cachesize= (cachesize*3/4 & ~(min_cache-1)); } } - DBUG_PRINT("info",("init_io_cache: cachesize = %u",cachesize)); + DBUG_PRINT("info",("init_io_cache: cachesize = %lu", (ulong) cachesize)); info->read_length=info->buffer_length=cachesize; info->myflags=cache_myflags & ~(MY_NABP | MY_FNABP); info->request_pos= info->read_pos= info->write_pos = info->buffer; @@ -350,7 +349,7 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type, seek_offset <= my_b_tell(info)) { /* Reuse current buffer without flushing it to disk */ - byte *pos; + uchar *pos; if (info->type == WRITE_CACHE && type == READ_CACHE) { info->read_end=info->write_pos; @@ -452,22 +451,22 @@ my_bool reinit_io_cache(IO_CACHE *info, enum cache_type type, 1 Error: can't read requested characters */ -int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count) +int _my_b_read(register IO_CACHE *info, uchar *Buffer, size_t Count) { - uint length,diff_length,left_length; - my_off_t max_length, pos_in_file; + size_t length,diff_length,left_length, max_length; + my_off_t pos_in_file; DBUG_ENTER("_my_b_read"); - if ((left_length=(uint) (info->read_end-info->read_pos))) + if ((left_length= (size_t) (info->read_end-info->read_pos))) { DBUG_ASSERT(Count >= left_length); /* User is not using my_b_read() */ - memcpy(Buffer,info->read_pos, (size_t) (left_length)); + memcpy(Buffer,info->read_pos, left_length); Buffer+=left_length; Count-=left_length; } /* pos_in_file always point on where info->buffer was read */ - pos_in_file=info->pos_in_file+(uint) (info->read_end - info->buffer); + pos_in_file=info->pos_in_file+ (size_t) (info->read_end - info->buffer); /* Whenever a function which operates on IO_CACHE flushes/writes @@ -496,20 +495,20 @@ int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count) } } - diff_length=(uint) (pos_in_file & (IO_SIZE-1)); - if (Count >= (uint) (IO_SIZE+(IO_SIZE-diff_length))) + diff_length= (size_t) (pos_in_file & (IO_SIZE-1)); + if (Count >= (size_t) (IO_SIZE+(IO_SIZE-diff_length))) { /* Fill first intern buffer */ - uint read_length; + size_t read_length; if (info->end_of_file <= pos_in_file) { /* End of file */ - info->error=(int) left_length; + info->error= (int) left_length; DBUG_RETURN(1); } - length=(Count & (uint) ~(IO_SIZE-1))-diff_length; - if ((read_length=my_read(info->file,Buffer,(uint) length,info->myflags)) - != (uint) length) + length=(Count & (size_t) ~(IO_SIZE-1))-diff_length; + if ((read_length= my_read(info->file,Buffer, length, info->myflags)) + != length) { - info->error= (read_length == (uint) -1 ? -1 : + info->error= (read_length == (size_t) -1 ? -1 : (int) (read_length+left_length)); DBUG_RETURN(1); } @@ -520,10 +519,10 @@ int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count) diff_length=0; } - max_length=info->read_length-diff_length; + max_length= info->read_length-diff_length; if (info->type != READ_FIFO && max_length > (info->end_of_file - pos_in_file)) - max_length = info->end_of_file - pos_in_file; + max_length= (size_t) (info->end_of_file - pos_in_file); if (!max_length) { if (Count) @@ -533,21 +532,21 @@ int _my_b_read(register IO_CACHE *info, byte *Buffer, uint Count) } length=0; /* Didn't read any chars */ } - else if ((length=my_read(info->file,info->buffer,(uint) max_length, - info->myflags)) < Count || - length == (uint) -1) + else if ((length= my_read(info->file,info->buffer, max_length, + info->myflags)) < Count || + length == (size_t) -1) { - if (length != (uint) -1) - memcpy(Buffer,info->buffer,(size_t) length); + if (length != (size_t) -1) + memcpy(Buffer, info->buffer, length); info->pos_in_file= pos_in_file; - info->error= length == (uint) -1 ? -1 : (int) (length+left_length); + info->error= length == (size_t) -1 ? -1 : (int) (length+left_length); info->read_pos=info->read_end=info->buffer; DBUG_RETURN(1); } info->read_pos=info->buffer+Count; info->read_end=info->buffer+length; info->pos_in_file=pos_in_file; - memcpy(Buffer,info->buffer,(size_t) Count); + memcpy(Buffer, info->buffer, Count); DBUG_RETURN(0); } @@ -859,8 +858,9 @@ static int lock_io_cache(IO_CACHE *cache, my_off_t pos) /* Another thread did read the block already. */ } DBUG_PRINT("io_cache_share", ("reader awoke, going to process %u bytes", - cshare->read_end ? (uint) - (cshare->read_end - cshare->buffer) : 0)); + (uint) (cshare->read_end ? (size_t) + (cshare->read_end - cshare->buffer) : + 0))); /* Leave the lock. Do not call unlock_io_cache() later. The thread that @@ -952,33 +952,33 @@ static void unlock_io_cache(IO_CACHE *cache) 1 Error: can't read requested characters */ -int _my_b_read_r(register IO_CACHE *cache, byte *Buffer, uint Count) +int _my_b_read_r(register IO_CACHE *cache, uchar *Buffer, size_t Count) { my_off_t pos_in_file; - uint length, diff_length, left_length; + size_t length, diff_length, left_length; IO_CACHE_SHARE *cshare= cache->share; DBUG_ENTER("_my_b_read_r"); - if ((left_length= (uint) (cache->read_end - cache->read_pos))) + if ((left_length= (size_t) (cache->read_end - cache->read_pos))) { DBUG_ASSERT(Count >= left_length); /* User is not using my_b_read() */ - memcpy(Buffer, cache->read_pos, (size_t) (left_length)); + memcpy(Buffer, cache->read_pos, left_length); Buffer+= left_length; Count-= left_length; } while (Count) { - int cnt, len; + size_t cnt, len; pos_in_file= cache->pos_in_file + (cache->read_end - cache->buffer); - diff_length= (uint) (pos_in_file & (IO_SIZE-1)); + diff_length= (size_t) (pos_in_file & (IO_SIZE-1)); length=IO_ROUND_UP(Count+diff_length)-diff_length; length= ((length <= cache->read_length) ? length + IO_ROUND_DN(cache->read_length - length) : length - IO_ROUND_UP(length - cache->read_length)); if (cache->type != READ_FIFO && (length > (cache->end_of_file - pos_in_file))) - length= (uint) (cache->end_of_file - pos_in_file); + length= (size_t) (cache->end_of_file - pos_in_file); if (length == 0) { cache->error= (int) left_length; @@ -1013,12 +1013,12 @@ int _my_b_read_r(register IO_CACHE *cache, byte *Buffer, uint Count) DBUG_RETURN(1); } } - len= (int) my_read(cache->file, cache->buffer, length, cache->myflags); + len= my_read(cache->file, cache->buffer, length, cache->myflags); } - DBUG_PRINT("io_cache_share", ("read %d bytes", len)); + DBUG_PRINT("io_cache_share", ("read %lu bytes", (ulong) len)); - cache->read_end= cache->buffer + (len == -1 ? 0 : len); - cache->error= (len == (int)length ? 0 : len); + cache->read_end= cache->buffer + (len == (size_t) -1 ? 0 : len); + cache->error= (len == length ? 0 : (int) len); cache->pos_in_file= pos_in_file; /* Copy important values to the share. */ @@ -1039,19 +1039,20 @@ int _my_b_read_r(register IO_CACHE *cache, byte *Buffer, uint Count) cache->read_end= cshare->read_end; cache->pos_in_file= cshare->pos_in_file; - len= (int) ((cache->error == -1) ? -1 : cache->read_end - cache->buffer); + len= ((cache->error == -1) ? (size_t) -1 : + (size_t) (cache->read_end - cache->buffer)); } cache->read_pos= cache->buffer; cache->seek_not_done= 0; - if (len <= 0) + if (len == 0 || len == (size_t) -1) { - DBUG_PRINT("io_cache_share", ("reader error. len %d left %u", - len, left_length)); + DBUG_PRINT("io_cache_share", ("reader error. len %lu left %lu", + (ulong) len, (ulong) left_length)); cache->error= (int) left_length; DBUG_RETURN(1); } - cnt= ((uint) len > Count) ? (int) Count : len; - memcpy(Buffer, cache->read_pos, (size_t) cnt); + cnt= (len > Count) ? Count : len; + memcpy(Buffer, cache->read_pos, cnt); Count -= cnt; Buffer+= cnt; left_length+= cnt; @@ -1079,7 +1080,7 @@ int _my_b_read_r(register IO_CACHE *cache, byte *Buffer, uint Count) */ static void copy_to_read_buffer(IO_CACHE *write_cache, - const byte *write_buffer, uint write_length) + const uchar *write_buffer, size_t write_length) { IO_CACHE_SHARE *cshare= write_cache->share; @@ -1090,7 +1091,7 @@ static void copy_to_read_buffer(IO_CACHE *write_cache, */ while (write_length) { - uint copy_length= min(write_length, write_cache->buffer_length); + size_t copy_length= min(write_length, write_cache->buffer_length); int __attribute__((unused)) rc; rc= lock_io_cache(write_cache, write_cache->pos_in_file); @@ -1126,33 +1127,32 @@ static void copy_to_read_buffer(IO_CACHE *write_cache, 1 Failed to read */ -int _my_b_seq_read(register IO_CACHE *info, byte *Buffer, uint Count) +int _my_b_seq_read(register IO_CACHE *info, uchar *Buffer, size_t Count) { - uint length,diff_length,left_length,save_count; - my_off_t max_length, pos_in_file; + size_t length, diff_length, left_length, save_count, max_length; + my_off_t pos_in_file; save_count=Count; /* first, read the regular buffer */ - if ((left_length=(uint) (info->read_end-info->read_pos))) + if ((left_length=(size_t) (info->read_end-info->read_pos))) { DBUG_ASSERT(Count > left_length); /* User is not using my_b_read() */ - memcpy(Buffer,info->read_pos, (size_t) (left_length)); + memcpy(Buffer,info->read_pos, left_length); Buffer+=left_length; Count-=left_length; } lock_append_buffer(info); /* pos_in_file always point on where info->buffer was read */ - if ((pos_in_file=info->pos_in_file+(uint) (info->read_end - info->buffer)) >= - info->end_of_file) + if ((pos_in_file=info->pos_in_file + + (size_t) (info->read_end - info->buffer)) >= info->end_of_file) goto read_append_buffer; /* With read-append cache we must always do a seek before we read, because the write could have moved the file pointer astray */ - if (my_seek(info->file,pos_in_file,MY_SEEK_SET,MYF(0)) - == MY_FILEPOS_ERROR) + if (my_seek(info->file,pos_in_file,MY_SEEK_SET,MYF(0)) == MY_FILEPOS_ERROR) { info->error= -1; unlock_append_buffer(info); @@ -1160,16 +1160,17 @@ int _my_b_seq_read(register IO_CACHE *info, byte *Buffer, uint Count) } info->seek_not_done=0; - diff_length=(uint) (pos_in_file & (IO_SIZE-1)); + diff_length= (size_t) (pos_in_file & (IO_SIZE-1)); /* now the second stage begins - read from file descriptor */ - if (Count >= (uint) (IO_SIZE+(IO_SIZE-diff_length))) - { /* Fill first intern buffer */ - uint read_length; + if (Count >= (size_t) (IO_SIZE+(IO_SIZE-diff_length))) + { + /* Fill first intern buffer */ + size_t read_length; - length=(Count & (uint) ~(IO_SIZE-1))-diff_length; - if ((read_length=my_read(info->file,Buffer,(uint) length,info->myflags)) == - (uint)-1) + length=(Count & (size_t) ~(IO_SIZE-1))-diff_length; + if ((read_length= my_read(info->file,Buffer, length, + info->myflags)) == (size_t) -1) { info->error= -1; unlock_append_buffer(info); @@ -1179,7 +1180,7 @@ int _my_b_seq_read(register IO_CACHE *info, byte *Buffer, uint Count) Buffer+=read_length; pos_in_file+=read_length; - if (read_length != (uint) length) + if (read_length != length) { /* We only got part of data; Read the rest of the data from the @@ -1191,9 +1192,9 @@ int _my_b_seq_read(register IO_CACHE *info, byte *Buffer, uint Count) diff_length=0; } - max_length=info->read_length-diff_length; + max_length= info->read_length-diff_length; if (max_length > (info->end_of_file - pos_in_file)) - max_length = info->end_of_file - pos_in_file; + max_length= (size_t) (info->end_of_file - pos_in_file); if (!max_length) { if (Count) @@ -1202,9 +1203,8 @@ int _my_b_seq_read(register IO_CACHE *info, byte *Buffer, uint Count) } else { - length=my_read(info->file,info->buffer,(uint) max_length, - info->myflags); - if (length == (uint) -1) + length= my_read(info->file,info->buffer, max_length, info->myflags); + if (length == (size_t) -1) { info->error= -1; unlock_append_buffer(info); @@ -1212,7 +1212,7 @@ int _my_b_seq_read(register IO_CACHE *info, byte *Buffer, uint Count) } if (length < Count) { - memcpy(Buffer,info->buffer,(size_t) length); + memcpy(Buffer, info->buffer, length); Count -= length; Buffer += length; @@ -1241,9 +1241,9 @@ read_append_buffer: { /* First copy the data to Count */ - uint len_in_buff = (uint) (info->write_pos - info->append_read_pos); - uint copy_len; - uint transfer_len; + size_t len_in_buff = (size_t) (info->write_pos - info->append_read_pos); + size_t copy_len; + size_t transfer_len; DBUG_ASSERT(info->append_read_pos <= info->write_pos); /* @@ -1288,15 +1288,16 @@ read_append_buffer: 0 Success 1 An error has occurred; IO_CACHE to error state. */ -int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count) + +int _my_b_async_read(register IO_CACHE *info, uchar *Buffer, size_t Count) { - uint length,read_length,diff_length,left_length,use_length,org_Count; - my_off_t max_length; + size_t length,read_length,diff_length,left_length,use_length,org_Count; + size_t max_length; my_off_t next_pos_in_file; - byte *read_buffer; + uchar *read_buffer; memcpy(Buffer,info->read_pos, - (size_t) (left_length=(uint) (info->read_end-info->read_pos))); + (left_length= (size_t) (info->read_end-info->read_pos))); Buffer+=left_length; org_Count=Count; Count-=left_length; @@ -1315,15 +1316,15 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count) info->error= -1; return(1); } - if (! (read_length = (uint) info->aio_result.result.aio_return) || - read_length == (uint) -1) + if (! (read_length= (size_t) info->aio_result.result.aio_return) || + read_length == (size_t) -1) { my_errno=0; /* For testing */ - info->error= (read_length == (uint) -1 ? -1 : + info->error= (read_length == (size_t) -1 ? -1 : (int) (read_length+left_length)); return(1); } - info->pos_in_file+=(uint) (info->read_end - info->request_pos); + info->pos_in_file+= (size_t) (info->read_end - info->request_pos); if (info->request_pos != info->buffer) info->request_pos=info->buffer; @@ -1354,7 +1355,7 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count) if (info->aio_read_pos > info->pos_in_file) { my_errno=EINVAL; - return(info->read_length= -1); + return(info->read_length= (size_t) -1); } #endif /* Copy found bytes to buffer */ @@ -1367,7 +1368,7 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count) info->read_pos+=length; } else - next_pos_in_file=(info->pos_in_file+ (uint) + next_pos_in_file=(info->pos_in_file+ (size_t) (info->read_end - info->request_pos)); /* If reading large blocks, or first read or read with skip */ @@ -1386,11 +1387,11 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count) return (1); } - read_length=IO_SIZE*2- (uint) (next_pos_in_file & (IO_SIZE-1)); + read_length=IO_SIZE*2- (size_t) (next_pos_in_file & (IO_SIZE-1)); if (Count < read_length) { /* Small block, read to cache */ if ((read_length=my_read(info->file,info->request_pos, - read_length, info->myflags)) == (uint) -1) + read_length, info->myflags)) == (size_t) -1) return info->error= -1; use_length=min(Count,read_length); memcpy(Buffer,info->request_pos,(size_t) use_length); @@ -1410,10 +1411,10 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count) } else { /* Big block, don't cache it */ - if ((read_length=my_read(info->file,Buffer,(uint) Count,info->myflags)) + if ((read_length= my_read(info->file,Buffer, Count,info->myflags)) != Count) { - info->error= read_length == (uint) -1 ? -1 : read_length+left_length; + info->error= read_length == (size_t) -1 ? -1 : read_length+left_length; return 1; } info->read_pos=info->read_end=info->request_pos; @@ -1421,12 +1422,12 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count) } } - /* Read next block with asyncronic io */ - max_length=info->end_of_file - next_pos_in_file; + /* Read next block with asyncronic io */ diff_length=(next_pos_in_file & (IO_SIZE-1)); + max_length= info->read_length - diff_length; + if (max_length > info->end_of_file - next_pos_in_file) + max_length= (size_t) (info->end_of_file - next_pos_in_file); - if (max_length > (my_off_t) info->read_length - diff_length) - max_length= (my_off_t) info->read_length - diff_length; if (info->request_pos != info->buffer) read_buffer=info->buffer; else @@ -1435,9 +1436,9 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count) if (max_length) { info->aio_result.result.aio_errno=AIO_INPROGRESS; /* Marker for test */ - DBUG_PRINT("aioread",("filepos: %ld length: %ld", - (ulong) next_pos_in_file,(ulong) max_length)); - if (aioread(info->file,read_buffer,(int) max_length, + DBUG_PRINT("aioread",("filepos: %ld length: %lu", + (ulong) next_pos_in_file, (ulong) max_length)); + if (aioread(info->file,read_buffer, max_length, (my_off_t) next_pos_in_file,MY_SEEK_SET, &info->aio_result.result)) { /* Skip async io */ @@ -1447,7 +1448,7 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count) if (info->request_pos != info->buffer) { bmove(info->buffer,info->request_pos, - (uint) (info->read_end - info->read_pos)); + (size_t) (info->read_end - info->read_pos)); info->request_pos=info->buffer; info->read_pos-=info->read_length; info->read_end-=info->read_length; @@ -1467,7 +1468,7 @@ int _my_b_async_read(register IO_CACHE *info, byte *Buffer, uint Count) int _my_b_get(IO_CACHE *info) { - byte buff; + uchar buff; IO_CACHE_CALLBACK pre_read,post_read; if ((pre_read = info->pre_read)) (*pre_read)(info); @@ -1488,9 +1489,9 @@ int _my_b_get(IO_CACHE *info) -1 On error; my_errno contains error code. */ -int _my_b_write(register IO_CACHE *info, const byte *Buffer, uint Count) +int _my_b_write(register IO_CACHE *info, const uchar *Buffer, size_t Count) { - uint rest_length,length; + size_t rest_length,length; if (info->pos_in_file+info->buffer_length > info->end_of_file) { @@ -1498,7 +1499,7 @@ int _my_b_write(register IO_CACHE *info, const byte *Buffer, uint Count) return info->error = -1; } - rest_length=(uint) (info->write_end - info->write_pos); + rest_length= (size_t) (info->write_end - info->write_pos); memcpy(info->write_pos,Buffer,(size_t) rest_length); Buffer+=rest_length; Count-=rest_length; @@ -1508,7 +1509,7 @@ int _my_b_write(register IO_CACHE *info, const byte *Buffer, uint Count) return 1; if (Count >= IO_SIZE) { /* Fill first intern buffer */ - length=Count & (uint) ~(IO_SIZE-1); + length=Count & (size_t) ~(IO_SIZE-1); if (info->seek_not_done) { /* @@ -1524,7 +1525,7 @@ int _my_b_write(register IO_CACHE *info, const byte *Buffer, uint Count) } info->seek_not_done=0; } - if (my_write(info->file,Buffer,(uint) length,info->myflags | MY_NABP)) + if (my_write(info->file, Buffer, length, info->myflags | MY_NABP)) return info->error= -1; #ifdef THREAD @@ -1559,9 +1560,9 @@ int _my_b_write(register IO_CACHE *info, const byte *Buffer, uint Count) the write buffer before we are ready with it. */ -int my_b_append(register IO_CACHE *info, const byte *Buffer, uint Count) +int my_b_append(register IO_CACHE *info, const uchar *Buffer, size_t Count) { - uint rest_length,length; + size_t rest_length,length; #ifdef THREAD /* @@ -1572,10 +1573,10 @@ int my_b_append(register IO_CACHE *info, const byte *Buffer, uint Count) #endif lock_append_buffer(info); - rest_length=(uint) (info->write_end - info->write_pos); + rest_length= (size_t) (info->write_end - info->write_pos); if (Count <= rest_length) goto end; - memcpy(info->write_pos,Buffer,(size_t) rest_length); + memcpy(info->write_pos, Buffer, rest_length); Buffer+=rest_length; Count-=rest_length; info->write_pos+=rest_length; @@ -1586,8 +1587,8 @@ int my_b_append(register IO_CACHE *info, const byte *Buffer, uint Count) } if (Count >= IO_SIZE) { /* Fill first intern buffer */ - length=Count & (uint) ~(IO_SIZE-1); - if (my_write(info->file,Buffer,(uint) length,info->myflags | MY_NABP)) + length=Count & (size_t) ~(IO_SIZE-1); + if (my_write(info->file,Buffer, length, info->myflags | MY_NABP)) { unlock_append_buffer(info); return info->error= -1; @@ -1605,7 +1606,7 @@ end: } -int my_b_safe_write(IO_CACHE *info, const byte *Buffer, uint Count) +int my_b_safe_write(IO_CACHE *info, const uchar *Buffer, size_t Count) { /* Sasha: We are not writing this with the ? operator to avoid hitting @@ -1625,10 +1626,10 @@ int my_b_safe_write(IO_CACHE *info, const byte *Buffer, uint Count) we will never get a seek over the end of the buffer */ -int my_block_write(register IO_CACHE *info, const byte *Buffer, uint Count, +int my_block_write(register IO_CACHE *info, const uchar *Buffer, size_t Count, my_off_t pos) { - uint length; + size_t length; int error=0; #ifdef THREAD @@ -1648,7 +1649,7 @@ int my_block_write(register IO_CACHE *info, const byte *Buffer, uint Count, /* Write the part of the block that is before buffer */ length= (uint) (info->pos_in_file - pos); if (my_pwrite(info->file, Buffer, length, pos, info->myflags | MY_NABP)) - info->error=error=-1; + info->error= error= -1; Buffer+=length; pos+= length; Count-= length; @@ -1658,10 +1659,10 @@ int my_block_write(register IO_CACHE *info, const byte *Buffer, uint Count, } /* Check if we want to write inside the used part of the buffer.*/ - length= (uint) (info->write_end - info->buffer); + length= (size_t) (info->write_end - info->buffer); if (pos < info->pos_in_file + length) { - uint offset= (uint) (pos - info->pos_in_file); + size_t offset= (size_t) (pos - info->pos_in_file); length-=offset; if (length > Count) length=Count; @@ -1696,7 +1697,7 @@ int my_block_write(register IO_CACHE *info, const byte *Buffer, uint Count, int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock) { - uint length; + size_t length; my_bool append_cache; my_off_t pos_in_file; DBUG_ENTER("my_b_flush_io_cache"); @@ -1713,7 +1714,7 @@ int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock) } LOCK_APPEND_BUFFER; - if ((length=(uint) (info->write_pos - info->write_buffer))) + if ((length=(size_t) (info->write_pos - info->write_buffer))) { #ifdef THREAD /* @@ -1821,8 +1822,8 @@ int end_io_cache(IO_CACHE *info) info->alloced_buffer=0; if (info->file != -1) /* File doesn't exist */ error= my_b_flush_io_cache(info,1); - my_free((gptr) info->buffer,MYF(MY_WME)); - info->buffer=info->read_pos=(byte*) 0; + my_free((uchar*) info->buffer,MYF(MY_WME)); + info->buffer=info->read_pos=(uchar*) 0; } if (info->type == SEQ_READ_APPEND) { diff --git a/mysys/mf_iocache2.c b/mysys/mf_iocache2.c index bdb5d057a16..8a5b91661c4 100644 --- a/mysys/mf_iocache2.c +++ b/mysys/mf_iocache2.c @@ -50,7 +50,7 @@ int my_b_copy_to_file(IO_CACHE *cache, FILE *file) { - uint bytes_in_cache; + size_t bytes_in_cache; DBUG_ENTER("my_b_copy_to_file"); /* Reinit the cache to read from the beginning of the cache */ @@ -60,7 +60,7 @@ my_b_copy_to_file(IO_CACHE *cache, FILE *file) do { if (my_fwrite(file, cache->read_pos, bytes_in_cache, - MYF(MY_WME | MY_NABP)) == (uint) -1) + MYF(MY_WME | MY_NABP)) == (size_t) -1) DBUG_RETURN(1); cache->read_pos= cache->read_end; } while ((bytes_in_cache= my_b_fill(cache))); @@ -175,18 +175,24 @@ void my_b_seek(IO_CACHE *info,my_off_t pos) /* - Fill buffer. Note that this assumes that you have already used - all characters in the CACHE, independent of the read_pos value! - return: 0 on error or EOF (info->error = -1 on error) - number of characters + Fill buffer of the cache. + + NOTES + This assumes that you have already used all characters in the CACHE, + independent of the read_pos value! + + RETURN + 0 On error or EOF (info->error = -1 on error) + # Number of characters */ -uint my_b_fill(IO_CACHE *info) + +size_t my_b_fill(IO_CACHE *info) { my_off_t pos_in_file=(info->pos_in_file+ - (uint) (info->read_end - info->buffer)); - my_off_t max_length; - uint diff_length,length; + (size_t) (info->read_end - info->buffer)); + size_t diff_length, length, max_length; + if (info->seek_not_done) { /* File touched, do seek */ if (my_seek(info->file,pos_in_file,MY_SEEK_SET,MYF(0)) == @@ -197,17 +203,18 @@ uint my_b_fill(IO_CACHE *info) } info->seek_not_done=0; } - diff_length=(uint) (pos_in_file & (IO_SIZE-1)); - max_length= (my_off_t) (info->end_of_file - pos_in_file); - if (max_length > (my_off_t) (info->read_length-diff_length)) - max_length=(my_off_t) (info->read_length-diff_length); + diff_length=(size_t) (pos_in_file & (IO_SIZE-1)); + max_length=(info->read_length-diff_length); + if (max_length >= (info->end_of_file - pos_in_file)) + max_length= (size_t) (info->end_of_file - pos_in_file); + if (!max_length) { info->error= 0; return 0; /* EOF */ } - else if ((length=my_read(info->file,info->buffer,(uint) max_length, - info->myflags)) == (uint) -1) + if ((length= my_read(info->file,info->buffer,max_length, + info->myflags)) == (size_t) -1) { info->error= -1; return 0; @@ -226,15 +233,17 @@ uint my_b_fill(IO_CACHE *info) If buffer is full then to[max_length-1] will be set to \0. */ -uint my_b_gets(IO_CACHE *info, char *to, uint max_length) +size_t my_b_gets(IO_CACHE *info, char *to, size_t max_length) { char *start = to; - uint length; + size_t length; max_length--; /* Save place for end \0 */ + /* Calculate number of characters in buffer */ if (!(length= my_b_bytes_in_cache(info)) && !(length= my_b_fill(info))) return 0; + for (;;) { char *pos,*end; @@ -246,7 +255,7 @@ uint my_b_gets(IO_CACHE *info, char *to, uint max_length) { info->read_pos=pos; *to='\0'; - return (uint) (to-start); + return (size_t) (to-start); } } if (!(max_length-=length)) @@ -254,7 +263,7 @@ uint my_b_gets(IO_CACHE *info, char *to, uint max_length) /* Found enough charcters; Return found string */ info->read_pos=pos; *to='\0'; - return (uint) (to-start); + return (size_t) (to-start); } if (!(length=my_b_fill(info))) return 0; @@ -265,26 +274,22 @@ uint my_b_gets(IO_CACHE *info, char *to, uint max_length) my_off_t my_b_filelength(IO_CACHE *info) { if (info->type == WRITE_CACHE) - { return my_b_tell(info); - } - else - { - info->seek_not_done=1; - return my_seek(info->file,0L,MY_SEEK_END,MYF(0)); - } + + info->seek_not_done= 1; + return my_seek(info->file, 0L, MY_SEEK_END, MYF(0)); } /* Simple printf version. Supports '%s', '%d', '%u', "%ld" and "%lu" Used for logging in MySQL - returns number of written character, or (uint) -1 on error + returns number of written character, or (size_t) -1 on error */ -uint my_b_printf(IO_CACHE *info, const char* fmt, ...) +size_t my_b_printf(IO_CACHE *info, const char* fmt, ...) { - int result; + size_t result; va_list args; va_start(args,fmt); result=my_b_vprintf(info, fmt, args); @@ -293,9 +298,9 @@ uint my_b_printf(IO_CACHE *info, const char* fmt, ...) } -uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) +size_t my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) { - uint out_length=0; + size_t out_length= 0; uint minimum_width; /* as yet unimplemented */ uint minimum_width_sign; uint precision; /* as yet unimplemented for anything but %b */ @@ -312,19 +317,17 @@ uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) { /* Copy everything until '%' or end of string */ const char *start=fmt; - uint length; + size_t length; for (; (*fmt != '\0') && (*fmt != '%'); fmt++) ; - length= (uint) (fmt - start); + length= (size_t) (fmt - start); out_length+=length; if (my_b_write(info, start, length)) goto err; if (*fmt == '\0') /* End of format */ - { return out_length; - } /* By this point, *fmt must be a percent; Keep track of this location and @@ -339,10 +342,13 @@ uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) minimum_width_sign= 1; /* Skip if max size is used (to be compatible with printf) */ while (*fmt == '-') { fmt++; minimum_width_sign= -1; } - if (*fmt == '*') { + if (*fmt == '*') + { precision= (int) va_arg(args, int); fmt++; - } else { + } + else + { while (my_isdigit(&my_charset_latin1, *fmt)) { minimum_width=(minimum_width * 10) + (*fmt - '0'); fmt++; @@ -350,12 +356,15 @@ uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) } minimum_width*= minimum_width_sign; - if (*fmt == '.') { + if (*fmt == '.') + { fmt++; if (*fmt == '*') { precision= (int) va_arg(args, int); fmt++; - } else { + } + else + { while (my_isdigit(&my_charset_latin1, *fmt)) { precision=(precision * 10) + (*fmt - '0'); fmt++; @@ -366,7 +375,7 @@ uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) if (*fmt == 's') /* String parameter */ { reg2 char *par = va_arg(args, char *); - uint length2 = (uint) strlen(par); + size_t length2 = strlen(par); /* TODO: implement minimum width and precision */ out_length+= length2; if (my_b_write(info, par, length2)) @@ -382,14 +391,14 @@ uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) else if (*fmt == 'd' || *fmt == 'u') /* Integer parameter */ { register int iarg; - uint length2; + size_t length2; char buff[17]; iarg = va_arg(args, int); if (*fmt == 'd') - length2= (uint) (int10_to_str((long) iarg,buff, -10) - buff); + length2= (size_t) (int10_to_str((long) iarg,buff, -10) - buff); else - length2= (uint) (int10_to_str((long) (uint) iarg,buff,10)- buff); + length2= (size_t) (int10_to_str((long) (uint) iarg,buff,10)- buff); out_length+= length2; if (my_b_write(info, buff, length2)) goto err; @@ -398,14 +407,14 @@ uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) /* long parameter */ { register long iarg; - uint length2; + size_t length2; char buff[17]; iarg = va_arg(args, long); if (*++fmt == 'd') - length2= (uint) (int10_to_str(iarg,buff, -10) - buff); + length2= (size_t) (int10_to_str(iarg,buff, -10) - buff); else - length2= (uint) (int10_to_str(iarg,buff,10)- buff); + length2= (size_t) (int10_to_str(iarg,buff,10)- buff); out_length+= length2; if (my_b_write(info, buff, length2)) goto err; @@ -421,5 +430,5 @@ uint my_b_vprintf(IO_CACHE *info, const char* fmt, va_list args) return out_length; err: - return (uint) -1; + return (size_t) -1; } diff --git a/mysys/mf_keycache.c b/mysys/mf_keycache.c index 7ca07016823..4c98882ac7e 100644 --- a/mysys/mf_keycache.c +++ b/mysys/mf_keycache.c @@ -203,7 +203,7 @@ struct st_block_link struct st_hash_link *hash_link; /* backward ptr to referring hash_link */ KEYCACHE_WQUEUE wqueue[2]; /* queues on waiting requests for new/old pages */ uint requests; /* number of requests for the block */ - byte *buffer; /* buffer for the block page */ + uchar *buffer; /* buffer for the block page */ uint offset; /* beginning of modified data in the buffer */ uint length; /* end of data in the buffer */ uint status; /* state of the block */ @@ -454,11 +454,11 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, keycache->hash_link_root= (HASH_LINK*) ((char*) keycache->hash_root + ALIGN_SIZE((sizeof(HASH_LINK*) * keycache->hash_entries))); - bzero((byte*) keycache->block_root, + bzero((uchar*) keycache->block_root, keycache->disk_blocks * sizeof(BLOCK_LINK)); - bzero((byte*) keycache->hash_root, + bzero((uchar*) keycache->hash_root, keycache->hash_entries * sizeof(HASH_LINK*)); - bzero((byte*) keycache->hash_link_root, + bzero((uchar*) keycache->hash_link_root, keycache->hash_links * sizeof(HASH_LINK)); keycache->hash_links_used= 0; keycache->free_hash_list= NULL; @@ -490,9 +490,9 @@ int init_key_cache(KEY_CACHE *keycache, uint key_cache_block_size, keycache->disk_blocks, (long) keycache->block_root, keycache->hash_entries, (long) keycache->hash_root, keycache->hash_links, (long) keycache->hash_link_root)); - bzero((gptr) keycache->changed_blocks, + bzero((uchar*) keycache->changed_blocks, sizeof(keycache->changed_blocks[0]) * CHANGED_BLOCKS_HASH); - bzero((gptr) keycache->file_blocks, + bzero((uchar*) keycache->file_blocks, sizeof(keycache->file_blocks[0]) * CHANGED_BLOCKS_HASH); } else @@ -510,12 +510,12 @@ err: keycache->blocks= 0; if (keycache->block_mem) { - my_large_free((gptr) keycache->block_mem, MYF(0)); + my_large_free((uchar*) keycache->block_mem, MYF(0)); keycache->block_mem= NULL; } if (keycache->block_root) { - my_free((gptr) keycache->block_root, MYF(0)); + my_free((uchar*) keycache->block_root, MYF(0)); keycache->block_root= NULL; } my_errno= error; @@ -736,9 +736,9 @@ void end_key_cache(KEY_CACHE *keycache, my_bool cleanup) { if (keycache->block_mem) { - my_large_free((gptr) keycache->block_mem, MYF(0)); + my_large_free((uchar*) keycache->block_mem, MYF(0)); keycache->block_mem= NULL; - my_free((gptr) keycache->block_root, MYF(0)); + my_free((uchar*) keycache->block_root, MYF(0)); keycache->block_root= NULL; } keycache->disk_blocks= -1; @@ -2039,12 +2039,13 @@ restart: else { /* There are some never used blocks, take first of them */ - DBUG_ASSERT(keycache->blocks_used < (ulong) keycache->disk_blocks); + DBUG_ASSERT(keycache->blocks_used < + (ulong) keycache->disk_blocks); block= &keycache->block_root[keycache->blocks_used]; block->buffer= ADD_TO_PTR(keycache->block_mem, ((ulong) keycache->blocks_used* keycache->key_cache_block_size), - byte*); + uchar*); keycache->blocks_used++; DBUG_ASSERT(!block->next_used); } @@ -2508,15 +2509,15 @@ static void read_block(KEY_CACHE *keycache, have to be a multiple of key_cache_block_size; */ -byte *key_cache_read(KEY_CACHE *keycache, +uchar *key_cache_read(KEY_CACHE *keycache, File file, my_off_t filepos, int level, - byte *buff, uint length, + uchar *buff, uint length, uint block_length __attribute__((unused)), int return_buffer __attribute__((unused))) { my_bool locked_and_incremented= FALSE; int error=0; - byte *start= buff; + uchar *start= buff; DBUG_ENTER("key_cache_read"); DBUG_PRINT("enter", ("fd: %u pos: %lu length: %u", (uint) file, (ulong) filepos, length)); @@ -2530,12 +2531,12 @@ byte *key_cache_read(KEY_CACHE *keycache, uint status; int page_st; - /* + /* When the key cache is once initialized, we use the cache_lock to reliably distinguish the cases of normal operation, resizing, and disabled cache. We always increment and decrement 'cnt_for_resize_op' so that a resizer can wait for pending I/O. - */ + */ keycache_pthread_mutex_lock(&keycache->cache_lock); /* Cache resizing has two phases: Flushing and re-initializing. In @@ -2562,6 +2563,7 @@ byte *key_cache_read(KEY_CACHE *keycache, do { /* Cache could be disabled in a later iteration. */ + if (!keycache->can_be_used) goto no_key_cache; /* Start reading at the beginning of the cache block. */ @@ -2588,7 +2590,7 @@ byte *key_cache_read(KEY_CACHE *keycache, */ keycache->global_cache_read++; keycache_pthread_mutex_unlock(&keycache->cache_lock); - error= (my_pread(file, (byte*) buff, read_length, + error= (my_pread(file, (uchar*) buff, read_length, filepos + offset, MYF(MY_NABP)) != 0); keycache_pthread_mutex_lock(&keycache->cache_lock); goto next_block; @@ -2653,7 +2655,7 @@ byte *key_cache_read(KEY_CACHE *keycache, /* Link the block into the LRU ring if it's the last submitted request for the block. This enables eviction for the block. - */ + */ unreg_request(keycache, block, 1); if (status & BLOCK_ERROR) @@ -2667,7 +2669,7 @@ byte *key_cache_read(KEY_CACHE *keycache, if (return_buffer) DBUG_RETURN(block->buffer); #endif - next_block: + next_block: buff+= read_length; filepos+= read_length+offset; offset= 0; @@ -2681,9 +2683,10 @@ no_key_cache: keycache->global_cache_r_requests++; keycache->global_cache_read++; + if (locked_and_incremented) keycache_pthread_mutex_unlock(&keycache->cache_lock); - if (my_pread(file, (byte*) buff, length, filepos, MYF(MY_NABP))) + if (my_pread(file, (uchar*) buff, length, filepos, MYF(MY_NABP))) error= 1; if (locked_and_incremented) keycache_pthread_mutex_lock(&keycache->cache_lock); @@ -2694,7 +2697,7 @@ end: dec_counter_for_resize_op(keycache); keycache_pthread_mutex_unlock(&keycache->cache_lock); } - DBUG_RETURN(error ? (byte*) 0 : start); + DBUG_RETURN(error ? (uchar*) 0 : start); } @@ -2720,7 +2723,7 @@ end: int key_cache_insert(KEY_CACHE *keycache, File file, my_off_t filepos, int level, - byte *buff, uint length) + uchar *buff, uint length) { int error= 0; DBUG_ENTER("key_cache_insert"); @@ -2836,6 +2839,7 @@ int key_cache_insert(KEY_CACHE *keycache, DBUG_ASSERT(block->status & BLOCK_IN_USE); DBUG_ASSERT((page_st == PAGE_TO_BE_READ) || (block->status & BLOCK_READ)); + #if !defined(SERIALIZED_READ_FROM_CACHE) keycache_pthread_mutex_unlock(&keycache->cache_lock); /* @@ -2901,6 +2905,7 @@ int key_cache_insert(KEY_CACHE *keycache, DBUG_ASSERT(block->status & (BLOCK_READ | BLOCK_IN_USE)); } /* end of if (!(block->status & BLOCK_ERROR)) */ + remove_reader(block); /* @@ -2925,7 +2930,6 @@ int key_cache_insert(KEY_CACHE *keycache, dec_counter_for_resize_op(keycache); keycache_pthread_mutex_unlock(&keycache->cache_lock); } - DBUG_RETURN(error); } @@ -2961,7 +2965,7 @@ int key_cache_insert(KEY_CACHE *keycache, int key_cache_write(KEY_CACHE *keycache, File file, my_off_t filepos, int level, - byte *buff, uint length, + uchar *buff, uint length, uint block_length __attribute__((unused)), int dont_write) { @@ -3055,7 +3059,7 @@ int key_cache_write(KEY_CACHE *keycache, /* Used in the server. */ keycache->global_cache_write++; keycache_pthread_mutex_unlock(&keycache->cache_lock); - if (my_pwrite(file, (byte*) buff, read_length, filepos + offset, + if (my_pwrite(file, (uchar*) buff, read_length, filepos + offset, MYF(MY_NABP | MY_WAIT_IF_FULL))) error=1; keycache_pthread_mutex_lock(&keycache->cache_lock); @@ -3224,7 +3228,7 @@ no_key_cache: keycache->global_cache_write++; if (locked_and_incremented) keycache_pthread_mutex_unlock(&keycache->cache_lock); - if (my_pwrite(file, (byte*) buff, length, filepos, + if (my_pwrite(file, (uchar*) buff, length, filepos, MYF(MY_NABP | MY_WAIT_IF_FULL))) error=1; if (locked_and_incremented) @@ -3422,7 +3426,7 @@ static int flush_cached_blocks(KEY_CACHE *keycache, As all blocks referred in 'cache' are marked by BLOCK_IN_FLUSH we are guarunteed no thread will change them */ - qsort((byte*) cache, count, sizeof(*cache), (qsort_cmp) cmp_sec_link); + qsort((uchar*) cache, count, sizeof(*cache), (qsort_cmp) cmp_sec_link); keycache_pthread_mutex_lock(&keycache->cache_lock); /* @@ -3479,6 +3483,7 @@ static int flush_cached_blocks(KEY_CACHE *keycache, right queue anyway. */ link_to_file_list(keycache, block, file, 1); + } block->status&= ~BLOCK_IN_FLUSH; /* @@ -3509,13 +3514,12 @@ static int flush_cached_blocks(KEY_CACHE *keycache, } } /* end of for ( ; cache != end ; cache++) */ - return last_errno; } /* - Flush all key blocks for a file to disk, but don't do any mutex locks. + flush all key blocks for a file to disk, but don't do any mutex locks. SYNOPSIS flush_key_blocks_int() @@ -3680,6 +3684,7 @@ restart: { /* It's a temporary file */ DBUG_ASSERT(!(block->status & BLOCK_REASSIGNED)); + /* free_block() must not be called with BLOCK_CHANGED. Note that we must not change the BLOCK_CHANGED flag outside of @@ -3964,7 +3969,7 @@ restart: #endif err: if (cache != cache_buff) - my_free((gptr) cache, MYF(0)); + my_free((uchar*) cache, MYF(0)); if (last_errno) errno=last_errno; /* Return first error */ DBUG_RETURN(last_errno != 0); diff --git a/mysys/mf_keycaches.c b/mysys/mf_keycaches.c index 51ad54159e5..6227a05ce06 100644 --- a/mysys/mf_keycaches.c +++ b/mysys/mf_keycaches.c @@ -44,9 +44,9 @@ typedef struct st_safe_hash_entry { - byte *key; + uchar *key; uint length; - byte *data; + uchar *data; struct st_safe_hash_entry *next, **prev; } SAFE_HASH_ENTRY; @@ -57,7 +57,7 @@ typedef struct st_safe_hash_with_default rw_lock_t mutex; #endif HASH hash; - byte *default_value; + uchar *default_value; SAFE_HASH_ENTRY *root; } SAFE_HASH; @@ -71,18 +71,18 @@ typedef struct st_safe_hash_with_default static void safe_hash_entry_free(SAFE_HASH_ENTRY *entry) { DBUG_ENTER("free_assign_entry"); - my_free((gptr) entry, MYF(0)); + my_free((uchar*) entry, MYF(0)); DBUG_VOID_RETURN; } /* Get key and length for a SAFE_HASH_ENTRY */ -static byte *safe_hash_entry_get(SAFE_HASH_ENTRY *entry, uint *length, - my_bool not_used __attribute__((unused))) +static uchar *safe_hash_entry_get(SAFE_HASH_ENTRY *entry, size_t *length, + my_bool not_used __attribute__((unused))) { *length=entry->length; - return (byte*) entry->key; + return (uchar*) entry->key; } @@ -105,7 +105,7 @@ static byte *safe_hash_entry_get(SAFE_HASH_ENTRY *entry, uint *length, */ static my_bool safe_hash_init(SAFE_HASH *hash, uint elements, - byte *default_value) + uchar *default_value) { DBUG_ENTER("safe_hash"); if (hash_init(&hash->hash, &my_charset_bin, elements, @@ -147,9 +147,9 @@ static void safe_hash_free(SAFE_HASH *hash) Return the value stored for a key or default value if no key */ -static byte *safe_hash_search(SAFE_HASH *hash, const byte *key, uint length) +static uchar *safe_hash_search(SAFE_HASH *hash, const uchar *key, uint length) { - byte *result; + uchar *result; DBUG_ENTER("safe_hash_search"); rw_rdlock(&hash->mutex); result= hash_search(&hash->hash, key, length); @@ -183,8 +183,8 @@ static byte *safe_hash_search(SAFE_HASH *hash, const byte *key, uint length) 1 error (Can only be EOM). In this case my_message() is called. */ -static my_bool safe_hash_set(SAFE_HASH *hash, const byte *key, uint length, - byte *data) +static my_bool safe_hash_set(SAFE_HASH *hash, const uchar *key, uint length, + uchar *data) { SAFE_HASH_ENTRY *entry; my_bool error= 0; @@ -206,7 +206,7 @@ static my_bool safe_hash_set(SAFE_HASH *hash, const byte *key, uint length, /* unlink entry from list */ if ((*entry->prev= entry->next)) entry->next->prev= entry->prev; - hash_delete(&hash->hash, (byte*) entry); + hash_delete(&hash->hash, (uchar*) entry); goto end; } if (entry) @@ -222,7 +222,7 @@ static my_bool safe_hash_set(SAFE_HASH *hash, const byte *key, uint length, error= 1; goto end; } - entry->key= (byte*) (entry +1); + entry->key= (uchar*) (entry +1); memcpy((char*) entry->key, (char*) key, length); entry->length= length; entry->data= data; @@ -231,7 +231,7 @@ static my_bool safe_hash_set(SAFE_HASH *hash, const byte *key, uint length, entry->next->prev= &entry->next; entry->prev= &hash->root; hash->root= entry; - if (my_hash_insert(&hash->hash, (byte*) entry)) + if (my_hash_insert(&hash->hash, (uchar*) entry)) { /* This can only happen if hash got out of memory */ my_free((char*) entry, MYF(0)); @@ -261,7 +261,7 @@ end: default value. */ -static void safe_hash_change(SAFE_HASH *hash, byte *old_data, byte *new_data) +static void safe_hash_change(SAFE_HASH *hash, uchar *old_data, uchar *new_data) { SAFE_HASH_ENTRY *entry, *next; DBUG_ENTER("safe_hash_set"); @@ -277,7 +277,7 @@ static void safe_hash_change(SAFE_HASH *hash, byte *old_data, byte *new_data) { if ((*entry->prev= entry->next)) entry->next->prev= entry->prev; - hash_delete(&hash->hash, (byte*) entry); + hash_delete(&hash->hash, (uchar*) entry); } else entry->data= new_data; @@ -299,7 +299,7 @@ static SAFE_HASH key_cache_hash; my_bool multi_keycache_init(void) { - return safe_hash_init(&key_cache_hash, 16, (byte*) dflt_key_cache); + return safe_hash_init(&key_cache_hash, 16, (uchar*) dflt_key_cache); } @@ -325,7 +325,7 @@ void multi_keycache_free(void) key cache to use */ -KEY_CACHE *multi_key_cache_search(byte *key, uint length) +KEY_CACHE *multi_key_cache_search(uchar *key, uint length) { if (!key_cache_hash.hash.records) return dflt_key_cache; @@ -349,15 +349,15 @@ KEY_CACHE *multi_key_cache_search(byte *key, uint length) */ -my_bool multi_key_cache_set(const byte *key, uint length, +my_bool multi_key_cache_set(const uchar *key, uint length, KEY_CACHE *key_cache) { - return safe_hash_set(&key_cache_hash, key, length, (byte*) key_cache); + return safe_hash_set(&key_cache_hash, key, length, (uchar*) key_cache); } void multi_key_cache_change(KEY_CACHE *old_data, KEY_CACHE *new_data) { - safe_hash_change(&key_cache_hash, (byte*) old_data, (byte*) new_data); + safe_hash_change(&key_cache_hash, (uchar*) old_data, (uchar*) new_data); } diff --git a/mysys/mf_loadpath.c b/mysys/mf_loadpath.c index ffa83cb20ec..48a69207839 100644 --- a/mysys/mf_loadpath.c +++ b/mysys/mf_loadpath.c @@ -23,7 +23,7 @@ /* if there is no path, prepend with own_path_prefix if given */ /* else unpack path according to current dir */ -my_string my_load_path(my_string to, const char *path, +char * my_load_path(char * to, const char *path, const char *own_path_prefix) { char buff[FN_REFLEN]; @@ -36,7 +36,7 @@ my_string my_load_path(my_string to, const char *path, test_if_hard_path(path)) VOID(strmov(buff,path)); else if ((is_cur=(path[0] == FN_CURLIB && path[1] == FN_LIBCHAR)) || - (is_prefix((gptr) path,FN_PARENTDIR)) || + (is_prefix(path,FN_PARENTDIR)) || ! own_path_prefix) { if (is_cur) diff --git a/mysys/mf_pack.c b/mysys/mf_pack.c index 1b83c6fda10..99c0c959d94 100644 --- a/mysys/mf_pack.c +++ b/mysys/mf_pack.c @@ -24,17 +24,17 @@ #include <descrip.h> #endif /* VMS */ -static my_string NEAR_F expand_tilde(my_string *path); +static char * NEAR_F expand_tilde(char * *path); /* Pack a dirname ; Changes HOME to ~/ and current dev to ./ */ /* from is a dirname (from dirname() ?) ending with FN_LIBCHAR */ /* to may be == from */ -void pack_dirname(my_string to, const char *from) +void pack_dirname(char * to, const char *from) { int cwd_err; - uint d_length,length,buff_length; - my_string start; + size_t d_length,length,buff_length; + char * start; char buff[FN_REFLEN]; DBUG_ENTER("pack_dirname"); @@ -50,13 +50,13 @@ void pack_dirname(my_string to, const char *from) if (!(cwd_err= my_getwd(buff,FN_REFLEN,MYF(0)))) { - buff_length= (uint) strlen(buff); - d_length=(uint) (start-to); + buff_length= strlen(buff); + d_length= (size_t) (start-to); if ((start == to || (buff_length == d_length && !bcmp(buff,start,d_length))) && *start != FN_LIBCHAR && *start) { /* Put current dir before */ - bchange(to,d_length,buff,buff_length,(uint) strlen(to)+1); + bchange(to,d_length,buff,buff_length,strlen(to)+1); } } @@ -65,7 +65,7 @@ void pack_dirname(my_string to, const char *from) length=0; if (home_dir) { - length= (uint) strlen(home_dir); + length= strlen(home_dir); if (home_dir[length-1] == FN_LIBCHAR) length--; /* Don't test last '/' */ } @@ -89,7 +89,7 @@ void pack_dirname(my_string to, const char *from) } if (is_prefix(to,buff)) { - length= (uint) strlen(buff); + length= strlen(buff); if (to[length]) (void) strmov_overlapp(to,to+length); /* Remove everything before */ else @@ -126,12 +126,12 @@ void pack_dirname(my_string to, const char *from) # length of new name */ -uint cleanup_dirname(register my_string to, const char *from) +size_t cleanup_dirname(register char *to, const char *from) { - reg5 uint length; - reg2 my_string pos; - reg3 my_string from_ptr; - reg4 my_string start; + reg5 size_t length; + reg2 char * pos; + reg3 char * from_ptr; + reg4 char * start; char parent[5], /* for "FN_PARENTDIR" */ buff[FN_REFLEN+1],*end_parentdir; #ifdef BACKSLASH_MBTAIL @@ -141,17 +141,17 @@ uint cleanup_dirname(register my_string to, const char *from) DBUG_PRINT("enter",("from: '%s'",from)); start=buff; - from_ptr=(my_string) from; + from_ptr=(char *) from; #ifdef FN_DEVCHAR if ((pos=strrchr(from_ptr,FN_DEVCHAR)) != 0) { /* Skip device part */ - length=(uint) (pos-from_ptr)+1; + length=(size_t) (pos-from_ptr)+1; start=strnmov(buff,from_ptr,length); from_ptr+=length; } #endif parent[0]=FN_LIBCHAR; - length=(uint) (strmov(parent+1,FN_PARENTDIR)-parent); + length=(size_t) (strmov(parent+1,FN_PARENTDIR)-parent); for (pos=start ; (*pos= *from_ptr++) != 0 ; pos++) { #ifdef BACKSLASH_MBTAIL @@ -167,7 +167,7 @@ uint cleanup_dirname(register my_string to, const char *from) *pos = FN_LIBCHAR; if (*pos == FN_LIBCHAR) { - if ((uint) (pos-start) > length && bcmp(pos-length,parent,length) == 0) + if ((size_t) (pos-start) > length && bcmp(pos-length,parent,length) == 0) { /* If .../../; skip prev */ pos-=length; if (pos != start) @@ -206,7 +206,7 @@ uint cleanup_dirname(register my_string to, const char *from) } } } - else if ((uint) (pos-start) == length-1 && + else if ((size_t) (pos-start) == length-1 && !bcmp(start,parent+1,length-1)) start=pos; /* Starts with "../" */ else if (pos-start > 0 && pos[-1] == FN_LIBCHAR) @@ -228,7 +228,7 @@ uint cleanup_dirname(register my_string to, const char *from) } (void) strmov(to,buff); DBUG_PRINT("exit",("to: '%s'",to)); - DBUG_RETURN((uint) (pos-buff)); + DBUG_RETURN((size_t) (pos-buff)); } /* cleanup_dirname */ @@ -251,7 +251,7 @@ void symdirget(char *dir) if (dir[0] && pos[-1] != FN_DEVCHAR && my_access(dir, F_OK)) { File file; - uint length; + size_t length; char temp= *(--pos); /* May be "/" or "\" */ strmov(pos,".sym"); file= my_open(dir, O_RDONLY, MYF(0)); @@ -268,7 +268,7 @@ void symdirget(char *dir) if (pos == buff || pos[-1] != FN_LIBCHAR) *pos++=FN_LIBCHAR; - strmake(dir,buff, (uint) (pos-buff)); + strmake(dir,buff, (size_t) (pos-buff)); } my_close(file, MYF(0)); } @@ -296,14 +296,14 @@ void symdirget(char *dir) Length of new directory name (= length of to) */ -uint unpack_dirname(my_string to, const char *from) +size_t unpack_dirname(char * to, const char *from) { - uint length,h_length; + size_t length, h_length; char buff[FN_REFLEN+1+4],*suffix,*tilde_expansion; DBUG_ENTER("unpack_dirname"); - (void) intern_filename(buff,from); /* Change to intern name */ - length= (uint) strlen(buff); /* Fix that '/' is last */ + (void) intern_filename(buff,from); /* Change to intern name */ + length= strlen(buff); /* Fix that '/' is last */ if (length && #ifdef FN_DEVCHAR buff[length-1] != FN_DEVCHAR && @@ -320,8 +320,8 @@ uint unpack_dirname(my_string to, const char *from) suffix=buff+1; tilde_expansion=expand_tilde(&suffix); if (tilde_expansion) { - length-=(uint) (suffix-buff)-1; - if (length+(h_length= (uint) strlen(tilde_expansion)) <= FN_REFLEN) + length-= (size_t) (suffix-buff)-1; + if (length+(h_length= strlen(tilde_expansion)) <= FN_REFLEN) { if (tilde_expansion[h_length-1] == FN_LIBCHAR) h_length--; @@ -344,7 +344,7 @@ uint unpack_dirname(my_string to, const char *from) /* Expand tilde to home or user-directory */ /* Path is reset to point at FN_LIBCHAR after ~xxx */ -static my_string NEAR_F expand_tilde(my_string *path) +static char * NEAR_F expand_tilde(char * *path) { if (path[0][0] == FN_LIBCHAR) return home_dir; /* ~/ expanded to home */ @@ -366,7 +366,7 @@ static my_string NEAR_F expand_tilde(my_string *path) } } #endif - return (my_string) 0; + return (char *) 0; } @@ -387,13 +387,13 @@ static my_string NEAR_F expand_tilde(my_string *path) */ -uint unpack_filename(my_string to, const char *from) +size_t unpack_filename(char * to, const char *from) { - uint length,n_length; + size_t length, n_length, buff_length; char buff[FN_REFLEN]; DBUG_ENTER("unpack_filename"); - length=dirname_part(buff,from); /* copy & convert dirname */ + length=dirname_part(buff, from, &buff_length);/* copy & convert dirname */ n_length=unpack_dirname(buff,buff); if (n_length+strlen(from+length) < FN_REFLEN) { @@ -410,10 +410,10 @@ uint unpack_filename(my_string to, const char *from) /* Used before system command's like open(), create() .. */ /* Returns length of to */ -uint system_filename(my_string to, const char *from) +size_t system_filename(char * to, const char *from) { #ifndef FN_C_BEFORE_DIR - return (uint) (strmake(to,from,FN_REFLEN-1)-to); + return (size_t) (strmake(to,from,FN_REFLEN-1)-to); #else /* VMS */ /* change 'dev:lib/xxx' to 'dev:[lib]xxx' */ @@ -423,8 +423,9 @@ uint system_filename(my_string to, const char *from) /* change '/x/y/z to '[x.y]x' */ /* change 'dev:/x' to 'dev:[000000]x' */ - int libchar_found,length; - my_string to_pos,from_pos,pos; + int libchar_found; + size_t length; + char * to_pos,from_pos,pos; char buff[FN_REFLEN]; DBUG_ENTER("system_filename"); @@ -434,7 +435,7 @@ uint system_filename(my_string to, const char *from) if ((pos=strrchr(from_pos,FN_DEVCHAR))) /* Skip device part */ { pos++; - to_pos=strnmov(to,from_pos,(size_s) (pos-from_pos)); + to_pos=strnmov(to,from_pos,(size_t) (pos-from_pos)); from_pos=pos; } else @@ -465,115 +466,30 @@ uint system_filename(my_string to, const char *from) from_pos+strlen(FN_PARENTDIR) == pos) to_pos=strmov(to_pos,FN_C_PARENT_DIR); /* Found '../' */ else - to_pos=strnmov(to_pos,from_pos,(size_s) (pos-from_pos)); + to_pos=strnmov(to_pos,from_pos,(size_t) (pos-from_pos)); from_pos=pos+1; } *(to_pos++)=FN_C_AFTER_DIR; } - length=(int) (strmov(to_pos,from_pos)-to); + length= (size_t) (strmov(to_pos,from_pos)-to); DBUG_PRINT("exit",("name: '%s'",to)); - DBUG_RETURN((uint) length); + DBUG_RETURN(length); #endif } /* system_filename */ /* Fix a filename to intern (UNIX format) */ -my_string intern_filename(my_string to, const char *from) +char *intern_filename(char *to, const char *from) { -#ifndef VMS - { - uint length; - char buff[FN_REFLEN]; - if (from == to) - { /* Dirname may destroy from */ - strmov(buff,from); - from=buff; - } - length=dirname_part(to,from); /* Copy dirname & fix chars */ - (void) strcat(to,from+length); - return (to); - } -#else /* VMS */ - - /* change 'dev:[lib]xxx' to 'dev:lib/xxx' */ - /* change 'dev:xxx' to 'dev:xxx' */ - /* change 'dev:x/y/[.lib]' to 'dev:x/y/lib/ */ - /* change '[.lib]' to './lib/' */ - /* change '[x.y]' or '[x.][y]' or '[x][.y]' to '/x/y/' */ - /* change '[000000.x] or [x.000000]' to '/x/' */ - - int par_length,root_length; - my_string pos,from_pos,to_pos,end_pos; + size_t length, to_length; char buff[FN_REFLEN]; - - convert_dirname(buff,from,NullS); /* change '<>' to '[]' */ - from_pos=buff; - if ((pos=strrchr(from_pos,FN_DEVCHAR))) /* Skip device part */ - { - pos++; - to_pos=strnmov(to,from_pos,(size_s) (pos-from_pos)); - from_pos=pos; - } - else - to_pos=to; - - root_length=strlen(FN_C_ROOT_DIR); - if ((pos = strchr(from_pos,FN_C_BEFORE_DIR)) && - (end_pos = strrchr(pos+1,FN_C_AFTER_DIR))) - { - to_pos=strnmov(to_pos,from_pos,(size_s) (pos-from_pos)); - /* Copy all between ':' and '[' */ - from_pos=pos+1; - if (strinstr(from_pos,FN_C_ROOT_DIR) == 1 && - (from_pos[root_length] == FN_C_DIR_SEP || - from_pos[root_length] == FN_C_AFTER_DIR)) - { - from_pos+=root_length+1; - } - else if (*from_pos == FN_C_DIR_SEP) - *(to_pos++) = FN_CURLIB; /* Set ./ first */ - *(to_pos++) = FN_LIBCHAR; - - par_length=strlen(FN_C_PARENT_DIR); - pos=to_pos; - for (; from_pos <= end_pos ; from_pos++) - { - switch (*from_pos) { - case FN_C_DIR_SEP: - case FN_C_AFTER_DIR: - if (pos != to_pos) - { - if ((int) (to_pos-pos) == root_length && - is_suffix(pos,FN_C_ROOT_DIR)) - to_pos=pos; /* remove root-pos */ - else - { - *(to_pos++)=FN_LIBCHAR; /* Find lib */ - pos=to_pos; - } - } - break; - case FN_C_BEFORE_DIR: - break; - case '-': /* *(FN_C_PARENT_DIR): */ - if (to_pos[-1] == FN_LIBCHAR && - strncmp(from_pos,FN_C_PARENT_DIR,par_length) == 0) - { /* Change '-' to '..' */ - to_pos=strmov(to_pos,FN_PARENTDIR); - *(to_pos++)=FN_LIBCHAR; - pos=to_pos; - from_pos+=par_length-1; - break; - } - /* Fall through */ - default: - *(to_pos++)= *from_pos; - break; - } - } + if (from == to) + { /* Dirname may destroy from */ + strmov(buff,from); + from=buff; } - (void) strmov(to_pos,from_pos); + length= dirname_part(to, from, &to_length); /* Copy dirname & fix chars */ + (void) strmov(to + to_length,from+length); return (to); -#endif /* VMS */ } /* intern_filename */ diff --git a/mysys/mf_path.c b/mysys/mf_path.c index 00e6b2046b9..7baded9d715 100644 --- a/mysys/mf_path.c +++ b/mysys/mf_path.c @@ -29,16 +29,18 @@ static char *find_file_in_path(char *to,const char *name); own_path_name_part is concatinated to result. my_path puts result in to and returns to */ -my_string my_path(my_string to, const char *progname, - const char *own_pathname_part) +char * my_path(char * to, const char *progname, + const char *own_pathname_part) { - my_string start,end,prog; + char *start, *end, *prog; + size_t to_length; DBUG_ENTER("my_path"); start=to; /* Return this */ - if (progname && (dirname_part(to, progname) || + if (progname && (dirname_part(to, progname, &to_length) || find_file_in_path(to,progname) || - ((prog=getenv("_")) != 0 && dirname_part(to,prog)))) + ((prog=getenv("_")) != 0 && + dirname_part(to, prog, &to_length)))) { VOID(intern_filename(to,to)); if (!test_if_hard_path(to)) diff --git a/mysys/mf_radix.c b/mysys/mf_radix.c index 6b750181558..582ca76b8f8 100644 --- a/mysys/mf_radix.c +++ b/mysys/mf_radix.c @@ -25,7 +25,7 @@ /* Radixsort */ -void radixsort_for_str_ptr(uchar **base, uint number_of_elements, size_s size_of_element, uchar **buffer) +void radixsort_for_str_ptr(uchar **base, uint number_of_elements, size_t size_of_element, uchar **buffer) { uchar **end,**ptr,**buffer_ptr; uint32 *count_ptr,*count_end,count[256]; @@ -34,7 +34,7 @@ void radixsort_for_str_ptr(uchar **base, uint number_of_elements, size_s size_of end=base+number_of_elements; count_end=count+256; for (pass=(int) size_of_element-1 ; pass >= 0 ; pass--) { - bzero((gptr) count,sizeof(uint32)*256); + bzero((uchar*) count,sizeof(uint32)*256); for (ptr= base ; ptr < end ; ptr++) count[ptr[0][pass]]++; if (count[0] == number_of_elements) diff --git a/mysys/mf_same.c b/mysys/mf_same.c index e7cdb012c9f..6738dc8051e 100644 --- a/mysys/mf_same.c +++ b/mysys/mf_same.c @@ -25,14 +25,15 @@ Returns 'to'. */ -my_string fn_same(char *to, const char *name, int flag) +char * fn_same(char *to, const char *name, int flag) { char dev[FN_REFLEN]; const char *ext; + size_t dev_length; DBUG_ENTER("fn_same"); DBUG_PRINT("enter",("to: %s name: %s flag: %d",to,name,flag)); - if ((ext=strrchr(name+dirname_part(dev,name),FN_EXTCHAR)) == 0) + if ((ext=strrchr(name+dirname_part(dev, name, &dev_length),FN_EXTCHAR)) == 0) ext=""; DBUG_RETURN(fn_format(to,to,dev,ext,flag)); diff --git a/mysys/mf_sort.c b/mysys/mf_sort.c index e7fd6873eee..741c8f42327 100644 --- a/mysys/mf_sort.c +++ b/mysys/mf_sort.c @@ -18,7 +18,7 @@ #include "mysys_priv.h" #include <m_string.h> -void my_string_ptr_sort(void *base, uint items, size_s size) +void my_string_ptr_sort(uchar *base, uint items, size_t size) { #if INT_MAX > 65536L uchar **ptr=0; @@ -27,15 +27,15 @@ void my_string_ptr_sort(void *base, uint items, size_s size) (ptr= (uchar**) my_malloc(items*sizeof(char*),MYF(0)))) { radixsort_for_str_ptr((uchar**) base,items,size,ptr); - my_free((gptr) ptr,MYF(0)); + my_free((uchar*) ptr,MYF(0)); } else #endif { if (size && items) { - uint size_arg=size; - qsort2(base,items,sizeof(byte*),get_ptr_compare(size),(void*) &size_arg); + qsort2(base,items, sizeof(uchar*), get_ptr_compare(size), + (void*) &size); } } } diff --git a/mysys/mf_soundex.c b/mysys/mf_soundex.c index fa393d1a94a..fe30d8c81af 100644 --- a/mysys/mf_soundex.c +++ b/mysys/mf_soundex.c @@ -42,11 +42,11 @@ static char get_scode(CHARSET_INFO * cs, char **ptr,pbool remove_garbage); /* outputed string is 4 byte long */ /* out_pntr can be == in_pntr */ -void soundex(CHARSET_INFO * cs,register my_string out_pntr, my_string in_pntr, +void soundex(CHARSET_INFO * cs,register char * out_pntr, char * in_pntr, pbool remove_garbage) { char ch,last_ch; - reg3 my_string end; + reg3 char * end; register uchar *map=cs->to_upper; if (remove_garbage) diff --git a/mysys/mf_strip.c b/mysys/mf_strip.c index 712b0e1d28a..b33620b1b2d 100644 --- a/mysys/mf_strip.c +++ b/mysys/mf_strip.c @@ -18,14 +18,14 @@ #include "mysys_priv.h" /* - strip_sp(my_string str) + strip_sp(char * str) Strips end-space from string and returns new length. */ -size_s strip_sp(register my_string str) +size_t strip_sp(register char * str) { - reg2 my_string found; - reg3 my_string start; + reg2 char * found; + reg3 char * start; start=found=str; @@ -35,11 +35,11 @@ size_s strip_sp(register my_string str) { while (*++str && *str != ' ') {}; if (!*str) - return (size_s) (str-start); /* Return stringlength */ + return (size_t) (str-start); /* Return stringlength */ } found=str; while (*++str == ' ') {}; } *found= '\0'; /* Stripp at first space */ - return (size_s) (found-start); + return (size_t) (found-start); } /* strip_sp */ diff --git a/mysys/mf_tempdir.c b/mysys/mf_tempdir.c index 36eecbeac09..b2c18c74347 100644 --- a/mysys/mf_tempdir.c +++ b/mysys/mf_tempdir.c @@ -52,7 +52,7 @@ my_bool init_tmpdir(MY_TMPDIR *tmpdir, const char *pathlist) strmake(buff, pathlist, (uint) (end-pathlist)); length= cleanup_dirname(buff, buff); if (!(copy= my_strndup(buff, length, MYF(MY_WME))) || - insert_dynamic(&tmpdir->full_list, (gptr) ©)) + insert_dynamic(&tmpdir->full_list, (uchar*) ©)) DBUG_RETURN(TRUE); pathlist=end+1; } diff --git a/mysys/mf_unixpath.c b/mysys/mf_unixpath.c index 11292e231ba..75f8de14879 100644 --- a/mysys/mf_unixpath.c +++ b/mysys/mf_unixpath.c @@ -19,7 +19,7 @@ /* convert filename to unix style filename */ /* If MSDOS converts '\' to '/' */ -void to_unix_path(my_string to __attribute__((unused))) +void to_unix_path(char * to __attribute__((unused))) { #if FN_LIBCHAR != '/' { diff --git a/mysys/mf_wfile.c b/mysys/mf_wfile.c index b574d158b9e..f98d348994e 100644 --- a/mysys/mf_wfile.c +++ b/mysys/mf_wfile.c @@ -29,12 +29,12 @@ /* Store wildcard-string in a easyer format */ -WF_PACK *wf_comp(my_string str) +WF_PACK *wf_comp(char * str) { uint ant; int not_pos; - register my_string pos; - my_string buffer; + register char * pos; + char * buffer; WF_PACK *ret; DBUG_ENTER("wf_comp"); @@ -53,13 +53,13 @@ WF_PACK *wf_comp(my_string str) for (pos=str ; *pos ; pos++) ant+= test(*pos == ' ' || *pos == ','); - if ((ret= (WF_PACK*) my_malloc((uint) ant*(sizeof(my_string*)+2)+ + if ((ret= (WF_PACK*) my_malloc((uint) ant*(sizeof(char **)+2)+ sizeof(WF_PACK)+ (uint) strlen(str)+1, MYF(MY_WME))) == 0) DBUG_RETURN((WF_PACK *) NULL); - ret->wild= (my_string*) (ret+1); - buffer= (my_string) (ret->wild+ant); + ret->wild= (char **) (ret+1); + buffer= (char *) (ret->wild+ant); ant=0; for (pos=str ; *pos ; str= pos) @@ -119,6 +119,6 @@ void wf_end(WF_PACK *buffer) { DBUG_ENTER("wf_end"); if (buffer) - my_free((gptr) buffer,MYF(0)); + my_free((uchar*) buffer,MYF(0)); DBUG_VOID_RETURN; } /* wf_end */ diff --git a/mysys/mulalloc.c b/mysys/mulalloc.c index bada0a55a6a..f4ca3d9f9ab 100644 --- a/mysys/mulalloc.c +++ b/mysys/mulalloc.c @@ -31,11 +31,11 @@ NULL */ -gptr my_multi_malloc(myf myFlags, ...) +void* my_multi_malloc(myf myFlags, ...) { va_list args; char **ptr,*start,*res; - uint tot_length,length; + size_t tot_length,length; DBUG_ENTER("my_multi_malloc"); va_start(args,myFlags); @@ -59,5 +59,5 @@ gptr my_multi_malloc(myf myFlags, ...) res+=ALIGN_SIZE(length); } va_end(args); - DBUG_RETURN((gptr) start); + DBUG_RETURN((void*) start); } diff --git a/mysys/my_alloc.c b/mysys/my_alloc.c index b4ebaeba647..9203ce9c34e 100644 --- a/mysys/my_alloc.c +++ b/mysys/my_alloc.c @@ -43,8 +43,8 @@ reported as error in first alloc_root() on this memory root. */ -void init_alloc_root(MEM_ROOT *mem_root, uint block_size, - uint pre_alloc_size __attribute__((unused))) +void init_alloc_root(MEM_ROOT *mem_root, size_t block_size, + size_t pre_alloc_size __attribute__((unused))) { DBUG_ENTER("init_alloc_root"); DBUG_PRINT("enter",("root: 0x%lx", (long) mem_root)); @@ -90,8 +90,8 @@ void init_alloc_root(MEM_ROOT *mem_root, uint block_size, before allocation. */ -void reset_root_defaults(MEM_ROOT *mem_root, uint block_size, - uint pre_alloc_size __attribute__((unused))) +void reset_root_defaults(MEM_ROOT *mem_root, size_t block_size, + size_t pre_alloc_size __attribute__((unused))) { DBUG_ASSERT(alloc_root_inited(mem_root)); @@ -99,7 +99,7 @@ void reset_root_defaults(MEM_ROOT *mem_root, uint block_size, #if !(defined(HAVE_purify) && defined(EXTRA_DEBUG)) if (pre_alloc_size) { - uint size= pre_alloc_size + ALIGN_SIZE(sizeof(USED_MEM)); + size_t size= pre_alloc_size + ALIGN_SIZE(sizeof(USED_MEM)); if (!mem_root->pre_alloc || mem_root->pre_alloc->size != size) { USED_MEM *mem, **prev= &mem_root->free; @@ -120,7 +120,7 @@ void reset_root_defaults(MEM_ROOT *mem_root, uint block_size, { /* remove block from the list and free it */ *prev= mem->next; - my_free((gptr) mem, MYF(0)); + my_free(mem, MYF(0)); } else prev= &mem->next; @@ -145,7 +145,7 @@ void reset_root_defaults(MEM_ROOT *mem_root, uint block_size, } -gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size) +void *alloc_root(MEM_ROOT *mem_root, size_t length) { #if defined(HAVE_purify) && defined(EXTRA_DEBUG) reg1 USED_MEM *next; @@ -154,32 +154,32 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size) DBUG_ASSERT(alloc_root_inited(mem_root)); - Size+=ALIGN_SIZE(sizeof(USED_MEM)); - if (!(next = (USED_MEM*) my_malloc(Size,MYF(MY_WME)))) + length+=ALIGN_SIZE(sizeof(USED_MEM)); + if (!(next = (USED_MEM*) my_malloc(length,MYF(MY_WME)))) { if (mem_root->error_handler) (*mem_root->error_handler)(); - DBUG_RETURN((gptr) 0); /* purecov: inspected */ + DBUG_RETURN((uchar*) 0); /* purecov: inspected */ } next->next= mem_root->used; - next->size= Size; + next->size= length; mem_root->used= next; DBUG_PRINT("exit",("ptr: 0x%lx", (long) (((char*) next)+ ALIGN_SIZE(sizeof(USED_MEM))))); - DBUG_RETURN((gptr) (((char*) next)+ALIGN_SIZE(sizeof(USED_MEM)))); + DBUG_RETURN((uchar*) (((char*) next)+ALIGN_SIZE(sizeof(USED_MEM)))); #else - uint get_size, block_size; - gptr point; + size_t get_size, block_size; + uchar* point; reg1 USED_MEM *next= 0; reg2 USED_MEM **prev; DBUG_ENTER("alloc_root"); DBUG_PRINT("enter",("root: 0x%lx", (long) mem_root)); DBUG_ASSERT(alloc_root_inited(mem_root)); - Size= ALIGN_SIZE(Size); + length= ALIGN_SIZE(length); if ((*(prev= &mem_root->free)) != NULL) { - if ((*prev)->left < Size && + if ((*prev)->left < length && mem_root->first_block_usage++ >= ALLOC_MAX_BLOCK_USAGE_BEFORE_DROP && (*prev)->left < ALLOC_MAX_BLOCK_TO_DROP) { @@ -189,20 +189,20 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size) mem_root->used= next; mem_root->first_block_usage= 0; } - for (next= *prev ; next && next->left < Size ; next= next->next) + for (next= *prev ; next && next->left < length ; next= next->next) prev= &next->next; } if (! next) { /* Time to alloc new block */ block_size= mem_root->block_size * (mem_root->block_num >> 2); - get_size= Size+ALIGN_SIZE(sizeof(USED_MEM)); + get_size= length+ALIGN_SIZE(sizeof(USED_MEM)); get_size= max(get_size, block_size); if (!(next = (USED_MEM*) my_malloc(get_size,MYF(MY_WME)))) { if (mem_root->error_handler) (*mem_root->error_handler)(); - return((gptr) 0); /* purecov: inspected */ + return((void*) 0); /* purecov: inspected */ } mem_root->block_num++; next->next= *prev; @@ -211,9 +211,9 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size) *prev=next; } - point= (gptr) ((char*) next+ (next->size-next->left)); + point= (uchar*) ((char*) next+ (next->size-next->left)); /*TODO: next part may be unneded due to mem_root->first_block_usage counter*/ - if ((next->left-= Size) < mem_root->min_malloc) + if ((next->left-= length) < mem_root->min_malloc) { /* Full block */ *prev= next->next; /* Remove block from list */ next->next= mem_root->used; @@ -221,7 +221,7 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size) mem_root->first_block_usage= 0; } DBUG_PRINT("exit",("ptr: 0x%lx", (ulong) point)); - DBUG_RETURN(point); + DBUG_RETURN((void*) point); #endif } @@ -245,11 +245,11 @@ gptr alloc_root(MEM_ROOT *mem_root,unsigned int Size) in case of success or NULL if out of memory. */ -gptr multi_alloc_root(MEM_ROOT *root, ...) +void *multi_alloc_root(MEM_ROOT *root, ...) { va_list args; char **ptr, *start, *res; - uint tot_length, length; + size_t tot_length, length; DBUG_ENTER("multi_alloc_root"); va_start(args, root); @@ -273,7 +273,7 @@ gptr multi_alloc_root(MEM_ROOT *root, ...) res+= ALIGN_SIZE(length); } va_end(args); - DBUG_RETURN((gptr) start); + DBUG_RETURN((void*) start); } #define TRASH_MEM(X) TRASH(((char*)(X) + ((X)->size-(X)->left)), (X)->left) @@ -346,13 +346,13 @@ void free_root(MEM_ROOT *root, myf MyFlags) { old=next; next= next->next ; if (old != root->pre_alloc) - my_free((gptr) old,MYF(0)); + my_free(old,MYF(0)); } for (next=root->free ; next ;) { old=next; next= next->next; if (old != root->pre_alloc) - my_free((gptr) old,MYF(0)); + my_free(old,MYF(0)); } root->used=root->free=0; if (root->pre_alloc) @@ -393,13 +393,13 @@ void set_prealloc_root(MEM_ROOT *root, char *ptr) } -char *strdup_root(MEM_ROOT *root,const char *str) +char *strdup_root(MEM_ROOT *root, const char *str) { - return strmake_root(root, str, (uint) strlen(str)); + return strmake_root(root, str, strlen(str)); } -char *strmake_root(MEM_ROOT *root,const char *str, uint len) +char *strmake_root(MEM_ROOT *root, const char *str, size_t len) { char *pos; if ((pos=alloc_root(root,len+1))) @@ -411,7 +411,7 @@ char *strmake_root(MEM_ROOT *root,const char *str, uint len) } -char *memdup_root(MEM_ROOT *root,const char *str,uint len) +void *memdup_root(MEM_ROOT *root, const void *str, size_t len) { char *pos; if ((pos=alloc_root(root,len))) diff --git a/mysys/my_chsize.c b/mysys/my_chsize.c index a5dd1564692..b1dbb22c687 100644 --- a/mysys/my_chsize.c +++ b/mysys/my_chsize.c @@ -40,12 +40,12 @@ int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags) { my_off_t oldsize; - char buff[IO_SIZE]; + uchar buff[IO_SIZE]; DBUG_ENTER("my_chsize"); DBUG_PRINT("my",("fd: %d length: %lu MyFlags: %d",fd,(ulong) newlength, MyFlags)); - if ((oldsize = my_seek(fd, 0L, MY_SEEK_END, MYF(MY_WME+MY_FAE))) == newlength) + if ((oldsize= my_seek(fd, 0L, MY_SEEK_END, MYF(MY_WME+MY_FAE))) == newlength) DBUG_RETURN(0); DBUG_PRINT("info",("old_size: %ld", (ulong) oldsize)); @@ -98,11 +98,11 @@ int my_chsize(File fd, my_off_t newlength, int filler, myf MyFlags) bfill(buff, IO_SIZE, filler); while (newlength-oldsize > IO_SIZE) { - if (my_write(fd,(byte*) buff,IO_SIZE,MYF(MY_NABP))) + if (my_write(fd, buff, IO_SIZE, MYF(MY_NABP))) goto err; oldsize+= IO_SIZE; } - if (my_write(fd,(byte*) buff,(uint) (newlength-oldsize),MYF(MY_NABP))) + if (my_write(fd,buff,(size_t) (newlength-oldsize), MYF(MY_NABP))) goto err; DBUG_RETURN(0); diff --git a/mysys/my_compress.c b/mysys/my_compress.c index 45e60552592..d495a1c1c6d 100644 --- a/mysys/my_compress.c +++ b/mysys/my_compress.c @@ -24,12 +24,20 @@ #include <zlib.h> /* -** This replaces the packet with a compressed packet -** Returns 1 on error -** *complen is 0 if the packet wasn't compressed + This replaces the packet with a compressed packet + + SYNOPSIS + my_compress() + packet Data to compress. This is is replaced with the compressed data. + len Length of data to compress at 'packet' + complen out: 0 if packet was not compressed + + RETURN + 1 error. 'len' is not changed' + 0 ok. In this case 'len' contains the size of the compressed packet */ -my_bool my_compress(byte *packet, ulong *len, ulong *complen) +my_bool my_compress(uchar *packet, size_t *len, size_t *complen) { DBUG_ENTER("my_compress"); if (*len < MIN_COMPRESS_LENGTH) @@ -39,27 +47,36 @@ my_bool my_compress(byte *packet, ulong *len, ulong *complen) } else { - byte *compbuf=my_compress_alloc(packet,len,complen); + uchar *compbuf=my_compress_alloc(packet,len,complen); if (!compbuf) DBUG_RETURN(*complen ? 0 : 1); memcpy(packet,compbuf,*len); - my_free(compbuf,MYF(MY_WME)); } + my_free(compbuf,MYF(MY_WME)); + } DBUG_RETURN(0); } -byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen) +uchar *my_compress_alloc(const uchar *packet, size_t *len, size_t *complen) { - byte *compbuf; + uchar *compbuf; + uLongf tmp_complen; + int res; *complen= *len * 120 / 100 + 12; - if (!(compbuf= (byte *) my_malloc(*complen,MYF(MY_WME)))) + + if (!(compbuf= (uchar *) my_malloc(*complen, MYF(MY_WME)))) return 0; /* Not enough memory */ - if (compress((Bytef*) compbuf,(ulong *) complen, (Bytef*) packet, - (uLong) *len ) != Z_OK) + + tmp_complen= *complen; + res= compress((Bytef*) compbuf, &tmp_complen, (Bytef*) packet, (uLong) *len); + *complen= tmp_complen; + + if (res != Z_OK) { - my_free(compbuf,MYF(MY_WME)); + my_free(compbuf, MYF(MY_WME)); return 0; } + if (*complen >= *len) { *complen= 0; @@ -67,50 +84,68 @@ byte *my_compress_alloc(const byte *packet, ulong *len, ulong *complen) DBUG_PRINT("note",("Packet got longer on compression; Not compressed")); return 0; } - swap_variables(ulong, *len, *complen); /* *len is now packet length */ + /* Store length of compressed packet in *len */ + swap_variables(size_t, *len, *complen); return compbuf; } -my_bool my_uncompress (byte *packet, ulong *len, ulong *complen) +/* + Uncompress packet + + SYNOPSIS + my_uncompress() + packet Compressed data. This is is replaced with the orignal data. + len Length of compressed data + complen Length of the packet buffer (must be enough for the original + data) + + RETURN + 1 error + 0 ok. In this case 'complen' contains the updated size of the + real data. +*/ + +my_bool my_uncompress(uchar *packet, size_t len, size_t *complen) { + uLongf tmp_complen; DBUG_ENTER("my_uncompress"); + if (*complen) /* If compressed */ { - byte *compbuf= (byte *) my_malloc(*complen,MYF(MY_WME)); + uchar *compbuf= (uchar *) my_malloc(*complen,MYF(MY_WME)); int error; if (!compbuf) DBUG_RETURN(1); /* Not enough memory */ - if ((error=uncompress((Bytef*) compbuf, complen, (Bytef*) packet, *len)) - != Z_OK) + + tmp_complen= *complen; + error= uncompress((Bytef*) compbuf, &tmp_complen, (Bytef*) packet, + (uLong) len); + *complen= tmp_complen; + if (error != Z_OK) { /* Probably wrong packet */ DBUG_PRINT("error",("Can't uncompress packet, error: %d",error)); my_free(compbuf, MYF(MY_WME)); DBUG_RETURN(1); } - *len= *complen; - memcpy(packet, compbuf, *len); + memcpy(packet, compbuf, *complen); my_free(compbuf, MYF(MY_WME)); } + else + *complen= len; DBUG_RETURN(0); } /* - Internal representation of the frm blob + Internal representation of the frm blob is: + + ver 4 bytes + orglen 4 bytes + complen 4 bytes */ -struct frm_blob_header -{ - uint ver; /* Version of header */ - uint orglen; /* Original length of compressed data */ - uint complen; /* Compressed length of data, 0=uncompressed */ -}; +#define BLOB_HEADER 12 -struct frm_blob_struct -{ - struct frm_blob_header head; - char data[1]; -}; /* packfrm is a method used to compress the frm file for storage in a @@ -129,43 +164,42 @@ struct frm_blob_struct >0 Failure */ -int packfrm(const void *data, uint len, - const void **pack_data, uint *pack_len) +int packfrm(const uchar *data, size_t len, + uchar **pack_data, size_t *pack_len) { int error; - ulong org_len, comp_len; - uint blob_len; - struct frm_blob_struct *blob; + size_t org_len, comp_len, blob_len; + uchar *blob; DBUG_ENTER("packfrm"); - DBUG_PRINT("enter", ("data: 0x%lx, len: %d", (long) data, len)); + DBUG_PRINT("enter", ("data: 0x%lx len: %lu", (long) data, (ulong) len)); error= 1; org_len= len; - if (my_compress((byte*)data, &org_len, &comp_len)) + if (my_compress((uchar*)data, &org_len, &comp_len)) goto err; DBUG_PRINT("info", ("org_len: %lu comp_len: %lu", org_len, comp_len)); DBUG_DUMP("compressed", (char*)data, org_len); error= 2; - blob_len= sizeof(struct frm_blob_header)+org_len; - if (!(blob= (struct frm_blob_struct*) my_malloc(blob_len,MYF(MY_WME)))) + blob_len= BLOB_HEADER + org_len; + if (!(blob= (uchar*) my_malloc(blob_len,MYF(MY_WME)))) goto err; /* Store compressed blob in machine independent format */ - int4store((char*)(&blob->head.ver), 1); - int4store((char*)(&blob->head.orglen), comp_len); - int4store((char*)(&blob->head.complen), org_len); + int4store(blob, 1); + int4store(blob+4, (uint32) len); + int4store(blob+8, (uint32) org_len); /* compressed length */ /* Copy frm data into blob, already in machine independent format */ - memcpy(blob->data, data, org_len); + memcpy(blob+BLOB_HEADER, data, org_len); *pack_data= blob; - *pack_len= blob_len; + *pack_len= blob_len; error= 0; - DBUG_PRINT("exit", ("pack_data: 0x%lx pack_len: %d", - (long) *pack_data, *pack_len)); + DBUG_PRINT("exit", ("pack_data: 0x%lx pack_len: %lu", + (long) *pack_data, (ulong) *pack_len)); err: DBUG_RETURN(error); @@ -187,40 +221,40 @@ err: >0 Failure */ -int unpackfrm(const void **unpack_data, uint *unpack_len, - const void *pack_data) +int unpackfrm(uchar **unpack_data, size_t *unpack_len, + const uchar *pack_data) { - const struct frm_blob_struct *blob= (struct frm_blob_struct*)pack_data; - byte *data; - ulong complen, orglen, ver; + uchar *data; + size_t complen, orglen; + ulong ver; DBUG_ENTER("unpackfrm"); DBUG_PRINT("enter", ("pack_data: 0x%lx", (long) pack_data)); - complen= uint4korr((char*)&blob->head.complen); - orglen= uint4korr((char*)&blob->head.orglen); - ver= uint4korr((char*)&blob->head.ver); + ver= uint4korr(pack_data); + orglen= uint4korr(pack_data+4); + complen= uint4korr(pack_data+8); DBUG_PRINT("blob",("ver: %lu complen: %lu orglen: %lu", - ver,complen,orglen)); - DBUG_DUMP("blob->data", (char*) blob->data, complen); + ver, complen, orglen)); + DBUG_DUMP("blob->data", pack_data + BLOB_HEADER, complen); if (ver != 1) DBUG_RETURN(1); if (!(data= my_malloc(max(orglen, complen), MYF(MY_WME)))) DBUG_RETURN(2); - memcpy(data, blob->data, complen); - + memcpy(data, pack_data + BLOB_HEADER, complen); - if (my_uncompress(data, &complen, &orglen)) + if (my_uncompress(data, complen, &orglen)) { - my_free((char*)data, MYF(0)); + my_free(data, MYF(0)); DBUG_RETURN(3); } *unpack_data= data; - *unpack_len= complen; + *unpack_len= orglen; - DBUG_PRINT("exit", ("frmdata: 0x%lx len: %d", (long) *unpack_data, *unpack_len)); + DBUG_PRINT("exit", ("frmdata: 0x%lx len: %lu", (long) *unpack_data, + (ulong) *unpack_len)); DBUG_RETURN(0); } #endif /* HAVE_COMPRESS */ diff --git a/mysys/my_conio.c b/mysys/my_conio.c index 23b0c55e7a9..1ea1f7a820a 100644 --- a/mysys/my_conio.c +++ b/mysys/my_conio.c @@ -29,10 +29,10 @@ static HANDLE my_coninpfh= 0; /* console input */ if found useful they are to be exported in mysys */ + /* int my_pthread_auto_mutex_lock(HANDLE* ph, const char* name, int id, int time) - NOTES creates a mutex with given name and tries to lock it time msec. mutex name is appended with id to allow system wide or process wide @@ -41,8 +41,8 @@ static HANDLE my_coninpfh= 0; /* console input */ RETURN 0 thread owns mutex <>0 error - */ + static int my_pthread_auto_mutex_lock(HANDLE* ph, const char* name, int id, int time) { @@ -69,7 +69,6 @@ int my_pthread_auto_mutex_lock(HANDLE* ph, const char* name, int id, int time) /* int my_pthread_auto_mutex_free(HANDLE* ph) - NOTES releases a mutex. @@ -103,7 +102,7 @@ int my_pthread_auto_mutex_free(HANDLE* ph) /* - char* my_cgets(char *string, unsigned long clen, unsigned long* plen) + char* my_cgets() NOTES Replaces _cgets from libc to support input of more than 255 chars. @@ -121,10 +120,12 @@ int my_pthread_auto_mutex_free(HANDLE* ph) NULL Error */ -char* my_cgets(char *buffer, unsigned long clen, unsigned long* plen) + +char* my_cgets(char *buffer, size_t clen, size_t* plen) { ULONG state; char *result; + DWORD plen_res; CONSOLE_SCREEN_BUFFER_INFO csbi; pthread_auto_mutex_decl(my_conio_cs); @@ -170,8 +171,9 @@ char* my_cgets(char *buffer, unsigned long clen, unsigned long* plen) clen= min(clen, 65535); do { - clen= min(clen, (unsigned long)csbi.dwSize.X*csbi.dwSize.Y); - if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, clen - 1, plen, NULL)) + clen= min(clen, (size_t) csbi.dwSize.X*csbi.dwSize.Y); + if (!ReadConsole((HANDLE)my_coninpfh, (LPVOID)buffer, clen - 1, &plen_res, + NULL)) { result= NULL; clen>>= 1; @@ -183,7 +185,7 @@ char* my_cgets(char *buffer, unsigned long clen, unsigned long* plen) } } while (GetLastError() == ERROR_NOT_ENOUGH_MEMORY); - + *plen= plen_res; if (result != NULL) { diff --git a/mysys/my_create.c b/mysys/my_create.c index 5639459f5a9..55878318ead 100644 --- a/mysys/my_create.c +++ b/mysys/my_create.c @@ -40,13 +40,13 @@ File my_create(const char *FileName, int CreateFlags, int access_flags, FileName, CreateFlags, access_flags, MyFlags)); #if !defined(NO_OPEN_3) - fd = open((my_string) FileName, access_flags | O_CREAT, + fd = open((char *) FileName, access_flags | O_CREAT, CreateFlags ? CreateFlags : my_umask); #elif defined(VMS) - fd = open((my_string) FileName, access_flags | O_CREAT, 0, + fd = open((char *) FileName, access_flags | O_CREAT, 0, "ctx=stm","ctx=bin"); #elif defined(__WIN__) - fd= my_sopen((my_string) FileName, access_flags | O_CREAT | O_BINARY, + fd= my_sopen((char *) FileName, access_flags | O_CREAT | O_BINARY, SH_DENYNO, MY_S_IREAD | MY_S_IWRITE); #else fd = open(FileName, access_flags); diff --git a/mysys/my_div.c b/mysys/my_div.c index 656c6cfde91..d29d3668852 100644 --- a/mysys/my_div.c +++ b/mysys/my_div.c @@ -23,7 +23,7 @@ fd File descriptor */ -my_string my_filename(File fd) +char * my_filename(File fd) { DBUG_ENTER("my_filename"); if ((uint) fd >= (uint) my_file_limit) diff --git a/mysys/my_error.c b/mysys/my_error.c index 48392fe84c3..e8fd8b938ee 100644 --- a/mysys/my_error.c +++ b/mysys/my_error.c @@ -191,7 +191,7 @@ int my_error_register(const char **errmsgs, int first, int last) /* Error numbers must be unique. No overlapping is allowed. */ if (*search_meh_pp && ((*search_meh_pp)->meh_first <= last)) { - my_free((gptr)meh_p, MYF(0)); + my_free((uchar*)meh_p, MYF(0)); return 1; } @@ -247,7 +247,7 @@ const char **my_error_unregister(int first, int last) /* Save the return value and free the header. */ errmsgs= meh_p->meh_errmsgs; - my_free((gptr) meh_p, MYF(0)); + my_free((uchar*) meh_p, MYF(0)); return errmsgs; } @@ -259,7 +259,7 @@ void my_error_unregister_all(void) for (list= my_errmsgs_globerrs.meh_next; list; list= next) { next= list->meh_next; - my_free((gptr) list, MYF(0)); + my_free((uchar*) list, MYF(0)); } my_errmsgs_list= &my_errmsgs_globerrs; } diff --git a/mysys/my_fopen.c b/mysys/my_fopen.c index b56be263ba4..09f710c1ef4 100644 --- a/mysys/my_fopen.c +++ b/mysys/my_fopen.c @@ -18,7 +18,7 @@ #include <errno.h> #include "mysys_err.h" -static void make_ftype(my_string to,int flag); +static void make_ftype(char * to,int flag); /* Open a file as stream @@ -192,7 +192,7 @@ FILE *my_fdopen(File Filedes, const char *name, int Flags, myf MyFlags) a+ == O_RDWR|O_APPEND|O_CREAT */ -static void make_ftype(register my_string to, register int flag) +static void make_ftype(register char * to, register int flag) { /* check some possible invalid combinations */ DBUG_ASSERT((flag & (O_TRUNC | O_APPEND)) != (O_TRUNC | O_APPEND)); diff --git a/mysys/my_fstream.c b/mysys/my_fstream.c index ea30509ca8c..f5fe862937c 100644 --- a/mysys/my_fstream.c +++ b/mysys/my_fstream.c @@ -27,24 +27,31 @@ #define fseek(A,B,C) fseeko((A),(B),(C)) #endif - /* Read a chunk of bytes from a file */ - /* Returns (uint) -1 if error as my_read() */ - -uint my_fread(FILE *stream, byte *Buffer, uint Count, myf MyFlags) - /* File descriptor */ - /* Buffer must be at least count bytes */ - /* Max number of bytes returnd */ - /* Flags on what to do on error */ +/* + Read a chunk of bytes from a FILE + + SYNOPSIS + my_fread() + stream File descriptor + Buffer Buffer to read to + Count Number of bytes to read + MyFlags Flags on what to do on error + + RETURN + (size_t) -1 Error + # Number of bytes read + */ + +size_t my_fread(FILE *stream, uchar *Buffer, size_t Count, myf MyFlags) { - uint readbytes; + size_t readbytes; DBUG_ENTER("my_fread"); DBUG_PRINT("my",("stream: 0x%lx Buffer: 0x%lx Count: %u MyFlags: %d", - (long) stream, (long) Buffer, Count, MyFlags)); + (long) stream, (long) Buffer, (uint) Count, MyFlags)); - if ((readbytes = (uint) fread(Buffer,sizeof(char),(size_t) Count,stream)) - != Count) + if ((readbytes= fread(Buffer, sizeof(char), Count, stream)) != Count) { - DBUG_PRINT("error",("Read only %d bytes",readbytes)); + DBUG_PRINT("error",("Read only %d bytes", (int) readbytes)); if (MyFlags & (MY_WME | MY_FAE | MY_FNABP)) { if (ferror(stream)) @@ -57,7 +64,7 @@ uint my_fread(FILE *stream, byte *Buffer, uint Count, myf MyFlags) } my_errno=errno ? errno : -1; if (ferror(stream) || MyFlags & (MY_NABP | MY_FNABP)) - DBUG_RETURN((uint) -1); /* Return with error */ + DBUG_RETURN((size_t) -1); /* Return with error */ } if (MyFlags & (MY_NABP | MY_FNABP)) DBUG_RETURN(0); /* Read ok */ @@ -66,40 +73,48 @@ uint my_fread(FILE *stream, byte *Buffer, uint Count, myf MyFlags) /* -** Write a chunk of bytes to a stream -** Returns (uint) -1 if error as my_write() -** Does retries if interrupted + Write a chunk of bytes to a stream + + my_fwrite() + stream File descriptor + Buffer Buffer to write from + Count Number of bytes to write + MyFlags Flags on what to do on error + + RETURN + (size_t) -1 Error + # Number of bytes written */ -uint my_fwrite(FILE *stream, const byte *Buffer, uint Count, myf MyFlags) +size_t my_fwrite(FILE *stream, const uchar *Buffer, size_t Count, myf MyFlags) { - uint writenbytes=0; - off_t seekptr; + size_t writtenbytes =0; + my_off_t seekptr; #if !defined(NO_BACKGROUND) && defined(USE_MY_STREAM) uint errors; #endif DBUG_ENTER("my_fwrite"); DBUG_PRINT("my",("stream: 0x%lx Buffer: 0x%lx Count: %u MyFlags: %d", - (long) stream, (long) Buffer, Count, MyFlags)); + (long) stream, (long) Buffer, (uint) Count, MyFlags)); #if !defined(NO_BACKGROUND) && defined(USE_MY_STREAM) errors=0; #endif - seekptr=ftell(stream); + seekptr= ftell(stream); for (;;) { - uint writen; - if ((writen = (uint) fwrite((char*) Buffer,sizeof(char), - (size_t) Count, stream)) != Count) + size_t written; + if ((written = (size_t) fwrite((char*) Buffer,sizeof(char), + Count, stream)) != Count) { - DBUG_PRINT("error",("Write only %d bytes",writenbytes)); + DBUG_PRINT("error",("Write only %d bytes", (int) writtenbytes)); my_errno=errno; - if (writen != (uint) -1) + if (written != (size_t) -1) { - seekptr+=writen; - Buffer+=writen; - writenbytes+=writen; - Count-=writen; + seekptr+=written; + Buffer+=written; + writtenbytes+=written; + Count-=written; } #ifdef EINTR if (errno == EINTR) @@ -131,21 +146,21 @@ uint my_fwrite(FILE *stream, const byte *Buffer, uint Count, myf MyFlags) my_error(EE_WRITE, MYF(ME_BELL+ME_WAITTANG), my_filename(fileno(stream)),errno); } - writenbytes=(uint) -1; /* Return that we got error */ + writtenbytes= (size_t) -1; /* Return that we got error */ break; } } if (MyFlags & (MY_NABP | MY_FNABP)) - writenbytes=0; /* Everything OK */ + writtenbytes= 0; /* Everything OK */ else - writenbytes+=writen; + writtenbytes+= written; break; } - DBUG_RETURN(writenbytes); + DBUG_RETURN(writtenbytes); } /* my_fwrite */ - /* Seek to position in file */ - /* ARGSUSED */ + +/* Seek to position in file */ my_off_t my_fseek(FILE *stream, my_off_t pos, int whence, myf MyFlags __attribute__((unused))) @@ -158,8 +173,7 @@ my_off_t my_fseek(FILE *stream, my_off_t pos, int whence, } /* my_seek */ - /* Tell current position of file */ - /* ARGSUSED */ +/* Tell current position of file */ my_off_t my_ftell(FILE *stream, myf MyFlags __attribute__((unused))) { diff --git a/mysys/my_getopt.c b/mysys/my_getopt.c index a23e84ab96a..32a5452e451 100644 --- a/mysys/my_getopt.c +++ b/mysys/my_getopt.c @@ -33,7 +33,7 @@ static longlong getopt_ll(char *arg, const struct my_option *optp, int *err); static ulonglong getopt_ull(char *arg, const struct my_option *optp, int *err); static void init_variables(const struct my_option *options); -static int setval(const struct my_option *opts, gptr *value, char *argument, +static int setval(const struct my_option *opts, uchar* *value, char *argument, my_bool set_maximum_value); static char *check_struct_option(char *cur_arg, char *key_name); @@ -89,15 +89,15 @@ static void default_reporter(enum loglevel level, one. Call function 'get_one_option()' once for each option. */ -static gptr* (*getopt_get_addr)(const char *, uint, const struct my_option *); +static uchar** (*getopt_get_addr)(const char *, uint, const struct my_option *); -void my_getopt_register_get_addr(gptr* (*func_addr)(const char *, uint, +void my_getopt_register_get_addr(uchar** (*func_addr)(const char *, uint, const struct my_option *)) { getopt_get_addr= func_addr; } -int handle_options(int *argc, char ***argv, +int handle_options(int *argc, char ***argv, const struct my_option *longopts, my_get_one_option get_one_option) { @@ -107,7 +107,7 @@ int handle_options(int *argc, char ***argv, char **pos, **pos_end, *optend, *prev_found, *opt_str, key_name[FN_REFLEN]; const struct my_option *optp; - gptr *value; + uchar* *value; int error, i; LINT_INIT(opt_found); @@ -580,14 +580,14 @@ static char *check_struct_option(char *cur_arg, char *key_name) Will set the option value to given value */ -static int setval(const struct my_option *opts, gptr *value, char *argument, +static int setval(const struct my_option *opts, uchar* *value, char *argument, my_bool set_maximum_value) { int err= 0; if (value && argument) { - gptr *result_pos= ((set_maximum_value) ? + uchar* *result_pos= ((set_maximum_value) ? opts->u_max_value : value); if (!result_pos) @@ -810,7 +810,7 @@ ulonglong getopt_ull_limit_value(ulonglong num, const struct my_option *optp) value Pointer to variable */ -static void init_one_value(const struct my_option *option, gptr *variable, +static void init_one_value(const struct my_option *option, uchar* *variable, longlong value) { DBUG_ENTER("init_one_value"); @@ -886,7 +886,7 @@ static void init_variables(const struct my_option *options) DBUG_ENTER("init_variables"); for (; options->name; options++) { - gptr *variable; + uchar* *variable; DBUG_PRINT("options", ("name: '%s'", options->name)); /* We must set u_max_value first as for some variables @@ -1001,7 +1001,7 @@ void my_print_variables(const struct my_option *options) printf("--------------------------------- -----------------------------\n"); for (optp= options; optp->id; optp++) { - gptr *value= (optp->var_type & GET_ASK_ADDR ? + uchar* *value= (optp->var_type & GET_ASK_ADDR ? (*getopt_get_addr)("", 0, optp) : optp->value); if (value) { diff --git a/mysys/my_getwd.c b/mysys/my_getwd.c index c258db8b126..cbfebcf2374 100644 --- a/mysys/my_getwd.c +++ b/mysys/my_getwd.c @@ -27,16 +27,28 @@ #include <direct.h> #endif - /* Gets current working directory in buff. Directory is allways ended - with FN_LIBCHAR */ - /* One must pass a buffer to my_getwd. One can allways use - curr_dir[] */ +/* Gets current working directory in buff. -int my_getwd(my_string buf, uint size, myf MyFlags) + SYNPOSIS + my_getwd() + buf Buffer to store result. Can be curr_dir[]. + size Size of buffer + MyFlags Flags + + NOTES + Directory is allways ended with FN_LIBCHAR + + RESULT + 0 ok + # error +*/ + +int my_getwd(char * buf, size_t size, myf MyFlags) { - my_string pos; + char * pos; DBUG_ENTER("my_getwd"); - DBUG_PRINT("my",("buf: 0x%lx size: %d MyFlags %d", (long) buf,size,MyFlags)); + DBUG_PRINT("my",("buf: 0x%lx size: %u MyFlags %d", + (long) buf, (uint) size, MyFlags)); if (curr_dir[0]) /* Current pos is saved here */ VOID(strmake(buf,&curr_dir[0],size-1)); @@ -71,26 +83,26 @@ int my_getwd(my_string buf, uint size, myf MyFlags) pos[0]= FN_LIBCHAR; pos[1]=0; } - (void) strmake(&curr_dir[0],buf,(size_s) (FN_REFLEN-1)); + (void) strmake(&curr_dir[0],buf, (size_t) (FN_REFLEN-1)); } DBUG_RETURN(0); } /* my_getwd */ - /* Set new working directory */ +/* Set new working directory */ int my_setwd(const char *dir, myf MyFlags) { int res; - size_s length; - my_string start,pos; + size_t length; + char *start, *pos; #if defined(VMS) char buff[FN_REFLEN]; #endif DBUG_ENTER("my_setwd"); DBUG_PRINT("my",("dir: '%s' MyFlags %d", dir, MyFlags)); - start=(my_string) dir; + start=(char *) dir; if (! dir[0] || (dir[0] == FN_LIBCHAR && dir[1] == 0)) dir=FN_ROOTDIR; #ifdef VMS @@ -115,7 +127,7 @@ int my_setwd(const char *dir, myf MyFlags) { if (test_if_hard_path(start)) { /* Hard pathname */ - pos=strmake(&curr_dir[0],start,(size_s) FN_REFLEN-1); + pos= strmake(&curr_dir[0],start,(size_t) FN_REFLEN-1); if (pos[-1] != FN_LIBCHAR) { length=(uint) (pos-(char*) curr_dir); diff --git a/mysys/my_init.c b/mysys/my_init.c index 7784c09d9d6..dcc49c68c0f 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -69,7 +69,7 @@ static ulong atoi_octal(const char *str) my_bool my_init(void) { - my_string str; + char * str; if (my_init_done) return 0; my_init_done=1; diff --git a/mysys/my_largepage.c b/mysys/my_largepage.c index 9714c582acb..a20111396cb 100644 --- a/mysys/my_largepage.c +++ b/mysys/my_largepage.c @@ -26,8 +26,8 @@ #endif static uint my_get_large_page_size_int(void); -static gptr my_large_malloc_int(uint size, myf my_flags); -static my_bool my_large_free_int(gptr ptr, myf my_flags); +static uchar* my_large_malloc_int(size_t size, myf my_flags); +static my_bool my_large_free_int(uchar* ptr, myf my_flags); /* Gets the size of large pages from the OS */ @@ -48,9 +48,9 @@ uint my_get_large_page_size(void) my_malloc_lock() in case of failure */ -gptr my_large_malloc(uint size, myf my_flags) +uchar* my_large_malloc(size_t size, myf my_flags) { - gptr ptr; + uchar* ptr; DBUG_ENTER("my_large_malloc"); if (my_use_large_pages && my_large_page_size) @@ -70,7 +70,7 @@ gptr my_large_malloc(uint size, myf my_flags) to my_free_lock() in case of failure */ -void my_large_free(gptr ptr, myf my_flags __attribute__((unused))) +void my_large_free(uchar* ptr, myf my_flags __attribute__((unused))) { DBUG_ENTER("my_large_free"); @@ -113,29 +113,29 @@ finish: #if HAVE_DECL_SHM_HUGETLB /* Linux-specific large pages allocator */ -gptr my_large_malloc_int(uint size, myf my_flags) +uchar* my_large_malloc_int(size_t size, myf my_flags) { int shmid; - gptr ptr; + uchar* ptr; struct shmid_ds buf; DBUG_ENTER("my_large_malloc_int"); /* Align block size to my_large_page_size */ size = ((size - 1) & ~(my_large_page_size - 1)) + my_large_page_size; - shmid = shmget(IPC_PRIVATE, (size_t)size, SHM_HUGETLB | SHM_R | SHM_W); + shmid = shmget(IPC_PRIVATE, size, SHM_HUGETLB | SHM_R | SHM_W); if (shmid < 0) { if (my_flags & MY_WME) fprintf(stderr, - "Warning: Failed to allocate %d bytes from HugeTLB memory." - " errno %d\n", size, errno); + "Warning: Failed to allocate %lu bytesx from HugeTLB memory." + " errno %d\n", (ulong) size, errno); DBUG_RETURN(NULL); } - ptr = shmat(shmid, NULL, 0); - if (ptr == (void *)-1) + ptr = (uchar*) shmat(shmid, NULL, 0); + if (ptr == (uchar *) -1) { if (my_flags& MY_WME) fprintf(stderr, "Warning: Failed to attach shared memory segment," @@ -156,7 +156,7 @@ gptr my_large_malloc_int(uint size, myf my_flags) /* Linux-specific large pages deallocator */ -my_bool my_large_free_int(byte *ptr, myf my_flags __attribute__((unused))) +my_bool my_large_free_int(uchar *ptr, myf my_flags __attribute__((unused))) { DBUG_ENTER("my_large_free_int"); DBUG_RETURN(shmdt(ptr) == 0); diff --git a/mysys/my_lib.c b/mysys/my_lib.c index 783a0683731..c10b2e391b4 100644 --- a/mysys/my_lib.c +++ b/mysys/my_lib.c @@ -78,7 +78,7 @@ void my_dirend(MY_DIR *buffer) ALIGN_SIZE(sizeof(MY_DIR)))); free_root((MEM_ROOT*)((char*)buffer + ALIGN_SIZE(sizeof(MY_DIR)) + ALIGN_SIZE(sizeof(DYNAMIC_ARRAY))), MYF(0)); - my_free((gptr) buffer,MYF(0)); + my_free((uchar*) buffer,MYF(0)); } DBUG_VOID_RETURN; } /* my_dirend */ @@ -114,7 +114,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags) pthread_mutex_lock(&THR_LOCK_open); #endif - dirp = opendir(directory_file_name(tmp_path,(my_string) path)); + dirp = opendir(directory_file_name(tmp_path,(char *) path)); #if defined(__amiga__) if ((dirp->dd_fd) < 0) /* Directory doesn't exists */ goto error; @@ -132,7 +132,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags) if (my_init_dynamic_array(dir_entries_storage, sizeof(FILEINFO), ENTRIES_START_SIZE, ENTRIES_INCREMENT)) { - my_free((gptr) buffer,MYF(0)); + my_free((uchar*) buffer,MYF(0)); goto error; } init_alloc_root(names_storage, NAMES_START_SIZE, NAMES_START_SIZE); @@ -168,7 +168,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags) else finfo.mystat= NULL; - if (push_dynamic(dir_entries_storage, (gptr)&finfo)) + if (push_dynamic(dir_entries_storage, (uchar*)&finfo)) goto error; } @@ -208,13 +208,13 @@ MY_DIR *my_dir(const char *path, myf MyFlags) * Returns pointer to dst; */ -my_string directory_file_name (my_string dst, const char *src) +char * directory_file_name (char * dst, const char *src) { #ifndef VMS /* Process as Unix format: just remove test the final slash. */ - my_string end; + char * end; if (src[0] == 0) src= (char*) "."; /* Use empty as current */ @@ -230,7 +230,7 @@ my_string directory_file_name (my_string dst, const char *src) long slen; long rlen; - my_string ptr, rptr; + char * ptr, rptr; char bracket; struct FAB fab = cc$rms_fab; struct NAM nam = cc$rms_nam; @@ -401,7 +401,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags) if (my_init_dynamic_array(dir_entries_storage, sizeof(FILEINFO), ENTRIES_START_SIZE, ENTRIES_INCREMENT)) { - my_free((gptr) buffer,MYF(0)); + my_free((uchar*) buffer,MYF(0)); goto error; } init_alloc_root(names_storage, NAMES_START_SIZE, NAMES_START_SIZE); @@ -475,7 +475,7 @@ MY_DIR *my_dir(const char *path, myf MyFlags) else finfo.mystat= NULL; - if (push_dynamic(dir_entries_storage, (gptr)&finfo)) + if (push_dynamic(dir_entries_storage, (uchar*)&finfo)) goto error; } #ifdef __BORLANDC__ @@ -533,13 +533,13 @@ MY_STAT *my_stat(const char *path, MY_STAT *stat_area, myf my_flags) if ((m_used= (stat_area == NULL))) if (!(stat_area = (MY_STAT *) my_malloc(sizeof(MY_STAT), my_flags))) goto error; - if (! stat((my_string) path, (struct stat *) stat_area) ) + if (! stat((char *) path, (struct stat *) stat_area) ) DBUG_RETURN(stat_area); DBUG_PRINT("error",("Got errno: %d from stat", errno)); my_errno= errno; if (m_used) /* Free if new area */ - my_free((gptr) stat_area,MYF(0)); + my_free((uchar*) stat_area,MYF(0)); error: if (my_flags & (MY_FAE+MY_WME)) diff --git a/mysys/my_lockmem.c b/mysys/my_lockmem.c index a58a5a340b1..b96331cd3cf 100644 --- a/mysys/my_lockmem.c +++ b/mysys/my_lockmem.c @@ -25,17 +25,17 @@ struct st_mem_list { LIST list; - byte *page; + uchar *page; uint size; }; LIST *mem_list; -byte *my_malloc_lock(uint size,myf MyFlags) +uchar *my_malloc_lock(uint size,myf MyFlags) { int success; uint pagesize=sysconf(_SC_PAGESIZE); - byte *ptr; + uchar *ptr; struct st_mem_list *element; DBUG_ENTER("my_malloc_lock"); @@ -46,7 +46,7 @@ byte *my_malloc_lock(uint size,myf MyFlags) my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),size); DBUG_RETURN(0); } - success = mlock((byte*) ptr,size); + success = mlock((uchar*) ptr,size); if (success != 0 && geteuid() == 0) { DBUG_PRINT("warning",("Failed to lock memory. errno %d\n", @@ -59,11 +59,11 @@ byte *my_malloc_lock(uint size,myf MyFlags) /* Add block in a list for munlock */ if (!(element=(struct st_mem_list*) my_malloc(sizeof(*element),MyFlags))) { - VOID(munlock((byte*) ptr,size)); + VOID(munlock((uchar*) ptr,size)); free(ptr); DBUG_RETURN(0); } - element->list.data=(byte*) element; + element->list.data=(uchar*) element; element->page=ptr; element->size=size; pthread_mutex_lock(&THR_LOCK_malloc); @@ -74,7 +74,7 @@ byte *my_malloc_lock(uint size,myf MyFlags) } -void my_free_lock(byte *ptr,myf Myflags __attribute__((unused))) +void my_free_lock(uchar *ptr,myf Myflags __attribute__((unused))) { LIST *list; struct st_mem_list *element=0; @@ -85,14 +85,14 @@ void my_free_lock(byte *ptr,myf Myflags __attribute__((unused))) element=(struct st_mem_list*) list->data; if (ptr == element->page) { /* Found locked mem */ - VOID(munlock((byte*) ptr,element->size)); + VOID(munlock((uchar*) ptr,element->size)); mem_list=list_delete(mem_list,list); break; } } pthread_mutex_unlock(&THR_LOCK_malloc); if (element) - my_free((gptr) element,MYF(0)); + my_free((uchar*) element,MYF(0)); free(ptr); /* Free even if not locked */ } diff --git a/mysys/my_malloc.c b/mysys/my_malloc.c index b0e775177a6..12793ad451b 100644 --- a/mysys/my_malloc.c +++ b/mysys/my_malloc.c @@ -23,11 +23,11 @@ /* My memory allocator */ -gptr my_malloc(unsigned int size, myf my_flags) +void *my_malloc(size_t size, myf my_flags) { - gptr point; + void* point; DBUG_ENTER("my_malloc"); - DBUG_PRINT("my",("size: %u my_flags: %d",size, my_flags)); + DBUG_PRINT("my",("size: %lu my_flags: %d", (ulong) size, my_flags)); if (!size) size=1; /* Safety */ @@ -44,14 +44,14 @@ gptr my_malloc(unsigned int size, myf my_flags) else if (my_flags & MY_ZEROFILL) bzero(point,size); DBUG_PRINT("exit",("ptr: 0x%lx", (long) point)); - DBUG_RETURN(point); + DBUG_RETURN((void*) point); } /* my_malloc */ /* Free memory allocated with my_malloc */ /*ARGSUSED*/ -void my_no_flags_free(gptr ptr) +void my_no_flags_free(void* ptr) { DBUG_ENTER("my_free"); DBUG_PRINT("my",("ptr: 0x%lx", (long) ptr)); @@ -63,32 +63,32 @@ void my_no_flags_free(gptr ptr) /* malloc and copy */ -gptr my_memdup(const byte *from, uint length, myf my_flags) +void* my_memdup(const void *from, size_t length, myf my_flags) { - gptr ptr; - if ((ptr=my_malloc(length,my_flags)) != 0) - memcpy((byte*) ptr, (byte*) from,(size_t) length); + void *ptr; + if ((ptr= my_malloc(length,my_flags)) != 0) + memcpy(ptr, from, length); return(ptr); } char *my_strdup(const char *from, myf my_flags) { - gptr ptr; - uint length=(uint) strlen(from)+1; - if ((ptr=my_malloc(length,my_flags)) != 0) - memcpy((byte*) ptr, (byte*) from,(size_t) length); - return((my_string) ptr); + char *ptr; + size_t length= strlen(from)+1; + if ((ptr= (char*) my_malloc(length, my_flags))) + memcpy((uchar*) ptr, (uchar*) from,(size_t) length); + return(ptr); } -char *my_strndup(const char *from, uint length, myf my_flags) +char *my_strndup(const char *from, size_t length, myf my_flags) { - gptr ptr; - if ((ptr=my_malloc(length+1,my_flags)) != 0) + char *ptr; + if ((ptr= (char*) my_malloc(length+1,my_flags)) != 0) { - memcpy((byte*) ptr, (byte*) from,(size_t) length); - ((char*) ptr)[length]=0; + memcpy((uchar*) ptr, (uchar*) from, length); + ptr[length]=0; } return((char*) ptr); } diff --git a/mysys/my_memmem.c b/mysys/my_memmem.c index 9230337409d..c000f14bc66 100644 --- a/mysys/my_memmem.c +++ b/mysys/my_memmem.c @@ -22,8 +22,9 @@ Returns a pointer to the beginning of the substring, needle, or NULL if the substring is not found in haystack. */ + void *my_memmem(const void *haystack, size_t haystacklen, - const void *needle, size_t needlelen) + const void *needle, size_t needlelen) { const unsigned char *cursor; const unsigned char *last_possible_needle_location = diff --git a/mysys/my_once.c b/mysys/my_once.c index fcb5af3ccbd..b6f6656fce2 100644 --- a/mysys/my_once.c +++ b/mysys/my_once.c @@ -36,10 +36,10 @@ No DBUG_ENTER... here to get smaller dbug-startup */ -gptr my_once_alloc(unsigned int Size, myf MyFlags) +void* my_once_alloc(size_t Size, myf MyFlags) { - uint get_size,max_left; - gptr point; + size_t get_size, max_left; + uchar* point; reg1 USED_MEM *next; reg2 USED_MEM **prev; @@ -63,36 +63,36 @@ gptr my_once_alloc(unsigned int Size, myf MyFlags) my_errno=errno; if (MyFlags & (MY_FAE+MY_WME)) my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),get_size); - return((gptr) 0); + return((uchar*) 0); } - DBUG_PRINT("test",("my_once_malloc %u byte malloced",get_size)); + DBUG_PRINT("test",("my_once_malloc %lu byte malloced", (ulong) get_size)); next->next= 0; next->size= get_size; next->left= get_size-ALIGN_SIZE(sizeof(USED_MEM)); *prev=next; } - point= (gptr) ((char*) next+ (next->size-next->left)); + point= (uchar*) ((char*) next+ (next->size-next->left)); next->left-= Size; if (MyFlags & MY_ZEROFILL) bzero(point, Size); - return(point); + return((void*) point); } /* my_once_alloc */ char *my_once_strdup(const char *src,myf myflags) { - uint len= (uint) strlen(src)+1; - char *dst=my_once_alloc(len, myflags); + size_t len= strlen(src)+1; + uchar *dst= my_once_alloc(len, myflags); if (dst) memcpy(dst, src, len); - return dst; + return (char*) dst; } -char *my_once_memdup(const char *src, uint len, myf myflags) +void *my_once_memdup(const void *src, size_t len, myf myflags) { - char *dst=my_once_alloc(len, myflags); + uchar *dst= my_once_alloc(len, myflags); if (dst) memcpy(dst, src, len); return dst; @@ -114,7 +114,7 @@ void my_once_free(void) for (next=my_once_root_block ; next ; ) { old=next; next= next->next ; - free((gptr) old); + free((uchar*) old); } my_once_root_block=0; diff --git a/mysys/my_open.c b/mysys/my_open.c index 71e243c0173..5ad48e66b68 100644 --- a/mysys/my_open.c +++ b/mysys/my_open.c @@ -56,20 +56,20 @@ File my_open(const char *FileName, int Flags, myf MyFlags) } #ifndef __WIN__ if (Flags & O_SHARE) - fd = sopen((my_string) FileName, (Flags & ~O_SHARE) | O_BINARY, SH_DENYNO, + fd = sopen((char *) FileName, (Flags & ~O_SHARE) | O_BINARY, SH_DENYNO, MY_S_IREAD | MY_S_IWRITE); else - fd = open((my_string) FileName, Flags | O_BINARY, + fd = open((char *) FileName, Flags | O_BINARY, MY_S_IREAD | MY_S_IWRITE); #else - fd= my_sopen((my_string) FileName, (Flags & ~O_SHARE) | O_BINARY, SH_DENYNO, + fd= my_sopen((char *) FileName, (Flags & ~O_SHARE) | O_BINARY, SH_DENYNO, MY_S_IREAD | MY_S_IWRITE); #endif #elif !defined(NO_OPEN_3) fd = open(FileName, Flags, my_umask); /* Normal unix */ #else - fd = open((my_string) FileName, Flags); + fd = open((char *) FileName, Flags); #endif DBUG_RETURN(my_register_filename(fd, FileName, FILE_BY_OPEN, EE_FILENOTFOUND, MyFlags)); diff --git a/mysys/my_pread.c b/mysys/my_pread.c index f8f0fa49c10..6e98132db73 100644 --- a/mysys/my_pread.c +++ b/mysys/my_pread.c @@ -20,61 +20,57 @@ #include <unistd.h> #endif - /* Read a chunk of bytes from a file */ - -uint my_pread(File Filedes, byte *Buffer, uint Count, my_off_t offset, - myf MyFlags) +/* + Read a chunk of bytes from a file from a given position + + SYNOPSIOS + my_pread() + Filedes File decsriptor + Buffer Buffer to read data into + Count Number of bytes to read + offset Position to read from + MyFlags Flags + + NOTES + This differs from the normal pread() call in that we don't care + to set the position in the file back to the original position + if the system doesn't support pread(). + + RETURN + (size_t) -1 Error + # Number of bytes read +*/ + +size_t my_pread(File Filedes, uchar *Buffer, size_t Count, my_off_t offset, + myf MyFlags) { - uint readbytes; + size_t readbytes; int error= 0; DBUG_ENTER("my_pread"); DBUG_PRINT("my",("Fd: %d Seek: %lu Buffer: 0x%lx Count: %u MyFlags: %d", - Filedes, (ulong) offset, (long) Buffer, Count, MyFlags)); - + Filedes, (ulong) offset, (long) Buffer, (uint) Count, + MyFlags)); for (;;) { #ifndef __WIN__ errno=0; /* Linux doesn't reset this */ #endif #ifndef HAVE_PREAD - os_off_t old_offset; - pthread_mutex_lock(&my_file_info[Filedes].mutex); - /* - As we cannot change the file pointer, we save the old position, - before seeking to the given offset - */ - - error= (old_offset= lseek(Filedes, 0L, MY_SEEK_CUR)) == -1L || - lseek(Filedes, offset, MY_SEEK_SET) == -1L; - - if (!error) /* Seek was successful */ - { - if ((readbytes = (uint) read(Filedes, Buffer, Count)) == -1L) - my_errno= errno; - - /* - We should seek back, even if read failed. If this fails, - we will return an error. If read failed as well, we will - save the errno from read, not from lseek(). - */ - if ((error= (lseek(Filedes, old_offset, MY_SEEK_SET) == -1L)) && - readbytes != -1L) - my_errno= errno; - } - + readbytes= (uint) -1; + error= (lseek(Filedes, offset, MY_SEEK_SET) == (my_off_t) -1 || + (readbytes= read(Filedes, Buffer, Count)) != Count); pthread_mutex_unlock(&my_file_info[Filedes].mutex); #else - if ((error= ((readbytes = - (uint) pread(Filedes, Buffer, Count, offset)) != Count))) + if ((error= ((readbytes= pread(Filedes, Buffer, Count, offset)) != Count))) my_errno= errno; #endif if (error || readbytes != Count) { DBUG_PRINT("warning",("Read only %d bytes off %u from %d, errno: %d", - (int) readbytes, Count,Filedes,my_errno)); + (int) readbytes, (uint) Count,Filedes,my_errno)); #ifdef THREAD - if ((readbytes == 0 || (int) readbytes == -1) && errno == EINTR) + if ((readbytes == 0 || readbytes == (size_t) -1) && errno == EINTR) { DBUG_PRINT("debug", ("my_pread() was interrupted and returned %d", (int) readbytes)); @@ -83,14 +79,14 @@ uint my_pread(File Filedes, byte *Buffer, uint Count, my_off_t offset, #endif if (MyFlags & (MY_WME | MY_FAE | MY_FNABP)) { - if ((int) readbytes == -1) + if (readbytes == (size_t) -1) my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG), my_filename(Filedes),my_errno); else if (MyFlags & (MY_NABP | MY_FNABP)) my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG), my_filename(Filedes),my_errno); } - if ((int) readbytes == -1 || (MyFlags & (MY_FNABP | MY_NABP))) + if (readbytes == (size_t) -1 || (MyFlags & (MY_FNABP | MY_NABP))) DBUG_RETURN(MY_FILE_ERROR); /* Return with error */ } if (MyFlags & (MY_NABP | MY_FNABP)) @@ -100,65 +96,63 @@ uint my_pread(File Filedes, byte *Buffer, uint Count, my_off_t offset, } /* my_pread */ - /* Write a chunk of bytes to a file */ +/* + Write a chunk of bytes to a file at a given position + + SYNOPSIOS + my_pwrite() + Filedes File decsriptor + Buffer Buffer to write data from + Count Number of bytes to write + offset Position to write to + MyFlags Flags + + NOTES + This differs from the normal pwrite() call in that we don't care + to set the position in the file back to the original position + if the system doesn't support pwrite() -uint my_pwrite(int Filedes, const byte *Buffer, uint Count, my_off_t offset, - myf MyFlags) + RETURN + (size_t) -1 Error + # Number of bytes read + */ + +size_t my_pwrite(int Filedes, const uchar *Buffer, size_t Count, + my_off_t offset, myf MyFlags) { - uint writenbytes,errors; - ulong written; + size_t writenbytes, written; + uint errors; DBUG_ENTER("my_pwrite"); - DBUG_PRINT("my",("Fd: %d Seek: %lu Buffer: 0x%lx Count: %d MyFlags: %d", - Filedes, (ulong) offset, (long) Buffer, Count, MyFlags)); - errors=0; written=0L; + DBUG_PRINT("my",("Fd: %d Seek: %lu Buffer: 0x%lx Count: %u MyFlags: %d", + Filedes, (ulong) offset, (long) Buffer, (uint) Count, + MyFlags)); + errors= 0; + written= 0; for (;;) { #ifndef HAVE_PREAD - int error= 0; - os_off_t old_offset; - writenbytes= (uint) -1; + int error; + writenbytes= (size_t) -1; pthread_mutex_lock(&my_file_info[Filedes].mutex); - - /* - As we cannot change the file pointer, we save the old position, - before seeking to the given offset - */ - error= ((old_offset= lseek(Filedes, 0L, MY_SEEK_CUR)) == -1L || - lseek(Filedes, offset, MY_SEEK_SET) == -1L); - - if (!error) /* Seek was successful */ - { - if ((writenbytes = (uint) write(Filedes, Buffer, Count)) == -1L) - my_errno= errno; - - /* - We should seek back, even if write failed. If this fails, - we will return an error. If write failed as well, we will - save the errno from write, not from lseek(). - */ - if ((error= (lseek(Filedes, old_offset, MY_SEEK_SET) == -1L)) && - writenbytes != -1L) - my_errno= errno; - } + error= (lseek(Filedes, offset, MY_SEEK_SET) != (my_off_t) -1 && + (writenbytes = write(Filedes, Buffer, Count)) == Count); pthread_mutex_unlock(&my_file_info[Filedes].mutex); - - if (!error && writenbytes == Count) + if (error) break; #else - if ((writenbytes = (uint) pwrite(Filedes, Buffer, Count,offset)) == Count) + if ((writenbytes= pwrite(Filedes, Buffer, Count,offset)) == Count) break; - else - my_errno= errno; + my_errno= errno; #endif - if ((int) writenbytes != -1) + if (writenbytes != (size_t) -1) { /* Safegueard */ written+=writenbytes; Buffer+=writenbytes; Count-=writenbytes; offset+=writenbytes; } - DBUG_PRINT("error",("Write only %d bytes",writenbytes)); + DBUG_PRINT("error",("Write only %u bytes", (uint) writenbytes)); #ifndef NO_BACKGROUND #ifdef THREAD if (my_thread_var->abort) @@ -173,8 +167,7 @@ uint my_pwrite(int Filedes, const byte *Buffer, uint Count, my_off_t offset, VOID(sleep(MY_WAIT_FOR_USER_TO_FIX_PANIC)); continue; } - if ((writenbytes > 0 && (uint) writenbytes != (uint) -1) || - my_errno == EINTR) + if ((writenbytes && writenbytes != (size_t) -1) || my_errno == EINTR) continue; /* Retry */ #endif if (MyFlags & (MY_NABP | MY_FNABP)) @@ -189,6 +182,7 @@ uint my_pwrite(int Filedes, const byte *Buffer, uint Count, my_off_t offset, else break; /* Return bytes written */ } + DBUG_EXECUTE_IF("check", my_seek(Filedes, -1, SEEK_SET, MYF(0));); if (MyFlags & (MY_NABP | MY_FNABP)) DBUG_RETURN(0); /* Want only errors */ DBUG_RETURN(writenbytes+written); /* purecov: inspected */ diff --git a/mysys/my_quick.c b/mysys/my_quick.c index 15549dfb751..c19fe08572d 100644 --- a/mysys/my_quick.c +++ b/mysys/my_quick.c @@ -19,14 +19,14 @@ #include "my_nosys.h" -uint my_quick_read(File Filedes,byte *Buffer,uint Count,myf MyFlags) +size_t my_quick_read(File Filedes,uchar *Buffer,size_t Count,myf MyFlags) { - uint readbytes; + size_t readbytes; - if ((readbytes = (uint) read(Filedes, Buffer, Count)) != Count) + if ((readbytes = read(Filedes, Buffer, Count)) != Count) { #ifndef DBUG_OFF - if ((readbytes == 0 || (int) readbytes == -1) && errno == EINTR) + if ((readbytes == 0 || readbytes == (size_t) -1) && errno == EINTR) { DBUG_PRINT("error", ("my_quick_read() was interrupted and returned %d" ". This function does not retry the read!", @@ -40,20 +40,20 @@ uint my_quick_read(File Filedes,byte *Buffer,uint Count,myf MyFlags) } -uint my_quick_write(File Filedes,const byte *Buffer,uint Count) +size_t my_quick_write(File Filedes,const uchar *Buffer,size_t Count) { #ifndef DBUG_OFF - uint writtenbytes; + size_t writtenbytes; #endif if (( #ifndef DBUG_OFF writtenbytes = #endif - (uint) write(Filedes,Buffer,Count)) != Count) + (size_t) write(Filedes,Buffer,Count)) != Count) { #ifndef DBUG_OFF - if ((writtenbytes == 0 || (int) writtenbytes == -1) && errno == EINTR) + if ((writtenbytes == 0 || writtenbytes == (size_t) -1) && errno == EINTR) { DBUG_PRINT("error", ("my_quick_write() was interrupted and returned %d" ". This function does not retry the write!", @@ -61,7 +61,7 @@ uint my_quick_write(File Filedes,const byte *Buffer,uint Count) } #endif my_errno=errno; - return (uint) -1; + return (size_t) -1; } return 0; } diff --git a/mysys/my_read.c b/mysys/my_read.c index a6c45340b0c..f3e8a4b300e 100644 --- a/mysys/my_read.c +++ b/mysys/my_read.c @@ -33,43 +33,44 @@ N number of bytes read. */ -uint my_read(File Filedes, byte *Buffer, uint Count, myf MyFlags) +size_t my_read(File Filedes, uchar *Buffer, size_t Count, myf MyFlags) { - uint readbytes, save_count; + size_t readbytes, save_count; DBUG_ENTER("my_read"); - DBUG_PRINT("my",("Fd: %d Buffer: 0x%lx Count: %u MyFlags: %d", - Filedes, (long) Buffer, Count, MyFlags)); + DBUG_PRINT("my",("Fd: %d Buffer: 0x%lx Count: %lu MyFlags: %d", + Filedes, (long) Buffer, (ulong) Count, MyFlags)); save_count= Count; for (;;) { errno= 0; /* Linux doesn't reset this */ - if ((readbytes= (uint) read(Filedes, Buffer, Count)) != Count) + if ((readbytes= read(Filedes, Buffer, Count)) != Count) { my_errno= errno ? errno : -1; - DBUG_PRINT("warning",("Read only %d bytes off %u from %d, errno: %d", - (int) readbytes, Count, Filedes, my_errno)); + DBUG_PRINT("warning",("Read only %d bytes off %lu from %d, errno: %d", + (int) readbytes, (ulong) Count, Filedes, + my_errno)); #ifdef THREAD if ((readbytes == 0 || (int) readbytes == -1) && errno == EINTR) { - DBUG_PRINT("debug", ("my_read() was interrupted and returned %d", - (int) readbytes)); + DBUG_PRINT("debug", ("my_read() was interrupted and returned %ld", + (long) readbytes)); continue; /* Interrupted */ } #endif if (MyFlags & (MY_WME | MY_FAE | MY_FNABP)) { - if ((int) readbytes == -1) + if (readbytes == (size_t) -1) my_error(EE_READ, MYF(ME_BELL+ME_WAITTANG), my_filename(Filedes),my_errno); else if (MyFlags & (MY_NABP | MY_FNABP)) my_error(EE_EOFERR, MYF(ME_BELL+ME_WAITTANG), my_filename(Filedes),my_errno); } - if ((int) readbytes == -1 || + if (readbytes == (size_t) -1 || ((MyFlags & (MY_FNABP | MY_NABP)) && !(MyFlags & MY_FULL_IO))) DBUG_RETURN(MY_FILE_ERROR); /* Return with error */ - if (readbytes > 0 && (MyFlags & MY_FULL_IO)) + if (readbytes != (size_t) -1 && (MyFlags & MY_FULL_IO)) { Buffer+= readbytes; Count-= readbytes; diff --git a/mysys/my_realloc.c b/mysys/my_realloc.c index 43fbb0c1eee..c7cf1323cd4 100644 --- a/mysys/my_realloc.c +++ b/mysys/my_realloc.c @@ -22,12 +22,12 @@ /* My memory re allocator */ -gptr my_realloc(gptr oldpoint, uint size, myf my_flags) +void* my_realloc(void* oldpoint, size_t size, myf my_flags) { - gptr point; + void *point; DBUG_ENTER("my_realloc"); - DBUG_PRINT("my",("ptr: 0x%lx size: %u my_flags: %d", (long) oldpoint, size, - my_flags)); + DBUG_PRINT("my",("ptr: 0x%lx size: %lu my_flags: %d", (long) oldpoint, + (ulong) size, my_flags)); if (!oldpoint && (my_flags & MY_ALLOW_ZERO_PTR)) DBUG_RETURN(my_malloc(size,my_flags)); @@ -48,7 +48,7 @@ gptr my_realloc(gptr oldpoint, uint size, myf my_flags) free(oldpoint); } #else - if ((point = (char*)realloc(oldpoint,size)) == NULL) + if ((point= (uchar*) realloc(oldpoint,size)) == NULL) { if (my_flags & MY_FREE_ON_ERROR) my_free(oldpoint, my_flags); diff --git a/mysys/my_static.c b/mysys/my_static.c index 77243611c03..472cf3b5084 100644 --- a/mysys/my_static.c +++ b/mysys/my_static.c @@ -27,7 +27,7 @@ my_bool timed_mutexes= 0; /* from my_init */ -my_string home_dir=0; +char * home_dir=0; const char *my_progname=0; char NEAR curr_dir[FN_REFLEN]= {0}, NEAR home_dir_buff[FN_REFLEN]= {0}; @@ -74,8 +74,8 @@ uint sf_malloc_prehunc=0, /* If you have problem with core- */ ulong sf_malloc_cur_memory= 0L; /* Current memory usage */ ulong sf_malloc_max_memory= 0L; /* Maximum memory usage */ uint sf_malloc_count= 0; /* Number of times NEW() was called */ -byte *sf_min_adress= (byte*) ~(unsigned long) 0L, - *sf_max_adress= (byte*) 0L; +uchar *sf_min_adress= (uchar*) ~(unsigned long) 0L, + *sf_max_adress= (uchar*) 0L; /* Root of the linked list of struct st_irem */ struct st_irem *sf_malloc_root = NULL; diff --git a/mysys/my_static.h b/mysys/my_static.h index b438c936225..66e6ea1c280 100644 --- a/mysys/my_static.h +++ b/mysys/my_static.h @@ -60,7 +60,7 @@ extern const char *soundex_map; extern USED_MEM* my_once_root_block; extern uint my_once_extra; -extern byte *sf_min_adress,*sf_max_adress; +extern uchar *sf_min_adress,*sf_max_adress; extern uint sf_malloc_count; extern struct st_irem *sf_malloc_root; diff --git a/mysys/my_vle.c b/mysys/my_vle.c index 18339c877df..09f297eb553 100644 --- a/mysys/my_vle.c +++ b/mysys/my_vle.c @@ -39,16 +39,16 @@ bytes. On failure, the 'out' pointer is returned. */ -byte* -my_vle_encode(byte* out, my_size_t max, ulong n) +uchar* +my_vle_encode(uchar* out, size_t max, ulong n) { - byte buf[my_vle_sizeof(n)]; - byte *ptr= buf; - my_size_t len; + uchar buf[my_vle_sizeof(n)]; + uchar *ptr= buf; + size_t len; do { - *ptr++= (byte) (n & 0x7F); + *ptr++= (uchar) (n & 0x7F); n>>= 7; } while (n > 0); @@ -64,7 +64,7 @@ my_vle_encode(byte* out, my_size_t max, ulong n) */ while (ptr-- > buf) { - byte v= *ptr; + uchar v= *ptr; if (ptr > buf) v|= 0x80; *out++= v; @@ -89,11 +89,11 @@ my_vle_encode(byte* out, my_size_t max, ulong n) more than sizeof(*result_ptr) + 1 bytes. */ -byte const* -my_vle_decode(ulong *result_ptr, byte const *vle) +uchar const* +my_vle_decode(ulong *result_ptr, uchar const *vle) { ulong result= 0; - my_size_t cnt= 1; + size_t cnt= 1; do { diff --git a/mysys/my_wincond.c b/mysys/my_wincond.c index 353b2fced4e..d1b07b61408 100644 --- a/mysys/my_wincond.c +++ b/mysys/my_wincond.c @@ -201,7 +201,7 @@ int pthread_attr_setprio(pthread_attr_t *connect_att,int priority) int pthread_attr_destroy(pthread_attr_t *connect_att) { - bzero((gptr) connect_att,sizeof(*connect_att)); + bzero((uchar*) connect_att,sizeof(*connect_att)); return 0; } diff --git a/mysys/my_windac.c b/mysys/my_windac.c index c711093b48f..f846853f7be 100644 --- a/mysys/my_windac.c +++ b/mysys/my_windac.c @@ -194,8 +194,8 @@ error: FreeSid(everyone_sid); if (htoken) CloseHandle(htoken); - my_free((gptr) sa, MYF(MY_ALLOW_ZERO_PTR)); - my_free((gptr) dacl, MYF(MY_ALLOW_ZERO_PTR)); + my_free((uchar*) sa, MYF(MY_ALLOW_ZERO_PTR)); + my_free((uchar*) dacl, MYF(MY_ALLOW_ZERO_PTR)); *psa= 0; return 1; } @@ -215,8 +215,8 @@ void my_security_attr_free(SECURITY_ATTRIBUTES *sa) My_security_attr *attr= (My_security_attr*) (((char*)sa) + ALIGN_SIZE(sizeof(*sa))); FreeSid(attr->everyone_sid); - my_free((gptr) attr->dacl, MYF(0)); - my_free((gptr) sa, MYF(0)); + my_free((uchar*) attr->dacl, MYF(0)); + my_free((uchar*) sa, MYF(0)); } } diff --git a/mysys/my_write.c b/mysys/my_write.c index 4c3d187e4e8..056a84f1794 100644 --- a/mysys/my_write.c +++ b/mysys/my_write.c @@ -20,28 +20,28 @@ /* Write a chunk of bytes to a file */ -uint my_write(int Filedes, const byte *Buffer, uint Count, myf MyFlags) +size_t my_write(int Filedes, const uchar *Buffer, size_t Count, myf MyFlags) { - uint writenbytes,errors; - ulong written; + size_t writenbytes, written; + uint errors; DBUG_ENTER("my_write"); - DBUG_PRINT("my",("Fd: %d Buffer: 0x%lx Count: %d MyFlags: %d", - Filedes, (long) Buffer, Count, MyFlags)); - errors=0; written=0L; + DBUG_PRINT("my",("Fd: %d Buffer: 0x%lx Count: %lu MyFlags: %d", + Filedes, (long) Buffer, (ulong) Count, MyFlags)); + errors=0; written=0; for (;;) { - if ((writenbytes = (uint) write(Filedes, Buffer, Count)) == Count) + if ((writenbytes= write(Filedes, Buffer, Count)) == Count) break; - if ((int) writenbytes != -1) + if (writenbytes != (size_t) -1) { /* Safeguard */ written+=writenbytes; Buffer+=writenbytes; Count-=writenbytes; } my_errno=errno; - DBUG_PRINT("error",("Write only %d bytes, error: %d", - writenbytes,my_errno)); + DBUG_PRINT("error",("Write only %ld bytes, error: %d", + (long) writenbytes, my_errno)); #ifndef NO_BACKGROUND #ifdef THREAD if (my_thread_var->abort) @@ -57,12 +57,12 @@ uint my_write(int Filedes, const byte *Buffer, uint Count, myf MyFlags) continue; } - if ((writenbytes == 0 || (int) writenbytes == -1)) + if ((writenbytes == 0 || writenbytes == (size_t) -1)) { if (my_errno == EINTR) { - DBUG_PRINT("debug", ("my_write() was interrupted and returned %d", - (int) writenbytes)); + DBUG_PRINT("debug", ("my_write() was interrupted and returned %ld", + (long) writenbytes)); continue; /* Interrupted */ } diff --git a/mysys/ptr_cmp.c b/mysys/ptr_cmp.c index 4fdbad58aaf..24ab6a1ea9c 100644 --- a/mysys/ptr_cmp.c +++ b/mysys/ptr_cmp.c @@ -22,15 +22,15 @@ #include "mysys_priv.h" #include <myisampack.h> -static int ptr_compare(uint *compare_length, uchar **a, uchar **b); -static int ptr_compare_0(uint *compare_length, uchar **a, uchar **b); -static int ptr_compare_1(uint *compare_length, uchar **a, uchar **b); -static int ptr_compare_2(uint *compare_length, uchar **a, uchar **b); -static int ptr_compare_3(uint *compare_length, uchar **a, uchar **b); +static int ptr_compare(size_t *compare_length, uchar **a, uchar **b); +static int ptr_compare_0(size_t *compare_length, uchar **a, uchar **b); +static int ptr_compare_1(size_t *compare_length, uchar **a, uchar **b); +static int ptr_compare_2(size_t *compare_length, uchar **a, uchar **b); +static int ptr_compare_3(size_t *compare_length, uchar **a, uchar **b); /* Get a pointer to a optimal byte-compare function for a given size */ -qsort2_cmp get_ptr_compare (uint size) +qsort2_cmp get_ptr_compare (size_t size) { if (size < 4) return (qsort2_cmp) ptr_compare; @@ -51,7 +51,7 @@ qsort2_cmp get_ptr_compare (uint size) #define cmp(N) if (first[N] != last[N]) return (int) first[N] - (int) last[N] -static int ptr_compare(uint *compare_length, uchar **a, uchar **b) +static int ptr_compare(size_t *compare_length, uchar **a, uchar **b) { reg3 int length= *compare_length; reg1 uchar *first,*last; @@ -66,7 +66,7 @@ static int ptr_compare(uint *compare_length, uchar **a, uchar **b) } -static int ptr_compare_0(uint *compare_length,uchar **a, uchar **b) +static int ptr_compare_0(size_t *compare_length,uchar **a, uchar **b) { reg3 int length= *compare_length; reg1 uchar *first,*last; @@ -87,7 +87,7 @@ static int ptr_compare_0(uint *compare_length,uchar **a, uchar **b) } -static int ptr_compare_1(uint *compare_length,uchar **a, uchar **b) +static int ptr_compare_1(size_t *compare_length,uchar **a, uchar **b) { reg3 int length= *compare_length-1; reg1 uchar *first,*last; @@ -108,7 +108,7 @@ static int ptr_compare_1(uint *compare_length,uchar **a, uchar **b) return (0); } -static int ptr_compare_2(uint *compare_length,uchar **a, uchar **b) +static int ptr_compare_2(size_t *compare_length,uchar **a, uchar **b) { reg3 int length= *compare_length-2; reg1 uchar *first,*last; @@ -130,7 +130,7 @@ static int ptr_compare_2(uint *compare_length,uchar **a, uchar **b) return (0); } -static int ptr_compare_3(uint *compare_length,uchar **a, uchar **b) +static int ptr_compare_3(size_t *compare_length,uchar **a, uchar **b) { reg3 int length= *compare_length-3; reg1 uchar *first,*last; @@ -153,7 +153,7 @@ static int ptr_compare_3(uint *compare_length,uchar **a, uchar **b) return (0); } -void my_store_ptr(byte *buff, uint pack_length, my_off_t pos) +void my_store_ptr(uchar *buff, size_t pack_length, my_off_t pos) { switch (pack_length) { #if SIZEOF_OFF_T > 4 @@ -171,7 +171,7 @@ void my_store_ptr(byte *buff, uint pack_length, my_off_t pos) return; } -my_off_t my_get_ptr(byte *ptr, uint pack_length) +my_off_t my_get_ptr(uchar *ptr, size_t pack_length) { my_off_t pos; switch (pack_length) { diff --git a/mysys/queues.c b/mysys/queues.c index 5970922284f..d8a7ca19bee 100644 --- a/mysys/queues.c +++ b/mysys/queues.c @@ -49,11 +49,11 @@ */ int init_queue(QUEUE *queue, uint max_elements, uint offset_to_key, - pbool max_at_top, int (*compare) (void *, byte *, byte *), + pbool max_at_top, int (*compare) (void *, uchar *, uchar *), void *first_cmp_arg) { DBUG_ENTER("init_queue"); - if ((queue->root= (byte **) my_malloc((max_elements+1)*sizeof(void*), + if ((queue->root= (uchar **) my_malloc((max_elements+1)*sizeof(void*), MYF(MY_WME))) == 0) DBUG_RETURN(1); queue->elements=0; @@ -92,7 +92,7 @@ int init_queue(QUEUE *queue, uint max_elements, uint offset_to_key, */ int init_queue_ex(QUEUE *queue, uint max_elements, uint offset_to_key, - pbool max_at_top, int (*compare) (void *, byte *, byte *), + pbool max_at_top, int (*compare) (void *, uchar *, uchar *), void *first_cmp_arg, uint auto_extent) { int ret; @@ -129,7 +129,7 @@ int init_queue_ex(QUEUE *queue, uint max_elements, uint offset_to_key, */ int reinit_queue(QUEUE *queue, uint max_elements, uint offset_to_key, - pbool max_at_top, int (*compare) (void *, byte *, byte *), + pbool max_at_top, int (*compare) (void *, uchar *, uchar *), void *first_cmp_arg) { DBUG_ENTER("reinit_queue"); @@ -162,11 +162,11 @@ int reinit_queue(QUEUE *queue, uint max_elements, uint offset_to_key, int resize_queue(QUEUE *queue, uint max_elements) { - byte **new_root; + uchar **new_root; DBUG_ENTER("resize_queue"); if (queue->max_elements == max_elements) DBUG_RETURN(0); - if ((new_root= (byte **) my_realloc((void *)queue->root, + if ((new_root= (uchar **) my_realloc((void *)queue->root, (max_elements+1)*sizeof(void*), MYF(MY_WME))) == 0) DBUG_RETURN(1); @@ -196,7 +196,7 @@ void delete_queue(QUEUE *queue) DBUG_ENTER("delete_queue"); if (queue->root) { - my_free((gptr) queue->root,MYF(0)); + my_free((uchar*) queue->root,MYF(0)); queue->root=0; } DBUG_VOID_RETURN; @@ -205,7 +205,7 @@ void delete_queue(QUEUE *queue) /* Code for insert, search and delete of elements */ -void queue_insert(register QUEUE *queue, byte *element) +void queue_insert(register QUEUE *queue, uchar *element) { reg2 uint idx, next; int cmp; @@ -234,7 +234,7 @@ void queue_insert(register QUEUE *queue, byte *element) */ -int queue_insert_safe(register QUEUE *queue, byte *element) +int queue_insert_safe(register QUEUE *queue, uchar *element) { if (queue->elements == queue->max_elements) @@ -253,9 +253,9 @@ int queue_insert_safe(register QUEUE *queue, byte *element) /* Remove item from queue */ /* Returns pointer to removed element */ -byte *queue_remove(register QUEUE *queue, uint idx) +uchar *queue_remove(register QUEUE *queue, uint idx) { - byte *element; + uchar *element; DBUG_ASSERT(idx < queue->max_elements); element= queue->root[++idx]; /* Intern index starts from 1 */ queue->root[idx]= queue->root[queue->elements--]; @@ -276,7 +276,7 @@ void queue_replaced(QUEUE *queue) void _downheap(register QUEUE *queue, uint idx) { - byte *element; + uchar *element; uint elements,half_queue,offset_to_key, next_index; bool first= TRUE; uint start_idx= idx; @@ -332,7 +332,7 @@ void _downheap(register QUEUE *queue, uint idx) /* Fix heap when index have changed */ void _downheap(register QUEUE *queue, uint idx) { - byte *element; + uchar *element; uint elements,half_queue,next_index,offset_to_key; int cmp; @@ -483,7 +483,7 @@ void calculate_end_next(uint part) } return; } -static int test_compare(void *null_arg, byte *a, byte *b) +static int test_compare(void *null_arg, uchar *a, uchar *b) { uint a_num= (*(uint*)a) & 0x3FFFFF; uint b_num= (*(uint*)b) & 0x3FFFFF; @@ -541,9 +541,9 @@ void perform_insert(QUEUE *queue) } num_array[i]= num + (i << 22); if (fix_used) - queue_element(queue, i-1)= (byte*)&num_array[i]; + queue_element(queue, i-1)= (uchar*)&num_array[i]; else - queue_insert(queue, (byte*)&num_array[i]); + queue_insert(queue, (uchar*)&num_array[i]); } while (++i <= no_parts); if (fix_used) { @@ -573,7 +573,7 @@ bool perform_ins_del(QUEUE *queue, bool max_ind) num_array[part]-= part; else num_array[part]+= part; - queue_top(queue)= (byte*)&num_array[part]; + queue_top(queue)= (uchar*)&num_array[part]; queue_replaced(queue); } } while (++i < no_loops); @@ -665,7 +665,7 @@ static void benchmark_test() num+= 16; part= num >> 22; num_array[part]= num; - queue_top(queue)= (byte*)&num_array[part]; + queue_top(queue)= (uchar*)&num_array[part]; queue_replaced(queue); } for (i= 0; i < 16; i++) diff --git a/mysys/safemalloc.c b/mysys/safemalloc.c index f2a4c280610..30c501c54ee 100644 --- a/mysys/safemalloc.c +++ b/mysys/safemalloc.c @@ -82,7 +82,7 @@ static int sf_malloc_tampered= 0; /* Static functions prototypes */ -static int check_ptr(const char *where, byte *ptr, const char *sFile, +static int check_ptr(const char *where, uchar *ptr, const char *sFile, uint uLine); static int _checkchunk(struct st_irem *pRec, const char *sFile, uint uLine); @@ -119,12 +119,12 @@ static int _checkchunk(struct st_irem *pRec, const char *sFile, uint uLine); /* Allocate some memory. */ -gptr _mymalloc(uint size, const char *filename, uint lineno, myf MyFlags) +void *_mymalloc(size_t size, const char *filename, uint lineno, myf MyFlags) { struct st_irem *irem; - char *data; + uchar *data; DBUG_ENTER("_mymalloc"); - DBUG_PRINT("enter",("Size: %u",size)); + DBUG_PRINT("enter",("Size: %lu", (ulong) size)); if (!sf_malloc_quick) (void) _sanity (filename, lineno); @@ -151,8 +151,8 @@ gptr _mymalloc(uint size, const char *filename, uint lineno, myf MyFlags) my_errno=errno; sprintf(buff,"Out of memory at line %d, '%s'", lineno, filename); my_message(EE_OUTOFMEMORY, buff, MYF(ME_BELL+ME_WAITTANG+ME_NOREFRESH)); - sprintf(buff,"needed %d byte (%ldk), memory in use: %ld bytes (%ldk)", - size, (size + 1023L) / 1024L, + sprintf(buff,"needed %u byte (%ldk), memory in use: %ld bytes (%ldk)", + (uint) size, (uint) (size + 1023L) / 1024L, sf_malloc_max_memory, (sf_malloc_max_memory + 1023L) / 1024L); my_message(EE_OUTOFMEMORY, buff, MYF(ME_BELL+ME_WAITTANG+ME_NOREFRESH)); } @@ -160,18 +160,18 @@ gptr _mymalloc(uint size, const char *filename, uint lineno, myf MyFlags) sf_malloc_max_memory,lineno, filename)); if (MyFlags & MY_FAE) exit(1); - DBUG_RETURN ((gptr) 0); + DBUG_RETURN ((void*) 0); } /* Fill up the structure */ - data= (((char*) irem) + ALIGN_SIZE(sizeof(struct st_irem)) + + data= (((uchar*) irem) + ALIGN_SIZE(sizeof(struct st_irem)) + sf_malloc_prehunc); *((uint32*) (data-sizeof(uint32)))= MAGICKEY; data[size + 0]= MAGICEND0; data[size + 1]= MAGICEND1; data[size + 2]= MAGICEND2; data[size + 3]= MAGICEND3; - irem->filename= (my_string) filename; + irem->filename= (char *) filename; irem->linenum= lineno; irem->datasize= size; irem->prev= NULL; @@ -198,7 +198,7 @@ gptr _mymalloc(uint size, const char *filename, uint lineno, myf MyFlags) sf_min_adress= data; if (sf_max_adress < data) sf_max_adress= data; - DBUG_RETURN ((gptr) data); + DBUG_RETURN((void*) data); } @@ -207,8 +207,8 @@ gptr _mymalloc(uint size, const char *filename, uint lineno, myf MyFlags) Free then old memoryblock */ -gptr _myrealloc(register gptr ptr, register uint size, - const char *filename, uint lineno, myf MyFlags) +void *_myrealloc(register void *ptr, register size_t size, + const char *filename, uint lineno, myf MyFlags) { struct st_irem *irem; char *data; @@ -220,8 +220,8 @@ gptr _myrealloc(register gptr ptr, register uint size, if (!sf_malloc_quick) (void) _sanity (filename, lineno); - if (check_ptr("Reallocating", (byte*) ptr, filename, lineno)) - DBUG_RETURN((gptr) NULL); + if (check_ptr("Reallocating", (uchar*) ptr, filename, lineno)) + DBUG_RETURN((uchar*) NULL); irem= (struct st_irem *) (((char*) ptr) - ALIGN_SIZE(sizeof(struct st_irem))- sf_malloc_prehunc); @@ -232,13 +232,13 @@ gptr _myrealloc(register gptr ptr, register uint size, DBUG_PRINT("safe",("Reallocating unallocated data at line %d, '%s'", lineno, filename)); (void) fflush(stderr); - DBUG_RETURN((gptr) NULL); + DBUG_RETURN((uchar*) NULL); } if ((data= _mymalloc(size,filename,lineno,MyFlags))) /* Allocate new area */ { size=min(size, irem->datasize); /* Move as much as possibly */ - memcpy((byte*) data, ptr, (size_t) size); /* Copy old data */ + memcpy((uchar*) data, ptr, (size_t) size); /* Copy old data */ _myfree(ptr, filename, lineno, 0); /* Free not needed area */ } else @@ -254,7 +254,7 @@ gptr _myrealloc(register gptr ptr, register uint size, /* Deallocate some memory. */ -void _myfree(gptr ptr, const char *filename, uint lineno, myf myflags) +void _myfree(void *ptr, const char *filename, uint lineno, myf myflags) { struct st_irem *irem; DBUG_ENTER("_myfree"); @@ -264,7 +264,7 @@ void _myfree(gptr ptr, const char *filename, uint lineno, myf myflags) (void) _sanity (filename, lineno); if ((!ptr && (myflags & MY_ALLOW_ZERO_PTR)) || - check_ptr("Freeing",(byte*) ptr,filename,lineno)) + check_ptr("Freeing",(uchar*) ptr,filename,lineno)) DBUG_VOID_RETURN; /* Calculate the address of the remember structure */ @@ -316,7 +316,7 @@ void _myfree(gptr ptr, const char *filename, uint lineno, myf myflags) /* Check if we have a wrong pointer */ -static int check_ptr(const char *where, byte *ptr, const char *filename, +static int check_ptr(const char *where, uchar *ptr, const char *filename, uint lineno) { if (!ptr) @@ -503,12 +503,12 @@ int _sanity(const char *filename, uint lineno) /* malloc and copy */ -gptr _my_memdup(const byte *from, uint length, const char *filename, - uint lineno, myf MyFlags) +void *_my_memdup(const void *from, size_t length, const char *filename, + uint lineno, myf MyFlags) { - gptr ptr; - if ((ptr=_mymalloc(length,filename,lineno,MyFlags)) != 0) - memcpy((byte*) ptr, (byte*) from,(size_t) length); + void *ptr; + if ((ptr= _mymalloc(length,filename,lineno,MyFlags)) != 0) + memcpy(ptr, from, length); return(ptr); } /*_my_memdup */ @@ -516,23 +516,23 @@ gptr _my_memdup(const byte *from, uint length, const char *filename, char *_my_strdup(const char *from, const char *filename, uint lineno, myf MyFlags) { - gptr ptr; - uint length=(uint) strlen(from)+1; - if ((ptr=_mymalloc(length,filename,lineno,MyFlags)) != 0) - memcpy((byte*) ptr, (byte*) from,(size_t) length); - return((char*) ptr); + char *ptr; + size_t length= strlen(from)+1; + if ((ptr= (char*) _mymalloc(length,filename,lineno,MyFlags)) != 0) + memcpy((uchar*) ptr, (uchar*) from, (size_t) length); + return(ptr); } /* _my_strdup */ -char *_my_strndup(const char *from, uint length, - const char *filename, uint lineno, - myf MyFlags) +char *_my_strndup(const char *from, size_t length, + const char *filename, uint lineno, + myf MyFlags) { - gptr ptr; - if ((ptr=_mymalloc(length+1,filename,lineno,MyFlags)) != 0) + char *ptr; + if ((ptr= (char*) _mymalloc(length+1,filename,lineno,MyFlags)) != 0) { - memcpy((byte*) ptr, (byte*) from,(size_t) length); + memcpy((uchar*) ptr, (uchar*) from, (size_t) length); ptr[length]=0; } - return((char *) ptr); + return(ptr); } diff --git a/mysys/string.c b/mysys/string.c index e1ff9ec8c26..b234a589406 100644 --- a/mysys/string.c +++ b/mysys/string.c @@ -23,7 +23,7 @@ #include <m_string.h> my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str, - uint init_alloc, uint alloc_increment) + size_t init_alloc, size_t alloc_increment) { uint length; DBUG_ENTER("init_dynamic_string"); @@ -31,7 +31,7 @@ my_bool init_dynamic_string(DYNAMIC_STRING *str, const char *init_str, if (!alloc_increment) alloc_increment=128; length=1; - if (init_str && (length= (uint) strlen(init_str)+1) < init_alloc) + if (init_str && (length= strlen(init_str)+1) < init_alloc) init_alloc=((length+alloc_increment-1)/alloc_increment)*alloc_increment; if (!init_alloc) init_alloc=alloc_increment; @@ -72,7 +72,7 @@ my_bool dynstr_set(DYNAMIC_STRING *str, const char *init_str) } -my_bool dynstr_realloc(DYNAMIC_STRING *str, ulong additional_size) +my_bool dynstr_realloc(DYNAMIC_STRING *str, size_t additional_size) { DBUG_ENTER("dynstr_realloc"); @@ -95,7 +95,7 @@ my_bool dynstr_append(DYNAMIC_STRING *str, const char *append) my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append, - uint length) + size_t length) { char *new_ptr; if (str->length+length >= str->max_length) @@ -114,26 +114,30 @@ my_bool dynstr_append_mem(DYNAMIC_STRING *str, const char *append, return FALSE; } -my_bool dynstr_trunc(DYNAMIC_STRING *str, int n) + +my_bool dynstr_trunc(DYNAMIC_STRING *str, size_t n) { str->length-=n; str->str[str->length]= '\0'; return FALSE; } -/** Concatenates any number of strings, escapes any OS quote in the result then - * surround the whole affair in another set of quotes which is finally appended - * to specified DYNAMIC_STRING. This function is especially useful when - * building strings to be executed with the system() function. - * @param str Dynamic String which will have addtional strings appended. - * @param append String to be appended. - * @param ... Optional. Additional string(s) to be appended. - * - * @note The final argument in the list must be NullS even if no additional - * options are passed. - * - * @return True = Success. - */ +/* + Concatenates any number of strings, escapes any OS quote in the result then + surround the whole affair in another set of quotes which is finally appended + to specified DYNAMIC_STRING. This function is especially useful when + building strings to be executed with the system() function. + + @param str Dynamic String which will have addtional strings appended. + @param append String to be appended. + @param ... Optional. Additional string(s) to be appended. + + @note The final argument in the list must be NullS even if no additional + options are passed. + + @return True = Success. +*/ + my_bool dynstr_append_os_quoted(DYNAMIC_STRING *str, const char *append, ...) { #ifdef __WIN__ diff --git a/mysys/testhash.c b/mysys/testhash.c index 0961558afd3..2add2ebd2d7 100644 --- a/mysys/testhash.c +++ b/mysys/testhash.c @@ -38,11 +38,11 @@ my_bool hash_check(HASH *hash); void free_record(void *record); -static byte *hash2_key(const byte *rec,uint *length, +static uchar *hash2_key(const uchar *rec,uint *length, my_bool not_used __attribute__((unused))) { *length=(uint) (uchar) rec[reclength-1]; - return (byte*) rec; + return (uchar*) rec; } /* main program */ @@ -196,7 +196,7 @@ static int do_test() pos=0; while ((recpos=hash_element(&hash,0))) { - record=(byte*) my_malloc(reclength,MYF(MY_FAE)); + record=(uchar*) my_malloc(reclength,MYF(MY_FAE)); memcpy(record,recpos,reclength); record[reclength-1]=rnd(5)+1; if (my_hash_insert(&hash2,record)) diff --git a/mysys/thr_alarm.c b/mysys/thr_alarm.c index 471ec0ab10d..81093be3678 100644 --- a/mysys/thr_alarm.c +++ b/mysys/thr_alarm.c @@ -60,7 +60,7 @@ static void *alarm_handler(void *arg); static sig_handler thread_alarm(int sig __attribute__((unused))); static int compare_ulong(void *not_used __attribute__((unused)), - byte *a_ptr,byte* b_ptr) + uchar *a_ptr,uchar* b_ptr) { ulong a=*((ulong*) a_ptr),b= *((ulong*) b_ptr); return (a < b) ? -1 : (a == b) ? 0 : 1; @@ -205,7 +205,7 @@ my_bool thr_alarm(thr_alarm_t *alrm, uint sec, ALARM *alarm_data) alarm_data->alarmed=0; alarm_data->thread= current_my_thread_var->pthread_self; alarm_data->thread_id= current_my_thread_var->id; - queue_insert(&alarm_queue,(byte*) alarm_data); + queue_insert(&alarm_queue,(uchar*) alarm_data); /* Reschedule alarm if the current one has more than sec left */ if (reschedule) @@ -237,14 +237,14 @@ void thr_end_alarm(thr_alarm_t *alarmed) pthread_sigmask(SIG_BLOCK,&full_signal_set,&old_mask); pthread_mutex_lock(&LOCK_alarm); - alarm_data= (ALARM*) ((byte*) *alarmed - offsetof(ALARM,alarmed)); + alarm_data= (ALARM*) ((uchar*) *alarmed - offsetof(ALARM,alarmed)); for (i=0 ; i < alarm_queue.elements ; i++) { if ((ALARM*) queue_element(&alarm_queue,i) == alarm_data) { queue_remove(&alarm_queue,i),MYF(0); if (alarm_data->malloced) - my_free((gptr) alarm_data,MYF(0)); + my_free((uchar*) alarm_data,MYF(0)); found++; #ifdef DBUG_OFF break; @@ -464,7 +464,7 @@ void thr_alarm_kill(my_thread_id thread_id) { ALARM *tmp=(ALARM*) queue_remove(&alarm_queue,i); tmp->expire_time=0; - queue_insert(&alarm_queue,(byte*) tmp); + queue_insert(&alarm_queue,(uchar*) tmp); reschedule_alarms(); break; } @@ -755,7 +755,7 @@ static void *test_thread(void *arg) thread_count--; VOID(pthread_cond_signal(&COND_thread_count)); /* Tell main we are ready */ pthread_mutex_unlock(&LOCK_thread_count); - free((gptr) arg); + free((uchar*) arg); return 0; } diff --git a/mysys/thr_lock.c b/mysys/thr_lock.c index 94c34eef2fa..20edffb49c2 100644 --- a/mysys/thr_lock.c +++ b/mysys/thr_lock.c @@ -899,7 +899,7 @@ end: */ -#define LOCK_CMP(A,B) ((byte*) (A->lock) - (uint) ((A)->type) < (byte*) (B->lock)- (uint) ((B)->type)) +#define LOCK_CMP(A,B) ((uchar*) (A->lock) - (uint) ((A)->type) < (uchar*) (B->lock)- (uint) ((B)->type)) static void sort_locks(THR_LOCK_DATA **data,uint count) { @@ -1600,7 +1600,7 @@ static void *test_thread(void *arg) thread_count--; VOID(pthread_cond_signal(&COND_thread_count)); /* Tell main we are ready */ pthread_mutex_unlock(&LOCK_thread_count); - free((gptr) arg); + free((uchar*) arg); return 0; } diff --git a/mysys/tree.c b/mysys/tree.c index 2e6868e0777..ef33f75b7c6 100644 --- a/mysys/tree.c +++ b/mysys/tree.c @@ -93,7 +93,7 @@ void init_tree(TREE *tree, ulong default_alloc_size, ulong memory_limit, if (default_alloc_size < DEFAULT_ALLOC_SIZE) default_alloc_size= DEFAULT_ALLOC_SIZE; default_alloc_size= MY_ALIGN(default_alloc_size, DEFAULT_ALIGN_SIZE); - bzero((gptr) &tree->null_element,sizeof(tree->null_element)); + bzero((uchar*) &tree->null_element,sizeof(tree->null_element)); tree->root= &tree->null_element; tree->compare=compare; tree->size_of_element=size > 0 ? (uint) size : 0; @@ -247,12 +247,12 @@ TREE_ELEMENT *tree_insert(TREE *tree, void *key, uint key_size, else { *((void**) (element+1))= (void*) ((void **) (element+1)+1); - memcpy((byte*) *((void **) (element+1)),key, + memcpy((uchar*) *((void **) (element+1)),key, (size_t) (key_size-sizeof(void*))); } } else - memcpy((byte*) element+tree->offset_to_key,key,(size_t) key_size); + memcpy((uchar*) element+tree->offset_to_key,key,(size_t) key_size); element->count=1; /* May give warning in purify */ tree->elements_in_tree++; rb_insert(tree,parent,element); /* rebalance tree */ @@ -326,7 +326,7 @@ int tree_delete(TREE *tree, void *key, uint key_size, void *custom_arg) if (tree->free) (*tree->free)(ELEMENT_KEY(tree,element), free_free, tree->custom_arg); tree->allocated-= sizeof(TREE_ELEMENT) + tree->size_of_element + key_size; - my_free((gptr) element,MYF(0)); + my_free((uchar*) element,MYF(0)); tree->elements_in_tree--; return 0; } diff --git a/mysys/trie.c b/mysys/trie.c index 8daa6f3e661..5738b9b866b 100644 --- a/mysys/trie.c +++ b/mysys/trie.c @@ -101,7 +101,7 @@ void trie_free (TRIE *trie) /* SYNOPSIS - my_bool trie_insert (TRIE *trie, const byte *key, uint keylen); + my_bool trie_insert (TRIE *trie, const uchar *key, uint keylen); trie - valid pointer to `TRIE' key - valid pointer to key to insert keylen - non-0 key length @@ -118,11 +118,11 @@ void trie_free (TRIE *trie) However it can be freed with trie_free(). */ -my_bool trie_insert (TRIE *trie, const byte *key, uint keylen) +my_bool trie_insert (TRIE *trie, const uchar *key, uint keylen) { TRIE_NODE *node; TRIE_NODE *next; - byte p; + uchar p; uint k; DBUG_ENTER("trie_insert"); DBUG_ASSERT(trie && key && keylen); @@ -211,7 +211,7 @@ my_bool ac_trie_prepare (TRIE *trie) fail= fail->fail; } } - my_free((gptr)tmp_nodes, MYF(0)); + my_free((uchar*)tmp_nodes, MYF(0)); DBUG_RETURN(FALSE); } diff --git a/mysys/typelib.c b/mysys/typelib.c index 47fe6967da5..e745a9fb917 100644 --- a/mysys/typelib.c +++ b/mysys/typelib.c @@ -27,7 +27,7 @@ int find_type_or_exit(const char *x, TYPELIB *typelib, const char *option) int res; const char **ptr; - if ((res= find_type((my_string) x, typelib, 2)) <= 0) + if ((res= find_type((char *) x, typelib, 2)) <= 0) { ptr= typelib->type_names; if (!*x) @@ -67,10 +67,11 @@ int find_type_or_exit(const char *x, TYPELIB *typelib, const char *option) >0 Offset+1 in typelib for matched string */ + int find_type(char *x, const TYPELIB *typelib, uint full_name) { int find,pos,findpos; - reg1 my_string i; + reg1 char * i; reg2 const char *j; DBUG_ENTER("find_type"); DBUG_PRINT("enter",("x: '%s' lib: 0x%lx", x, (long) typelib)); @@ -124,7 +125,7 @@ int find_type(char *x, const TYPELIB *typelib, uint full_name) /* Get name of type nr 'nr' */ /* Warning first type is 1, 0 = empty field */ -void make_type(register my_string to, register uint nr, +void make_type(register char * to, register uint nr, register TYPELIB *typelib) { DBUG_ENTER("make_type"); @@ -162,11 +163,11 @@ const char *get_type(TYPELIB *typelib, uint nr) a integer representation of the supplied string */ -my_ulonglong find_typeset(my_string x, TYPELIB *lib, int *err) +my_ulonglong find_typeset(char *x, TYPELIB *lib, int *err) { my_ulonglong result; int find; - my_string i; + char *i; DBUG_ENTER("find_set"); DBUG_PRINT("enter",("x: '%s' lib: 0x%lx", x, (long) lib)); diff --git a/plugin/daemon_example/daemon_example.cc b/plugin/daemon_example/daemon_example.cc index 994c385796e..af585bb4302 100644 --- a/plugin/daemon_example/daemon_example.cc +++ b/plugin/daemon_example/daemon_example.cc @@ -60,7 +60,7 @@ pthread_handler_t mysql_heartbeat(void *p) tm_tmp.tm_hour, tm_tmp.tm_min, tm_tmp.tm_sec); - my_write(con->heartbeat_file, buffer, strlen(buffer), MYF(0)); + my_write(con->heartbeat_file, (uchar*) buffer, strlen(buffer), MYF(0)); x++; } @@ -114,7 +114,7 @@ static int daemon_example_plugin_init(void *p) tm_tmp.tm_hour, tm_tmp.tm_min, tm_tmp.tm_sec); - my_write(con->heartbeat_file, buffer, strlen(buffer), MYF(0)); + my_write(con->heartbeat_file, (uchar*) buffer, strlen(buffer), MYF(0)); pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, @@ -168,7 +168,7 @@ static int daemon_example_plugin_deinit(void *p) tm_tmp.tm_hour, tm_tmp.tm_min, tm_tmp.tm_sec); - my_write(con->heartbeat_file, buffer, strlen(buffer), MYF(0)); + my_write(con->heartbeat_file, (uchar*) buffer, strlen(buffer), MYF(0)); my_close(con->heartbeat_file, MYF(0)); my_free((char *)con, MYF(0)); diff --git a/regex/reginit.c b/regex/reginit.c index f0b53e64be3..8347c4f6895 100644 --- a/regex/reginit.c +++ b/regex/reginit.c @@ -16,7 +16,7 @@ void my_regex_init(CHARSET_INFO *cs) if (!regex_inited) { regex_inited=1; - bzero((gptr) &count,sizeof(count)); + bzero((uchar*) &count,sizeof(count)); for (i=1 ; i<= 255; i++) { diff --git a/server-tools/instance-manager/buffer.cc b/server-tools/instance-manager/buffer.cc index 67be2382523..1c50b11609e 100644 --- a/server-tools/instance-manager/buffer.cc +++ b/server-tools/instance-manager/buffer.cc @@ -44,12 +44,12 @@ const uint Buffer::MAX_BUFFER_SIZE= 16777216; 1 - got an error in reserve() */ -int Buffer::append(uint position, const char *string, uint len_arg) +int Buffer::append(size_t position, const char *string, size_t len_arg) { if (reserve(position, len_arg)) return 1; - strnmov(buffer + position, string, len_arg); + strnmov((char*) buffer + position, string, len_arg); return 0; } @@ -75,20 +75,20 @@ int Buffer::append(uint position, const char *string, uint len_arg) 1 - realloc error or we have come to the 16Mb barrier */ -int Buffer::reserve(uint position, uint len_arg) +int Buffer::reserve(size_t position, size_t len_arg) { if (position + len_arg >= MAX_BUFFER_SIZE) goto err; if (position + len_arg >= buffer_size) { - buffer= (char*) my_realloc(buffer, + buffer= (uchar*) my_realloc(buffer, min(MAX_BUFFER_SIZE, max((uint) (buffer_size*1.5), position + len_arg)), MYF(0)); if (!(buffer)) goto err; - buffer_size= (uint) (buffer_size*1.5); + buffer_size= (size_t) (buffer_size*1.5); } return 0; diff --git a/server-tools/instance-manager/buffer.h b/server-tools/instance-manager/buffer.h index a551dd98a25..3bd7a714437 100644 --- a/server-tools/instance-manager/buffer.h +++ b/server-tools/instance-manager/buffer.h @@ -45,7 +45,7 @@ public: /* As append() will invokes realloc() anyway, it's ok if malloc returns 0 */ - if (!(buffer= (char*) my_malloc(buffer_size, MYF(0)))) + if (!(buffer= (uchar*) my_malloc(buffer_size, MYF(0)))) buffer_size= 0; } @@ -55,11 +55,11 @@ public: } public: - char *buffer; + uchar *buffer; int get_size(); int is_error(); - int append(uint position, const char *string, uint len_arg); - int reserve(uint position, uint len_arg); + int append(size_t position, const char *string, size_t len_arg); + int reserve(size_t position, size_t len_arg); }; #endif /* INCLUDES_MYSQL_INSTANCE_MANAGER_BUFFER_H */ diff --git a/server-tools/instance-manager/commands.cc b/server-tools/instance-manager/commands.cc index 393aceadca9..56bd720b3e9 100644 --- a/server-tools/instance-manager/commands.cc +++ b/server-tools/instance-manager/commands.cc @@ -170,7 +170,7 @@ int Show_instances::write_data(st_net *net) while ((instance= iterator.next())) { Buffer send_buf; /* buffer for packets */ - uint pos= 0; + size_t pos= 0; instance->lock(); @@ -356,7 +356,7 @@ int Show_instance_status::write_data(st_net *net, Instance *instance) { Buffer send_buf; /* buffer for packets */ char version_num_buf[MAX_VERSION_LENGTH]; - uint pos= 0; + size_t pos= 0; const char *state_name= instance->get_state_name(); const char *version_tag= "unknown"; @@ -379,7 +379,7 @@ int Show_instance_status::write_data(st_net *net, Instance *instance) store_to_protocol_packet(&send_buf, version_num, &pos) || store_to_protocol_packet(&send_buf, version_tag, &pos) || store_to_protocol_packet(&send_buf, mysqld_compatible_status, &pos) || - my_net_write(net, send_buf.buffer, (uint) pos)) + my_net_write(net, send_buf.buffer, pos)) { return ER_OUT_OF_RESOURCES; } @@ -455,7 +455,7 @@ int Show_instance_options::write_header(st_net *net) int Show_instance_options::write_data(st_net *net, Instance *instance) { Buffer send_buff; /* buffer for packets */ - uint pos= 0; + size_t pos= 0; if (store_to_protocol_packet(&send_buff, "instance_name", &pos) || store_to_protocol_packet(&send_buff, get_instance_name()->str, &pos) || @@ -618,7 +618,7 @@ bool Create_instance::init(const char **text) bool Create_instance::parse_args(const char **text) { - uint len; + size_t len; /* Check if we have something (and trim leading spaces). */ @@ -991,13 +991,13 @@ int Show_instance_log::write_header(st_net *net) int Show_instance_log::write_data(st_net *net, Instance *instance) { Buffer send_buff; /* buffer for packets */ - uint pos= 0; + size_t pos= 0; const char *logpath= instance->options.logs[log_type]; File fd; size_t buff_size; - int read_len; + size_t read_len; MY_STAT file_stat; Buffer read_buff; @@ -1020,8 +1020,8 @@ int Show_instance_log::write_data(st_net *net, Instance *instance) /* read in one chunk */ read_len= (int)my_seek(fd, file_stat.st_size - size, MY_SEEK_SET, MYF(0)); - if ((read_len= my_read(fd, (byte*) read_buff.buffer, - buff_size, MYF(0))) < 0) + if ((read_len= my_read(fd, read_buff.buffer, buff_size, MYF(0))) == + MY_FILE_ERROR) { close(fd); return ER_READ_FILE; @@ -1029,7 +1029,8 @@ int Show_instance_log::write_data(st_net *net, Instance *instance) close(fd); - if (store_to_protocol_packet(&send_buff, read_buff.buffer, &pos, read_len) || + if (store_to_protocol_packet(&send_buff, (char*) read_buff.buffer, &pos, + read_len) || my_net_write(net, send_buff.buffer, pos)) { return ER_OUT_OF_RESOURCES; @@ -1142,7 +1143,7 @@ int Show_instance_log_files::write_data(st_net *net, Instance *instance) enum { LOG_NAME_BUFFER_SIZE= 20 }; char buff[LOG_NAME_BUFFER_SIZE]; - uint pos= 0; + size_t pos= 0; const char *log_path= ""; const char *log_size= "0"; @@ -1227,12 +1228,12 @@ bool Instance_options_list::init() C_MODE_START -static byte* get_item_key(const byte* item, uint* len, - my_bool __attribute__((unused)) t) +static uchar* get_item_key(const uchar* item, size_t* len, + my_bool __attribute__((unused)) t) { const Instance_options_list *lst= (const Instance_options_list *) item; *len= lst->get_instance_name()->length; - return (byte *) lst->get_instance_name()->str; + return (uchar *) lst->get_instance_name()->str; } static void delete_item(void *item) @@ -1358,7 +1359,7 @@ Abstract_option_cmd::get_instance_options_list(const LEX_STRING *instance_name) { Instance_options_list *lst= (Instance_options_list *) hash_search(&instance_options_map, - (byte *) instance_name->str, + (uchar *) instance_name->str, instance_name->length); if (!lst) @@ -1368,7 +1369,7 @@ Abstract_option_cmd::get_instance_options_list(const LEX_STRING *instance_name) if (!lst) return NULL; - if (lst->init() || my_hash_insert(&instance_options_map, (byte *) lst)) + if (lst->init() || my_hash_insert(&instance_options_map, (uchar *) lst)) { delete lst; return NULL; @@ -1458,7 +1459,7 @@ int Abstract_option_cmd::execute_impl(st_net *net, ulong connection_id) bool Set_option::parse_args(const char **text) { - uint len; + size_t len; /* Check if we have something (and trim leading spaces). */ @@ -1632,7 +1633,7 @@ int Set_option::process_option(Instance *instance, Named_value *option) bool Unset_option::parse_args(const char **text) { - uint len; + size_t len; /* Check if we have something (and trim leading spaces). */ diff --git a/server-tools/instance-manager/instance_map.cc b/server-tools/instance-manager/instance_map.cc index 5d492fe5c11..d7328d51cfe 100644 --- a/server-tools/instance-manager/instance_map.cc +++ b/server-tools/instance-manager/instance_map.cc @@ -37,12 +37,12 @@ C_MODE_START HASH-routines: get key of instance for storing in hash. */ -static byte* get_instance_key(const byte* u, uint* len, - my_bool __attribute__((unused)) t) +static uchar* get_instance_key(const uchar* u, size_t* len, + my_bool __attribute__((unused)) t) { const Instance *instance= (const Instance *) u; *len= instance->options.instance_name.length; - return (byte *) instance->options.instance_name.str; + return (uchar *) instance->options.instance_name.str; } /** @@ -165,7 +165,7 @@ int Instance_map::process_one_option(const LEX_STRING *group, return 0; } - if (!(instance= (Instance *) hash_search(&hash, (byte *) group->str, + if (!(instance= (Instance *) hash_search(&hash, (uchar *) group->str, group->length))) { if (!(instance= new Instance())) @@ -332,7 +332,7 @@ bool Instance_map::is_there_active_instance() int Instance_map::add_instance(Instance *instance) { - return my_hash_insert(&hash, (byte *) instance); + return my_hash_insert(&hash, (uchar *) instance); } @@ -344,7 +344,7 @@ int Instance_map::add_instance(Instance *instance) int Instance_map::remove_instance(Instance *instance) { - return hash_delete(&hash, (byte *) instance); + return hash_delete(&hash, (uchar *) instance); } @@ -425,7 +425,7 @@ int Instance_map::create_instance(const LEX_STRING *instance_name, Instance * Instance_map::find(const LEX_STRING *name) { - return (Instance *) hash_search(&hash, (byte *) name->str, name->length); + return (Instance *) hash_search(&hash, (uchar *) name->str, name->length); } @@ -603,12 +603,12 @@ int create_instance_in_file(const LEX_STRING *instance_name, return ER_ACCESS_OPTION_FILE; } - if (my_write(cnf_file, (byte*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP)) || - my_write(cnf_file, (byte*)"[", 1, MYF(MY_NABP)) || - my_write(cnf_file, (byte*)instance_name->str, instance_name->length, + if (my_write(cnf_file, (uchar*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP)) || + my_write(cnf_file, (uchar*)"[", 1, MYF(MY_NABP)) || + my_write(cnf_file, (uchar*)instance_name->str, instance_name->length, MYF(MY_NABP)) || - my_write(cnf_file, (byte*)"]", 1, MYF(MY_NABP)) || - my_write(cnf_file, (byte*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP))) + my_write(cnf_file, (uchar*)"]", 1, MYF(MY_NABP)) || + my_write(cnf_file, (uchar*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP))) { log_error("Can not write to configuration file (%s): %s.", (const char *) Options::Main::config_file, @@ -631,8 +631,8 @@ int create_instance_in_file(const LEX_STRING *instance_name, option_str_len= ptr - option_str; - if (my_write(cnf_file, (byte*)option_str, option_str_len, MYF(MY_NABP)) || - my_write(cnf_file, (byte*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP))) + if (my_write(cnf_file, (uchar*)option_str, option_str_len, MYF(MY_NABP)) || + my_write(cnf_file, (uchar*)NEWLINE, NEWLINE_LEN, MYF(MY_NABP))) { log_error("Can not write to configuration file (%s): %s.", (const char *) Options::Main::config_file, diff --git a/server-tools/instance-manager/instance_options.cc b/server-tools/instance-manager/instance_options.cc index 6b23df97f7f..5665c6f8670 100644 --- a/server-tools/instance-manager/instance_options.cc +++ b/server-tools/instance-manager/instance_options.cc @@ -156,7 +156,7 @@ int Instance_options::get_default_option(char *result, size_t result_len, goto err; /* +2 eats first "--" from the option string (E.g. "--datadir") */ - rc= parse_output_and_get_value(cmd.buffer, option_name + 2, + rc= parse_output_and_get_value((char*) cmd.buffer, option_name + 2, result, result_len, GET_VALUE); err: return rc; @@ -194,7 +194,7 @@ bool Instance_options::fill_instance_version() bzero(result, MAX_VERSION_LENGTH); - if (parse_output_and_get_value(cmd.buffer, "Ver", result, + if (parse_output_and_get_value((char*) cmd.buffer, "Ver", result, MAX_VERSION_LENGTH, GET_LINE)) { log_error("Failed to get version of '%s': unexpected output.", @@ -255,7 +255,7 @@ bool Instance_options::fill_mysqld_real_path() bzero(result, FN_REFLEN); - if (parse_output_and_get_value(cmd.buffer, "Usage: ", + if (parse_output_and_get_value((char*) cmd.buffer, "Usage: ", result, FN_REFLEN, GET_LINE)) { @@ -466,13 +466,9 @@ bool Instance_options::complete_initialization() Need to copy the path to allocated memory, as convert_dirname() might need to change it */ - mysqld_path.str= - alloc_root(&alloc, strlen(Options::Main::default_mysqld_path) + 1); - + mysqld_path.str= strdup_root(&alloc, Options::Main::default_mysqld_path); if (!mysqld_path.str) return TRUE; - - strcpy(mysqld_path.str, Options::Main::default_mysqld_path); } mysqld_path.length= strlen(mysqld_path.str); diff --git a/server-tools/instance-manager/mysql_connection.cc b/server-tools/instance-manager/mysql_connection.cc index 293d90420b1..c228a680f7a 100644 --- a/server-tools/instance-manager/mysql_connection.cc +++ b/server-tools/instance-manager/mysql_connection.cc @@ -147,12 +147,12 @@ int Mysql_connection::check_connection() ulong pkt_len=0; // to hold client reply length /* buffer for the first packet */ /* packet contains: */ - char buff[MAX_VERSION_LENGTH + 1 + // server version, 0-ended - 4 + // connection id - SCRAMBLE_LENGTH + 2 + // scramble (in 2 pieces) - 18]; // server variables: flags, + uchar buff[MAX_VERSION_LENGTH + 1 + // server version, 0-ended + 4 + // connection id + SCRAMBLE_LENGTH + 2 + // scramble (in 2 pieces) + 18]; // server variables: flags, // charset number, status, - char *pos= buff; + uchar *pos= buff; ulong server_flags; memcpy(pos, mysqlmanager_version.str, mysqlmanager_version.length + 1); @@ -195,7 +195,8 @@ int Mysql_connection::check_connection() /* write connection message and read reply */ enum { MIN_HANDSHAKE_SIZE= 2 }; - if (net_write_command(&net, protocol_version, "", 0, buff, pos - buff) || + if (net_write_command(&net, protocol_version, (uchar*) "", 0, + buff, pos - buff) || (pkt_len= my_net_read(&net)) == packet_error || pkt_len < MIN_HANDSHAKE_SIZE) { @@ -211,17 +212,17 @@ int Mysql_connection::check_connection() } client_capabilities|= ((ulong) uint2korr(net.read_pos + 2)) << 16; - pos= (char*) net.read_pos + 32; + pos= net.read_pos + 32; /* At least one byte for username and one byte for password */ - if (pos >= (char*) net.read_pos + pkt_len + 2) + if (pos >= net.read_pos + pkt_len + 2) { /*TODO add user and password handling in error messages*/ net_send_error(&net, ER_HANDSHAKE_ERROR); return 1; } - const char *user= pos; + const char *user= (char*) pos; const char *password= strend(user)+1; ulong password_len= *password++; LEX_STRING user_name= { (char *) user, password - user - 2 }; diff --git a/server-tools/instance-manager/options.cc b/server-tools/instance-manager/options.cc index 74e7812ea72..7eba3187dd9 100644 --- a/server-tools/instance-manager/options.cc +++ b/server-tools/instance-manager/options.cc @@ -152,14 +152,14 @@ static struct my_option my_long_options[] = #ifndef __WIN__ { "angel-pid-file", OPT_ANGEL_PID_FILE, "Pid file for angel process.", - (gptr *) &Options::Daemon::angel_pid_file_name, - (gptr *) &Options::Daemon::angel_pid_file_name, + (uchar* *) &Options::Daemon::angel_pid_file_name, + (uchar* *) &Options::Daemon::angel_pid_file_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, #endif { "bind-address", OPT_BIND_ADDRESS, "Bind address to use for connection.", - (gptr *) &Options::Main::bind_address, - (gptr *) &Options::Main::bind_address, + (uchar* *) &Options::Main::bind_address, + (uchar* *) &Options::Main::bind_address, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "check-password-file", OPT_CHECK_PASSWORD_FILE, @@ -172,15 +172,15 @@ static struct my_option my_long_options[] = #ifndef DBUG_OFF {"debug", '#', "Debug log.", - (gptr *) &Options::Debug::config_str, - (gptr *) &Options::Debug::config_str, + (uchar* *) &Options::Debug::config_str, + (uchar* *) &Options::Debug::config_str, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif { "default-mysqld-path", OPT_MYSQLD_PATH, "Where to look for MySQL" " Server binary.", - (gptr *) &Options::Main::default_mysqld_path, - (gptr *) &Options::Main::default_mysqld_path, + (uchar* *) &Options::Main::default_mysqld_path, + (uchar* *) &Options::Main::default_mysqld_path, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0 }, { "drop-user", OPT_DROP_USER, @@ -193,8 +193,8 @@ static struct my_option my_long_options[] = #ifdef __WIN__ { "install", OPT_INSTALL_SERVICE, "Install as system service.", - (gptr *) &Options::Service::install_as_service, - (gptr *) &Options::Service::install_as_service, + (uchar* *) &Options::Service::install_as_service, + (uchar* *) &Options::Service::install_as_service, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0 }, #endif @@ -204,22 +204,22 @@ static struct my_option my_long_options[] = #ifndef __WIN__ { "log", OPT_LOG, "Path to log file. Used only with --run-as-service.", - (gptr *) &Options::Daemon::log_file_name, - (gptr *) &Options::Daemon::log_file_name, + (uchar* *) &Options::Daemon::log_file_name, + (uchar* *) &Options::Daemon::log_file_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, #endif { "monitoring-interval", OPT_MONITORING_INTERVAL, "Interval to monitor" " instances in seconds.", - (gptr *) &Options::Main::monitoring_interval, - (gptr *) &Options::Main::monitoring_interval, + (uchar* *) &Options::Main::monitoring_interval, + (uchar* *) &Options::Main::monitoring_interval, 0, GET_UINT, REQUIRED_ARG, DEFAULT_MONITORING_INTERVAL, 0, 0, 0, 0, 0 }, { "mysqld-safe-compatible", OPT_MYSQLD_SAFE_COMPATIBLE, "Start Instance Manager in mysqld_safe compatible manner", - (gptr *) &Options::Main::mysqld_safe_compatible, - (gptr *) &Options::Main::mysqld_safe_compatible, + (uchar* *) &Options::Main::mysqld_safe_compatible, + (uchar* *) &Options::Main::mysqld_safe_compatible, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0 }, { "print-password-line", OPT_PRINT_PASSWORD_LINE, @@ -227,61 +227,61 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "password", OPT_PASSWORD, "Password to update the password file", - (gptr *) &Options::User_management::password, - (gptr *) &Options::User_management::password, + (uchar* *) &Options::User_management::password, + (uchar* *) &Options::User_management::password, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "password-file", OPT_PASSWORD_FILE, "Look for Instance Manager users and passwords here.", - (gptr *) &Options::Main::password_file_name, - (gptr *) &Options::Main::password_file_name, + (uchar* *) &Options::Main::password_file_name, + (uchar* *) &Options::Main::password_file_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "pid-file", OPT_PID_FILE, "Pid file to use.", - (gptr *) &Options::Main::pid_file_name, - (gptr *) &Options::Main::pid_file_name, + (uchar* *) &Options::Main::pid_file_name, + (uchar* *) &Options::Main::pid_file_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "port", OPT_PORT, "Port number to use for connections", - (gptr *) &Options::Main::port_number, - (gptr *) &Options::Main::port_number, + (uchar* *) &Options::Main::port_number, + (uchar* *) &Options::Main::port_number, 0, GET_UINT, REQUIRED_ARG, DEFAULT_PORT, 0, 0, 0, 0, 0 }, #ifdef __WIN__ { "remove", OPT_REMOVE_SERVICE, "Remove system service.", - (gptr *) &Options::Service::remove_service, - (gptr *) &Options::Service::remove_service, + (uchar* *) &Options::Service::remove_service, + (uchar* *) &Options::Service::remove_service, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0}, #else { "run-as-service", OPT_RUN_AS_SERVICE, "Daemonize and start angel process.", - (gptr *) &Options::Daemon::run_as_service, + (uchar* *) &Options::Daemon::run_as_service, 0, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0 }, #endif #ifndef __WIN__ { "socket", OPT_SOCKET, "Socket file to use for connection.", - (gptr *) &Options::Main::socket_file_name, - (gptr *) &Options::Main::socket_file_name, + (uchar* *) &Options::Main::socket_file_name, + (uchar* *) &Options::Main::socket_file_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, #endif #ifdef __WIN__ { "standalone", OPT_STAND_ALONE, "Run the application in stand alone mode.", - (gptr *) &Options::Service::stand_alone, - (gptr *) &Options::Service::stand_alone, + (uchar* *) &Options::Service::stand_alone, + (uchar* *) &Options::Service::stand_alone, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 0, 0}, #else { "user", OPT_USER, "Username to start mysqlmanager", - (gptr *) &Options::Daemon::user, - (gptr *) &Options::Daemon::user, + (uchar* *) &Options::Daemon::user, + (uchar* *) &Options::Daemon::user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, #endif { "username", OPT_USERNAME, "Username to update the password file", - (gptr *) &Options::User_management::user_name, - (gptr *) &Options::User_management::user_name, + (uchar* *) &Options::User_management::user_name, + (uchar* *) &Options::User_management::user_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "version", 'V', "Output version information and exit.", 0, 0, 0, @@ -289,8 +289,8 @@ static struct my_option my_long_options[] = { "wait-timeout", OPT_WAIT_TIMEOUT, "The number of seconds IM waits " "for activity on a connection before closing it.", - (gptr *) &net_read_timeout, - (gptr *) &net_read_timeout, + (uchar* *) &net_read_timeout, + (uchar* *) &net_read_timeout, 0, GET_ULONG, REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0 } diff --git a/server-tools/instance-manager/parse.cc b/server-tools/instance-manager/parse.cc index 3995a265e96..cd20e3bc7ab 100644 --- a/server-tools/instance-manager/parse.cc +++ b/server-tools/instance-manager/parse.cc @@ -105,7 +105,7 @@ Named_value_arr::~Named_value_arr() TOK_NOT_FOUND */ -inline Token find_token(const char *word, uint word_len) +inline Token find_token(const char *word, size_t word_len) { int i= 0; do @@ -119,7 +119,7 @@ inline Token find_token(const char *word, uint word_len) } -Token get_token(const char **text, uint *word_len) +Token get_token(const char **text, size_t *word_len) { get_word(text, word_len); if (*word_len) @@ -128,7 +128,7 @@ Token get_token(const char **text, uint *word_len) } -Token shift_token(const char **text, uint *word_len) +Token shift_token(const char **text, size_t *word_len) { Token save= get_token(text, word_len); (*text)+= *word_len; @@ -157,7 +157,7 @@ static bool parse_long(const LEX_STRING *token, long *value) } -bool parse_option_value(const char *text, uint *text_len, char **value) +bool parse_option_value(const char *text, size_t *text_len, char **value) { char beginning_quote; const char *text_start_ptr; @@ -270,7 +270,7 @@ void skip_spaces(const char **text) Command *parse_command(const char *text) { - uint word_len; + size_t word_len; LEX_STRING instance_name; Command *command= 0; diff --git a/server-tools/instance-manager/parse.h b/server-tools/instance-manager/parse.h index 02bb81749f0..00f7aa237b8 100644 --- a/server-tools/instance-manager/parse.h +++ b/server-tools/instance-manager/parse.h @@ -30,7 +30,7 @@ enum Log_type Command *parse_command(const char *text); -bool parse_option_value(const char *text, uint *text_len, char **value); +bool parse_option_value(const char *text, size_t *text_len, char **value); void skip_spaces(const char **text); @@ -138,7 +138,7 @@ inline Named_value Named_value_arr::get_element(int idx) const DBUG_ASSERT(0 <= idx && (uint) idx < arr.elements); Named_value option; - get_dynamic((DYNAMIC_ARRAY *) &arr, (gptr) &option, idx); + get_dynamic((DYNAMIC_ARRAY *) &arr, (uchar*) &option, idx); return option; } @@ -156,7 +156,7 @@ inline void Named_value_arr::remove_element(int idx) inline bool Named_value_arr::add_element(Named_value *option) { - return insert_dynamic(&arr, (gptr) option); + return insert_dynamic(&arr, (uchar*) option); } @@ -166,7 +166,7 @@ inline bool Named_value_arr::replace_element(int idx, Named_value *option) get_element(idx).free(); - return set_dynamic(&arr, (gptr) option, idx); + return set_dynamic(&arr, (uchar*) option, idx); } /************************************************************************/ @@ -177,7 +177,7 @@ inline bool Named_value_arr::replace_element(int idx, Named_value *option) if not found returns pointer to first non-space or to '\0', word_len == 0 */ -inline void get_word(const char **text, uint *word_len, +inline void get_word(const char **text, size_t *word_len, enum_seek_method seek_method= ALPHANUM) { const char *word_end; diff --git a/server-tools/instance-manager/protocol.cc b/server-tools/instance-manager/protocol.cc index 05099b59064..8d71fcb8026 100644 --- a/server-tools/instance-manager/protocol.cc +++ b/server-tools/instance-manager/protocol.cc @@ -21,7 +21,7 @@ #include <m_string.h> -static char eof_buff[1]= { (char) 254 }; /* Marker for end of fields */ +static uchar eof_buff[1]= { (char) 254 }; /* Marker for end of fields */ static const char ERROR_PACKET_CODE= (char) 255; @@ -38,7 +38,7 @@ int net_send_ok(struct st_net *net, unsigned long connection_id, 1-9 + message length message to send (isn't stored if no message) */ Buffer buff; - char *pos= buff.buffer; + uchar *pos= buff.buffer; /* check that we have space to hold mandatory fields */ buff.reserve(0, 23); @@ -53,7 +53,7 @@ int net_send_ok(struct st_net *net, unsigned long connection_id, int2store(pos, 0); pos+= 2; - uint position= pos - buff.buffer; /* we might need it for message */ + size_t position= pos - buff.buffer; /* we might need it for message */ if (message != NULL) { @@ -82,7 +82,8 @@ int net_send_error(struct st_net *net, uint sql_errno) memcpy(pos, errno_to_sqlstate(sql_errno), SQLSTATE_LENGTH); pos+= SQLSTATE_LENGTH; pos= strmake(pos, err, MYSQL_ERRMSG_SIZE - 1) + 1; - return my_net_write(net, buff, pos - buff) || net_flush(net); + return (my_net_write(net, (uchar*) buff, (size_t) (pos - buff)) || + net_flush(net)); } @@ -98,7 +99,8 @@ int net_send_error_323(struct st_net *net, uint sql_errno) int2store(pos, sql_errno); pos+= 2; pos= strmake(pos, err, MYSQL_ERRMSG_SIZE - 1) + 1; - return my_net_write(net, buff, pos - buff) || net_flush(net); + return (my_net_write(net, (uchar*) buff, (size_t) (pos - buff)) || + net_flush(net)); } char *net_store_length(char *pkg, uint length) @@ -115,8 +117,8 @@ char *net_store_length(char *pkg, uint length) } -int store_to_protocol_packet(Buffer *buf, const char *string, uint *position, - uint string_len) +int store_to_protocol_packet(Buffer *buf, const char *string, size_t *position, + size_t string_len) { uint currpos; @@ -135,9 +137,10 @@ err: } -int store_to_protocol_packet(Buffer *buf, const char *string, uint *position) +int store_to_protocol_packet(Buffer *buf, const char *string, + size_t *position) { - uint string_len; + size_t string_len; string_len= strlen(string); return store_to_protocol_packet(buf, string, position, string_len); @@ -153,15 +156,16 @@ int send_eof(struct st_net *net) buff[0]=254; int2store(buff+1, 0); int2store(buff+3, 0); - return my_net_write(net, (char*) buff, sizeof buff); + return my_net_write(net, buff, sizeof(buff)); } + int send_fields(struct st_net *net, LIST *fields) { LIST *tmp= fields; Buffer send_buff; - char small_buff[4]; - uint position= 0; + uchar small_buff[4]; + size_t position= 0; LEX_STRING *field; /* send the number of fileds */ diff --git a/server-tools/instance-manager/protocol.h b/server-tools/instance-manager/protocol.h index 520b6d4c92c..b06ae4dfdb2 100644 --- a/server-tools/instance-manager/protocol.h +++ b/server-tools/instance-manager/protocol.h @@ -36,10 +36,11 @@ int send_fields(struct st_net *net, LIST *fields); char *net_store_length(char *pkg, uint length); -int store_to_protocol_packet(Buffer *buf, const char *string, uint *position); +int store_to_protocol_packet(Buffer *buf, const char *string, + size_t *position); -int store_to_protocol_packet(Buffer *buf, const char *string, uint *position, - uint string_len); +int store_to_protocol_packet(Buffer *buf, const char *string, size_t *position, + size_t string_len); int send_eof(struct st_net *net); diff --git a/server-tools/instance-manager/user_map.cc b/server-tools/instance-manager/user_map.cc index 832a8cee6b9..49c35c16ca9 100644 --- a/server-tools/instance-manager/user_map.cc +++ b/server-tools/instance-manager/user_map.cc @@ -97,12 +97,12 @@ int User::init(const char *line) C_MODE_START -static byte* get_user_key(const byte* u, uint* len, - my_bool __attribute__((unused)) t) +static uchar* get_user_key(const uchar* u, size_t* len, + my_bool __attribute__((unused)) t) { const User *user= (const User *) u; *len= user->user_length; - return (byte *) user->user; + return (uchar *) user->user; } static void delete_user(void *u) @@ -133,7 +133,7 @@ int User_map::init() { enum { START_HASH_SIZE= 16 }; if (hash_init(&hash, default_charset_info, START_HASH_SIZE, 0, 0, - get_user_key, delete_user, 0)) + get_user_key, delete_user, 0)) return 1; initialized= TRUE; @@ -274,7 +274,7 @@ int User_map::load(const char *password_file_name, const char **err_msg) return ERR_PASSWORD_FILE_CORRUPTED; } - if (my_hash_insert(&hash, (byte *) user)) + if (my_hash_insert(&hash, (uchar *) user)) { delete user; my_fclose(file, MYF(0)); @@ -374,7 +374,7 @@ int User_map::authenticate(const LEX_STRING *user_name, User *User_map::find_user(const LEX_STRING *user_name) { - return (User*) hash_search(&hash, (byte*) user_name->str, user_name->length); + return (User*) hash_search(&hash, (uchar*) user_name->str, user_name->length); } const User *User_map::find_user(const LEX_STRING *user_name) const @@ -385,11 +385,11 @@ const User *User_map::find_user(const LEX_STRING *user_name) const bool User_map::add_user(User *user) { - return my_hash_insert(&hash, (byte*) user) == 0 ? FALSE : TRUE; + return my_hash_insert(&hash, (uchar*) user) == 0 ? FALSE : TRUE; } bool User_map::remove_user(User *user) { - return hash_delete(&hash, (byte*) user) == 0 ? FALSE : TRUE; + return hash_delete(&hash, (uchar*) user) == 0 ? FALSE : TRUE; } diff --git a/sql-common/client.c b/sql-common/client.c index 2c09498d8f4..2753317b053 100644 --- a/sql-common/client.c +++ b/sql-common/client.c @@ -644,14 +644,14 @@ void free_rows(MYSQL_DATA *cur) if (cur) { free_root(&cur->alloc,MYF(0)); - my_free((gptr) cur,MYF(0)); + my_free((uchar*) cur,MYF(0)); } } my_bool cli_advanced_command(MYSQL *mysql, enum enum_server_command command, - const char *header, ulong header_length, - const char *arg, ulong arg_length, my_bool skip_check, + const uchar *header, ulong header_length, + const uchar *arg, ulong arg_length, my_bool skip_check, MYSQL_STMT *stmt __attribute__((unused))) { NET *net= &mysql->net; @@ -914,8 +914,8 @@ mysql_free_result(MYSQL_RES *result) if (result->fields) free_root(&result->field_alloc,MYF(0)); if (result->row) - my_free((gptr) result->row,MYF(0)); - my_free((gptr) result,MYF(0)); + my_free((uchar*) result->row,MYF(0)); + my_free((uchar*) result,MYF(0)); } DBUG_VOID_RETURN; } @@ -958,7 +958,7 @@ static int add_init_command(struct st_mysql_options *options, const char *cmd) } if (!(tmp= my_strdup(cmd,MYF(MY_WME))) || - insert_dynamic(options->init_commands, (gptr)&tmp)) + insert_dynamic(options->init_commands, (uchar*)&tmp)) { my_free(tmp, MYF(MY_ALLOW_ZERO_PTR)); return 1; @@ -1170,7 +1170,7 @@ static void cli_fetch_lengths(ulong *to, MYSQL_ROW column, unsigned int field_count) { ulong *prev_length; - byte *start=0; + char *start=0; MYSQL_ROW end; prev_length=0; /* Keep gcc happy */ @@ -1589,7 +1589,7 @@ mysql_ssl_free(MYSQL *mysql __attribute__((unused))) */ const char * STDCALL -mysql_get_ssl_cipher(MYSQL *mysql) +mysql_get_ssl_cipher(MYSQL *mysql __attribute__((unused))) { DBUG_ENTER("mysql_get_ssl_cipher"); #ifdef HAVE_OPENSSL @@ -2575,7 +2575,7 @@ static void mysql_close_free_options(MYSQL *mysql) static void mysql_close_free(MYSQL *mysql) { - my_free((gptr) mysql->host_info,MYF(MY_ALLOW_ZERO_PTR)); + my_free((uchar*) mysql->host_info,MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->user,MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->passwd,MYF(MY_ALLOW_ZERO_PTR)); my_free(mysql->db,MYF(MY_ALLOW_ZERO_PTR)); @@ -2665,7 +2665,7 @@ void STDCALL mysql_close(MYSQL *mysql) (*mysql->methods->free_embedded_thd)(mysql); #endif if (mysql->free_me) - my_free((gptr) mysql,MYF(0)); + my_free((uchar*) mysql,MYF(0)); } DBUG_VOID_RETURN; } @@ -2818,7 +2818,7 @@ MYSQL_RES * STDCALL mysql_store_result(MYSQL *mysql) if (!(result->data= (*mysql->methods->read_rows)(mysql,mysql->fields,mysql->field_count))) { - my_free((gptr) result,MYF(0)); + my_free((uchar*) result,MYF(0)); DBUG_RETURN(0); } mysql->affected_rows= result->row_count= result->data->rows; @@ -2868,7 +2868,7 @@ static MYSQL_RES * cli_use_result(MYSQL *mysql) if (!(result->row=(MYSQL_ROW) my_malloc(sizeof(result->row[0])*(mysql->field_count+1), MYF(MY_WME)))) { /* Ptrs: to one row */ - my_free((gptr) result,MYF(0)); + my_free((uchar*) result,MYF(0)); DBUG_RETURN(0); } result->fields= mysql->fields; diff --git a/sql-common/my_user.c b/sql-common/my_user.c index fa5b80413bf..16a544387ee 100644 --- a/sql-common/my_user.c +++ b/sql-common/my_user.c @@ -31,9 +31,9 @@ host_name_len [OUT] A place to store length of the host name part. */ -void parse_user(const char *user_id_str, uint user_id_len, - char *user_name_str, uint *user_name_len, - char *host_name_str, uint *host_name_len) +void parse_user(const char *user_id_str, size_t user_id_len, + char *user_name_str, size_t *user_name_len, + char *host_name_str, size_t *host_name_len) { char *p= strrchr(user_id_str, '@'); diff --git a/sql-common/pack.c b/sql-common/pack.c index 33c1103fb04..f6cda4e5b86 100644 --- a/sql-common/pack.c +++ b/sql-common/pack.c @@ -94,10 +94,8 @@ my_ulonglong net_field_length_ll(uchar **packet) Position in 'pkg' after the packed length */ -char * -net_store_length(char *pkg, ulonglong length) +uchar *net_store_length(uchar *packet, ulonglong length) { - uchar *packet=(uchar*) pkg; if (length < (ulonglong) LL(251)) { *packet=(uchar) length; diff --git a/sql/derror.cc b/sql/derror.cc index eca553d1bf8..3b67e0f5bf0 100644 --- a/sql/derror.cc +++ b/sql/derror.cc @@ -65,7 +65,7 @@ bool init_errmessage(void) /* Register messages for use with my_error(). */ if (my_error_register(errmsgs, ER_ERROR_FIRST, ER_ERROR_LAST)) { - x_free((gptr) errmsgs); + x_free((uchar*) errmsgs); DBUG_RETURN(TRUE); } @@ -81,11 +81,13 @@ static bool read_texts(const char *file_name,const char ***point, uint error_messages) { register uint i; - uint count,funktpos,length,textcount; + uint count,funktpos,textcount; + size_t length; File file; char name[FN_REFLEN]; - const char *buff; + uchar *buff; uchar head[32],*pos; + const char *errmsg; DBUG_ENTER("read_texts"); LINT_INIT(buff); @@ -96,7 +98,7 @@ static bool read_texts(const char *file_name,const char ***point, goto err; /* purecov: inspected */ funktpos=1; - if (my_read(file,(byte*) head,32,MYF(MY_NABP))) goto err; + if (my_read(file,(uchar*) head,32,MYF(MY_NABP))) goto err; if (head[0] != (uchar) 254 || head[1] != (uchar) 254 || head[2] != 2 || head[3] != 1) goto err; /* purecov: inspected */ @@ -130,22 +132,24 @@ Check that the above file is the right version for this program!", DBUG_RETURN(1); } - x_free((gptr) *point); /* Free old language */ + x_free((uchar*) *point); /* Free old language */ if (!(*point= (const char**) - my_malloc((uint) (length+count*sizeof(char*)),MYF(0)))) + my_malloc((size_t) (length+count*sizeof(char*)),MYF(0)))) { funktpos=2; /* purecov: inspected */ goto err; /* purecov: inspected */ } - buff= (char*) (*point + count); + buff= (uchar*) (*point + count); - if (my_read(file,(byte*) buff,(uint) count*2,MYF(MY_NABP))) goto err; - for (i=0, pos= (uchar*) buff ; i< count ; i++) + if (my_read(file, buff, (size_t) count*2,MYF(MY_NABP))) + goto err; + for (i=0, pos= buff ; i< count ; i++) { - (*point)[i]=buff+uint2korr(pos); + (*point)[i]= (char*) buff+uint2korr(pos); pos+=2; } - if (my_read(file,(byte*) buff,(uint) length,MYF(MY_NABP))) goto err; + if (my_read(file, buff, length, MYF(MY_NABP))) + goto err; for (i=1 ; i < textcount ; i++) { @@ -157,16 +161,16 @@ Check that the above file is the right version for this program!", err: switch (funktpos) { case 2: - buff="Not enough memory for messagefile '%s'"; + errmsg= "Not enough memory for messagefile '%s'"; break; case 1: - buff="Can't read from messagefile '%s'"; + errmsg= "Can't read from messagefile '%s'"; break; default: - buff="Can't find messagefile '%s'"; + errmsg= "Can't find messagefile '%s'"; break; } - sql_print_error(buff,name); + sql_print_error(errmsg, name); err1: if (file != FERR) VOID(my_close(file,MYF(MY_WME))); diff --git a/sql/discover.cc b/sql/discover.cc index 395bfbfff45..a7af90c440f 100644 --- a/sql/discover.cc +++ b/sql/discover.cc @@ -39,14 +39,13 @@ frmdata and len are set to 0 on error */ -int readfrm(const char *name, - const void **frmdata, uint *len) +int readfrm(const char *name, uchar **frmdata, size_t *len) { int error; char index_file[FN_REFLEN]; File file; - ulong read_len; - char *read_data; + size_t read_len; + uchar *read_data; MY_STAT state; DBUG_ENTER("readfrm"); DBUG_PRINT("enter",("name: '%s'",name)); @@ -68,12 +67,12 @@ int readfrm(const char *name, // Read whole frm file error= 3; - read_data= 0; + read_data= 0; // Nothing to free if (read_string(file, &read_data, read_len)) goto err; // Setup return data - *frmdata= (void*) read_data; + *frmdata= (uchar*) read_data; *len= read_len; error= 0; @@ -102,21 +101,20 @@ int readfrm(const char *name, 2 Could not write file */ -int writefrm(const char *name, const void *frmdata, uint len) +int writefrm(const char *name, const uchar *frmdata, size_t len) { File file; char index_file[FN_REFLEN]; int error; DBUG_ENTER("writefrm"); - DBUG_PRINT("enter",("name: '%s' len: %d ",name,len)); - //DBUG_DUMP("frmdata", (char*)frmdata, len); + DBUG_PRINT("enter",("name: '%s' len: %lu ",name, (ulong) len)); error= 0; if ((file=my_create(fn_format(index_file,name,"",reg_ext, MY_UNPACK_FILENAME|MY_APPEND_EXT), CREATE_MODE,O_RDWR | O_TRUNC,MYF(MY_WME))) >= 0) { - if (my_write(file,(byte*)frmdata,len,MYF(MY_WME | MY_NABP))) + if (my_write(file, frmdata, len,MYF(MY_WME | MY_NABP))) error= 2; VOID(my_close(file,MYF(0))); } diff --git a/sql/event_data_objects.cc b/sql/event_data_objects.cc index 86a8f264331..138752d5ce5 100644 --- a/sql/event_data_objects.cc +++ b/sql/event_data_objects.cc @@ -42,7 +42,7 @@ Event_queue_element_for_exec::init(LEX_STRING db, LEX_STRING n) return TRUE; if (!(name.str= my_strndup(n.str, name.length= n.length, MYF(MY_WME)))) { - my_free((gptr) dbname.str, MYF(0)); + my_free((uchar*) dbname.str, MYF(0)); return TRUE; } return FALSE; @@ -58,8 +58,8 @@ Event_queue_element_for_exec::init(LEX_STRING db, LEX_STRING n) Event_queue_element_for_exec::~Event_queue_element_for_exec() { - my_free((gptr) dbname.str, MYF(0)); - my_free((gptr) name.str, MYF(0)); + my_free((uchar*) dbname.str, MYF(0)); + my_free((uchar*) name.str, MYF(0)); } @@ -620,7 +620,7 @@ Event_parse_data::init_definer(THD *thd) /* + 1 for @ */ DBUG_PRINT("info",("init definer as whole")); definer.length= definer_user_len + definer_host_len + 1; - definer.str= thd->alloc(definer.length + 1); + definer.str= (char*) thd->alloc(definer.length + 1); DBUG_PRINT("info",("copy the user")); memcpy(definer.str, definer_user, definer_user_len); @@ -1636,7 +1636,7 @@ Event_queue_element::update_timing_fields(THD *thd) DBUG_ENTER("Event_queue_element::update_timing_fields"); - DBUG_PRINT("enter", ("name: %*s", name.length, name.str)); + DBUG_PRINT("enter", ("name: %*s", (int) name.length, name.str)); /* No need to update if nothing has changed */ if (!(status_changed || last_executed_changed)) @@ -1696,7 +1696,8 @@ Event_timed::get_create_event(THD *thd, String *buf) expr_buf.length(0); DBUG_ENTER("get_create_event"); - DBUG_PRINT("ret_info",("body_len=[%d]body=[%s]", body.length, body.str)); + DBUG_PRINT("ret_info",("body_len=[%d]body=[%s]", + (int) body.length, body.str)); if (expression && Events::reconstruct_interval_expression(&expr_buf, interval, expression)) diff --git a/sql/event_db_repository.cc b/sql/event_db_repository.cc index e49fd6791a0..fa17ee8a380 100644 --- a/sql/event_db_repository.cc +++ b/sql/event_db_repository.cc @@ -303,7 +303,7 @@ Event_db_repository::index_read_for_db_for_i_s(THD *thd, TABLE *schema_table, CHARSET_INFO *scs= system_charset_info; KEY *key_info; uint key_len; - byte *key_buf= NULL; + uchar *key_buf= NULL; LINT_INIT(key_buf); DBUG_ENTER("Event_db_repository::index_read_for_db_for_i_s"); @@ -324,7 +324,7 @@ Event_db_repository::index_read_for_db_for_i_s(THD *thd, TABLE *schema_table, event_table->field[ET_FIELD_DB]->store(db, strlen(db), scs); key_len= key_info->key_part[0].store_length; - if (!(key_buf= (byte *)alloc_root(thd->mem_root, key_len))) + if (!(key_buf= (uchar *)alloc_root(thd->mem_root, key_len))) { /* Don't send error, it would be done by sql_alloc_error_handler() */ ret= 1; @@ -521,7 +521,7 @@ Event_db_repository::create_event(THD *thd, Event_parse_data *parse_data, if (open_event_table(thd, TL_WRITE, &table)) goto end; - DBUG_PRINT("info", ("name: %.*s", parse_data->name.length, + DBUG_PRINT("info", ("name: %.*s", (int) parse_data->name.length, parse_data->name.str)); DBUG_PRINT("info", ("check existance of an event with the same name")); @@ -757,9 +757,9 @@ bool Event_db_repository::find_named_event(LEX_STRING db, LEX_STRING name, TABLE *table) { - byte key[MAX_KEY_LENGTH]; + uchar key[MAX_KEY_LENGTH]; DBUG_ENTER("Event_db_repository::find_named_event"); - DBUG_PRINT("enter", ("name: %.*s", name.length, name.str)); + DBUG_PRINT("enter", ("name: %.*s", (int) name.length, name.str)); /* Create key to find row. We have to use field->store() to be able to @@ -879,7 +879,8 @@ Event_db_repository::load_named_event(THD *thd, LEX_STRING dbname, bool ret; DBUG_ENTER("Event_db_repository::load_named_event"); - DBUG_PRINT("enter",("thd: 0x%lx name: %*s", (long) thd, name.length, name.str)); + DBUG_PRINT("enter",("thd: 0x%lx name: %*s", (long) thd, + (int) name.length, name.str)); if (!(ret= open_event_table(thd, TL_READ, &table))) { diff --git a/sql/event_queue.cc b/sql/event_queue.cc index 6cf5da383ea..634cc764d74 100644 --- a/sql/event_queue.cc +++ b/sql/event_queue.cc @@ -53,7 +53,7 @@ */ static int -event_queue_element_compare_q(void *vptr, byte* a, byte *b) +event_queue_element_compare_q(void *vptr, uchar* a, uchar *b) { my_time_t lhs = ((Event_queue_element *)a)->execute_at; my_time_t rhs = ((Event_queue_element *)b)->execute_at; @@ -195,7 +195,7 @@ Event_queue::create_event(THD *thd, Event_queue_element *new_element, DBUG_PRINT("info", ("new event in the queue: 0x%lx", (long) new_element)); LOCK_QUEUE_DATA(); - *created= (queue_insert_safe(&queue, (byte *) new_element) == FALSE); + *created= (queue_insert_safe(&queue, (uchar *) new_element) == FALSE); dbug_dump_queue(thd->query_start()); pthread_cond_broadcast(&COND_queue_state); UNLOCK_QUEUE_DATA(); @@ -244,7 +244,7 @@ Event_queue::update_event(THD *thd, LEX_STRING dbname, LEX_STRING name, if (new_element) { DBUG_PRINT("info", ("new event in the queue: 0x%lx", (long) new_element)); - queue_insert_safe(&queue, (byte *) new_element); + queue_insert_safe(&queue, (uchar *) new_element); pthread_cond_broadcast(&COND_queue_state); } diff --git a/sql/field.cc b/sql/field.cc index fa25871fe61..6fd88e4e1ac 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -1051,7 +1051,7 @@ bool Field::type_can_have_key_part(enum enum_field_types type) /* Numeric fields base class constructor */ -Field_num::Field_num(char *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, +Field_num::Field_num(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, utype unireg_check_arg, const char *field_name_arg, uint8 dec_arg, bool zero_arg, bool unsigned_arg) @@ -1071,9 +1071,10 @@ void Field_num::prepend_zeros(String *value) int diff; if ((diff= (int) (field_length - value->length())) > 0) { - bmove_upp((char*) value->ptr()+field_length,value->ptr()+value->length(), + bmove_upp((uchar*) value->ptr()+field_length, + (uchar*) value->ptr()+value->length(), value->length()); - bfill((char*) value->ptr(),diff,'0'); + bfill((uchar*) value->ptr(),diff,'0'); value->length(field_length); (void) value->c_ptr_quick(); // Avoid warnings in purify } @@ -1155,7 +1156,8 @@ bool Field_num::get_int(CHARSET_INFO *cs, const char *from, uint len, char *end; int error; - *rnd= (longlong) cs->cset->strntoull10rnd(cs, from, len, unsigned_flag, &end, + *rnd= (longlong) cs->cset->strntoull10rnd(cs, from, len, + unsigned_flag, &end, &error); if (unsigned_flag) { @@ -1179,7 +1181,8 @@ bool Field_num::get_int(CHARSET_INFO *cs, const char *from, uint len, goto out_of_range; } } - if (table->in_use->count_cuted_fields && check_int(cs, from, len, end, error)) + if (table->in_use->count_cuted_fields && + check_int(cs, from, len, end, error)) return 1; return 0; @@ -1296,7 +1299,7 @@ String *Field::val_int_as_str(String *val_buffer, my_bool unsigned_val) } -Field::Field(char *ptr_arg,uint32 length_arg,uchar *null_ptr_arg, +Field::Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg, uchar null_bit_arg, utype unireg_check_arg, const char *field_name_arg) :ptr(ptr_arg), null_ptr(null_ptr_arg), @@ -1323,18 +1326,17 @@ void Field::hash(ulong *nr, ulong *nr2) { uint len= pack_length(); CHARSET_INFO *cs= charset(); - cs->coll->hash_sort(cs, (uchar*) ptr, len, nr, nr2); + cs->coll->hash_sort(cs, ptr, len, nr, nr2); } } -my_size_t +size_t Field::do_last_null_byte() const { - DBUG_ASSERT(null_ptr == NULL || (byte*) null_ptr >= table->record[0]); + DBUG_ASSERT(null_ptr == NULL || null_ptr >= table->record[0]); if (null_ptr) - return (byte*) null_ptr - table->record[0] + 1; - else - return LAST_NULL_BYTE_UNDEF; + return (size_t) (null_ptr - table->record[0]) + 1; + return LAST_NULL_BYTE_UNDEF; } @@ -1488,7 +1490,7 @@ my_decimal* Field_num::val_decimal(my_decimal *decimal_value) } -Field_str::Field_str(char *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, +Field_str::Field_str(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, utype unireg_check_arg, const char *field_name_arg, CHARSET_INFO *charset_arg) :Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, @@ -1639,7 +1641,7 @@ Field *Field::new_field(MEM_ROOT *root, struct st_table *new_table, Field *Field::new_key_field(MEM_ROOT *root, struct st_table *new_table, - char *new_ptr, uchar *new_null_ptr, + uchar *new_ptr, uchar *new_null_ptr, uint new_null_bit) { Field *tmp; @@ -1693,7 +1695,7 @@ Field_decimal::reset(void) void Field_decimal::overflow(bool negative) { uint len=field_length; - char *to=ptr, filler= '9'; + uchar *to=ptr, filler= '9'; set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, ER_WARN_DATA_OUT_OF_RANGE, 1); if (negative) @@ -1729,36 +1731,37 @@ void Field_decimal::overflow(bool negative) } -int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs) +int Field_decimal::store(const char *from_arg, uint len, CHARSET_INFO *cs) { ASSERT_COLUMN_MARKED_FOR_WRITE; char buff[STRING_BUFFER_USUAL_SIZE]; String tmp(buff,sizeof(buff), &my_charset_bin); + const uchar *from= (uchar*) from_arg; - /* Convert character set if the old one is multi byte */ + /* Convert character set if the old one is multi uchar */ if (cs->mbmaxlen > 1) { uint dummy_errors; - tmp.copy(from, len, cs, &my_charset_bin, &dummy_errors); - from= tmp.ptr(); + tmp.copy((char*) from, len, cs, &my_charset_bin, &dummy_errors); + from= (uchar*) tmp.ptr(); len= tmp.length(); } - const char *end= from+len; + const uchar *end= from+len; /* The pointer where the field value starts (i.e., "where to write") */ - char *to=ptr; + uchar *to= ptr; uint tmp_dec, tmp_uint; /* The sign of the number : will be 0 (means positive but sign not specified), '+' or '-' */ - char sign_char=0; + uchar sign_char=0; /* The pointers where prezeros start and stop */ - const char *pre_zeros_from, *pre_zeros_end; + const uchar *pre_zeros_from, *pre_zeros_end; /* The pointers where digits at the left of '.' start and stop */ - const char *int_digits_from, *int_digits_end; + const uchar *int_digits_from, *int_digits_end; /* The pointers where digits at the right of '.' start and stop */ - const char *frac_digits_from, *frac_digits_end; + const uchar *frac_digits_from, *frac_digits_end; /* The sign of the exponent : will be 0 (means no exponent), '+' or '-' */ char expo_sign_char=0; uint exponent=0; // value of the exponent @@ -1766,20 +1769,20 @@ int Field_decimal::store(const char *from, uint len, CHARSET_INFO *cs) Pointers used when digits move from the left of the '.' to the right of the '.' (explained below) */ - const char *int_digits_tail_from; + const uchar *int_digits_tail_from; /* Number of 0 that need to be added at the left of the '.' (1E3: 3 zeros) */ uint int_digits_added_zeros; /* Pointer used when digits move from the right of the '.' to the left of the '.' */ - const char *frac_digits_head_end; + const uchar *frac_digits_head_end; /* Number of 0 that need to be added at the right of the '.' (for 1E-3) */ uint frac_digits_added_zeros; - char *pos,*tmp_left_pos,*tmp_right_pos; + uchar *pos,*tmp_left_pos,*tmp_right_pos; /* Pointers that are used as limits (begin and end of the field buffer) */ - char *left_wall,*right_wall; - char tmp_char; + uchar *left_wall,*right_wall; + uchar tmp_char; /* To remember if table->in_use->cuted_fields has already been incremented, to do that only once @@ -2116,17 +2119,18 @@ int Field_decimal::store(double nr) } #endif - reg4 uint i,length; - char fyllchar,*to; + reg4 uint i; + size_t length; + uchar fyllchar,*to; char buff[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE]; fyllchar = zerofill ? (char) '0' : (char) ' '; #ifdef HAVE_SNPRINTF buff[sizeof(buff)-1]=0; // Safety snprintf(buff,sizeof(buff)-1, "%.*f",(int) dec,nr); - length=(uint) strlen(buff); + length= strlen(buff); #else - length=(uint) my_sprintf(buff,(buff,"%.*f",dec,nr)); + length= my_sprintf(buff,(buff,"%.*f",dec,nr)); #endif if (length > field_length) @@ -2150,7 +2154,8 @@ int Field_decimal::store(longlong nr, bool unsigned_val) ASSERT_COLUMN_MARKED_FOR_WRITE; char buff[22]; uint length, int_part; - char fyllchar, *to; + char fyllchar; + uchar *to; if (nr < 0 && unsigned_flag && !unsigned_val) { @@ -2185,7 +2190,7 @@ double Field_decimal::val_real(void) ASSERT_COLUMN_MARKED_FOR_READ; int not_used; char *end_not_used; - return my_strntod(&my_charset_bin, ptr, field_length, &end_not_used, + return my_strntod(&my_charset_bin, (char*) ptr, field_length, &end_not_used, ¬_used); } @@ -2194,11 +2199,10 @@ longlong Field_decimal::val_int(void) ASSERT_COLUMN_MARKED_FOR_READ; int not_used; if (unsigned_flag) - return my_strntoull(&my_charset_bin, ptr, field_length, 10, NULL, - ¬_used); - else - return my_strntoll(&my_charset_bin, ptr, field_length, 10, NULL, + return my_strntoull(&my_charset_bin, (char*) ptr, field_length, 10, NULL, ¬_used); + return my_strntoll(&my_charset_bin, (char*) ptr, field_length, 10, NULL, + ¬_used); } @@ -2206,10 +2210,12 @@ String *Field_decimal::val_str(String *val_buffer __attribute__((unused)), String *val_ptr) { ASSERT_COLUMN_MARKED_FOR_READ; - char *str; + uchar *str; + size_t tmp_length; + for (str=ptr ; *str == ' ' ; str++) ; - uint tmp_length=(uint) (str-ptr); val_ptr->set_charset(&my_charset_bin); + tmp_length= (size_t) (str-ptr); if (field_length < tmp_length) // Error in data val_ptr->length(0); else @@ -2222,9 +2228,9 @@ String *Field_decimal::val_str(String *val_buffer __attribute__((unused)), ** 5.00 , -1.0, 05, -05, +5 with optional pre/end space */ -int Field_decimal::cmp(const char *a_ptr,const char *b_ptr) +int Field_decimal::cmp(const uchar *a_ptr,const uchar *b_ptr) { - const char *end; + const uchar *end; int swap=0; /* First remove prefixes '0', ' ', and '-' */ for (end=a_ptr+field_length; @@ -2255,9 +2261,9 @@ int Field_decimal::cmp(const char *a_ptr,const char *b_ptr) } -void Field_decimal::sort_string(char *to,uint length) +void Field_decimal::sort_string(uchar *to,uint length) { - char *str,*end; + uchar *str,*end; for (str=ptr,end=ptr+length; str != end && ((my_isspace(&my_charset_bin,*str) || *str == '+' || @@ -2299,7 +2305,7 @@ void Field_decimal::sql_type(String &res) const ** Field_new_decimal ****************************************************************************/ -Field_new_decimal::Field_new_decimal(char *ptr_arg, +Field_new_decimal::Field_new_decimal(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, @@ -2321,7 +2327,7 @@ Field_new_decimal::Field_new_decimal(uint32 len_arg, const char *name, uint8 dec_arg, bool unsigned_arg) - :Field_num((char*) 0, len_arg, + :Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0, NONE, name, dec_arg, 0, unsigned_arg) { @@ -2419,7 +2425,7 @@ bool Field_new_decimal::store_value(const my_decimal *decimal_value) my_decimal2binary(E_DEC_FATAL_ERROR, &buff, ptr, precision, dec); error= 1; } - DBUG_EXECUTE("info", print_decimal_buff(decimal_value, (byte *) ptr, + DBUG_EXECUTE("info", print_decimal_buff(decimal_value, (uchar *) ptr, bin_size);); DBUG_RETURN(error); } @@ -2434,8 +2440,9 @@ int Field_new_decimal::store(const char *from, uint length, DBUG_ENTER("Field_new_decimal::store(char*)"); if ((err= str2my_decimal(E_DEC_FATAL_ERROR & - ~(E_DEC_OVERFLOW | E_DEC_BAD_NUM), - from, length, charset_arg, &decimal_value)) && + ~(E_DEC_OVERFLOW | E_DEC_BAD_NUM), + from, length, charset_arg, + &decimal_value)) && table->in_use->abort_on_warning) { /* Because "from" is not NUL-terminated and we use %s in the ER() */ @@ -2584,7 +2591,7 @@ my_decimal* Field_new_decimal::val_decimal(my_decimal *decimal_value) DBUG_ENTER("Field_new_decimal::val_decimal"); binary2my_decimal(E_DEC_FATAL_ERROR, ptr, decimal_value, precision, dec); - DBUG_EXECUTE("info", print_decimal_buff(decimal_value, (byte *) ptr, + DBUG_EXECUTE("info", print_decimal_buff(decimal_value, (uchar *) ptr, bin_size);); DBUG_RETURN(decimal_value); } @@ -2602,13 +2609,13 @@ String *Field_new_decimal::val_str(String *val_buffer, } -int Field_new_decimal::cmp(const char *a,const char*b) +int Field_new_decimal::cmp(const uchar *a,const uchar*b) { return memcmp(a, b, bin_size); } -void Field_new_decimal::sort_string(char *buff, +void Field_new_decimal::sort_string(uchar *buff, uint length __attribute__((unused))) { memcpy(buff, ptr, bin_size); @@ -2743,7 +2750,7 @@ int Field_tiny::store(longlong nr, bool unsigned_val) double Field_tiny::val_real(void) { ASSERT_COLUMN_MARKED_FOR_READ; - int tmp= unsigned_flag ? (int) ((uchar*) ptr)[0] : + int tmp= unsigned_flag ? (int) ptr[0] : (int) ((signed char*) ptr)[0]; return (double) tmp; } @@ -2752,7 +2759,7 @@ double Field_tiny::val_real(void) longlong Field_tiny::val_int(void) { ASSERT_COLUMN_MARKED_FOR_READ; - int tmp= unsigned_flag ? (int) ((uchar*) ptr)[0] : + int tmp= unsigned_flag ? (int) ptr[0] : (int) ((signed char*) ptr)[0]; return (longlong) tmp; } @@ -2770,7 +2777,7 @@ String *Field_tiny::val_str(String *val_buffer, if (unsigned_flag) length= (uint) cs->cset->long10_to_str(cs,to,mlength, 10, - (long) *((uchar*) ptr)); + (long) *ptr); else length= (uint) cs->cset->long10_to_str(cs,to,mlength,-10, (long) *((signed char*) ptr)); @@ -2786,7 +2793,7 @@ bool Field_tiny::send_binary(Protocol *protocol) return protocol->store_tiny((longlong) (int8) ptr[0]); } -int Field_tiny::cmp(const char *a_ptr, const char *b_ptr) +int Field_tiny::cmp(const uchar *a_ptr, const uchar *b_ptr) { signed char a,b; a=(signed char) a_ptr[0]; b= (signed char) b_ptr[0]; @@ -2795,12 +2802,12 @@ int Field_tiny::cmp(const char *a_ptr, const char *b_ptr) return (a < b) ? -1 : (a > b) ? 1 : 0; } -void Field_tiny::sort_string(char *to,uint length __attribute__((unused))) +void Field_tiny::sort_string(uchar *to,uint length __attribute__((unused))) { if (unsigned_flag) *to= *ptr; else - to[0] = (char) ((uchar) ptr[0] ^ (uchar) 128); /* Revers signbit */ + to[0] = (char) (ptr[0] ^ (uchar) 128); /* Revers signbit */ } void Field_tiny::sql_type(String &res) const @@ -3005,7 +3012,7 @@ bool Field_short::send_binary(Protocol *protocol) } -int Field_short::cmp(const char *a_ptr, const char *b_ptr) +int Field_short::cmp(const uchar *a_ptr, const uchar *b_ptr) { short a,b; #ifdef WORDS_BIGENDIAN @@ -3027,7 +3034,7 @@ int Field_short::cmp(const char *a_ptr, const char *b_ptr) return (a < b) ? -1 : (a > b) ? 1 : 0; } -void Field_short::sort_string(char *to,uint length __attribute__((unused))) +void Field_short::sort_string(uchar *to,uint length __attribute__((unused))) { #ifdef WORDS_BIGENDIAN if (!table->s->db_low_byte_first) @@ -3213,7 +3220,7 @@ bool Field_medium::send_binary(Protocol *protocol) } -int Field_medium::cmp(const char *a_ptr, const char *b_ptr) +int Field_medium::cmp(const uchar *a_ptr, const uchar *b_ptr) { long a,b; if (unsigned_flag) @@ -3229,7 +3236,7 @@ int Field_medium::cmp(const char *a_ptr, const char *b_ptr) return (a < b) ? -1 : (a > b) ? 1 : 0; } -void Field_medium::sort_string(char *to,uint length __attribute__((unused))) +void Field_medium::sort_string(uchar *to,uint length __attribute__((unused))) { if (unsigned_flag) to[0] = ptr[2]; @@ -3440,7 +3447,7 @@ bool Field_long::send_binary(Protocol *protocol) return protocol->store_long(Field_long::val_int()); } -int Field_long::cmp(const char *a_ptr, const char *b_ptr) +int Field_long::cmp(const uchar *a_ptr, const uchar *b_ptr) { int32 a,b; #ifdef WORDS_BIGENDIAN @@ -3460,7 +3467,7 @@ int Field_long::cmp(const char *a_ptr, const char *b_ptr) return (a < b) ? -1 : (a > b) ? 1 : 0; } -void Field_long::sort_string(char *to,uint length __attribute__((unused))) +void Field_long::sort_string(uchar *to,uint length __attribute__((unused))) { #ifdef WORDS_BIGENDIAN if (!table->s->db_low_byte_first) @@ -3680,7 +3687,7 @@ bool Field_longlong::send_binary(Protocol *protocol) } -int Field_longlong::cmp(const char *a_ptr, const char *b_ptr) +int Field_longlong::cmp(const uchar *a_ptr, const uchar *b_ptr) { longlong a,b; #ifdef WORDS_BIGENDIAN @@ -3701,7 +3708,7 @@ int Field_longlong::cmp(const char *a_ptr, const char *b_ptr) return (a < b) ? -1 : (a > b) ? 1 : 0; } -void Field_longlong::sort_string(char *to,uint length __attribute__((unused))) +void Field_longlong::sort_string(uchar *to,uint length __attribute__((unused))) { #ifdef WORDS_BIGENDIAN if (!table->s->db_low_byte_first) @@ -3826,7 +3833,7 @@ int Field_float::store(double nr) } else #endif - memcpy_fixed(ptr,(byte*) &j,sizeof(j)); + memcpy_fixed(ptr,(uchar*) &j,sizeof(j)); return error; } @@ -3849,7 +3856,7 @@ double Field_float::val_real(void) } else #endif - memcpy_fixed((byte*) &j,ptr,sizeof(j)); + memcpy_fixed((uchar*) &j,ptr,sizeof(j)); return ((double) j); } @@ -3863,7 +3870,7 @@ longlong Field_float::val_int(void) } else #endif - memcpy_fixed((byte*) &j,ptr,sizeof(j)); + memcpy_fixed((uchar*) &j,ptr,sizeof(j)); return (longlong) rint(j); } @@ -3880,7 +3887,7 @@ String *Field_float::val_str(String *val_buffer, } else #endif - memcpy_fixed((byte*) &nr,ptr,sizeof(nr)); + memcpy_fixed((uchar*) &nr,ptr,sizeof(nr)); uint to_length=max(field_length,70); val_buffer->alloc(to_length); @@ -3952,7 +3959,7 @@ String *Field_float::val_str(String *val_buffer, } -int Field_float::cmp(const char *a_ptr, const char *b_ptr) +int Field_float::cmp(const uchar *a_ptr, const uchar *b_ptr) { float a,b; #ifdef WORDS_BIGENDIAN @@ -3972,7 +3979,7 @@ int Field_float::cmp(const char *a_ptr, const char *b_ptr) #define FLT_EXP_DIG (sizeof(float)*8-FLT_MANT_DIG) -void Field_float::sort_string(char *to,uint length __attribute__((unused))) +void Field_float::sort_string(uchar *to,uint length __attribute__((unused))) { float nr; #ifdef WORDS_BIGENDIAN @@ -3984,7 +3991,7 @@ void Field_float::sort_string(char *to,uint length __attribute__((unused))) #endif memcpy_fixed(&nr,ptr,sizeof(float)); - uchar *tmp= (uchar*) to; + uchar *tmp= to; if (nr == (float) 0.0) { /* Change to zero string */ tmp[0]=(uchar) 128; @@ -4284,7 +4291,7 @@ bool Field_double::send_binary(Protocol *protocol) } -int Field_double::cmp(const char *a_ptr, const char *b_ptr) +int Field_double::cmp(const uchar *a_ptr, const uchar *b_ptr) { ASSERT_COLUMN_MARKED_FOR_READ; double a,b; @@ -4308,7 +4315,7 @@ int Field_double::cmp(const char *a_ptr, const char *b_ptr) /* The following should work for IEEE */ -void Field_double::sort_string(char *to,uint length __attribute__((unused))) +void Field_double::sort_string(uchar *to,uint length __attribute__((unused))) { double nr; #ifdef WORDS_BIGENDIAN @@ -4319,7 +4326,7 @@ void Field_double::sort_string(char *to,uint length __attribute__((unused))) else #endif doubleget(nr,ptr); - change_double_for_sort(nr, (byte*) to); + change_double_for_sort(nr, to); } @@ -4384,7 +4391,7 @@ void Field_double::sql_type(String &res) const exception is different behavior of old/new timestamps during ALTER TABLE. */ -Field_timestamp::Field_timestamp(char *ptr_arg, uint32 len_arg, +Field_timestamp::Field_timestamp(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, @@ -4407,7 +4414,7 @@ Field_timestamp::Field_timestamp(char *ptr_arg, uint32 len_arg, Field_timestamp::Field_timestamp(bool maybe_null_arg, const char *field_name_arg, CHARSET_INFO *cs) - :Field_str((char*) 0, 19, maybe_null_arg ? (uchar*) "": 0, 0, + :Field_str((uchar*) 0, 19, maybe_null_arg ? (uchar*) "": 0, 0, NONE, field_name_arg, cs) { /* For 4.0 MYD and 4.0 InnoDB compatibility */ @@ -4720,7 +4727,7 @@ bool Field_timestamp::send_binary(Protocol *protocol) } -int Field_timestamp::cmp(const char *a_ptr, const char *b_ptr) +int Field_timestamp::cmp(const uchar *a_ptr, const uchar *b_ptr) { int32 a,b; #ifdef WORDS_BIGENDIAN @@ -4739,7 +4746,7 @@ int Field_timestamp::cmp(const char *a_ptr, const char *b_ptr) } -void Field_timestamp::sort_string(char *to,uint length __attribute__((unused))) +void Field_timestamp::sort_string(uchar *to,uint length __attribute__((unused))) { #ifdef WORDS_BIGENDIAN if (!table || !table->s->db_low_byte_first) @@ -5021,7 +5028,7 @@ bool Field_time::send_binary(Protocol *protocol) } -int Field_time::cmp(const char *a_ptr, const char *b_ptr) +int Field_time::cmp(const uchar *a_ptr, const uchar *b_ptr) { int32 a,b; a=(int32) sint3korr(a_ptr); @@ -5029,7 +5036,7 @@ int Field_time::cmp(const char *a_ptr, const char *b_ptr) return (a < b) ? -1 : (a > b) ? 1 : 0; } -void Field_time::sort_string(char *to,uint length __attribute__((unused))) +void Field_time::sort_string(uchar *to,uint length __attribute__((unused))) { to[0] = (uchar) (ptr[2] ^ 128); to[1] = ptr[1]; @@ -5133,7 +5140,7 @@ double Field_year::val_real(void) longlong Field_year::val_int(void) { ASSERT_COLUMN_MARKED_FOR_READ; - int tmp= (int) ((uchar*) ptr)[0]; + int tmp= (int) ptr[0]; if (field_length != 4) tmp%=100; // Return last 2 char else if (tmp) @@ -5327,7 +5334,7 @@ String *Field_date::val_str(String *val_buffer, } -int Field_date::cmp(const char *a_ptr, const char *b_ptr) +int Field_date::cmp(const uchar *a_ptr, const uchar *b_ptr) { int32 a,b; #ifdef WORDS_BIGENDIAN @@ -5346,7 +5353,7 @@ int Field_date::cmp(const char *a_ptr, const char *b_ptr) } -void Field_date::sort_string(char *to,uint length __attribute__((unused))) +void Field_date::sort_string(uchar *to,uint length __attribute__((unused))) { #ifdef WORDS_BIGENDIAN if (!table || !table->s->db_low_byte_first) @@ -5578,7 +5585,7 @@ bool Field_newdate::get_time(MYSQL_TIME *ltime) } -int Field_newdate::cmp(const char *a_ptr, const char *b_ptr) +int Field_newdate::cmp(const uchar *a_ptr, const uchar *b_ptr) { uint32 a,b; a=(uint32) uint3korr(a_ptr); @@ -5587,7 +5594,7 @@ int Field_newdate::cmp(const char *a_ptr, const char *b_ptr) } -void Field_newdate::sort_string(char *to,uint length __attribute__((unused))) +void Field_newdate::sort_string(uchar *to,uint length __attribute__((unused))) { to[0] = ptr[2]; to[1] = ptr[1]; @@ -5843,7 +5850,7 @@ bool Field_datetime::get_time(MYSQL_TIME *ltime) return Field_datetime::get_date(ltime,0); } -int Field_datetime::cmp(const char *a_ptr, const char *b_ptr) +int Field_datetime::cmp(const uchar *a_ptr, const uchar *b_ptr) { longlong a,b; #ifdef WORDS_BIGENDIAN @@ -5862,7 +5869,7 @@ int Field_datetime::cmp(const char *a_ptr, const char *b_ptr) ((ulonglong) a > (ulonglong) b) ? 1 : 0; } -void Field_datetime::sort_string(char *to,uint length __attribute__((unused))) +void Field_datetime::sort_string(uchar *to,uint length __attribute__((unused))) { #ifdef WORDS_BIGENDIAN if (!table || !table->s->db_low_byte_first) @@ -6013,7 +6020,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) DBUG_ASSERT(table->in_use == current_thd); copy_length= well_formed_copy_nchars(field_charset, - ptr, field_length, + (char*) ptr, field_length, cs, from, length, field_length / field_charset->mbmaxlen, &well_formed_error_pos, @@ -6022,7 +6029,7 @@ int Field_string::store(const char *from,uint length,CHARSET_INFO *cs) /* Append spaces if the string was shorter than the field. */ if (copy_length < field_length) - field_charset->cset->fill(field_charset,ptr+copy_length, + field_charset->cset->fill(field_charset,(char*) ptr+copy_length, field_length-copy_length, field_charset->pad_char); @@ -6089,7 +6096,7 @@ int Field_str::store(double nr) like inserting 500.0 in char(1) */ DBUG_ASSERT(local_char_length < 5 || length <= local_char_length+1); - return store((const char *) buff, length, charset()); + return store(buff, length, charset()); } @@ -6149,14 +6156,15 @@ double Field_string::val_real(void) CHARSET_INFO *cs= charset(); double result; - result= my_strntod(cs,ptr,field_length,&end,&error); + result= my_strntod(cs,(char*) ptr,field_length,&end,&error); if (!table->in_use->no_errors && - (error || (field_length != (uint32)(end - ptr) && - !check_if_only_end_space(cs, end, ptr + field_length)))) + (error || (field_length != (uint32)(end - (char*) ptr) && + !check_if_only_end_space(cs, end, + (char*) ptr + field_length)))) { char buf[DOUBLE_TO_STRING_CONVERSION_BUFFER_SIZE]; String tmp(buf, sizeof(buf), cs); - tmp.copy(ptr, field_length, cs); + tmp.copy((char*) ptr, field_length, cs); push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_TRUNCATED_WRONG_VALUE, ER(ER_TRUNCATED_WRONG_VALUE), @@ -6174,14 +6182,15 @@ longlong Field_string::val_int(void) CHARSET_INFO *cs= charset(); longlong result; - result= my_strntoll(cs,ptr,field_length,10,&end,&error); + result= my_strntoll(cs, (char*) ptr,field_length,10,&end,&error); if (!table->in_use->no_errors && - (error || (field_length != (uint32)(end - ptr) && - !check_if_only_end_space(cs, end, ptr + field_length)))) + (error || (field_length != (uint32)(end - (char*) ptr) && + !check_if_only_end_space(cs, end, + (char*) ptr + field_length)))) { char buf[LONGLONG_TO_STRING_CONVERSION_BUFFER_SIZE]; String tmp(buf, sizeof(buf), cs); - tmp.copy(ptr, field_length, cs); + tmp.copy((char*) ptr, field_length, cs); push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_TRUNCATED_WRONG_VALUE, ER(ER_TRUNCATED_WRONG_VALUE), @@ -6195,9 +6204,15 @@ String *Field_string::val_str(String *val_buffer __attribute__((unused)), String *val_ptr) { ASSERT_COLUMN_MARKED_FOR_READ; - uint length= field_charset->cset->lengthsp(field_charset, ptr, field_length); /* See the comment for Field_long::store(long long) */ DBUG_ASSERT(table->in_use == current_thd); + uint length; + if (table->in_use->variables.sql_mode & + MODE_PAD_CHAR_TO_FULL_LENGTH) + length= my_charpos(field_charset, ptr, ptr + field_length, field_length); + else + length= field_charset->cset->lengthsp(field_charset, (const char*) ptr, + field_length); val_ptr->set((const char*) ptr, length, field_charset); return val_ptr; } @@ -6206,14 +6221,14 @@ String *Field_string::val_str(String *val_buffer __attribute__((unused)), my_decimal *Field_string::val_decimal(my_decimal *decimal_value) { ASSERT_COLUMN_MARKED_FOR_READ; - int err= str2my_decimal(E_DEC_FATAL_ERROR, ptr, field_length, charset(), - decimal_value); + int err= str2my_decimal(E_DEC_FATAL_ERROR, (char*) ptr, field_length, + charset(), decimal_value); if (!table->in_use->no_errors && err) { char buf[DECIMAL_TO_STRING_CONVERSION_BUFFER_SIZE]; CHARSET_INFO *cs= charset(); String tmp(buf, sizeof(buf), cs); - tmp.copy(ptr, field_length, cs); + tmp.copy((char*) ptr, field_length, cs); push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, ER_TRUNCATED_WRONG_VALUE, ER(ER_TRUNCATED_WRONG_VALUE), @@ -6224,7 +6239,7 @@ my_decimal *Field_string::val_decimal(my_decimal *decimal_value) } -int Field_string::cmp(const char *a_ptr, const char *b_ptr) +int Field_string::cmp(const uchar *a_ptr, const uchar *b_ptr) { uint a_len, b_len; @@ -6241,17 +6256,17 @@ int Field_string::cmp(const char *a_ptr, const char *b_ptr) like in latin_de 'ae' and 0xe4 */ return field_charset->coll->strnncollsp(field_charset, - (const uchar*) a_ptr, a_len, - (const uchar*) b_ptr, b_len, + a_ptr, a_len, + b_ptr, b_len, 0); } -void Field_string::sort_string(char *to,uint length) +void Field_string::sort_string(uchar *to,uint length) { IF_DBUG(uint tmp=) my_strnxfrm(field_charset, - (uchar*) to, length, - (uchar*) ptr, field_length); + to, length, + ptr, field_length); DBUG_ASSERT(tmp == length); } @@ -6276,7 +6291,7 @@ void Field_string::sql_type(String &res) const } -char *Field_string::pack(char *to, const char *from, uint max_length) +uchar *Field_string::pack(uchar *to, const uchar *from, uint max_length) { uint length= min(field_length,max_length); uint local_char_length= max_length/field_charset->mbmaxlen; @@ -6286,15 +6301,15 @@ char *Field_string::pack(char *to, const char *from, uint max_length) set_if_smaller(length, local_char_length); while (length && from[length-1] == ' ') length--; - *to++= (char) (uchar) length; + *to++= (uchar) length; if (field_length > 255) - *to++= (char) (uchar) (length >> 8); + *to++= (uchar) (length >> 8); memcpy(to, from, length); return to+length; } -const char *Field_string::unpack(char *to, const char *from) +const uchar *Field_string::unpack(uchar *to, const uchar *from) { uint length; if (field_length > 255) @@ -6303,7 +6318,7 @@ const char *Field_string::unpack(char *to, const char *from) from+= 2; } else - length= (uint) (uchar) *from++; + length= (uint) *from++; memcpy(to, from, (int) length); bfill(to+length, field_length - length, ' '); return from+length; @@ -6326,7 +6341,7 @@ const char *Field_string::unpack(char *to, const char *from) > 0 a > b */ -int Field_string::pack_cmp(const char *a, const char *b, uint length, +int Field_string::pack_cmp(const uchar *a, const uchar *b, uint length, my_bool insert_or_update) { uint a_length, b_length; @@ -6339,12 +6354,12 @@ int Field_string::pack_cmp(const char *a, const char *b, uint length, } else { - a_length= (uint) (uchar) *a++; - b_length= (uint) (uchar) *b++; + a_length= (uint) *a++; + b_length= (uint) *b++; } return field_charset->coll->strnncollsp(field_charset, - (const uchar*) a, a_length, - (const uchar*) b, b_length, + a, a_length, + b, b_length, insert_or_update); } @@ -6364,18 +6379,18 @@ int Field_string::pack_cmp(const char *a, const char *b, uint length, > 0 row > key */ -int Field_string::pack_cmp(const char *key, uint length, +int Field_string::pack_cmp(const uchar *key, uint length, my_bool insert_or_update) { uint row_length, local_key_length; - char *end; + uchar *end; if (length > 255) { local_key_length= uint2korr(key); key+= 2; } else - local_key_length= (uint) (uchar) *key++; + local_key_length= (uint) *key++; /* Only use 'length' of key, not field_length */ end= ptr + length; @@ -6384,17 +6399,17 @@ int Field_string::pack_cmp(const char *key, uint length, row_length= (uint) (end - ptr); return field_charset->coll->strnncollsp(field_charset, - (const uchar*) ptr, row_length, - (const uchar*) key, local_key_length, + ptr, row_length, + key, local_key_length, insert_or_update); } -uint Field_string::packed_col_length(const char *data_ptr, uint length) +uint Field_string::packed_col_length(const uchar *data_ptr, uint length) { if (length > 255) return uint2korr(data_ptr)+2; - return (uint) ((uchar) *data_ptr)+1; + return (uint) *data_ptr + 1; } @@ -6403,9 +6418,11 @@ uint Field_string::max_packed_col_length(uint max_length) return (max_length > 255 ? 2 : 1)+max_length; } -uint Field_string::get_key_image(char *buff, uint length, imagetype type_arg) + +uint Field_string::get_key_image(uchar *buff, uint length, imagetype type_arg) { - uint bytes = my_charpos(field_charset, ptr, ptr + field_length, + uint bytes = my_charpos(field_charset, (char*) ptr, + (char*) ptr + field_length, length / field_charset->mbmaxlen); memcpy(buff, ptr, bytes); if (bytes < length) @@ -6413,6 +6430,7 @@ uint Field_string::get_key_image(char *buff, uint length, imagetype type_arg) return bytes; } + Field *Field_string::new_field(MEM_ROOT *root, struct st_table *new_table, bool keep_type) { @@ -6466,7 +6484,8 @@ int Field_varstring::store(const char *from,uint length,CHARSET_INFO *cs) const char *from_end_pos; copy_length= well_formed_copy_nchars(field_charset, - ptr + length_bytes, field_length, + (char*) ptr + length_bytes, + field_length, cs, from, length, field_length / field_charset->mbmaxlen, &well_formed_error_pos, @@ -6514,9 +6533,9 @@ double Field_varstring::val_real(void) ASSERT_COLUMN_MARKED_FOR_READ; int not_used; char *end_not_used; - uint length= length_bytes == 1 ? (uint) (uchar) *ptr : uint2korr(ptr); - return my_strntod(field_charset, ptr+length_bytes, length, &end_not_used, - ¬_used); + uint length= length_bytes == 1 ? (uint) *ptr : uint2korr(ptr); + return my_strntod(field_charset, (char*) ptr+length_bytes, length, + &end_not_used, ¬_used); } @@ -6525,8 +6544,8 @@ longlong Field_varstring::val_int(void) ASSERT_COLUMN_MARKED_FOR_READ; int not_used; char *end_not_used; - uint length= length_bytes == 1 ? (uint) (uchar) *ptr : uint2korr(ptr); - return my_strntoll(field_charset, ptr+length_bytes, length, 10, + uint length= length_bytes == 1 ? (uint) *ptr : uint2korr(ptr); + return my_strntoll(field_charset, (char*) ptr+length_bytes, length, 10, &end_not_used, ¬_used); } @@ -6534,7 +6553,7 @@ String *Field_varstring::val_str(String *val_buffer __attribute__((unused)), String *val_ptr) { ASSERT_COLUMN_MARKED_FOR_READ; - uint length= length_bytes == 1 ? (uint) (uchar) *ptr : uint2korr(ptr); + uint length= length_bytes == 1 ? (uint) *ptr : uint2korr(ptr); val_ptr->set((const char*) ptr+length_bytes, length, field_charset); return val_ptr; } @@ -6543,14 +6562,14 @@ String *Field_varstring::val_str(String *val_buffer __attribute__((unused)), my_decimal *Field_varstring::val_decimal(my_decimal *decimal_value) { ASSERT_COLUMN_MARKED_FOR_READ; - uint length= length_bytes == 1 ? (uint) (uchar) *ptr : uint2korr(ptr); - str2my_decimal(E_DEC_FATAL_ERROR, ptr+length_bytes, length, charset(), - decimal_value); + uint length= length_bytes == 1 ? (uint) *ptr : uint2korr(ptr); + str2my_decimal(E_DEC_FATAL_ERROR, (char*) ptr+length_bytes, length, + charset(), decimal_value); return decimal_value; } -int Field_varstring::cmp_max(const char *a_ptr, const char *b_ptr, +int Field_varstring::cmp_max(const uchar *a_ptr, const uchar *b_ptr, uint max_len) { uint a_length, b_length; @@ -6558,8 +6577,8 @@ int Field_varstring::cmp_max(const char *a_ptr, const char *b_ptr, if (length_bytes == 1) { - a_length= (uint) (uchar) *a_ptr; - b_length= (uint) (uchar) *b_ptr; + a_length= (uint) *a_ptr; + b_length= (uint) *b_ptr; } else { @@ -6569,10 +6588,10 @@ int Field_varstring::cmp_max(const char *a_ptr, const char *b_ptr, set_if_smaller(a_length, max_len); set_if_smaller(b_length, max_len); diff= field_charset->coll->strnncollsp(field_charset, - (const uchar*) a_ptr+ + a_ptr+ length_bytes, a_length, - (const uchar*) b_ptr+ + b_ptr+ length_bytes, b_length,0); return diff; @@ -6583,18 +6602,18 @@ int Field_varstring::cmp_max(const char *a_ptr, const char *b_ptr, NOTE: varstring and blob keys are ALWAYS stored with a 2 byte length prefix */ -int Field_varstring::key_cmp(const byte *key_ptr, uint max_key_length) +int Field_varstring::key_cmp(const uchar *key_ptr, uint max_key_length) { - uint length= length_bytes == 1 ? (uint) (uchar) *ptr : uint2korr(ptr); + uint length= length_bytes == 1 ? (uint) *ptr : uint2korr(ptr); uint local_char_length= max_key_length / field_charset->mbmaxlen; local_char_length= my_charpos(field_charset, ptr + length_bytes, ptr + length_bytes + length, local_char_length); set_if_smaller(length, local_char_length); return field_charset->coll->strnncollsp(field_charset, - (const uchar*) ptr + length_bytes, + ptr + length_bytes, length, - (const uchar*) key_ptr+ + key_ptr+ HA_KEY_BLOB_LENGTH, uint2korr(key_ptr), 0); } @@ -6608,22 +6627,20 @@ int Field_varstring::key_cmp(const byte *key_ptr, uint max_key_length) (keys are created and compared in key.cc) */ -int Field_varstring::key_cmp(const byte *a,const byte *b) +int Field_varstring::key_cmp(const uchar *a,const uchar *b) { return field_charset->coll->strnncollsp(field_charset, - (const uchar*) a + - HA_KEY_BLOB_LENGTH, + a + HA_KEY_BLOB_LENGTH, uint2korr(a), - (const uchar*) b + - HA_KEY_BLOB_LENGTH, + b + HA_KEY_BLOB_LENGTH, uint2korr(b), 0); } -void Field_varstring::sort_string(char *to,uint length) +void Field_varstring::sort_string(uchar *to,uint length) { - uint tot_length= length_bytes == 1 ? (uint) (uchar) *ptr : uint2korr(ptr); + uint tot_length= length_bytes == 1 ? (uint) *ptr : uint2korr(ptr); if (field_charset == &my_charset_bin) { @@ -6636,8 +6653,7 @@ void Field_varstring::sort_string(char *to,uint length) } tot_length= my_strnxfrm(field_charset, - (uchar*) to, length, - (uchar*) ptr + length_bytes, + to, length, ptr + length_bytes, tot_length); DBUG_ASSERT(tot_length == length); } @@ -6674,7 +6690,7 @@ void Field_varstring::sql_type(String &res) const uint32 Field_varstring::data_length() { - return length_bytes == 1 ? (uint32) (uchar) *ptr : uint2korr(ptr); + return length_bytes == 1 ? (uint32) *ptr : uint2korr(ptr); } /* @@ -6682,9 +6698,9 @@ uint32 Field_varstring::data_length() Here the number of length bytes are depending on the given max_length */ -char *Field_varstring::pack(char *to, const char *from, uint max_length) +uchar *Field_varstring::pack(uchar *to, const uchar *from, uint max_length) { - uint length= length_bytes == 1 ? (uint) (uchar) *from : uint2korr(from); + uint length= length_bytes == 1 ? (uint) *from : uint2korr(from); set_if_smaller(max_length, field_length); if (length > max_length) length=max_length; @@ -6697,9 +6713,9 @@ char *Field_varstring::pack(char *to, const char *from, uint max_length) } -char *Field_varstring::pack_key(char *to, const char *key, uint max_length) +uchar *Field_varstring::pack_key(uchar *to, const uchar *key, uint max_length) { - uint length= length_bytes == 1 ? (uint) (uchar) *key : uint2korr(key); + uint length= length_bytes == 1 ? (uint) *key : uint2korr(key); uint local_char_length= ((field_charset->mbmaxlen > 1) ? max_length/field_charset->mbmaxlen : max_length); key+= length_bytes; @@ -6736,13 +6752,13 @@ char *Field_varstring::pack_key(char *to, const char *key, uint max_length) Pointer to end of 'key' (To the next key part if multi-segment key) */ -const char *Field_varstring::unpack_key(char *to, const char *key, - uint max_length) +const uchar *Field_varstring::unpack_key(uchar *to, const uchar *key, + uint max_length) { /* get length of the blob key */ - uint32 length= *((uchar*) key++); + uint32 length= *key++; if (max_length > 255) - length+= (*((uchar*) key++)) << 8; + length+= (*key++) << 8; /* put the length into the record buffer */ if (length_bytes == 1) @@ -6766,8 +6782,8 @@ const char *Field_varstring::unpack_key(char *to, const char *key, end of key storage */ -char *Field_varstring::pack_key_from_key_image(char *to, const char *from, - uint max_length) +uchar *Field_varstring::pack_key_from_key_image(uchar *to, const uchar *from, + uint max_length) { /* Key length is always stored as 2 bytes */ uint length= uint2korr(from); @@ -6786,11 +6802,11 @@ char *Field_varstring::pack_key_from_key_image(char *to, const char *from, unpack field packed with Field_varstring::pack() */ -const char *Field_varstring::unpack(char *to, const char *from) +const uchar *Field_varstring::unpack(uchar *to, const uchar *from) { uint length; if (length_bytes == 1) - length= (uint) (uchar) (*to= *from++); + length= (uint) (*to= *from++); else { length= uint2korr(from); @@ -6803,7 +6819,7 @@ const char *Field_varstring::unpack(char *to, const char *from) } -int Field_varstring::pack_cmp(const char *a, const char *b, +int Field_varstring::pack_cmp(const uchar *a, const uchar *b, uint key_length_arg, my_bool insert_or_update) { @@ -6815,21 +6831,21 @@ int Field_varstring::pack_cmp(const char *a, const char *b, } else { - a_length= (uint) (uchar) *a++; - b_length= (uint) (uchar) *b++; + a_length= (uint) *a++; + b_length= (uint) *b++; } return field_charset->coll->strnncollsp(field_charset, - (const uchar*) a, a_length, - (const uchar*) b, b_length, + a, a_length, + b, b_length, insert_or_update); } -int Field_varstring::pack_cmp(const char *b, uint key_length_arg, +int Field_varstring::pack_cmp(const uchar *b, uint key_length_arg, my_bool insert_or_update) { - char *a= ptr+ length_bytes; - uint a_length= length_bytes == 1 ? (uint) (uchar) *ptr : uint2korr(ptr); + uchar *a= ptr+ length_bytes; + uint a_length= length_bytes == 1 ? (uint) *ptr : uint2korr(ptr); uint b_length; uint local_char_length= ((field_charset->mbmaxlen > 1) ? key_length_arg / field_charset->mbmaxlen : @@ -6840,7 +6856,7 @@ int Field_varstring::pack_cmp(const char *b, uint key_length_arg, b_length=uint2korr(b); b+= HA_KEY_BLOB_LENGTH; } else - b_length= (uint) (uchar) *b++; + b_length= (uint) *b++; if (a_length > local_char_length) { @@ -6850,18 +6866,17 @@ int Field_varstring::pack_cmp(const char *b, uint key_length_arg, } return field_charset->coll->strnncollsp(field_charset, - (const uchar*) a, - a_length, - (const uchar*) b, b_length, + a, a_length, + b, b_length, insert_or_update); } -uint Field_varstring::packed_col_length(const char *data_ptr, uint length) +uint Field_varstring::packed_col_length(const uchar *data_ptr, uint length) { if (length > 255) return uint2korr(data_ptr)+2; - return (uint) ((uchar) *data_ptr)+1; + return (uint) *data_ptr + 1; } @@ -6870,11 +6885,11 @@ uint Field_varstring::max_packed_col_length(uint max_length) return (max_length > 255 ? 2 : 1)+max_length; } -uint Field_varstring::get_key_image(char *buff, uint length, imagetype type) +uint Field_varstring::get_key_image(uchar *buff, uint length, imagetype type) { - uint f_length= length_bytes == 1 ? (uint) (uchar) *ptr : uint2korr(ptr); + uint f_length= length_bytes == 1 ? (uint) *ptr : uint2korr(ptr); uint local_char_length= length / field_charset->mbmaxlen; - char *pos= ptr+length_bytes; + uchar *pos= ptr+length_bytes; local_char_length= my_charpos(field_charset, pos, pos + f_length, local_char_length); set_if_smaller(f_length, local_char_length); @@ -6893,23 +6908,23 @@ uint Field_varstring::get_key_image(char *buff, uint length, imagetype type) } -void Field_varstring::set_key_image(char *buff,uint length) +void Field_varstring::set_key_image(const uchar *buff,uint length) { length= uint2korr(buff); // Real length is here - (void) Field_varstring::store(buff+HA_KEY_BLOB_LENGTH, length, + (void) Field_varstring::store((const char*) buff+HA_KEY_BLOB_LENGTH, length, field_charset); } -int Field_varstring::cmp_binary(const char *a_ptr, const char *b_ptr, +int Field_varstring::cmp_binary(const uchar *a_ptr, const uchar *b_ptr, uint32 max_length) { uint32 a_length,b_length; if (length_bytes == 1) { - a_length= (uint) (uchar) *a_ptr; - b_length= (uint) (uchar) *b_ptr; + a_length= (uint) *a_ptr; + b_length= (uint) *b_ptr; } else { @@ -6937,7 +6952,7 @@ Field *Field_varstring::new_field(MEM_ROOT *root, struct st_table *new_table, Field *Field_varstring::new_key_field(MEM_ROOT *root, struct st_table *new_table, - char *new_ptr, uchar *new_null_ptr, + uchar *new_ptr, uchar *new_null_ptr, uint new_null_bit) { Field_varstring *res; @@ -6978,9 +6993,9 @@ void Field_varstring::hash(ulong *nr, ulong *nr2) } else { - uint len= length_bytes == 1 ? (uint) (uchar) *ptr : uint2korr(ptr); + uint len= length_bytes == 1 ? (uint) *ptr : uint2korr(ptr); CHARSET_INFO *cs= charset(); - cs->coll->hash_sort(cs, (uchar*) ptr + length_bytes, len, nr, nr2); + cs->coll->hash_sort(cs, ptr + length_bytes, len, nr, nr2); } } @@ -6991,7 +7006,7 @@ void Field_varstring::hash(ulong *nr, ulong *nr2) ** packlength slot and may be from 1-4. ****************************************************************************/ -Field_blob::Field_blob(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, +Field_blob::Field_blob(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, TABLE_SHARE *share, uint blob_pack_length, CHARSET_INFO *cs) @@ -7006,7 +7021,7 @@ Field_blob::Field_blob(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, } -void Field_blob::store_length(char *i_ptr, uint i_packlength, uint32 i_number) +void Field_blob::store_length(uchar *i_ptr, uint i_packlength, uint32 i_number) { switch (i_packlength) { case 1: @@ -7038,11 +7053,11 @@ void Field_blob::store_length(char *i_ptr, uint i_packlength, uint32 i_number) } -uint32 Field_blob::get_length(const char *pos) +uint32 Field_blob::get_length(const uchar *pos) { switch (packlength) { case 1: - return (uint32) (uchar) pos[0]; + return (uint32) pos[0]; case 2: { uint16 tmp; @@ -7089,7 +7104,7 @@ uint32 Field_blob::get_length(const char *pos) nothing */ -void Field_blob::put_length(char *pos, uint32 length) +void Field_blob::put_length(uchar *pos, uint32 length) { switch (packlength) { case 1: @@ -7157,7 +7172,7 @@ int Field_blob::store(const char *from,uint length,CHARSET_INFO *cs) Field_blob::store_length(copy_length); tmp= value.ptr(); - bmove(ptr+packlength,(char*) &tmp,sizeof(char*)); + bmove(ptr+packlength,(uchar*) &tmp,sizeof(char*)); if (check_string_copy_error(this, well_formed_error_pos, cannot_convert_error_pos, from + length)) @@ -7241,29 +7256,35 @@ my_decimal *Field_blob::val_decimal(my_decimal *decimal_value) { ASSERT_COLUMN_MARKED_FOR_READ; const char *blob; - memcpy_fixed(&blob, ptr+packlength, sizeof(const char*)); + size_t length; + memcpy_fixed(&blob, ptr+packlength, sizeof(const uchar*)); if (!blob) + { blob= ""; - str2my_decimal(E_DEC_FATAL_ERROR, blob, get_length(ptr), charset(), + length= 0; + } + else + length= get_length(ptr); + + str2my_decimal(E_DEC_FATAL_ERROR, blob, length, charset(), decimal_value); return decimal_value; } -int Field_blob::cmp(const char *a,uint32 a_length, const char *b, +int Field_blob::cmp(const uchar *a,uint32 a_length, const uchar *b, uint32 b_length) { return field_charset->coll->strnncollsp(field_charset, - (const uchar*)a, a_length, - (const uchar*)b, b_length, + a, a_length, b, b_length, 0); } -int Field_blob::cmp_max(const char *a_ptr, const char *b_ptr, +int Field_blob::cmp_max(const uchar *a_ptr, const uchar *b_ptr, uint max_length) { - char *blob1,*blob2; + uchar *blob1,*blob2; memcpy_fixed(&blob1,a_ptr+packlength,sizeof(char*)); memcpy_fixed(&blob2,b_ptr+packlength,sizeof(char*)); uint a_len= get_length(a_ptr), b_len= get_length(b_ptr); @@ -7273,7 +7294,7 @@ int Field_blob::cmp_max(const char *a_ptr, const char *b_ptr, } -int Field_blob::cmp_binary(const char *a_ptr, const char *b_ptr, +int Field_blob::cmp_binary(const uchar *a_ptr, const uchar *b_ptr, uint32 max_length) { char *a,*b; @@ -7294,10 +7315,10 @@ int Field_blob::cmp_binary(const char *a_ptr, const char *b_ptr, /* The following is used only when comparing a key */ -uint Field_blob::get_key_image(char *buff,uint length, imagetype type_arg) +uint Field_blob::get_key_image(uchar *buff,uint length, imagetype type_arg) { uint32 blob_length= get_length(ptr); - char *blob; + uchar *blob; #ifdef HAVE_SPATIAL if (type_arg == itMBR) @@ -7314,7 +7335,7 @@ uint Field_blob::get_key_image(char *buff,uint length, imagetype type_arg) return image_length; } get_ptr(&blob); - gobj= Geometry::construct(&buffer, blob, blob_length); + gobj= Geometry::construct(&buffer, (char*) blob, blob_length); if (!gobj || gobj->get_mbr(&mbr, &dummy)) bzero(buff, image_length); else @@ -7349,16 +7370,17 @@ uint Field_blob::get_key_image(char *buff,uint length, imagetype type_arg) } -void Field_blob::set_key_image(char *buff,uint length) +void Field_blob::set_key_image(const uchar *buff,uint length) { length= uint2korr(buff); - (void) Field_blob::store(buff+HA_KEY_BLOB_LENGTH, length, field_charset); + (void) Field_blob::store((const char*) buff+HA_KEY_BLOB_LENGTH, length, + field_charset); } -int Field_blob::key_cmp(const byte *key_ptr, uint max_key_length) +int Field_blob::key_cmp(const uchar *key_ptr, uint max_key_length) { - char *blob1; + uchar *blob1; uint blob_length=get_length(ptr); memcpy_fixed(&blob1,ptr+packlength,sizeof(char*)); CHARSET_INFO *cs= charset(); @@ -7367,14 +7389,14 @@ int Field_blob::key_cmp(const byte *key_ptr, uint max_key_length) local_char_length); set_if_smaller(blob_length, local_char_length); return Field_blob::cmp(blob1, blob_length, - (char*) key_ptr+HA_KEY_BLOB_LENGTH, + key_ptr+HA_KEY_BLOB_LENGTH, uint2korr(key_ptr)); } -int Field_blob::key_cmp(const byte *a,const byte *b) +int Field_blob::key_cmp(const uchar *a,const uchar *b) { - return Field_blob::cmp((char*) a+HA_KEY_BLOB_LENGTH, uint2korr(a), - (char*) b+HA_KEY_BLOB_LENGTH, uint2korr(b)); + return Field_blob::cmp(a+HA_KEY_BLOB_LENGTH, uint2korr(a), + b+HA_KEY_BLOB_LENGTH, uint2korr(b)); } @@ -7385,9 +7407,9 @@ uint32 Field_blob::sort_length() const } -void Field_blob::sort_string(char *to,uint length) +void Field_blob::sort_string(uchar *to,uint length) { - char *blob; + uchar *blob; uint blob_length=get_length(); if (!blob_length) @@ -7396,7 +7418,7 @@ void Field_blob::sort_string(char *to,uint length) { if (field_charset == &my_charset_bin) { - char *pos; + uchar *pos; /* Store length of blob last in blob to shorter blobs before longer blobs @@ -7422,8 +7444,7 @@ void Field_blob::sort_string(char *to,uint length) memcpy_fixed(&blob,ptr+packlength,sizeof(char*)); blob_length=my_strnxfrm(field_charset, - (uchar*) to, length, - (uchar*) blob, blob_length); + to, length, blob, blob_length); DBUG_ASSERT(blob_length == length); } } @@ -7449,23 +7470,23 @@ void Field_blob::sql_type(String &res) const } -char *Field_blob::pack(char *to, const char *from, uint max_length) +uchar *Field_blob::pack(uchar *to, const uchar *from, uint max_length) { - char *save=ptr; - ptr=(char*) from; + uchar *save= ptr; + ptr= (uchar*) from; uint32 length=get_length(); // Length of from string if (length > max_length) { ptr=to; length=max_length; store_length(length); // Store max length - ptr=(char*) from; + ptr= (uchar*) from; } else memcpy(to,from,packlength); // Copy length if (length) { - get_ptr((char**) &from); + get_ptr((uchar**) &from); memcpy(to+packlength, from,length); } ptr=save; // Restore org row pointer @@ -7473,7 +7494,7 @@ char *Field_blob::pack(char *to, const char *from, uint max_length) } -const char *Field_blob::unpack(char *to, const char *from) +const uchar *Field_blob::unpack(uchar *to, const uchar *from) { memcpy(to,from,packlength); uint32 length=get_length(from); @@ -7487,7 +7508,7 @@ const char *Field_blob::unpack(char *to, const char *from) /* Keys for blobs are like keys on varchars */ -int Field_blob::pack_cmp(const char *a, const char *b, uint key_length_arg, +int Field_blob::pack_cmp(const uchar *a, const uchar *b, uint key_length_arg, my_bool insert_or_update) { uint a_length, b_length; @@ -7498,20 +7519,20 @@ int Field_blob::pack_cmp(const char *a, const char *b, uint key_length_arg, } else { - a_length= (uint) (uchar) *a++; - b_length= (uint) (uchar) *b++; + a_length= (uint) *a++; + b_length= (uint) *b++; } return field_charset->coll->strnncollsp(field_charset, - (const uchar*) a, a_length, - (const uchar*) b, b_length, + a, a_length, + b, b_length, insert_or_update); } -int Field_blob::pack_cmp(const char *b, uint key_length_arg, +int Field_blob::pack_cmp(const uchar *b, uint key_length_arg, my_bool insert_or_update) { - char *a; + uchar *a; uint a_length, b_length; memcpy_fixed(&a,ptr+packlength,sizeof(char*)); if (!a) @@ -7523,24 +7544,24 @@ int Field_blob::pack_cmp(const char *b, uint key_length_arg, b_length= uint2korr(b); b+=2; } else - b_length= (uint) (uchar) *b++; + b_length= (uint) *b++; return field_charset->coll->strnncollsp(field_charset, - (const uchar*) a, a_length, - (const uchar*) b, b_length, + a, a_length, + b, b_length, insert_or_update); } /* Create a packed key that will be used for storage from a MySQL row */ -char *Field_blob::pack_key(char *to, const char *from, uint max_length) +uchar *Field_blob::pack_key(uchar *to, const uchar *from, uint max_length) { - char *save=ptr; - ptr=(char*) from; + uchar *save= ptr; + ptr= (uchar*) from; uint32 length=get_length(); // Length of from string uint local_char_length= ((field_charset->mbmaxlen > 1) ? - max_length/field_charset->mbmaxlen : max_length); + max_length/field_charset->mbmaxlen : max_length); if (length) - get_ptr((char**) &from); + get_ptr((uchar**) &from); if (length > local_char_length) local_char_length= my_charpos(field_charset, from, from+length, local_char_length); @@ -7577,12 +7598,13 @@ char *Field_blob::pack_key(char *to, const char *from, uint max_length) Pointer into 'from' past the last byte copied from packed key. */ -const char *Field_blob::unpack_key(char *to, const char *from, uint max_length) +const uchar *Field_blob::unpack_key(uchar *to, const uchar *from, + uint max_length) { /* get length of the blob key */ - uint32 length= *((uchar*) from++); + uint32 length= *from++; if (max_length > 255) - length+= (*((uchar*) from++)) << 8; + length+= *from++ << 8; /* put the length into the record buffer */ put_length(to, length); @@ -7600,8 +7622,8 @@ const char *Field_blob::unpack_key(char *to, const char *from, uint max_length) /* Create a packed key that will be used for storage from a MySQL key */ -char *Field_blob::pack_key_from_key_image(char *to, const char *from, - uint max_length) +uchar *Field_blob::pack_key_from_key_image(uchar *to, const uchar *from, + uint max_length) { uint length=uint2korr(from); if (length > max_length) @@ -7615,11 +7637,11 @@ char *Field_blob::pack_key_from_key_image(char *to, const char *from, } -uint Field_blob::packed_col_length(const char *data_ptr, uint length) +uint Field_blob::packed_col_length(const uchar *data_ptr, uint length) { if (length > 255) return uint2korr(data_ptr)+2; - return (uint) ((uchar) *data_ptr)+1; + return (uint) *data_ptr + 1; } @@ -7643,9 +7665,9 @@ uint Field_blob::is_equal(create_field *new_field) #ifdef HAVE_SPATIAL -uint Field_geom::get_key_image(char *buff, uint length, imagetype type) +uint Field_geom::get_key_image(uchar *buff, uint length, imagetype type) { - char *blob; + uchar *blob; const char *dummy; MBR mbr; ulong blob_length= get_length(ptr); @@ -7659,7 +7681,7 @@ uint Field_geom::get_key_image(char *buff, uint length, imagetype type) return image_length; } get_ptr(&blob); - gobj= Geometry::construct(&buffer, blob, blob_length); + gobj= Geometry::construct(&buffer, (char*) blob, blob_length); if (!gobj || gobj->get_mbr(&mbr, &dummy)) bzero(buff, image_length); else @@ -7897,7 +7919,7 @@ longlong Field_enum::val_int(void) ASSERT_COLUMN_MARKED_FOR_READ; switch (packlength) { case 1: - return (longlong) (uchar) ptr[0]; + return (longlong) ptr[0]; case 2: { uint16 tmp; @@ -7951,18 +7973,18 @@ String *Field_enum::val_str(String *val_buffer __attribute__((unused)), return val_ptr; } -int Field_enum::cmp(const char *a_ptr, const char *b_ptr) +int Field_enum::cmp(const uchar *a_ptr, const uchar *b_ptr) { - char *old=ptr; - ptr=(char*) a_ptr; + uchar *old= ptr; + ptr= (uchar*) a_ptr; ulonglong a=Field_enum::val_int(); - ptr=(char*) b_ptr; + ptr= (uchar*) b_ptr; ulonglong b=Field_enum::val_int(); - ptr=old; + ptr= old; return (a < b) ? -1 : (a > b) ? 1 : 0; } -void Field_enum::sort_string(char *to,uint length __attribute__((unused))) +void Field_enum::sort_string(uchar *to,uint length __attribute__((unused))) { ulonglong value=Field_enum::val_int(); to+=packlength-1; @@ -8144,9 +8166,9 @@ bool Field_enum::eq_def(Field *field) for (uint i=0 ; i < from_lib->count ; i++) if (my_strnncoll(field_charset, (const uchar*)typelib->type_names[i], - (uint) strlen(typelib->type_names[i]), + strlen(typelib->type_names[i]), (const uchar*)from_lib->type_names[i], - (uint) strlen(from_lib->type_names[i]))) + strlen(from_lib->type_names[i]))) return 0; return 1; } @@ -8205,7 +8227,7 @@ uint Field_num::is_equal(create_field *new_field) 11 one byte for 'd' */ -Field_bit::Field_bit(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, +Field_bit::Field_bit(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, uchar *bit_ptr_arg, uchar bit_ofs_arg, enum utype unireg_check_arg, const char *field_name_arg) : Field(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, @@ -8223,7 +8245,7 @@ Field_bit::Field_bit(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, } -my_size_t +size_t Field_bit::do_last_null_byte() const { /* @@ -8245,14 +8267,14 @@ Field_bit::do_last_null_byte() const result= bit_ptr; if (result) - return (byte*) result - table->record[0] + 1; - else - return LAST_NULL_BYTE_UNDEF; + return (size_t) (result - table->record[0]) + 1; + return LAST_NULL_BYTE_UNDEF; } + Field *Field_bit::new_key_field(MEM_ROOT *root, struct st_table *new_table, - char *new_ptr, uchar *new_null_ptr, + uchar *new_ptr, uchar *new_null_ptr, uint new_null_bit) { Field_bit *res; @@ -8261,7 +8283,7 @@ Field *Field_bit::new_key_field(MEM_ROOT *root, new_null_bit))) { /* Move bits normally stored in null_pointer to new_ptr */ - res->bit_ptr= (uchar*) new_ptr; + res->bit_ptr= new_ptr; res->bit_ofs= 0; if (bit_len) res->ptr++; // Store rest of data here @@ -8358,7 +8380,7 @@ longlong Field_bit::val_int(void) switch (bytes_in_rec) { case 0: return bits; - case 1: return bits | (ulonglong) (uchar) ptr[0]; + case 1: return bits | (ulonglong) ptr[0]; case 2: return bits | mi_uint2korr(ptr); case 3: return bits | mi_uint3korr(ptr); case 4: return bits | mi_uint4korr(ptr); @@ -8408,7 +8430,7 @@ my_decimal *Field_bit::val_decimal(my_decimal *deciaml_value) The a and b pointer must be pointers to the field in a record (not the table->record[0] necessarily) */ -int Field_bit::cmp_max(const char *a, const char *b, uint max_len) +int Field_bit::cmp_max(const uchar *a, const uchar *b, uint max_len) { my_ptrdiff_t a_diff= a - ptr; my_ptrdiff_t b_diff= b - ptr; @@ -8424,13 +8446,13 @@ int Field_bit::cmp_max(const char *a, const char *b, uint max_len) } -int Field_bit::key_cmp(const byte *str, uint length) +int Field_bit::key_cmp(const uchar *str, uint length) { if (bit_len) { int flag; uchar bits= get_rec_bits(bit_ptr, bit_ofs, bit_len); - if ((flag= (int) (bits - *(uchar*) str))) + if ((flag= (int) (bits - *str))) return flag; str++; length--; @@ -8453,7 +8475,7 @@ int Field_bit::cmp_offset(uint row_offset) } -uint Field_bit::get_key_image(char *buff, uint length, imagetype type_arg) +uint Field_bit::get_key_image(uchar *buff, uint length, imagetype type_arg) { if (bit_len) { @@ -8476,7 +8498,7 @@ void Field_bit::sql_type(String &res) const } -char *Field_bit::pack(char *to, const char *from, uint max_length) +uchar *Field_bit::pack(uchar *to, const uchar *from, uint max_length) { DBUG_ASSERT(max_length); uint length; @@ -8510,7 +8532,7 @@ char *Field_bit::pack(char *to, const char *from, uint max_length) } -const char *Field_bit::unpack(char *to, const char *from) +const uchar *Field_bit::unpack(uchar *to, const uchar *from) { if (bit_len > 0) { @@ -8544,7 +8566,7 @@ void Field_bit::set_default() Bit field support for non-MyISAM tables. */ -Field_bit_as_char::Field_bit_as_char(char *ptr_arg, uint32 len_arg, +Field_bit_as_char::Field_bit_as_char(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg) @@ -8571,7 +8593,7 @@ int Field_bit_as_char::store(const char *from, uint length, CHARSET_INFO *cs) { memset(ptr, 0xff, bytes_in_rec); if (bits) - *ptr&= ((1 << bits) - 1); /* set first byte */ + *ptr&= ((1 << bits) - 1); /* set first uchar */ if (table->in_use->really_abort_on_warning()) set_warning(MYSQL_ERROR::WARN_LEVEL_ERROR, ER_DATA_TOO_LONG, 1); else @@ -9098,7 +9120,7 @@ uint pack_length_to_packflag(uint type) } -Field *make_field(TABLE_SHARE *share, char *ptr, uint32 field_length, +Field *make_field(TABLE_SHARE *share, uchar *ptr, uint32 field_length, uchar *null_pos, uchar null_bit, uint pack_flag, enum_field_types field_type, diff --git a/sql/field.h b/sql/field.h index f9b4ae33378..54a061276b6 100644 --- a/sql/field.h +++ b/sql/field.h @@ -48,10 +48,10 @@ class Field Field(const Item &); /* Prevent use of these */ void operator=(Field &); public: - static void *operator new(size_t size) {return (void*) sql_alloc((uint) size); } + static void *operator new(size_t size) {return sql_alloc(size); } static void operator delete(void *ptr_arg, size_t size) { TRASH(ptr_arg, size); } - char *ptr; // Position to field in record + uchar *ptr; // Position to field in record uchar *null_ptr; // Byte where null_bit is /* Note that you can use table->in_use as replacement for current_thd member @@ -90,11 +90,12 @@ public: uint16 field_index; // field number in fields array uchar null_bit; // Bit used to test null bit - Field(char *ptr_arg,uint32 length_arg,uchar *null_ptr_arg,uchar null_bit_arg, - utype unireg_check_arg, const char *field_name_arg); + Field(uchar *ptr_arg,uint32 length_arg,uchar *null_ptr_arg, + uchar null_bit_arg, utype unireg_check_arg, + const char *field_name_arg); virtual ~Field() {} /* Store functions returns 1 on overflow and -1 on fatal error */ - virtual int store(const char *to,uint length,CHARSET_INFO *cs)=0; + virtual int store(const char *to, uint length,CHARSET_INFO *cs)=0; virtual int store(double nr)=0; virtual int store(longlong nr, bool unsigned_val)=0; virtual int store_decimal(const my_decimal *d)=0; @@ -171,20 +172,20 @@ public: virtual uint32 key_length() const { return pack_length(); } virtual enum_field_types type() const =0; virtual enum_field_types real_type() const { return type(); } - inline int cmp(const char *str) { return cmp(ptr,str); } - virtual int cmp_max(const char *a, const char *b, uint max_len) + inline int cmp(const uchar *str) { return cmp(ptr,str); } + virtual int cmp_max(const uchar *a, const uchar *b, uint max_len) { return cmp(a, b); } - virtual int cmp(const char *,const char *)=0; - virtual int cmp_binary(const char *a,const char *b, uint32 max_length=~0L) + virtual int cmp(const uchar *,const uchar *)=0; + virtual int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0L) { return memcmp(a,b,pack_length()); } virtual int cmp_offset(uint row_offset) { return cmp(ptr,ptr+row_offset); } virtual int cmp_binary_offset(uint row_offset) { return cmp_binary(ptr, ptr+row_offset); }; - virtual int key_cmp(const byte *a,const byte *b) - { return cmp((char*) a,(char*) b); } - virtual int key_cmp(const byte *str, uint length) - { return cmp(ptr,(char*) str); } + virtual int key_cmp(const uchar *a,const uchar *b) + { return cmp(a, b); } + virtual int key_cmp(const uchar *str, uint length) + { return cmp(ptr,str); } virtual uint decimals() const { return 0; } /* Caller beware: sql_type can change str.Ptr, so check @@ -201,7 +202,7 @@ public: { if (!null_ptr) return 0; - return test(record[(uint) (null_ptr - (uchar*) table->record[0])] & + return test(record[(uint) (null_ptr -table->record[0])] & null_bit); } inline bool is_null_in_record_with_offset(my_ptrdiff_t offset) @@ -236,15 +237,15 @@ public: the record. If the field does not use any bits of the null bytes, the value 0 (LAST_NULL_BYTE_UNDEF) is returned. */ - my_size_t last_null_byte() const { - my_size_t bytes= do_last_null_byte(); + size_t last_null_byte() const { + size_t bytes= do_last_null_byte(); DBUG_PRINT("debug", ("last_null_byte() ==> %ld", (long) bytes)); DBUG_ASSERT(bytes <= table->s->null_bytes); return bytes; } virtual void make_field(Send_field *); - virtual void sort_string(char *buff,uint length)=0; + virtual void sort_string(uchar *buff,uint length)=0; virtual bool optimize_range(uint idx, uint part); /* This should be true for fields which, when compared with constant @@ -258,23 +259,23 @@ public: virtual Field *new_field(MEM_ROOT *root, struct st_table *new_table, bool keep_type); virtual Field *new_key_field(MEM_ROOT *root, struct st_table *new_table, - char *new_ptr, uchar *new_null_ptr, + uchar *new_ptr, uchar *new_null_ptr, uint new_null_bit); Field *clone(MEM_ROOT *mem_root, struct st_table *new_table); - inline void move_field(char *ptr_arg,uchar *null_ptr_arg,uchar null_bit_arg) + inline void move_field(uchar *ptr_arg,uchar *null_ptr_arg,uchar null_bit_arg) { ptr=ptr_arg; null_ptr=null_ptr_arg; null_bit=null_bit_arg; } - inline void move_field(char *ptr_arg) { ptr=ptr_arg; } + inline void move_field(uchar *ptr_arg) { ptr=ptr_arg; } virtual void move_field_offset(my_ptrdiff_t ptr_diff) { - ptr=ADD_TO_PTR(ptr,ptr_diff,char*); + ptr=ADD_TO_PTR(ptr,ptr_diff, uchar*); if (null_ptr) null_ptr=ADD_TO_PTR(null_ptr,ptr_diff,uchar*); } - inline void get_image(char *buff,uint length, CHARSET_INFO *cs) + inline void get_image(uchar *buff,uint length, CHARSET_INFO *cs) { memcpy(buff,ptr,length); } - inline void set_image(char *buff,uint length, CHARSET_INFO *cs) + inline void set_image(const uchar *buff,uint length, CHARSET_INFO *cs) { memcpy(ptr,buff,length); } @@ -304,12 +305,12 @@ public: Number of copied bytes (excluding padded zero bytes -- see above). */ - virtual uint get_key_image(char *buff, uint length, imagetype type) + virtual uint get_key_image(uchar *buff, uint length, imagetype type) { get_image(buff, length, &my_charset_bin); return length; } - virtual void set_key_image(char *buff,uint length) + virtual void set_key_image(const uchar *buff,uint length) { set_image(buff,length, &my_charset_bin); } inline longlong val_int_offset(uint row_offset) { @@ -318,63 +319,64 @@ public: ptr-=row_offset; return tmp; } - inline longlong val_int(char *new_ptr) + inline longlong val_int(const uchar *new_ptr) { - char *old_ptr= ptr; + uchar *old_ptr= ptr; longlong return_value; - ptr= new_ptr; + ptr= (uchar*) new_ptr; return_value= val_int(); ptr= old_ptr; return return_value; } - inline String *val_str(String *str, char *new_ptr) + inline String *val_str(String *str, const uchar *new_ptr) { - char *old_ptr= ptr; - ptr= new_ptr; + uchar *old_ptr= ptr; + ptr= (uchar*) new_ptr; val_str(str); ptr= old_ptr; return str; } virtual bool send_binary(Protocol *protocol); - virtual char *pack(char* to, const char *from, uint max_length=~(uint) 0) + virtual uchar *pack(uchar *to, const uchar *from, uint max_length=~(uint) 0) { uint32 length=pack_length(); memcpy(to,from,length); return to+length; } - virtual const char *unpack(char* to, const char *from) + virtual const uchar *unpack(uchar* to, const uchar *from) { uint length=pack_length(); memcpy(to,from,length); return from+length; } - virtual char *pack_key(char* to, const char *from, uint max_length) + virtual uchar *pack_key(uchar* to, const uchar *from, uint max_length) { return pack(to,from,max_length); } - virtual char *pack_key_from_key_image(char* to, const char *from, + virtual uchar *pack_key_from_key_image(uchar* to, const uchar *from, uint max_length) { return pack(to,from,max_length); } - virtual const char *unpack_key(char* to, const char *from, uint max_length) + virtual const uchar *unpack_key(uchar* to, const uchar *from, + uint max_length) { return unpack(to,from); } - virtual uint packed_col_length(const char *to, uint length) + virtual uint packed_col_length(const uchar *to, uint length) { return length;} virtual uint max_packed_col_length(uint max_length) { return max_length;} - virtual int pack_cmp(const char *a,const char *b, uint key_length_arg, + virtual int pack_cmp(const uchar *a,const uchar *b, uint key_length_arg, my_bool insert_or_update) { return cmp(a,b); } - virtual int pack_cmp(const char *b, uint key_length_arg, + virtual int pack_cmp(const uchar *b, uint key_length_arg, my_bool insert_or_update) { return cmp(ptr,b); } - uint offset(byte *record) + uint offset(uchar *record) { - return (uint) (ptr - (char*) record); + return (uint) (ptr - record); } void copy_from_tmp(int offset); uint fill_cache_field(struct st_cache_field *copy); @@ -424,7 +426,7 @@ public: /* Hash value */ virtual void hash(ulong *nr, ulong *nr2); friend bool reopen_table(THD *,struct st_table *,bool); - friend int cre_myisam(my_string name, register TABLE *form, uint options, + friend int cre_myisam(char * name, register TABLE *form, uint options, ulonglong auto_increment_value); friend class Copy_field; friend class Item_avg_field; @@ -451,7 +453,7 @@ private: function. This represents the inheritance interface and can be overridden by subclasses. */ - virtual my_size_t do_last_null_byte() const; + virtual size_t do_last_null_byte() const; }; @@ -459,7 +461,7 @@ class Field_num :public Field { public: const uint8 dec; bool zerofill,unsigned_flag; // Purify cannot handle bit fields - Field_num(char *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, + Field_num(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, utype unireg_check_arg, const char *field_name_arg, uint8 dec_arg, bool zero_arg, bool unsigned_arg); @@ -487,7 +489,7 @@ protected: CHARSET_INFO *field_charset; enum Derivation field_derivation; public: - Field_str(char *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, + Field_str(uchar *ptr_arg,uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, utype unireg_check_arg, const char *field_name_arg, CHARSET_INFO *charset); Item_result result_type () const { return STRING_RESULT; } @@ -517,7 +519,7 @@ public: class Field_longstr :public Field_str { public: - Field_longstr(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, + Field_longstr(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, utype unireg_check_arg, const char *field_name_arg, CHARSET_INFO *charset_arg) :Field_str(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, unireg_check_arg, @@ -530,7 +532,7 @@ public: /* base class for float and double and decimal (old one) */ class Field_real :public Field_num { public: - Field_real(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, + Field_real(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, utype unireg_check_arg, const char *field_name_arg, uint8 dec_arg, bool zero_arg, bool unsigned_arg) @@ -545,7 +547,7 @@ public: class Field_decimal :public Field_real { public: - Field_decimal(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, + Field_decimal(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, uint8 dec_arg,bool zero_arg,bool unsigned_arg) @@ -563,8 +565,8 @@ public: double val_real(void); longlong val_int(void); String *val_str(String*,String *); - int cmp(const char *,const char*); - void sort_string(char *buff,uint length); + int cmp(const uchar *,const uchar *); + void sort_string(uchar *buff,uint length); void overflow(bool negative); bool zero_pack() const { return 0; } void sql_type(String &str) const; @@ -583,7 +585,7 @@ public: So for example we need to count length from precision handling CREATE TABLE ( DECIMAL(x,y)) */ - Field_new_decimal(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, + Field_new_decimal(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, uint8 dec_arg, bool zero_arg, bool unsigned_arg); @@ -605,8 +607,8 @@ public: longlong val_int(void); my_decimal *val_decimal(my_decimal *); String *val_str(String*, String *); - int cmp(const char *, const char*); - void sort_string(char *buff, uint length); + int cmp(const uchar *, const uchar *); + void sort_string(uchar *buff, uint length); bool zero_pack() const { return 0; } void sql_type(String &str) const; uint32 max_display_length() { return field_length; } @@ -618,7 +620,7 @@ public: class Field_tiny :public Field_num { public: - Field_tiny(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, + Field_tiny(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, bool zero_arg, bool unsigned_arg) @@ -638,8 +640,8 @@ public: longlong val_int(void); String *val_str(String*,String *); bool send_binary(Protocol *protocol); - int cmp(const char *,const char*); - void sort_string(char *buff,uint length); + int cmp(const uchar *,const uchar *); + void sort_string(uchar *buff,uint length); uint32 pack_length() const { return 1; } void sql_type(String &str) const; uint32 max_display_length() { return 4; } @@ -648,7 +650,7 @@ public: class Field_short :public Field_num { public: - Field_short(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, + Field_short(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, bool zero_arg, bool unsigned_arg) @@ -658,7 +660,7 @@ public: {} Field_short(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg, bool unsigned_arg) - :Field_num((char*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0, + :Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0, NONE, field_name_arg, 0, 0, unsigned_arg) {} enum Item_result result_type () const { return INT_RESULT; } @@ -673,8 +675,8 @@ public: longlong val_int(void); String *val_str(String*,String *); bool send_binary(Protocol *protocol); - int cmp(const char *,const char*); - void sort_string(char *buff,uint length); + int cmp(const uchar *,const uchar *); + void sort_string(uchar *buff,uint length); uint32 pack_length() const { return 2; } void sql_type(String &str) const; uint32 max_display_length() { return 6; } @@ -683,7 +685,7 @@ public: class Field_medium :public Field_num { public: - Field_medium(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, + Field_medium(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, bool zero_arg, bool unsigned_arg) @@ -703,8 +705,8 @@ public: longlong val_int(void); String *val_str(String*,String *); bool send_binary(Protocol *protocol); - int cmp(const char *,const char*); - void sort_string(char *buff,uint length); + int cmp(const uchar *,const uchar *); + void sort_string(uchar *buff,uint length); uint32 pack_length() const { return 3; } void sql_type(String &str) const; uint32 max_display_length() { return 8; } @@ -713,7 +715,7 @@ public: class Field_long :public Field_num { public: - Field_long(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, + Field_long(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, bool zero_arg, bool unsigned_arg) @@ -723,7 +725,7 @@ public: {} Field_long(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg, bool unsigned_arg) - :Field_num((char*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0, + :Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0, NONE, field_name_arg,0,0,unsigned_arg) {} enum Item_result result_type () const { return INT_RESULT; } @@ -738,8 +740,8 @@ public: longlong val_int(void); bool send_binary(Protocol *protocol); String *val_str(String*,String *); - int cmp(const char *,const char*); - void sort_string(char *buff,uint length); + int cmp(const uchar *,const uchar *); + void sort_string(uchar *buff,uint length); uint32 pack_length() const { return 4; } void sql_type(String &str) const; uint32 max_display_length() { return 11; } @@ -749,7 +751,7 @@ public: #ifdef HAVE_LONG_LONG class Field_longlong :public Field_num { public: - Field_longlong(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, + Field_longlong(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, bool zero_arg, bool unsigned_arg) @@ -760,7 +762,7 @@ public: Field_longlong(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg, bool unsigned_arg) - :Field_num((char*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0, + :Field_num((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0,0, NONE, field_name_arg,0,0,unsigned_arg) {} enum Item_result result_type () const { return INT_RESULT; } @@ -779,8 +781,8 @@ public: longlong val_int(void); String *val_str(String*,String *); bool send_binary(Protocol *protocol); - int cmp(const char *,const char*); - void sort_string(char *buff,uint length); + int cmp(const uchar *,const uchar *); + void sort_string(uchar *buff,uint length); uint32 pack_length() const { return 8; } void sql_type(String &str) const; bool can_be_compared_as_longlong() const { return TRUE; } @@ -791,7 +793,7 @@ public: class Field_float :public Field_real { public: - Field_float(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, + Field_float(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, uint8 dec_arg,bool zero_arg,bool unsigned_arg) @@ -801,7 +803,7 @@ public: {} Field_float(uint32 len_arg, bool maybe_null_arg, const char *field_name_arg, uint8 dec_arg) - :Field_real((char*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, (uint) 0, + :Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, (uint) 0, NONE, field_name_arg, dec_arg, 0, 0) {} enum_field_types type() const { return MYSQL_TYPE_FLOAT;} @@ -814,8 +816,8 @@ public: longlong val_int(void); String *val_str(String*,String *); bool send_binary(Protocol *protocol); - int cmp(const char *,const char*); - void sort_string(char *buff,uint length); + int cmp(const uchar *,const uchar *); + void sort_string(uchar *buff,uint length); uint32 pack_length() const { return sizeof(float); } void sql_type(String &str) const; }; @@ -824,7 +826,7 @@ public: class Field_double :public Field_real { public: my_bool not_fixed; - Field_double(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, + Field_double(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, uint8 dec_arg,bool zero_arg,bool unsigned_arg) @@ -835,13 +837,13 @@ public: {} Field_double(uint32 len_arg, bool maybe_null_arg, const char *field_name_arg, uint8 dec_arg) - :Field_real((char*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0, + :Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0, NONE, field_name_arg, dec_arg, 0, 0), not_fixed(dec_arg >= NOT_FIXED_DEC) {} Field_double(uint32 len_arg, bool maybe_null_arg, const char *field_name_arg, uint8 dec_arg, my_bool not_fixed_srg) - :Field_real((char*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0, + :Field_real((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "" : 0, (uint) 0, NONE, field_name_arg, dec_arg, 0, 0), not_fixed(not_fixed_srg) {} @@ -855,8 +857,8 @@ public: longlong val_int(void); String *val_str(String*,String *); bool send_binary(Protocol *protocol); - int cmp(const char *,const char*); - void sort_string(char *buff,uint length); + int cmp(const uchar *,const uchar *); + void sort_string(uchar *buff,uint length); uint32 pack_length() const { return sizeof(double); } void sql_type(String &str) const; uint size_of() const { return sizeof(*this); } @@ -868,7 +870,7 @@ public: class Field_null :public Field_str { static uchar null[1]; public: - Field_null(char *ptr_arg, uint32 len_arg, + Field_null(uchar *ptr_arg, uint32 len_arg, enum utype unireg_check_arg, const char *field_name_arg, CHARSET_INFO *cs) :Field_str(ptr_arg, len_arg, null, 1, @@ -886,8 +888,8 @@ public: my_decimal *val_decimal(my_decimal *) { return 0; } String *val_str(String *value,String *value2) { value2->length(0); return value2;} - int cmp(const char *a, const char *b) { return 0;} - void sort_string(char *buff, uint length) {} + int cmp(const uchar *a, const uchar *b) { return 0;} + void sort_string(uchar *buff, uint length) {} uint32 pack_length() const { return 0; } void sql_type(String &str) const; uint size_of() const { return sizeof(*this); } @@ -897,7 +899,7 @@ public: class Field_timestamp :public Field_str { public: - Field_timestamp(char *ptr_arg, uint32 len_arg, + Field_timestamp(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, TABLE_SHARE *share, CHARSET_INFO *cs); @@ -914,8 +916,8 @@ public: longlong val_int(void); String *val_str(String*,String *); bool send_binary(Protocol *protocol); - int cmp(const char *,const char*); - void sort_string(char *buff,uint length); + int cmp(const uchar *,const uchar *); + void sort_string(uchar *buff,uint length); uint32 pack_length() const { return 4; } void sql_type(String &str) const; bool can_be_compared_as_longlong() const { return TRUE; } @@ -950,7 +952,7 @@ public: class Field_year :public Field_tiny { public: - Field_year(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, + Field_year(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg) :Field_tiny(ptr_arg, len_arg, null_ptr_arg, null_bit_arg, @@ -971,7 +973,7 @@ public: class Field_date :public Field_str { public: - Field_date(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, + Field_date(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, CHARSET_INFO *cs) :Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg, @@ -979,7 +981,7 @@ public: {} Field_date(bool maybe_null_arg, const char *field_name_arg, CHARSET_INFO *cs) - :Field_str((char*) 0,10, maybe_null_arg ? (uchar*) "": 0,0, + :Field_str((uchar*) 0,10, maybe_null_arg ? (uchar*) "": 0,0, NONE, field_name_arg, cs) {} enum_field_types type() const { return MYSQL_TYPE_DATE;} enum ha_base_keytype key_type() const { return HA_KEYTYPE_ULONG_INT; } @@ -992,8 +994,8 @@ public: longlong val_int(void); String *val_str(String*,String *); bool send_binary(Protocol *protocol); - int cmp(const char *,const char*); - void sort_string(char *buff,uint length); + int cmp(const uchar *,const uchar *); + void sort_string(uchar *buff,uint length); uint32 pack_length() const { return 4; } void sql_type(String &str) const; bool can_be_compared_as_longlong() const { return TRUE; } @@ -1003,7 +1005,7 @@ public: class Field_newdate :public Field_str { public: - Field_newdate(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, + Field_newdate(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, CHARSET_INFO *cs) :Field_str(ptr_arg, 10, null_ptr_arg, null_bit_arg, @@ -1022,8 +1024,8 @@ public: longlong val_int(void); String *val_str(String*,String *); bool send_binary(Protocol *protocol); - int cmp(const char *,const char*); - void sort_string(char *buff,uint length); + int cmp(const uchar *,const uchar *); + void sort_string(uchar *buff,uint length); uint32 pack_length() const { return 3; } void sql_type(String &str) const; bool can_be_compared_as_longlong() const { return TRUE; } @@ -1035,7 +1037,7 @@ public: class Field_time :public Field_str { public: - Field_time(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, + Field_time(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, CHARSET_INFO *cs) :Field_str(ptr_arg, 8, null_ptr_arg, null_bit_arg, @@ -1043,7 +1045,7 @@ public: {} Field_time(bool maybe_null_arg, const char *field_name_arg, CHARSET_INFO *cs) - :Field_str((char*) 0,8, maybe_null_arg ? (uchar*) "": 0,0, + :Field_str((uchar*) 0,8, maybe_null_arg ? (uchar*) "": 0,0, NONE, field_name_arg, cs) {} enum_field_types type() const { return MYSQL_TYPE_TIME;} enum ha_base_keytype key_type() const { return HA_KEYTYPE_INT24; } @@ -1059,8 +1061,8 @@ public: bool get_date(MYSQL_TIME *ltime, uint fuzzydate); bool send_binary(Protocol *protocol); bool get_time(MYSQL_TIME *ltime); - int cmp(const char *,const char*); - void sort_string(char *buff,uint length); + int cmp(const uchar *,const uchar *); + void sort_string(uchar *buff,uint length); uint32 pack_length() const { return 3; } void sql_type(String &str) const; bool can_be_compared_as_longlong() const { return TRUE; } @@ -1070,7 +1072,7 @@ public: class Field_datetime :public Field_str { public: - Field_datetime(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, + Field_datetime(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, CHARSET_INFO *cs) :Field_str(ptr_arg, 19, null_ptr_arg, null_bit_arg, @@ -1078,7 +1080,7 @@ public: {} Field_datetime(bool maybe_null_arg, const char *field_name_arg, CHARSET_INFO *cs) - :Field_str((char*) 0,19, maybe_null_arg ? (uchar*) "": 0,0, + :Field_str((uchar*) 0,19, maybe_null_arg ? (uchar*) "": 0,0, NONE, field_name_arg, cs) {} enum_field_types type() const { return MYSQL_TYPE_DATETIME;} #ifdef HAVE_LONG_LONG @@ -1099,8 +1101,8 @@ public: longlong val_int(void); String *val_str(String*,String *); bool send_binary(Protocol *protocol); - int cmp(const char *,const char*); - void sort_string(char *buff,uint length); + int cmp(const uchar *,const uchar *); + void sort_string(uchar *buff,uint length); uint32 pack_length() const { return 8; } void sql_type(String &str) const; bool can_be_compared_as_longlong() const { return TRUE; } @@ -1113,7 +1115,7 @@ public: class Field_string :public Field_longstr { public: bool can_alter_field_type; - Field_string(char *ptr_arg, uint32 len_arg,uchar *null_ptr_arg, + Field_string(uchar *ptr_arg, uint32 len_arg,uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, CHARSET_INFO *cs) @@ -1122,7 +1124,7 @@ public: can_alter_field_type(1) {}; Field_string(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg, CHARSET_INFO *cs) - :Field_longstr((char*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0, + :Field_longstr((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0, NONE, field_name_arg, cs), can_alter_field_type(1) {}; @@ -1139,7 +1141,7 @@ public: bool zero_pack() const { return 0; } int reset(void) { - charset()->cset->fill(charset(),ptr,field_length, + charset()->cset->fill(charset(),(char*) ptr, field_length, (has_charset() ? ' ' : 0)); return 0; } @@ -1150,22 +1152,22 @@ public: longlong val_int(void); String *val_str(String*,String *); my_decimal *val_decimal(my_decimal *); - int cmp(const char *,const char*); - void sort_string(char *buff,uint length); + int cmp(const uchar *,const uchar *); + void sort_string(uchar *buff,uint length); void sql_type(String &str) const; - char *pack(char *to, const char *from, uint max_length=~(uint) 0); - const char *unpack(char* to, const char *from); - int pack_cmp(const char *a,const char *b,uint key_length, + uchar *pack(uchar *to, const uchar *from, uint max_length=~(uint) 0); + const uchar *unpack(uchar* to, const uchar *from); + int pack_cmp(const uchar *a,const uchar *b,uint key_length, my_bool insert_or_update); - int pack_cmp(const char *b,uint key_length,my_bool insert_or_update); - uint packed_col_length(const char *to, uint length); + int pack_cmp(const uchar *b,uint key_length,my_bool insert_or_update); + uint packed_col_length(const uchar *to, uint length); uint max_packed_col_length(uint max_length); uint size_of() const { return sizeof(*this); } enum_field_types real_type() const { return MYSQL_TYPE_STRING; } bool has_charset(void) const { return charset() == &my_charset_bin ? FALSE : TRUE; } Field *new_field(MEM_ROOT *root, struct st_table *new_table, bool keep_type); - virtual uint get_key_image(char *buff,uint length, imagetype type); + virtual uint get_key_image(uchar *buff,uint length, imagetype type); }; @@ -1173,7 +1175,7 @@ class Field_varstring :public Field_longstr { public: /* Store number of bytes used to store length (1 or 2) */ uint32 length_bytes; - Field_varstring(char *ptr_arg, + Field_varstring(uchar *ptr_arg, uint32 len_arg, uint length_bytes_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, @@ -1187,7 +1189,7 @@ public: Field_varstring(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg, TABLE_SHARE *share, CHARSET_INFO *cs) - :Field_longstr((char*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0, + :Field_longstr((uchar*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0, NONE, field_name_arg, cs), length_bytes(len_arg < 256 ? 1 :2) { @@ -1212,27 +1214,28 @@ public: longlong val_int(void); String *val_str(String*,String *); my_decimal *val_decimal(my_decimal *); - int cmp_max(const char *, const char *, uint max_length); - int cmp(const char *a,const char*b) + int cmp_max(const uchar *, const uchar *, uint max_length); + int cmp(const uchar *a,const uchar *b) { return cmp_max(a, b, ~0L); } - void sort_string(char *buff,uint length); - uint get_key_image(char *buff,uint length, imagetype type); - void set_key_image(char *buff,uint length); + void sort_string(uchar *buff,uint length); + uint get_key_image(uchar *buff,uint length, imagetype type); + void set_key_image(const uchar *buff,uint length); void sql_type(String &str) const; - char *pack(char *to, const char *from, uint max_length=~(uint) 0); - char *pack_key(char *to, const char *from, uint max_length); - char *pack_key_from_key_image(char* to, const char *from, uint max_length); - const char *unpack(char* to, const char *from); - const char *unpack_key(char* to, const char *from, uint max_length); - int pack_cmp(const char *a, const char *b, uint key_length, + uchar *pack(uchar *to, const uchar *from, uint max_length=~(uint) 0); + uchar *pack_key(uchar *to, const uchar *from, uint max_length); + uchar *pack_key_from_key_image(uchar* to, const uchar *from, + uint max_length); + const uchar *unpack(uchar* to, const uchar *from); + const uchar *unpack_key(uchar* to, const uchar *from, uint max_length); + int pack_cmp(const uchar *a, const uchar *b, uint key_length, my_bool insert_or_update); - int pack_cmp(const char *b, uint key_length,my_bool insert_or_update); - int cmp_binary(const char *a,const char *b, uint32 max_length=~0L); - int key_cmp(const byte *,const byte*); - int key_cmp(const byte *str, uint length); - uint packed_col_length(const char *to, uint length); + int pack_cmp(const uchar *b, uint key_length,my_bool insert_or_update); + int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0L); + int key_cmp(const uchar *,const uchar*); + int key_cmp(const uchar *str, uint length); + uint packed_col_length(const uchar *to, uint length); uint max_packed_col_length(uint max_length); uint32 data_length(); uint size_of() const { return sizeof(*this); } @@ -1241,7 +1244,7 @@ public: { return charset() == &my_charset_bin ? FALSE : TRUE; } Field *new_field(MEM_ROOT *root, struct st_table *new_table, bool keep_type); Field *new_key_field(MEM_ROOT *root, struct st_table *new_table, - char *new_ptr, uchar *new_null_ptr, + uchar *new_ptr, uchar *new_null_ptr, uint new_null_bit); uint is_equal(create_field *new_field); void hash(ulong *nr, ulong *nr2); @@ -1253,12 +1256,12 @@ protected: uint packlength; String value; // For temporaries public: - Field_blob(char *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, + Field_blob(uchar *ptr_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, TABLE_SHARE *share, uint blob_pack_length, CHARSET_INFO *cs); Field_blob(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg, CHARSET_INFO *cs) - :Field_longstr((char*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0, + :Field_longstr((uchar*) 0, len_arg, maybe_null_arg ? (uchar*) "": 0, 0, NONE, field_name_arg, cs), packlength(4) { @@ -1266,7 +1269,7 @@ public: } Field_blob(uint32 len_arg,bool maybe_null_arg, const char *field_name_arg, CHARSET_INFO *cs, bool set_packlength) - :Field_longstr((char*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0, + :Field_longstr((uchar*) 0,len_arg, maybe_null_arg ? (uchar*) "": 0, 0, NONE, field_name_arg, cs) { flags|= BLOB_FLAG; @@ -1289,15 +1292,15 @@ public: longlong val_int(void); String *val_str(String*,String *); my_decimal *val_decimal(my_decimal *); - int cmp_max(const char *, const char *, uint max_length); - int cmp(const char *a,const char*b) + int cmp_max(const uchar *, const uchar *, uint max_length); + int cmp(const uchar *a,const uchar *b) { return cmp_max(a, b, ~0L); } - int cmp(const char *a, uint32 a_length, const char *b, uint32 b_length); - int cmp_binary(const char *a,const char *b, uint32 max_length=~0L); - int key_cmp(const byte *,const byte*); - int key_cmp(const byte *str, uint length); + int cmp(const uchar *a, uint32 a_length, const uchar *b, uint32 b_length); + int cmp_binary(const uchar *a,const uchar *b, uint32 max_length=~0L); + int key_cmp(const uchar *,const uchar*); + int key_cmp(const uchar *str, uint length); uint32 key_length() const { return 0; } - void sort_string(char *buff,uint length); + void sort_string(uchar *buff,uint length); uint32 pack_length() const { return (uint32) (packlength+table->s->blob_ptr_size); } uint32 sort_length() const; @@ -1305,70 +1308,73 @@ public: { return (uint32) (((ulonglong) 1 << (packlength*8)) -1); } - int reset(void) { bzero(ptr, packlength+sizeof(char*)); return 0; } - void reset_fields() { bzero((char*) &value,sizeof(value)); } + int reset(void) { bzero(ptr, packlength+sizeof(uchar*)); return 0; } + void reset_fields() { bzero((uchar*) &value,sizeof(value)); } #ifndef WORDS_BIGENDIAN static #endif - void store_length(char *i_ptr, uint i_packlength, uint32 i_number); + void store_length(uchar *i_ptr, uint i_packlength, uint32 i_number); inline void store_length(uint32 number) { store_length(ptr, packlength, number); } - + inline uint32 get_length(uint row_offset=0) { return get_length(ptr+row_offset); } - uint32 get_length(const char *ptr); - void put_length(char *pos, uint32 length); - inline void get_ptr(char **str) + uint32 get_length(const uchar *ptr); + void put_length(uchar *pos, uint32 length); + inline void get_ptr(uchar **str) { - memcpy_fixed(str,ptr+packlength,sizeof(char*)); + memcpy_fixed((uchar*) str,ptr+packlength,sizeof(uchar*)); } - inline void get_ptr(char **str, uint row_offset) + inline void get_ptr(uchar **str, uint row_offset) { - memcpy_fixed(str,ptr+packlength+row_offset,sizeof(char*)); + memcpy_fixed((uchar*) str,ptr+packlength+row_offset,sizeof(char*)); } - inline void set_ptr(char *length,char *data) + inline void set_ptr(uchar *length, uchar *data) { memcpy(ptr,length,packlength); memcpy_fixed(ptr+packlength,&data,sizeof(char*)); } - void set_ptr_offset(my_ptrdiff_t ptr_diff, uint32 length,char *data) + void set_ptr_offset(my_ptrdiff_t ptr_diff, uint32 length, uchar *data) { - char *ptr_ofs= ADD_TO_PTR(ptr,ptr_diff,char*); + uchar *ptr_ofs= ADD_TO_PTR(ptr,ptr_diff,uchar*); store_length(ptr_ofs, packlength, length); memcpy_fixed(ptr_ofs+packlength,&data,sizeof(char*)); } - inline void set_ptr(uint32 length,char *data) + inline void set_ptr(uint32 length, uchar *data) { set_ptr_offset(0, length, data); } - uint get_key_image(char *buff,uint length, imagetype type); - void set_key_image(char *buff,uint length); + uint get_key_image(uchar *buff,uint length, imagetype type); + void set_key_image(const uchar *buff,uint length); void sql_type(String &str) const; inline bool copy() - { char *tmp; + { + uchar *tmp; get_ptr(&tmp); - if (value.copy(tmp,get_length(),charset())) + if (value.copy((char*) tmp, get_length(),charset())) { Field_blob::reset(); return 1; } - tmp=(char*) value.ptr(); memcpy_fixed(ptr+packlength,&tmp,sizeof(char*)); + tmp=(uchar*) value.ptr(); + memcpy_fixed(ptr+packlength,&tmp,sizeof(char*)); return 0; } - char *pack(char *to, const char *from, uint max_length= ~(uint) 0); - char *pack_key(char *to, const char *from, uint max_length); - char *pack_key_from_key_image(char* to, const char *from, uint max_length); - const char *unpack(char *to, const char *from); - const char *unpack_key(char* to, const char *from, uint max_length); - int pack_cmp(const char *a, const char *b, uint key_length, + uchar *pack(uchar *to, const uchar *from, uint max_length= ~(uint) 0); + uchar *pack_key(uchar *to, const uchar *from, uint max_length); + uchar *pack_key_from_key_image(uchar* to, const uchar *from, + uint max_length); + const uchar *unpack(uchar *to, const uchar *from); + const uchar *unpack_key(uchar* to, const uchar *from, uint max_length); + int pack_cmp(const uchar *a, const uchar *b, uint key_length, my_bool insert_or_update); - int pack_cmp(const char *b, uint key_length,my_bool insert_or_update); - uint packed_col_length(const char *col_ptr, uint length); + int pack_cmp(const uchar *b, uint key_length,my_bool insert_or_update); + uint packed_col_length(const uchar *col_ptr, uint length); uint max_packed_col_length(uint max_length); void free() { value.free(); } - inline void clear_temporary() { bzero((char*) &value,sizeof(value)); } + inline void clear_temporary() { bzero((uchar*) &value,sizeof(value)); } friend int field_conv(Field *to,Field *from); uint size_of() const { return sizeof(*this); } bool has_charset(void) const @@ -1383,7 +1389,7 @@ class Field_geom :public Field_blob { public: enum geometry_type geom_type; - Field_geom(char *ptr_arg, uchar *null_ptr_arg, uint null_bit_arg, + Field_geom(uchar *ptr_arg, uchar *null_ptr_arg, uint null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, TABLE_SHARE *share, uint blob_pack_length, enum geometry_type geom_type_arg) @@ -1401,7 +1407,7 @@ public: int store(double nr); int store(longlong nr, bool unsigned_val); int store_decimal(const my_decimal *); - uint get_key_image(char *buff,uint length,imagetype type); + uint get_key_image(uchar *buff,uint length,imagetype type); uint size_of() const { return sizeof(*this); } int reset(void) { return !maybe_null() || Field_blob::reset(); } }; @@ -1413,7 +1419,7 @@ protected: uint packlength; public: TYPELIB *typelib; - Field_enum(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, + Field_enum(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, uint packlength_arg, @@ -1436,8 +1442,8 @@ public: double val_real(void); longlong val_int(void); String *val_str(String*,String *); - int cmp(const char *,const char*); - void sort_string(char *buff,uint length); + int cmp(const uchar *,const uchar *); + void sort_string(uchar *buff,uint length); uint32 pack_length() const { return (uint32) packlength; } void store_type(ulonglong value); void sql_type(String &str) const; @@ -1454,7 +1460,7 @@ public: class Field_set :public Field_enum { public: - Field_set(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, + Field_set(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg, uint32 packlength_arg, @@ -1497,7 +1503,7 @@ public: uchar bit_ofs; // offset to 'uneven' high bits uint bit_len; // number of 'uneven' high bits uint bytes_in_rec; - Field_bit(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, + Field_bit(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, uchar *bit_ptr_arg, uchar bit_ofs_arg, enum utype unireg_check_arg, const char *field_name_arg); enum_field_types type() const { return MYSQL_TYPE_BIT; } @@ -1516,29 +1522,29 @@ public: String *val_str(String*, String *); virtual bool str_needs_quotes() { return TRUE; } my_decimal *val_decimal(my_decimal *); - int cmp(const char *a, const char *b) + int cmp(const uchar *a, const uchar *b) { return cmp_binary(a, b); } int cmp_binary_offset(uint row_offset) { return cmp_offset(row_offset); } - int cmp_max(const char *a, const char *b, uint max_length); - int key_cmp(const byte *a, const byte *b) - { return cmp_binary((char *) a, (char *) b); } - int key_cmp(const byte *str, uint length); + int cmp_max(const uchar *a, const uchar *b, uint max_length); + int key_cmp(const uchar *a, const uchar *b) + { return cmp_binary((uchar *) a, (uchar *) b); } + int key_cmp(const uchar *str, uint length); int cmp_offset(uint row_offset); - uint get_key_image(char *buff, uint length, imagetype type); - void set_key_image(char *buff, uint length) - { Field_bit::store(buff, length, &my_charset_bin); } - void sort_string(char *buff, uint length) + uint get_key_image(uchar *buff, uint length, imagetype type); + void set_key_image(const uchar *buff, uint length) + { Field_bit::store((char*) buff, length, &my_charset_bin); } + void sort_string(uchar *buff, uint length) { get_key_image(buff, length, itRAW); } uint32 pack_length() const { return (uint32) (field_length + 7) / 8; } uint32 pack_length_in_rec() const { return bytes_in_rec; } void sql_type(String &str) const; - char *pack(char *to, const char *from, uint max_length=~(uint) 0); - const char *unpack(char* to, const char *from); + uchar *pack(uchar *to, const uchar *from, uint max_length=~(uint) 0); + const uchar *unpack(uchar* to, const uchar *from); virtual void set_default(); Field *new_key_field(MEM_ROOT *root, struct st_table *new_table, - char *new_ptr, uchar *new_null_ptr, + uchar *new_ptr, uchar *new_null_ptr, uint new_null_bit); void set_bit_ptr(uchar *bit_ptr_arg, uchar bit_ofs_arg) { @@ -1559,7 +1565,7 @@ public: } private: - virtual my_size_t do_last_null_byte() const; + virtual size_t do_last_null_byte() const; }; @@ -1572,7 +1578,7 @@ private: */ class Field_bit_as_char: public Field_bit { public: - Field_bit_as_char(char *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, + Field_bit_as_char(uchar *ptr_arg, uint32 len_arg, uchar *null_ptr_arg, uchar null_bit_arg, enum utype unireg_check_arg, const char *field_name_arg); enum ha_base_keytype key_type() const { return HA_KEYTYPE_BINARY; } @@ -1663,7 +1669,7 @@ class Send_field { class Copy_field :public Sql_alloc { void (*get_copy_func(Field *to,Field *from))(Copy_field *); public: - char *from_ptr,*to_ptr; + uchar *from_ptr,*to_ptr; uchar *from_null_ptr,*to_null_ptr; my_bool *null_row; uint from_bit,to_bit; @@ -1674,13 +1680,13 @@ public: Copy_field() {} ~Copy_field() {} void set(Field *to,Field *from,bool save); // Field to field - void set(char *to,Field *from); // Field to string + void set(uchar *to,Field *from); // Field to string void (*do_copy)(Copy_field *); void (*do_copy2)(Copy_field *); // Used to handle null values }; -Field *make_field(TABLE_SHARE *share, char *ptr, uint32 field_length, +Field *make_field(TABLE_SHARE *share, uchar *ptr, uint32 field_length, uchar *null_pos, uchar null_bit, uint pack_flag, enum_field_types field_type, CHARSET_INFO *cs, diff --git a/sql/field_conv.cc b/sql/field_conv.cc index 9771cbc12b1..e920fe70f26 100644 --- a/sql/field_conv.cc +++ b/sql/field_conv.cc @@ -355,8 +355,8 @@ static void do_cut_string(Copy_field *copy) /* Check if we loosed any important characters */ if (cs->cset->scan(cs, - copy->from_ptr + copy->to_length, - copy->from_ptr + copy->from_length, + (char*) copy->from_ptr + copy->to_length, + (char*) copy->from_ptr + copy->from_length, MY_SEQ_SPACES) < copy->from_length - copy->to_length) { copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, @@ -374,8 +374,10 @@ static void do_cut_string_complex(Copy_field *copy) { // Shorter string field int well_formed_error; CHARSET_INFO *cs= copy->from_field->charset(); - const char *from_end= copy->from_ptr + copy->from_length; - uint copy_length= cs->cset->well_formed_len(cs, copy->from_ptr, from_end, + const uchar *from_end= copy->from_ptr + copy->from_length; + uint copy_length= cs->cset->well_formed_len(cs, + (char*) copy->from_ptr, + (char*) from_end, copy->to_length / cs->mbmaxlen, &well_formed_error); if (copy->to_length < copy_length) @@ -384,7 +386,8 @@ static void do_cut_string_complex(Copy_field *copy) /* Check if we lost any important characters */ if (well_formed_error || - cs->cset->scan(cs, copy->from_ptr + copy_length, from_end, + cs->cset->scan(cs, (char*) copy->from_ptr + copy_length, + (char*) from_end, MY_SEQ_SPACES) < (copy->from_length - copy_length)) { copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, @@ -392,7 +395,7 @@ static void do_cut_string_complex(Copy_field *copy) } if (copy_length < copy->to_length) - cs->cset->fill(cs, copy->to_ptr + copy_length, + cs->cset->fill(cs, (char*) copy->to_ptr + copy_length, copy->to_length - copy_length, ' '); } @@ -403,7 +406,7 @@ static void do_expand_binary(Copy_field *copy) { CHARSET_INFO *cs= copy->from_field->charset(); memcpy(copy->to_ptr,copy->from_ptr,copy->from_length); - cs->cset->fill(cs, copy->to_ptr+copy->from_length, + cs->cset->fill(cs, (char*) copy->to_ptr+copy->from_length, copy->to_length-copy->from_length, '\0'); } @@ -413,7 +416,7 @@ static void do_expand_string(Copy_field *copy) { CHARSET_INFO *cs= copy->from_field->charset(); memcpy(copy->to_ptr,copy->from_ptr,copy->from_length); - cs->cset->fill(cs, copy->to_ptr+copy->from_length, + cs->cset->fill(cs, (char*) copy->to_ptr+copy->from_length, copy->to_length-copy->from_length, ' '); } @@ -438,9 +441,10 @@ static void do_varstring1_mb(Copy_field *copy) int well_formed_error; CHARSET_INFO *cs= copy->from_field->charset(); uint from_length= (uint) *(uchar*) copy->from_ptr; - const char *from_ptr= copy->from_ptr + 1; + const uchar *from_ptr= copy->from_ptr + 1; uint to_char_length= (copy->to_length - 1) / cs->mbmaxlen; - uint length= cs->cset->well_formed_len(cs, from_ptr, from_ptr + from_length, + uint length= cs->cset->well_formed_len(cs, (char*) from_ptr, + (char*) from_ptr + from_length, to_char_length, &well_formed_error); if (length < from_length) { @@ -448,7 +452,7 @@ static void do_varstring1_mb(Copy_field *copy) copy->to_field->set_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, 1); } - *(uchar*) copy->to_ptr= (uchar) length; + *copy->to_ptr= (uchar) length; memcpy(copy->to_ptr + 1, from_ptr, length); } @@ -475,8 +479,9 @@ static void do_varstring2_mb(Copy_field *copy) CHARSET_INFO *cs= copy->from_field->charset(); uint char_length= (copy->to_length - HA_KEY_BLOB_LENGTH) / cs->mbmaxlen; uint from_length= uint2korr(copy->from_ptr); - const char *from_beg= copy->from_ptr + HA_KEY_BLOB_LENGTH; - uint length= cs->cset->well_formed_len(cs, from_beg, from_beg + from_length, + const uchar *from_beg= copy->from_ptr + HA_KEY_BLOB_LENGTH; + uint length= cs->cset->well_formed_len(cs, (char*) from_beg, + (char*) from_beg + from_length, char_length, &well_formed_error); if (length < from_length) { @@ -501,7 +506,7 @@ static void do_varstring2_mb(Copy_field *copy) The 'to' buffer should have a size of field->pack_length()+1 */ -void Copy_field::set(char *to,Field *from) +void Copy_field::set(uchar *to,Field *from) { from_ptr=from->ptr; to_ptr=to; diff --git a/sql/filesort.cc b/sql/filesort.cc index e44862c667b..1d443e85327 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -30,7 +30,7 @@ /* How to write record_ref. */ #define WRITE_REF(file,from) \ -if (my_b_write((file),(byte*) (from),param->ref_length)) \ +if (my_b_write((file),(uchar*) (from),param->ref_length)) \ DBUG_RETURN(1); /* functions defined in this file */ @@ -42,7 +42,7 @@ static ha_rows find_all_keys(SORTPARAM *param,SQL_SELECT *select, IO_CACHE *tempfile,IO_CACHE *indexfile); static int write_keys(SORTPARAM *param,uchar * *sort_keys, uint count, IO_CACHE *buffer_file, IO_CACHE *tempfile); -static void make_sortkey(SORTPARAM *param,uchar *to, byte *ref_pos); +static void make_sortkey(SORTPARAM *param,uchar *to, uchar *ref_pos); static void register_used_fields(SORTPARAM *param); static int merge_index(SORTPARAM *param,uchar *sort_buffer, BUFFPEK *buffpek, @@ -56,7 +56,7 @@ static uint sortlength(THD *thd, SORT_FIELD *sortorder, uint s_length, static SORT_ADDON_FIELD *get_addon_fields(THD *thd, Field **ptabfield, uint sortlength, uint *plength); static void unpack_addon_fields(struct st_sort_addon_field *addon_field, - byte *buff); + uchar *buff); /* Sort a table @@ -153,7 +153,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, if (param.addon_field) { param.res_length= param.addon_length; - if (!(table_sort.addon_buf= (byte *) my_malloc(param.addon_length, + if (!(table_sort.addon_buf= (uchar *) my_malloc(param.addon_length, MYF(MY_WME)))) goto err; } @@ -198,7 +198,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, } if (multi_byte_charset && - !(param.tmp_buffer=my_malloc(param.sort_length,MYF(MY_WME)))) + !(param.tmp_buffer= (char*) my_malloc(param.sort_length,MYF(MY_WME)))) goto err; memavl= thd->variables.sortbuff_size; @@ -245,7 +245,7 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, { if (!table_sort.buffpek && table_sort.buffpek_len < maxbuffer && !(table_sort.buffpek= - (byte *) read_buffpek_from_file(&buffpek_pointers, maxbuffer))) + (uchar *) read_buffpek_from_file(&buffpek_pointers, maxbuffer))) goto err; buffpek= (BUFFPEK *) table_sort.buffpek; table_sort.buffpek_len= maxbuffer; @@ -284,9 +284,9 @@ ha_rows filesort(THD *thd, TABLE *table, SORT_FIELD *sortorder, uint s_length, x_free(param.tmp_buffer); if (!subselect || !subselect->is_uncacheable()) { - x_free((gptr) sort_keys); + x_free((uchar*) sort_keys); table_sort.sort_keys= 0; - x_free((gptr) buffpek); + x_free((uchar*) buffpek); table_sort.buffpek= 0; table_sort.buffpek_len= 0; } @@ -324,19 +324,19 @@ void filesort_free_buffers(TABLE *table, bool full) { if (table->sort.record_pointers) { - my_free((gptr) table->sort.record_pointers,MYF(0)); + my_free((uchar*) table->sort.record_pointers,MYF(0)); table->sort.record_pointers=0; } if (full) { if (table->sort.sort_keys ) { - x_free((gptr) table->sort.sort_keys); + x_free((uchar*) table->sort.sort_keys); table->sort.sort_keys= 0; } if (table->sort.buffpek) { - x_free((gptr) table->sort.buffpek); + x_free((uchar*) table->sort.buffpek); table->sort.buffpek= 0; table->sort.buffpek_len= 0; } @@ -382,7 +382,7 @@ static BUFFPEK *read_buffpek_from_file(IO_CACHE *buffpek_pointers, uint count) if (tmp) { if (reinit_io_cache(buffpek_pointers,READ_CACHE,0L,0,0) || - my_b_read(buffpek_pointers, (byte*) tmp, length)) + my_b_read(buffpek_pointers, (uchar*) tmp, length)) { my_free((char*) tmp, MYF(0)); tmp=0; @@ -434,7 +434,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, { int error,flag,quick_select; uint idx,indexpos,ref_length; - byte *ref_pos,*next_pos,ref_buff[MAX_REFLENGTH]; + uchar *ref_pos,*next_pos,ref_buff[MAX_REFLENGTH]; my_off_t record; TABLE *sort_form; THD *thd= current_thd; @@ -461,7 +461,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, next_pos=ref_pos; if (! indexfile && ! quick_select) { - next_pos=(byte*) 0; /* Find records in sequence */ + next_pos=(uchar*) 0; /* Find records in sequence */ file->ha_rnd_init(1); file->extra_opt(HA_EXTRA_CACHE, current_thd->variables.read_buff_size); @@ -486,7 +486,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, register_used_fields(param); if (select && select->cond) select->cond->walk(&Item::register_field_in_read_map, 1, - (byte*) sort_form); + (uchar*) sort_form); sort_form->column_bitmaps_set(&sort_form->tmp_set, &sort_form->tmp_set); for (;;) @@ -504,7 +504,7 @@ static ha_rows find_all_keys(SORTPARAM *param, SQL_SELECT *select, { if (indexfile) { - if (my_b_read(indexfile,(byte*) ref_pos,ref_length)) /* purecov: deadcode */ + if (my_b_read(indexfile,(uchar*) ref_pos,ref_length)) /* purecov: deadcode */ { error= my_errno ? my_errno : -1; /* Abort */ break; @@ -612,7 +612,7 @@ static int write_keys(SORTPARAM *param, register uchar **sort_keys, uint count, IO_CACHE *buffpek_pointers, IO_CACHE *tempfile) { - uint sort_length, rec_length; + size_t sort_length, rec_length; uchar **end; BUFFPEK buffpek; DBUG_ENTER("write_keys"); @@ -622,7 +622,7 @@ write_keys(SORTPARAM *param, register uchar **sort_keys, uint count, #ifdef MC68000 quicksort(sort_keys,count,sort_length); #else - my_string_ptr_sort((gptr) sort_keys, (uint) count, sort_length); + my_string_ptr_sort((uchar*) sort_keys, (uint) count, sort_length); #endif if (!my_b_inited(tempfile) && open_cached_file(tempfile, mysql_tmpdir, TEMP_PREFIX, DISK_BUFFER_SIZE, @@ -636,9 +636,9 @@ write_keys(SORTPARAM *param, register uchar **sort_keys, uint count, count=(uint) param->max_rows; /* purecov: inspected */ buffpek.count=(ha_rows) count; for (end=sort_keys+count ; sort_keys != end ; sort_keys++) - if (my_b_write(tempfile, (byte*) *sort_keys, (uint) rec_length)) + if (my_b_write(tempfile, (uchar*) *sort_keys, (uint) rec_length)) goto err; - if (my_b_write(buffpek_pointers, (byte*) &buffpek, sizeof(buffpek))) + if (my_b_write(buffpek_pointers, (uchar*) &buffpek, sizeof(buffpek))) goto err; DBUG_RETURN(0); @@ -673,7 +673,7 @@ static inline void store_length(uchar *to, uint length, uint pack_length) /* makes a sort-key from record */ static void make_sortkey(register SORTPARAM *param, - register uchar *to, byte *ref_pos) + register uchar *to, uchar *ref_pos) { reg3 Field *field; reg1 SORT_FIELD *sort_field; @@ -700,7 +700,7 @@ static void make_sortkey(register SORTPARAM *param, else *to++=1; } - field->sort_string((char*) to,sort_field->length); + field->sort_string(to, sort_field->length); } else { // Item @@ -829,7 +829,7 @@ static void make_sortkey(register SORTPARAM *param, } *to++=1; } - my_decimal2binary(E_DEC_FATAL_ERROR, dec_val, (char*)to, + my_decimal2binary(E_DEC_FATAL_ERROR, dec_val, to, item->max_length - (item->decimals ? 1:0), item->decimals); break; @@ -847,7 +847,7 @@ static void make_sortkey(register SORTPARAM *param, } *to++=1; } - change_double_for_sort(value,(byte*) to); + change_double_for_sort(value,(uchar*) to); break; } case ROW_RESULT: @@ -897,13 +897,13 @@ static void make_sortkey(register SORTPARAM *param, else { #ifdef HAVE_purify - uchar *end= (uchar*) field->pack((char *) to, field->ptr); + uchar *end= field->pack(to, field->ptr); uint length= (uint) ((to + addonf->length) - end); DBUG_ASSERT((int) length >= 0); if (length) bzero(end, length); #else - (void) field->pack((char *) to, field->ptr); + (void) field->pack(to, field->ptr); #endif } to+= addonf->length; @@ -912,7 +912,7 @@ static void make_sortkey(register SORTPARAM *param, else { /* Save filepos last */ - memcpy((byte*) to, ref_pos, (size_s) param->ref_length); + memcpy((uchar*) to, ref_pos, (size_t) param->ref_length); } return; } @@ -941,7 +941,7 @@ static void register_used_fields(SORTPARAM *param) else { // Item sort_field->item->walk(&Item::register_field_in_read_map, 1, - (byte *) table); + (uchar *) table); } } @@ -964,16 +964,16 @@ static bool save_index(SORTPARAM *param, uchar **sort_keys, uint count, FILESORT_INFO *table_sort) { uint offset,res_length; - byte *to; + uchar *to; DBUG_ENTER("save_index"); - my_string_ptr_sort((gptr) sort_keys, (uint) count, param->sort_length); + my_string_ptr_sort((uchar*) sort_keys, (uint) count, param->sort_length); res_length= param->res_length; offset= param->rec_length-res_length; if ((ha_rows) count > param->max_rows) count=(uint) param->max_rows; if (!(to= table_sort->record_pointers= - (byte*) my_malloc(res_length*count, MYF(MY_WME)))) + (uchar*) my_malloc(res_length*count, MYF(MY_WME)))) DBUG_RETURN(1); /* purecov: inspected */ for (uchar **end= sort_keys+count ; sort_keys != end ; sort_keys++) { @@ -1048,7 +1048,7 @@ uint read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek, if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count))) { - if (my_pread(fromfile->file,(byte*) buffpek->base, + if (my_pread(fromfile->file,(uchar*) buffpek->base, (length= rec_length*count),buffpek->file_pos,MYF_RW)) return((uint) -1); /* purecov: inspected */ buffpek->key=buffpek->base; @@ -1162,7 +1162,7 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file, if (error == -1) goto err; /* purecov: inspected */ buffpek->max_keys= buffpek->mem_count; // If less data in buffers than expected - queue_insert(&queue, (byte*) buffpek); + queue_insert(&queue, (uchar*) buffpek); } if (param->unique_buff) @@ -1177,7 +1177,7 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file, */ buffpek= (BUFFPEK*) queue_top(&queue); memcpy(param->unique_buff, buffpek->key, rec_length); - if (my_b_write(to_file, (byte*) buffpek->key, rec_length)) + if (my_b_write(to_file, (uchar*) buffpek->key, rec_length)) { error=1; goto err; /* purecov: inspected */ } @@ -1211,14 +1211,14 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file, } if (flag == 0) { - if (my_b_write(to_file,(byte*) buffpek->key, rec_length)) + if (my_b_write(to_file,(uchar*) buffpek->key, rec_length)) { error=1; goto err; /* purecov: inspected */ } } else { - if (my_b_write(to_file, (byte*) buffpek->key+offset, res_length)) + if (my_b_write(to_file, (uchar*) buffpek->key+offset, res_length)) { error=1; goto err; /* purecov: inspected */ } @@ -1273,7 +1273,7 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file, max_rows-= buffpek->mem_count; if (flag == 0) { - if (my_b_write(to_file,(byte*) buffpek->key, + if (my_b_write(to_file,(uchar*) buffpek->key, (rec_length*buffpek->mem_count))) { error= 1; goto err; /* purecov: inspected */ @@ -1287,7 +1287,7 @@ int merge_buffers(SORTPARAM *param, IO_CACHE *from_file, strpos != end ; strpos+= rec_length) { - if (my_b_write(to_file, (byte *) strpos, res_length)) + if (my_b_write(to_file, (uchar *) strpos, res_length)) { error=1; goto err; } @@ -1556,7 +1556,7 @@ get_addon_fields(THD *thd, Field **ptabfield, uint sortlength, uint *plength) */ static void -unpack_addon_fields(struct st_sort_addon_field *addon_field, byte *buff) +unpack_addon_fields(struct st_sort_addon_field *addon_field, uchar *buff) { Field *field; SORT_ADDON_FIELD *addonf= addon_field; @@ -1569,7 +1569,7 @@ unpack_addon_fields(struct st_sort_addon_field *addon_field, byte *buff) continue; } field->set_notnull(); - field->unpack(field->ptr, (char *) buff+addonf->offset); + field->unpack(field->ptr, buff + addonf->offset); } } @@ -1580,7 +1580,7 @@ unpack_addon_fields(struct st_sort_addon_field *addon_field, byte *buff) #define DBL_EXP_DIG (sizeof(double)*8-DBL_MANT_DIG) -void change_double_for_sort(double nr,byte *to) +void change_double_for_sort(double nr,uchar *to) { uchar *tmp=(uchar*) to; if (nr == 0.0) diff --git a/sql/gen_lex_hash.cc b/sql/gen_lex_hash.cc index 2d78999017a..36b7f30dc64 100644 --- a/sql/gen_lex_hash.cc +++ b/sql/gen_lex_hash.cc @@ -90,8 +90,8 @@ struct my_option my_long_options[] = {"debug", '#', "This is a non-debug version. Catch this and exit", 0,0, 0, GET_DISABLED, OPT_ARG, 0, 0, 0, 0, 0, 0}, #else - {"debug", '#', "Output debug log", (gptr*) &default_dbug_option, - (gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"debug", '#', "Output debug log", (uchar**) &default_dbug_option, + (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif {"help", '?', "Display help and exit", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/sql/gstream.h b/sql/gstream.h index 10274635413..1ef90ad5bf0 100644 --- a/sql/gstream.h +++ b/sql/gstream.h @@ -35,7 +35,7 @@ public: {} ~Gis_read_stream() { - my_free(m_err_msg, MYF(MY_ALLOW_ZERO_PTR)); + my_free((uchar*) m_err_msg, MYF(MY_ALLOW_ZERO_PTR)); } enum enum_tok_types get_next_toc_type(); diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index afb2589f6b9..aeaea90feb6 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -146,7 +146,7 @@ pthread_mutex_t ndbcluster_mutex; // Table lock handling HASH ndbcluster_open_tables; -static byte *ndbcluster_get_key(NDB_SHARE *share,uint *length, +static uchar *ndbcluster_get_key(NDB_SHARE *share, size_t *length, my_bool not_used __attribute__((unused))); #ifdef HAVE_NDB_BINLOG static int rename_share(NDB_SHARE *share, const char *new_key); @@ -336,11 +336,11 @@ int execute_no_commit_ie(ha_ndbcluster *h, NdbTransaction *trans, Place holder for ha_ndbcluster thread specific data */ static -byte *thd_ndb_share_get_key(THD_NDB_SHARE *thd_ndb_share, uint *length, +uchar *thd_ndb_share_get_key(THD_NDB_SHARE *thd_ndb_share, size_t *length, my_bool not_used __attribute__((unused))) { *length= sizeof(thd_ndb_share->key); - return (byte*) &thd_ndb_share->key; + return (uchar*) &thd_ndb_share->key; } Thd_ndb::Thd_ndb() @@ -395,9 +395,9 @@ Thd_ndb::get_open_table(THD *thd, const void *key) DBUG_ENTER("Thd_ndb::get_open_table"); HASH_SEARCH_STATE state; THD_NDB_SHARE *thd_ndb_share= - (THD_NDB_SHARE*)hash_first(&open_tables, (byte *)&key, sizeof(key), &state); + (THD_NDB_SHARE*)hash_first(&open_tables, (uchar *)&key, sizeof(key), &state); while (thd_ndb_share && thd_ndb_share->key != key) - thd_ndb_share= (THD_NDB_SHARE*)hash_next(&open_tables, (byte *)&key, sizeof(key), &state); + thd_ndb_share= (THD_NDB_SHARE*)hash_next(&open_tables, (uchar *)&key, sizeof(key), &state); if (thd_ndb_share == 0) { thd_ndb_share= (THD_NDB_SHARE *) alloc_root(&thd->transaction.mem_root, @@ -406,7 +406,7 @@ Thd_ndb::get_open_table(THD *thd, const void *key) thd_ndb_share->stat.last_count= count; thd_ndb_share->stat.no_uncommitted_rows_count= 0; thd_ndb_share->stat.records= ~(ha_rows)0; - my_hash_insert(&open_tables, (byte *)thd_ndb_share); + my_hash_insert(&open_tables, (uchar *)thd_ndb_share); } else if (thd_ndb_share->stat.last_count != count) { @@ -674,7 +674,7 @@ static bool field_type_forces_var_part(enum_field_types type) */ bool ha_ndbcluster::set_hidden_key(NdbOperation *ndb_op, - uint fieldnr, const byte *field_ptr) + uint fieldnr, const uchar *field_ptr) { DBUG_ENTER("set_hidden_key"); DBUG_RETURN(ndb_op->equal(fieldnr, (char*)field_ptr) != 0); @@ -686,14 +686,14 @@ bool ha_ndbcluster::set_hidden_key(NdbOperation *ndb_op, */ int ha_ndbcluster::set_ndb_key(NdbOperation *ndb_op, Field *field, - uint fieldnr, const byte *field_ptr) + uint fieldnr, const uchar *field_ptr) { uint32 pack_len= field->pack_length(); DBUG_ENTER("set_ndb_key"); DBUG_PRINT("enter", ("%d: %s, ndb_type: %u, len=%d", fieldnr, field->field_name, field->type(), pack_len)); - DBUG_DUMP("key", (char*)field_ptr, pack_len); + DBUG_DUMP("key", field_ptr, pack_len); DBUG_ASSERT(ndb_supported_type(field->type())); DBUG_ASSERT(! (field->flags & BLOB_FLAG)); @@ -710,13 +710,13 @@ int ha_ndbcluster::set_ndb_value(NdbOperation *ndb_op, Field *field, uint fieldnr, int row_offset, bool *set_blob_value) { - const byte* field_ptr= field->ptr + row_offset; + const uchar* field_ptr= field->ptr + row_offset; uint32 pack_len= field->pack_length(); DBUG_ENTER("set_ndb_value"); DBUG_PRINT("enter", ("%d: %s type: %u len=%d is_null=%s", fieldnr, field->field_name, field->type(), pack_len, field->is_null(row_offset) ? "Y" : "N")); - DBUG_DUMP("value", (char*) field_ptr, pack_len); + DBUG_DUMP("value", field_ptr, pack_len); DBUG_ASSERT(ndb_supported_type(field->type())); { @@ -725,7 +725,7 @@ int ha_ndbcluster::set_ndb_value(NdbOperation *ndb_op, Field *field, if (pack_len == 0) { pack_len= sizeof(empty_field); - field_ptr= (byte *)&empty_field; + field_ptr= (uchar *)&empty_field; if (field->is_null(row_offset)) empty_field= 0; else @@ -755,7 +755,7 @@ int ha_ndbcluster::set_ndb_value(NdbOperation *ndb_op, Field *field, // Set value to NULL DBUG_RETURN((ndb_op->setValue(fieldnr, (char*)NULL) != 0)); DBUG_PRINT("info", ("bit field")); - DBUG_DUMP("value", (char*)&bits, pack_len); + DBUG_DUMP("value", (uchar*)&bits, pack_len); #ifdef WORDS_BIGENDIAN /* store lsw first */ bits = ((bits >> 32) & 0x00000000FFFFFFFFLL) @@ -775,18 +775,18 @@ int ha_ndbcluster::set_ndb_value(NdbOperation *ndb_op, Field *field, // Get length and pointer to data uint32 blob_len= field_blob->get_length(field_ptr); - char* blob_ptr= NULL; + uchar* blob_ptr= NULL; field_blob->get_ptr(&blob_ptr); // Looks like NULL ptr signals length 0 blob if (blob_ptr == NULL) { DBUG_ASSERT(blob_len == 0); - blob_ptr= (char*)""; + blob_ptr= (uchar*)""; } DBUG_PRINT("value", ("set blob ptr: 0x%lx len: %u", (long) blob_ptr, blob_len)); - DBUG_DUMP("value", (char*)blob_ptr, min(blob_len, 26)); + DBUG_DUMP("value", blob_ptr, min(blob_len, 26)); if (set_blob_value) *set_blob_value= TRUE; @@ -830,7 +830,7 @@ int g_get_ndb_blobs_value(NdbBlob *ndb_blob, void *arg) passes a record pointer diff. */ int get_ndb_blobs_value(TABLE* table, NdbValue* value_array, - byte*& buffer, uint& buffer_size, + uchar*& buffer, uint& buffer_size, my_ptrdiff_t ptrdiff) { DBUG_ENTER("get_ndb_blobs_value"); @@ -866,7 +866,7 @@ int get_ndb_blobs_value(TABLE* table, NdbValue* value_array, size+= 8 - size % 8; if (loop == 1) { - char *buf= buffer + offset; + uchar *buf= buffer + offset; uint32 len= 0xffffffff; // Max uint32 if (ndb_blob->readData(buf, len) != 0) ERR_RETURN(ndb_blob->getNdbError()); @@ -881,9 +881,9 @@ int get_ndb_blobs_value(TABLE* table, NdbValue* value_array, else if (loop == 1) // undefined or null { // have to set length even in this case - char *buf= buffer + offset; // or maybe NULL + uchar *buf= buffer + offset; // or maybe NULL uint32 len= 0; - field_blob->set_ptr_offset(ptrdiff, len, buf); + field_blob->set_ptr_offset(ptrdiff, len, buf); DBUG_PRINT("info", ("[%u] isNull=%d", i, isNull)); } } @@ -892,7 +892,7 @@ int get_ndb_blobs_value(TABLE* table, NdbValue* value_array, my_free(buffer, MYF(MY_ALLOW_ZERO_PTR)); buffer_size= 0; DBUG_PRINT("info", ("allocate blobs buffer size %u", offset)); - buffer= my_malloc(offset, MYF(MY_WME)); + buffer= (uchar*) my_malloc(offset, MYF(MY_WME)); if (buffer == NULL) { sql_print_error("ha_ndbcluster::get_ndb_blobs_value: " @@ -913,7 +913,7 @@ int get_ndb_blobs_value(TABLE* table, NdbValue* value_array, */ int ha_ndbcluster::get_ndb_value(NdbOperation *ndb_op, Field *field, - uint fieldnr, byte* buf) + uint fieldnr, uchar* buf) { DBUG_ENTER("get_ndb_value"); DBUG_PRINT("enter", ("fieldnr: %d flags: %o", fieldnr, @@ -928,13 +928,13 @@ int ha_ndbcluster::get_ndb_value(NdbOperation *ndb_op, Field *field, { if (field->type() != MYSQL_TYPE_BIT) { - byte *field_buf; + uchar *field_buf; if (field->pack_length() != 0) field_buf= buf + (field->ptr - table->record[0]); else - field_buf= (byte *)&dummy_buf; + field_buf= (uchar *)&dummy_buf; m_value[fieldnr].rec= ndb_op->getValue(fieldnr, - field_buf); + (char*) field_buf); } else // if (field->type() == MYSQL_TYPE_BIT) { @@ -949,7 +949,7 @@ int ha_ndbcluster::get_ndb_value(NdbOperation *ndb_op, Field *field, if (ndb_blob != NULL) { // Set callback - m_blobs_offset= buf - (byte*) table->record[0]; + m_blobs_offset= buf - (uchar*) table->record[0]; void *arg= (void *)this; DBUG_RETURN(ndb_blob->setActiveHook(g_get_ndb_blobs_value, arg) != 0); } @@ -957,7 +957,7 @@ int ha_ndbcluster::get_ndb_value(NdbOperation *ndb_op, Field *field, } // Used for hidden key only - m_value[fieldnr].rec= ndb_op->getValue(fieldnr, m_ref); + m_value[fieldnr].rec= ndb_op->getValue(fieldnr, (char*) m_ref); DBUG_RETURN(m_value[fieldnr].rec == NULL); } @@ -1031,8 +1031,8 @@ int ha_ndbcluster::get_metadata(const char *path) DBUG_ASSERT(m_table == NULL); DBUG_ASSERT(m_table_info == NULL); - const void *data= NULL, *pack_data= NULL; - uint length, pack_length; + uchar *data= NULL, *pack_data= NULL; + size_t length, pack_length; /* Compare FrmData in NDB with frm file from disk. @@ -1041,8 +1041,8 @@ int ha_ndbcluster::get_metadata(const char *path) if (readfrm(path, &data, &length) || packfrm(data, length, &pack_data, &pack_length)) { - my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR)); - my_free((char*)pack_data, MYF(MY_ALLOW_ZERO_PTR)); + my_free(data, MYF(MY_ALLOW_ZERO_PTR)); + my_free(pack_data, MYF(MY_ALLOW_ZERO_PTR)); DBUG_RETURN(1); } @@ -1054,11 +1054,11 @@ int ha_ndbcluster::get_metadata(const char *path) && cmp_frm(tab, pack_data, pack_length)) { DBUG_PRINT("error", - ("metadata, pack_length: %d getFrmLength: %d memcmp: %d", - pack_length, tab->getFrmLength(), + ("metadata, pack_length: %lu getFrmLength: %d memcmp: %d", + (ulong) pack_length, tab->getFrmLength(), memcmp(pack_data, tab->getFrmData(), pack_length))); - DBUG_DUMP("pack_data", (char*)pack_data, pack_length); - DBUG_DUMP("frm", (char*)tab->getFrmData(), tab->getFrmLength()); + DBUG_DUMP("pack_data", (uchar*) pack_data, pack_length); + DBUG_DUMP("frm", (uchar*) tab->getFrmData(), tab->getFrmLength()); error= HA_ERR_TABLE_DEF_CHANGED; } my_free((char*)data, MYF(0)); @@ -1561,7 +1561,7 @@ inline ulong ha_ndbcluster::index_flags(uint idx_no, uint part, HA_KEY_SCAN_NOT_ROR); } -static void shrink_varchar(Field* field, const byte* & ptr, char* buf) +static void shrink_varchar(Field* field, const uchar* & ptr, uchar* buf) { if (field->type() == MYSQL_TYPE_VARCHAR && ptr != NULL) { Field_varstring* f= (Field_varstring*)field; @@ -1580,7 +1580,7 @@ static void shrink_varchar(Field* field, const byte* & ptr, char* buf) } } -int ha_ndbcluster::set_primary_key(NdbOperation *op, const byte *key) +int ha_ndbcluster::set_primary_key(NdbOperation *op, const uchar *key) { KEY* key_info= table->key_info + table_share->primary_key; KEY_PART_INFO* key_part= key_info->key_part; @@ -1590,8 +1590,8 @@ int ha_ndbcluster::set_primary_key(NdbOperation *op, const byte *key) for (; key_part != end; key_part++) { Field* field= key_part->field; - const byte* ptr= key; - char buf[256]; + const uchar* ptr= key; + uchar buf[256]; shrink_varchar(field, ptr, buf); if (set_ndb_key(op, field, key_part->fieldnr-1, ptr)) @@ -1602,7 +1602,7 @@ int ha_ndbcluster::set_primary_key(NdbOperation *op, const byte *key) } -int ha_ndbcluster::set_primary_key_from_record(NdbOperation *op, const byte *record) +int ha_ndbcluster::set_primary_key_from_record(NdbOperation *op, const uchar *record) { KEY* key_info= table->key_info + table_share->primary_key; KEY_PART_INFO* key_part= key_info->key_part; @@ -1620,7 +1620,7 @@ int ha_ndbcluster::set_primary_key_from_record(NdbOperation *op, const byte *rec } int ha_ndbcluster::set_index_key_from_record(NdbOperation *op, - const byte *record, uint keyno) + const uchar *record, uint keyno) { KEY* key_info= table->key_info + keyno; KEY_PART_INFO* key_part= key_info->key_part; @@ -1641,7 +1641,7 @@ int ha_ndbcluster::set_index_key_from_record(NdbOperation *op, int ha_ndbcluster::set_index_key(NdbOperation *op, const KEY *key_info, - const byte * key_ptr) + const uchar * key_ptr) { DBUG_ENTER("ha_ndbcluster::set_index_key"); uint i; @@ -1651,8 +1651,8 @@ ha_ndbcluster::set_index_key(NdbOperation *op, for (i= 0; key_part != end; key_part++, i++) { Field* field= key_part->field; - const byte* ptr= key_part->null_bit ? key_ptr + 1 : key_ptr; - char buf[256]; + const uchar* ptr= key_part->null_bit ? key_ptr + 1 : key_ptr; + uchar buf[256]; shrink_varchar(field, ptr, buf); if (set_ndb_key(op, field, m_index[active_index].unique_index_attrid_map[i], ptr)) ERR_RETURN(m_active_trans->getNdbError()); @@ -1662,7 +1662,7 @@ ha_ndbcluster::set_index_key(NdbOperation *op, } inline -int ha_ndbcluster::define_read_attrs(byte* buf, NdbOperation* op) +int ha_ndbcluster::define_read_attrs(uchar* buf, NdbOperation* op) { uint i; DBUG_ENTER("define_read_attrs"); @@ -1704,7 +1704,7 @@ int ha_ndbcluster::define_read_attrs(byte* buf, NdbOperation* op) Read one record from NDB using primary key */ -int ha_ndbcluster::pk_read(const byte *key, uint key_len, byte *buf, +int ha_ndbcluster::pk_read(const uchar *key, uint key_len, uchar *buf, uint32 part_id) { uint no_fields= table_share->fields; @@ -1714,7 +1714,7 @@ int ha_ndbcluster::pk_read(const byte *key, uint key_len, byte *buf, int res; DBUG_ENTER("pk_read"); DBUG_PRINT("enter", ("key_len: %u", key_len)); - DBUG_DUMP("key", (char*)key, key_len); + DBUG_DUMP("key", key, key_len); m_write_op= FALSE; NdbOperation::LockMode lm= @@ -1727,7 +1727,7 @@ int ha_ndbcluster::pk_read(const byte *key, uint key_len, byte *buf, { // This table has no primary key, use "hidden" primary key DBUG_PRINT("info", ("Using hidden key")); - DBUG_DUMP("key", (char*)key, 8); + DBUG_DUMP("key", key, 8); if (set_hidden_key(op, no_fields, key)) ERR_RETURN(trans->getNdbError()); @@ -1773,7 +1773,7 @@ int ha_ndbcluster::pk_read(const byte *key, uint key_len, byte *buf, or hidden key */ -int ha_ndbcluster::complemented_read(const byte *old_data, byte *new_data, +int ha_ndbcluster::complemented_read(const uchar *old_data, uchar *new_data, uint32 old_part_id) { uint no_fields= table_share->fields, i; @@ -1910,7 +1910,7 @@ bool ha_ndbcluster::check_all_operations_for_error(NdbTransaction *trans, */ static int -check_null_in_record(const KEY* key_info, const byte *record) +check_null_in_record(const KEY* key_info, const uchar *record) { KEY_PART_INFO *curr_part, *end_part; curr_part= key_info->key_part; @@ -1937,7 +1937,7 @@ check_null_in_record(const KEY* key_info, const byte *record) * primary key or unique index values */ -int ha_ndbcluster::peek_indexed_rows(const byte *record, +int ha_ndbcluster::peek_indexed_rows(const uchar *record, bool check_pk) { NdbTransaction *trans= m_active_trans; @@ -2041,15 +2041,15 @@ int ha_ndbcluster::peek_indexed_rows(const byte *record, Read one record from NDB using unique secondary index */ -int ha_ndbcluster::unique_index_read(const byte *key, - uint key_len, byte *buf) +int ha_ndbcluster::unique_index_read(const uchar *key, + uint key_len, uchar *buf) { int res; NdbTransaction *trans= m_active_trans; NdbIndexOperation *op; DBUG_ENTER("ha_ndbcluster::unique_index_read"); DBUG_PRINT("enter", ("key_len: %u, index: %u", key_len, active_index)); - DBUG_DUMP("key", (char*)key, key_len); + DBUG_DUMP("key", key, key_len); NdbOperation::LockMode lm= (NdbOperation::LockMode)get_ndb_lock_type(m_lock.type); @@ -2185,7 +2185,7 @@ inline int ha_ndbcluster::fetch_next(NdbScanOperation* cursor) */ -inline int ha_ndbcluster::next_result(byte *buf) +inline int ha_ndbcluster::next_result(uchar *buf) { int res; DBUG_ENTER("next_result"); @@ -2264,10 +2264,10 @@ int ha_ndbcluster::set_bounds(NdbIndexScanOperation *op, struct part_st { bool part_last; const key_range *key; - const byte *part_ptr; + const uchar *part_ptr; bool part_null; int bound_type; - const char* bound_ptr; + const uchar* bound_ptr; }; struct part_st part[2]; @@ -2377,13 +2377,13 @@ int ha_ndbcluster::set_bounds(NdbIndexScanOperation *op, { DBUG_PRINT("info", ("key %d:%d offset: %d length: %d last: %d bound: %d", j, i, tot_len, part_len, p.part_last, p.bound_type)); - DBUG_DUMP("info", (const char*)p.part_ptr, part_store_len); + DBUG_DUMP("info", p.part_ptr, part_store_len); // Set bound if not cancelled via type -1 if (p.bound_type != -1) { - const char* ptr= p.bound_ptr; - char buf[256]; + const uchar* ptr= p.bound_ptr; + uchar buf[256]; shrink_varchar(field, ptr, buf); if (op->setBound(i, p.bound_type, ptr)) ERR_RETURN(op->getNdbError()); @@ -2403,7 +2403,7 @@ int ha_ndbcluster::set_bounds(NdbIndexScanOperation *op, int ha_ndbcluster::ordered_index_scan(const key_range *start_key, const key_range *end_key, bool sorted, bool descending, - byte* buf, part_id_range *part_spec) + uchar* buf, part_id_range *part_spec) { int res; bool restart; @@ -2509,9 +2509,9 @@ guess_scan_flags(NdbOperation::LockMode lm, */ int ha_ndbcluster::unique_index_scan(const KEY* key_info, - const byte *key, + const uchar *key, uint key_len, - byte *buf) + uchar *buf) { int res; NdbScanOperation *op; @@ -2585,7 +2585,7 @@ int ha_ndbcluster::unique_index_scan(const KEY* key_info, Start full table scan in NDB */ -int ha_ndbcluster::full_table_scan(byte *buf) +int ha_ndbcluster::full_table_scan(uchar *buf) { int res; NdbScanOperation *op; @@ -2652,7 +2652,7 @@ int ha_ndbcluster::full_table_scan(byte *buf) /* Insert one record into NDB */ -int ha_ndbcluster::write_row(byte *record) +int ha_ndbcluster::write_row(uchar *record) { bool has_auto_increment; uint i; @@ -2739,17 +2739,17 @@ int ha_ndbcluster::write_row(byte *record) Ndb_tuple_id_range_guard g(m_share); if (ndb->getAutoIncrementValue(m_table, g.range, auto_value, 1) == -1) { - if (--retries && - ndb->getNdbError().status == NdbError::TemporaryError); - { - my_sleep(retry_sleep); - continue; - } - ERR_RETURN(ndb->getNdbError()); + if (--retries && + ndb->getNdbError().status == NdbError::TemporaryError); + { + my_sleep(retry_sleep); + continue; + } + ERR_RETURN(ndb->getNdbError()); } break; } - if (set_hidden_key(op, table->s->fields, (const byte*)&auto_value)) + if (set_hidden_key(op, table_share->fields, (const uchar*)&auto_value)) ERR_RETURN(op->getNdbError()); } else @@ -2870,8 +2870,8 @@ int ha_ndbcluster::write_row(byte *record) /* Compare if a key in a row has changed */ -int ha_ndbcluster::key_cmp(uint keynr, const byte * old_row, - const byte * new_row) +int ha_ndbcluster::key_cmp(uint keynr, const uchar * old_row, + const uchar * new_row) { KEY_PART_INFO *key_part=table->key_info[keynr].key_part; KEY_PART_INFO *end=key_part+table->key_info[keynr].key_parts; @@ -2887,8 +2887,8 @@ int ha_ndbcluster::key_cmp(uint keynr, const byte * old_row, if (key_part->key_part_flag & (HA_BLOB_PART | HA_VAR_LENGTH_PART)) { - if (key_part->field->cmp_binary((char*) (old_row + key_part->offset), - (char*) (new_row + key_part->offset), + if (key_part->field->cmp_binary((old_row + key_part->offset), + (new_row + key_part->offset), (ulong) key_part->length)) return 1; } @@ -2906,7 +2906,7 @@ int ha_ndbcluster::key_cmp(uint keynr, const byte * old_row, Update one record in NDB using primary key */ -int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) +int ha_ndbcluster::update_row(const uchar *old_data, uchar *new_data) { THD *thd= table->in_use; NdbTransaction *trans= m_active_trans; @@ -2991,7 +2991,7 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) { // Undo delete_row(old_data) m_primary_key_update= TRUE; - undo_res= write_row((byte *)old_data); + undo_res= write_row((uchar *)old_data); if (undo_res) push_warning(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, @@ -3106,7 +3106,7 @@ int ha_ndbcluster::update_row(const byte *old_data, byte *new_data) Delete one record from NDB, using primary key */ -int ha_ndbcluster::delete_row(const byte *record) +int ha_ndbcluster::delete_row(const uchar *record) { THD *thd= table->in_use; NdbTransaction *trans= m_active_trans; @@ -3218,7 +3218,7 @@ int ha_ndbcluster::delete_row(const byte *record) */ void ndb_unpack_record(TABLE *table, NdbValue *value, - MY_BITMAP *defined, byte *buf) + MY_BITMAP *defined, uchar *buf) { Field **p_field= table->field, *field= *p_field; my_ptrdiff_t row_offset= (my_ptrdiff_t) (buf - table->record[0]); @@ -3305,13 +3305,13 @@ void ndb_unpack_record(TABLE *table, NdbValue *value, field_bit->Field_bit::move_field_offset(-row_offset); DBUG_PRINT("info",("[%u] SET", (*value).rec->getColumn()->getColumnNo())); - DBUG_DUMP("info", (const char*) field->ptr, field->pack_length()); + DBUG_DUMP("info", field->ptr, field->pack_length()); } else { DBUG_PRINT("info",("[%u] SET", (*value).rec->getColumn()->getColumnNo())); - DBUG_DUMP("info", (const char*) field->ptr, field->pack_length()); + DBUG_DUMP("info", field->ptr, field->pack_length()); } } else @@ -3335,7 +3335,7 @@ void ndb_unpack_record(TABLE *table, NdbValue *value, #ifndef DBUG_OFF // pointer vas set in get_ndb_blobs_value Field_blob *field_blob= (Field_blob*)field; - char* ptr; + uchar *ptr; field_blob->get_ptr(&ptr, row_offset); uint32 len= field_blob->get_length(row_offset); DBUG_PRINT("info",("[%u] SET ptr: 0x%lx len: %u", @@ -3349,7 +3349,7 @@ void ndb_unpack_record(TABLE *table, NdbValue *value, DBUG_VOID_RETURN; } -void ha_ndbcluster::unpack_record(byte *buf) +void ha_ndbcluster::unpack_record(uchar *buf) { ndb_unpack_record(table, m_value, 0, buf); #ifndef DBUG_OFF @@ -3462,10 +3462,10 @@ int ha_ndbcluster::index_end() */ static int -check_null_in_key(const KEY* key_info, const byte *key, uint key_len) +check_null_in_key(const KEY* key_info, const uchar *key, uint key_len) { KEY_PART_INFO *curr_part, *end_part; - const byte* end_ptr= key + key_len; + const uchar* end_ptr= key + key_len; curr_part= key_info->key_part; end_part= curr_part + key_info->key_parts; @@ -3479,8 +3479,8 @@ check_null_in_key(const KEY* key_info, const byte *key, uint key_len) return 0; } -int ha_ndbcluster::index_read(byte *buf, - const byte *key, uint key_len, +int ha_ndbcluster::index_read(uchar *buf, + const uchar *key, uint key_len, enum ha_rkey_function find_flag) { key_range start_key; @@ -3508,7 +3508,7 @@ int ha_ndbcluster::index_read(byte *buf, } -int ha_ndbcluster::index_next(byte *buf) +int ha_ndbcluster::index_next(uchar *buf) { DBUG_ENTER("ha_ndbcluster::index_next"); ha_statistic_increment(&SSV::ha_read_next_count); @@ -3516,7 +3516,7 @@ int ha_ndbcluster::index_next(byte *buf) } -int ha_ndbcluster::index_prev(byte *buf) +int ha_ndbcluster::index_prev(uchar *buf) { DBUG_ENTER("ha_ndbcluster::index_prev"); ha_statistic_increment(&SSV::ha_read_prev_count); @@ -3524,7 +3524,7 @@ int ha_ndbcluster::index_prev(byte *buf) } -int ha_ndbcluster::index_first(byte *buf) +int ha_ndbcluster::index_first(uchar *buf) { DBUG_ENTER("ha_ndbcluster::index_first"); ha_statistic_increment(&SSV::ha_read_first_count); @@ -3535,14 +3535,14 @@ int ha_ndbcluster::index_first(byte *buf) } -int ha_ndbcluster::index_last(byte *buf) +int ha_ndbcluster::index_last(uchar *buf) { DBUG_ENTER("ha_ndbcluster::index_last"); ha_statistic_increment(&SSV::ha_read_last_count); DBUG_RETURN(ordered_index_scan(0, 0, TRUE, TRUE, buf, NULL)); } -int ha_ndbcluster::index_read_last(byte * buf, const byte * key, uint key_len) +int ha_ndbcluster::index_read_last(uchar * buf, const uchar * key, uint key_len) { DBUG_ENTER("ha_ndbcluster::index_read_last"); DBUG_RETURN(index_read(buf, key, key_len, HA_READ_PREFIX_LAST)); @@ -3551,7 +3551,7 @@ int ha_ndbcluster::index_read_last(byte * buf, const byte * key, uint key_len) int ha_ndbcluster::read_range_first_to_buf(const key_range *start_key, const key_range *end_key, bool desc, bool sorted, - byte* buf) + uchar* buf) { part_id_range part_spec; ndb_index_type type= get_index_type(active_index); @@ -3631,7 +3631,7 @@ int ha_ndbcluster::read_range_first(const key_range *start_key, const key_range *end_key, bool eq_r, bool sorted) { - byte* buf= table->record[0]; + uchar* buf= table->record[0]; DBUG_ENTER("ha_ndbcluster::read_range_first"); DBUG_RETURN(read_range_first_to_buf(start_key, end_key, FALSE, sorted, buf)); @@ -3721,7 +3721,7 @@ int ha_ndbcluster::rnd_end() } -int ha_ndbcluster::rnd_next(byte *buf) +int ha_ndbcluster::rnd_next(uchar *buf) { DBUG_ENTER("rnd_next"); ha_statistic_increment(&SSV::ha_read_rnd_next_count); @@ -3739,7 +3739,7 @@ int ha_ndbcluster::rnd_next(byte *buf) again */ -int ha_ndbcluster::rnd_pos(byte *buf, byte *pos) +int ha_ndbcluster::rnd_pos(uchar *buf, uchar *pos) { DBUG_ENTER("rnd_pos"); ha_statistic_increment(&SSV::ha_read_rnd_count); @@ -3756,7 +3756,7 @@ int ha_ndbcluster::rnd_pos(byte *buf, byte *pos) The partition id has been fetched from ndb and has been stored directly after the hidden key */ - DBUG_DUMP("key+part", (char *)pos, key_length); + DBUG_DUMP("key+part", pos, key_length); key_length= ref_length - sizeof(m_part_id); part_spec.start_part= part_spec.end_part= *(uint32 *)(pos + key_length); } @@ -3773,7 +3773,7 @@ int ha_ndbcluster::rnd_pos(byte *buf, byte *pos) } DBUG_PRINT("info", ("partition id %u", part_spec.start_part)); } - DBUG_DUMP("key", (char *)pos, key_length); + DBUG_DUMP("key", pos, key_length); DBUG_RETURN(pk_read(pos, key_length, buf, part_spec.start_part)); } } @@ -3785,12 +3785,12 @@ int ha_ndbcluster::rnd_pos(byte *buf, byte *pos) using "reference" in rnd_pos */ -void ha_ndbcluster::position(const byte *record) +void ha_ndbcluster::position(const uchar *record) { KEY *key_info; KEY_PART_INFO *key_part; KEY_PART_INFO *end; - byte *buff; + uchar *buff; uint key_length; DBUG_ENTER("position"); @@ -3816,7 +3816,7 @@ void ha_ndbcluster::position(const byte *record) } size_t len = key_part->length; - const byte * ptr = record + key_part->offset; + const uchar * ptr = record + key_part->offset; Field *field = key_part->field; if (field->type() == MYSQL_TYPE_VARCHAR) { @@ -3867,9 +3867,9 @@ void ha_ndbcluster::position(const byte *record) } #ifndef DBUG_OFF if (table_share->primary_key == MAX_KEY && m_use_partition_function) - DBUG_DUMP("key+part", (char*)ref, key_length+sizeof(m_part_id)); + DBUG_DUMP("key+part", ref, key_length+sizeof(m_part_id)); #endif - DBUG_DUMP("ref", (char*)ref, key_length); + DBUG_DUMP("ref", ref, key_length); DBUG_VOID_RETURN; } @@ -4972,8 +4972,9 @@ int ha_ndbcluster::create(const char *name, THD *thd= current_thd; NDBTAB tab; NDBCOL col; - uint pack_length, length, i, pk_length= 0; - const void *data= NULL, *pack_data= NULL; + size_t pack_length, length; + uint i, pk_length= 0; + uchar *data= NULL, *pack_data= NULL; bool create_from_engine= (create_info->table_options & HA_OPTION_CREATE_FROM_ENGINE); bool is_truncate= (thd->lex->sql_command == SQLCOM_TRUNCATE); char tablespace[FN_LEN]; @@ -5057,7 +5058,9 @@ int ha_ndbcluster::create(const char *name, my_free((char*)data, MYF(0)); DBUG_RETURN(2); } - DBUG_PRINT("info", ("setFrm data: 0x%lx len: %d", (long) pack_data, pack_length)); + DBUG_PRINT("info", + ("setFrm data: 0x%lx len: %lu", (long) pack_data, + (ulong) pack_length)); tab.setFrm(pack_data, pack_length); my_free((char*)data, MYF(0)); my_free((char*)pack_data, MYF(0)); @@ -5292,7 +5295,7 @@ int ha_ndbcluster::create(const char *name, { uint length= (uint) strlen(name); if ((share= (NDB_SHARE*) hash_search(&ndbcluster_open_tables, - (byte*) name, length))) + (uchar*) name, length))) handle_trailing_share(share); } /* @@ -5371,8 +5374,8 @@ int ha_ndbcluster::create_handler_files(const char *file, { Ndb* ndb; const NDBTAB *tab; - const void *data= NULL, *pack_data= NULL; - uint length, pack_length; + uchar *data= NULL, *pack_data= NULL; + size_t length, pack_length; int error= 0; DBUG_ENTER("create_handler_files"); @@ -6448,13 +6451,13 @@ static int ndbcluster_close_connection(handlerton *hton, THD *thd) int ndbcluster_discover(handlerton *hton, THD* thd, const char *db, const char *name, - const void** frmblob, - uint* frmlen) + uchar **frmblob, + size_t *frmlen) { int error= 0; NdbError ndb_error; - uint len; - const void* data= NULL; + size_t len; + uchar* data= NULL; Ndb* ndb; char key[FN_REFLEN]; DBUG_ENTER("ndbcluster_discover"); @@ -6515,7 +6518,7 @@ int ndbcluster_discover(handlerton *hton, THD* thd, const char *db, goto err; } - if (unpackfrm(&data, &len, tab->getFrmData())) + if (unpackfrm(&data, &len, (uchar*) tab->getFrmData())) { DBUG_PRINT("error", ("Could not unpack table")); error= 1; @@ -6585,11 +6588,11 @@ int ndbcluster_table_exists_in_engine(handlerton *hton, THD* thd, -extern "C" byte* tables_get_key(const char *entry, uint *length, +extern "C" uchar* tables_get_key(const char *entry, size_t *length, my_bool not_used __attribute__((unused))) { *length= strlen(entry); - return (byte*) entry; + return (uchar*) entry; } @@ -6770,8 +6773,8 @@ int ndbcluster_find_all_files(THD *thd) /* finalize construction of path */ end+= tablename_to_filename(elmt.name, end, sizeof(key)-(end-key)); - const void *data= 0, *pack_data= 0; - uint length, pack_length; + uchar *data= 0, *pack_data= 0; + size_t length, pack_length; int discover= 0; if (readfrm(key, &data, &length) || packfrm(data, length, &pack_data, &pack_length)) @@ -6899,7 +6902,7 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, continue; } DBUG_PRINT("info", ("Inserting %s into ndb_tables hash", elmt.name)); - my_hash_insert(&ndb_tables, (byte*)thd->strdup(elmt.name)); + my_hash_insert(&ndb_tables, (uchar*)thd->strdup(elmt.name)); } char *file_name; @@ -6909,7 +6912,7 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, { bool file_on_disk= FALSE; DBUG_PRINT("info", ("%s", file_name)); - if (hash_search(&ndb_tables, file_name, strlen(file_name))) + if (hash_search(&ndb_tables, (uchar*) file_name, strlen(file_name))) { DBUG_PRINT("info", ("%s existed in NDB _and_ on disk ", file_name)); file_on_disk= TRUE; @@ -6925,7 +6928,8 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, if (file_on_disk) { // Ignore this ndb table - gptr record= hash_search(&ndb_tables, file_name, strlen(file_name)); + uchar *record= hash_search(&ndb_tables, (uchar*) file_name, + strlen(file_name)); DBUG_ASSERT(record); hash_delete(&ndb_tables, record); push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN, @@ -6938,7 +6942,7 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, if (file_on_disk) { // File existed in NDB and as frm file, put in ok_tables list - my_hash_insert(&ok_tables, (byte*)file_name); + my_hash_insert(&ok_tables, (uchar*)file_name); continue; } DBUG_PRINT("info", ("%s existed on disk", name)); @@ -6976,8 +6980,8 @@ int ndbcluster_find_files(handlerton *hton, THD *thd, List<char> create_list; for (i= 0 ; i < ndb_tables.records ; i++) { - file_name= hash_element(&ndb_tables, i); - if (!hash_search(&ok_tables, file_name, strlen(file_name))) + file_name= (char*) hash_element(&ndb_tables, i); + if (!hash_search(&ok_tables, (uchar*) file_name, strlen(file_name))) { build_table_filename(name, sizeof(name), db, file_name, reg_ext, 0); if (my_access(name, F_OK)) @@ -7609,7 +7613,7 @@ uint ndb_get_commitcount(THD *thd, char *dbname, char *tabname, DBUG_PRINT("enter", ("name: %s", name)); pthread_mutex_lock(&ndbcluster_mutex); if (!(share=(NDB_SHARE*) hash_search(&ndbcluster_open_tables, - (byte*) name, + (uchar*) name, strlen(name)))) { pthread_mutex_unlock(&ndbcluster_mutex); @@ -7834,11 +7838,11 @@ ha_ndbcluster::register_query_cache_table(THD *thd, data we want to or can share. */ -static byte *ndbcluster_get_key(NDB_SHARE *share,uint *length, +static uchar *ndbcluster_get_key(NDB_SHARE *share, size_t *length, my_bool not_used __attribute__((unused))) { *length= share->key_length; - return (byte*) share->key; + return (uchar*) share->key; } @@ -7981,7 +7985,7 @@ int handle_trailing_share(NDB_SHARE *share) at the cost of a possible mem leak, by "renaming" the share - First remove from hash */ - hash_delete(&ndbcluster_open_tables, (byte*) share); + hash_delete(&ndbcluster_open_tables, (uchar*) share); /* now give it a new name, just a running number @@ -7991,7 +7995,7 @@ int handle_trailing_share(NDB_SHARE *share) const uint min_key_length= 10; if (share->key_length < min_key_length) { - share->key= alloc_root(&share->mem_root, min_key_length + 1); + share->key= (char*) alloc_root(&share->mem_root, min_key_length + 1); share->key_length= min_key_length; } share->key_length= @@ -7999,7 +8003,7 @@ int handle_trailing_share(NDB_SHARE *share) trailing_share_id++); } /* Keep it for possible the future trailing free */ - my_hash_insert(&ndbcluster_open_tables, (byte*) share); + my_hash_insert(&ndbcluster_open_tables, (uchar*) share); DBUG_RETURN(0); } @@ -8015,11 +8019,11 @@ static int rename_share(NDB_SHARE *share, const char *new_key) DBUG_PRINT("rename_share", ("old_key: %s old__length: %d", share->key, share->key_length)); if ((tmp= (NDB_SHARE*) hash_search(&ndbcluster_open_tables, - (byte*) new_key, new_length))) + (uchar*) new_key, new_length))) handle_trailing_share(tmp); /* remove the share from hash */ - hash_delete(&ndbcluster_open_tables, (byte*) share); + hash_delete(&ndbcluster_open_tables, (uchar*) share); dbug_print_open_tables(); /* save old stuff if insert should fail */ @@ -8030,18 +8034,18 @@ static int rename_share(NDB_SHARE *share, const char *new_key) now allocate and set the new key, db etc enough space for key, db, and table_name */ - share->key= alloc_root(&share->mem_root, 2 * (new_length + 1)); + share->key= (char*) alloc_root(&share->mem_root, 2 * (new_length + 1)); strmov(share->key, new_key); share->key_length= new_length; - if (my_hash_insert(&ndbcluster_open_tables, (byte*) share)) + if (my_hash_insert(&ndbcluster_open_tables, (uchar*) share)) { // ToDo free the allocated stuff above? DBUG_PRINT("error", ("rename_share: my_hash_insert %s failed", share->key)); share->key= old_key; share->key_length= old_length; - if (my_hash_insert(&ndbcluster_open_tables, (byte*) share)) + if (my_hash_insert(&ndbcluster_open_tables, (uchar*) share)) { sql_print_error("rename_share: failed to recover %s", share->key); DBUG_PRINT("error", ("rename_share: my_hash_insert %s failed", @@ -8121,7 +8125,7 @@ NDB_SHARE *ndbcluster_get_share(const char *key, TABLE *table, if (!have_lock) pthread_mutex_lock(&ndbcluster_mutex); if (!(share= (NDB_SHARE*) hash_search(&ndbcluster_open_tables, - (byte*) key, + (uchar*) key, length))) { if (!create_if_not_exists) @@ -8141,13 +8145,13 @@ NDB_SHARE *ndbcluster_get_share(const char *key, TABLE *table, *root_ptr= &share->mem_root; // remember to reset before return share->state= NSS_INITIAL; /* enough space for key, db, and table_name */ - share->key= alloc_root(*root_ptr, 2 * (length + 1)); + share->key= (char*) alloc_root(*root_ptr, 2 * (length + 1)); share->key_length= length; strmov(share->key, key); - if (my_hash_insert(&ndbcluster_open_tables, (byte*) share)) + if (my_hash_insert(&ndbcluster_open_tables, (uchar*) share)) { free_root(&share->mem_root, MYF(0)); - my_free((gptr) share, 0); + my_free((uchar*) share, 0); *root_ptr= old_root; if (!have_lock) pthread_mutex_unlock(&ndbcluster_mutex); @@ -8190,7 +8194,7 @@ void ndbcluster_real_free_share(NDB_SHARE **share) DBUG_ENTER("ndbcluster_real_free_share"); dbug_print_share("ndbcluster_real_free_share:", *share); - hash_delete(&ndbcluster_open_tables, (byte*) *share); + hash_delete(&ndbcluster_open_tables, (uchar*) *share); thr_lock_delete(&(*share)->lock); pthread_mutex_destroy(&(*share)->mutex); @@ -8202,15 +8206,15 @@ void ndbcluster_real_free_share(NDB_SHARE **share) // (*share)->table_share->mem_root is freed by free_table_share free_table_share((*share)->table_share); #ifndef DBUG_OFF - bzero((gptr)(*share)->table_share, sizeof(*(*share)->table_share)); - bzero((gptr)(*share)->table, sizeof(*(*share)->table)); + bzero((uchar*)(*share)->table_share, sizeof(*(*share)->table_share)); + bzero((uchar*)(*share)->table, sizeof(*(*share)->table)); (*share)->table_share= 0; (*share)->table= 0; #endif } #endif free_root(&(*share)->mem_root, MYF(0)); - my_free((gptr) *share, MYF(0)); + my_free((uchar*) *share, MYF(0)); *share= 0; dbug_print_open_tables(); @@ -8435,13 +8439,13 @@ ha_ndbcluster::null_value_index_search(KEY_MULTI_RANGE *ranges, KEY* key_info= table->key_info + active_index; KEY_MULTI_RANGE *range= ranges; ulong reclength= table->s->reclength; - byte *curr= (byte*)buffer->buffer; - byte *end_of_buffer= (byte*)buffer->buffer_end; + uchar *curr= (uchar*)buffer->buffer; + uchar *end_of_buffer= (uchar*)buffer->buffer_end; for (; range<end_range && curr+reclength <= end_of_buffer; range++) { - const byte *key= range->start_key.key; + const uchar *key= range->start_key.key; uint key_len= range->start_key.length; if (check_null_in_key(key_info, key, key_len)) DBUG_RETURN(TRUE); @@ -8509,8 +8513,8 @@ ha_ndbcluster::read_multi_range_first(KEY_MULTI_RANGE **found_range_p, /** * Variables for loop */ - byte *curr= (byte*)buffer->buffer; - byte *end_of_buffer= (byte*)buffer->buffer_end; + uchar *curr= (uchar*)buffer->buffer; + uchar *end_of_buffer= (uchar*)buffer->buffer_end; NdbOperation::LockMode lm= (NdbOperation::LockMode)get_ndb_lock_type(m_lock.type); bool need_pk = (lm == NdbOperation::LM_Read); @@ -8639,7 +8643,7 @@ ha_ndbcluster::read_multi_range_first(KEY_MULTI_RANGE **found_range_p, * This as we don't want mysqld to reuse the buffer when we read * the remaining ranges */ - buffer->end_of_used_area= (byte*)buffer->buffer_end; + buffer->end_of_used_area= (uchar*)buffer->buffer_end; } else { @@ -8655,7 +8659,7 @@ ha_ndbcluster::read_multi_range_first(KEY_MULTI_RANGE **found_range_p, { m_multi_range_defined= multi_range_curr; multi_range_curr= ranges; - m_multi_range_result_ptr= (byte*)buffer->buffer; + m_multi_range_result_ptr= (uchar*)buffer->buffer; DBUG_RETURN(read_multi_range_next(found_range_p)); } ERR_RETURN(m_active_trans->getNdbError()); @@ -8874,7 +8878,7 @@ ha_ndbcluster::update_table_comment( char *str; const char *fmt="%s%snumber_of_replicas: %d"; const unsigned fmt_len_plus_extra= length + strlen(fmt); - if ((str= my_malloc(fmt_len_plus_extra, MYF(0))) == NULL) + if ((str= (char*) my_malloc(fmt_len_plus_extra, MYF(0))) == NULL) { sql_print_error("ha_ndbcluster::update_table_comment: " "my_malloc(%u) failed", (unsigned int)fmt_len_plus_extra); diff --git a/sql/ha_ndbcluster.h b/sql/ha_ndbcluster.h index df621ff1938..a84ec66f399 100644 --- a/sql/ha_ndbcluster.h +++ b/sql/ha_ndbcluster.h @@ -84,7 +84,7 @@ typedef struct ndb_index_data { typedef union { const NdbRecAttr *rec; NdbBlob *blob; void *ptr; } NdbValue; int get_ndb_blobs_value(TABLE* table, NdbValue* value_array, - byte*& buffer, uint& buffer_size, + uchar*& buffer, uint& buffer_size, my_ptrdiff_t ptrdiff); typedef enum { @@ -115,7 +115,7 @@ typedef struct st_ndbcluster_share { char *old_names; // for rename table TABLE_SHARE *table_share; TABLE *table; - byte *record[2]; // pointer to allocated records for receiving data + uchar *record[2]; // pointer to allocated records for receiving data NdbValue *ndb_value[2]; MY_BITMAP *subscriber_bitmap; #endif @@ -224,30 +224,30 @@ class ha_ndbcluster: public handler int open(const char *name, int mode, uint test_if_locked); int close(void); - int write_row(byte *buf); - int update_row(const byte *old_data, byte *new_data); - int delete_row(const byte *buf); + int write_row(uchar *buf); + int update_row(const uchar *old_data, uchar *new_data); + int delete_row(const uchar *buf); int index_init(uint index, bool sorted); int index_end(); - int index_read(byte *buf, const byte *key, uint key_len, + int index_read(uchar *buf, const uchar *key, uint key_len, enum ha_rkey_function find_flag); - int index_next(byte *buf); - int index_prev(byte *buf); - int index_first(byte *buf); - int index_last(byte *buf); - int index_read_last(byte * buf, const byte * key, uint key_len); + int index_next(uchar *buf); + int index_prev(uchar *buf); + int index_first(uchar *buf); + int index_last(uchar *buf); + int index_read_last(uchar * buf, const uchar * key, uint key_len); int rnd_init(bool scan); int rnd_end(); - int rnd_next(byte *buf); - int rnd_pos(byte *buf, byte *pos); - void position(const byte *record); + int rnd_next(uchar *buf); + int rnd_pos(uchar *buf, uchar *pos); + void position(const uchar *record); int read_range_first(const key_range *start_key, const key_range *end_key, bool eq_range, bool sorted); int read_range_first_to_buf(const key_range *start_key, const key_range *end_key, bool eq_range, bool sorted, - byte* buf); + uchar* buf); int read_range_next(); int alter_tablespace(st_alter_tablespace *info); @@ -416,56 +416,56 @@ private: char* get_tablespace_name(THD *thd, char *name, uint name_len); int set_range_data(void *tab, partition_info* part_info); int set_list_data(void *tab, partition_info* part_info); - int complemented_read(const byte *old_data, byte *new_data, + int complemented_read(const uchar *old_data, uchar *new_data, uint32 old_part_id); - int pk_read(const byte *key, uint key_len, byte *buf, uint32 part_id); + int pk_read(const uchar *key, uint key_len, uchar *buf, uint32 part_id); int ordered_index_scan(const key_range *start_key, const key_range *end_key, - bool sorted, bool descending, byte* buf, + bool sorted, bool descending, uchar* buf, part_id_range *part_spec); - int unique_index_read(const byte *key, uint key_len, - byte *buf); + int unique_index_read(const uchar *key, uint key_len, + uchar *buf); int unique_index_scan(const KEY* key_info, - const byte *key, + const uchar *key, uint key_len, - byte *buf); - int full_table_scan(byte * buf); + uchar *buf); + int full_table_scan(uchar * buf); bool check_all_operations_for_error(NdbTransaction *trans, const NdbOperation *first, const NdbOperation *last, uint errcode); - int peek_indexed_rows(const byte *record, bool check_pk); + int peek_indexed_rows(const uchar *record, bool check_pk); int fetch_next(NdbScanOperation* op); - int next_result(byte *buf); - int define_read_attrs(byte* buf, NdbOperation* op); - int filtered_scan(const byte *key, uint key_len, - byte *buf, + int next_result(uchar *buf); + int define_read_attrs(uchar* buf, NdbOperation* op); + int filtered_scan(const uchar *key, uint key_len, + uchar *buf, enum ha_rkey_function find_flag); int close_scan(); - void unpack_record(byte *buf); + void unpack_record(uchar *buf); int get_ndb_lock_type(enum thr_lock_type type); void set_dbname(const char *pathname); void set_tabname(const char *pathname); bool set_hidden_key(NdbOperation*, - uint fieldnr, const byte* field_ptr); + uint fieldnr, const uchar* field_ptr); int set_ndb_key(NdbOperation*, Field *field, - uint fieldnr, const byte* field_ptr); + uint fieldnr, const uchar* field_ptr); int set_ndb_value(NdbOperation*, Field *field, uint fieldnr, int row_offset= 0, bool *set_blob_value= 0); - int get_ndb_value(NdbOperation*, Field *field, uint fieldnr, byte*); + int get_ndb_value(NdbOperation*, Field *field, uint fieldnr, uchar*); int get_ndb_partition_id(NdbOperation *); friend int g_get_ndb_blobs_value(NdbBlob *ndb_blob, void *arg); - int set_primary_key(NdbOperation *op, const byte *key); - int set_primary_key_from_record(NdbOperation *op, const byte *record); - int set_index_key_from_record(NdbOperation *op, const byte *record, + int set_primary_key(NdbOperation *op, const uchar *key); + int set_primary_key_from_record(NdbOperation *op, const uchar *record); + int set_index_key_from_record(NdbOperation *op, const uchar *record, uint keyno); int set_bounds(NdbIndexScanOperation*, uint inx, bool rir, const key_range *keys[2], uint= 0); - int key_cmp(uint keynr, const byte * old_row, const byte * new_row); - int set_index_key(NdbOperation *, const KEY *key_info, const byte *key_ptr); + int key_cmp(uint keynr, const uchar * old_row, const uchar * new_row); + int set_index_key(NdbOperation *, const KEY *key_info, const uchar *key_ptr); void print_results(); virtual void get_auto_increment(ulonglong offset, ulonglong increment, @@ -508,10 +508,10 @@ private: THD_NDB_SHARE *m_thd_ndb_share; // NdbRecAttr has no reference to blob NdbValue m_value[NDB_MAX_ATTRIBUTES_IN_TABLE]; - byte m_ref[NDB_HIDDEN_PRIMARY_KEY_LENGTH]; + uchar m_ref[NDB_HIDDEN_PRIMARY_KEY_LENGTH]; partition_info *m_part_info; uint32 m_part_id; - byte *m_rec0; + uchar *m_rec0; Field **m_part_field_array; bool m_use_partition_function; bool m_sorted; @@ -534,7 +534,7 @@ private: bool m_slow_path; my_ptrdiff_t m_blobs_offset; // memory for blobs in one tuple - char *m_blobs_buffer; + uchar *m_blobs_buffer; uint32 m_blobs_buffer_size; uint m_dupkey; // set from thread variables at external lock @@ -545,12 +545,12 @@ private: ha_ndbcluster_cond *m_cond; bool m_disable_multi_read; - byte *m_multi_range_result_ptr; + uchar *m_multi_range_result_ptr; KEY_MULTI_RANGE *m_multi_ranges; KEY_MULTI_RANGE *m_multi_range_defined; const NdbOperation *m_current_multi_operation; NdbIndexScanOperation *m_multi_cursor; - byte *m_multi_range_cursor_result_ptr; + uchar *m_multi_range_cursor_result_ptr; int setup_recattr(const NdbRecAttr*); Ndb *get_ndb(); }; diff --git a/sql/ha_ndbcluster_binlog.cc b/sql/ha_ndbcluster_binlog.cc index 5751bd0057a..391051d8775 100644 --- a/sql/ha_ndbcluster_binlog.cc +++ b/sql/ha_ndbcluster_binlog.cc @@ -130,14 +130,14 @@ static TABLE_LIST binlog_tables; #ifndef DBUG_OFF /* purecov: begin deadcode */ -static void print_records(TABLE *table, const char *record) +static void print_records(TABLE *table, const uchar *record) { for (uint j= 0; j < table->s->fields; j++) { char buf[40]; int pos= 0; Field *field= table->field[j]; - const byte* field_ptr= field->ptr - table->record[0] + record; + const uchar* field_ptr= field->ptr - table->record[0] + record; int pack_len= field->pack_length(); int n= pack_len < 10 ? pack_len : 10; @@ -196,14 +196,14 @@ static void dbug_print_table(const char *info, TABLE *table) (long) f->ptr, (int) (f->ptr - table->record[0]), f->null_bit, (long) f->null_ptr, - (int) ((byte*) f->null_ptr - table->record[0]))); + (int) ((uchar*) f->null_ptr - table->record[0]))); if (f->type() == MYSQL_TYPE_BIT) { Field_bit *g= (Field_bit*) f; DBUG_PRINT("MYSQL_TYPE_BIT",("field_length: %d bit_ptr: 0x%lx[+%d] " "bit_ofs: %d bit_len: %u", g->field_length, (long) g->bit_ptr, - (int) ((byte*) g->bit_ptr - + (int) ((uchar*) g->bit_ptr - table->record[0]), g->bit_ofs, g->bit_len)); } @@ -683,7 +683,7 @@ static NDB_SHARE *ndbcluster_check_ndb_apply_status_share() pthread_mutex_lock(&ndbcluster_mutex); void *share= hash_search(&ndbcluster_open_tables, - NDB_APPLY_TABLE_FILE, + (uchar*) NDB_APPLY_TABLE_FILE, sizeof(NDB_APPLY_TABLE_FILE) - 1); DBUG_PRINT("info",("ndbcluster_check_ndb_apply_status_share %s 0x%lx", NDB_APPLY_TABLE_FILE, (long) share)); @@ -701,7 +701,7 @@ static NDB_SHARE *ndbcluster_check_ndb_schema_share() pthread_mutex_lock(&ndbcluster_mutex); void *share= hash_search(&ndbcluster_open_tables, - NDB_SCHEMA_TABLE_FILE, + (uchar*) NDB_SCHEMA_TABLE_FILE, sizeof(NDB_SCHEMA_TABLE_FILE) - 1); DBUG_PRINT("info",("ndbcluster_check_ndb_schema_share %s 0x%lx", NDB_SCHEMA_TABLE_FILE, (long) share)); @@ -905,7 +905,7 @@ static void ndbcluster_get_schema(NDB_SHARE *share, TABLE *table= share->table; Field **field; /* unpack blob values */ - byte* blobs_buffer= 0; + uchar* blobs_buffer= 0; uint blobs_buffer_size= 0; my_bitmap_map *old_map= dbug_tmp_use_all_columns(table, table->read_set); { @@ -920,14 +920,14 @@ static void ndbcluster_get_schema(NDB_SHARE *share, DBUG_ASSERT(FALSE); } } - /* db varchar 1 length byte */ + /* db varchar 1 length uchar */ field= table->field; s->db_length= *(uint8*)(*field)->ptr; DBUG_ASSERT(s->db_length <= (*field)->field_length); DBUG_ASSERT((*field)->field_length + 1 == sizeof(s->db)); memcpy(s->db, (*field)->ptr + 1, s->db_length); s->db[s->db_length]= 0; - /* name varchar 1 length byte */ + /* name varchar 1 length uchar */ field++; s->name_length= *(uint8*)(*field)->ptr; DBUG_ASSERT(s->name_length <= (*field)->field_length); @@ -944,13 +944,11 @@ static void ndbcluster_get_schema(NDB_SHARE *share, { Field_blob *field_blob= (Field_blob*)(*field); uint blob_len= field_blob->get_length((*field)->ptr); - char *blob_ptr= 0; + uchar *blob_ptr= 0; field_blob->get_ptr(&blob_ptr); assert(blob_len == 0 || blob_ptr != 0); s->query_length= blob_len; - s->query= sql_alloc(blob_len+1); - memcpy(s->query, blob_ptr, blob_len); - s->query[blob_len]= 0; + s->query= sql_strmake((char*) blob_ptr, blob_len); } /* node_id */ field++; @@ -1319,7 +1317,7 @@ int ndbcluster_log_schema_op(THD *thd, NDB_SHARE *share, (void) pthread_mutex_unlock(&ndb_schema_object->mutex); } - DBUG_DUMP("schema_subscribers", (char*)schema_subscribers.bitmap, + DBUG_DUMP("schema_subscribers", (uchar*)schema_subscribers.bitmap, no_bytes_in_map(&schema_subscribers)); DBUG_PRINT("info", ("bitmap_is_clear_all(&schema_subscribers): %d", bitmap_is_clear_all(&schema_subscribers))); @@ -1523,7 +1521,7 @@ end: bitmap_intersect(&ndb_schema_object->slock_bitmap, &schema_subscribers); DBUG_DUMP("ndb_schema_object->slock_bitmap.bitmap", - (char*)ndb_schema_object->slock_bitmap.bitmap, + (uchar*)ndb_schema_object->slock_bitmap.bitmap, no_bytes_in_map(&ndb_schema_object->slock_bitmap)); if (bitmap_is_clear_all(&ndb_schema_object->slock_bitmap)) @@ -1608,8 +1606,8 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp, { const char *tabname= table_share->table_name.str; char key[FN_REFLEN]; - const void *data= 0, *pack_data= 0; - uint length, pack_length; + uchar *data= 0, *pack_data= 0; + size_t length, pack_length; int error; NDBDICT *dict= ndb->getDictionary(); const NDBTAB *altered_table= pOp->getTable(); @@ -1627,7 +1625,7 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp, packfrm(data, length, &pack_data, &pack_length) == 0 && cmp_frm(altered_table, pack_data, pack_length)) { - DBUG_DUMP("frm", (char*)altered_table->getFrmData(), + DBUG_DUMP("frm", (uchar*) altered_table->getFrmData(), altered_table->getFrmLength()); pthread_mutex_lock(&LOCK_open); Ndb_table_guard ndbtab_g(dict, tabname); @@ -1638,7 +1636,8 @@ ndb_handle_schema_change(THD *thd, Ndb *ndb, NdbEventOperation *pOp, my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR)); data= NULL; - if ((error= unpackfrm(&data, &length, altered_table->getFrmData())) || + if ((error= unpackfrm(&data, &length, + (const uchar*) altered_table->getFrmData())) || (error= writefrm(key, data, length))) { sql_print_information("NDB: Failed write frm for %s.%s, error %d", @@ -1894,16 +1893,16 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, pthread_mutex_lock(&LOCK_open); if (ndbcluster_check_if_local_table(schema->db, schema->name)) { - DBUG_PRINT("info", ("NDB binlog: Skipping locally defined table '%s.%s'", + DBUG_PRINT("info", ("NDB Binlog: Skipping locally defined table '%s.%s'", schema->db, schema->name)); - sql_print_error("NDB binlog: Skipping locally defined table '%s.%s' from " + sql_print_error("NDB Binlog: Skipping locally defined table '%s.%s' from " "binlog schema event '%s' from node %d. ", schema->db, schema->name, schema->query, schema->node_id); } else if (ndb_create_table_from_engine(thd, schema->db, schema->name)) { - sql_print_error("NDB binlog: Could not discover table '%s.%s' from " + sql_print_error("NDB Binlog: Could not discover table '%s.%s' from " "binlog schema event '%s' from node %d. " "my_errno: %d", schema->db, schema->name, schema->query, @@ -1911,7 +1910,7 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, List_iterator_fast<MYSQL_ERROR> it(thd->warn_list); MYSQL_ERROR *err; while ((err= it++)) - sql_print_warning("NDB binlog: (%d)%s", err->code, err->msg); + sql_print_warning("NDB Binlog: (%d)%s", err->code, err->msg); } pthread_mutex_unlock(&LOCK_open); log_query= 1; @@ -1932,7 +1931,7 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, else { /* Database contained local tables, leave it */ - sql_print_error("NDB binlog: Skipping drop database '%s' since it contained local tables " + sql_print_error("NDB Binlog: Skipping drop database '%s' since it contained local tables " "binlog schema event '%s' from node %d. ", schema->db, schema->query, schema->node_id); @@ -1958,7 +1957,7 @@ ndb_binlog_thread_handle_schema_event(THD *thd, Ndb *ndb, if (log_query && ndb_binlog_running) ndb_binlog_query(thd, schema); /* signal that schema operation has been handled */ - DBUG_DUMP("slock", (char*)schema->slock, schema->slock_length); + DBUG_DUMP("slock", (uchar*) schema->slock, schema->slock_length); if (bitmap_is_set(&slock, node_id)) { if (post_epoch_unlock) @@ -2105,14 +2104,14 @@ ndb_binlog_thread_handle_schema_event_post_epoch(THD *thd, pthread_mutex_lock(&ndbcluster_mutex); NDB_SCHEMA_OBJECT *ndb_schema_object= (NDB_SCHEMA_OBJECT*) hash_search(&ndb_schema_objects, - (byte*) key, strlen(key)); + (uchar*) key, strlen(key)); if (ndb_schema_object) { pthread_mutex_lock(&ndb_schema_object->mutex); memcpy(ndb_schema_object->slock, schema->slock, sizeof(ndb_schema_object->slock)); DBUG_DUMP("ndb_schema_object->slock_bitmap.bitmap", - (char*)ndb_schema_object->slock_bitmap.bitmap, + (uchar*)ndb_schema_object->slock_bitmap.bitmap, no_bytes_in_map(&ndb_schema_object->slock_bitmap)); pthread_mutex_unlock(&ndb_schema_object->mutex); pthread_cond_signal(&injector_cond); @@ -2180,23 +2179,23 @@ ndb_binlog_thread_handle_schema_event_post_epoch(THD *thd, pthread_mutex_lock(&LOCK_open); if (ndbcluster_check_if_local_table(schema->db, schema->name)) { - DBUG_PRINT("info", ("NDB binlog: Skipping locally defined table '%s.%s'", + DBUG_PRINT("info", ("NDB Binlog: Skipping locally defined table '%s.%s'", schema->db, schema->name)); - sql_print_error("NDB binlog: Skipping locally defined table '%s.%s' from " + sql_print_error("NDB Binlog: Skipping locally defined table '%s.%s' from " "binlog schema event '%s' from node %d. ", schema->db, schema->name, schema->query, schema->node_id); } else if (ndb_create_table_from_engine(thd, schema->db, schema->name)) { - sql_print_error("NDB binlog: Could not discover table '%s.%s' from " + sql_print_error("NDB Binlog: Could not discover table '%s.%s' from " "binlog schema event '%s' from node %d. my_errno: %d", schema->db, schema->name, schema->query, schema->node_id, my_errno); List_iterator_fast<MYSQL_ERROR> it(thd->warn_list); MYSQL_ERROR *err; while ((err= it++)) - sql_print_warning("NDB binlog: (%d)%s", err->code, err->msg); + sql_print_warning("NDB Binlog: (%d)%s", err->code, err->msg); } pthread_mutex_unlock(&LOCK_open); } @@ -2496,7 +2495,7 @@ int ndbcluster_create_binlog_setup(Ndb *ndb, const char *key, /* Handle any trailing share */ NDB_SHARE *share= (NDB_SHARE*) hash_search(&ndbcluster_open_tables, - (byte*) key, key_len); + (uchar*) key, key_len); if (share && share_may_exist) { @@ -2907,10 +2906,10 @@ ndbcluster_create_event_ops(NDB_SHARE *share, const NDBTAB *ndbtab, if (is_ndb_compatible_type(f)) { DBUG_PRINT("info", ("%s compatible", col_name)); - attr0.rec= op->getValue(col_name, f->ptr); + attr0.rec= op->getValue(col_name, (char*) f->ptr); attr1.rec= op->getPreValue(col_name, - (f->ptr - share->table->record[0]) + - share->table->record[1]); + (f->ptr - share->table->record[0]) + + (char*) share->table->record[1]); } else if (! (f->flags & BLOB_FLAG)) { @@ -3296,7 +3295,7 @@ ndb_binlog_thread_handle_data_event(Ndb *ndb, NdbEventOperation *pOp, for now malloc/free blobs buffer each time TODO if possible share single permanent buffer with handlers */ - byte* blobs_buffer[2] = { 0, 0 }; + uchar* blobs_buffer[2] = { 0, 0 }; uint blobs_buffer_size[2] = { 0, 0 }; switch(pOp->getEventType()) @@ -3456,11 +3455,13 @@ private: Injector thread main loop ****************************************************************/ -static byte *ndb_schema_objects_get_key(NDB_SCHEMA_OBJECT *schema_object, uint *length, - my_bool not_used __attribute__((unused))) +static uchar * +ndb_schema_objects_get_key(NDB_SCHEMA_OBJECT *schema_object, + size_t *length, + my_bool not_used __attribute__((unused))) { *length= schema_object->key_length; - return (byte*) schema_object->key; + return (uchar*) schema_object->key; } static NDB_SCHEMA_OBJECT *ndb_get_schema_object(const char *key, @@ -3476,7 +3477,7 @@ static NDB_SCHEMA_OBJECT *ndb_get_schema_object(const char *key, pthread_mutex_lock(&ndbcluster_mutex); while (!(ndb_schema_object= (NDB_SCHEMA_OBJECT*) hash_search(&ndb_schema_objects, - (byte*) key, + (uchar*) key, length))) { if (!create_if_not_exists) @@ -3494,9 +3495,9 @@ static NDB_SCHEMA_OBJECT *ndb_get_schema_object(const char *key, ndb_schema_object->key= (char *)(ndb_schema_object+1); memcpy(ndb_schema_object->key, key, length + 1); ndb_schema_object->key_length= length; - if (my_hash_insert(&ndb_schema_objects, (byte*) ndb_schema_object)) + if (my_hash_insert(&ndb_schema_objects, (uchar*) ndb_schema_object)) { - my_free((gptr) ndb_schema_object, 0); + my_free((uchar*) ndb_schema_object, 0); break; } pthread_mutex_init(&ndb_schema_object->mutex, MY_MUTEX_INIT_FAST); @@ -3526,9 +3527,9 @@ static void ndb_free_schema_object(NDB_SCHEMA_OBJECT **ndb_schema_object, if (!--(*ndb_schema_object)->use_count) { DBUG_PRINT("info", ("use_count: %d", (*ndb_schema_object)->use_count)); - hash_delete(&ndb_schema_objects, (byte*) *ndb_schema_object); + hash_delete(&ndb_schema_objects, (uchar*) *ndb_schema_object); pthread_mutex_destroy(&(*ndb_schema_object)->mutex); - my_free((gptr) *ndb_schema_object, MYF(0)); + my_free((uchar*) *ndb_schema_object, MYF(0)); *ndb_schema_object= 0; } else @@ -3968,7 +3969,7 @@ restart: NdbDictionary::Event::TE_DELETE)) == 0) { DBUG_PRINT("info", ("skipping non data event table: %.*s", - name.length, name.str)); + (int) name.length, name.str)); continue; } if (!trans.good()) @@ -3977,7 +3978,8 @@ restart: ("Found new data event, initializing transaction")); inj->new_trans(thd, &trans); } - DBUG_PRINT("info", ("use_table: %.*s", name.length, name.str)); + DBUG_PRINT("info", ("use_table: %.*s", + (int) name.length, name.str)); injector::transaction::table tbl(table, TRUE); IF_DBUG(int ret=) trans.use_table(::server_id, tbl); DBUG_ASSERT(ret == 0); @@ -3991,7 +3993,8 @@ restart: #ifndef DBUG_OFF const LEX_STRING& name= table->s->table_name; - DBUG_PRINT("info", ("use_table: %.*s", name.length, name.str)); + DBUG_PRINT("info", ("use_table: %.*s", + (int) name.length, name.str)); #endif injector::transaction::table tbl(table, TRUE); IF_DBUG(int ret=) trans.use_table(::server_id, tbl); @@ -4110,7 +4113,7 @@ restart: injector::transaction::binlog_pos start= trans.start_pos(); if (int r= trans.commit()) { - sql_print_error("NDB binlog: " + sql_print_error("NDB Binlog: " "Error during COMMIT of GCI. Error: %d", r); /* TODO: Further handling? */ diff --git a/sql/ha_ndbcluster_binlog.h b/sql/ha_ndbcluster_binlog.h index ac0d769433e..b5b8d0d9745 100644 --- a/sql/ha_ndbcluster_binlog.h +++ b/sql/ha_ndbcluster_binlog.h @@ -184,7 +184,7 @@ int ndbcluster_find_all_files(THD *thd); #endif /* HAVE_NDB_BINLOG */ void ndb_unpack_record(TABLE *table, NdbValue *value, - MY_BITMAP *defined, byte *buf); + MY_BITMAP *defined, uchar *buf); char *ndb_pack_varchar(const NDBCOL *col, char *buf, const char *str, int sz); diff --git a/sql/ha_ndbcluster_cond.cc b/sql/ha_ndbcluster_cond.cc index 267be17c330..c686e83504c 100644 --- a/sql/ha_ndbcluster_cond.cc +++ b/sql/ha_ndbcluster_cond.cc @@ -1377,9 +1377,9 @@ ha_ndbcluster_cond::generate_scan_filter_from_cond(NdbScanFilter& filter) int ha_ndbcluster_cond::generate_scan_filter_from_key(NdbScanOperation *op, const KEY* key_info, - const byte *key, + const uchar *key, uint key_len, - byte *buf) + uchar *buf) { KEY_PART_INFO* key_part= key_info->key_part; KEY_PART_INFO* end= key_part+key_info->key_parts; @@ -1392,9 +1392,9 @@ int ha_ndbcluster_cond::generate_scan_filter_from_key(NdbScanOperation *op, { Field* field= key_part->field; uint32 pack_len= field->pack_length(); - const byte* ptr= key; + const uchar* ptr= key; DBUG_PRINT("info", ("Filtering value for %s", field->field_name)); - DBUG_DUMP("key", (char*)ptr, pack_len); + DBUG_DUMP("key", ptr, pack_len); if (key_part->null_bit) { DBUG_PRINT("info", ("Generating ISNULL filter")); diff --git a/sql/ha_ndbcluster_cond.h b/sql/ha_ndbcluster_cond.h index 617302107d8..d5b3b913f22 100644 --- a/sql/ha_ndbcluster_cond.h +++ b/sql/ha_ndbcluster_cond.h @@ -198,7 +198,7 @@ public: return value.item->str_value.ptr(); break; case(NDB_FIELD): - return value.field_value->field->ptr; + return (char*) value.field_value->field->ptr; default: break; } @@ -458,9 +458,9 @@ public: int generate_scan_filter_from_cond(NdbScanFilter& filter); int generate_scan_filter_from_key(NdbScanOperation* op, const KEY* key_info, - const byte *key, + const uchar *key, uint key_len, - byte *buf); + uchar *buf); private: bool serialize_cond(const COND *cond, Ndb_cond_stack *ndb_cond, TABLE *table, const NdbDictionary::Table *ndb_table); diff --git a/sql/ha_partition.cc b/sql/ha_partition.cc index e741ef7deb6..e9f4bc4c745 100644 --- a/sql/ha_partition.cc +++ b/sql/ha_partition.cc @@ -1224,9 +1224,9 @@ int ha_partition::change_partitions(HA_CREATE_INFO *create_info, const char *path, ulonglong *copied, ulonglong *deleted, - const void *pack_frm_data + const uchar *pack_frm_data __attribute__((unused)), - uint pack_frm_len + size_t pack_frm_len __attribute__((unused))) { List_iterator<partition_element> part_it(m_part_info->partitions); @@ -1964,8 +1964,8 @@ bool ha_partition::create_handler_file(const char *name) if ((file= my_create(file_name, CREATE_MODE, O_RDWR | O_TRUNC, MYF(MY_WME))) >= 0) { - result= my_write(file, (byte *) file_buffer, tot_len_byte, - MYF(MY_WME | MY_NABP)); + result= my_write(file, (uchar *) file_buffer, tot_len_byte, + MYF(MY_WME | MY_NABP)) != 0; VOID(my_close(file, MYF(0))); } else @@ -2146,14 +2146,14 @@ bool ha_partition::get_from_handler_file(const char *name, MEM_ROOT *mem_root) /* Following could be done with my_stat to read in whole file */ if ((file= my_open(buff, O_RDONLY | O_SHARE, MYF(0))) < 0) DBUG_RETURN(TRUE); - if (my_read(file, (byte *) & buff[0], 8, MYF(MY_NABP))) + if (my_read(file, (uchar *) & buff[0], 8, MYF(MY_NABP))) goto err1; len_words= uint4korr(buff); len_bytes= 4 * len_words; - if (!(file_buffer= my_malloc(len_bytes, MYF(0)))) + if (!(file_buffer= (char*) my_malloc(len_bytes, MYF(0)))) goto err1; VOID(my_seek(file, 0, MY_SEEK_SET, MYF(0))); - if (my_read(file, (byte *) file_buffer, len_bytes, MYF(MY_NABP))) + if (my_read(file, (uchar *) file_buffer, len_bytes, MYF(MY_NABP))) goto err2; chksum= 0; @@ -2252,7 +2252,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked) alloc_len+= table->s->max_key_length; if (!m_ordered_rec_buffer) { - if (!(m_ordered_rec_buffer= (byte*)my_malloc(alloc_len, MYF(MY_WME)))) + if (!(m_ordered_rec_buffer= (uchar*)my_malloc(alloc_len, MYF(MY_WME)))) { DBUG_RETURN(1); } @@ -2271,7 +2271,7 @@ int ha_partition::open(const char *name, int mode, uint test_if_locked) int2store(ptr, i); ptr+= m_rec_length + PARTITION_BYTES_IN_POS; } while (++i < m_tot_parts); - m_start_key.key= (const byte*)ptr; + m_start_key.key= (const uchar*)ptr; } } @@ -2657,13 +2657,13 @@ void ha_partition::unlock_row() may be used in determining which partition the row should be written to. */ -int ha_partition::write_row(byte * buf) +int ha_partition::write_row(uchar * buf) { uint32 part_id; int error; longlong func_value; #ifdef NOT_NEEDED - byte *rec0= m_rec0; + uchar *rec0= m_rec0; #endif DBUG_ENTER("ha_partition::write_row"); DBUG_ASSERT(buf == m_rec0); @@ -2737,7 +2737,7 @@ int ha_partition::write_row(byte * buf) old_data is normally record[1] but may be anything */ -int ha_partition::update_row(const byte *old_data, byte *new_data) +int ha_partition::update_row(const uchar *old_data, uchar *new_data) { uint32 new_part_id, old_part_id; int error; @@ -2809,7 +2809,7 @@ int ha_partition::update_row(const byte *old_data, byte *new_data) buf is either record[0] or record[1] */ -int ha_partition::delete_row(const byte *buf) +int ha_partition::delete_row(const uchar *buf) { uint32 part_id; int error; @@ -3080,7 +3080,7 @@ int ha_partition::rnd_end() sql_table.cc, and sql_update.cc. */ -int ha_partition::rnd_next(byte *buf) +int ha_partition::rnd_next(uchar *buf) { handler *file; int result= HA_ERR_END_OF_FILE; @@ -3173,7 +3173,7 @@ end: Called from filesort.cc, sql_select.cc, sql_delete.cc and sql_update.cc. */ -void ha_partition::position(const byte *record) +void ha_partition::position(const uchar *record) { handler *file= m_file[m_last_part]; DBUG_ENTER("ha_partition::position"); @@ -3213,13 +3213,13 @@ void ha_partition::position(const byte *record) sql_update.cc. */ -int ha_partition::rnd_pos(byte * buf, byte *pos) +int ha_partition::rnd_pos(uchar * buf, uchar *pos) { uint part_id; handler *file; DBUG_ENTER("ha_partition::rnd_pos"); - part_id= uint2korr((const byte *) pos); + part_id= uint2korr((const uchar *) pos); DBUG_ASSERT(part_id < m_tot_parts); file= m_file[part_id]; m_last_part= part_id; @@ -3351,7 +3351,7 @@ int ha_partition::index_end() used in conjuntion with multi read ranges. */ -int ha_partition::index_read(byte * buf, const byte * key, +int ha_partition::index_read(uchar * buf, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag) { @@ -3372,7 +3372,7 @@ int ha_partition::index_read(byte * buf, const byte * key, see index_read for rest */ -int ha_partition::common_index_read(byte *buf, const byte *key, +int ha_partition::common_index_read(uchar *buf, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag) { @@ -3449,7 +3449,7 @@ int ha_partition::common_index_read(byte *buf, const byte *key, and sql_select.cc. */ -int ha_partition::index_first(byte * buf) +int ha_partition::index_first(uchar * buf) { DBUG_ENTER("ha_partition::index_first"); @@ -3480,7 +3480,7 @@ int ha_partition::index_first(byte * buf) and sql_select.cc. */ -int ha_partition::index_last(byte * buf) +int ha_partition::index_last(uchar * buf) { DBUG_ENTER("ha_partition::index_last"); @@ -3497,7 +3497,7 @@ int ha_partition::index_last(byte * buf) see index_first for rest */ -int ha_partition::common_first_last(byte *buf) +int ha_partition::common_first_last(uchar *buf) { int error; @@ -3528,7 +3528,7 @@ int ha_partition::common_first_last(byte *buf) Can only be used on indexes supporting HA_READ_ORDER */ -int ha_partition::index_read_last(byte *buf, const byte *key, +int ha_partition::index_read_last(uchar *buf, const uchar *key, key_part_map keypart_map) { DBUG_ENTER("ha_partition::index_read_last"); @@ -3555,7 +3555,7 @@ int ha_partition::index_read_last(byte *buf, const byte *key, Used to read forward through the index. */ -int ha_partition::index_next(byte * buf) +int ha_partition::index_next(uchar * buf) { DBUG_ENTER("ha_partition::index_next"); @@ -3591,7 +3591,7 @@ int ha_partition::index_next(byte * buf) as supplied in the call. */ -int ha_partition::index_next_same(byte *buf, const byte *key, uint keylen) +int ha_partition::index_next_same(uchar *buf, const uchar *key, uint keylen) { DBUG_ENTER("ha_partition::index_next_same"); @@ -3618,7 +3618,7 @@ int ha_partition::index_next_same(byte *buf, const byte *key, uint keylen) Used to read backwards through the index. */ -int ha_partition::index_prev(byte * buf) +int ha_partition::index_prev(uchar * buf) { DBUG_ENTER("ha_partition::index_prev"); @@ -3727,7 +3727,7 @@ int ha_partition::read_range_next() of them */ -int ha_partition::partition_scan_set_up(byte * buf, bool idx_read_flag) +int ha_partition::partition_scan_set_up(uchar * buf, bool idx_read_flag) { DBUG_ENTER("ha_partition::partition_scan_set_up"); @@ -3808,7 +3808,7 @@ int ha_partition::partition_scan_set_up(byte * buf, bool idx_read_flag) perform any sort. */ -int ha_partition::handle_unordered_next(byte *buf, bool is_next_same) +int ha_partition::handle_unordered_next(uchar *buf, bool is_next_same) { handler *file= file= m_file[m_part_spec.start_part]; int error; @@ -3863,7 +3863,7 @@ int ha_partition::handle_unordered_next(byte *buf, bool is_next_same) Both initial start and after completing scan on one partition. */ -int ha_partition::handle_unordered_scan_next_partition(byte * buf) +int ha_partition::handle_unordered_scan_next_partition(uchar * buf) { uint i; DBUG_ENTER("ha_partition::handle_unordered_scan_next_partition"); @@ -3950,7 +3950,7 @@ int ha_partition::handle_unordered_scan_next_partition(byte * buf) entries. */ -int ha_partition::handle_ordered_index_scan(byte *buf, bool reverse_order) +int ha_partition::handle_ordered_index_scan(uchar *buf, bool reverse_order) { uint i; uint j= 0; @@ -3965,7 +3965,7 @@ int ha_partition::handle_ordered_index_scan(byte *buf, bool reverse_order) { if (!(bitmap_is_set(&(m_part_info->used_partitions), i))) continue; - byte *rec_buf_ptr= rec_buf(i); + uchar *rec_buf_ptr= rec_buf(i); int error; handler *file= m_file[i]; @@ -4000,7 +4000,7 @@ int ha_partition::handle_ordered_index_scan(byte *buf, bool reverse_order) /* Initialise queue without order first, simply insert */ - queue_element(&m_queue, j++)= (byte*)queue_buf(i); + queue_element(&m_queue, j++)= (uchar*)queue_buf(i); } else if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE) { @@ -4037,11 +4037,11 @@ int ha_partition::handle_ordered_index_scan(byte *buf, bool reverse_order) NONE */ -void ha_partition::return_top_record(byte *buf) +void ha_partition::return_top_record(uchar *buf) { uint part_id; - byte *key_buffer= queue_top(&m_queue); - byte *rec_buffer= key_buffer + PARTITION_BYTES_IN_POS; + uchar *key_buffer= queue_top(&m_queue); + uchar *rec_buffer= key_buffer + PARTITION_BYTES_IN_POS; part_id= uint2korr(key_buffer); memcpy(buf, rec_buffer, m_rec_length); @@ -4064,7 +4064,7 @@ void ha_partition::return_top_record(byte *buf) other Error code */ -int ha_partition::handle_ordered_next(byte *buf, bool is_next_same) +int ha_partition::handle_ordered_next(uchar *buf, bool is_next_same) { int error; uint part_id= m_top_entry; @@ -4113,7 +4113,7 @@ int ha_partition::handle_ordered_next(byte *buf, bool is_next_same) other Error code */ -int ha_partition::handle_ordered_prev(byte *buf) +int ha_partition::handle_ordered_prev(uchar *buf) { int error; uint part_id= m_top_entry; @@ -5358,7 +5358,7 @@ uint ha_partition::min_record_length(uint options) const they are the same. Sort in partition id order if not equal. */ -int ha_partition::cmp_ref(const byte *ref1, const byte *ref2) +int ha_partition::cmp_ref(const uchar *ref1, const uchar *ref2) { uint part_id; my_ptrdiff_t diff1, diff2; @@ -5567,11 +5567,11 @@ static int partition_init= 0; Function we use in the creation of our hash to get key. */ -static byte *partition_get_key(PARTITION_SHARE *share, uint *length, +static uchar *partition_get_key(PARTITION_SHARE *share, size_t *length, my_bool not_used __attribute__ ((unused))) { *length= share->table_name_length; - return (byte *) share->table_name; + return (uchar *) share->table_name; } /* @@ -5611,12 +5611,12 @@ static PARTITION_SHARE *get_share(const char *table_name, TABLE *table) length= (uint) strlen(table_name); if (!(share= (PARTITION_SHARE *) hash_search(&partition_open_tables, - (byte *) table_name, length))) + (uchar *) table_name, length))) { if (!(share= (PARTITION_SHARE *) my_multi_malloc(MYF(MY_WME | MY_ZEROFILL), - &share, sizeof(*share), - &tmp_name, length + 1, NullS))) + &share, (uint) sizeof(*share), + &tmp_name, (uint) length + 1, NullS))) { pthread_mutex_unlock(&partition_mutex); return NULL; @@ -5626,7 +5626,7 @@ static PARTITION_SHARE *get_share(const char *table_name, TABLE *table) share->table_name_length= length; share->table_name= tmp_name; strmov(share->table_name, table_name); - if (my_hash_insert(&partition_open_tables, (byte *) share)) + if (my_hash_insert(&partition_open_tables, (uchar *) share)) goto error; thr_lock_init(&share->lock); pthread_mutex_init(&share->mutex, MY_MUTEX_INIT_FAST); @@ -5638,7 +5638,7 @@ static PARTITION_SHARE *get_share(const char *table_name, TABLE *table) error: pthread_mutex_unlock(&partition_mutex); - my_free((gptr) share, MYF(0)); + my_free((uchar*) share, MYF(0)); return NULL; } @@ -5655,10 +5655,10 @@ static int free_share(PARTITION_SHARE *share) pthread_mutex_lock(&partition_mutex); if (!--share->use_count) { - hash_delete(&partition_open_tables, (byte *) share); + hash_delete(&partition_open_tables, (uchar *) share); thr_lock_delete(&share->lock); pthread_mutex_destroy(&share->mutex); - my_free((gptr) share, MYF(0)); + my_free((uchar*) share, MYF(0)); } pthread_mutex_unlock(&partition_mutex); diff --git a/sql/ha_partition.h b/sql/ha_partition.h index f5695e91ee0..a168007ea04 100644 --- a/sql/ha_partition.h +++ b/sql/ha_partition.h @@ -63,12 +63,12 @@ private: handler **m_reorged_file; // Reorganised partitions handler **m_added_file; // Added parts kept for errors partition_info *m_part_info; // local reference to partition - byte *m_start_key_ref; // Reference of start key in current + uchar *m_start_key_ref; // Reference of start key in current // index scan info Field **m_part_field_array; // Part field array locally to save acc - byte *m_ordered_rec_buffer; // Row and key buffer for ord. idx scan + uchar *m_ordered_rec_buffer; // Row and key buffer for ord. idx scan KEY *m_curr_key_info; // Current index - byte *m_rec0; // table->record[0] + uchar *m_rec0; // table->record[0] QUEUE m_queue; // Prio queue used by sorted read /* Since the partition handler is a handler on top of other handlers, it @@ -199,8 +199,8 @@ public: const char *path, ulonglong *copied, ulonglong *deleted, - const void *pack_frm_data, - uint pack_frm_len); + const uchar *pack_frm_data, + size_t pack_frm_len); virtual int drop_partitions(const char *path); virtual int rename_partitions(const char *path); bool get_no_parts(const char *name, uint *no_parts) @@ -310,9 +310,9 @@ public: number of calls to write_row. Not yet though. */ - virtual int write_row(byte * buf); - virtual int update_row(const byte * old_data, byte * new_data); - virtual int delete_row(const byte * buf); + virtual int write_row(uchar * buf); + virtual int update_row(const uchar * old_data, uchar * new_data); + virtual int delete_row(const uchar * buf); virtual int delete_all_rows(void); virtual void start_bulk_insert(ha_rows rows); virtual int end_bulk_insert(); @@ -351,9 +351,9 @@ public: */ virtual int rnd_init(bool scan); virtual int rnd_end(); - virtual int rnd_next(byte * buf); - virtual int rnd_pos(byte * buf, byte * pos); - virtual void position(const byte * record); + virtual int rnd_next(uchar * buf); + virtual int rnd_pos(uchar * buf, uchar * pos); + virtual void position(const uchar * record); /* ------------------------------------------------------------------------- @@ -387,7 +387,7 @@ public: index_init initializes an index before using it and index_end does any end processing needed. */ - virtual int index_read(byte * buf, const byte * key, + virtual int index_read(uchar * buf, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag); virtual int index_init(uint idx, bool sorted); @@ -397,12 +397,12 @@ public: These methods are used to jump to next or previous entry in the index scan. There are also methods to jump to first and last entry. */ - virtual int index_next(byte * buf); - virtual int index_prev(byte * buf); - virtual int index_first(byte * buf); - virtual int index_last(byte * buf); - virtual int index_next_same(byte * buf, const byte * key, uint keylen); - virtual int index_read_last(byte * buf, const byte * key, + virtual int index_next(uchar * buf); + virtual int index_prev(uchar * buf); + virtual int index_first(uchar * buf); + virtual int index_last(uchar * buf); + virtual int index_next_same(uchar * buf, const uchar * key, uint keylen); + virtual int index_read_last(uchar * buf, const uchar * key, key_part_map keypart_map); /* @@ -410,7 +410,7 @@ public: handler.cc, no storage engine has implemented it so neither will the partition handler. - virtual int read_first_row(byte *buf, uint primary_key); + virtual int read_first_row(uchar *buf, uint primary_key); */ /* @@ -428,27 +428,27 @@ public: virtual int read_range_next(); private: - int common_index_read(byte * buf, const byte * key, + int common_index_read(uchar * buf, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag); - int common_first_last(byte * buf); - int partition_scan_set_up(byte * buf, bool idx_read_flag); - int handle_unordered_next(byte * buf, bool next_same); - int handle_unordered_scan_next_partition(byte * buf); - byte *queue_buf(uint part_id) + int common_first_last(uchar * buf); + int partition_scan_set_up(uchar * buf, bool idx_read_flag); + int handle_unordered_next(uchar * buf, bool next_same); + int handle_unordered_scan_next_partition(uchar * buf); + uchar *queue_buf(uint part_id) { return (m_ordered_rec_buffer + (part_id * (m_rec_length + PARTITION_BYTES_IN_POS))); } - byte *rec_buf(uint part_id) + uchar *rec_buf(uint part_id) { return (queue_buf(part_id) + PARTITION_BYTES_IN_POS); } - int handle_ordered_index_scan(byte * buf, bool reverse_order); - int handle_ordered_next(byte * buf, bool next_same); - int handle_ordered_prev(byte * buf); - void return_top_record(byte * buf); + int handle_ordered_index_scan(uchar * buf, bool reverse_order); + int handle_ordered_next(uchar * buf, bool next_same); + int handle_ordered_prev(uchar * buf); + void return_top_record(uchar * buf); void include_partition_fields_in_used_fields(); public: /* @@ -813,7 +813,7 @@ public: to check whether the rest of the reference part is also the same. ------------------------------------------------------------------------- */ - virtual int cmp_ref(const byte * ref1, const byte * ref2); + virtual int cmp_ref(const uchar * ref1, const uchar * ref2); /* ------------------------------------------------------------------------- MODULE auto increment @@ -877,10 +877,10 @@ public: Fulltext stuff not yet. ------------------------------------------------------------------------- virtual int ft_init() { return HA_ERR_WRONG_COMMAND; } - virtual FT_INFO *ft_init_ext(uint flags,uint inx,const byte *key, + virtual FT_INFO *ft_init_ext(uint flags,uint inx,const uchar *key, uint keylen) { return NULL; } - virtual int ft_read(byte *buf) { return HA_ERR_WRONG_COMMAND; } + virtual int ft_read(uchar *buf) { return HA_ERR_WRONG_COMMAND; } */ /* @@ -889,7 +889,7 @@ public: ------------------------------------------------------------------------- The following method is only used by MyISAM when used as temporary tables in a join. - virtual int restart_rnd_next(byte *buf, byte *pos); + virtual int restart_rnd_next(uchar *buf, uchar *pos); */ /* diff --git a/sql/handler.cc b/sql/handler.cc index 6bdcdc72bdb..afb88dc962d 100644 --- a/sql/handler.cc +++ b/sql/handler.cc @@ -368,7 +368,7 @@ static int ha_finish_errors(void) /* Allocate a pointer array for the error message strings. */ if (! (errmsgs= my_error_unregister(HA_ERR_FIRST, HA_ERR_LAST))) return 1; - my_free((gptr) errmsgs, MYF(0)); + my_free((uchar*) errmsgs, MYF(0)); return 0; } @@ -406,7 +406,7 @@ int ha_finalize_handlerton(st_plugin_int *plugin) } } - my_free((gptr)hton, MYF(0)); + my_free((uchar*)hton, MYF(0)); DBUG_RETURN(0); } @@ -1053,7 +1053,7 @@ static my_bool xarecover_handlerton(THD *unused, plugin_ref plugin, } // recovery mode if (info->commit_list ? - hash_search(info->commit_list, (byte *)&x, sizeof(x)) != 0 : + hash_search(info->commit_list, (uchar *)&x, sizeof(x)) != 0 : tc_heuristic_recover == TC_HEURISTIC_RECOVER_COMMIT) { #ifndef DBUG_OFF @@ -1123,7 +1123,7 @@ int ha_recover(HASH *commit_list) plugin_foreach(NULL, xarecover_handlerton, MYSQL_STORAGE_ENGINE_PLUGIN, &info); - my_free((gptr)info.list, MYF(0)); + my_free((uchar*)info.list, MYF(0)); if (info.found_foreign_xids) sql_print_warning("Found %d prepared XA transactions", info.found_foreign_xids); @@ -1247,7 +1247,7 @@ int ha_rollback_to_savepoint(THD *thd, SAVEPOINT *sv) { int err; DBUG_ASSERT((*ht)->savepoint_set != 0); - if ((err= (*(*ht)->savepoint_rollback)(*ht, thd, (byte *)(sv+1)+(*ht)->savepoint_offset))) + if ((err= (*(*ht)->savepoint_rollback)(*ht, thd, (uchar *)(sv+1)+(*ht)->savepoint_offset))) { // cannot happen my_error(ER_ERROR_DURING_ROLLBACK, MYF(0), err); error=1; @@ -1295,7 +1295,7 @@ int ha_savepoint(THD *thd, SAVEPOINT *sv) error=1; break; } - if ((err= (*(*ht)->savepoint_set)(*ht, thd, (byte *)(sv+1)+(*ht)->savepoint_offset))) + if ((err= (*(*ht)->savepoint_set)(*ht, thd, (uchar *)(sv+1)+(*ht)->savepoint_offset))) { // cannot happen my_error(ER_GET_ERRNO, MYF(0), err); error=1; @@ -1322,7 +1322,7 @@ int ha_release_savepoint(THD *thd, SAVEPOINT *sv) if (!(*ht)->savepoint_release) continue; if ((err= (*(*ht)->savepoint_release)(*ht, thd, - (byte *)(sv+1)+ + (uchar *)(sv+1)+ (*ht)->savepoint_offset))) { // cannot happen my_error(ER_GET_ERRNO, MYF(0), err); @@ -1572,7 +1572,7 @@ int handler::ha_open(TABLE *table_arg, const char *name, int mode, table->db_stat|=HA_READ_ONLY; (void) extra(HA_EXTRA_NO_READCHECK); // Not needed in SQL - if (!(ref= (byte*) alloc_root(&table->mem_root, ALIGN_SIZE(ref_length)*2))) + if (!(ref= (uchar*) alloc_root(&table->mem_root, ALIGN_SIZE(ref_length)*2))) { close(); error=HA_ERR_OUT_OF_MEM; @@ -1590,7 +1590,7 @@ int handler::ha_open(TABLE *table_arg, const char *name, int mode, This is never called for InnoDB tables, as these table types has the HA_STATS_RECORDS_IS_EXACT set. */ -int handler::read_first_row(byte * buf, uint primary_key) +int handler::read_first_row(uchar * buf, uint primary_key) { register int error; DBUG_ENTER("handler::read_first_row"); @@ -1999,7 +1999,7 @@ void handler::get_auto_increment(ulonglong offset, ulonglong increment, } else { - byte key[MAX_KEY_LENGTH]; + uchar key[MAX_KEY_LENGTH]; key_copy(key, table->record[0], table->key_info + table->s->next_number_index, table->s->next_number_key_offset); @@ -2358,12 +2358,12 @@ static bool update_frm_version(TABLE *table) int4store(version, MYSQL_VERSION_ID); - if ((result= my_pwrite(file,(byte*) version,4,51L,MYF_RW))) + if ((result= my_pwrite(file,(uchar*) version,4,51L,MYF_RW))) goto err; - for (entry=(TABLE*) hash_first(&open_cache,(byte*) key,key_length, &state); + for (entry=(TABLE*) hash_first(&open_cache,(uchar*) key,key_length, &state); entry; - entry= (TABLE*) hash_next(&open_cache,(byte*) key,key_length, &state)) + entry= (TABLE*) hash_next(&open_cache,(uchar*) key,key_length, &state)) entry->s->mysql_version= MYSQL_VERSION_ID; } err: @@ -2526,7 +2526,7 @@ int ha_enable_transaction(THD *thd, bool on) DBUG_RETURN(error); } -int handler::index_next_same(byte *buf, const byte *key, uint keylen) +int handler::index_next_same(uchar *buf, const uchar *key, uint keylen) { int error; if (!(error=index_next(buf))) @@ -2635,8 +2635,8 @@ err: int ha_create_table_from_engine(THD* thd, const char *db, const char *name) { int error; - const void *frmblob; - uint frmlen; + uchar *frmblob; + size_t frmlen; char path[FN_REFLEN]; HA_CREATE_INFO create_info; TABLE table; @@ -2644,7 +2644,7 @@ int ha_create_table_from_engine(THD* thd, const char *db, const char *name) DBUG_ENTER("ha_create_table_from_engine"); DBUG_PRINT("enter", ("name '%s'.'%s'", db, name)); - bzero((char*) &create_info,sizeof(create_info)); + bzero((uchar*) &create_info,sizeof(create_info)); if ((error= ha_discover(thd, db, name, &frmblob, &frmlen))) { /* Table could not be discovered and thus not created */ @@ -2659,7 +2659,7 @@ int ha_create_table_from_engine(THD* thd, const char *db, const char *name) (void)strxnmov(path,FN_REFLEN-1,mysql_data_home,"/",db,"/",name,NullS); // Save the frm file error= writefrm(path, frmblob, frmlen); - my_free((char*) frmblob, MYF(0)); + my_free(frmblob, MYF(0)); if (error) DBUG_RETURN(2); @@ -2801,8 +2801,8 @@ struct st_discover_args { const char *db; const char *name; - const void** frmblob; - uint* frmlen; + uchar **frmblob; + size_t *frmlen; }; static my_bool discover_handlerton(THD *thd, plugin_ref plugin, @@ -2820,7 +2820,7 @@ static my_bool discover_handlerton(THD *thd, plugin_ref plugin, } int ha_discover(THD *thd, const char *db, const char *name, - const void **frmblob, uint *frmlen) + uchar **frmblob, size_t *frmlen) { int error= -1; // Table does not exist in any handler DBUG_ENTER("ha_discover"); @@ -3310,7 +3310,7 @@ int handler::compare_key(key_range *range) } -int handler::index_read_idx(byte * buf, uint index, const byte * key, +int handler::index_read_idx(uchar * buf, uint index, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag) { @@ -3570,8 +3570,8 @@ namespace template<class RowsEventT> int binlog_log_row(TABLE* table, - const byte *before_record, - const byte *after_record) + const uchar *before_record, + const uchar *after_record) { if (table->file->ha_table_flags() & HA_HAS_OWN_BINLOGGING) return 0; @@ -3620,13 +3620,13 @@ namespace */ template int - binlog_log_row<Write_rows_log_event>(TABLE *, const byte *, const byte *); + binlog_log_row<Write_rows_log_event>(TABLE *, const uchar *, const uchar *); template int - binlog_log_row<Delete_rows_log_event>(TABLE *, const byte *, const byte *); + binlog_log_row<Delete_rows_log_event>(TABLE *, const uchar *, const uchar *); template int - binlog_log_row<Update_rows_log_event>(TABLE *, const byte *, const byte *); + binlog_log_row<Update_rows_log_event>(TABLE *, const uchar *, const uchar *); } @@ -3650,9 +3650,9 @@ int handler::ha_reset() { DBUG_ENTER("ha_reset"); /* Check that we have called all proper deallocation functions */ - DBUG_ASSERT((byte*) table->def_read_set.bitmap + + DBUG_ASSERT((uchar*) table->def_read_set.bitmap + table->s->column_bitmap_size == - (byte*) table->def_write_set.bitmap); + (uchar*) table->def_write_set.bitmap); DBUG_ASSERT(bitmap_is_set_all(&table->s->all_set)); DBUG_ASSERT(table->key_read == 0); /* ensure that ha_index_end / ha_rnd_end has been called */ @@ -3663,7 +3663,7 @@ int handler::ha_reset() } -int handler::ha_write_row(byte *buf) +int handler::ha_write_row(uchar *buf) { int error; if (unlikely(error= write_row(buf))) @@ -3673,7 +3673,7 @@ int handler::ha_write_row(byte *buf) return 0; } -int handler::ha_update_row(const byte *old_data, byte *new_data) +int handler::ha_update_row(const uchar *old_data, uchar *new_data) { int error; @@ -3690,7 +3690,7 @@ int handler::ha_update_row(const byte *old_data, byte *new_data) return 0; } -int handler::ha_delete_row(const byte *buf) +int handler::ha_delete_row(const uchar *buf) { int error; if (unlikely(error= delete_row(buf))) @@ -3813,7 +3813,7 @@ int fl_log_iterator_next(struct handler_iterator *iterator, void fl_log_iterator_destroy(struct handler_iterator *iterator) { - my_free((gptr)iterator->buffer, MYF(MY_ALLOW_ZERO_PTR)); + my_free((uchar*)iterator->buffer, MYF(MY_ALLOW_ZERO_PTR)); } @@ -3826,7 +3826,7 @@ fl_log_iterator_buffer_init(struct handler_iterator *iterator) MY_DIR *dirp; struct fl_buff *buff; char *name_ptr; - byte *ptr; + uchar *ptr; FILEINFO *file; uint32 i; @@ -3837,7 +3837,7 @@ fl_log_iterator_buffer_init(struct handler_iterator *iterator) { return HA_ITERATOR_ERROR; } - if ((ptr= (byte*)my_malloc(ALIGN_SIZE(sizeof(fl_buff)) + + if ((ptr= (uchar*)my_malloc(ALIGN_SIZE(sizeof(fl_buff)) + ((ALIGN_SIZE(sizeof(LEX_STRING)) + sizeof(enum log_status) + + FN_REFLEN) * diff --git a/sql/handler.h b/sql/handler.h index 216620a6882..952e7351a68 100644 --- a/sql/handler.h +++ b/sql/handler.h @@ -379,9 +379,9 @@ struct xid_t { return sizeof(formatID)+sizeof(gtrid_length)+sizeof(bqual_length)+ gtrid_length+bqual_length; } - byte *key() + uchar *key() { - return (byte *)>rid_length; + return (uchar *)>rid_length; } uint key_length() { @@ -675,8 +675,8 @@ struct handlerton struct handler_iterator *fill_this_in); int (*discover)(handlerton *hton, THD* thd, const char *db, const char *name, - const void** frmblob, - uint* frmlen); + uchar **frmblob, + size_t *frmlen); int (*find_files)(handlerton *hton, THD *thd, const char *db, const char *path, @@ -836,9 +836,9 @@ typedef struct st_ha_check_opt typedef struct st_handler_buffer { - const byte *buffer; /* Buffer one can start using */ - const byte *buffer_end; /* End of buffer */ - byte *end_of_used_area; /* End of area that was used by handler */ + const uchar *buffer; /* Buffer one can start using */ + const uchar *buffer_end; /* End of buffer */ + uchar *end_of_used_area; /* End of area that was used by handler */ } HANDLER_BUFFER; typedef struct system_status_var SSV; @@ -868,7 +868,7 @@ public: {} }; -uint calculate_key_len(TABLE *, uint, const byte *, key_part_map); +uint calculate_key_len(TABLE *, uint, const uchar *, key_part_map); /* bitmap with first N+1 bits set (keypart_map for a key prefix of [0..N] keyparts) @@ -919,8 +919,8 @@ class handler :public Sql_alloc virtual int end_bulk_insert() {return 0; } public: handlerton *ht; /* storage engine of this handler */ - byte *ref; /* Pointer to current row */ - byte *dup_ref; /* Pointer to duplicate row */ + uchar *ref; /* Pointer to current row */ + uchar *dup_ref; /* Pointer to duplicate row */ ha_statistics stats; @@ -1143,9 +1143,9 @@ public: and delete_row() below. */ int ha_external_lock(THD *thd, int lock_type); - int ha_write_row(byte * buf); - int ha_update_row(const byte * old_data, byte * new_data); - int ha_delete_row(const byte * buf); + int ha_write_row(uchar * buf); + int ha_update_row(const uchar * old_data, uchar * new_data); + int ha_delete_row(const uchar * buf); /* SYNOPSIS @@ -1178,7 +1178,7 @@ public: 0 Bulk delete used by handler 1 Bulk delete not used, normal operation used */ - virtual int bulk_update_row(const byte *old_data, byte *new_data, + virtual int bulk_update_row(const uchar *old_data, uchar *new_data, uint *dup_key_found) { DBUG_ASSERT(FALSE); @@ -1227,7 +1227,7 @@ public: return HA_ERR_WRONG_COMMAND; } private: - virtual int index_read(byte * buf, const byte * key, uint key_len, + virtual int index_read(uchar * buf, const uchar * key, uint key_len, enum ha_rkey_function find_flag) { return HA_ERR_WRONG_COMMAND; } public: @@ -1237,7 +1237,7 @@ public: row if available. If the key value is null, begin at the first key of the index. */ - virtual int index_read(byte * buf, const byte * key, key_part_map keypart_map, + virtual int index_read(uchar * buf, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag) { uint key_len= calculate_key_len(table, active_index, key, keypart_map); @@ -1249,20 +1249,20 @@ public: row if available. If the key value is null, begin at the first key of the index. */ - virtual int index_read_idx(byte * buf, uint index, const byte * key, + virtual int index_read_idx(uchar * buf, uint index, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag); - virtual int index_next(byte * buf) + virtual int index_next(uchar * buf) { return HA_ERR_WRONG_COMMAND; } - virtual int index_prev(byte * buf) + virtual int index_prev(uchar * buf) { return HA_ERR_WRONG_COMMAND; } - virtual int index_first(byte * buf) + virtual int index_first(uchar * buf) { return HA_ERR_WRONG_COMMAND; } - virtual int index_last(byte * buf) + virtual int index_last(uchar * buf) { return HA_ERR_WRONG_COMMAND; } - virtual int index_next_same(byte *buf, const byte *key, uint keylen); + virtual int index_next_same(uchar *buf, const uchar *key, uint keylen); private: - virtual int index_read_last(byte * buf, const byte * key, uint key_len) + virtual int index_read_last(uchar * buf, const uchar * key, uint key_len) { return (my_errno=HA_ERR_WRONG_COMMAND); } public: /** @@ -1270,7 +1270,7 @@ public: The following functions works like index_read, but it find the last row with the current key value or prefix. */ - virtual int index_read_last(byte * buf, const byte * key, + virtual int index_read_last(uchar * buf, const uchar * key, key_part_map keypart_map) { uint key_len= calculate_key_len(table, active_index, key, keypart_map); @@ -1289,21 +1289,21 @@ public: void ft_end() { ft_handler=NULL; } virtual FT_INFO *ft_init_ext(uint flags, uint inx,String *key) { return NULL; } - virtual int ft_read(byte *buf) { return HA_ERR_WRONG_COMMAND; } - virtual int rnd_next(byte *buf)=0; - virtual int rnd_pos(byte * buf, byte *pos)=0; - virtual int read_first_row(byte *buf, uint primary_key); + virtual int ft_read(uchar *buf) { return HA_ERR_WRONG_COMMAND; } + virtual int rnd_next(uchar *buf)=0; + virtual int rnd_pos(uchar * buf, uchar *pos)=0; + virtual int read_first_row(uchar *buf, uint primary_key); /* The following function is only needed for tables that may be temporary tables during joins */ - virtual int restart_rnd_next(byte *buf, byte *pos) + virtual int restart_rnd_next(uchar *buf, uchar *pos) { return HA_ERR_WRONG_COMMAND; } - virtual int rnd_same(byte *buf, uint inx) + virtual int rnd_same(uchar *buf, uint inx) { return HA_ERR_WRONG_COMMAND; } virtual ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key) { return (ha_rows) 10; } - virtual void position(const byte *record)=0; + virtual void position(const uchar *record)=0; virtual int info(uint)=0; // see my_base.h for full description virtual void get_dynamic_partition_info(PARTITION_INFO *stat_info, uint part_id); @@ -1559,8 +1559,8 @@ public: const char *path, ulonglong *copied, ulonglong *deleted, - const void *pack_frm_data, - uint pack_frm_len) + const uchar *pack_frm_data, + size_t pack_frm_len) { return HA_ERR_WRONG_COMMAND; } virtual int drop_partitions(const char *path) { return HA_ERR_WRONG_COMMAND; } @@ -1603,7 +1603,7 @@ public: false otherwise */ virtual bool primary_key_is_clustered() { return FALSE; } - virtual int cmp_ref(const byte *ref1, const byte *ref2) + virtual int cmp_ref(const uchar *ref1, const uchar *ref2) { return memcmp(ref1, ref2, ref_length); } @@ -1648,18 +1648,18 @@ public: { return COMPATIBLE_DATA_NO; } /* These are only called from sql_select for internal temporary tables */ - virtual int write_row(byte *buf __attribute__((unused))) + virtual int write_row(uchar *buf __attribute__((unused))) { return HA_ERR_WRONG_COMMAND; } - virtual int update_row(const byte *old_data __attribute__((unused)), - byte *new_data __attribute__((unused))) + virtual int update_row(const uchar *old_data __attribute__((unused)), + uchar *new_data __attribute__((unused))) { return HA_ERR_WRONG_COMMAND; } - virtual int delete_row(const byte *buf __attribute__((unused))) + virtual int delete_row(const uchar *buf __attribute__((unused))) { return HA_ERR_WRONG_COMMAND; } @@ -1752,7 +1752,7 @@ bool ha_show_status(THD *thd, handlerton *db_type, enum ha_stat_type stat); /* discovery */ int ha_create_table_from_engine(THD* thd, const char *db, const char *name); int ha_discover(THD* thd, const char* dbname, const char* name, - const void** frmblob, uint* frmlen); + uchar** frmblob, size_t* frmlen); int ha_find_files(THD *thd,const char *db,const char *path, const char *wild, bool dir,List<char>* files); int ha_table_exists_in_engine(THD* thd, const char* db, const char* name); diff --git a/sql/hash_filo.h b/sql/hash_filo.h index c25af67b572..ab13d338695 100644 --- a/sql/hash_filo.h +++ b/sql/hash_filo.h @@ -84,10 +84,10 @@ public: first_link=last_link=0; } - hash_filo_element *search(gptr key,uint length) + hash_filo_element *search(uchar* key, size_t length) { hash_filo_element *entry=(hash_filo_element*) - hash_search(&cache,(byte*) key,length); + hash_search(&cache,(uchar*) key,length); if (entry) { // Found; link it first if (entry != first_link) @@ -113,9 +113,9 @@ public: { hash_filo_element *tmp=last_link; last_link=last_link->prev_used; - hash_delete(&cache,(byte*) tmp); + hash_delete(&cache,(uchar*) tmp); } - if (my_hash_insert(&cache,(byte*) entry)) + if (my_hash_insert(&cache,(uchar*) entry)) { if (free_element) (*free_element)(entry); // This should never happen diff --git a/sql/hostname.cc b/sql/hostname.cc index 049220c6b6f..34384a9c8c0 100644 --- a/sql/hostname.cc +++ b/sql/hostname.cc @@ -84,7 +84,7 @@ static void add_hostname(struct in_addr *in,const char *name) { VOID(pthread_mutex_lock(&hostname_cache->lock)); host_entry *entry; - if (!(entry=(host_entry*) hostname_cache->search((gptr) &in->s_addr,0))) + if (!(entry=(host_entry*) hostname_cache->search((uchar*) &in->s_addr,0))) { uint length=name ? (uint) strlen(name) : 0; @@ -115,7 +115,7 @@ void inc_host_errors(struct in_addr *in) { VOID(pthread_mutex_lock(&hostname_cache->lock)); host_entry *entry; - if ((entry=(host_entry*) hostname_cache->search((gptr) &in->s_addr,0))) + if ((entry=(host_entry*) hostname_cache->search((uchar*) &in->s_addr,0))) entry->errors++; VOID(pthread_mutex_unlock(&hostname_cache->lock)); } @@ -124,7 +124,7 @@ void reset_host_errors(struct in_addr *in) { VOID(pthread_mutex_lock(&hostname_cache->lock)); host_entry *entry; - if ((entry=(host_entry*) hostname_cache->search((gptr) &in->s_addr,0))) + if ((entry=(host_entry*) hostname_cache->search((uchar*) &in->s_addr,0))) entry->errors=0; VOID(pthread_mutex_unlock(&hostname_cache->lock)); } @@ -134,7 +134,7 @@ void reset_host_errors(struct in_addr *in) #define INADDR_LOOPBACK 0x7f000001UL #endif -my_string ip_to_hostname(struct in_addr *in, uint *errors) +char * ip_to_hostname(struct in_addr *in, uint *errors) { uint i; host_entry *entry; @@ -149,7 +149,7 @@ my_string ip_to_hostname(struct in_addr *in, uint *errors) if (!(specialflag & SPECIAL_NO_HOST_CACHE)) { VOID(pthread_mutex_lock(&hostname_cache->lock)); - if ((entry=(host_entry*) hostname_cache->search((gptr) &in->s_addr,0))) + if ((entry=(host_entry*) hostname_cache->search((uchar*) &in->s_addr,0))) { char *name; if (!entry->hostname) diff --git a/sql/item.cc b/sql/item.cc index 24958f64f2a..6f68ba37603 100644 --- a/sql/item.cc +++ b/sql/item.cc @@ -161,6 +161,7 @@ Hybrid_type_traits_integer::fix_length_and_dec(Item *item, Item *arg) const void item_init(void) { item_user_lock_init(); + uuid_short_init(); } @@ -431,7 +432,7 @@ void Item::cleanup() arg - a dummy parameter, is not used here */ -bool Item::cleanup_processor(byte *arg) +bool Item::cleanup_processor(uchar *arg) { if (fixed) cleanup(); @@ -494,7 +495,7 @@ void Item::rename(char *new_name) pointer to newly allocated item is returned. */ -Item* Item::transform(Item_transformer transformer, byte *arg) +Item* Item::transform(Item_transformer transformer, uchar *arg) { DBUG_ASSERT(!current_thd->is_stmt_prepare()); @@ -552,7 +553,7 @@ void Item_ident::cleanup() DBUG_VOID_RETURN; } -bool Item_ident::remove_dependence_processor(byte * arg) +bool Item_ident::remove_dependence_processor(uchar * arg) { DBUG_ENTER("Item_ident::remove_dependence_processor"); if (depended_from == (st_select_lex *) arg) @@ -583,7 +584,7 @@ bool Item_ident::remove_dependence_processor(byte * arg) for the subsequent items. */ -bool Item_field::collect_item_field_processor(byte *arg) +bool Item_field::collect_item_field_processor(uchar *arg) { DBUG_ENTER("Item_field::collect_item_field_processor"); DBUG_PRINT("info", ("%s", field->field_name ? field->field_name : "noname")); @@ -618,7 +619,7 @@ bool Item_field::collect_item_field_processor(byte *arg) FALSE otherwise */ -bool Item_field::find_item_in_field_list_processor(byte *arg) +bool Item_field::find_item_in_field_list_processor(uchar *arg) { KEY_PART_INFO *first_non_group_part= *((KEY_PART_INFO **) arg); KEY_PART_INFO *last_part= *(((KEY_PART_INFO **) arg) + 1); @@ -641,7 +642,7 @@ bool Item_field::find_item_in_field_list_processor(byte *arg) column read set or to register used fields in a view */ -bool Item_field::register_field_in_read_map(byte *arg) +bool Item_field::register_field_in_read_map(uchar *arg) { TABLE *table= (TABLE *) arg; if (field->table == table || !table) @@ -690,7 +691,7 @@ void Item::set_name(const char *str, uint length, CHARSET_INFO *cs) } if (!my_charset_same(cs, system_charset_info)) { - uint32 res_length; + size_t res_length; name= sql_strmake_with_convert(str, name_length= length, cs, MAX_ALIAS_NAME, system_charset_info, &res_length); @@ -785,7 +786,7 @@ Item *Item_string::safe_charset_converter(CHARSET_INFO *tocs) */ return NULL; } - if (!(ptr= current_thd->memdup(cstr.ptr(), cstr.length() + 1 ))) + if (!(ptr= current_thd->strmake(cstr.ptr(), cstr.length()))) return NULL; conv->str_value.set(ptr, cstr.length(), cstr.charset()); /* Ensure that no one is going to change the result string */ @@ -2139,7 +2140,7 @@ Item_decimal::Item_decimal(my_decimal *value_par) } -Item_decimal::Item_decimal(const char *bin, int precision, int scale) +Item_decimal::Item_decimal(const uchar *bin, int precision, int scale) { binary2my_decimal(E_DEC_FATAL_ERROR, bin, &decimal_value, precision, scale); @@ -4067,7 +4068,7 @@ Item_equal *Item_field::find_item_equal(COND_EQUAL *cond_equal) FALSE otherwise */ -bool Item_field::subst_argument_checker(byte **arg) +bool Item_field::subst_argument_checker(uchar **arg) { return (result_type() != STRING_RESULT) || (*arg); } @@ -4099,7 +4100,7 @@ bool Item_field::subst_argument_checker(byte **arg) pointer to the field item, otherwise. */ -Item *Item_field::equal_fields_propagator(byte *arg) +Item *Item_field::equal_fields_propagator(uchar *arg) { if (no_const_subst) return this; @@ -4130,7 +4131,7 @@ Item *Item_field::equal_fields_propagator(byte *arg) See comments in Arg_comparator::set_compare_func() for details */ -bool Item_field::set_no_const_sub(byte *arg) +bool Item_field::set_no_const_sub(uchar *arg) { if (field->charset() != &my_charset_bin) no_const_subst=1; @@ -4165,7 +4166,7 @@ bool Item_field::set_no_const_sub(byte *arg) this - otherwise. */ -Item *Item_field::replace_equal_field(byte *arg) +Item *Item_field::replace_equal_field(uchar *arg) { if (item_equal) { @@ -4315,42 +4316,42 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, bool fixed_length) switch (field_type()) { case MYSQL_TYPE_DECIMAL: case MYSQL_TYPE_NEWDECIMAL: - field= new Field_new_decimal((char*) 0, max_length, null_ptr, 0, + field= new Field_new_decimal((uchar*) 0, max_length, null_ptr, 0, Field::NONE, name, decimals, 0, unsigned_flag); break; case MYSQL_TYPE_TINY: - field= new Field_tiny((char*) 0, max_length, null_ptr, 0, Field::NONE, + field= new Field_tiny((uchar*) 0, max_length, null_ptr, 0, Field::NONE, name, 0, unsigned_flag); break; case MYSQL_TYPE_SHORT: - field= new Field_short((char*) 0, max_length, null_ptr, 0, Field::NONE, + field= new Field_short((uchar*) 0, max_length, null_ptr, 0, Field::NONE, name, 0, unsigned_flag); break; case MYSQL_TYPE_LONG: - field= new Field_long((char*) 0, max_length, null_ptr, 0, Field::NONE, + field= new Field_long((uchar*) 0, max_length, null_ptr, 0, Field::NONE, name, 0, unsigned_flag); break; #ifdef HAVE_LONG_LONG case MYSQL_TYPE_LONGLONG: - field= new Field_longlong((char*) 0, max_length, null_ptr, 0, Field::NONE, + field= new Field_longlong((uchar*) 0, max_length, null_ptr, 0, Field::NONE, name, 0, unsigned_flag); break; #endif case MYSQL_TYPE_FLOAT: - field= new Field_float((char*) 0, max_length, null_ptr, 0, Field::NONE, + field= new Field_float((uchar*) 0, max_length, null_ptr, 0, Field::NONE, name, decimals, 0, unsigned_flag); break; case MYSQL_TYPE_DOUBLE: - field= new Field_double((char*) 0, max_length, null_ptr, 0, Field::NONE, + field= new Field_double((uchar*) 0, max_length, null_ptr, 0, Field::NONE, name, decimals, 0, unsigned_flag); break; case MYSQL_TYPE_NULL: - field= new Field_null((char*) 0, max_length, Field::NONE, + field= new Field_null((uchar*) 0, max_length, Field::NONE, name, &my_charset_bin); break; case MYSQL_TYPE_INT24: - field= new Field_medium((char*) 0, max_length, null_ptr, 0, Field::NONE, + field= new Field_medium((uchar*) 0, max_length, null_ptr, 0, Field::NONE, name, 0, unsigned_flag); break; case MYSQL_TYPE_NEWDATE: @@ -4367,7 +4368,7 @@ Field *Item::tmp_table_field_from_field_type(TABLE *table, bool fixed_length) field= new Field_datetime(maybe_null, name, &my_charset_bin); break; case MYSQL_TYPE_YEAR: - field= new Field_year((char*) 0, max_length, null_ptr, 0, Field::NONE, + field= new Field_year((uchar*) 0, max_length, null_ptr, 0, Field::NONE, name); break; case MYSQL_TYPE_BIT: @@ -5031,7 +5032,7 @@ void Item_field::update_null_value() this field otherwise */ -Item *Item_field::update_value_transformer(byte *select_arg) +Item *Item_field::update_value_transformer(uchar *select_arg) { SELECT_LEX *select= (SELECT_LEX*)select_arg; DBUG_ASSERT(fixed); @@ -5848,7 +5849,7 @@ int Item_default_value::save_in_field(Field *field_arg, bool no_conversions) same time it can replace some nodes in the tree */ -Item *Item_default_value::transform(Item_transformer transformer, byte *args) +Item *Item_default_value::transform(Item_transformer transformer, uchar *args) { DBUG_ASSERT(!current_thd->is_stmt_prepare()); @@ -6790,7 +6791,7 @@ Field *Item_type_holder::make_field_by_type(TABLE *table) switch (fld_type) { case MYSQL_TYPE_ENUM: DBUG_ASSERT(enum_set_typelib); - field= new Field_enum((char *) 0, max_length, null_ptr, 0, + field= new Field_enum((uchar *) 0, max_length, null_ptr, 0, Field::NONE, name, get_enum_pack_length(enum_set_typelib->count), enum_set_typelib, collation.collation); @@ -6799,7 +6800,7 @@ Field *Item_type_holder::make_field_by_type(TABLE *table) return field; case MYSQL_TYPE_SET: DBUG_ASSERT(enum_set_typelib); - field= new Field_set((char *) 0, max_length, null_ptr, 0, + field= new Field_set((uchar *) 0, max_length, null_ptr, 0, Field::NONE, name, get_set_pack_length(enum_set_typelib->count), enum_set_typelib, collation.collation); diff --git a/sql/item.h b/sql/item.h index 957edbb8f0d..1c8b46fe0c7 100644 --- a/sql/item.h +++ b/sql/item.h @@ -426,7 +426,7 @@ public: }; -typedef bool (Item::*Item_processor) (byte *arg); +typedef bool (Item::*Item_processor) (uchar *arg); /* Analyzer function SYNOPSIS @@ -438,8 +438,8 @@ typedef bool (Item::*Item_processor) (byte *arg); FALSE Don't do it */ -typedef bool (Item::*Item_analyzer) (byte **argp); -typedef Item* (Item::*Item_transformer) (byte *arg); +typedef bool (Item::*Item_analyzer) (uchar **argp); +typedef Item* (Item::*Item_transformer) (uchar *arg); typedef void (*Cond_traverser) (const Item *item, void *arg); @@ -448,9 +448,9 @@ class Item { void operator=(Item &); public: static void *operator new(size_t size) - { return (void*) sql_alloc((uint) size); } + { return sql_alloc(size); } static void *operator new(size_t size, MEM_ROOT *mem_root) - { return (void*) alloc_root(mem_root, (uint) size); } + { return alloc_root(mem_root, size); } static void operator delete(void *ptr,size_t size) { TRASH(ptr, size); } static void operator delete(void *ptr, MEM_ROOT *mem_root) {} @@ -476,9 +476,9 @@ public: save_in_field */ String str_value; - my_string name; /* Name from select */ + char * name; /* Name from select */ /* Original item name (if it was renamed)*/ - my_string orig_name; + char * orig_name; Item *next; uint32 max_length; uint name_length; /* Length of name */ @@ -779,12 +779,12 @@ public: static CHARSET_INFO *default_charset(); virtual CHARSET_INFO *compare_collation() { return NULL; } - virtual bool walk(Item_processor processor, bool walk_subquery, byte *arg) + virtual bool walk(Item_processor processor, bool walk_subquery, uchar *arg) { return (this->*processor)(arg); } - virtual Item* transform(Item_transformer transformer, byte *arg); + virtual Item* transform(Item_transformer transformer, uchar *arg); /* This function performs a generic "compilation" of the Item tree. @@ -802,8 +802,8 @@ public: i.e. analysis is performed top-down while transformation is done bottom-up. */ - virtual Item* compile(Item_analyzer analyzer, byte **arg_p, - Item_transformer transformer, byte *arg_t) + virtual Item* compile(Item_analyzer analyzer, uchar **arg_p, + Item_transformer transformer, uchar *arg_t) { if ((this->*analyzer) (arg_p)) return ((this->*transformer) (arg_t)); @@ -816,15 +816,15 @@ public: (*traverser)(this, arg); } - virtual bool remove_dependence_processor(byte * arg) { return 0; } - virtual bool remove_fixed(byte * arg) { fixed= 0; return 0; } - virtual bool cleanup_processor(byte *arg); - virtual bool collect_item_field_processor(byte * arg) { return 0; } - virtual bool find_item_in_field_list_processor(byte *arg) { return 0; } - virtual bool change_context_processor(byte *context) { return 0; } - virtual bool reset_query_id_processor(byte *query_id_arg) { return 0; } - virtual bool is_expensive_processor(byte *arg) { return 0; } - virtual bool register_field_in_read_map(byte *arg) { return 0; } + virtual bool remove_dependence_processor(uchar * arg) { return 0; } + virtual bool remove_fixed(uchar * arg) { fixed= 0; return 0; } + virtual bool cleanup_processor(uchar *arg); + virtual bool collect_item_field_processor(uchar * arg) { return 0; } + virtual bool find_item_in_field_list_processor(uchar *arg) { return 0; } + virtual bool change_context_processor(uchar *context) { return 0; } + virtual bool reset_query_id_processor(uchar *query_id_arg) { return 0; } + virtual bool is_expensive_processor(uchar *arg) { return 0; } + virtual bool register_field_in_read_map(uchar *arg) { return 0; } /* Check if a partition function is allowed SYNOPSIS @@ -877,17 +877,17 @@ public: assumes that there are no multi-byte collations amongst the partition fields. */ - virtual bool check_partition_func_processor(byte *bool_arg) { return TRUE;} - virtual bool subst_argument_checker(byte **arg) + virtual bool check_partition_func_processor(uchar *bool_arg) { return TRUE;} + virtual bool subst_argument_checker(uchar **arg) { if (*arg) *arg= NULL; return TRUE; } - virtual Item *equal_fields_propagator(byte * arg) { return this; } - virtual bool set_no_const_sub(byte *arg) { return FALSE; } - virtual Item *replace_equal_field(byte * arg) { return this; } + virtual Item *equal_fields_propagator(uchar * arg) { return this; } + virtual bool set_no_const_sub(uchar *arg) { return FALSE; } + virtual Item *replace_equal_field(uchar * arg) { return this; } /* For SP local variable returns pointer to Item representing its @@ -916,7 +916,7 @@ public: virtual Item_field *filed_for_view_update() { return 0; } virtual Item *neg_transformer(THD *thd) { return NULL; } - virtual Item *update_value_transformer(byte *select_arg) { return this; } + virtual Item *update_value_transformer(uchar *select_arg) { return this; } virtual Item *safe_charset_converter(CHARSET_INFO *tocs); void delete_self() { @@ -1224,7 +1224,7 @@ public: Item_num() {} /* Remove gcc warning */ virtual Item_num *neg()= 0; Item *safe_charset_converter(CHARSET_INFO *tocs); - bool check_partition_func_processor(byte *int_arg) { return FALSE;} + bool check_partition_func_processor(uchar *int_arg) { return FALSE;} }; #define NO_CACHED_FIELD_INDEX ((uint)(-1)) @@ -1268,9 +1268,9 @@ public: Item_ident(THD *thd, Item_ident *item); const char *full_name() const; void cleanup(); - bool remove_dependence_processor(byte * arg); + bool remove_dependence_processor(uchar * arg); void print(String *str); - virtual bool change_context_processor(byte *cntx) + virtual bool change_context_processor(uchar *cntx) { context= (Name_resolution_context *)cntx; return FALSE; } friend bool insert_fields(THD *thd, Name_resolution_context *context, const char *db_name, @@ -1379,25 +1379,25 @@ public: bool is_null() { return field->is_null(); } void update_null_value(); Item *get_tmp_table_item(THD *thd); - bool collect_item_field_processor(byte * arg); - bool find_item_in_field_list_processor(byte *arg); - bool register_field_in_read_map(byte *arg); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool collect_item_field_processor(uchar * arg); + bool find_item_in_field_list_processor(uchar *arg); + bool register_field_in_read_map(uchar *arg); + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} void cleanup(); bool result_as_longlong() { return field->can_be_compared_as_longlong(); } Item_equal *find_item_equal(COND_EQUAL *cond_equal); - bool subst_argument_checker(byte **arg); - Item *equal_fields_propagator(byte *arg); - bool set_no_const_sub(byte *arg); - Item *replace_equal_field(byte *arg); + bool subst_argument_checker(uchar **arg); + Item *equal_fields_propagator(uchar *arg); + bool set_no_const_sub(uchar *arg); + Item *replace_equal_field(uchar *arg); inline uint32 max_disp_length() { return field->max_display_length(); } Item_field *filed_for_view_update() { return this; } Item *safe_charset_converter(CHARSET_INFO *tocs); int fix_outer_field(THD *thd, Field **field, Item **reference); - virtual Item *update_value_transformer(byte *select_arg); + virtual Item *update_value_transformer(uchar *select_arg); void print(String *str); friend class Item_default_value; friend class Item_insert_value; @@ -1433,7 +1433,7 @@ public: bool is_null() { return 1; } void print(String *str) { str->append(STRING_WITH_LEN("NULL")); } Item *safe_charset_converter(CHARSET_INFO *tocs); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class Item_null_result :public Item_null @@ -1446,7 +1446,7 @@ public: { save_in_field(result_field, no_conversions); } - bool check_partition_func_processor(byte *int_arg) {return TRUE;} + bool check_partition_func_processor(uchar *int_arg) {return TRUE;} }; /* Item represents one placeholder ('?') of prepared statement */ @@ -1653,7 +1653,7 @@ public: Item_decimal(my_decimal *value_par); Item_decimal(longlong val, bool unsig); Item_decimal(double val, int precision, int scale); - Item_decimal(const char *bin, int precision, int scale); + Item_decimal(const uchar *bin, int precision, int scale); enum Type type() const { return DECIMAL_ITEM; } enum Item_result result_type () const { return DECIMAL_RESULT; } @@ -1740,7 +1740,7 @@ public: {} void print(String *str) { str->append(func_name); } Item *safe_charset_converter(CHARSET_INFO *tocs); - bool check_partition_func_processor(byte *int_arg) {return TRUE;} + bool check_partition_func_processor(uchar *int_arg) {return TRUE;} }; @@ -1822,7 +1822,7 @@ public: void print(String *str); // to prevent drop fixed flag (no need parent cleanup call) void cleanup() {} - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -1837,7 +1837,7 @@ public: {} Item *safe_charset_converter(CHARSET_INFO *tocs); void print(String *str) { str->append(func_name); } - bool check_partition_func_processor(byte *int_arg) {return TRUE;} + bool check_partition_func_processor(uchar *int_arg) {return TRUE;} }; @@ -1849,7 +1849,7 @@ public: CHARSET_INFO *cs= NULL): Item_string(name, length, cs) {} - bool check_partition_func_processor(byte *int_arg) {return TRUE;} + bool check_partition_func_processor(uchar *int_arg) {return TRUE;} }; @@ -1897,7 +1897,7 @@ public: unsigned_flag=1; } enum_field_types field_type() const { return int_field_type; } - bool check_partition_func_processor(byte *int_arg) {return TRUE;} + bool check_partition_func_processor(uchar *int_arg) {return TRUE;} }; @@ -1924,7 +1924,7 @@ public: void cleanup() {} bool eq(const Item *item, bool binary_cmp) const; virtual Item *safe_charset_converter(CHARSET_INFO *tocs); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -2044,7 +2044,7 @@ public: { return ref ? (*ref)->real_item() : this; } - bool walk(Item_processor processor, bool walk_subquery, byte *arg) + bool walk(Item_processor processor, bool walk_subquery, uchar *arg) { return (*ref)->walk(processor, walk_subquery, arg); } void print(String *str); bool result_as_longlong() @@ -2223,7 +2223,7 @@ public: } Item *clone_item(); virtual Item *real_item() { return ref; } - bool check_partition_func_processor(byte *int_arg) {return TRUE;} + bool check_partition_func_processor(uchar *int_arg) {return TRUE;} }; #ifdef MYSQL_SERVER @@ -2332,7 +2332,7 @@ public: class Cached_item_field :public Cached_item { - char *buff; + uchar *buff; Field *field; uint length; @@ -2340,7 +2340,7 @@ public: Cached_item_field(Item_field *item) { field= item->field; - buff= (char*) sql_calloc(length=field->pack_length()); + buff= (uchar*) sql_calloc(length=field->pack_length()); } bool cmp(void); }; @@ -2364,13 +2364,13 @@ public: int save_in_field(Field *field_arg, bool no_conversions); table_map used_tables() const { return (table_map)0L; } - bool walk(Item_processor processor, bool walk_subquery, byte *args) + bool walk(Item_processor processor, bool walk_subquery, uchar *args) { return arg->walk(processor, walk_subquery, args) || (this->*processor)(args); } - Item *transform(Item_transformer transformer, byte *args); + Item *transform(Item_transformer transformer, uchar *args); }; /* @@ -2404,7 +2404,7 @@ public: */ table_map used_tables() const { return RAND_TABLE_BIT; } - bool walk(Item_processor processor, bool walk_subquery, byte *args) + bool walk(Item_processor processor, bool walk_subquery, uchar *args) { return arg->walk(processor, walk_subquery, args) || (this->*processor)(args); diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc index 4a18de8ce4f..6842febea4d 100644 --- a/sql/item_cmpfunc.cc +++ b/sql/item_cmpfunc.cc @@ -531,8 +531,8 @@ int Arg_comparator::set_compare_func(Item_bool_func2 *item, Item_result type) which would be transformed to: WHERE col= 'j' */ - (*a)->walk(&Item::set_no_const_sub, FALSE, (byte*) 0); - (*b)->walk(&Item::set_no_const_sub, FALSE, (byte*) 0); + (*a)->walk(&Item::set_no_const_sub, FALSE, (uchar*) 0); + (*b)->walk(&Item::set_no_const_sub, FALSE, (uchar*) 0); } break; } @@ -2435,7 +2435,7 @@ bool Item_func_case::fix_fields(THD *thd, Item **ref) Item_func_case::val_int() -> Item_func_case::find_item() */ #ifndef EMBEDDED_LIBRARY - char buff[MAX_FIELD_WIDTH*2+sizeof(String)*2+sizeof(String*)*2+sizeof(double)*2+sizeof(longlong)*2]; + uchar buff[MAX_FIELD_WIDTH*2+sizeof(String)*2+sizeof(String*)*2+sizeof(double)*2+sizeof(longlong)*2]; #endif bool res= Item_func::fix_fields(thd, ref); /* @@ -2775,7 +2775,7 @@ static int cmp_decimal(void *cmp_arg, my_decimal *a, my_decimal *b) int in_vector::find(Item *item) { - byte *result=get_value(item); + uchar *result=get_value(item); if (!result || !used_count) return 0; // Null value @@ -2830,9 +2830,9 @@ void in_string::set(uint pos,Item *item) } -byte *in_string::get_value(Item *item) +uchar *in_string::get_value(Item *item) { - return (byte*) item->val_str(&tmp); + return (uchar*) item->val_str(&tmp); } in_row::in_row(uint elements, Item * item) @@ -2854,12 +2854,12 @@ in_row::~in_row() delete [] (cmp_item_row*) base; } -byte *in_row::get_value(Item *item) +uchar *in_row::get_value(Item *item) { tmp.store_value(item); if (item->is_null()) return 0; - return (byte *)&tmp; + return (uchar *)&tmp; } void in_row::set(uint pos, Item *item) @@ -2882,13 +2882,13 @@ void in_longlong::set(uint pos,Item *item) buff->unsigned_flag= item->unsigned_flag; } -byte *in_longlong::get_value(Item *item) +uchar *in_longlong::get_value(Item *item) { tmp.val= item->val_int(); if (item->null_value) return 0; tmp.unsigned_flag= item->unsigned_flag; - return (byte*) &tmp; + return (uchar*) &tmp; } void in_datetime::set(uint pos,Item *item) @@ -2901,7 +2901,7 @@ void in_datetime::set(uint pos,Item *item) buff->unsigned_flag= 1L; } -byte *in_datetime::get_value(Item *item) +uchar *in_datetime::get_value(Item *item) { bool is_null; Item **tmp_item= lval_cache ? &lval_cache : &item; @@ -2909,7 +2909,7 @@ byte *in_datetime::get_value(Item *item) if (item->null_value) return 0; tmp.unsigned_flag= 1L; - return (byte*) &tmp; + return (uchar*) &tmp; } in_double::in_double(uint elements) @@ -2921,12 +2921,12 @@ void in_double::set(uint pos,Item *item) ((double*) base)[pos]= item->val_real(); } -byte *in_double::get_value(Item *item) +uchar *in_double::get_value(Item *item) { tmp= item->val_real(); if (item->null_value) return 0; /* purecov: inspected */ - return (byte*) &tmp; + return (uchar*) &tmp; } @@ -2948,12 +2948,12 @@ void in_decimal::set(uint pos, Item *item) } -byte *in_decimal::get_value(Item *item) +uchar *in_decimal::get_value(Item *item) { my_decimal *result= item->val_decimal(&val); if (item->null_value) return 0; - return (byte *)result; + return (uchar *)result; } @@ -3603,7 +3603,7 @@ Item_cond::fix_fields(THD *thd, Item **ref) List_iterator<Item> li(list); Item *item; #ifndef EMBEDDED_LIBRARY - char buff[sizeof(char*)]; // Max local vars in function + uchar buff[sizeof(char*)]; // Max local vars in function #endif not_null_tables_cache= used_tables_cache= 0; const_item_cache= 1; @@ -3670,7 +3670,7 @@ Item_cond::fix_fields(THD *thd, Item **ref) return FALSE; } -bool Item_cond::walk(Item_processor processor, bool walk_subquery, byte *arg) +bool Item_cond::walk(Item_processor processor, bool walk_subquery, uchar *arg) { List_iterator_fast<Item> li(list); Item *item; @@ -3702,7 +3702,7 @@ bool Item_cond::walk(Item_processor processor, bool walk_subquery, byte *arg) Item returned as the result of transformation of the root node */ -Item *Item_cond::transform(Item_transformer transformer, byte *arg) +Item *Item_cond::transform(Item_transformer transformer, uchar *arg) { DBUG_ASSERT(!current_thd->is_stmt_prepare()); @@ -3753,8 +3753,8 @@ Item *Item_cond::transform(Item_transformer transformer, byte *arg) Item returned as the result of transformation of the root node */ -Item *Item_cond::compile(Item_analyzer analyzer, byte **arg_p, - Item_transformer transformer, byte *arg_t) +Item *Item_cond::compile(Item_analyzer analyzer, uchar **arg_p, + Item_transformer transformer, uchar *arg_t) { if (!(this->*analyzer)(arg_p)) return 0; @@ -3767,7 +3767,7 @@ Item *Item_cond::compile(Item_analyzer analyzer, byte **arg_p, The same parameter value of arg_p must be passed to analyze any argument of the condition formula. */ - byte *arg_v= *arg_p; + uchar *arg_v= *arg_p; Item *new_item= item->compile(analyzer, &arg_v, transformer, arg_t); if (new_item && new_item != item) li.replace(new_item); @@ -5001,7 +5001,7 @@ void Item_equal::fix_length_and_dec() item->collation.collation); } -bool Item_equal::walk(Item_processor processor, bool walk_subquery, byte *arg) +bool Item_equal::walk(Item_processor processor, bool walk_subquery, uchar *arg) { List_iterator_fast<Item_field> it(fields); Item *item; @@ -5013,7 +5013,7 @@ bool Item_equal::walk(Item_processor processor, bool walk_subquery, byte *arg) return Item_func::walk(processor, walk_subquery, arg); } -Item *Item_equal::transform(Item_transformer transformer, byte *arg) +Item *Item_equal::transform(Item_transformer transformer, uchar *arg) { DBUG_ASSERT(!current_thd->is_stmt_prepare()); diff --git a/sql/item_cmpfunc.h b/sql/item_cmpfunc.h index 8db962a4e2c..60f2ac6321d 100644 --- a/sql/item_cmpfunc.h +++ b/sql/item_cmpfunc.h @@ -355,8 +355,8 @@ public: } Item *neg_transformer(THD *thd); virtual Item *negated_item(); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} - bool subst_argument_checker(byte **arg) { return TRUE; } + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} + bool subst_argument_checker(uchar **arg) { return TRUE; } }; class Item_func_not :public Item_bool_func @@ -367,7 +367,7 @@ public: enum Functype functype() const { return NOT_FUNC; } const char *func_name() const { return "not"; } Item *neg_transformer(THD *thd); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} void print(String *str); }; @@ -572,7 +572,7 @@ public: return this; } bool eq(const Item *item, bool binary_cmp) const; - bool subst_argument_checker(byte **arg) { return TRUE; } + bool subst_argument_checker(uchar **arg) { return TRUE; } }; @@ -598,7 +598,7 @@ public: bool is_bool_func() { return 1; } CHARSET_INFO *compare_collation() { return cmp_collation.collation; } uint decimal_precision() const { return 1; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -610,7 +610,7 @@ public: optimize_type select_optimize() const { return OPTIMIZE_NONE; } const char *func_name() const { return "strcmp"; } void print(String *str) { Item_func::print(str); } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -673,7 +673,7 @@ public: const char *func_name() const { return "ifnull"; } Field *tmp_table_field(TABLE *table); uint decimal_precision() const; - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -714,7 +714,7 @@ public: void print(String *str) { Item_func::print(str); } table_map not_null_tables() const { return 0; } bool is_null(); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; /* Functions to handle the optimized IN */ @@ -739,7 +739,7 @@ public: count(elements), used_count(elements) {} virtual ~in_vector() {} virtual void set(uint pos,Item *item)=0; - virtual byte *get_value(Item *item)=0; + virtual uchar *get_value(Item *item)=0; void sort() { qsort2(base,used_count,size,compare,collation); @@ -782,7 +782,7 @@ public: in_string(uint elements,qsort2_cmp cmp_func, CHARSET_INFO *cs); ~in_string(); void set(uint pos,Item *item); - byte *get_value(Item *item); + uchar *get_value(Item *item); Item* create_item() { return new Item_string(collation); @@ -812,7 +812,7 @@ protected: public: in_longlong(uint elements); void set(uint pos,Item *item); - byte *get_value(Item *item); + uchar *get_value(Item *item); Item* create_item() { @@ -853,7 +853,7 @@ public: :in_longlong(elements), thd(current_thd), warn_item(warn_item_arg), lval_cache(0) {}; void set(uint pos,Item *item); - byte *get_value(Item *item); + uchar *get_value(Item *item); friend int cmp_longlong(void *cmp_arg, packed_longlong *a,packed_longlong *b); }; @@ -863,7 +863,7 @@ class in_double :public in_vector public: in_double(uint elements); void set(uint pos,Item *item); - byte *get_value(Item *item); + uchar *get_value(Item *item); Item *create_item() { return new Item_float(0.0); @@ -882,7 +882,7 @@ class in_decimal :public in_vector public: in_decimal(uint elements); void set(uint pos, Item *item); - byte *get_value(Item *item); + uchar *get_value(Item *item); Item *create_item() { return new Item_decimal(0, FALSE); @@ -1141,7 +1141,7 @@ public: void print(String *str); Item *find_item(String *str); CHARSET_INFO *compare_collation() { return cmp_collation.collation; } - bool check_partition_func_processor(byte *bool_arg) { return FALSE;} + bool check_partition_func_processor(uchar *bool_arg) { return FALSE;} void cleanup() { uint i; @@ -1222,7 +1222,7 @@ public: bool nulls_in_row(); bool is_bool_func() { return 1; } CHARSET_INFO *compare_collation() { return cmp_collation.collation; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class cmp_item_row :public cmp_item @@ -1249,9 +1249,9 @@ public: in_row(uint elements, Item *); ~in_row(); void set(uint pos,Item *item); - byte *get_value(Item *item); + uchar *get_value(Item *item); friend void Item_func_in::fix_length_and_dec(); - Item_result result_type() { return ROW_RESULT; }; + Item_result result_type() { return ROW_RESULT; } }; /* Functions used by where clause */ @@ -1294,7 +1294,7 @@ public: optimize_type select_optimize() const { return OPTIMIZE_NULL; } Item *neg_transformer(THD *thd); CHARSET_INFO *compare_collation() { return args[0]->collation.collation; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; /* Functions used by HAVING for rewriting IN subquery */ @@ -1321,7 +1321,7 @@ public: */ table_map used_tables() const { return used_tables_cache | RAND_TABLE_BIT; } - bool check_partition_func_processor(byte *int_arg) {return TRUE;} + bool check_partition_func_processor(uchar *int_arg) {return TRUE;} }; @@ -1344,7 +1344,7 @@ public: void print(String *str); CHARSET_INFO *compare_collation() { return args[0]->collation.collation; } void top_level_item() { abort_on_null=1; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -1383,7 +1383,7 @@ public: const char *func_name() const { return "like"; } bool fix_fields(THD *thd, Item **ref); void cleanup(); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; #ifdef USE_REGEX @@ -1406,7 +1406,7 @@ public: const char *func_name() const { return "regexp"; } void print(String *str) { print_op(str); } CHARSET_INFO *compare_collation() { return cmp_collation.collation; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; #else @@ -1459,14 +1459,14 @@ public: COND **conds); void top_level_item() { abort_on_null=1; } void copy_andor_arguments(THD *thd, Item_cond *item); - bool walk(Item_processor processor, bool walk_subquery, byte *arg); - Item *transform(Item_transformer transformer, byte *arg); + bool walk(Item_processor processor, bool walk_subquery, uchar *arg); + Item *transform(Item_transformer transformer, uchar *arg); void traverse_cond(Cond_traverser, void *arg, traverse_order order); void neg_arguments(THD *thd); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} - bool subst_argument_checker(byte **arg) { return TRUE; } - Item *compile(Item_analyzer analyzer, byte **arg_p, - Item_transformer transformer, byte *arg_t); + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} + bool subst_argument_checker(uchar **arg) { return TRUE; } + Item *compile(Item_analyzer analyzer, uchar **arg_p, + Item_transformer transformer, uchar *arg_t); }; @@ -1575,8 +1575,8 @@ public: void fix_length_and_dec(); bool fix_fields(THD *thd, Item **ref); void update_used_tables(); - bool walk(Item_processor processor, bool walk_subquery, byte *arg); - Item *transform(Item_transformer transformer, byte *arg); + bool walk(Item_processor processor, bool walk_subquery, uchar *arg); + Item *transform(Item_transformer transformer, uchar *arg); void print(String *str); CHARSET_INFO *compare_collation() { return fields.head()->collation.collation; } diff --git a/sql/item_create.cc b/sql/item_create.cc index 62f44996f4b..19a7a8b6d3f 100644 --- a/sql/item_create.cc +++ b/sql/item_create.cc @@ -2141,6 +2141,19 @@ protected: }; +class Create_func_uuid_short : public Create_func_arg0 +{ +public: + virtual Item *create(THD *thd); + + static Create_func_uuid_short s_singleton; + +protected: + Create_func_uuid_short() {} + virtual ~Create_func_uuid_short() {} +}; + + class Create_func_version : public Create_func_arg0 { public: @@ -4533,6 +4546,16 @@ Create_func_uuid::create(THD *thd) } +Create_func_uuid_short Create_func_uuid_short::s_singleton; + +Item* +Create_func_uuid_short::create(THD *thd) +{ + thd->lex->binlog_row_based_if_mixed= TRUE; + return new (thd->mem_root) Item_func_uuid_short(); +} + + Create_func_version Create_func_version::s_singleton; Item* @@ -4872,6 +4895,7 @@ static Native_func_registry func_array[] = { { C_STRING_WITH_LEN("UPDATEXML") }, BUILDER(Create_func_xml_update)}, { { C_STRING_WITH_LEN("UPPER") }, BUILDER(Create_func_ucase)}, { { C_STRING_WITH_LEN("UUID") }, BUILDER(Create_func_uuid)}, + { { C_STRING_WITH_LEN("UUID_SHORT") }, BUILDER(Create_func_uuid_short)}, { { C_STRING_WITH_LEN("VERSION") }, BUILDER(Create_func_version)}, { { C_STRING_WITH_LEN("WEEKDAY") }, BUILDER(Create_func_weekday)}, { { C_STRING_WITH_LEN("WEEKOFYEAR") }, BUILDER(Create_func_weekofyear)}, @@ -4885,12 +4909,13 @@ static Native_func_registry func_array[] = static HASH native_functions_hash; -extern "C" byte* -get_native_fct_hash_key(const byte *buff, uint *length, my_bool /* unused */) +extern "C" uchar* +get_native_fct_hash_key(const uchar *buff, size_t *length, + my_bool /* unused */) { Native_func_registry *func= (Native_func_registry*) buff; *length= func->name.length; - return (byte*) func->name.str; + return (uchar*) func->name.str; } /* @@ -4917,7 +4942,7 @@ int item_create_init() for (func= func_array; func->builder != NULL; func++) { - if (my_hash_insert(& native_functions_hash, (byte*) func)) + if (my_hash_insert(& native_functions_hash, (uchar*) func)) DBUG_RETURN(1); } @@ -4925,8 +4950,8 @@ int item_create_init() for (uint i=0 ; i < native_functions_hash.records ; i++) { func= (Native_func_registry*) hash_element(& native_functions_hash, i); - DBUG_PRINT("info", ("native function %s, length %d", - func->name.str, func->name.length)); + DBUG_PRINT("info", ("native function: %s length: %u", + func->name.str, (uint) func->name.length)); } #endif @@ -4954,7 +4979,7 @@ find_native_function_builder(THD *thd, LEX_STRING name) /* Thread safe */ func= (Native_func_registry*) hash_search(& native_functions_hash, - (byte*) name.str, + (uchar*) name.str, name.length); if (func) diff --git a/sql/item_func.cc b/sql/item_func.cc index 51a3edf1e0d..27500b259e0 100644 --- a/sql/item_func.cc +++ b/sql/item_func.cc @@ -142,7 +142,7 @@ Item_func::fix_fields(THD *thd, Item **ref) DBUG_ASSERT(fixed == 0); Item **arg,**arg_end; #ifndef EMBEDDED_LIBRARY // Avoid compiler warning - char buff[STACK_BUFF_ALLOC]; // Max argument in function + uchar buff[STACK_BUFF_ALLOC]; // Max argument in function #endif used_tables_cache= not_null_tables_cache= 0; @@ -195,7 +195,7 @@ Item_func::fix_fields(THD *thd, Item **ref) bool Item_func::walk(Item_processor processor, bool walk_subquery, - byte *argument) + uchar *argument) { if (arg_count) { @@ -258,7 +258,7 @@ void Item_func::traverse_cond(Cond_traverser traverser, Item returned as the result of transformation of the root node */ -Item *Item_func::transform(Item_transformer transformer, byte *argument) +Item *Item_func::transform(Item_transformer transformer, uchar *argument) { DBUG_ASSERT(!current_thd->is_stmt_prepare()); @@ -311,8 +311,8 @@ Item *Item_func::transform(Item_transformer transformer, byte *argument) Item returned as the result of transformation of the root node */ -Item *Item_func::compile(Item_analyzer analyzer, byte **arg_p, - Item_transformer transformer, byte *arg_t) +Item *Item_func::compile(Item_analyzer analyzer, uchar **arg_p, + Item_transformer transformer, uchar *arg_t) { if (!(this->*analyzer)(arg_p)) return 0; @@ -325,7 +325,7 @@ Item *Item_func::compile(Item_analyzer analyzer, byte **arg_p, The same parameter value of arg_p must be passed to analyze any argument of the condition formula. */ - byte *arg_v= *arg_p; + uchar *arg_v= *arg_p; Item *new_item= (*arg)->compile(analyzer, &arg_v, transformer, arg_t); if (new_item && *arg != new_item) current_thd->change_item_tree(arg, new_item); @@ -465,7 +465,7 @@ Field *Item_func::tmp_table_field(TABLE *table) } -bool Item_func::is_expensive_processor(byte *arg) +bool Item_func::is_expensive_processor(uchar *arg) { return is_expensive(); } @@ -2801,7 +2801,7 @@ udf_handler::fix_fields(THD *thd, Item_result_field *func, uint arg_count, Item **arguments) { #ifndef EMBEDDED_LIBRARY // Avoid compiler warning - char buff[STACK_BUFF_ALLOC]; // Max argument in function + uchar buff[STACK_BUFF_ALLOC]; // Max argument in function #endif DBUG_ENTER("Item_udf_func::fix_fields"); @@ -3239,8 +3239,8 @@ static HASH hash_user_locks; class User_level_lock { - char *key; - uint key_length; + uchar *key; + size_t key_length; public: int count; @@ -3249,16 +3249,16 @@ public: my_thread_id thread_id; void set_thread(THD *thd) { thread_id= thd->thread_id; } - User_level_lock(const char *key_arg,uint length, ulong id) + User_level_lock(const uchar *key_arg,uint length, ulong id) :key_length(length),count(1),locked(1), thread_id(id) { - key=(char*) my_memdup((byte*) key_arg,length,MYF(0)); + key= (uchar*) my_memdup(key_arg,length,MYF(0)); pthread_cond_init(&cond,NULL); if (key) { - if (my_hash_insert(&hash_user_locks,(byte*) this)) + if (my_hash_insert(&hash_user_locks,(uchar*) this)) { - my_free((gptr) key,MYF(0)); + my_free(key,MYF(0)); key=0; } } @@ -3267,22 +3267,22 @@ public: { if (key) { - hash_delete(&hash_user_locks,(byte*) this); - my_free((gptr) key,MYF(0)); + hash_delete(&hash_user_locks,(uchar*) this); + my_free(key, MYF(0)); } pthread_cond_destroy(&cond); } inline bool initialized() { return key != 0; } friend void item_user_lock_release(User_level_lock *ull); - friend char *ull_get_key(const User_level_lock *ull, uint *length, - my_bool not_used); + friend uchar *ull_get_key(const User_level_lock *ull, size_t *length, + my_bool not_used); }; -char *ull_get_key(const User_level_lock *ull, uint *length, - my_bool not_used __attribute__((unused))) +uchar *ull_get_key(const User_level_lock *ull, size_t *length, + my_bool not_used __attribute__((unused))) { - *length=(uint) ull->key_length; - return (char*) ull->key; + *length= ull->key_length; + return ull->key; } @@ -3352,8 +3352,8 @@ void debug_sync_point(const char* lock_name, uint lock_timeout) THD* thd=current_thd; User_level_lock* ull; struct timespec abstime; - int lock_name_len; - lock_name_len=strlen(lock_name); + size_t lock_name_len; + lock_name_len= strlen(lock_name); pthread_mutex_lock(&LOCK_user_locks); if (thd->ull) @@ -3368,8 +3368,9 @@ void debug_sync_point(const char* lock_name, uint lock_timeout) this case, we will not be waiting, but rather, just waste CPU and memory on the whole deal */ - if (!(ull= ((User_level_lock*) hash_search(&hash_user_locks, lock_name, - lock_name_len)))) + if (!(ull= ((User_level_lock*) hash_search(&hash_user_locks, + (uchar*) lock_name, + lock_name_len)))) { pthread_mutex_unlock(&LOCK_user_locks); return; @@ -3464,10 +3465,11 @@ longlong Item_func_get_lock::val_int() } if (!(ull= ((User_level_lock *) hash_search(&hash_user_locks, - (byte*) res->ptr(), - res->length())))) + (uchar*) res->ptr(), + (size_t) res->length())))) { - ull=new User_level_lock(res->ptr(),res->length(), thd->thread_id); + ull= new User_level_lock((uchar*) res->ptr(), (size_t) res->length(), + thd->thread_id); if (!ull || !ull->initialized()) { delete ull; @@ -3557,8 +3559,8 @@ longlong Item_func_release_lock::val_int() result=0; pthread_mutex_lock(&LOCK_user_locks); if (!(ull= ((User_level_lock*) hash_search(&hash_user_locks, - (const byte*) res->ptr(), - res->length())))) + (const uchar*) res->ptr(), + (size_t) res->length())))) { null_value=1; } @@ -3703,7 +3705,7 @@ static user_var_entry *get_variable(HASH *hash, LEX_STRING &name, { user_var_entry *entry; - if (!(entry = (user_var_entry*) hash_search(hash, (byte*) name.str, + if (!(entry = (user_var_entry*) hash_search(hash, (uchar*) name.str, name.length)) && create_if_not_exists) { @@ -3733,7 +3735,7 @@ static user_var_entry *get_variable(HASH *hash, LEX_STRING &name, entry->used_query_id=current_thd->query_id; entry->type=STRING_RESULT; memcpy(entry->name.str, name.str, name.length+1); - if (my_hash_insert(hash,(byte*) entry)) + if (my_hash_insert(hash,(uchar*) entry)) { my_free((char*) entry,MYF(0)); return 0; @@ -4480,7 +4482,7 @@ int get_var_with_binlog(THD *thd, enum_sql_command sql_command, } /* Mark that this variable has been used by this query */ var_entry->used_query_id= thd->query_id; - if (insert_dynamic(&thd->user_var_events, (gptr) &user_var_event)) + if (insert_dynamic(&thd->user_var_events, (uchar*) &user_var_event)) goto err; *out_entry= var_entry; @@ -4992,7 +4994,7 @@ double Item_func_match::val_real() if ((null_value= (a == 0)) || !a->length()) DBUG_RETURN(0); DBUG_RETURN(ft_handler->please->find_relevance(ft_handler, - (byte *)a->ptr(), a->length())); + (uchar *)a->ptr(), a->length())); } DBUG_RETURN(ft_handler->please->find_relevance(ft_handler, table->record[0], 0)); @@ -5107,8 +5109,8 @@ longlong Item_func_is_free_lock::val_int() } pthread_mutex_lock(&LOCK_user_locks); - ull= (User_level_lock *) hash_search(&hash_user_locks, (byte*) res->ptr(), - res->length()); + ull= (User_level_lock *) hash_search(&hash_user_locks, (uchar*) res->ptr(), + (size_t) res->length()); pthread_mutex_unlock(&LOCK_user_locks); if (!ull || !ull->locked) return 1; @@ -5126,8 +5128,8 @@ longlong Item_func_is_used_lock::val_int() return 0; pthread_mutex_lock(&LOCK_user_locks); - ull= (User_level_lock *) hash_search(&hash_user_locks, (byte*) res->ptr(), - res->length()); + ull= (User_level_lock *) hash_search(&hash_user_locks, (uchar*) res->ptr(), + (size_t) res->length()); pthread_mutex_unlock(&LOCK_user_locks); if (!ull || !ull->locked) return 0; @@ -5225,14 +5227,13 @@ Item_func_sp::func_name() const @retval TRUE is returned on an error @retval FALSE is returned on success. */ + bool Item_func_sp::init_result_field(THD *thd) { - DBUG_ENTER("Item_func_sp::init_result_field"); - LEX_STRING empty_name= { C_STRING_WITH_LEN("") }; - TABLE_SHARE *share; + DBUG_ENTER("Item_func_sp::init_result_field"); DBUG_ASSERT(m_sp == NULL); DBUG_ASSERT(sp_result_field == NULL); @@ -5259,30 +5260,34 @@ Item_func_sp::init_result_field(THD *thd) share->table_cache_key = empty_name; share->table_name = empty_name; - if (!(sp_result_field= m_sp->create_result_field(max_length, name, dummy_table))) + if (!(sp_result_field= m_sp->create_result_field(max_length, name, + dummy_table))) { DBUG_RETURN(TRUE); } if (sp_result_field->pack_length() > sizeof(result_buf)) { - sp_result_field->move_field(sql_alloc(sp_result_field->pack_length())); - } else { - sp_result_field->move_field(result_buf); + void *tmp; + if (!(tmp= sql_alloc(sp_result_field->pack_length()))) + DBUG_RETURN(TRUE); + sp_result_field->move_field((uchar*) tmp); } + else + sp_result_field->move_field(result_buf); sp_result_field->null_ptr= (uchar *) &null_value; sp_result_field->null_bit= 1; - - DBUG_RETURN(FALSE); } + /** @brief Initialize local members with values from the Field interface. @note called from Item::fix_fields. */ + void Item_func_sp::fix_length_and_dec() { DBUG_ENTER("Item_func_sp::fix_length_and_dec"); @@ -5297,6 +5302,7 @@ void Item_func_sp::fix_length_and_dec() DBUG_VOID_RETURN; } + /** @brief Execute function & store value in field. @@ -5310,12 +5316,6 @@ Item_func_sp::execute() { THD *thd= current_thd; - /* - Get field in virtual tmp table to store result. Create the field if - invoked first time. - */ - - /* Execute function and store the return value in the field. */ if (execute_impl(thd)) @@ -5515,3 +5515,40 @@ Item_func_sp::fix_fields(THD *thd, Item **ref) } DBUG_RETURN(res); } + + +/* + uuid_short handling. + + The short uuid is defined as a longlong that contains the following bytes: + + Bytes Comment + 1 Server_id & 255 + 4 Startup time of server in seconds + 3 Incrementor + + This means that an uuid is guaranteed to be unique + even in a replication environment if the following holds: + + - The last byte of the server id is unique + - If you between two shutdown of the server don't get more than + an average of 2^24 = 16M calls to uuid_short() per second. +*/ + +ulonglong uuid_value; + +void uuid_short_init() +{ + uuid_value= ((((ulonglong) server_id) << 56) + + (((ulonglong) server_start_time) << 24)); +} + + +longlong Item_func_uuid_short::val_int() +{ + ulonglong val; + pthread_mutex_lock(&LOCK_uuid_generator); + val= uuid_value++; + pthread_mutex_unlock(&LOCK_uuid_generator); + return (longlong) val; +} diff --git a/sql/item_func.h b/sql/item_func.h index 51ffe2133c9..60205170166 100644 --- a/sql/item_func.h +++ b/sql/item_func.h @@ -184,13 +184,13 @@ public: { return agg_item_charsets(c, func_name(), items, nitems, flags, item_sep); } - bool walk(Item_processor processor, bool walk_subquery, byte *arg); - Item *transform(Item_transformer transformer, byte *arg); - Item* compile(Item_analyzer analyzer, byte **arg_p, - Item_transformer transformer, byte *arg_t); + bool walk(Item_processor processor, bool walk_subquery, uchar *arg); + Item *transform(Item_transformer transformer, uchar *arg); + Item* compile(Item_analyzer analyzer, uchar **arg_p, + Item_transformer transformer, uchar *arg_t); void traverse_cond(Cond_traverser traverser, void * arg, traverse_order order); - bool is_expensive_processor(byte *arg); + bool is_expensive_processor(uchar *arg); virtual bool is_expensive() { return 0; } }; @@ -253,7 +253,7 @@ public: void fix_num_length_and_dec(); void find_num_type(); String *str_op(String *str) { DBUG_ASSERT(0); return 0; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -266,7 +266,7 @@ class Item_num_op :public Item_func_numhybrid void print(String *str) { print_op(str); } void find_num_type(); String *str_op(String *str) { DBUG_ASSERT(0); return 0; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -311,7 +311,7 @@ public: { max_length=args[0]->max_length; unsigned_flag=0; } void print(String *str); uint decimal_precision() const { return args[0]->decimal_precision(); } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -345,7 +345,7 @@ public: void fix_length_and_dec() {}; const char *func_name() const { return "decimal_typecast"; } void print(String *); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -414,7 +414,7 @@ public: const char *func_name() const { return "DIV"; } void fix_length_and_dec(); void print(String *str) { print_op(str); } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -488,7 +488,7 @@ public: Item_func_exp(Item *a) :Item_dec_func(a) {} double val_real(); const char *func_name() const { return "exp"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -498,7 +498,7 @@ public: Item_func_ln(Item *a) :Item_dec_func(a) {} double val_real(); const char *func_name() const { return "ln"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -509,7 +509,7 @@ public: Item_func_log(Item *a,Item *b) :Item_dec_func(a,b) {} double val_real(); const char *func_name() const { return "log"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -519,7 +519,7 @@ public: Item_func_log2(Item *a) :Item_dec_func(a) {} double val_real(); const char *func_name() const { return "log2"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -529,7 +529,7 @@ public: Item_func_log10(Item *a) :Item_dec_func(a) {} double val_real(); const char *func_name() const { return "log10"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -539,7 +539,7 @@ public: Item_func_sqrt(Item *a) :Item_dec_func(a) {} double val_real(); const char *func_name() const { return "sqrt"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -549,7 +549,7 @@ public: Item_func_pow(Item *a,Item *b) :Item_dec_func(a,b) {} double val_real(); const char *func_name() const { return "pow"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -559,7 +559,7 @@ public: Item_func_acos(Item *a) :Item_dec_func(a) {} double val_real(); const char *func_name() const { return "acos"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class Item_func_asin :public Item_dec_func @@ -568,7 +568,7 @@ public: Item_func_asin(Item *a) :Item_dec_func(a) {} double val_real(); const char *func_name() const { return "asin"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class Item_func_atan :public Item_dec_func @@ -578,7 +578,7 @@ public: Item_func_atan(Item *a,Item *b) :Item_dec_func(a,b) {} double val_real(); const char *func_name() const { return "atan"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class Item_func_cos :public Item_dec_func @@ -587,7 +587,7 @@ public: Item_func_cos(Item *a) :Item_dec_func(a) {} double val_real(); const char *func_name() const { return "cos"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class Item_func_sin :public Item_dec_func @@ -596,7 +596,7 @@ public: Item_func_sin(Item *a) :Item_dec_func(a) {} double val_real(); const char *func_name() const { return "sin"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class Item_func_tan :public Item_dec_func @@ -605,7 +605,7 @@ public: Item_func_tan(Item *a) :Item_dec_func(a) {} double val_real(); const char *func_name() const { return "tan"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class Item_func_integer :public Item_int_func @@ -684,7 +684,7 @@ public: Item_func_sign(Item *a) :Item_int_func(a) {} const char *func_name() const { return "sign"; } longlong val_int(); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -699,7 +699,7 @@ public: const char *func_name() const { return name; } void fix_length_and_dec() { decimals= NOT_FIXED_DEC; max_length= float_length(decimals); } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -725,7 +725,7 @@ public: void fix_length_and_dec(); enum Item_result result_type () const { return cmp_type; } bool result_as_longlong() { return compare_as_dates; }; - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} uint cmp_datetimes(ulonglong *value); }; @@ -781,7 +781,7 @@ public: longlong val_int(); const char *func_name() const { return "length"; } void fix_length_and_dec() { max_length=10; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class Item_func_bit_length :public Item_func_length @@ -801,7 +801,7 @@ public: longlong val_int(); const char *func_name() const { return "char_length"; } void fix_length_and_dec() { max_length=10; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class Item_func_coercibility :public Item_int_func @@ -825,7 +825,7 @@ public: longlong val_int(); void fix_length_and_dec(); void print(String *str); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -850,7 +850,7 @@ public: longlong val_int(); const char *func_name() const { return "ascii"; } void fix_length_and_dec() { max_length=3; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class Item_func_ord :public Item_int_func @@ -860,7 +860,7 @@ public: Item_func_ord(Item *a) :Item_int_func(a) {} longlong val_int(); const char *func_name() const { return "ord"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class Item_func_find_in_set :public Item_int_func @@ -874,7 +874,7 @@ public: longlong val_int(); const char *func_name() const { return "find_in_set"; } void fix_length_and_dec(); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; /* Base class for all bit functions: '~', '|', '^', '&', '>>', '<<' */ @@ -886,7 +886,7 @@ public: Item_func_bit(Item *a) :Item_int_func(a) {} void fix_length_and_dec() { unsigned_flag= 1; } void print(String *str) { print_op(str); } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class Item_func_bit_or :public Item_func_bit @@ -912,7 +912,7 @@ public: longlong val_int(); const char *func_name() const { return "bit_count"; } void fix_length_and_dec() { max_length=2; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class Item_func_shift_left :public Item_func_bit @@ -1352,7 +1352,7 @@ public: longlong val_int(); const char *func_name() const { return "inet_aton"; } void fix_length_and_dec() { decimals= 0; max_length= 21; maybe_null= 1; unsigned_flag= 1;} - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -1465,7 +1465,7 @@ private: sp_name *m_name; mutable sp_head *m_sp; TABLE *dummy_table; - char result_buf[64]; + uchar result_buf[64]; /* The result field of the concrete stored function. */ @@ -1539,7 +1539,7 @@ public: return str; } - virtual bool change_context_processor(byte *cntx) + virtual bool change_context_processor(uchar *cntx) { context= (Name_resolution_context *)cntx; return FALSE; } bool sp_check_access(THD * thd); @@ -1559,3 +1559,18 @@ public: const char *func_name() const { return "found_rows"; } void fix_length_and_dec() { decimals= 0; maybe_null=0; } }; + + +void uuid_short_init(); + +class Item_func_uuid_short :public Item_int_func +{ +public: + Item_func_uuid_short() :Item_int_func() {} + const char *func_name() const { return "uuid_short"; } + longlong val_int(); + void fix_length_and_dec() + { max_length= 21; unsigned_flag=1; } + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} +}; + diff --git a/sql/item_row.cc b/sql/item_row.cc index 956556ca783..d1d1011ab2b 100644 --- a/sql/item_row.cc +++ b/sql/item_row.cc @@ -142,7 +142,7 @@ void Item_row::print(String *str) } -bool Item_row::walk(Item_processor processor, bool walk_subquery, byte *arg) +bool Item_row::walk(Item_processor processor, bool walk_subquery, uchar *arg) { for (uint i= 0; i < arg_count; i++) { @@ -153,7 +153,7 @@ bool Item_row::walk(Item_processor processor, bool walk_subquery, byte *arg) } -Item *Item_row::transform(Item_transformer transformer, byte *arg) +Item *Item_row::transform(Item_transformer transformer, uchar *arg) { DBUG_ASSERT(!current_thd->is_stmt_prepare()); diff --git a/sql/item_row.h b/sql/item_row.h index d55d3ae223f..dd7436888f0 100644 --- a/sql/item_row.h +++ b/sql/item_row.h @@ -67,8 +67,8 @@ public: void update_used_tables(); void print(String *str); - bool walk(Item_processor processor, bool walk_subquery, byte *arg); - Item *transform(Item_transformer transformer, byte *arg); + bool walk(Item_processor processor, bool walk_subquery, uchar *arg); + Item *transform(Item_transformer transformer, uchar *arg); uint cols() { return arg_count; } Item* element_index(uint i) { return items[i]; } diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc index a1fd79cbfb0..f9ca53a8355 100644 --- a/sql/item_strfunc.cc +++ b/sql/item_strfunc.cc @@ -28,6 +28,7 @@ #include "md5.h" #include "sha1.h" #include "my_aes.h" +#include <zlib.h> C_MODE_START #include "../mysys/my_static.h" // For soundex_map C_MODE_END @@ -2220,7 +2221,7 @@ String *Item_func_make_set::val_str(String *str) } -Item *Item_func_make_set::transform(Item_transformer transformer, byte *arg) +Item *Item_func_make_set::transform(Item_transformer transformer, uchar *arg) { DBUG_ASSERT(!current_thd->is_stmt_prepare()); @@ -2903,7 +2904,7 @@ String *Item_load_file::val_str(String *str) goto err; if ((file = my_open(file_name->c_ptr(), O_RDONLY, MYF(0))) < 0) goto err; - if (my_read(file, (byte*) tmp_value.ptr(), stat_info.st_size, MYF(MY_NABP))) + if (my_read(file, (uchar*) tmp_value.ptr(), stat_info.st_size, MYF(MY_NABP))) { my_close(file, MYF(0)); goto err; diff --git a/sql/item_strfunc.h b/sql/item_strfunc.h index 60e7de42a9d..c036ec490db 100644 --- a/sql/item_strfunc.h +++ b/sql/item_strfunc.h @@ -50,7 +50,7 @@ public: String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "md5"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -94,7 +94,7 @@ public: String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "concat"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class Item_func_concat_ws :public Item_str_func @@ -116,7 +116,7 @@ public: String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "reverse"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -148,13 +148,13 @@ class Item_str_conv :public Item_str_func { protected: uint multiply; - uint (*converter)(CHARSET_INFO *cs, char *src, uint srclen, - char *dst, uint dstlen); + size_t (*converter)(CHARSET_INFO *cs, char *src, size_t srclen, + char *dst, size_t dstlen); String tmp_value; public: Item_str_conv(Item *item) :Item_str_func(item) {} String *val_str(String *); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -455,7 +455,7 @@ public: String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "soundex"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -491,12 +491,12 @@ public: void update_used_tables(); const char *func_name() const { return "make_set"; } - bool walk(Item_processor processor, bool walk_subquery, byte *arg) + bool walk(Item_processor processor, bool walk_subquery, uchar *arg) { return item->walk(processor, walk_subquery, arg) || Item_str_func::walk(processor, walk_subquery, arg); } - Item *transform(Item_transformer transformer, byte *arg); + Item *transform(Item_transformer transformer, uchar *arg); void print(String *str); }; @@ -549,7 +549,7 @@ public: String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "rpad"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -562,7 +562,7 @@ public: String *val_str(String *); void fix_length_and_dec(); const char *func_name() const { return "lpad"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -577,7 +577,7 @@ public: collation.set(default_charset()); max_length= 64; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -594,7 +594,7 @@ public: decimals=0; max_length=args[0]->max_length*2*collation.collation->mbmaxlen; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class Item_func_unhex :public Item_str_func @@ -614,7 +614,7 @@ public: decimals=0; max_length=(1+args[0]->max_length)/2; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -638,7 +638,7 @@ public: } void print(String *str); const char *func_name() const { return "cast_as_binary"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -678,7 +678,7 @@ public: String* val_str(String* str); const char *func_name() const { return "inet_ntoa"; } void fix_length_and_dec() { decimals = 0; max_length=3*8+7; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class Item_func_quote :public Item_str_func @@ -693,7 +693,7 @@ public: collation.set(args[0]->collation); max_length= args[0]->max_length * 2 + 2; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class Item_func_conv_charset :public Item_str_func @@ -794,7 +794,7 @@ public: const char *func_name() const { return "crc32"; } void fix_length_and_dec() { max_length=10; } longlong val_int(); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class Item_func_uncompressed_length : public Item_int_func diff --git a/sql/item_subselect.cc b/sql/item_subselect.cc index ab4b4eb6796..9494d1dc2ee 100644 --- a/sql/item_subselect.cc +++ b/sql/item_subselect.cc @@ -149,7 +149,7 @@ bool Item_subselect::fix_fields(THD *thd_param, Item **ref) DBUG_ASSERT(fixed == 0); engine->set_thd((thd= thd_param)); - if (check_stack_overrun(thd, STACK_MIN_SIZE, (gptr)&res)) + if (check_stack_overrun(thd, STACK_MIN_SIZE, (uchar*)&res)) return TRUE; res= engine->prepare(); @@ -206,7 +206,7 @@ err: bool Item_subselect::walk(Item_processor processor, bool walk_subquery, - byte *argument) + uchar *argument) { if (walk_subquery) @@ -449,7 +449,7 @@ Item_singlerow_subselect::select_transformer(JOIN *join) 'upper' select is not really dependent => we remove this dependence */ substitution->walk(&Item::remove_dependence_processor, 0, - (byte *) select_lex->outer_select()); + (uchar *) select_lex->outer_select()); return RES_REDUCE; } return RES_OK; diff --git a/sql/item_subselect.h b/sql/item_subselect.h index 7c21eac6ec3..51ab7b8ad42 100644 --- a/sql/item_subselect.h +++ b/sql/item_subselect.h @@ -125,7 +125,7 @@ public: */ virtual void reset_value_registration() {} enum_parsing_place place() { return parsing_place; } - bool walk(Item_processor processor, bool walk_subquery, byte *arg); + bool walk(Item_processor processor, bool walk_subquery, uchar *arg); /** Get the SELECT_LEX structure associated with this Item. diff --git a/sql/item_sum.cc b/sql/item_sum.cc index f962d067e17..69148d81b9a 100644 --- a/sql/item_sum.cc +++ b/sql/item_sum.cc @@ -403,7 +403,7 @@ Item *Item_sum::get_tmp_table_item(THD *thd) bool Item_sum::walk (Item_processor processor, bool walk_subquery, - byte *argument) + uchar *argument) { if (arg_count) { @@ -1434,7 +1434,7 @@ my_decimal *Item_sum_variance::val_decimal(my_decimal *dec_buf) void Item_sum_variance::reset_field() { double nr; - char *res= result_field->ptr; + uchar *res= result_field->ptr; nr= args[0]->val_real(); /* sets null_value as side-effect */ @@ -1457,7 +1457,7 @@ void Item_sum_variance::reset_field() void Item_sum_variance::update_field() { ulonglong field_count; - char *res=result_field->ptr; + uchar *res=result_field->ptr; double nr= args[0]->val_real(); /* sets null_value as side-effect */ @@ -1821,7 +1821,7 @@ bool Item_sum_and::add() void Item_sum_num::reset_field() { double nr= args[0]->val_real(); - char *res=result_field->ptr; + uchar *res=result_field->ptr; if (maybe_null) { @@ -1943,7 +1943,7 @@ void Item_sum_sum::reset_field() void Item_sum_count::reset_field() { - char *res=result_field->ptr; + uchar *res=result_field->ptr; longlong nr=0; if (!args[0]->maybe_null || !args[0]->is_null()) @@ -1954,7 +1954,7 @@ void Item_sum_count::reset_field() void Item_sum_avg::reset_field() { - char *res=result_field->ptr; + uchar *res=result_field->ptr; if (hybrid_type == DECIMAL_RESULT) { longlong tmp; @@ -1995,7 +1995,7 @@ void Item_sum_bit::reset_field() void Item_sum_bit::update_field() { - char *res=result_field->ptr; + uchar *res=result_field->ptr; bits= uint8korr(res); add(); int8store(res, bits); @@ -2030,7 +2030,7 @@ void Item_sum_sum::update_field() else { double old_nr,nr; - char *res=result_field->ptr; + uchar *res=result_field->ptr; float8get(old_nr,res); nr= args[0]->val_real(); @@ -2047,7 +2047,7 @@ void Item_sum_sum::update_field() void Item_sum_count::update_field() { longlong nr; - char *res=result_field->ptr; + uchar *res=result_field->ptr; nr=sint8korr(res); if (!args[0]->maybe_null || !args[0]->is_null()) @@ -2059,7 +2059,7 @@ void Item_sum_count::update_field() void Item_sum_avg::update_field() { longlong field_count; - char *res=result_field->ptr; + uchar *res=result_field->ptr; if (hybrid_type == DECIMAL_RESULT) { my_decimal value, *arg_val= args[0]->val_decimal(&value); @@ -2228,7 +2228,7 @@ double Item_avg_field::val_real() // fix_fields() never calls for this Item double nr; longlong count; - char *res; + uchar *res; if (hybrid_type == DECIMAL_RESULT) return val_real_from_decimal(); @@ -2361,10 +2361,10 @@ double Item_variance_field::val_real() ** COUNT(DISTINCT ...) ****************************************************************************/ -int simple_str_key_cmp(void* arg, byte* key1, byte* key2) +int simple_str_key_cmp(void* arg, uchar* key1, uchar* key2) { Field *f= (Field*) arg; - return f->cmp((const char*)key1, (const char*)key2); + return f->cmp(key1, key2); } /* @@ -2374,7 +2374,7 @@ int simple_str_key_cmp(void* arg, byte* key1, byte* key2) static */ -int composite_key_cmp(void* arg, byte* key1, byte* key2) +int composite_key_cmp(void* arg, uchar* key1, uchar* key2) { Item_sum_count_distinct* item = (Item_sum_count_distinct*)arg; Field **field = item->table->field; @@ -2384,7 +2384,7 @@ int composite_key_cmp(void* arg, byte* key1, byte* key2) { Field* f = *field; int len = *lengths++; - int res = f->cmp((char *) key1, (char *) key2); + int res = f->cmp(key1, key2); if (res) return res; key1 += len; @@ -2839,8 +2839,8 @@ String *Item_sum_udf_str::val_str(String *str) GROUP_CONCAT(DISTINCT expr,...) */ -int group_concat_key_cmp_with_distinct(void* arg, byte* key1, - byte* key2) +int group_concat_key_cmp_with_distinct(void* arg, uchar* key1, + uchar* key2) { Item_func_group_concat* grp_item= (Item_func_group_concat*)arg; TABLE *table= grp_item->table; @@ -2865,7 +2865,7 @@ int group_concat_key_cmp_with_distinct(void* arg, byte* key1, int res; uint offset= (field->offset(field->table->record[0]) - table->s->null_bytes); - if ((res= field->cmp((char *) key1 + offset, (char *) key2 + offset))) + if ((res= field->cmp(key1 + offset, key2 + offset))) return res; } } @@ -2878,7 +2878,7 @@ int group_concat_key_cmp_with_distinct(void* arg, byte* key1, GROUP_CONCAT(expr,... ORDER BY col,... ) */ -int group_concat_key_cmp_with_order(void* arg, byte* key1, byte* key2) +int group_concat_key_cmp_with_order(void* arg, uchar* key1, uchar* key2) { Item_func_group_concat* grp_item= (Item_func_group_concat*) arg; ORDER **order_item, **end; @@ -2904,7 +2904,7 @@ int group_concat_key_cmp_with_order(void* arg, byte* key1, byte* key2) int res; uint offset= (field->offset(field->table->record[0]) - table->s->null_bytes); - if ((res= field->cmp((char *) key1 + offset, (char *) key2 + offset))) + if ((res= field->cmp(key1 + offset, key2 + offset))) return (*order_item)->asc ? res : -res; } } @@ -2927,8 +2927,8 @@ int group_concat_key_cmp_with_order(void* arg, byte* key1, byte* key2) the duplicated values when inserting things sorted by ORDER BY */ -int group_concat_key_cmp_with_distinct_and_order(void* arg,byte* key1, - byte* key2) +int group_concat_key_cmp_with_distinct_and_order(void* arg,uchar* key1, + uchar* key2) { if (!group_concat_key_cmp_with_distinct(arg,key1,key2)) return 0; @@ -2940,7 +2940,7 @@ int group_concat_key_cmp_with_distinct_and_order(void* arg,byte* key1, Append data from current leaf to item->result */ -int dump_leaf_key(byte* key, element_count count __attribute__((unused)), +int dump_leaf_key(uchar* key, element_count count __attribute__((unused)), Item_func_group_concat *item) { TABLE *table= item->table; @@ -2974,7 +2974,7 @@ int dump_leaf_key(byte* key, element_count count __attribute__((unused)), uint offset= (field->offset(field->table->record[0]) - table->s->null_bytes); DBUG_ASSERT(offset < table->s->reclength); - res= field->val_str(&tmp, (char *) key + offset); + res= field->val_str(&tmp, key + offset); } else res= (*arg)->val_str(&tmp); diff --git a/sql/item_sum.h b/sql/item_sum.h index 5cf4f93af0e..84b425755d1 100644 --- a/sql/item_sum.h +++ b/sql/item_sum.h @@ -361,7 +361,7 @@ public: Item *get_tmp_table_item(THD *thd); virtual Field *create_tmp_field(bool group, TABLE *table, uint convert_blob_length); - bool walk(Item_processor processor, bool walk_subquery, byte *argument); + bool walk(Item_processor processor, bool walk_subquery, uchar *argument); bool init_sum_func_check(THD *thd); bool check_sum_func(THD *thd, Item **ref); bool register_sum_func(THD *thd, Item **ref); @@ -587,8 +587,8 @@ class Item_sum_count_distinct :public Item_sum_int bool always_null; // Set to 1 if the result is always NULL - friend int composite_key_cmp(void* arg, byte* key1, byte* key2); - friend int simple_str_key_cmp(void* arg, byte* key1, byte* key2); + friend int composite_key_cmp(void* arg, uchar* key1, uchar* key2); + friend int simple_str_key_cmp(void* arg, uchar* key1, uchar* key2); public: Item_sum_count_distinct(List<Item> &list) @@ -1183,14 +1183,14 @@ class Item_func_group_concat : public Item_sum */ Item_func_group_concat *original; - friend int group_concat_key_cmp_with_distinct(void* arg, byte* key1, - byte* key2); - friend int group_concat_key_cmp_with_order(void* arg, byte* key1, - byte* key2); + friend int group_concat_key_cmp_with_distinct(void* arg, uchar* key1, + uchar* key2); + friend int group_concat_key_cmp_with_order(void* arg, uchar* key1, + uchar* key2); friend int group_concat_key_cmp_with_distinct_and_order(void* arg, - byte* key1, - byte* key2); - friend int dump_leaf_key(byte* key, + uchar* key1, + uchar* key2); + friend int dump_leaf_key(uchar* key, element_count count __attribute__((unused)), Item_func_group_concat *group_concat_item); @@ -1243,6 +1243,6 @@ public: Item *copy_or_same(THD* thd); void no_rows_in_result() {} void print(String *str); - virtual bool change_context_processor(byte *cntx) + virtual bool change_context_processor(uchar *cntx) { context= (Name_resolution_context *)cntx; return FALSE; } }; diff --git a/sql/item_timefunc.cc b/sql/item_timefunc.cc index 0fd57264784..3bc63eaf5f9 100644 --- a/sql/item_timefunc.cc +++ b/sql/item_timefunc.cc @@ -886,9 +886,9 @@ static bool get_interval_info(const char *str,uint length,CHARSET_INFO *cs, { i++; /* Change values[0...i-1] -> values[0...count-1] */ - bmove_upp((char*) (values+count), (char*) (values+i), + bmove_upp((uchar*) (values+count), (uchar*) (values+i), sizeof(*values)*i); - bzero((char*) values, sizeof(*values)*(count-i)); + bzero((uchar*) values, sizeof(*values)*(count-i)); break; } } @@ -1223,7 +1223,7 @@ bool get_interval_value(Item *args,interval_type int_type, ulonglong array[5]; longlong value; const char *str; - uint32 length; + size_t length; CHARSET_INFO *cs=str_value->charset(); LINT_INIT(value); @@ -1258,7 +1258,7 @@ bool get_interval_value(Item *args,interval_type int_type, interval->neg=1; str++; } - length=(uint32) (end-str); // Set up pointers to new str + length= (size_t) (end-str); // Set up pointers to new str } switch (int_type) { diff --git a/sql/item_timefunc.h b/sql/item_timefunc.h index 992b79753ca..bd0954e6bdb 100644 --- a/sql/item_timefunc.h +++ b/sql/item_timefunc.h @@ -38,7 +38,7 @@ public: { max_length=6*MY_CHARSET_BIN_MB_MAXLEN; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -53,7 +53,7 @@ public: decimals=0; max_length=6*MY_CHARSET_BIN_MB_MAXLEN; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -70,7 +70,7 @@ public: maybe_null=1; } enum_monotonicity_info get_monotonicity_info() const; - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -86,7 +86,7 @@ public: max_length=2*MY_CHARSET_BIN_MB_MAXLEN; maybe_null=1; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -111,7 +111,7 @@ public: max_length=2*MY_CHARSET_BIN_MB_MAXLEN; maybe_null=1; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -144,7 +144,7 @@ public: max_length=3*MY_CHARSET_BIN_MB_MAXLEN; maybe_null=1; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -160,7 +160,7 @@ public: max_length=2*MY_CHARSET_BIN_MB_MAXLEN; maybe_null=1; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -176,7 +176,7 @@ public: max_length=2*MY_CHARSET_BIN_MB_MAXLEN; maybe_null=1; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -192,7 +192,7 @@ public: max_length=1*MY_CHARSET_BIN_MB_MAXLEN; maybe_null=1; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -208,7 +208,7 @@ public: max_length=2*MY_CHARSET_BIN_MB_MAXLEN; maybe_null=1; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -224,7 +224,7 @@ public: max_length=2*MY_CHARSET_BIN_MB_MAXLEN; maybe_null=1; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class Item_func_yearweek :public Item_int_func @@ -239,7 +239,7 @@ public: max_length=6*MY_CHARSET_BIN_MB_MAXLEN; maybe_null=1; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -256,7 +256,7 @@ public: max_length=4*MY_CHARSET_BIN_MB_MAXLEN; maybe_null=1; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -286,7 +286,7 @@ public: max_length=1*MY_CHARSET_BIN_MB_MAXLEN; maybe_null=1; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class Item_func_dayname :public Item_func_weekday @@ -319,7 +319,7 @@ public: decimals=0; max_length=10*MY_CHARSET_BIN_MB_MAXLEN; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -334,7 +334,7 @@ public: decimals=0; max_length=10*MY_CHARSET_BIN_MB_MAXLEN; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -585,7 +585,7 @@ public: Item_func_from_days(Item *a) :Item_date(a) {} const char *func_name() const { return "from_days"; } bool get_date(MYSQL_TIME *res, uint fuzzy_date); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -603,7 +603,7 @@ public: void fix_length_and_dec(); uint format_length(const String *format); bool eq(const Item *item, bool binary_cmp) const; - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -617,7 +617,7 @@ class Item_func_from_unixtime :public Item_date_func const char *func_name() const { return "from_unixtime"; } void fix_length_and_dec(); bool get_date(MYSQL_TIME *res, uint fuzzy_date); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -676,7 +676,7 @@ public: } const char *func_name() const { return "sec_to_time"; } bool result_as_longlong() { return TRUE; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -698,7 +698,7 @@ public: bool get_date(MYSQL_TIME *res, uint fuzzy_date); bool eq(const Item *item, bool binary_cmp) const; void print(String *str); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -716,7 +716,7 @@ class Item_extract :public Item_int_func void fix_length_and_dec(); bool eq(const Item *item, bool binary_cmp) const; void print(String *str); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -753,7 +753,7 @@ public: max_length=args[0]->max_length; maybe_null= 1; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -773,7 +773,7 @@ public: String *val_str(String *a); void fix_length_and_dec(); void print(String *str); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -884,7 +884,7 @@ public: max_length=MAX_DATE_WIDTH*MY_CHARSET_BIN_MB_MAXLEN; } longlong val_int(); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -907,7 +907,7 @@ public: } void print(String *str); const char *func_name() const { return "add_time"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} double val_real() { return val_real_from_decimal(); } my_decimal *val_decimal(my_decimal *decimal_value) { @@ -949,7 +949,7 @@ public: :Item_str_timefunc(a, b ,c) {} String *val_str(String *str); const char *func_name() const { return "maketime"; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; class Item_func_microsecond :public Item_int_func @@ -963,7 +963,7 @@ public: decimals=0; maybe_null=1; } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -981,7 +981,7 @@ public: maybe_null=1; } void print(String *str); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; @@ -1028,7 +1028,7 @@ public: { return tmp_table_field_from_field_type(table, 1); } - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; diff --git a/sql/item_xmlfunc.cc b/sql/item_xmlfunc.cc index 428bffa6879..f8457a1ae50 100644 --- a/sql/item_xmlfunc.cc +++ b/sql/item_xmlfunc.cc @@ -2656,7 +2656,7 @@ static uint xml_parent_tag(MY_XML_NODE *items, uint nitems, uint level) RETURN Currently only MY_XML_OK */ -static int xml_enter(MY_XML_PARSER *st,const char *attr, uint len) +static int xml_enter(MY_XML_PARSER *st,const char *attr, size_t len) { MY_XML_USER_DATA *data= (MY_XML_USER_DATA*)st->user_data; MY_XML_NODE *nodes= (MY_XML_NODE*) data->pxml->ptr(); @@ -2687,7 +2687,7 @@ static int xml_enter(MY_XML_PARSER *st,const char *attr, uint len) RETURN Currently only MY_XML_OK */ -static int xml_value(MY_XML_PARSER *st,const char *attr, uint len) +static int xml_value(MY_XML_PARSER *st,const char *attr, size_t len) { MY_XML_USER_DATA *data= (MY_XML_USER_DATA*)st->user_data; MY_XML_NODE *nodes= (MY_XML_NODE*) data->pxml->ptr(); @@ -2717,7 +2717,7 @@ static int xml_value(MY_XML_PARSER *st,const char *attr, uint len) RETURN Currently only MY_XML_OK */ -static int xml_leave(MY_XML_PARSER *st,const char *attr, uint len) +static int xml_leave(MY_XML_PARSER *st,const char *attr, size_t len) { MY_XML_USER_DATA *data= (MY_XML_USER_DATA*)st->user_data; DBUG_ASSERT(data->level > 0); @@ -2767,7 +2767,7 @@ String *Item_xml_str_func::parse_xml(String *raw_xml, String *parsed_xml_buf) if ((rc= my_xml_parse(&p, raw_xml->ptr(), raw_xml->length())) != MY_XML_OK) { char buf[128]; - my_snprintf(buf, sizeof(buf)-1, "parse error at line %d pos %d: %s", + my_snprintf(buf, sizeof(buf)-1, "parse error at line %d pos %lu: %s", my_xml_error_lineno(&p) + 1, my_xml_error_pos(&p) + 1, my_xml_error_string(&p)); diff --git a/sql/item_xmlfunc.h b/sql/item_xmlfunc.h index 9f2860ef403..650893fa7bd 100644 --- a/sql/item_xmlfunc.h +++ b/sql/item_xmlfunc.h @@ -41,7 +41,7 @@ public: Item_func_xml_extractvalue(Item *a,Item *b) :Item_xml_str_func(a,b) {} const char *func_name() const { return "extractvalue"; } String *val_str(String *); - bool check_partition_func_processor(byte *int_arg) {return FALSE;} + bool check_partition_func_processor(uchar *int_arg) {return FALSE;} }; diff --git a/sql/key.cc b/sql/key.cc index 9a3155c459e..fee06ec058f 100644 --- a/sql/key.cc +++ b/sql/key.cc @@ -45,7 +45,7 @@ key_length is set to length of key before (not including) field */ -int find_ref_key(KEY *key, uint key_count, byte *record, Field *field, +int find_ref_key(KEY *key, uint key_count, uchar *record, Field *field, uint *key_length, uint *keypart) { reg2 int i; @@ -111,7 +111,8 @@ int find_ref_key(KEY *key, uint key_count, byte *record, Field *field, None */ -void key_copy(byte *to_key, byte *from_record, KEY *key_info, uint key_length) +void key_copy(uchar *to_key, uchar *from_record, KEY *key_info, + uint key_length) { uint length; KEY_PART_INFO *key_part; @@ -131,7 +132,7 @@ void key_copy(byte *to_key, byte *from_record, KEY *key_info, uint key_length) Field_bit *field= (Field_bit *) (key_part->field); if (field->bit_len) { - uchar bits= get_rec_bits((uchar*) from_record + + uchar bits= get_rec_bits(from_record + key_part->null_offset + (key_part->null_bit == 128), field->bit_ofs, field->bit_len); @@ -144,7 +145,7 @@ void key_copy(byte *to_key, byte *from_record, KEY *key_info, uint key_length) { key_length-= HA_KEY_BLOB_LENGTH; length= min(key_length, key_part->length); - key_part->field->get_key_image((char*) to_key, length, Field::itRAW); + key_part->field->get_key_image(to_key, length, Field::itRAW); to_key+= HA_KEY_BLOB_LENGTH; } else @@ -152,7 +153,7 @@ void key_copy(byte *to_key, byte *from_record, KEY *key_info, uint key_length) length= min(key_length, key_part->length); Field *field= key_part->field; CHARSET_INFO *cs= field->charset(); - uint bytes= field->get_key_image((char*) to_key, length, Field::itRAW); + uint bytes= field->get_key_image(to_key, length, Field::itRAW); if (bytes < length) cs->cset->fill(cs, (char*) to_key + bytes, length - bytes, ' '); } @@ -180,7 +181,7 @@ void key_copy(byte *to_key, byte *from_record, KEY *key_info, uint key_length) None */ -void key_restore(byte *to_record, byte *from_key, KEY *key_info, +void key_restore(uchar *to_record, uchar *from_key, KEY *key_info, uint key_length) { uint length; @@ -226,7 +227,7 @@ void key_restore(byte *to_record, byte *from_key, KEY *key_info, from_key+= HA_KEY_BLOB_LENGTH; key_length-= HA_KEY_BLOB_LENGTH; field->set_ptr_offset(to_record - field->table->record[0], - (ulong) blob_length, (char*) from_key); + (ulong) blob_length, from_key); length= key_part->length; } else if (key_part->key_part_flag & HA_VAR_LENGTH_PART) @@ -238,7 +239,7 @@ void key_restore(byte *to_record, byte *from_key, KEY *key_info, key_length-= HA_KEY_BLOB_LENGTH; length= min(key_length, key_part->length); old_map= dbug_tmp_use_all_columns(field->table, field->table->write_set); - field->set_key_image((char *) from_key, length); + field->set_key_image(from_key, length); dbug_tmp_restore_column_map(field->table->write_set, old_map); from_key+= HA_KEY_BLOB_LENGTH; field->move_field_offset(-ptrdiff); @@ -275,11 +276,11 @@ void key_restore(byte *to_record, byte *from_key, KEY *key_info, 1 Key has changed */ -bool key_cmp_if_same(TABLE *table,const byte *key,uint idx,uint key_length) +bool key_cmp_if_same(TABLE *table,const uchar *key,uint idx,uint key_length) { uint store_length; KEY_PART_INFO *key_part; - const byte *key_end= key + key_length;; + const uchar *key_end= key + key_length;; for (key_part=table->key_info[idx].key_part; key < key_end ; @@ -311,7 +312,7 @@ bool key_cmp_if_same(TABLE *table,const byte *key,uint idx,uint key_length) { CHARSET_INFO *cs= key_part->field->charset(); uint char_length= key_part->length / cs->mbmaxlen; - const byte *pos= table->record[0] + key_part->offset; + const uchar *pos= table->record[0] + key_part->offset; if (length > char_length) { char_length= my_charpos(cs, pos, pos + length, char_length); @@ -435,11 +436,11 @@ bool is_key_used(TABLE *table, uint idx, const MY_BITMAP *fields) 1 Key is larger than range */ -int key_cmp(KEY_PART_INFO *key_part, const byte *key, uint key_length) +int key_cmp(KEY_PART_INFO *key_part, const uchar *key, uint key_length) { uint store_length; - for (const byte *end=key + key_length; + for (const uchar *end=key + key_length; key < end; key+= store_length, key_part++) { @@ -462,7 +463,7 @@ int key_cmp(KEY_PART_INFO *key_part, const byte *key, uint key_length) key++; // Skip null byte store_length--; } - if ((cmp=key_part->field->key_cmp((byte*) key, key_part->length)) < 0) + if ((cmp=key_part->field->key_cmp(key, key_part->length)) < 0) return -1; if (cmp > 0) return 1; @@ -495,13 +496,13 @@ int key_cmp(KEY_PART_INFO *key_part, const byte *key, uint key_length) and return the result of the comparison. */ -int key_rec_cmp(void *key, byte *first_rec, byte *second_rec) +int key_rec_cmp(void *key, uchar *first_rec, uchar *second_rec) { KEY *key_info= (KEY*)key; uint key_parts= key_info->key_parts, i= 0; KEY_PART_INFO *key_part= key_info->key_part; - char *rec0= key_part->field->ptr - key_part->offset; - my_ptrdiff_t first_diff= first_rec - (byte*)rec0, sec_diff= second_rec - (byte*)rec0; + uchar *rec0= key_part->field->ptr - key_part->offset; + my_ptrdiff_t first_diff= first_rec - rec0, sec_diff= second_rec - rec0; int result= 0; DBUG_ENTER("key_rec_cmp"); diff --git a/sql/lock.cc b/sql/lock.cc index ac6e90f68ff..6f1dd0669ee 100644 --- a/sql/lock.cc +++ b/sql/lock.cc @@ -137,7 +137,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, { /* Clear the lock type of all lock data to avoid reusage. */ reset_lock_data(sql_lock); - my_free((gptr) sql_lock,MYF(0)); + my_free((uchar*) sql_lock,MYF(0)); sql_lock=0; break; } @@ -145,7 +145,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, { /* Clear the lock type of all lock data to avoid reusage. */ reset_lock_data(sql_lock); - my_free((gptr) sql_lock,MYF(0)); + my_free((uchar*) sql_lock,MYF(0)); goto retry; } } @@ -161,7 +161,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, We do not wait for READ_ONLY=0, and fail. */ reset_lock_data(sql_lock); - my_free((gptr) sql_lock, MYF(0)); + my_free((uchar*) sql_lock, MYF(0)); sql_lock=0; my_error(ER_OPTION_PREVENTS_STATEMENT, MYF(0), "--read-only"); break; @@ -173,7 +173,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, { /* Clear the lock type of all lock data to avoid reusage. */ reset_lock_data(sql_lock); - my_free((gptr) sql_lock,MYF(0)); + my_free((uchar*) sql_lock,MYF(0)); sql_lock=0; break; } @@ -191,7 +191,7 @@ MYSQL_LOCK *mysql_lock_tables(THD *thd, TABLE **tables, uint count, if (rc > 1) /* a timeout or a deadlock */ { my_error(rc, MYF(0)); - my_free((gptr) sql_lock,MYF(0)); + my_free((uchar*) sql_lock,MYF(0)); sql_lock= 0; break; } @@ -285,7 +285,7 @@ void mysql_unlock_tables(THD *thd, MYSQL_LOCK *sql_lock) thr_multi_unlock(sql_lock->locks,sql_lock->lock_count); if (sql_lock->table_count) VOID(unlock_external(thd,sql_lock->table,sql_lock->table_count)); - my_free((gptr) sql_lock,MYF(0)); + my_free((uchar*) sql_lock,MYF(0)); DBUG_VOID_RETURN; } @@ -435,7 +435,7 @@ void mysql_lock_downgrade_write(THD *thd, TABLE *table, { for (uint i=0; i < locked->lock_count; i++) thr_downgrade_write_lock(locked->locks[i], new_lock_type); - my_free((gptr) locked,MYF(0)); + my_free((uchar*) locked,MYF(0)); } } @@ -453,7 +453,7 @@ void mysql_lock_abort(THD *thd, TABLE *table, bool upgrade_lock) { for (uint i=0; i < locked->lock_count; i++) thr_abort_locks(locked->locks[i]->lock, upgrade_lock); - my_free((gptr) locked,MYF(0)); + my_free((uchar*) locked,MYF(0)); } DBUG_VOID_RETURN; } @@ -488,7 +488,7 @@ bool mysql_lock_abort_for_thread(THD *thd, TABLE *table) table->in_use->thread_id)) result= TRUE; } - my_free((gptr) locked,MYF(0)); + my_free((uchar*) locked,MYF(0)); } DBUG_RETURN(result); } @@ -530,8 +530,8 @@ MYSQL_LOCK *mysql_lock_merge(MYSQL_LOCK *a,MYSQL_LOCK *b) } /* Delete old, not needed locks */ - my_free((gptr) a,MYF(0)); - my_free((gptr) b,MYF(0)); + my_free((uchar*) a,MYF(0)); + my_free((uchar*) b,MYF(0)); DBUG_RETURN(sql_lock); } @@ -749,7 +749,7 @@ static MYSQL_LOCK *get_lock_data(THD *thd, TABLE **table_ptr, uint count, /* Clear the lock type of the lock data that are stored already. */ sql_lock->lock_count= locks - sql_lock->locks; reset_lock_data(sql_lock); - my_free((gptr) sql_lock,MYF(0)); + my_free((uchar*) sql_lock,MYF(0)); DBUG_RETURN(0); } } @@ -904,10 +904,10 @@ int lock_table_name(THD *thd, TABLE_LIST *table_list, bool check_in_use) if (check_in_use) { /* Only insert the table if we haven't insert it already */ - for (table=(TABLE*) hash_first(&open_cache, (byte*)key, + for (table=(TABLE*) hash_first(&open_cache, (uchar*)key, key_length, &state); table ; - table = (TABLE*) hash_next(&open_cache,(byte*) key, + table = (TABLE*) hash_next(&open_cache,(uchar*) key, key_length, &state)) { if (table->in_use == thd) @@ -935,7 +935,7 @@ void unlock_table_name(THD *thd, TABLE_LIST *table_list) { if (table_list->table) { - hash_delete(&open_cache, (byte*) table_list->table); + hash_delete(&open_cache, (uchar*) table_list->table); broadcast_refresh(); } } diff --git a/sql/log.cc b/sql/log.cc index 9e9cd35ec9a..6ef1c1ea912 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -1435,7 +1435,7 @@ static int binlog_close_connection(handlerton *hton, THD *thd) DBUG_ASSERT(mysql_bin_log.is_open() && trx_data->empty()); thd->ha_data[binlog_hton->slot]= 0; trx_data->~binlog_trx_data(); - my_free((gptr)trx_data, MYF(0)); + my_free((uchar*)trx_data, MYF(0)); return 0; } @@ -1670,7 +1670,7 @@ int check_binlog_magic(IO_CACHE* log, const char** errmsg) char magic[4]; DBUG_ASSERT(my_b_tell(log) == 0); - if (my_b_read(log, (byte*) magic, sizeof(magic))) + if (my_b_read(log, (uchar*) magic, sizeof(magic))) { *errmsg = "I/O error reading the header from the binary log"; sql_print_error("%s, errno=%d, io cache code=%d", *errmsg, my_errno, @@ -1772,15 +1772,16 @@ static int find_uniq_filename(char *name) struct st_my_dir *dir_info; reg1 struct fileinfo *file_info; ulong max_found=0; - + size_t buf_length, length; + char *start, *end; DBUG_ENTER("find_uniq_filename"); - uint length = dirname_part(buff,name); - char *start = name + length; - char *end = strend(start); + length= dirname_part(buff, name, &buf_length); + start= name + length; + end= strend(start); *end='.'; - length= (uint) (end-start+1); + length= (size_t) (end-start+1); if (!(dir_info = my_dir(buff,MYF(MY_DONT_SORT)))) { // This shouldn't happen @@ -1790,7 +1791,7 @@ static int find_uniq_filename(char *name) file_info= dir_info->dir_entry; for (i=dir_info->number_off_files ; i-- ; file_info++) { - if (bcmp(file_info->name,start,length) == 0 && + if (bcmp((uchar*) file_info->name, (uchar*) start, length) == 0 && test_if_number(file_info->name+length, &number,0)) { set_if_bigger(max_found,(ulong) number); @@ -1894,7 +1895,7 @@ bool MYSQL_LOG::open(const char *log_name, enum_log_type log_type_arg, ); end= strnmov(buff + len, "Time Id Command Argument\n", sizeof(buff) - len); - if (my_b_write(&log_file, (byte*) buff, (uint) (end-buff)) || + if (my_b_write(&log_file, (uchar*) buff, (uint) (end-buff)) || flush_io_cache(&log_file)) goto err; } @@ -2102,30 +2103,30 @@ bool MYSQL_QUERY_LOG::write(time_t event_time, const char *user_host, start.tm_mday, start.tm_hour, start.tm_min, start.tm_sec); - if (my_b_write(&log_file, (byte*) &time_buff, time_buff_len)) + if (my_b_write(&log_file, (uchar*) &time_buff, time_buff_len)) goto err; } else - if (my_b_write(&log_file, (byte*) "\t\t" ,2) < 0) + if (my_b_write(&log_file, (uchar*) "\t\t" ,2) < 0) goto err; /* command_type, thread_id */ length= my_snprintf(buff, 32, "%5ld ", (long) thread_id); - if (my_b_write(&log_file, (byte*) buff, length)) + if (my_b_write(&log_file, (uchar*) buff, length)) goto err; - if (my_b_write(&log_file, (byte*) command_type, command_type_len)) + if (my_b_write(&log_file, (uchar*) command_type, command_type_len)) goto err; - if (my_b_write(&log_file, (byte*) "\t", 1)) + if (my_b_write(&log_file, (uchar*) "\t", 1)) goto err; /* sql_text */ - if (my_b_write(&log_file, (byte*) sql_text, sql_text_len)) + if (my_b_write(&log_file, (uchar*) sql_text, sql_text_len)) goto err; - if (my_b_write(&log_file, (byte*) "\n", 1) || + if (my_b_write(&log_file, (uchar*) "\n", 1) || flush_io_cache(&log_file)) goto err; } @@ -2205,7 +2206,7 @@ bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time, start.tm_min, start.tm_sec); /* Note that my_b_write() assumes it knows the length for this */ - if (my_b_write(&log_file, (byte*) buff, buff_len)) + if (my_b_write(&log_file, (uchar*) buff, buff_len)) tmp_errno= errno; } if (my_b_printf(&log_file, "# User@Host: ", sizeof("# User@Host: ") - 1) @@ -2213,7 +2214,7 @@ bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time, tmp_errno= errno; if (my_b_printf(&log_file, user_host, user_host_len) != user_host_len) tmp_errno= errno; - if (my_b_write(&log_file, (byte*) "\n", 1)) + if (my_b_write(&log_file, (uchar*) "\n", 1)) tmp_errno= errno; } /* For slow query log */ @@ -2261,18 +2262,18 @@ bool MYSQL_QUERY_LOG::write(THD *thd, time_t current_time, { *end++=';'; *end='\n'; - if (my_b_write(&log_file, (byte*) "SET ", 4) || - my_b_write(&log_file, (byte*) buff + 1, (uint) (end-buff))) + if (my_b_write(&log_file, (uchar*) "SET ", 4) || + my_b_write(&log_file, (uchar*) buff + 1, (uint) (end-buff))) tmp_errno= errno; } if (is_command) { end= strxmov(buff, "# administrator command: ", NullS); buff_len= (ulong) (end - buff); - my_b_write(&log_file, (byte*) buff, buff_len); + my_b_write(&log_file, (uchar*) buff, buff_len); } - if (my_b_write(&log_file, (byte*) sql_text, sql_text_len) || - my_b_write(&log_file, (byte*) ";\n",2) || + if (my_b_write(&log_file, (uchar*) sql_text, sql_text_len) || + my_b_write(&log_file, (uchar*) ";\n",2) || flush_io_cache(&log_file)) tmp_errno= errno; if (tmp_errno) @@ -2456,7 +2457,7 @@ bool MYSQL_BIN_LOG::open(const char *log_name, an extension for the binary log files. In this case we write a standard header to it. */ - if (my_b_safe_write(&log_file, (byte*) BINLOG_MAGIC, + if (my_b_safe_write(&log_file, (uchar*) BINLOG_MAGIC, BIN_LOG_HEADER_SIZE)) goto err; bytes_written+= BIN_LOG_HEADER_SIZE; @@ -2528,9 +2529,9 @@ bool MYSQL_BIN_LOG::open(const char *log_name, As this is a new log file, we write the file name to the index file. As every time we write to the index file, we sync it. */ - if (my_b_write(&index_file, (byte*) log_file_name, + if (my_b_write(&index_file, (uchar*) log_file_name, strlen(log_file_name)) || - my_b_write(&index_file, (byte*) "\n", 1) || + my_b_write(&index_file, (uchar*) "\n", 1) || flush_io_cache(&index_file) || my_sync(index_file.file, MYF(MY_WME))) goto err; @@ -2598,7 +2599,7 @@ static bool copy_up_file_and_fill(IO_CACHE *index_file, my_off_t offset) int bytes_read; my_off_t init_offset= offset; File file= index_file->file; - byte io_buf[IO_SIZE*2]; + uchar io_buf[IO_SIZE*2]; DBUG_ENTER("copy_up_file_and_fill"); for (;; offset+= bytes_read) @@ -2610,7 +2611,7 @@ static bool copy_up_file_and_fill(IO_CACHE *index_file, my_off_t offset) if (!bytes_read) break; // end of file (void) my_seek(file, offset-init_offset, MY_SEEK_SET, MYF(0)); - if (my_write(file, (byte*) io_buf, bytes_read, MYF(MY_WME | MY_NABP))) + if (my_write(file, io_buf, bytes_read, MYF(MY_WME | MY_NABP))) goto err; } /* The following will either truncate the file or fill the end with \n' */ @@ -2822,7 +2823,7 @@ bool MYSQL_BIN_LOG::reset_logs(THD* thd) need_start_event=1; if (!open_index_file(index_file_name, 0)) open(save_name, log_type, 0, io_cache_type, no_auto_events, max_size, 0); - my_free((gptr) save_name, MYF(0)); + my_free((uchar*) save_name, MYF(0)); err: VOID(pthread_mutex_unlock(&LOCK_thread_count)); @@ -3324,7 +3325,7 @@ bool MYSQL_BIN_LOG::appendv(const char* buf, uint len,...) safe_mutex_assert_owner(&LOCK_log); do { - if (my_b_append(&log_file,(byte*) buf,len)) + if (my_b_append(&log_file,(uchar*) buf,len)) { error= 1; goto err; @@ -3398,7 +3399,7 @@ int THD::binlog_setup_trx_data() open_cached_file(&trx_data->trans_log, mysql_tmpdir, LOG_PREFIX, binlog_cache_size, MYF(MY_WME))) { - my_free((gptr)trx_data, MYF(MY_ALLOW_ZERO_PTR)); + my_free((uchar*)trx_data, MYF(MY_ALLOW_ZERO_PTR)); ha_data[binlog_hton->slot]= 0; DBUG_RETURN(1); // Didn't manage to set it up } @@ -3804,7 +3805,7 @@ bool MYSQL_BIN_LOG::write(Log_event *event_info) for (uint i= 0; i < thd->user_var_events.elements; i++) { BINLOG_USER_VAR_EVENT *user_var_event; - get_dynamic(&thd->user_var_events,(gptr) &user_var_event, i); + get_dynamic(&thd->user_var_events,(uchar*) &user_var_event, i); User_var_log_event e(thd, user_var_event->user_var_event->name.str, user_var_event->user_var_event->name.length, user_var_event->value, @@ -4131,8 +4132,16 @@ void MYSQL_BIN_LOG::close(uint exiting) if (log_file.type == WRITE_CACHE && log_type == LOG_BIN) { my_off_t offset= BIN_LOG_HEADER_SIZE + FLAGS_OFFSET; - byte flags=0; // clearing LOG_EVENT_BINLOG_IN_USE_F + my_off_t org_position= my_tell(log_file.file, MYF(0)); + uchar flags= 0; // clearing LOG_EVENT_BINLOG_IN_USE_F my_pwrite(log_file.file, &flags, 1, offset, MYF(0)); + /* + Restore position so that anything we have in the IO_cache is written + to the correct position. + We need the seek here, as my_pwrite() is not guaranteed to keep the + original position on system that doesn't support pwrite(). + */ + my_seek(log_file.file, org_position, MY_SEEK_SET, MYF(0)); } /* this will cleanup IO_CACHE, sync and close the file */ @@ -4256,17 +4265,21 @@ bool flush_error_log() (void) my_delete(err_temp, MYF(0)); if (freopen(err_temp,"a+",stdout)) { + int fd; + size_t bytes; + uchar buf[IO_SIZE]; + freopen(err_temp,"a+",stderr); (void) my_delete(err_renamed, MYF(0)); my_rename(log_error_file,err_renamed,MYF(0)); if (freopen(log_error_file,"a+",stdout)) freopen(log_error_file,"a+",stderr); - int fd, bytes; - char buf[IO_SIZE]; + if ((fd = my_open(err_temp, O_RDONLY, MYF(0))) >= 0) { - while ((bytes = (int) my_read(fd, (byte*) buf, IO_SIZE, MYF(0))) > 0) - my_fwrite(stderr, (byte*) buf, bytes, MYF(0)); + while ((bytes= my_read(fd, buf, IO_SIZE, MYF(0))) && + bytes != MY_FILE_ERROR) + my_fwrite(stderr, buf, bytes, MYF(0)); my_close(fd, MYF(0)); } (void) my_delete(err_temp, MYF(0)); @@ -4840,9 +4853,9 @@ void TC_LOG_MMAP::close() pthread_cond_destroy(&pages[i].cond); } case 3: - my_free((gptr)pages, MYF(0)); + my_free((uchar*)pages, MYF(0)); case 2: - my_munmap((byte*)data, (size_t)file_length); + my_munmap((char*)data, (size_t)file_length); case 1: my_close(fd, MYF(0)); } @@ -4876,13 +4889,13 @@ int TC_LOG_MMAP::recover() } if (hash_init(&xids, &my_charset_bin, tc_log_page_size/3, 0, - sizeof(my_xid), 0, 0, MYF(0))) + sizeof(my_xid), 0, 0, MYF(0))) goto err1; for ( ; p < end_p ; p++) { for (my_xid *x=p->start; x < p->end; x++) - if (*x && my_hash_insert(&xids, (byte *)x)) + if (*x && my_hash_insert(&xids, (uchar *)x)) goto err2; // OOM } @@ -5075,7 +5088,7 @@ int TC_LOG_BINLOG::recover(IO_CACHE *log, Format_description_log_event *fdle) if (! fdle->is_valid() || hash_init(&xids, &my_charset_bin, TC_LOG_PAGE_SIZE/3, 0, - sizeof(my_xid), 0, 0, MYF(0))) + sizeof(my_xid), 0, 0, MYF(0))) goto err1; init_alloc_root(&mem_root, TC_LOG_PAGE_SIZE, TC_LOG_PAGE_SIZE); @@ -5087,8 +5100,8 @@ int TC_LOG_BINLOG::recover(IO_CACHE *log, Format_description_log_event *fdle) if (ev->get_type_code() == XID_EVENT) { Xid_log_event *xev=(Xid_log_event *)ev; - byte *x=(byte *)memdup_root(&mem_root, (char *)& xev->xid, - sizeof(xev->xid)); + uchar *x= (uchar *) memdup_root(&mem_root, (uchar*) &xev->xid, + sizeof(xev->xid)); if (! x) goto err2; my_hash_insert(&xids, x); diff --git a/sql/log_event.cc b/sql/log_event.cc index 3cca8d53f07..3532a18939d 100644 --- a/sql/log_event.cc +++ b/sql/log_event.cc @@ -299,10 +299,10 @@ static void cleanup_load_tmpdir() static bool write_str(IO_CACHE *file, char *str, uint length) { - byte tmp[1]; - tmp[0]= (byte) length; + uchar tmp[1]; + tmp[0]= (uchar) length; return (my_b_safe_write(file, tmp, sizeof(tmp)) || - my_b_safe_write(file, (byte*) str, length)); + my_b_safe_write(file, (uchar*) str, length)); } @@ -310,8 +310,8 @@ static bool write_str(IO_CACHE *file, char *str, uint length) read_str() */ -static inline int read_str(const char **buf, const char *buf_end, const char **str, - uint8 *len) +static inline int read_str(const char **buf, const char *buf_end, + const char **str, uint8 *len) { if (*buf + ((uint) (uchar) **buf) >= buf_end) return 1; @@ -637,7 +637,7 @@ void Log_event::init_show_field_list(List<Item>* field_list) bool Log_event::write_header(IO_CACHE* file, ulong event_data_length) { - byte header[LOG_EVENT_HEADER_LEN]; + uchar header[LOG_EVENT_HEADER_LEN]; DBUG_ENTER("Log_event::write_header"); /* Store number of bytes that will be written by this event */ @@ -724,7 +724,7 @@ int Log_event::read_log_event(IO_CACHE* file, String* packet, if (log_lock) pthread_mutex_lock(log_lock); - if (my_b_read(file, (byte*) buf, sizeof(buf))) + if (my_b_read(file, (uchar*) buf, sizeof(buf))) { /* If the read hits eof, we must report it as eof so the caller @@ -825,7 +825,7 @@ Log_event* Log_event::read_log_event(IO_CACHE* file, LOCK_MUTEX; DBUG_PRINT("info", ("my_b_tell: %lu", (ulong) my_b_tell(file))); - if (my_b_read(file, (byte *) head, header_size)) + if (my_b_read(file, (uchar *) head, header_size)) { DBUG_PRINT("info", ("Log_event::read_log_event(IO_CACHE*,Format_desc*) \ failed my_b_read")); @@ -859,14 +859,14 @@ failed my_b_read")); } // some events use the extra byte to null-terminate strings - if (!(buf = my_malloc(data_len+1, MYF(MY_WME)))) + if (!(buf = (char*) my_malloc(data_len+1, MYF(MY_WME)))) { error = "Out of memory"; goto err; } buf[data_len] = 0; memcpy(buf, head, header_size); - if (my_b_read(file, (byte*) buf + header_size, data_len - header_size)) + if (my_b_read(file, (uchar*) buf + header_size, data_len - header_size)) { error = "read error"; goto err; @@ -1092,8 +1092,8 @@ void Log_event::print_header(IO_CACHE* file, ptr[7], ptr[8], ptr[9], ptr[10], ptr[11], ptr[12], ptr[13], ptr[14], ptr[15], ptr[16], ptr[17], ptr[18]); DBUG_ASSERT(bytes_written >= 0); - DBUG_ASSERT(static_cast<my_size_t>(bytes_written) < sizeof(emit_buf)); - my_b_write(file, (byte*) emit_buf, bytes_written); + DBUG_ASSERT(static_cast<size_t>(bytes_written) < sizeof(emit_buf)); + my_b_write(file, (uchar*) emit_buf, bytes_written); ptr += LOG_EVENT_MINIMAL_HEADER_LEN; hexdump_from += LOG_EVENT_MINIMAL_HEADER_LEN; } @@ -1123,8 +1123,8 @@ void Log_event::print_header(IO_CACHE* file, (unsigned long) (hexdump_from + (i & 0xfffffff0)), hex_string, char_string); DBUG_ASSERT(bytes_written >= 0); - DBUG_ASSERT(static_cast<my_size_t>(bytes_written) < sizeof(emit_buf)); - my_b_write(file, (byte*) emit_buf, bytes_written); + DBUG_ASSERT(static_cast<size_t>(bytes_written) < sizeof(emit_buf)); + my_b_write(file, (uchar*) emit_buf, bytes_written); hex_string[0]= 0; char_string[0]= 0; c= char_string; @@ -1144,14 +1144,14 @@ void Log_event::print_header(IO_CACHE* file, (unsigned long) (hexdump_from + (i & 0xfffffff0)), hex_string, char_string); DBUG_ASSERT(bytes_written >= 0); - DBUG_ASSERT(static_cast<my_size_t>(bytes_written) < sizeof(emit_buf)); - my_b_write(file, (byte*) emit_buf, bytes_written); + DBUG_ASSERT(static_cast<size_t>(bytes_written) < sizeof(emit_buf)); + my_b_write(file, (uchar*) emit_buf, bytes_written); } /* need a # to prefix the rest of printouts for example those of Rows_log_event::print_helper(). */ - my_b_write(file, reinterpret_cast<const byte*>("# "), 2); + my_b_write(file, reinterpret_cast<const uchar*>("# "), 2); } DBUG_VOID_RETURN; } @@ -1239,7 +1239,7 @@ void Query_log_event::pack_info(Protocol *protocol) { // TODO: show the catalog ?? char *buf, *pos; - if (!(buf= my_malloc(9 + db_len + q_len, MYF(MY_WME)))) + if (!(buf= (char*) my_malloc(9 + db_len + q_len, MYF(MY_WME)))) return; pos= buf; if (!(flags & LOG_EVENT_SUPPRESS_USE_F) @@ -1440,12 +1440,12 @@ bool Query_log_event::write(IO_CACHE* file) event_length= (uint) (start-buf) + get_post_header_size_for_derived() + db_len + 1 + q_len; return (write_header(file, event_length) || - my_b_safe_write(file, (byte*) buf, QUERY_HEADER_LEN) || + my_b_safe_write(file, (uchar*) buf, QUERY_HEADER_LEN) || write_post_header_for_derived(file) || - my_b_safe_write(file, (byte*) start_of_status, + my_b_safe_write(file, (uchar*) start_of_status, (uint) (start-start_of_status)) || - my_b_safe_write(file, (db) ? (byte*) db : (byte*)"", db_len + 1) || - my_b_safe_write(file, (byte*) query, q_len)) ? 1 : 0; + my_b_safe_write(file, (db) ? (uchar*) db : (uchar*)"", db_len + 1) || + my_b_safe_write(file, (uchar*) query, q_len)) ? 1 : 0; } /* @@ -1578,7 +1578,8 @@ static void copy_str_and_move(const char **src, */ Query_log_event::Query_log_event(const char* buf, uint event_len, - const Format_description_log_event *description_event, + const Format_description_log_event + *description_event, Log_event_type event_type) :Log_event(buf, description_event), data_buf(0), query(NullS), db(NullS), catalog_len(0), status_vars_len(0), @@ -1771,7 +1772,7 @@ void Query_log_event::print_query_header(IO_CACHE* file, end=int10_to_str((long) when, strmov(buff,"SET TIMESTAMP="),10); end= strmov(end, print_event_info->delimiter); *end++='\n'; - my_b_write(file, (byte*) buff, (uint) (end-buff)); + my_b_write(file, (uchar*) buff, (uint) (end-buff)); if (flags & LOG_EVENT_THREAD_SPECIFIC_F) my_b_printf(file,"SET @@session.pseudo_thread_id=%lu%s\n", (ulong)thread_id, print_event_info->delimiter); @@ -1855,7 +1856,7 @@ void Query_log_event::print_query_header(IO_CACHE* file, print_event_info->charset_inited= 1; print_event_info->charset[0]= ~charset[0]; // force a difference to force write } - if (unlikely(bcmp(print_event_info->charset, charset, 6))) + if (unlikely(bcmp((uchar*) print_event_info->charset, (uchar*) charset, 6))) { CHARSET_INFO *cs_info= get_charset(uint2korr(charset), MYF(MY_WME)); if (cs_info) @@ -1878,7 +1879,8 @@ void Query_log_event::print_query_header(IO_CACHE* file, } if (time_zone_len) { - if (bcmp(print_event_info->time_zone_str, time_zone_str, time_zone_len+1)) + if (bcmp((uchar*) print_event_info->time_zone_str, + (uchar*) time_zone_str, time_zone_len+1)) { my_b_printf(file,"SET @@session.time_zone='%s'%s\n", time_zone_str, print_event_info->delimiter); @@ -1909,7 +1911,7 @@ void Query_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info) Write_on_release_cache cache(&print_event_info->head_cache, file); print_query_header(&cache, print_event_info); - my_b_write(&cache, (byte*) query, q_len); + my_b_write(&cache, (uchar*) query, q_len); my_b_printf(&cache, "%s\n", print_event_info->delimiter); } #endif /* MYSQL_CLIENT */ @@ -2346,7 +2348,7 @@ bool Start_log_event_v3::write(IO_CACHE* file) memcpy(buff + ST_SERVER_VER_OFFSET,server_version,ST_SERVER_VER_LEN); int4store(buff + ST_CREATED_OFFSET,created); return (write_header(file, sizeof(buff)) || - my_b_safe_write(file, (byte*) buff, sizeof(buff))); + my_b_safe_write(file, (uchar*) buff, sizeof(buff))); } #endif @@ -2581,7 +2583,7 @@ Format_description_log_event(const char* buf, DBUG_PRINT("info", ("common_header_len=%d number_of_event_types=%d", common_header_len, number_of_event_types)); /* If alloc fails, we'll detect it in is_valid() */ - post_header_len= (uint8*) my_memdup((byte*)buf+ST_COMMON_HEADER_LEN_OFFSET+1, + post_header_len= (uint8*) my_memdup((uchar*)buf+ST_COMMON_HEADER_LEN_OFFSET+1, number_of_event_types* sizeof(*post_header_len), MYF(0)); calc_server_version_split(); @@ -2595,12 +2597,12 @@ bool Format_description_log_event::write(IO_CACHE* file) We don't call Start_log_event_v3::write() because this would make 2 my_b_safe_write(). */ - byte buff[FORMAT_DESCRIPTION_HEADER_LEN]; + uchar buff[FORMAT_DESCRIPTION_HEADER_LEN]; int2store(buff + ST_BINLOG_VER_OFFSET,binlog_version); memcpy((char*) buff + ST_SERVER_VER_OFFSET,server_version,ST_SERVER_VER_LEN); int4store(buff + ST_CREATED_OFFSET,created); buff[ST_COMMON_HEADER_LEN_OFFSET]= LOG_EVENT_HEADER_LEN; - memcpy((char*) buff+ST_COMMON_HEADER_LEN_OFFSET+1, (byte*) post_header_len, + memcpy((char*) buff+ST_COMMON_HEADER_LEN_OFFSET+1, (uchar*) post_header_len, LOG_EVENT_TYPES); return (write_header(file, sizeof(buff)) || my_b_safe_write(file, buff, sizeof(buff))); @@ -2855,7 +2857,7 @@ void Load_log_event::pack_info(Protocol *protocol) { char *buf, *end; - if (!(buf= my_malloc(get_query_buffer_length(), MYF(MY_WME)))) + if (!(buf= (char*) my_malloc(get_query_buffer_length(), MYF(MY_WME)))) return; print_query(TRUE, buf, &end, 0, 0); protocol->store(buf, end-buf, &my_charset_bin); @@ -2879,7 +2881,7 @@ bool Load_log_event::write_data_header(IO_CACHE* file) buf[L_TBL_LEN_OFFSET] = (char)table_name_len; buf[L_DB_LEN_OFFSET] = (char)db_len; int4store(buf + L_NUM_FIELDS_OFFSET, num_fields); - return my_b_safe_write(file, (byte*)buf, LOAD_HEADER_LEN) != 0; + return my_b_safe_write(file, (uchar*)buf, LOAD_HEADER_LEN) != 0; } @@ -2893,13 +2895,13 @@ bool Load_log_event::write_data_body(IO_CACHE* file) return 1; if (num_fields && fields && field_lens) { - if (my_b_safe_write(file, (byte*)field_lens, num_fields) || - my_b_safe_write(file, (byte*)fields, field_block_len)) + if (my_b_safe_write(file, (uchar*)field_lens, num_fields) || + my_b_safe_write(file, (uchar*)fields, field_block_len)) return 1; } - return (my_b_safe_write(file, (byte*)table_name, table_name_len + 1) || - my_b_safe_write(file, (byte*)db, db_len + 1) || - my_b_safe_write(file, (byte*)fname, fname_len)); + return (my_b_safe_write(file, (uchar*)table_name, table_name_len + 1) || + my_b_safe_write(file, (uchar*)db, db_len + 1) || + my_b_safe_write(file, (uchar*)fname, fname_len)); } @@ -3520,7 +3522,7 @@ void Rotate_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info) print_header(&cache, print_event_info, FALSE); my_b_printf(&cache, "\tRotate to "); if (new_log_ident) - my_b_write(&cache, (byte*) new_log_ident, (uint)ident_len); + my_b_write(&cache, (uchar*) new_log_ident, (uint)ident_len); my_b_printf(&cache, " pos: %s\n", llstr(pos, buf)); } #endif /* MYSQL_CLIENT */ @@ -3586,8 +3588,8 @@ bool Rotate_log_event::write(IO_CACHE* file) char buf[ROTATE_HEADER_LEN]; int8store(buf + R_POS_OFFSET, pos); return (write_header(file, ROTATE_HEADER_LEN + ident_len) || - my_b_safe_write(file, (byte*)buf, ROTATE_HEADER_LEN) || - my_b_safe_write(file, (byte*)new_log_ident, (uint) ident_len)); + my_b_safe_write(file, (uchar*)buf, ROTATE_HEADER_LEN) || + my_b_safe_write(file, (uchar*)new_log_ident, (uint) ident_len)); } #endif @@ -3754,8 +3756,8 @@ const char* Intvar_log_event::get_var_type_name() #ifndef MYSQL_CLIENT bool Intvar_log_event::write(IO_CACHE* file) { - byte buf[9]; - buf[I_TYPE_OFFSET]= (byte) type; + uchar buf[9]; + buf[I_TYPE_OFFSET]= (uchar) type; int8store(buf + I_VAL_OFFSET, val); return (write_header(file, sizeof(buf)) || my_b_safe_write(file, buf, sizeof(buf))); @@ -3883,7 +3885,7 @@ Rand_log_event::Rand_log_event(const char* buf, #ifndef MYSQL_CLIENT bool Rand_log_event::write(IO_CACHE* file) { - byte buf[16]; + uchar buf[16]; int8store(buf + RAND_SEED1_OFFSET, seed1); int8store(buf + RAND_SEED2_OFFSET, seed2); return (write_header(file, sizeof(buf)) || @@ -3990,7 +3992,7 @@ Xid_log_event(const char* buf, bool Xid_log_event::write(IO_CACHE* file) { return write_header(file, sizeof(xid)) || - my_b_safe_write(file, (byte*) &xid, sizeof(xid)); + my_b_safe_write(file, (uchar*) &xid, sizeof(xid)); } #endif @@ -4038,7 +4040,8 @@ void User_var_log_event::pack_info(Protocol* protocol) if (is_null) { - buf= my_malloc(val_offset + 5, MYF(MY_WME)); + if (!(buf= (char*) my_malloc(val_offset + 5, MYF(MY_WME)))) + return; strmov(buf + val_offset, "NULL"); event_len= val_offset + 4; } @@ -4048,28 +4051,37 @@ void User_var_log_event::pack_info(Protocol* protocol) case REAL_RESULT: double real_val; float8get(real_val, val); - buf= my_malloc(val_offset + FLOATING_POINT_BUFFER, MYF(MY_WME)); + if (!(buf= (char*) my_malloc(val_offset + FLOATING_POINT_BUFFER, + MYF(MY_WME)))) + return; event_len+= my_sprintf(buf + val_offset, (buf + val_offset, "%.14g", real_val)); break; case INT_RESULT: - buf= my_malloc(val_offset + 22, MYF(MY_WME)); + if (!(buf= (char*) my_malloc(val_offset + 22, MYF(MY_WME)))) + return; event_len= longlong10_to_str(uint8korr(val), buf + val_offset,-10)-buf; break; case DECIMAL_RESULT: { - buf= my_malloc(val_offset + DECIMAL_MAX_STR_LENGTH, MYF(MY_WME)); + if (!(buf= (char*) my_malloc(val_offset + DECIMAL_MAX_STR_LENGTH, + MYF(MY_WME)))) + return; String str(buf+val_offset, DECIMAL_MAX_STR_LENGTH, &my_charset_bin); my_decimal dec; - binary2my_decimal(E_DEC_FATAL_ERROR, val+2, &dec, val[0], val[1]); + binary2my_decimal(E_DEC_FATAL_ERROR, (uchar*) (val+2), &dec, val[0], + val[1]); my_decimal2string(E_DEC_FATAL_ERROR, &dec, 0, 0, 0, &str); event_len= str.length() + val_offset; break; } case STRING_RESULT: /* 15 is for 'COLLATE' and other chars */ - buf= my_malloc(event_len+val_len*2+1+2*MY_CS_NAME_SIZE+15, MYF(MY_WME)); + buf= (char*) my_malloc(event_len+val_len*2+1+2*MY_CS_NAME_SIZE+15, + MYF(MY_WME)); CHARSET_INFO *cs; + if (!buf) + return; if (!(cs= get_charset(charset_number, MYF(0)))) { strmov(buf+val_offset, "???"); @@ -4091,11 +4103,11 @@ void User_var_log_event::pack_info(Protocol* protocol) } buf[0]= '@'; buf[1]= '`'; + memcpy(buf+2, name, name_len); buf[2+name_len]= '`'; buf[3+name_len]= '='; - memcpy(buf+2, name, name_len); protocol->store(buf, event_len, &my_charset_bin); - my_free(buf, MYF(MY_ALLOW_ZERO_PTR)); + my_free(buf, MYF(0)); } #endif /* !MYSQL_CLIENT */ @@ -4135,7 +4147,7 @@ bool User_var_log_event::write(IO_CACHE* file) char buf[UV_NAME_LEN_SIZE]; char buf1[UV_VAL_IS_NULL + UV_VAL_TYPE_SIZE + UV_CHARSET_NUMBER_SIZE + UV_VAL_LEN_SIZE]; - char buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2; + uchar buf2[max(8, DECIMAL_MAX_FIELD_SIZE + 2)], *pos= buf2; uint buf1_length; ulong event_length; @@ -4144,7 +4156,7 @@ bool User_var_log_event::write(IO_CACHE* file) if ((buf1[0]= is_null)) { buf1_length= 1; - val_len= 0; + val_len= 0; // Length of 'pos' } else { @@ -4169,7 +4181,7 @@ bool User_var_log_event::write(IO_CACHE* file) break; } case STRING_RESULT: - pos= val; + pos= (uchar*) val; break; case ROW_RESULT: default: @@ -4184,10 +4196,10 @@ bool User_var_log_event::write(IO_CACHE* file) event_length= sizeof(buf)+ name_len + buf1_length + val_len; return (write_header(file, event_length) || - my_b_safe_write(file, (byte*) buf, sizeof(buf)) || - my_b_safe_write(file, (byte*) name, name_len) || - my_b_safe_write(file, (byte*) buf1, buf1_length) || - my_b_safe_write(file, (byte*) pos, val_len)); + my_b_safe_write(file, (uchar*) buf, sizeof(buf)) || + my_b_safe_write(file, (uchar*) name, name_len) || + my_b_safe_write(file, (uchar*) buf1, buf1_length) || + my_b_safe_write(file, pos, val_len)); } #endif @@ -4209,7 +4221,7 @@ void User_var_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info) } my_b_printf(&cache, "SET @`"); - my_b_write(&cache, (byte*) name, (uint) (name_len)); + my_b_write(&cache, (uchar*) name, (uint) (name_len)); my_b_printf(&cache, "`"); if (is_null) @@ -4240,7 +4252,7 @@ void User_var_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info) dec.len= 10; dec.buf= dec_buf; - bin2decimal(val+2, &dec, precision, scale); + bin2decimal((uchar*) val+2, &dec, precision, scale); decimal2string(&dec, str_buf, &str_len, 0, 0, 0); str_buf[str_len]= 0; my_b_printf(&cache, ":=%s%s\n", str_buf, print_event_info->delimiter); @@ -4341,7 +4353,7 @@ int User_var_log_event::do_apply_event(RELAY_LOG_INFO const *rli) break; case DECIMAL_RESULT: { - Item_decimal *dec= new Item_decimal(val+2, val[0], val[1]); + Item_decimal *dec= new Item_decimal((uchar*) val+2, val[0], val[1]); it= dec; val= (char *)dec->val_decimal(NULL); val_len= sizeof(my_decimal); @@ -4506,7 +4518,7 @@ bool Slave_log_event::write(IO_CACHE* file) // log and host are already there return (write_header(file, event_length) || - my_b_safe_write(file, (byte*) mem_pool, event_length)); + my_b_safe_write(file, (uchar*) mem_pool, event_length)); } #endif @@ -4649,8 +4661,8 @@ bool Create_file_log_event::write_data_body(IO_CACHE* file) bool res; if ((res= Load_log_event::write_data_body(file)) || fake_base) return res; - return (my_b_safe_write(file, (byte*) "", 1) || - my_b_safe_write(file, (byte*) block, block_len)); + return (my_b_safe_write(file, (uchar*) "", 1) || + my_b_safe_write(file, (uchar*) block, block_len)); } @@ -4661,7 +4673,7 @@ bool Create_file_log_event::write_data_body(IO_CACHE* file) bool Create_file_log_event::write_data_header(IO_CACHE* file) { bool res; - byte buf[CREATE_FILE_HEADER_LEN]; + uchar buf[CREATE_FILE_HEADER_LEN]; if ((res= Load_log_event::write_data_header(file)) || fake_base) return res; int4store(buf + CF_FILE_ID_OFFSET, file_id); @@ -4697,7 +4709,7 @@ Create_file_log_event::Create_file_log_event(const char* buf, uint len, uint header_len= description_event->common_header_len; uint8 load_header_len= description_event->post_header_len[LOAD_EVENT-1]; uint8 create_file_header_len= description_event->post_header_len[CREATE_FILE_EVENT-1]; - if (!(event_buf= my_memdup((byte*) buf, len, MYF(MY_WME))) || + if (!(event_buf= (char*) my_memdup(buf, len, MYF(MY_WME))) || copy_log_event(event_buf,len, ((buf[EVENT_TYPE_OFFSET] == LOAD_EVENT) ? load_header_len + header_len : @@ -4852,7 +4864,7 @@ int Create_file_log_event::do_apply_event(RELAY_LOG_INFO const *rli) "could not open file '%s'", fname_buf); goto err; } - if (my_write(fd, (byte*) block, block_len, MYF(MY_WME+MY_NABP))) + if (my_write(fd, (uchar*) block, block_len, MYF(MY_WME+MY_NABP))) { slave_print_msg(ERROR_LEVEL, rli, my_errno, "Error in Create_file event: " "write to '%s' failed", fname_buf); @@ -4920,11 +4932,11 @@ Append_block_log_event::Append_block_log_event(const char* buf, uint len, #ifndef MYSQL_CLIENT bool Append_block_log_event::write(IO_CACHE* file) { - byte buf[APPEND_BLOCK_HEADER_LEN]; + uchar buf[APPEND_BLOCK_HEADER_LEN]; int4store(buf + AB_FILE_ID_OFFSET, file_id); return (write_header(file, APPEND_BLOCK_HEADER_LEN + block_len) || my_b_safe_write(file, buf, APPEND_BLOCK_HEADER_LEN) || - my_b_safe_write(file, (byte*) block, block_len)); + my_b_safe_write(file, (uchar*) block, block_len)); } #endif @@ -5008,7 +5020,7 @@ int Append_block_log_event::do_apply_event(RELAY_LOG_INFO const *rli) get_type_str(), fname); goto err; } - if (my_write(fd, (byte*) block, block_len, MYF(MY_WME+MY_NABP))) + if (my_write(fd, (uchar*) block, block_len, MYF(MY_WME+MY_NABP))) { slave_print_msg(ERROR_LEVEL, rli, my_errno, "Error in %s event: write to '%s' failed", @@ -5065,7 +5077,7 @@ Delete_file_log_event::Delete_file_log_event(const char* buf, uint len, #ifndef MYSQL_CLIENT bool Delete_file_log_event::write(IO_CACHE* file) { - byte buf[DELETE_FILE_HEADER_LEN]; + uchar buf[DELETE_FILE_HEADER_LEN]; int4store(buf + DF_FILE_ID_OFFSET, file_id); return (write_header(file, sizeof(buf)) || my_b_safe_write(file, buf, sizeof(buf))); @@ -5161,7 +5173,7 @@ Execute_load_log_event::Execute_load_log_event(const char* buf, uint len, #ifndef MYSQL_CLIENT bool Execute_load_log_event::write(IO_CACHE* file) { - byte buf[EXEC_LOAD_HEADER_LEN]; + uchar buf[EXEC_LOAD_HEADER_LEN]; int4store(buf + EL_FILE_ID_OFFSET, file_id); return (write_header(file, sizeof(buf)) || my_b_safe_write(file, buf, sizeof(buf))); @@ -5379,12 +5391,12 @@ ulong Execute_load_query_log_event::get_post_header_size_for_derived() bool Execute_load_query_log_event::write_post_header_for_derived(IO_CACHE* file) { - char buf[EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN]; + uchar buf[EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN]; int4store(buf, file_id); int4store(buf + 4, fn_pos_start); int4store(buf + 4 + 4, fn_pos_end); - *(buf + 4 + 4 + 4)= (char)dup_handling; - return my_b_safe_write(file, (byte*) buf, EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN); + *(buf + 4 + 4 + 4)= (uchar) dup_handling; + return my_b_safe_write(file, buf, EXECUTE_LOAD_QUERY_EXTRA_HEADER_LEN); } #endif @@ -5407,19 +5419,19 @@ void Execute_load_query_log_event::print(FILE* file, if (local_fname) { - my_b_write(&cache, (byte*) query, fn_pos_start); + my_b_write(&cache, (uchar*) query, fn_pos_start); my_b_printf(&cache, " LOCAL INFILE \'"); my_b_printf(&cache, local_fname); my_b_printf(&cache, "\'"); if (dup_handling == LOAD_DUP_REPLACE) my_b_printf(&cache, " REPLACE"); my_b_printf(&cache, " INTO"); - my_b_write(&cache, (byte*) query + fn_pos_end, q_len-fn_pos_end); + my_b_write(&cache, (uchar*) query + fn_pos_end, q_len-fn_pos_end); my_b_printf(&cache, "%s\n", print_event_info->delimiter); } else { - my_b_write(&cache, (byte*) query, q_len); + my_b_write(&cache, (uchar*) query, q_len); my_b_printf(&cache, "%s\n", print_event_info->delimiter); } @@ -5433,7 +5445,7 @@ void Execute_load_query_log_event::print(FILE* file, void Execute_load_query_log_event::pack_info(Protocol *protocol) { char *buf, *pos; - if (!(buf= my_malloc(9 + db_len + q_len + 10 + 21, MYF(MY_WME)))) + if (!(buf= (char*) my_malloc(9 + db_len + q_len + 10 + 21, MYF(MY_WME)))) return; pos= buf; if (db && db_len) @@ -5464,8 +5476,8 @@ Execute_load_query_log_event::do_apply_event(RELAY_LOG_INFO const *rli) int error; /* Replace filename and LOCAL keyword in query before executing it */ - if (!(buf = my_malloc(q_len + 1 - (fn_pos_end - fn_pos_start) + - (FN_REFLEN + 10) + 10 + 8 + 5, MYF(MY_WME)))) + if (!(buf = (char*) my_malloc(q_len + 1 - (fn_pos_end - fn_pos_start) + + (FN_REFLEN + 10) + 10 + 8 + 5, MYF(MY_WME)))) { slave_print_msg(ERROR_LEVEL, rli, my_errno, "Not enough memory"); return 1; @@ -5527,7 +5539,7 @@ bool sql_ex_info::write_data(IO_CACHE* file) write_str(file, line_term, (uint) line_term_len) || write_str(file, line_start, (uint) line_start_len) || write_str(file, escaped, (uint) escaped_len) || - my_b_safe_write(file,(byte*) &opt_flags,1)); + my_b_safe_write(file,(uchar*) &opt_flags,1)); } else { @@ -5539,7 +5551,7 @@ bool sql_ex_info::write_data(IO_CACHE* file) old_ex.escaped= *escaped; old_ex.opt_flags= opt_flags; old_ex.empty_flags=empty_flags; - return my_b_safe_write(file, (byte*) &old_ex, sizeof(old_ex)) != 0; + return my_b_safe_write(file, (uchar*) &old_ex, sizeof(old_ex)) != 0; } } @@ -5674,9 +5686,9 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len, m_flags= uint2korr(post_start); - byte const *const var_start= - (const byte *)buf + common_header_len + post_header_len; - byte const *const ptr_width= var_start; + uchar const *const var_start= + (const uchar *)buf + common_header_len + post_header_len; + uchar const *const ptr_width= var_start; uchar *ptr_after_width= (uchar*) ptr_width; DBUG_PRINT("debug", ("Reading from %p", ptr_after_width)); m_width = net_field_length(&ptr_after_width); @@ -5690,7 +5702,7 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len, DBUG_PRINT("debug", ("Reading from %p", ptr_after_width)); memcpy(m_cols.bitmap, ptr_after_width, (m_width + 7) / 8); ptr_after_width+= (m_width + 7) / 8; - DBUG_DUMP("m_cols", (char*) m_cols.bitmap, no_bytes_in_map(&m_cols)); + DBUG_DUMP("m_cols", (uchar*) m_cols.bitmap, no_bytes_in_map(&m_cols)); } else { @@ -5714,7 +5726,8 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len, DBUG_PRINT("debug", ("Reading from %p", ptr_after_width)); memcpy(m_cols_ai.bitmap, ptr_after_width, (m_width + 7) / 8); ptr_after_width+= (m_width + 7) / 8; - DBUG_DUMP("m_cols_ai", (char*) m_cols_ai.bitmap, no_bytes_in_map(&m_cols_ai)); + DBUG_DUMP("m_cols_ai", (uchar*) m_cols_ai.bitmap, + no_bytes_in_map(&m_cols_ai)); } else { @@ -5724,13 +5737,13 @@ Rows_log_event::Rows_log_event(const char *buf, uint event_len, } } - const byte* const ptr_rows_data= (const byte*) ptr_after_width; + const uchar* const ptr_rows_data= (const uchar*) ptr_after_width; - my_size_t const data_size= event_len - (ptr_rows_data - (const byte *) buf); + size_t const data_size= event_len - (ptr_rows_data - (const uchar *) buf); DBUG_PRINT("info",("m_table_id: %lu m_flags: %d m_width: %lu data_size: %lu", m_table_id, m_flags, m_width, data_size)); - m_rows_buf= (byte*)my_malloc(data_size, MYF(MY_WME)); + m_rows_buf= (uchar*) my_malloc(data_size, MYF(MY_WME)); if (likely((bool)m_rows_buf)) { m_rows_end= m_rows_buf + data_size; @@ -5748,15 +5761,15 @@ Rows_log_event::~Rows_log_event() if (m_cols.bitmap == m_bitbuf) // no my_malloc happened m_cols.bitmap= 0; // so no my_free in bitmap_free bitmap_free(&m_cols); // To pair with bitmap_init(). - my_free((gptr)m_rows_buf, MYF(MY_ALLOW_ZERO_PTR)); + my_free((uchar*)m_rows_buf, MYF(MY_ALLOW_ZERO_PTR)); } int Rows_log_event::get_data_size() { int const type_code= get_type_code(); - char buf[sizeof(m_width)+1]; - char *end= net_store_length(buf, (m_width + 7) / 8); + uchar buf[sizeof(m_width)+1]; + uchar *end= net_store_length(buf, (m_width + 7) / 8); DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master", return 6 + no_bytes_in_map(&m_cols) + (end - buf) + @@ -5775,7 +5788,7 @@ int Rows_log_event::get_data_size() #ifndef MYSQL_CLIENT -int Rows_log_event::do_add_row_data(byte *row_data, my_size_t length) +int Rows_log_event::do_add_row_data(uchar *row_data, size_t length) { /* When the table has a primary key, we would probably want, by default, to @@ -5790,7 +5803,7 @@ int Rows_log_event::do_add_row_data(byte *row_data, my_size_t length) trigger false warnings. */ #ifndef HAVE_purify - DBUG_DUMP("row_data", (const char*)row_data, min(length, 32)); + DBUG_DUMP("row_data", row_data, min(length, 32)); #endif DBUG_ASSERT(m_rows_buf <= m_rows_cur); @@ -5798,14 +5811,14 @@ int Rows_log_event::do_add_row_data(byte *row_data, my_size_t length) DBUG_ASSERT(m_rows_cur <= m_rows_end); /* The cast will always work since m_rows_cur <= m_rows_end */ - if (static_cast<my_size_t>(m_rows_end - m_rows_cur) <= length) + if (static_cast<size_t>(m_rows_end - m_rows_cur) <= length) { - my_size_t const block_size= 1024; + size_t const block_size= 1024; my_ptrdiff_t const cur_size= m_rows_cur - m_rows_buf; my_ptrdiff_t const new_alloc= block_size * ((cur_size + length + block_size - 1) / block_size); - byte* const new_buf= (byte*)my_realloc((gptr)m_rows_buf, (uint) new_alloc, + uchar* const new_buf= (uchar*)my_realloc((uchar*)m_rows_buf, (uint) new_alloc, MYF(MY_ALLOW_ZERO_PTR|MY_WME)); if (unlikely(!new_buf)) DBUG_RETURN(HA_ERR_OUT_OF_MEM); @@ -5837,7 +5850,7 @@ int Rows_log_event::do_apply_event(RELAY_LOG_INFO const *rli) { DBUG_ENTER("Rows_log_event::do_apply_event(st_relay_log_info*)"); int error= 0; - char const *row_start= (char const *)m_rows_buf; + uchar const *row_start= m_rows_buf; /* If m_table_id == ~0UL, then we have a dummy event that does not @@ -6048,15 +6061,15 @@ int Rows_log_event::do_apply_event(RELAY_LOG_INFO const *rli) const_cast<RELAY_LOG_INFO*>(rli)->set_flag(RELAY_LOG_INFO::IN_STMT); error= do_before_row_operations(table); - while (error == 0 && row_start < (const char*) m_rows_end) + while (error == 0 && row_start < m_rows_end) { - char const *row_end= NULL; + uchar const *row_end= NULL; if ((error= do_prepare_row(thd, rli, table, row_start, &row_end))) break; // We should perform the after-row operation even in // the case of error DBUG_ASSERT(row_end != NULL); // cannot happen - DBUG_ASSERT(row_end <= (const char*)m_rows_end); + DBUG_ASSERT(row_end <= m_rows_end); /* in_use can have been set to NULL in close_tables_for_reopen */ THD* old_thd= table->in_use; @@ -6237,7 +6250,7 @@ Rows_log_event::do_update_pos(RELAY_LOG_INFO *rli) #ifndef MYSQL_CLIENT bool Rows_log_event::write_data_header(IO_CACHE *file) { - byte buf[ROWS_HEADER_LEN]; // No need to init the buffer + uchar buf[ROWS_HEADER_LEN]; // No need to init the buffer DBUG_ASSERT(m_table_id != ~0UL); DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master", { @@ -6256,34 +6269,30 @@ bool Rows_log_event::write_data_body(IO_CACHE*file) Note that this should be the number of *bits*, not the number of bytes. */ - char sbuf[sizeof(m_width)]; + uchar sbuf[sizeof(m_width)]; my_ptrdiff_t const data_size= m_rows_cur - m_rows_buf; bool res= false; + uchar *const sbuf_end= net_store_length(sbuf, (size_t) m_width); + DBUG_ASSERT(static_cast<size_t>(sbuf_end - sbuf) <= sizeof(sbuf)); - char *const sbuf_end= net_store_length((char*) sbuf, (uint) m_width); - DBUG_ASSERT(static_cast<my_size_t>(sbuf_end - sbuf) <= sizeof(sbuf)); - - DBUG_DUMP("m_width", sbuf, sbuf_end - sbuf); - res= res || my_b_safe_write(file, - reinterpret_cast<byte*>(sbuf), - sbuf_end - sbuf); + DBUG_DUMP("m_width", sbuf, (size_t) (sbuf_end - sbuf)); + res= res || my_b_safe_write(file, sbuf, (size_t) (sbuf_end - sbuf)); - DBUG_DUMP("m_cols", (char*) m_cols.bitmap, no_bytes_in_map(&m_cols)); - res= res || my_b_safe_write(file, - reinterpret_cast<byte*>(m_cols.bitmap), + DBUG_DUMP("m_cols", (uchar*) m_cols.bitmap, no_bytes_in_map(&m_cols)); + res= res || my_b_safe_write(file, (uchar*) m_cols.bitmap, no_bytes_in_map(&m_cols)); /* TODO[refactor write]: Remove the "down cast" here (and elsewhere). */ if (get_type_code() == UPDATE_ROWS_EVENT) { - DBUG_DUMP("m_cols_ai", (char*) m_cols_ai.bitmap, no_bytes_in_map(&m_cols_ai)); - res= res || my_b_safe_write(file, - reinterpret_cast<byte*>(m_cols_ai.bitmap), + DBUG_DUMP("m_cols_ai", (uchar*) m_cols_ai.bitmap, + no_bytes_in_map(&m_cols_ai)); + res= res || my_b_safe_write(file, (uchar*) m_cols_ai.bitmap, no_bytes_in_map(&m_cols_ai)); } - DBUG_DUMP("rows",(const char *) m_rows_buf, data_size); - res= res || my_b_safe_write(file, m_rows_buf, (uint) data_size); + DBUG_DUMP("rows", m_rows_buf, data_size); + res= res || my_b_safe_write(file, m_rows_buf, (size_t) data_size); return res; @@ -6296,7 +6305,7 @@ void Rows_log_event::pack_info(Protocol *protocol) char buf[256]; char const *const flagstr= get_flags(STMT_END_F) ? " flags: STMT_END_F" : ""; - my_size_t bytes= my_snprintf(buf, sizeof(buf), + size_t bytes= my_snprintf(buf, sizeof(buf), "table_id: %lu%s", m_table_id, flagstr); protocol->store(buf, bytes, &my_charset_bin); } @@ -6368,7 +6377,7 @@ Table_map_log_event::Table_map_log_event(THD *thd, TABLE *tbl, ulong tid, m_data_size+= 1 + m_colcnt; // COLCNT and column types /* If malloc fails, catched in is_valid() */ - if ((m_memory= my_malloc(m_colcnt, MYF(MY_WME)))) + if ((m_memory= (uchar*) my_malloc(m_colcnt, MYF(MY_WME)))) { m_coltype= reinterpret_cast<uchar*>(m_memory); for (unsigned int i= 0 ; i < m_table->s->fields ; ++i) @@ -6403,7 +6412,7 @@ Table_map_log_event::Table_map_log_event(const char *buf, uint event_len, trigger false warnings. */ #ifndef HAVE_purify - DBUG_DUMP("event buffer", buf, event_len); + DBUG_DUMP("event buffer", (uchar*) buf, event_len); #endif /* Read the post-header */ @@ -6431,29 +6440,29 @@ Table_map_log_event::Table_map_log_event(const char *buf, uint event_len, const char *const vpart= buf + common_header_len + post_header_len; /* Extract the length of the various parts from the buffer */ - byte const *const ptr_dblen= (byte const*)vpart + 0; + uchar const *const ptr_dblen= (uchar const*)vpart + 0; m_dblen= *(uchar*) ptr_dblen; /* Length of database name + counter + terminating null */ - byte const *const ptr_tbllen= ptr_dblen + m_dblen + 2; + uchar const *const ptr_tbllen= ptr_dblen + m_dblen + 2; m_tbllen= *(uchar*) ptr_tbllen; /* Length of table name + counter + terminating null */ - byte const *const ptr_colcnt= ptr_tbllen + m_tbllen + 2; + uchar const *const ptr_colcnt= ptr_tbllen + m_tbllen + 2; uchar *ptr_after_colcnt= (uchar*) ptr_colcnt; m_colcnt= net_field_length(&ptr_after_colcnt); DBUG_PRINT("info",("m_dblen: %lu off: %ld m_tbllen: %lu off: %ld m_colcnt: %lu off: %ld", - m_dblen, (long) (ptr_dblen-(const byte*)vpart), - m_tbllen, (long) (ptr_tbllen-(const byte*)vpart), - m_colcnt, (long) (ptr_colcnt-(const byte*)vpart))); + m_dblen, (long) (ptr_dblen-(const uchar*)vpart), + m_tbllen, (long) (ptr_tbllen-(const uchar*)vpart), + m_colcnt, (long) (ptr_colcnt-(const uchar*)vpart))); /* Allocate mem for all fields in one go. If fails, catched in is_valid() */ - m_memory= my_multi_malloc(MYF(MY_WME), - &m_dbnam, m_dblen + 1, - &m_tblnam, m_tbllen + 1, - &m_coltype, m_colcnt, - NULL); + m_memory= (uchar*) my_multi_malloc(MYF(MY_WME), + &m_dbnam, (uint) m_dblen + 1, + &m_tblnam, (uint) m_tbllen + 1, + &m_coltype, (uint) m_colcnt, + NullS); if (m_memory) { @@ -6486,8 +6495,11 @@ Table_map_log_event::~Table_map_log_event() #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) int Table_map_log_event::do_apply_event(RELAY_LOG_INFO const *rli) { + RPL_TABLE_LIST *table_list; + char *db_mem, *tname_mem; + size_t dummy_len; + void *memory; DBUG_ENTER("Table_map_log_event::do_apply_event(st_relay_log_info*)"); - DBUG_ASSERT(rli->sql_thd == thd); /* Step the query id to mark what columns that are actually used. */ @@ -6495,19 +6507,13 @@ int Table_map_log_event::do_apply_event(RELAY_LOG_INFO const *rli) thd->query_id= next_query_id(); pthread_mutex_unlock(&LOCK_thread_count); - RPL_TABLE_LIST *table_list; - char *db_mem, *tname_mem; - void *const memory= - my_multi_malloc(MYF(MY_WME), - &table_list, sizeof(RPL_TABLE_LIST), - &db_mem, NAME_LEN + 1, - &tname_mem, NAME_LEN + 1, - NULL); - - if (memory == NULL) + if (!(memory= my_multi_malloc(MYF(MY_WME), + &table_list, (uint) sizeof(RPL_TABLE_LIST), + &db_mem, (uint) NAME_LEN + 1, + &tname_mem, (uint) NAME_LEN + 1, + NullS))) DBUG_RETURN(HA_ERR_OUT_OF_MEM); - uint dummy_len; bzero(table_list, sizeof(*table_list)); table_list->db = db_mem; table_list->alias= table_list->table_name = tname_mem; @@ -6523,7 +6529,7 @@ int Table_map_log_event::do_apply_event(RELAY_LOG_INFO const *rli) if (!rpl_filter->db_ok(table_list->db) || (rpl_filter->is_on() && !rpl_filter->tables_ok("", table_list))) { - my_free((gptr) memory, MYF(MY_WME)); + my_free(memory, MYF(MY_WME)); } else { @@ -6618,7 +6624,7 @@ int Table_map_log_event::do_apply_event(RELAY_LOG_INFO const *rli) DBUG_RETURN(error); err: - my_free((gptr) memory, MYF(MY_WME)); + my_free(memory, MYF(MY_WME)); DBUG_RETURN(error); } @@ -6634,7 +6640,7 @@ int Table_map_log_event::do_update_pos(RELAY_LOG_INFO *rli) bool Table_map_log_event::write_data_header(IO_CACHE *file) { DBUG_ASSERT(m_table_id != ~0UL); - byte buf[TABLE_MAP_HEADER_LEN]; + uchar buf[TABLE_MAP_HEADER_LEN]; DBUG_EXECUTE_IF("old_row_based_repl_4_byte_map_id_master", { int4store(buf + 0, m_table_id); @@ -6654,20 +6660,19 @@ bool Table_map_log_event::write_data_body(IO_CACHE *file) DBUG_ASSERT(m_dblen < 128); DBUG_ASSERT(m_tbllen < 128); - byte const dbuf[]= { (byte) m_dblen }; - byte const tbuf[]= { (byte) m_tbllen }; + uchar const dbuf[]= { (uchar) m_dblen }; + uchar const tbuf[]= { (uchar) m_tbllen }; - char cbuf[sizeof(m_colcnt)]; - char *const cbuf_end= net_store_length((char*) cbuf, (uint) m_colcnt); - DBUG_ASSERT(static_cast<my_size_t>(cbuf_end - cbuf) <= sizeof(cbuf)); + uchar cbuf[sizeof(m_colcnt)]; + uchar *const cbuf_end= net_store_length(cbuf, (size_t) m_colcnt); + DBUG_ASSERT(static_cast<size_t>(cbuf_end - cbuf) <= sizeof(cbuf)); return (my_b_safe_write(file, dbuf, sizeof(dbuf)) || - my_b_safe_write(file, (const byte*)m_dbnam, m_dblen+1) || + my_b_safe_write(file, (const uchar*)m_dbnam, m_dblen+1) || my_b_safe_write(file, tbuf, sizeof(tbuf)) || - my_b_safe_write(file, (const byte*)m_tblnam, m_tbllen+1) || - my_b_safe_write(file, reinterpret_cast<byte*>(cbuf), - cbuf_end - (char*) cbuf) || - my_b_safe_write(file, reinterpret_cast<byte*>(m_coltype), m_colcnt)); + my_b_safe_write(file, (const uchar*)m_tblnam, m_tbllen+1) || + my_b_safe_write(file, cbuf, (size_t) (cbuf_end - cbuf)) || + my_b_safe_write(file, m_coltype, m_colcnt)); } #endif @@ -6682,7 +6687,7 @@ bool Table_map_log_event::write_data_body(IO_CACHE *file) void Table_map_log_event::pack_info(Protocol *protocol) { char buf[256]; - my_size_t bytes= my_snprintf(buf, sizeof(buf), + size_t bytes= my_snprintf(buf, sizeof(buf), "table_id: %lu (%s.%s)", m_table_id, m_dbnam, m_tblnam); protocol->store(buf, bytes, &my_charset_bin); @@ -6818,8 +6823,8 @@ int Write_rows_log_event::do_after_row_operations(TABLE *table, int error) int Write_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli, TABLE *table, - char const *const row_start, - char const **const row_end) + uchar const *const row_start, + uchar const **const row_end) { DBUG_ASSERT(table != NULL); DBUG_ASSERT(row_start && row_end); @@ -6884,7 +6889,7 @@ namespace { */ static int copy_extra_record_fields(TABLE *table, - my_size_t master_reclength, + size_t master_reclength, my_ptrdiff_t master_fields) { DBUG_PRINT("info", ("Copying to 0x%lx " @@ -7026,7 +7031,7 @@ replace_record(THD *thd, TABLE *table, auto_afree_ptr<char> key(NULL); #ifndef DBUG_OFF - DBUG_DUMP("record[0]",(const char *) table->record[0], table->s->reclength); + DBUG_DUMP("record[0]", table->record[0], table->s->reclength); DBUG_PRINT_BITSET("debug", "write_set = %s", table->write_set); DBUG_PRINT_BITSET("debug", "read_set = %s", table->read_set); #endif @@ -7077,9 +7082,9 @@ replace_record(THD *thd, TABLE *table, DBUG_RETURN(ENOMEM); } - key_copy((byte*)key.get(), table->record[0], table->key_info + keynum, 0); + key_copy((uchar*)key.get(), table->record[0], table->key_info + keynum, 0); error= table->file->index_read_idx(table->record[1], keynum, - (const byte*)key.get(), + (const uchar*)key.get(), HA_WHOLE_KEY, HA_READ_KEY_EXACT); if (error) @@ -7177,7 +7182,7 @@ static bool record_compare(TABLE *table) */ bool result= FALSE; - byte saved_x[2], saved_filler[2]; + uchar saved_x[2], saved_filler[2]; if (table->s->null_bytes > 0) { @@ -7260,15 +7265,15 @@ record_compare_exit: <code>table->record[1]</code>, error code otherwise. */ -static int find_and_fetch_row(TABLE *table, byte *key) +static int find_and_fetch_row(TABLE *table, uchar *key) { - DBUG_ENTER("find_and_fetch_row(TABLE *table, byte *key, byte *record)"); + DBUG_ENTER("find_and_fetch_row(TABLE *table, uchar *key, uchar *record)"); DBUG_PRINT("enter", ("table: 0x%lx, key: 0x%lx record: 0x%lx", (long) table, (long) key, (long) table->record[1])); DBUG_ASSERT(table->in_use != NULL); - DBUG_DUMP("record[0]",(const char *) table->record[0], table->s->reclength); + DBUG_DUMP("record[0]", table->record[0], table->s->reclength); if ((table->file->ha_table_flags() & HA_PRIMARY_KEY_REQUIRED_FOR_POSITION) && table->s->primary_key < MAX_KEY) @@ -7317,8 +7322,8 @@ static int find_and_fetch_row(TABLE *table, byte *key) trigger false warnings. */ #ifndef HAVE_purify - DBUG_DUMP("table->record[0]", (const char *)table->record[0], table->s->reclength); - DBUG_DUMP("table->record[1]", (const char *)table->record[1], table->s->reclength); + DBUG_DUMP("table->record[0]", table->record[0], table->s->reclength); + DBUG_DUMP("table->record[1]", table->record[1], table->s->reclength); #endif /* @@ -7343,8 +7348,8 @@ static int find_and_fetch_row(TABLE *table, byte *key) trigger false warnings. */ #ifndef HAVE_purify - DBUG_DUMP("table->record[0]", (const char *)table->record[0], table->s->reclength); - DBUG_DUMP("table->record[1]", (const char *)table->record[1], table->s->reclength); + DBUG_DUMP("table->record[0]", table->record[0], table->s->reclength); + DBUG_DUMP("table->record[1]", table->record[1], table->s->reclength); #endif /* Below is a minor "optimization". If the key (i.e., key number @@ -7412,11 +7417,10 @@ static int find_and_fetch_row(TABLE *table, byte *key) { error= table->file->rnd_next(table->record[1]); - DBUG_DUMP("record[0]",(const char *) table->record[0], table->s->reclength); - DBUG_DUMP("record[1]",(const char *) table->record[1], table->s->reclength); + DBUG_DUMP("record[0]", table->record[0], table->s->reclength); + DBUG_DUMP("record[1]", table->record[1], table->s->reclength); - switch (error) - { + switch (error) { case 0: case HA_ERR_RECORD_DELETED: break; @@ -7501,16 +7505,17 @@ int Delete_rows_log_event::do_before_row_operations(TABLE *table) if (table->s->keys > 0) { - m_memory= - my_multi_malloc(MYF(MY_WME), - &m_after_image, table->s->reclength, - &m_key, table->key_info->key_length, - NULL); + m_memory= (uchar*) my_multi_malloc(MYF(MY_WME), + &m_after_image, + (uint) table->s->reclength, + &m_key, + (uint) table->key_info->key_length, + NullS); } else { - m_after_image= (byte*)my_malloc(table->s->reclength, MYF(MY_WME)); - m_memory= (gptr)m_after_image; + m_after_image= (uchar*) my_malloc(table->s->reclength, MYF(MY_WME)); + m_memory= (uchar*)m_after_image; m_key= NULL; } if (!m_memory) @@ -7533,8 +7538,8 @@ int Delete_rows_log_event::do_after_row_operations(TABLE *table, int error) int Delete_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli, TABLE *table, - char const *const row_start, - char const **const row_end) + uchar const *const row_start, + uchar const **const row_end) { int error; DBUG_ASSERT(row_start && row_end); @@ -7673,16 +7678,17 @@ int Update_rows_log_event::do_before_row_operations(TABLE *table) if (table->s->keys > 0) { - m_memory= - my_multi_malloc(MYF(MY_WME), - &m_after_image, table->s->reclength, - &m_key, table->key_info->key_length, - NULL); + m_memory= (uchar*) my_multi_malloc(MYF(MY_WME), + &m_after_image, + (uint) table->s->reclength, + &m_key, + (uint) table->key_info->key_length, + NullS); } else { - m_after_image= (byte*)my_malloc(table->s->reclength, MYF(MY_WME)); - m_memory= (gptr)m_after_image; + m_after_image= (uchar*) my_malloc(table->s->reclength, MYF(MY_WME)); + m_memory= m_after_image; m_key= NULL; } if (!m_memory) @@ -7707,8 +7713,8 @@ int Update_rows_log_event::do_after_row_operations(TABLE *table, int error) int Update_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli, TABLE *table, - char const *const row_start, - char const **const row_end) + uchar const *const row_start, + uchar const **const row_end) { int error; DBUG_ASSERT(row_start && row_end); @@ -7728,7 +7734,7 @@ int Update_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli, error= unpack_row(rli, table, m_width, row_start, &m_cols, row_end, &m_master_reclength, table->read_set, UPDATE_ROWS_EVENT); store_record(table, record[1]); - char const *next_start = *row_end; + uchar const *next_start = *row_end; /* m_after_image is the after image for the update */ error= unpack_row(rli, table, m_width, next_start, &m_cols_ai, row_end, &m_master_reclength, table->write_set, UPDATE_ROWS_EVENT); @@ -7740,8 +7746,8 @@ int Update_rows_log_event::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli, trigger false warnings. */ #ifndef HAVE_purify - DBUG_DUMP("record[0]", (const char *)table->record[0], table->s->reclength); - DBUG_DUMP("m_after_image", (const char *)m_after_image, table->s->reclength); + DBUG_DUMP("record[0]", table->record[0], table->s->reclength); + DBUG_DUMP("m_after_image", m_after_image, table->s->reclength); #endif /* @@ -7845,7 +7851,7 @@ Incident_log_event::description() const DBUG_PRINT("info", ("m_incident: %d", m_incident)); DBUG_ASSERT(0 <= m_incident); - DBUG_ASSERT((my_size_t) m_incident <= sizeof(description)/sizeof(*description)); + DBUG_ASSERT((size_t) m_incident <= sizeof(description)/sizeof(*description)); return description[m_incident]; } @@ -7855,7 +7861,7 @@ Incident_log_event::description() const void Incident_log_event::pack_info(Protocol *protocol) { char buf[256]; - my_size_t bytes; + size_t bytes; if (m_message.length > 0) bytes= my_snprintf(buf, sizeof(buf), "#%d (%s)", m_incident, description()); @@ -7899,7 +7905,7 @@ Incident_log_event::write_data_header(IO_CACHE *file) { DBUG_ENTER("Incident_log_event::write_data_header"); DBUG_PRINT("enter", ("m_incident: %d", m_incident)); - byte buf[sizeof(int16)]; + uchar buf[sizeof(int16)]; int2store(buf, (int16) m_incident); DBUG_RETURN(my_b_safe_write(file, buf, sizeof(buf))); } diff --git a/sql/log_event.h b/sql/log_event.h index bb69043969d..16300e7bb55 100644 --- a/sql/log_event.h +++ b/sql/log_event.h @@ -753,7 +753,7 @@ public: static void operator delete(void *ptr, size_t size) { - my_free((gptr) ptr, MYF(MY_WME|MY_ALLOW_ZERO_PTR)); + my_free((uchar*) ptr, MYF(MY_WME|MY_ALLOW_ZERO_PTR)); } /* Placement version of the above operators */ @@ -1041,7 +1041,7 @@ public: ~Query_log_event() { if (data_buf) - my_free((gptr) data_buf, MYF(0)); + my_free((uchar*) data_buf, MYF(0)); } Log_event_type get_type_code() { return QUERY_EVENT; } #ifndef MYSQL_CLIENT @@ -1363,7 +1363,7 @@ public: Format_description_log_event(uint8 binlog_ver, const char* server_ver=0); Format_description_log_event(const char* buf, uint event_len, const Format_description_log_event* description_event); - ~Format_description_log_event() { my_free((gptr)post_header_len, MYF(0)); } + ~Format_description_log_event() { my_free((uchar*)post_header_len, MYF(0)); } Log_event_type get_type_code() { return FORMAT_DESCRIPTION_EVENT;} #ifndef MYSQL_CLIENT bool write(IO_CACHE* file); @@ -1646,7 +1646,7 @@ public: ~Rotate_log_event() { if (flags & DUP_NAME) - my_free((gptr) new_log_ident, MYF(MY_ALLOW_ZERO_PTR)); + my_free((uchar*) new_log_ident, MYF(MY_ALLOW_ZERO_PTR)); } Log_event_type get_type_code() { return ROTATE_EVENT;} int get_data_size() { return ident_len + ROTATE_HEADER_LEN;} @@ -2070,20 +2070,20 @@ private: #endif #ifndef MYSQL_CLIENT - TABLE *m_table; + TABLE *m_table; #endif char const *m_dbnam; - my_size_t m_dblen; + size_t m_dblen; char const *m_tblnam; - my_size_t m_tbllen; + size_t m_tbllen; ulong m_colcnt; - unsigned char *m_coltype; + uchar *m_coltype; - gptr m_memory; + uchar *m_memory; ulong m_table_id; flag_set m_flags; - my_size_t m_data_size; + size_t m_data_size; }; @@ -2161,7 +2161,7 @@ public: #endif #ifndef MYSQL_CLIENT - int add_row_data(byte *data, my_size_t length) + int add_row_data(uchar *data, size_t length) { return do_add_row_data(data,length); } @@ -2171,7 +2171,7 @@ public: virtual int get_data_size(); MY_BITMAP const *get_cols() const { return &m_cols; } - my_size_t get_width() const { return m_width; } + size_t get_width() const { return m_width; } ulong get_table_id() const { return m_table_id; } #ifndef MYSQL_CLIENT @@ -2210,7 +2210,7 @@ protected: #endif #ifndef MYSQL_CLIENT - virtual int do_add_row_data(byte *data, my_size_t length); + virtual int do_add_row_data(uchar *data, size_t length); #endif #ifndef MYSQL_CLIENT @@ -2234,9 +2234,9 @@ protected: uint32 m_bitbuf[128/(sizeof(uint32)*8)]; uint32 m_bitbuf_ai[128/(sizeof(uint32)*8)]; - byte *m_rows_buf; /* The rows in packed format */ - byte *m_rows_cur; /* One-after the end of the data */ - byte *m_rows_end; /* One-after the end of the allocated space */ + uchar *m_rows_buf; /* The rows in packed format */ + uchar *m_rows_cur; /* One-after the end of the data */ + uchar *m_rows_end; /* One-after the end of the allocated space */ flag_set m_flags; /* Flags for row-level events */ @@ -2294,7 +2294,8 @@ private: Error code, if something went wrong, 0 otherwise. */ virtual int do_prepare_row(THD*, RELAY_LOG_INFO const*, TABLE*, - char const *row_start, char const **row_end) = 0; + uchar const *row_start, + uchar const **row_end) = 0; /* Primitive to do the actual execution necessary for a row. @@ -2342,9 +2343,9 @@ public: bool is_transactional, MY_BITMAP *cols, uint fields, - const byte *before_record + const uchar *before_record __attribute__((unused)), - const byte *after_record) + const uchar *after_record) { return thd->binlog_write_row(table, is_transactional, cols, fields, after_record); @@ -2359,13 +2360,13 @@ private: #endif #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) - gptr m_memory; - byte *m_after_image; + uchar *m_memory; + uchar *m_after_image; virtual int do_before_row_operations(TABLE *table); virtual int do_after_row_operations(TABLE *table, int error); virtual int do_prepare_row(THD*, RELAY_LOG_INFO const*, TABLE*, - char const *row_start, char const **row_end); + uchar const *row_start, uchar const **row_end); virtual int do_exec_row(TABLE *table); #endif }; @@ -2417,8 +2418,8 @@ public: bool is_transactional, MY_BITMAP *cols, uint fields, - const byte *before_record, - const byte *after_record) + const uchar *before_record, + const uchar *after_record) { return thd->binlog_update_row(table, is_transactional, cols, fields, before_record, after_record); @@ -2438,14 +2439,14 @@ protected: #endif #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) - gptr m_memory; - byte *m_key; - byte *m_after_image; + uchar *m_memory; + uchar *m_key; + uchar *m_after_image; virtual int do_before_row_operations(TABLE *table); virtual int do_after_row_operations(TABLE *table, int error); virtual int do_prepare_row(THD*, RELAY_LOG_INFO const*, TABLE*, - char const *row_start, char const **row_end); + uchar const *row_start, uchar const **row_end); virtual int do_exec_row(TABLE *table); #endif /* !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) */ }; @@ -2492,8 +2493,8 @@ public: bool is_transactional, MY_BITMAP *cols, uint fields, - const byte *before_record, - const byte *after_record + const uchar *before_record, + const uchar *after_record __attribute__((unused))) { return thd->binlog_delete_row(table, is_transactional, @@ -2509,14 +2510,14 @@ protected: #endif #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) - gptr m_memory; - byte *m_key; - byte *m_after_image; + uchar *m_memory; + uchar *m_key; + uchar *m_after_image; virtual int do_before_row_operations(TABLE *table); virtual int do_after_row_operations(TABLE *table, int error); virtual int do_prepare_row(THD*, RELAY_LOG_INFO const*, TABLE*, - char const *row_start, char const **row_end); + uchar const *row_start, uchar const **row_end); virtual int do_exec_row(TABLE *table); #endif }; diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc index 5153dff0e55..e6a9dd50c08 100644 --- a/sql/log_event_old.cc +++ b/sql/log_event_old.cc @@ -8,8 +8,8 @@ int Write_rows_log_event_old::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli, TABLE *table, - char const *row_start, - char const **row_end) + uchar const *row_start, + uchar const **row_end) { DBUG_ASSERT(table != NULL); DBUG_ASSERT(row_start && row_end); @@ -28,8 +28,8 @@ int Delete_rows_log_event_old::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli, TABLE *table, - char const *row_start, - char const **row_end) + uchar const *row_start, + uchar const **row_end) { int error; DBUG_ASSERT(row_start && row_end); @@ -61,8 +61,8 @@ Delete_rows_log_event_old::do_prepare_row(THD *thd, int Update_rows_log_event_old::do_prepare_row(THD *thd, RELAY_LOG_INFO const *rli, TABLE *table, - char const *row_start, - char const **row_end) + uchar const *row_start, + uchar const **row_end) { int error; DBUG_ASSERT(row_start && row_end); @@ -84,9 +84,8 @@ int Update_rows_log_event_old::do_prepare_row(THD *thd, row_start, &m_cols, row_end, &m_master_reclength, table->write_set, PRE_GA_UPDATE_ROWS_EVENT); - DBUG_DUMP("record[0]", (const char*) table->record[0], table->s->reclength); - DBUG_DUMP("m_after_image", (const char *) m_after_image, table->s->reclength); - + DBUG_DUMP("record[0]", table->record[0], table->s->reclength); + DBUG_DUMP("m_after_image", m_after_image, table->s->reclength); /* If we will access rows using the random access method, m_key will diff --git a/sql/log_event_old.h b/sql/log_event_old.h index 87b11aea3a3..7c2932360f5 100644 --- a/sql/log_event_old.h +++ b/sql/log_event_old.h @@ -50,7 +50,7 @@ private: #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) virtual int do_prepare_row(THD*, RELAY_LOG_INFO const*, TABLE*, - char const *row_start, char const **row_end); + uchar const *row_start, uchar const **row_end); #endif }; @@ -84,7 +84,7 @@ private: #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) virtual int do_prepare_row(THD*, RELAY_LOG_INFO const*, TABLE*, - char const *row_start, char const **row_end); + uchar const *row_start, uchar const **row_end); #endif /* !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) */ }; @@ -118,7 +118,7 @@ private: #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) virtual int do_prepare_row(THD*, RELAY_LOG_INFO const*, TABLE*, - char const *row_start, char const **row_end); + uchar const *row_start, uchar const **row_end); #endif }; diff --git a/sql/mf_iocache.cc b/sql/mf_iocache.cc index f237f15dbc9..5d9d6d834b4 100644 --- a/sql/mf_iocache.cc +++ b/sql/mf_iocache.cc @@ -40,8 +40,8 @@ extern "C" { ** Returns 0 if record read */ -int _my_b_net_read(register IO_CACHE *info, byte *Buffer, - uint Count __attribute__((unused))) +int _my_b_net_read(register IO_CACHE *info, uchar *Buffer, + size_t Count __attribute__((unused))) { ulong read_length; NET *net= &(current_thd)->net; @@ -61,7 +61,7 @@ int _my_b_net_read(register IO_CACHE *info, byte *Buffer, DBUG_RETURN(1); } /* to set up stuff for my_b_get (no _) */ - info->read_end = (info->read_pos = (byte*) net->read_pos) + read_length; + info->read_end = (info->read_pos = (uchar*) net->read_pos) + read_length; Buffer[0] = info->read_pos[0]; /* length is always 1 */ /* diff --git a/sql/my_decimal.cc b/sql/my_decimal.cc index 8823fac3393..1f0ebf32795 100644 --- a/sql/my_decimal.cc +++ b/sql/my_decimal.cc @@ -118,7 +118,7 @@ int my_decimal2string(uint mask, const my_decimal *d, E_DEC_OVERFLOW */ -int my_decimal2binary(uint mask, const my_decimal *d, char *bin, int prec, +int my_decimal2binary(uint mask, const my_decimal *d, uchar *bin, int prec, int scale) { int err1= E_DEC_OK, err2; @@ -244,7 +244,7 @@ print_decimal(const my_decimal *dec) /* print decimal with its binary representation */ void -print_decimal_buff(const my_decimal *dec, const byte* ptr, int length) +print_decimal_buff(const my_decimal *dec, const uchar* ptr, int length) { print_decimal(dec); fprintf(DBUG_FILE, "Record: "); diff --git a/sql/my_decimal.h b/sql/my_decimal.h index 17eb75cfdc5..d6cefb3e080 100644 --- a/sql/my_decimal.h +++ b/sql/my_decimal.h @@ -110,7 +110,7 @@ public: #ifndef DBUG_OFF void print_decimal(const my_decimal *dec); -void print_decimal_buff(const my_decimal *dec, const byte* ptr, int length); +void print_decimal_buff(const my_decimal *dec, const uchar* ptr, int length); const char *dbug_decimal_as_string(char *buff, const my_decimal *val); #else #define dbug_decimal_as_string(A) NULL @@ -200,16 +200,15 @@ void my_decimal2decimal(const my_decimal *from, my_decimal *to) } -int my_decimal2binary(uint mask, const my_decimal *d, char *bin, int prec, +int my_decimal2binary(uint mask, const my_decimal *d, uchar *bin, int prec, int scale); inline -int binary2my_decimal(uint mask, const char *bin, my_decimal *d, int prec, +int binary2my_decimal(uint mask, const uchar *bin, my_decimal *d, int prec, int scale) { - return check_result(mask, bin2decimal((char *)bin, (decimal_t*) d, prec, - scale)); + return check_result(mask, bin2decimal(bin, (decimal_t*) d, prec, scale)); } diff --git a/sql/mysql_priv.h b/sql/mysql_priv.h index f0a4ef45219..f5d66696cab 100644 --- a/sql/mysql_priv.h +++ b/sql/mysql_priv.h @@ -73,16 +73,16 @@ extern const char *primary_key_name; #include "unireg.h" void init_sql_alloc(MEM_ROOT *root, uint block_size, uint pre_alloc_size); -gptr sql_alloc(unsigned size); -gptr sql_calloc(unsigned size); +void *sql_alloc(size_t); +void *sql_calloc(size_t); char *sql_strdup(const char *str); -char *sql_strmake(const char *str,uint len); -gptr sql_memdup(const void * ptr,unsigned size); +char *sql_strmake(const char *str, size_t len); +void *sql_memdup(const void * ptr, size_t size); void sql_element_free(void *ptr); -char *sql_strmake_with_convert(const char *str, uint32 arg_length, +char *sql_strmake_with_convert(const char *str, size_t arg_length, CHARSET_INFO *from_cs, - uint32 max_res_length, - CHARSET_INFO *to_cs, uint32 *result_length); + size_t max_res_length, + CHARSET_INFO *to_cs, size_t *result_length); uint kill_one_thread(THD *thd, ulong id, bool only_kill_query); void sql_kill(THD *thd, ulong id, bool only_kill_query); bool net_request_file(NET* net, const char* fname); @@ -91,15 +91,15 @@ char* query_table_status(THD *thd,const char *db,const char *table_name); void net_set_write_timeout(NET *net, uint timeout); void net_set_read_timeout(NET *net, uint timeout); -#define x_free(A) { my_free((gptr) (A),MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR)); } -#define safeFree(x) { if(x) { my_free((gptr) x,MYF(0)); x = NULL; } } +#define x_free(A) { my_free((uchar*) (A),MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR)); } +#define safeFree(x) { if(x) { my_free((uchar*) x,MYF(0)); x = NULL; } } #define PREV_BITS(type,A) ((type) (((type) 1 << (A)) -1)) #define all_bits_set(A,B) ((A) & (B) != (B)) #define WARN_DEPRECATED(Thd,Ver,Old,New) \ do { \ DBUG_ASSERT(strncmp(Ver, MYSQL_SERVER_VERSION, sizeof(Ver)-1) > 0); \ - if (((gptr)Thd) != NULL) \ + if (((uchar*)Thd) != NULL) \ push_warning_printf(((THD *)Thd), MYSQL_ERROR::WARN_LEVEL_WARN, \ ER_WARN_DEPRECATED_SYNTAX, ER(ER_WARN_DEPRECATED_SYNTAX), \ (Old), (Ver), (New)); \ @@ -385,7 +385,7 @@ MY_LOCALE *my_locale_by_number(uint number); #define MODE_NO_KEY_OPTIONS 8192 #define MODE_NO_TABLE_OPTIONS 16384 #define MODE_NO_FIELD_OPTIONS 32768 -#define MODE_MYSQL323 65536 +#define MODE_MYSQL323 65536L #define MODE_MYSQL40 (MODE_MYSQL323*2) #define MODE_ANSI (MODE_MYSQL40*2) #define MODE_NO_AUTO_VALUE_ON_ZERO (MODE_ANSI*2) @@ -400,6 +400,8 @@ MY_LOCALE *my_locale_by_number(uint number); #define MODE_NO_AUTO_CREATE_USER (MODE_TRADITIONAL*2) #define MODE_HIGH_NOT_PRECEDENCE (MODE_NO_AUTO_CREATE_USER*2) #define MODE_NO_ENGINE_SUBSTITUTION (MODE_HIGH_NOT_PRECEDENCE*2) +#define MODE_PAD_CHAR_TO_FULL_LENGTH (ULL(1) << 31) + /* Replication uses 8 bytes to store SQL_MODE in the binary log. The day you use strictly more than 64 bits by adding one more define above, you should @@ -499,8 +501,8 @@ class THD; typedef struct st_sql_list { uint elements; - byte *first; - byte **next; + uchar *first; + uchar **next; st_sql_list() {} /* Remove gcc warning */ inline void empty() @@ -509,7 +511,7 @@ typedef struct st_sql_list { first=0; next= &first; } - inline void link_in_list(byte *element,byte **next_ptr) + inline void link_in_list(uchar *element,uchar **next_ptr) { elements++; (*next)=element; @@ -887,9 +889,9 @@ my_bool is_partition_management(LEX *lex); All methods presume that there is at least one field to change. */ -void set_field_ptr(Field **ptr, const byte *new_buf, const byte *old_buf); -void set_key_field_ptr(KEY *key_info, const byte *new_buf, - const byte *old_buf); +void set_field_ptr(Field **ptr, const uchar *new_buf, const uchar *old_buf); +void set_key_field_ptr(KEY *key_info, const uchar *new_buf, + const uchar *old_buf); bool mysql_backup_table(THD* thd, TABLE_LIST* table_list); bool mysql_restore_table(THD* thd, TABLE_LIST* table_list); @@ -1346,11 +1348,11 @@ typedef struct st_lock_param_type KEY *key_info_buffer; const char *db; const char *table_name; - const void *pack_frm_data; + uchar *pack_frm_data; enum thr_lock_type old_lock_type; uint key_count; uint db_options; - uint pack_frm_len; + size_t pack_frm_len; partition_info *part_info; } ALTER_PARTITION_PARAM_TYPE; @@ -1513,16 +1515,16 @@ void print_plan(JOIN* join,uint idx, double record_count, double read_time, #endif void mysql_print_status(); /* key.cc */ -int find_ref_key(KEY *key, uint key_count, byte *record, Field *field, +int find_ref_key(KEY *key, uint key_count, uchar *record, Field *field, uint *key_length, uint *keypart); -void key_copy(byte *to_key, byte *from_record, KEY *key_info, uint key_length); -void key_restore(byte *to_record, byte *from_key, KEY *key_info, +void key_copy(uchar *to_key, uchar *from_record, KEY *key_info, uint key_length); +void key_restore(uchar *to_record, uchar *from_key, KEY *key_info, uint key_length); -bool key_cmp_if_same(TABLE *form,const byte *key,uint index,uint key_length); +bool key_cmp_if_same(TABLE *form,const uchar *key,uint index,uint key_length); void key_unpack(String *to,TABLE *form,uint index); bool is_key_used(TABLE *table, uint idx, const MY_BITMAP *fields); -int key_cmp(KEY_PART_INFO *key_part, const byte *key, uint key_length); -int key_rec_cmp(void *key_info, byte *a, byte *b); +int key_cmp(KEY_PART_INFO *key_part, const uchar *key, uint key_length); +int key_rec_cmp(void *key_info, uchar *a, uchar *b); bool init_errmessage(void); #endif /* MYSQL_SERVER */ @@ -1547,7 +1549,7 @@ bool slow_log_print(THD *thd, const char *query, uint query_length, bool general_log_print(THD *thd, enum enum_server_command command, const char *format,...); -bool fn_format_relative_to_data_home(my_string to, const char *name, +bool fn_format_relative_to_data_home(char * to, const char *name, const char *dir, const char *extension); #ifdef MYSQL_SERVER File open_binlog(IO_CACHE *log, const char *log_file_name, @@ -1814,8 +1816,8 @@ int rea_create_table(THD *thd, const char *path, List<create_field> &create_field, uint key_count,KEY *key_info, handler *file); -int format_number(uint inputflag,uint max_length,my_string pos,uint length, - my_string *errpos); +int format_number(uint inputflag,uint max_length,char * pos,uint length, + char * *errpos); /* table.cc */ TABLE_SHARE *alloc_table_share(TABLE_LIST *table_list, char *key, @@ -1828,10 +1830,10 @@ void open_table_error(TABLE_SHARE *share, int error, int db_errno, int errarg); int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, uint db_stat, uint prgflag, uint ha_open_flags, TABLE *outparam, bool is_create_table); -int readfrm(const char *name, const void** data, uint* length); -int writefrm(const char* name, const void* data, uint len); +int readfrm(const char *name, uchar **data, size_t *length); +int writefrm(const char* name, const uchar* data, size_t len); int closefrm(TABLE *table, bool free_share); -int read_string(File file, gptr *to, uint length); +int read_string(File file, uchar* *to, size_t length); void free_blobs(TABLE *table); int set_zone(int nr,int min_zone,int max_zone); ulong convert_period_to_month(ulong period); @@ -1876,7 +1878,7 @@ ulonglong get_datetime_value(THD *thd, Item ***item_arg, Item **cache_arg, Item *warn_item, bool *is_null); int test_if_number(char *str,int *res,bool allow_wildcards); -void change_byte(byte *,uint,char,char); +void change_byte(uchar *,uint,char,char); void init_read_record(READ_RECORD *info, THD *thd, TABLE *reg_form, SQL_SELECT *select, int use_record_cache, bool print_errors); @@ -1888,7 +1890,7 @@ ha_rows filesort(THD *thd, TABLE *form,struct st_sort_field *sortorder, ha_rows max_rows, bool sort_positions, ha_rows *examined_rows); void filesort_free_buffers(TABLE *table, bool full); -void change_double_for_sort(double nr,byte *to); +void change_double_for_sort(double nr,uchar *to); double my_double_round(double value, longlong dec, bool dec_unsigned, bool truncate); int get_quick_record(SQL_SELECT *select); @@ -1896,7 +1898,7 @@ int get_quick_record(SQL_SELECT *select); int calc_weekday(long daynr,bool sunday_first_day_of_week); uint calc_week(MYSQL_TIME *l_time, uint week_behaviour, uint *year); void find_date(char *pos,uint *vek,uint flag); -TYPELIB *convert_strings_to_array_type(my_string *typelibs, my_string *end); +TYPELIB *convert_strings_to_array_type(char * *typelibs, char * *end); TYPELIB *typelib(MEM_ROOT *mem_root, List<String> &strings); ulong get_form_pos(File file, uchar *head, TYPELIB *save_names); ulong make_new_entry(File file,uchar *fileinfo,TYPELIB *formnames, @@ -1931,7 +1933,7 @@ uint build_table_filename(char *buff, size_t bufflen, const char *db, /* from hostname.cc */ struct in_addr; -my_string ip_to_hostname(struct in_addr *in,uint *errors); +char * ip_to_hostname(struct in_addr *in,uint *errors); void inc_host_errors(struct in_addr *in); void reset_host_errors(struct in_addr *in); bool hostname_cache_init(); @@ -2095,7 +2097,7 @@ inline bool is_user_table(TABLE * table) #ifndef EMBEDDED_LIBRARY extern "C" void unireg_abort(int exit_code) __attribute__((noreturn)); void kill_delayed_threads(void); -bool check_stack_overrun(THD *thd, long margin, char *dummy); +bool check_stack_overrun(THD *thd, long margin, uchar *dummy); #else #define unireg_abort(exit_code) DBUG_RETURN(exit_code) inline void kill_delayed_threads(void) {} diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 045603dcb24..be704625e92 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -216,8 +216,10 @@ static const char *sql_mode_names[]= "ERROR_FOR_DIVISION_BY_ZERO", "TRADITIONAL", "NO_AUTO_CREATE_USER", "HIGH_NOT_PRECEDENCE", "NO_ENGINE_SUBSTITUTION", + "PAD_CHAR_TO_FULL_LENGTH", NullS }; + static const unsigned int sql_mode_names_len[]= { /*REAL_AS_FLOAT*/ 13, @@ -250,8 +252,10 @@ static const unsigned int sql_mode_names_len[]= /*TRADITIONAL*/ 11, /*NO_AUTO_CREATE_USER*/ 19, /*HIGH_NOT_PRECEDENCE*/ 19, - /*NO_ENGINE_SUBSTITUTION*/ 22 + /*NO_ENGINE_SUBSTITUTION*/ 22, + /*PAD_CHAR_TO_FULL_LENGTH*/ 23 }; + TYPELIB sql_mode_typelib= { array_elements(sql_mode_names)-1,"", sql_mode_names, (unsigned int *)sql_mode_names_len }; @@ -1192,7 +1196,7 @@ void clean_up(bool print_message) if (tc_log) tc_log->close(); xid_cache_free(); - delete_elements(&key_caches, (void (*)(const char*, gptr)) free_key_cache); + delete_elements(&key_caches, (void (*)(const char*, uchar*)) free_key_cache); multi_keycache_free(); free_status_vars(); end_thr_alarm(1); /* Free allocated memory */ @@ -1239,7 +1243,7 @@ void clean_up(bool print_message) #endif thread_scheduler.end(); finish_client_errs(); - my_free((gptr) my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST), + my_free((uchar*) my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST), MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR)); DBUG_PRINT("quit", ("Error messages freed")); /* Tell main we are ready */ @@ -2200,7 +2204,7 @@ the thread stack. Please read http://www.mysql.com/doc/en/Linux.html\n\n", if (!(test_flags & TEST_NO_STACKTRACE)) { fprintf(stderr,"thd: 0x%lx\n",(long) thd); - print_stacktrace(thd ? (gptr) thd->thread_stack : (gptr) 0, + print_stacktrace(thd ? (uchar*) thd->thread_stack : (uchar*) 0, thread_stack); } if (thd) @@ -2588,7 +2592,7 @@ static void *my_str_malloc_mysqld(size_t size) static void my_str_free_mysqld(void *ptr) { - my_free((gptr)ptr, MYF(MY_FAE)); + my_free((uchar*)ptr, MYF(MY_FAE)); } #endif /* EMBEDDED_LIBRARY */ @@ -5040,12 +5044,12 @@ enum options_mysqld struct my_option my_long_options[] = { {"help", '?', "Display this help and exit.", - (gptr*) &opt_help, (gptr*) &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + (uchar**) &opt_help, (uchar**) &opt_help, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_REPLICATION {"abort-slave-event-count", OPT_ABORT_SLAVE_EVENT_COUNT, "Option used by mysql-test for debugging and testing of replication.", - (gptr*) &abort_slave_event_count, (gptr*) &abort_slave_event_count, + (uchar**) &abort_slave_event_count, (uchar**) &abort_slave_event_count, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif /* HAVE_REPLICATION */ {"allow-suspicious-udfs", OPT_ALLOW_SUSPICIOUS_UDFS, @@ -5053,33 +5057,33 @@ struct my_option my_long_options[] = "without corresponding xxx_init() or xxx_deinit(). That also means " "that one can load any function from any library, for example exit() " "from libc.so", - (gptr*) &opt_allow_suspicious_udfs, (gptr*) &opt_allow_suspicious_udfs, + (uchar**) &opt_allow_suspicious_udfs, (uchar**) &opt_allow_suspicious_udfs, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"ansi", 'a', "Use ANSI SQL syntax instead of MySQL syntax. This mode will also set transaction isolation level 'serializable'.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"auto-increment-increment", OPT_AUTO_INCREMENT, "Auto-increment columns are incremented by this", - (gptr*) &global_system_variables.auto_increment_increment, - (gptr*) &max_system_variables.auto_increment_increment, 0, GET_ULONG, + (uchar**) &global_system_variables.auto_increment_increment, + (uchar**) &max_system_variables.auto_increment_increment, 0, GET_ULONG, OPT_ARG, 1, 1, 65535, 0, 1, 0 }, {"auto-increment-offset", OPT_AUTO_INCREMENT_OFFSET, "Offset added to Auto-increment columns. Used when auto-increment-increment != 1", - (gptr*) &global_system_variables.auto_increment_offset, - (gptr*) &max_system_variables.auto_increment_offset, 0, GET_ULONG, OPT_ARG, + (uchar**) &global_system_variables.auto_increment_offset, + (uchar**) &max_system_variables.auto_increment_offset, 0, GET_ULONG, OPT_ARG, 1, 1, 65535, 0, 1, 0 }, {"automatic-sp-privileges", OPT_SP_AUTOMATIC_PRIVILEGES, "Creating and dropping stored procedures alters ACLs. Disable with --skip-automatic-sp-privileges.", - (gptr*) &sp_automatic_privileges, (gptr*) &sp_automatic_privileges, + (uchar**) &sp_automatic_privileges, (uchar**) &sp_automatic_privileges, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"basedir", 'b', "Path to installation directory. All paths are usually resolved relative to this.", - (gptr*) &mysql_home_ptr, (gptr*) &mysql_home_ptr, 0, GET_STR, REQUIRED_ARG, + (uchar**) &mysql_home_ptr, (uchar**) &mysql_home_ptr, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"big-tables", OPT_BIG_TABLES, "Allow big result sets by saving all temporary sets on file (Solves most 'table full' errors).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"bind-address", OPT_BIND_ADDRESS, "IP address to bind to.", - (gptr*) &my_bind_addr_str, (gptr*) &my_bind_addr_str, 0, GET_STR, + (uchar**) &my_bind_addr_str, (uchar**) &my_bind_addr_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"binlog_format", OPT_BINLOG_FORMAT, "Does not have any effect without '--log-bin'. " @@ -5093,7 +5097,7 @@ struct my_option my_long_options[] = "If ndbcluster is enabled and binlog_format is `mixed', the format switches" " to 'row' and back implicitly per each query accessing a NDB table." #endif - ,(gptr*) &opt_binlog_format, (gptr*) &opt_binlog_format, + ,(uchar**) &opt_binlog_format, (uchar**) &opt_binlog_format, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"binlog-do-db", OPT_BINLOG_DO_DB, "Tells the master it should log updates for the specified database, and exclude all others not explicitly mentioned.", @@ -5105,8 +5109,8 @@ struct my_option my_long_options[] = "The maximum size of a row-based binary log event in bytes. Rows will be " "grouped into events smaller than this size if possible. " "The value has to be a multiple of 256.", - (gptr*) &opt_binlog_rows_event_max_size, - (gptr*) &opt_binlog_rows_event_max_size, 0, + (uchar**) &opt_binlog_rows_event_max_size, + (uchar**) &opt_binlog_rows_event_max_size, 0, GET_ULONG, REQUIRED_ARG, /* def_value */ 1024, /* min_value */ 256, /* max_value */ ULONG_MAX, /* sub_size */ 0, /* block_size */ 256, @@ -5118,61 +5122,61 @@ struct my_option my_long_options[] = #endif {"character-set-client-handshake", OPT_CHARACTER_SET_CLIENT_HANDSHAKE, "Don't ignore client side character set value sent during handshake.", - (gptr*) &opt_character_set_client_handshake, - (gptr*) &opt_character_set_client_handshake, + (uchar**) &opt_character_set_client_handshake, + (uchar**) &opt_character_set_client_handshake, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"character-set-filesystem", OPT_CHARACTER_SET_FILESYSTEM, "Set the filesystem character set.", - (gptr*) &character_set_filesystem_name, - (gptr*) &character_set_filesystem_name, + (uchar**) &character_set_filesystem_name, + (uchar**) &character_set_filesystem_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, {"character-set-server", 'C', "Set the default character set.", - (gptr*) &default_character_set_name, (gptr*) &default_character_set_name, + (uchar**) &default_character_set_name, (uchar**) &default_character_set_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, {"character-sets-dir", OPT_CHARSETS_DIR, - "Directory where character sets are.", (gptr*) &charsets_dir, - (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Directory where character sets are.", (uchar**) &charsets_dir, + (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"chroot", 'r', "Chroot mysqld daemon during startup.", - (gptr*) &mysqld_chroot, (gptr*) &mysqld_chroot, 0, GET_STR, REQUIRED_ARG, + (uchar**) &mysqld_chroot, (uchar**) &mysqld_chroot, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"collation-server", OPT_DEFAULT_COLLATION, "Set the default collation.", - (gptr*) &default_collation_name, (gptr*) &default_collation_name, + (uchar**) &default_collation_name, (uchar**) &default_collation_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, {"completion-type", OPT_COMPLETION_TYPE, "Default completion type.", - (gptr*) &global_system_variables.completion_type, - (gptr*) &max_system_variables.completion_type, 0, GET_ULONG, + (uchar**) &global_system_variables.completion_type, + (uchar**) &max_system_variables.completion_type, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 2, 0, 1, 0}, {"concurrent-insert", OPT_CONCURRENT_INSERT, "Use concurrent insert with MyISAM. Disable with --concurrent-insert=0", - (gptr*) &myisam_concurrent_insert, (gptr*) &myisam_concurrent_insert, + (uchar**) &myisam_concurrent_insert, (uchar**) &myisam_concurrent_insert, 0, GET_LONG, OPT_ARG, 1, 0, 2, 0, 0, 0}, {"console", OPT_CONSOLE, "Write error output on screen; Don't remove the console window on windows.", - (gptr*) &opt_console, (gptr*) &opt_console, 0, GET_BOOL, NO_ARG, 0, 0, 0, + (uchar**) &opt_console, (uchar**) &opt_console, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"core-file", OPT_WANT_CORE, "Write core on errors.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"datadir", 'h', "Path to the database root.", (gptr*) &mysql_data_home, - (gptr*) &mysql_data_home, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"datadir", 'h', "Path to the database root.", (uchar**) &mysql_data_home, + (uchar**) &mysql_data_home, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifndef DBUG_OFF - {"debug", '#', "Debug log.", (gptr*) &default_dbug_option, - (gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"debug", '#', "Debug log.", (uchar**) &default_dbug_option, + (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif {"default-character-set", 'C', "Set the default character set (deprecated option, use --character-set-server instead).", - (gptr*) &default_character_set_name, (gptr*) &default_character_set_name, + (uchar**) &default_character_set_name, (uchar**) &default_character_set_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, {"default-collation", OPT_DEFAULT_COLLATION, "Set the default collation (deprecated option, use --collation-server instead).", - (gptr*) &default_collation_name, (gptr*) &default_collation_name, + (uchar**) &default_collation_name, (uchar**) &default_collation_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, {"default-storage-engine", OPT_STORAGE_ENGINE, "Set the default storage engine (table type) for tables.", - (gptr*)&default_storage_engine_str, (gptr*)&default_storage_engine_str, + (uchar**)&default_storage_engine_str, (uchar**)&default_storage_engine_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"default-table-type", OPT_STORAGE_ENGINE, "(deprecated) Use --default-storage-engine.", - (gptr*)&default_storage_engine_str, (gptr*)&default_storage_engine_str, + (uchar**)&default_storage_engine_str, (uchar**)&default_storage_engine_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"default-time-zone", OPT_DEFAULT_TIME_ZONE, "Set the default time zone.", - (gptr*) &default_tz_name, (gptr*) &default_tz_name, + (uchar**) &default_tz_name, (uchar**) &default_tz_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, {"delay-key-write", OPT_DELAY_KEY_WRITE, "Type of DELAY_KEY_WRITE.", 0,0,0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, @@ -5182,33 +5186,33 @@ struct my_option my_long_options[] = #ifdef HAVE_OPENSSL {"des-key-file", OPT_DES_KEY_FILE, "Load keys for des_encrypt() and des_encrypt from given file.", - (gptr*) &des_key_file, (gptr*) &des_key_file, 0, GET_STR, REQUIRED_ARG, + (uchar**) &des_key_file, (uchar**) &des_key_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif /* HAVE_OPENSSL */ #ifdef HAVE_REPLICATION {"disconnect-slave-event-count", OPT_DISCONNECT_SLAVE_EVENT_COUNT, "Option used by mysql-test for debugging and testing of replication.", - (gptr*) &disconnect_slave_event_count, - (gptr*) &disconnect_slave_event_count, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, + (uchar**) &disconnect_slave_event_count, + (uchar**) &disconnect_slave_event_count, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif /* HAVE_REPLICATION */ {"enable-locking", OPT_ENABLE_LOCK, "Deprecated option, use --external-locking instead.", - (gptr*) &opt_external_locking, (gptr*) &opt_external_locking, + (uchar**) &opt_external_locking, (uchar**) &opt_external_locking, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef __NT__ {"enable-named-pipe", OPT_HAVE_NAMED_PIPE, "Enable the named pipe (NT).", - (gptr*) &opt_enable_named_pipe, (gptr*) &opt_enable_named_pipe, 0, GET_BOOL, + (uchar**) &opt_enable_named_pipe, (uchar**) &opt_enable_named_pipe, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"enable-pstack", OPT_DO_PSTACK, "Print a symbolic stack trace on failure.", - (gptr*) &opt_do_pstack, (gptr*) &opt_do_pstack, 0, GET_BOOL, NO_ARG, 0, 0, + (uchar**) &opt_do_pstack, (uchar**) &opt_do_pstack, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"engine-condition-pushdown", OPT_ENGINE_CONDITION_PUSHDOWN, "Push supported query conditions to the storage engine.", - (gptr*) &global_system_variables.engine_condition_pushdown, - (gptr*) &global_system_variables.engine_condition_pushdown, + (uchar**) &global_system_variables.engine_condition_pushdown, + (uchar**) &global_system_variables.engine_condition_pushdown, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, /* See how it's handled in get_one_option() */ {"event-scheduler", OPT_EVENT_SCHEDULER, "Enable/disable the event scheduler.", @@ -5216,7 +5220,7 @@ struct my_option my_long_options[] = {"exit-info", 'T', "Used for debugging; Use at your own risk!", 0, 0, 0, GET_LONG, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"external-locking", OPT_USE_LOCKING, "Use system (external) locking (disabled by default). With this option enabled you can run myisamchk to test (not repair) tables while the MySQL server is running. Disable with --skip-external-locking.", - (gptr*) &opt_external_locking, (gptr*) &opt_external_locking, + (uchar**) &opt_external_locking, (uchar**) &opt_external_locking, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"flush", OPT_FLUSH, "Flush tables to disk between SQL commands.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -5224,55 +5228,55 @@ struct my_option my_long_options[] = easier to do */ {"gdb", OPT_DEBUGGING, "Set up signals usable for debugging", - (gptr*) &opt_debugging, (gptr*) &opt_debugging, + (uchar**) &opt_debugging, (uchar**) &opt_debugging, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"general-log", OPT_GENERAL_LOG, - "Enable|disable general log", (gptr*) &opt_log, - (gptr*) &opt_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, + "Enable|disable general log", (uchar**) &opt_log, + (uchar**) &opt_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_LARGE_PAGES {"large-pages", OPT_ENABLE_LARGE_PAGES, "Enable support for large pages. \ Disable with --skip-large-pages.", - (gptr*) &opt_large_pages, (gptr*) &opt_large_pages, 0, GET_BOOL, NO_ARG, 0, 0, 0, + (uchar**) &opt_large_pages, (uchar**) &opt_large_pages, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"init-connect", OPT_INIT_CONNECT, "Command(s) that are executed for each new connection", - (gptr*) &opt_init_connect, (gptr*) &opt_init_connect, 0, GET_STR_ALLOC, + (uchar**) &opt_init_connect, (uchar**) &opt_init_connect, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifndef DISABLE_GRANT_OPTIONS {"init-file", OPT_INIT_FILE, "Read SQL commands from this file at startup.", - (gptr*) &opt_init_file, (gptr*) &opt_init_file, 0, GET_STR, REQUIRED_ARG, + (uchar**) &opt_init_file, (uchar**) &opt_init_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif {"init-rpl-role", OPT_INIT_RPL_ROLE, "Set the replication role.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"init-slave", OPT_INIT_SLAVE, "Command(s) that are executed when a slave connects to this master", - (gptr*) &opt_init_slave, (gptr*) &opt_init_slave, 0, GET_STR_ALLOC, + (uchar**) &opt_init_slave, (uchar**) &opt_init_slave, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"language", 'L', + {"language", 'L', "Client error messages in given language. May be given as a full path.", - (gptr*) &language_ptr, (gptr*) &language_ptr, 0, GET_STR, REQUIRED_ARG, + (uchar**) &language_ptr, (uchar**) &language_ptr, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"lc-time-names", OPT_LC_TIME_NAMES, "Set the language used for the month names and the days of the week.", - (gptr*) &lc_time_names_name, - (gptr*) &lc_time_names_name, + (uchar**) &lc_time_names_name, + (uchar**) &lc_time_names_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, {"local-infile", OPT_LOCAL_INFILE, "Enable/disable LOAD DATA LOCAL INFILE (takes values 1|0).", - (gptr*) &opt_local_infile, - (gptr*) &opt_local_infile, 0, GET_BOOL, OPT_ARG, + (uchar**) &opt_local_infile, + (uchar**) &opt_local_infile, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, - {"log", 'l', "Log connections and queries to file.", (gptr*) &opt_logname, - (gptr*) &opt_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"log", 'l', "Log connections and queries to file.", (uchar**) &opt_logname, + (uchar**) &opt_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"log-bin", OPT_BIN_LOG, "Log update queries in binary format. Optional (but strongly recommended " "to avoid replication problems if server's hostname changes) argument " "should be the chosen location for the binary log files.", - (gptr*) &opt_bin_logname, (gptr*) &opt_bin_logname, 0, GET_STR_ALLOC, + (uchar**) &opt_bin_logname, (uchar**) &opt_bin_logname, 0, GET_STR_ALLOC, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"log-bin-index", OPT_BIN_LOG_INDEX, "File that holds the names for last binary log files.", - (gptr*) &opt_binlog_index_name, (gptr*) &opt_binlog_index_name, 0, GET_STR, + (uchar**) &opt_binlog_index_name, (uchar**) &opt_binlog_index_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifndef TO_BE_REMOVED_IN_5_1_OR_6_0 /* @@ -5283,7 +5287,7 @@ Disable with --skip-large-pages.", */ {"log-bin-trust-routine-creators", OPT_LOG_BIN_TRUST_FUNCTION_CREATORS, "(deprecated) Use log-bin-trust-function-creators.", - (gptr*) &trust_function_creators, (gptr*) &trust_function_creators, 0, + (uchar**) &trust_function_creators, (uchar**) &trust_function_creators, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif /* @@ -5297,13 +5301,13 @@ Disable with --skip-large-pages.", "Note that if ALL connections to this server ALWAYS use row-based binary " "logging, the security issues do not exist and the binary logging cannot " "break, so you can safely set this to 1." - ,(gptr*) &trust_function_creators, (gptr*) &trust_function_creators, 0, + ,(uchar**) &trust_function_creators, (uchar**) &trust_function_creators, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"log-error", OPT_ERROR_LOG_FILE, "Error log file.", - (gptr*) &log_error_file_ptr, (gptr*) &log_error_file_ptr, 0, GET_STR, + (uchar**) &log_error_file_ptr, (uchar**) &log_error_file_ptr, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"log-isam", OPT_ISAM_LOG, "Log all MyISAM changes to file.", - (gptr*) &myisam_log_filename, (gptr*) &myisam_log_filename, 0, GET_STR, + (uchar**) &myisam_log_filename, (uchar**) &myisam_log_filename, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"log-long-format", '0', "Log some extra information to update log. Please note that this option is deprecated; see --log-short-format option.", @@ -5312,161 +5316,161 @@ Disable with --skip-large-pages.", {"log-output", OPT_LOG_OUTPUT, "Syntax: log-output[=value[,value...]], where \"value\" could be TABLE, " "FILE or NONE.", - (gptr*) &log_output_str, (gptr*) &log_output_str, 0, + (uchar**) &log_output_str, (uchar**) &log_output_str, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #endif {"log-queries-not-using-indexes", OPT_LOG_QUERIES_NOT_USING_INDEXES, "Log queries that are executed without benefit of any index to the slow log if it is open.", - (gptr*) &opt_log_queries_not_using_indexes, (gptr*) &opt_log_queries_not_using_indexes, + (uchar**) &opt_log_queries_not_using_indexes, (uchar**) &opt_log_queries_not_using_indexes, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"log-short-format", OPT_SHORT_LOG_FORMAT, "Don't log extra information to update and slow-query logs.", - (gptr*) &opt_short_log_format, (gptr*) &opt_short_log_format, + (uchar**) &opt_short_log_format, (uchar**) &opt_short_log_format, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"log-slave-updates", OPT_LOG_SLAVE_UPDATES, "Tells the slave to log the updates from the slave thread to the binary log. You will need to turn it on if you plan to daisy-chain the slaves.", - (gptr*) &opt_log_slave_updates, (gptr*) &opt_log_slave_updates, 0, GET_BOOL, + (uchar**) &opt_log_slave_updates, (uchar**) &opt_log_slave_updates, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"log-slow-admin-statements", OPT_LOG_SLOW_ADMIN_STATEMENTS, "Log slow OPTIMIZE, ANALYZE, ALTER and other administrative statements to the slow log if it is open.", - (gptr*) &opt_log_slow_admin_statements, - (gptr*) &opt_log_slow_admin_statements, + (uchar**) &opt_log_slow_admin_statements, + (uchar**) &opt_log_slow_admin_statements, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"log-slow-queries", OPT_SLOW_QUERY_LOG, "Log slow queries to this log file. Defaults logging to hostname-slow.log file. Must be enabled to activate other slow log options.", - (gptr*) &opt_slow_logname, (gptr*) &opt_slow_logname, 0, GET_STR, OPT_ARG, + (uchar**) &opt_slow_logname, (uchar**) &opt_slow_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"log-tc", OPT_LOG_TC, "Path to transaction coordinator log (used for transactions that affect " "more than one storage engine, when binary log is disabled)", - (gptr*) &opt_tc_log_file, (gptr*) &opt_tc_log_file, 0, GET_STR, + (uchar**) &opt_tc_log_file, (uchar**) &opt_tc_log_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_MMAP {"log-tc-size", OPT_LOG_TC_SIZE, "Size of transaction coordinator log.", - (gptr*) &opt_tc_log_size, (gptr*) &opt_tc_log_size, 0, GET_ULONG, + (uchar**) &opt_tc_log_size, (uchar**) &opt_tc_log_size, 0, GET_ULONG, REQUIRED_ARG, TC_LOG_MIN_SIZE, TC_LOG_MIN_SIZE, ~0L, 0, TC_LOG_PAGE_SIZE, 0}, #endif {"log-update", OPT_UPDATE_LOG, "The update log is deprecated since version 5.0, is replaced by the binary \ log and this option justs turns on --log-bin instead.", - (gptr*) &opt_update_logname, (gptr*) &opt_update_logname, 0, GET_STR, + (uchar**) &opt_update_logname, (uchar**) &opt_update_logname, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"log-warnings", 'W', "Log some not critical warnings to the log file.", - (gptr*) &global_system_variables.log_warnings, - (gptr*) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, 0, + (uchar**) &global_system_variables.log_warnings, + (uchar**) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, 0, 0, 0, 0}, {"low-priority-updates", OPT_LOW_PRIORITY_UPDATES, "INSERT/DELETE/UPDATE has lower priority than selects.", - (gptr*) &global_system_variables.low_priority_updates, - (gptr*) &max_system_variables.low_priority_updates, + (uchar**) &global_system_variables.low_priority_updates, + (uchar**) &max_system_variables.low_priority_updates, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"master-connect-retry", OPT_MASTER_CONNECT_RETRY, "The number of seconds the slave thread will sleep before retrying to connect to the master in case the master goes down or the connection is lost.", - (gptr*) &master_connect_retry, (gptr*) &master_connect_retry, 0, GET_UINT, + (uchar**) &master_connect_retry, (uchar**) &master_connect_retry, 0, GET_UINT, REQUIRED_ARG, 60, 0, 0, 0, 0, 0}, {"master-host", OPT_MASTER_HOST, "Master hostname or IP address for replication. If not set, the slave thread will not be started. Note that the setting of master-host will be ignored if there exists a valid master.info file.", - (gptr*) &master_host, (gptr*) &master_host, 0, GET_STR, REQUIRED_ARG, 0, 0, + (uchar**) &master_host, (uchar**) &master_host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"master-info-file", OPT_MASTER_INFO_FILE, "The location and name of the file that remembers the master and where the I/O replication \ thread is in the master's binlogs.", - (gptr*) &master_info_file, (gptr*) &master_info_file, 0, GET_STR, + (uchar**) &master_info_file, (uchar**) &master_info_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"master-password", OPT_MASTER_PASSWORD, "The password the slave thread will authenticate with when connecting to the master. If not set, an empty password is assumed.The value in master.info will take precedence if it can be read.", - (gptr*)&master_password, (gptr*)&master_password, 0, + (uchar**)&master_password, (uchar**)&master_password, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"master-port", OPT_MASTER_PORT, "The port the master is listening on. If not set, the compiled setting of MYSQL_PORT is assumed. If you have not tinkered with configure options, this should be 3306. The value in master.info will take precedence if it can be read.", - (gptr*) &master_port, (gptr*) &master_port, 0, GET_UINT, REQUIRED_ARG, + (uchar**) &master_port, (uchar**) &master_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0}, {"master-retry-count", OPT_MASTER_RETRY_COUNT, "The number of tries the slave will make to connect to the master before giving up.", - (gptr*) &master_retry_count, (gptr*) &master_retry_count, 0, GET_ULONG, + (uchar**) &master_retry_count, (uchar**) &master_retry_count, 0, GET_ULONG, REQUIRED_ARG, 3600*24, 0, 0, 0, 0, 0}, {"master-ssl", OPT_MASTER_SSL, "Enable the slave to connect to the master using SSL.", - (gptr*) &master_ssl, (gptr*) &master_ssl, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + (uchar**) &master_ssl, (uchar**) &master_ssl, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"master-ssl-ca", OPT_MASTER_SSL_CA, "Master SSL CA file. Only applies if you have enabled master-ssl.", - (gptr*) &master_ssl_ca, (gptr*) &master_ssl_ca, 0, GET_STR, OPT_ARG, + (uchar**) &master_ssl_ca, (uchar**) &master_ssl_ca, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"master-ssl-capath", OPT_MASTER_SSL_CAPATH, "Master SSL CA path. Only applies if you have enabled master-ssl.", - (gptr*) &master_ssl_capath, (gptr*) &master_ssl_capath, 0, GET_STR, OPT_ARG, + (uchar**) &master_ssl_capath, (uchar**) &master_ssl_capath, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"master-ssl-cert", OPT_MASTER_SSL_CERT, "Master SSL certificate file name. Only applies if you have enabled \ master-ssl", - (gptr*) &master_ssl_cert, (gptr*) &master_ssl_cert, 0, GET_STR, OPT_ARG, + (uchar**) &master_ssl_cert, (uchar**) &master_ssl_cert, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"master-ssl-cipher", OPT_MASTER_SSL_CIPHER, "Master SSL cipher. Only applies if you have enabled master-ssl.", - (gptr*) &master_ssl_cipher, (gptr*) &master_ssl_capath, 0, GET_STR, OPT_ARG, + (uchar**) &master_ssl_cipher, (uchar**) &master_ssl_capath, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"master-ssl-key", OPT_MASTER_SSL_KEY, "Master SSL keyfile name. Only applies if you have enabled master-ssl.", - (gptr*) &master_ssl_key, (gptr*) &master_ssl_key, 0, GET_STR, OPT_ARG, + (uchar**) &master_ssl_key, (uchar**) &master_ssl_key, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"master-user", OPT_MASTER_USER, "The username the slave thread will use for authentication when connecting to the master. The user must have FILE privilege. If the master user is not set, user test is assumed. The value in master.info will take precedence if it can be read.", - (gptr*) &master_user, (gptr*) &master_user, 0, GET_STR, REQUIRED_ARG, 0, 0, + (uchar**) &master_user, (uchar**) &master_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_REPLICATION {"max-binlog-dump-events", OPT_MAX_BINLOG_DUMP_EVENTS, "Option used by mysql-test for debugging and testing of replication.", - (gptr*) &max_binlog_dump_events, (gptr*) &max_binlog_dump_events, 0, + (uchar**) &max_binlog_dump_events, (uchar**) &max_binlog_dump_events, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif /* HAVE_REPLICATION */ - {"memlock", OPT_MEMLOCK, "Lock mysqld in memory.", (gptr*) &locked_in_memory, - (gptr*) &locked_in_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"memlock", OPT_MEMLOCK, "Lock mysqld in memory.", (uchar**) &locked_in_memory, + (uchar**) &locked_in_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"myisam-recover", OPT_MYISAM_RECOVER, "Syntax: myisam-recover[=option[,option...]], where option can be DEFAULT, BACKUP, FORCE or QUICK.", - (gptr*) &myisam_recover_options_str, (gptr*) &myisam_recover_options_str, 0, + (uchar**) &myisam_recover_options_str, (uchar**) &myisam_recover_options_str, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, #ifdef WITH_NDBCLUSTER_STORAGE_ENGINE {"ndb-connectstring", OPT_NDB_CONNECTSTRING, "Connect string for ndbcluster.", - (gptr*) &opt_ndb_connectstring, - (gptr*) &opt_ndb_connectstring, + (uchar**) &opt_ndb_connectstring, + (uchar**) &opt_ndb_connectstring, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"ndb-mgmd-host", OPT_NDB_MGMD, "Set host and port for ndb_mgmd. Syntax: hostname[:port]", - (gptr*) &opt_ndb_mgmd, - (gptr*) &opt_ndb_mgmd, + (uchar**) &opt_ndb_mgmd, + (uchar**) &opt_ndb_mgmd, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"ndb-nodeid", OPT_NDB_NODEID, "Nodeid for this mysqlserver in the cluster.", - (gptr*) &opt_ndb_nodeid, - (gptr*) &opt_ndb_nodeid, + (uchar**) &opt_ndb_nodeid, + (uchar**) &opt_ndb_nodeid, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"ndb-autoincrement-prefetch-sz", OPT_NDB_AUTOINCREMENT_PREFETCH_SZ, "Specify number of autoincrement values that are prefetched.", - (gptr*) &global_system_variables.ndb_autoincrement_prefetch_sz, - (gptr*) &global_system_variables.ndb_autoincrement_prefetch_sz, + (uchar**) &global_system_variables.ndb_autoincrement_prefetch_sz, + (uchar**) &global_system_variables.ndb_autoincrement_prefetch_sz, 0, GET_ULONG, REQUIRED_ARG, 32, 1, 256, 0, 0, 0}, {"ndb-distribution", OPT_NDB_DISTRIBUTION, "Default distribution for new tables in ndb", - (gptr*) &opt_ndb_distribution, - (gptr*) &opt_ndb_distribution, + (uchar**) &opt_ndb_distribution, + (uchar**) &opt_ndb_distribution, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"ndb-force-send", OPT_NDB_FORCE_SEND, "Force send of buffers to ndb immediately without waiting for " "other threads.", - (gptr*) &global_system_variables.ndb_force_send, - (gptr*) &global_system_variables.ndb_force_send, + (uchar**) &global_system_variables.ndb_force_send, + (uchar**) &global_system_variables.ndb_force_send, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, {"ndb_force_send", OPT_NDB_FORCE_SEND, "same as --ndb-force-send.", - (gptr*) &global_system_variables.ndb_force_send, - (gptr*) &global_system_variables.ndb_force_send, + (uchar**) &global_system_variables.ndb_force_send, + (uchar**) &global_system_variables.ndb_force_send, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, {"ndb-extra-logging", OPT_NDB_EXTRA_LOGGING, "Turn on more logging in the error log.", - (gptr*) &ndb_extra_logging, - (gptr*) &ndb_extra_logging, + (uchar**) &ndb_extra_logging, + (uchar**) &ndb_extra_logging, 0, GET_INT, OPT_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_NDB_BINLOG {"ndb-report-thresh-binlog-epoch-slip", OPT_NDB_REPORT_THRESH_BINLOG_EPOCH_SLIP, @@ -5474,113 +5478,113 @@ master-ssl", "E.g. 3 means that if the difference between what epoch has been received " "from the storage nodes and what has been applied to the binlog is 3 or more, " "a status message will be sent to the cluster log.", - (gptr*) &ndb_report_thresh_binlog_epoch_slip, - (gptr*) &ndb_report_thresh_binlog_epoch_slip, + (uchar**) &ndb_report_thresh_binlog_epoch_slip, + (uchar**) &ndb_report_thresh_binlog_epoch_slip, 0, GET_ULONG, REQUIRED_ARG, 3, 0, 256, 0, 0, 0}, {"ndb-report-thresh-binlog-mem-usage", OPT_NDB_REPORT_THRESH_BINLOG_MEM_USAGE, "Threshold on percentage of free memory before reporting binlog status. E.g. " "10 means that if amount of available memory for receiving binlog data from " "the storage nodes goes below 10%, " "a status message will be sent to the cluster log.", - (gptr*) &ndb_report_thresh_binlog_mem_usage, - (gptr*) &ndb_report_thresh_binlog_mem_usage, + (uchar**) &ndb_report_thresh_binlog_mem_usage, + (uchar**) &ndb_report_thresh_binlog_mem_usage, 0, GET_ULONG, REQUIRED_ARG, 10, 0, 100, 0, 0, 0}, #endif {"ndb-use-exact-count", OPT_NDB_USE_EXACT_COUNT, "Use exact records count during query planning and for fast " "select count(*), disable for faster queries.", - (gptr*) &global_system_variables.ndb_use_exact_count, - (gptr*) &global_system_variables.ndb_use_exact_count, + (uchar**) &global_system_variables.ndb_use_exact_count, + (uchar**) &global_system_variables.ndb_use_exact_count, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, {"ndb_use_exact_count", OPT_NDB_USE_EXACT_COUNT, "same as --ndb-use-exact-count.", - (gptr*) &global_system_variables.ndb_use_exact_count, - (gptr*) &global_system_variables.ndb_use_exact_count, + (uchar**) &global_system_variables.ndb_use_exact_count, + (uchar**) &global_system_variables.ndb_use_exact_count, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, {"ndb-use-transactions", OPT_NDB_USE_TRANSACTIONS, "Use transactions for large inserts, if enabled then large " "inserts will be split into several smaller transactions", - (gptr*) &global_system_variables.ndb_use_transactions, - (gptr*) &global_system_variables.ndb_use_transactions, + (uchar**) &global_system_variables.ndb_use_transactions, + (uchar**) &global_system_variables.ndb_use_transactions, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, {"ndb_use_transactions", OPT_NDB_USE_TRANSACTIONS, "same as --ndb-use-transactions.", - (gptr*) &global_system_variables.ndb_use_transactions, - (gptr*) &global_system_variables.ndb_use_transactions, + (uchar**) &global_system_variables.ndb_use_transactions, + (uchar**) &global_system_variables.ndb_use_transactions, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, {"ndb-shm", OPT_NDB_SHM, "Use shared memory connections when available.", - (gptr*) &opt_ndb_shm, - (gptr*) &opt_ndb_shm, + (uchar**) &opt_ndb_shm, + (uchar**) &opt_ndb_shm, 0, GET_BOOL, OPT_ARG, OPT_NDB_SHM_DEFAULT, 0, 0, 0, 0, 0}, {"ndb-optimized-node-selection", OPT_NDB_OPTIMIZED_NODE_SELECTION, "Select nodes for transactions in a more optimal way.", - (gptr*) &opt_ndb_optimized_node_selection, - (gptr*) &opt_ndb_optimized_node_selection, + (uchar**) &opt_ndb_optimized_node_selection, + (uchar**) &opt_ndb_optimized_node_selection, 0, GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0}, { "ndb-cache-check-time", OPT_NDB_CACHE_CHECK_TIME, "A dedicated thread is created to, at the given millisecons interval, invalidate the query cache if another MySQL server in the cluster has changed the data in the database.", - (gptr*) &opt_ndb_cache_check_time, (gptr*) &opt_ndb_cache_check_time, 0, GET_ULONG, REQUIRED_ARG, + (uchar**) &opt_ndb_cache_check_time, (uchar**) &opt_ndb_cache_check_time, 0, GET_ULONG, REQUIRED_ARG, 0, 0, LONG_TIMEOUT, 0, 1, 0}, {"ndb-index-stat-enable", OPT_NDB_INDEX_STAT_ENABLE, "Use ndb index statistics in query optimization.", - (gptr*) &global_system_variables.ndb_index_stat_enable, - (gptr*) &max_system_variables.ndb_index_stat_enable, + (uchar**) &global_system_variables.ndb_index_stat_enable, + (uchar**) &max_system_variables.ndb_index_stat_enable, 0, GET_BOOL, OPT_ARG, 0, 0, 1, 0, 0, 0}, #endif {"ndb-use-copying-alter-table", OPT_NDB_USE_COPYING_ALTER_TABLE, "Force ndbcluster to always copy tables at alter table (should only be used if on-line alter table fails).", - (gptr*) &global_system_variables.ndb_use_copying_alter_table, - (gptr*) &global_system_variables.ndb_use_copying_alter_table, + (uchar**) &global_system_variables.ndb_use_copying_alter_table, + (uchar**) &global_system_variables.ndb_use_copying_alter_table, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"new", 'n', "Use very new possible 'unsafe' functions.", - (gptr*) &global_system_variables.new_mode, - (gptr*) &max_system_variables.new_mode, + (uchar**) &global_system_variables.new_mode, + (uchar**) &max_system_variables.new_mode, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifdef NOT_YET {"no-mix-table-types", OPT_NO_MIX_TYPE, "Don't allow commands with uses two different table types.", - (gptr*) &opt_no_mix_types, (gptr*) &opt_no_mix_types, 0, GET_BOOL, NO_ARG, + (uchar**) &opt_no_mix_types, (uchar**) &opt_no_mix_types, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"old-alter-table", OPT_OLD_ALTER_TABLE, "Use old, non-optimized alter table.", - (gptr*) &global_system_variables.old_alter_table, - (gptr*) &max_system_variables.old_alter_table, 0, GET_BOOL, NO_ARG, + (uchar**) &global_system_variables.old_alter_table, + (uchar**) &max_system_variables.old_alter_table, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"old-passwords", OPT_OLD_PASSWORDS, "Use old password encryption method (needed for 4.0 and older clients).", - (gptr*) &global_system_variables.old_passwords, - (gptr*) &max_system_variables.old_passwords, 0, GET_BOOL, NO_ARG, + (uchar**) &global_system_variables.old_passwords, + (uchar**) &max_system_variables.old_passwords, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"one-thread", OPT_ONE_THREAD, "(deprecated): Only use one thread (for debugging under Linux). Use thread-handling=no-threads instead", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"old-style-user-limits", OPT_OLD_STYLE_USER_LIMITS, "Enable old-style user limits (before 5.0.3 user resources were counted per each user+host vs. per account)", - (gptr*) &opt_old_style_user_limits, (gptr*) &opt_old_style_user_limits, + (uchar**) &opt_old_style_user_limits, (uchar**) &opt_old_style_user_limits, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"pid-file", OPT_PID_FILE, "Pid file used by safe_mysqld.", - (gptr*) &pidfile_name_ptr, (gptr*) &pidfile_name_ptr, 0, GET_STR, + (uchar**) &pidfile_name_ptr, (uchar**) &pidfile_name_ptr, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Port number to use for connection.", (gptr*) &mysqld_port, - (gptr*) &mysqld_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"port", 'P', "Port number to use for connection.", (uchar**) &mysqld_port, + (uchar**) &mysqld_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"port-open-timeout", OPT_PORT_OPEN_TIMEOUT, "Maximum time in seconds to wait for the port to become free. " - "(Default: no wait)", (gptr*) &mysqld_port_timeout, - (gptr*) &mysqld_port_timeout, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "(Default: no wait)", (uchar**) &mysqld_port_timeout, + (uchar**) &mysqld_port_timeout, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"relay-log", OPT_RELAY_LOG, "The location and name to use for relay logs.", - (gptr*) &opt_relay_logname, (gptr*) &opt_relay_logname, 0, + (uchar**) &opt_relay_logname, (uchar**) &opt_relay_logname, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"relay-log-index", OPT_RELAY_LOG_INDEX, "The location and name to use for the file that keeps a list of the last \ relay logs.", - (gptr*) &opt_relaylog_index_name, (gptr*) &opt_relaylog_index_name, 0, + (uchar**) &opt_relaylog_index_name, (uchar**) &opt_relaylog_index_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"relay-log-info-file", OPT_RELAY_LOG_INFO_FILE, "The location and name of the file that remembers where the SQL replication \ thread is in the relay logs.", - (gptr*) &relay_log_info_file, (gptr*) &relay_log_info_file, 0, GET_STR, + (uchar**) &relay_log_info_file, (uchar**) &relay_log_info_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"replicate-do-db", OPT_REPLICATE_DO_DB, "Tells the slave thread to restrict replication to the specified database. To specify more than one database, use the directive multiple times, once for each database. Note that this will only work if you do not use cross-database queries such as UPDATE some_db.some_table SET foo='bar' while having selected a different or no database. If you need cross database updates to work, make sure you have 3.23.28 or later, and use replicate-wild-do-table=db_name.%.", @@ -5602,8 +5606,8 @@ thread is in the relay logs.", "In replication, if set to 1, do not skip events having our server id. \ Default value is 0 (to break infinite loops in circular replication). \ Can't be set to 1 if --log-slave-updates is used.", - (gptr*) &replicate_same_server_id, - (gptr*) &replicate_same_server_id, + (uchar**) &replicate_same_server_id, + (uchar**) &replicate_same_server_id, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"replicate-wild-do-table", OPT_REPLICATE_WILD_DO_TABLE, @@ -5615,19 +5619,19 @@ Can't be set to 1 if --log-slave-updates is used.", // In replication, we may need to tell the other servers how to connect {"report-host", OPT_REPORT_HOST, "Hostname or IP of the slave to be reported to to the master during slave registration. Will appear in the output of SHOW SLAVE HOSTS. Leave unset if you do not want the slave to register itself with the master. Note that it is not sufficient for the master to simply read the IP of the slave off the socket once the slave connects. Due to NAT and other routing issues, that IP may not be valid for connecting to the slave from the master or other hosts.", - (gptr*) &report_host, (gptr*) &report_host, 0, GET_STR, REQUIRED_ARG, 0, 0, + (uchar**) &report_host, (uchar**) &report_host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"report-password", OPT_REPORT_PASSWORD, "Undocumented.", - (gptr*) &report_password, (gptr*) &report_password, 0, GET_STR, + (uchar**) &report_password, (uchar**) &report_password, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"report-port", OPT_REPORT_PORT, "Port for connecting to slave reported to the master during slave registration. Set it only if the slave is listening on a non-default port or if you have a special tunnel from the master or other clients to the slave. If not sure, leave this option unset.", - (gptr*) &report_port, (gptr*) &report_port, 0, GET_UINT, REQUIRED_ARG, + (uchar**) &report_port, (uchar**) &report_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0}, - {"report-user", OPT_REPORT_USER, "Undocumented.", (gptr*) &report_user, - (gptr*) &report_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"report-user", OPT_REPORT_USER, "Undocumented.", (uchar**) &report_user, + (uchar**) &report_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"rpl-recovery-rank", OPT_RPL_RECOVERY_RANK, "Undocumented.", - (gptr*) &rpl_recovery_rank, (gptr*) &rpl_recovery_rank, 0, GET_ULONG, + (uchar**) &rpl_recovery_rank, (uchar**) &rpl_recovery_rank, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"safe-mode", OPT_SAFE, "Skip some optimize stages (for testing).", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -5638,43 +5642,43 @@ Can't be set to 1 if --log-slave-updates is used.", #endif {"safe-user-create", OPT_SAFE_USER_CREATE, "Don't allow new user creation by the user who has no write privileges to the mysql.user table.", - (gptr*) &opt_safe_user_create, (gptr*) &opt_safe_user_create, 0, GET_BOOL, + (uchar**) &opt_safe_user_create, (uchar**) &opt_safe_user_create, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"safemalloc-mem-limit", OPT_SAFEMALLOC_MEM_LIMIT, "Simulate memory shortage when compiled with the --with-debug=full option.", 0, 0, 0, GET_ULL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"secure-auth", OPT_SECURE_AUTH, "Disallow authentication for accounts that have old (pre-4.1) passwords.", - (gptr*) &opt_secure_auth, (gptr*) &opt_secure_auth, 0, GET_BOOL, NO_ARG, + (uchar**) &opt_secure_auth, (uchar**) &opt_secure_auth, 0, GET_BOOL, NO_ARG, my_bool(0), 0, 0, 0, 0, 0}, {"secure-file-priv", OPT_SECURE_FILE_PRIV, "Limit LOAD DATA, SELECT ... OUTFILE, and LOAD_FILE() to files within specified directory", - (gptr*) &opt_secure_file_priv, (gptr*) &opt_secure_file_priv, 0, + (uchar**) &opt_secure_file_priv, (uchar**) &opt_secure_file_priv, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"server-id", OPT_SERVER_ID, "Uniquely identifies the server instance in the community of replication partners.", - (gptr*) &server_id, (gptr*) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, + (uchar**) &server_id, (uchar**) &server_id, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"set-variable", 'O', "Change the value of a variable. Please note that this option is deprecated;you can set variables directly with --variable-name=value.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM {"shared-memory", OPT_ENABLE_SHARED_MEMORY, - "Enable the shared memory.",(gptr*) &opt_enable_shared_memory, (gptr*) &opt_enable_shared_memory, + "Enable the shared memory.",(uchar**) &opt_enable_shared_memory, (uchar**) &opt_enable_shared_memory, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif #ifdef HAVE_SMEM {"shared-memory-base-name",OPT_SHARED_MEMORY_BASE_NAME, - "Base name of shared memory.", (gptr*) &shared_memory_base_name, (gptr*) &shared_memory_base_name, + "Base name of shared memory.", (uchar**) &shared_memory_base_name, (uchar**) &shared_memory_base_name, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif {"show-slave-auth-info", OPT_SHOW_SLAVE_AUTH_INFO, "Show user and password in SHOW SLAVE HOSTS on this master", - (gptr*) &opt_show_slave_auth_info, (gptr*) &opt_show_slave_auth_info, 0, + (uchar**) &opt_show_slave_auth_info, (uchar**) &opt_show_slave_auth_info, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifndef DISABLE_GRANT_OPTIONS {"skip-grant-tables", OPT_SKIP_GRANT, "Start without grant tables. This gives all users FULL ACCESS to all tables!", - (gptr*) &opt_noacl, (gptr*) &opt_noacl, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, + (uchar**) &opt_noacl, (uchar**) &opt_noacl, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"skip-host-cache", OPT_SKIP_HOST_CACHE, "Don't cache host names.", 0, 0, 0, @@ -5701,8 +5705,8 @@ Can't be set to 1 if --log-slave-updates is used.", "Don't allow 'SHOW DATABASE' commands.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"skip-slave-start", OPT_SKIP_SLAVE_START, - "If set, slave is not autostarted.", (gptr*) &opt_skip_slave_start, - (gptr*) &opt_skip_slave_start, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + "If set, slave is not autostarted.", (uchar**) &opt_skip_slave_start, + (uchar**) &opt_skip_slave_start, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"skip-stack-trace", OPT_SKIP_STACK_TRACE, "Don't print a stack trace on failure.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -5715,23 +5719,23 @@ Can't be set to 1 if --log-slave-updates is used.", {"slave-load-tmpdir", OPT_SLAVE_LOAD_TMPDIR, "The location where the slave should put its temporary files when \ replicating a LOAD DATA INFILE command.", - (gptr*) &slave_load_tmpdir, (gptr*) &slave_load_tmpdir, 0, GET_STR_ALLOC, + (uchar**) &slave_load_tmpdir, (uchar**) &slave_load_tmpdir, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"slave-skip-errors", OPT_SLAVE_SKIP_ERRORS, "Tells the slave thread to continue replication when a query returns an error from the provided list.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif {"slow-query-log", OPT_SLOW_LOG, - "Enable|disable slow query log", (gptr*) &opt_slow_log, - (gptr*) &opt_slow_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, + "Enable|disable slow query log", (uchar**) &opt_slow_log, + (uchar**) &opt_slow_log, 0, GET_BOOL, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"socket", OPT_SOCKET, "Socket file to use for connection.", - (gptr*) &mysqld_unix_port, (gptr*) &mysqld_unix_port, 0, GET_STR, + (uchar**) &mysqld_unix_port, (uchar**) &mysqld_unix_port, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_REPLICATION {"sporadic-binlog-dump-fail", OPT_SPORADIC_BINLOG_DUMP_FAIL, "Option used by mysql-test for debugging and testing of replication.", - (gptr*) &opt_sporadic_binlog_dump_fail, - (gptr*) &opt_sporadic_binlog_dump_fail, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, + (uchar**) &opt_sporadic_binlog_dump_fail, + (uchar**) &opt_sporadic_binlog_dump_fail, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif /* HAVE_REPLICATION */ {"sql-bin-update-same", OPT_SQL_BIN_UPDATE_SAME, @@ -5740,7 +5744,7 @@ log and this option does nothing anymore.", 0, 0, 0, GET_DISABLED, NO_ARG, 0, 0, 0, 0, 0, 0}, {"sql-mode", OPT_SQL_MODE, "Syntax: sql-mode=option[,option[,option...]] where option can be one of: REAL_AS_FLOAT, PIPES_AS_CONCAT, ANSI_QUOTES, IGNORE_SPACE, ONLY_FULL_GROUP_BY, NO_UNSIGNED_SUBTRACTION.", - (gptr*) &sql_mode_str, (gptr*) &sql_mode_str, 0, GET_STR, REQUIRED_ARG, 0, + (uchar**) &sql_mode_str, (uchar**) &sql_mode_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_OPENSSL #include "sslopt-longopts.h" @@ -5751,7 +5755,7 @@ log and this option does nothing anymore.", NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"symbolic-links", 's', "Enable symbolic link support.", - (gptr*) &my_use_symdir, (gptr*) &my_use_symdir, 0, GET_BOOL, NO_ARG, + (uchar**) &my_use_symdir, (uchar**) &my_use_symdir, 0, GET_BOOL, NO_ARG, /* The system call realpath() produces warnings under valgrind and purify. These are not suppressed: instead we disable symlinks @@ -5760,19 +5764,19 @@ log and this option does nothing anymore.", IF_PURIFY(0,1), 0, 0, 0, 0, 0}, {"sysdate-is-now", OPT_SYSDATE_IS_NOW, "Non-default option to alias SYSDATE() to NOW() to make it safe-replicable. Since 5.0, SYSDATE() returns a `dynamic' value different for different invocations, even within the same statement.", - (gptr*) &global_system_variables.sysdate_is_now, + (uchar**) &global_system_variables.sysdate_is_now, 0, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0}, {"tc-heuristic-recover", OPT_TC_HEURISTIC_RECOVER, "Decision to use in heuristic recover process. Possible values are COMMIT or ROLLBACK.", - (gptr*) &opt_tc_heuristic_recover, (gptr*) &opt_tc_heuristic_recover, + (uchar**) &opt_tc_heuristic_recover, (uchar**) &opt_tc_heuristic_recover, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"temp-pool", OPT_TEMP_POOL, "Using this option will cause most temporary files created to use a small set of names, rather than a unique name for each new file.", - (gptr*) &use_temp_pool, (gptr*) &use_temp_pool, 0, GET_BOOL, NO_ARG, 1, + (uchar**) &use_temp_pool, (uchar**) &use_temp_pool, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"timed_mutexes", OPT_TIMED_MUTEXES, "Specify whether to time mutexes (only InnoDB mutexes are currently supported)", - (gptr*) &timed_mutexes, (gptr*) &timed_mutexes, 0, GET_BOOL, NO_ARG, 0, + (uchar**) &timed_mutexes, (uchar**) &timed_mutexes, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"tmpdir", 't', "Path for temporary files. Several paths may be specified, separated by a " @@ -5782,83 +5786,83 @@ log and this option does nothing anymore.", "colon (:)" #endif ", in this case they are used in a round-robin fashion.", - (gptr*) &opt_mysql_tmpdir, - (gptr*) &opt_mysql_tmpdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + (uchar**) &opt_mysql_tmpdir, + (uchar**) &opt_mysql_tmpdir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"transaction-isolation", OPT_TX_ISOLATION, "Default transaction isolation level.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"use-symbolic-links", 's', "Enable symbolic link support. Deprecated option; use --symbolic-links instead.", - (gptr*) &my_use_symdir, (gptr*) &my_use_symdir, 0, GET_BOOL, NO_ARG, + (uchar**) &my_use_symdir, (uchar**) &my_use_symdir, 0, GET_BOOL, NO_ARG, IF_PURIFY(0,1), 0, 0, 0, 0, 0}, {"user", 'u', "Run mysqld daemon as user.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"verbose", 'v', "Used with --help option for detailed help", - (gptr*) &opt_verbose, (gptr*) &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, + (uchar**) &opt_verbose, (uchar**) &opt_verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"warnings", 'W', "Deprecated; use --log-warnings instead.", - (gptr*) &global_system_variables.log_warnings, - (gptr*) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, ~0L, + (uchar**) &global_system_variables.log_warnings, + (uchar**) &max_system_variables.log_warnings, 0, GET_ULONG, OPT_ARG, 1, 0, ~0L, 0, 0, 0}, { "back_log", OPT_BACK_LOG, "The number of outstanding connection requests MySQL can have. This comes into play when the main MySQL thread gets very many connection requests in a very short time.", - (gptr*) &back_log, (gptr*) &back_log, 0, GET_ULONG, + (uchar**) &back_log, (uchar**) &back_log, 0, GET_ULONG, REQUIRED_ARG, 50, 1, 65535, 0, 1, 0 }, {"binlog_cache_size", OPT_BINLOG_CACHE_SIZE, "The size of the cache to hold the SQL statements for the binary log during a transaction. If you often use big, multi-statement transactions you can increase this to get more performance.", - (gptr*) &binlog_cache_size, (gptr*) &binlog_cache_size, 0, GET_ULONG, + (uchar**) &binlog_cache_size, (uchar**) &binlog_cache_size, 0, GET_ULONG, REQUIRED_ARG, 32*1024L, IO_SIZE, ~0L, 0, IO_SIZE, 0}, {"bulk_insert_buffer_size", OPT_BULK_INSERT_BUFFER_SIZE, "Size of tree cache used in bulk insert optimisation. Note that this is a limit per thread!", - (gptr*) &global_system_variables.bulk_insert_buff_size, - (gptr*) &max_system_variables.bulk_insert_buff_size, + (uchar**) &global_system_variables.bulk_insert_buff_size, + (uchar**) &max_system_variables.bulk_insert_buff_size, 0, GET_ULONG, REQUIRED_ARG, 8192*1024, 0, ~0L, 0, 1, 0}, {"connect_timeout", OPT_CONNECT_TIMEOUT, "The number of seconds the mysqld server is waiting for a connect packet before responding with 'Bad handshake'.", - (gptr*) &connect_timeout, (gptr*) &connect_timeout, + (uchar**) &connect_timeout, (uchar**) &connect_timeout, 0, GET_ULONG, REQUIRED_ARG, CONNECT_TIMEOUT, 2, LONG_TIMEOUT, 0, 1, 0 }, { "date_format", OPT_DATE_FORMAT, "The DATE format (For future).", - (gptr*) &opt_date_time_formats[MYSQL_TIMESTAMP_DATE], - (gptr*) &opt_date_time_formats[MYSQL_TIMESTAMP_DATE], + (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_DATE], + (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_DATE], 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "datetime_format", OPT_DATETIME_FORMAT, "The DATETIME/TIMESTAMP format (for future).", - (gptr*) &opt_date_time_formats[MYSQL_TIMESTAMP_DATETIME], - (gptr*) &opt_date_time_formats[MYSQL_TIMESTAMP_DATETIME], + (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_DATETIME], + (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_DATETIME], 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "default_week_format", OPT_DEFAULT_WEEK_FORMAT, "The default week format used by WEEK() functions.", - (gptr*) &global_system_variables.default_week_format, - (gptr*) &max_system_variables.default_week_format, + (uchar**) &global_system_variables.default_week_format, + (uchar**) &max_system_variables.default_week_format, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 7L, 0, 1, 0}, {"delayed_insert_limit", OPT_DELAYED_INSERT_LIMIT, "After inserting delayed_insert_limit rows, the INSERT DELAYED handler will check if there are any SELECT statements pending. If so, it allows these to execute before continuing.", - (gptr*) &delayed_insert_limit, (gptr*) &delayed_insert_limit, 0, GET_ULONG, + (uchar**) &delayed_insert_limit, (uchar**) &delayed_insert_limit, 0, GET_ULONG, REQUIRED_ARG, DELAYED_LIMIT, 1, ~0L, 0, 1, 0}, {"delayed_insert_timeout", OPT_DELAYED_INSERT_TIMEOUT, "How long a INSERT DELAYED thread should wait for INSERT statements before terminating.", - (gptr*) &delayed_insert_timeout, (gptr*) &delayed_insert_timeout, 0, + (uchar**) &delayed_insert_timeout, (uchar**) &delayed_insert_timeout, 0, GET_ULONG, REQUIRED_ARG, DELAYED_WAIT_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0}, { "delayed_queue_size", OPT_DELAYED_QUEUE_SIZE, "What size queue (in rows) should be allocated for handling INSERT DELAYED. If the queue becomes full, any client that does INSERT DELAYED will wait until there is room in the queue again.", - (gptr*) &delayed_queue_size, (gptr*) &delayed_queue_size, 0, GET_ULONG, + (uchar**) &delayed_queue_size, (uchar**) &delayed_queue_size, 0, GET_ULONG, REQUIRED_ARG, DELAYED_QUEUE_SIZE, 1, ~0L, 0, 1, 0}, {"div_precision_increment", OPT_DIV_PRECINCREMENT, "Precision of the result of '/' operator will be increased on that value.", - (gptr*) &global_system_variables.div_precincrement, - (gptr*) &max_system_variables.div_precincrement, 0, GET_ULONG, + (uchar**) &global_system_variables.div_precincrement, + (uchar**) &max_system_variables.div_precincrement, 0, GET_ULONG, REQUIRED_ARG, 4, 0, DECIMAL_MAX_SCALE, 0, 0, 0}, {"expire_logs_days", OPT_EXPIRE_LOGS_DAYS, "If non-zero, binary logs will be purged after expire_logs_days " "days; possible purges happen at startup and at binary log rotation.", - (gptr*) &expire_logs_days, - (gptr*) &expire_logs_days, 0, GET_ULONG, + (uchar**) &expire_logs_days, + (uchar**) &expire_logs_days, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 99, 0, 1, 0}, { "flush_time", OPT_FLUSH_TIME, "A dedicated thread is created to flush all tables at the given interval.", - (gptr*) &flush_time, (gptr*) &flush_time, 0, GET_ULONG, REQUIRED_ARG, + (uchar**) &flush_time, (uchar**) &flush_time, 0, GET_ULONG, REQUIRED_ARG, FLUSH_TIME, 0, LONG_TIMEOUT, 0, 1, 0}, { "ft_boolean_syntax", OPT_FT_BOOLEAN_SYNTAX, "List of operators for MATCH ... AGAINST ( ... IN BOOLEAN MODE)", @@ -5866,70 +5870,70 @@ log and this option does nothing anymore.", REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "ft_max_word_len", OPT_FT_MAX_WORD_LEN, "The maximum length of the word to be included in a FULLTEXT index. Note: FULLTEXT indexes must be rebuilt after changing this variable.", - (gptr*) &ft_max_word_len, (gptr*) &ft_max_word_len, 0, GET_ULONG, + (uchar**) &ft_max_word_len, (uchar**) &ft_max_word_len, 0, GET_ULONG, REQUIRED_ARG, HA_FT_MAXCHARLEN, 10, HA_FT_MAXCHARLEN, 0, 1, 0}, { "ft_min_word_len", OPT_FT_MIN_WORD_LEN, "The minimum length of the word to be included in a FULLTEXT index. Note: FULLTEXT indexes must be rebuilt after changing this variable.", - (gptr*) &ft_min_word_len, (gptr*) &ft_min_word_len, 0, GET_ULONG, + (uchar**) &ft_min_word_len, (uchar**) &ft_min_word_len, 0, GET_ULONG, REQUIRED_ARG, 4, 1, HA_FT_MAXCHARLEN, 0, 1, 0}, { "ft_query_expansion_limit", OPT_FT_QUERY_EXPANSION_LIMIT, "Number of best matches to use for query expansion", - (gptr*) &ft_query_expansion_limit, (gptr*) &ft_query_expansion_limit, 0, GET_ULONG, + (uchar**) &ft_query_expansion_limit, (uchar**) &ft_query_expansion_limit, 0, GET_ULONG, REQUIRED_ARG, 20, 0, 1000, 0, 1, 0}, { "ft_stopword_file", OPT_FT_STOPWORD_FILE, "Use stopwords from this file instead of built-in list.", - (gptr*) &ft_stopword_file, (gptr*) &ft_stopword_file, 0, GET_STR, + (uchar**) &ft_stopword_file, (uchar**) &ft_stopword_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "group_concat_max_len", OPT_GROUP_CONCAT_MAX_LEN, "The maximum length of the result of function group_concat.", - (gptr*) &global_system_variables.group_concat_max_len, - (gptr*) &max_system_variables.group_concat_max_len, 0, GET_ULONG, + (uchar**) &global_system_variables.group_concat_max_len, + (uchar**) &max_system_variables.group_concat_max_len, 0, GET_ULONG, REQUIRED_ARG, 1024, 4, (long) ~0, 0, 1, 0}, {"interactive_timeout", OPT_INTERACTIVE_TIMEOUT, "The number of seconds the server waits for activity on an interactive connection before closing it.", - (gptr*) &global_system_variables.net_interactive_timeout, - (gptr*) &max_system_variables.net_interactive_timeout, 0, + (uchar**) &global_system_variables.net_interactive_timeout, + (uchar**) &max_system_variables.net_interactive_timeout, 0, GET_ULONG, REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0}, {"join_buffer_size", OPT_JOIN_BUFF_SIZE, "The size of the buffer that is used for full joins.", - (gptr*) &global_system_variables.join_buff_size, - (gptr*) &max_system_variables.join_buff_size, 0, GET_ULONG, + (uchar**) &global_system_variables.join_buff_size, + (uchar**) &max_system_variables.join_buff_size, 0, GET_ULONG, REQUIRED_ARG, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, ~0L, MALLOC_OVERHEAD, IO_SIZE, 0}, {"key_buffer_size", OPT_KEY_BUFFER_SIZE, "The size of the buffer used for index blocks for MyISAM tables. Increase this to get better index handling (for all reads and multiple writes) to as much as you can afford; 64M on a 256M machine that mainly runs MySQL is quite common.", - (gptr*) &dflt_key_cache_var.param_buff_size, - (gptr*) 0, + (uchar**) &dflt_key_cache_var.param_buff_size, + (uchar**) 0, 0, (GET_ULL | GET_ASK_ADDR), REQUIRED_ARG, KEY_CACHE_SIZE, MALLOC_OVERHEAD, ~(ulong) 0, MALLOC_OVERHEAD, IO_SIZE, 0}, {"key_cache_age_threshold", OPT_KEY_CACHE_AGE_THRESHOLD, "This characterizes the number of hits a hot block has to be untouched until it is considered aged enough to be downgraded to a warm block. This specifies the percentage ratio of that number of hits to the total number of blocks in key cache", - (gptr*) &dflt_key_cache_var.param_age_threshold, - (gptr*) 0, + (uchar**) &dflt_key_cache_var.param_age_threshold, + (uchar**) 0, 0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, 300, 100, ~0L, 0, 100, 0}, {"key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE, "The default size of key cache blocks", - (gptr*) &dflt_key_cache_var.param_block_size, - (gptr*) 0, + (uchar**) &dflt_key_cache_var.param_block_size, + (uchar**) 0, 0, (GET_ULONG | GET_ASK_ADDR), REQUIRED_ARG, KEY_CACHE_BLOCK_SIZE , 512, 1024*16, MALLOC_OVERHEAD, 512, 0}, {"key_cache_division_limit", OPT_KEY_CACHE_DIVISION_LIMIT, "The minimum percentage of warm blocks in key cache", - (gptr*) &dflt_key_cache_var.param_division_limit, - (gptr*) 0, + (uchar**) &dflt_key_cache_var.param_division_limit, + (uchar**) 0, 0, (GET_ULONG | GET_ASK_ADDR) , REQUIRED_ARG, 100, 1, 100, 0, 1, 0}, {"long_query_time", OPT_LONG_QUERY_TIME, "Log all queries that have taken more than long_query_time seconds to execute to file.", - (gptr*) &global_system_variables.long_query_time, - (gptr*) &max_system_variables.long_query_time, 0, GET_ULONG, + (uchar**) &global_system_variables.long_query_time, + (uchar**) &max_system_variables.long_query_time, 0, GET_ULONG, REQUIRED_ARG, 10, 1, LONG_TIMEOUT, 0, 1, 0}, {"lower_case_table_names", OPT_LOWER_CASE_TABLE_NAMES, "If set to 1 table names are stored in lowercase on disk and table names will be case-insensitive. Should be set to 2 if you are using a case insensitive file system", - (gptr*) &lower_case_table_names, - (gptr*) &lower_case_table_names, 0, GET_UINT, OPT_ARG, + (uchar**) &lower_case_table_names, + (uchar**) &lower_case_table_names, 0, GET_UINT, OPT_ARG, #ifdef FN_NO_CASE_SENCE 1 #else @@ -5938,356 +5942,356 @@ log and this option does nothing anymore.", , 0, 2, 0, 1, 0}, {"max_allowed_packet", OPT_MAX_ALLOWED_PACKET, "Max packetlength to send/receive from to server.", - (gptr*) &global_system_variables.max_allowed_packet, - (gptr*) &max_system_variables.max_allowed_packet, 0, GET_ULONG, + (uchar**) &global_system_variables.max_allowed_packet, + (uchar**) &max_system_variables.max_allowed_packet, 0, GET_ULONG, REQUIRED_ARG, 1024*1024L, 1024, 1024L*1024L*1024L, MALLOC_OVERHEAD, 1024, 0}, {"max_binlog_cache_size", OPT_MAX_BINLOG_CACHE_SIZE, "Can be used to restrict the total size used to cache a multi-transaction query.", - (gptr*) &max_binlog_cache_size, (gptr*) &max_binlog_cache_size, 0, + (uchar**) &max_binlog_cache_size, (uchar**) &max_binlog_cache_size, 0, GET_ULONG, REQUIRED_ARG, ~0L, IO_SIZE, ~0L, 0, IO_SIZE, 0}, {"max_binlog_size", OPT_MAX_BINLOG_SIZE, "Binary log will be rotated automatically when the size exceeds this \ value. Will also apply to relay logs if max_relay_log_size is 0. \ The minimum value for this variable is 4096.", - (gptr*) &max_binlog_size, (gptr*) &max_binlog_size, 0, GET_ULONG, + (uchar**) &max_binlog_size, (uchar**) &max_binlog_size, 0, GET_ULONG, REQUIRED_ARG, 1024*1024L*1024L, IO_SIZE, 1024*1024L*1024L, 0, IO_SIZE, 0}, {"max_connect_errors", OPT_MAX_CONNECT_ERRORS, "If there is more than this number of interrupted connections from a host this host will be blocked from further connections.", - (gptr*) &max_connect_errors, (gptr*) &max_connect_errors, 0, GET_ULONG, + (uchar**) &max_connect_errors, (uchar**) &max_connect_errors, 0, GET_ULONG, REQUIRED_ARG, MAX_CONNECT_ERRORS, 1, ~0L, 0, 1, 0}, // Default max_connections of 151 is larger than Apache's default max // children, to avoid "too many connections" error in a common setup {"max_connections", OPT_MAX_CONNECTIONS, - "The number of simultaneous clients allowed.", (gptr*) &max_connections, - (gptr*) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 151, 1, 100000, 0, 1, + "The number of simultaneous clients allowed.", (uchar**) &max_connections, + (uchar**) &max_connections, 0, GET_ULONG, REQUIRED_ARG, 151, 1, 100000, 0, 1, 0}, {"max_delayed_threads", OPT_MAX_DELAYED_THREADS, "Don't start more than this number of threads to handle INSERT DELAYED statements. If set to zero, which means INSERT DELAYED is not used.", - (gptr*) &global_system_variables.max_insert_delayed_threads, - (gptr*) &max_system_variables.max_insert_delayed_threads, + (uchar**) &global_system_variables.max_insert_delayed_threads, + (uchar**) &max_system_variables.max_insert_delayed_threads, 0, GET_ULONG, REQUIRED_ARG, 20, 0, 16384, 0, 1, 0}, {"max_error_count", OPT_MAX_ERROR_COUNT, "Max number of errors/warnings to store for a statement.", - (gptr*) &global_system_variables.max_error_count, - (gptr*) &max_system_variables.max_error_count, + (uchar**) &global_system_variables.max_error_count, + (uchar**) &max_system_variables.max_error_count, 0, GET_ULONG, REQUIRED_ARG, DEFAULT_ERROR_COUNT, 0, 65535, 0, 1, 0}, {"max_heap_table_size", OPT_MAX_HEP_TABLE_SIZE, "Don't allow creation of heap tables bigger than this.", - (gptr*) &global_system_variables.max_heap_table_size, - (gptr*) &max_system_variables.max_heap_table_size, 0, GET_ULL, + (uchar**) &global_system_variables.max_heap_table_size, + (uchar**) &max_system_variables.max_heap_table_size, 0, GET_ULL, REQUIRED_ARG, 16*1024*1024L, 16384, MAX_MEM_TABLE_SIZE, MALLOC_OVERHEAD, 1024, 0}, {"max_join_size", OPT_MAX_JOIN_SIZE, "Joins that are probably going to read more than max_join_size records return an error.", - (gptr*) &global_system_variables.max_join_size, - (gptr*) &max_system_variables.max_join_size, 0, GET_HA_ROWS, REQUIRED_ARG, + (uchar**) &global_system_variables.max_join_size, + (uchar**) &max_system_variables.max_join_size, 0, GET_HA_ROWS, REQUIRED_ARG, ~0L, 1, ~0L, 0, 1, 0}, {"max_length_for_sort_data", OPT_MAX_LENGTH_FOR_SORT_DATA, "Max number of bytes in sorted records.", - (gptr*) &global_system_variables.max_length_for_sort_data, - (gptr*) &max_system_variables.max_length_for_sort_data, 0, GET_ULONG, + (uchar**) &global_system_variables.max_length_for_sort_data, + (uchar**) &max_system_variables.max_length_for_sort_data, 0, GET_ULONG, REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0}, {"max_prepared_stmt_count", OPT_MAX_PREPARED_STMT_COUNT, "Maximum number of prepared statements in the server.", - (gptr*) &max_prepared_stmt_count, (gptr*) &max_prepared_stmt_count, + (uchar**) &max_prepared_stmt_count, (uchar**) &max_prepared_stmt_count, 0, GET_ULONG, REQUIRED_ARG, 16382, 0, 1*1024*1024, 0, 1, 0}, {"max_relay_log_size", OPT_MAX_RELAY_LOG_SIZE, "If non-zero: relay log will be rotated automatically when the size exceeds this value; if zero (the default): when the size exceeds max_binlog_size. 0 excepted, the minimum value for this variable is 4096.", - (gptr*) &max_relay_log_size, (gptr*) &max_relay_log_size, 0, GET_ULONG, + (uchar**) &max_relay_log_size, (uchar**) &max_relay_log_size, 0, GET_ULONG, REQUIRED_ARG, 0L, 0L, 1024*1024L*1024L, 0, IO_SIZE, 0}, { "max_seeks_for_key", OPT_MAX_SEEKS_FOR_KEY, "Limit assumed max number of seeks when looking up rows based on a key", - (gptr*) &global_system_variables.max_seeks_for_key, - (gptr*) &max_system_variables.max_seeks_for_key, 0, GET_ULONG, + (uchar**) &global_system_variables.max_seeks_for_key, + (uchar**) &max_system_variables.max_seeks_for_key, 0, GET_ULONG, REQUIRED_ARG, ~0L, 1, ~0L, 0, 1, 0 }, {"max_sort_length", OPT_MAX_SORT_LENGTH, "The number of bytes to use when sorting BLOB or TEXT values (only the first max_sort_length bytes of each value are used; the rest are ignored).", - (gptr*) &global_system_variables.max_sort_length, - (gptr*) &max_system_variables.max_sort_length, 0, GET_ULONG, + (uchar**) &global_system_variables.max_sort_length, + (uchar**) &max_system_variables.max_sort_length, 0, GET_ULONG, REQUIRED_ARG, 1024, 4, 8192*1024L, 0, 1, 0}, {"max_sp_recursion_depth", OPT_MAX_SP_RECURSION_DEPTH, "Maximum stored procedure recursion depth. (discussed with docs).", - (gptr*) &global_system_variables.max_sp_recursion_depth, - (gptr*) &max_system_variables.max_sp_recursion_depth, 0, GET_ULONG, + (uchar**) &global_system_variables.max_sp_recursion_depth, + (uchar**) &max_system_variables.max_sp_recursion_depth, 0, GET_ULONG, OPT_ARG, 0, 0, 255, 0, 1, 0 }, {"max_tmp_tables", OPT_MAX_TMP_TABLES, "Maximum number of temporary tables a client can keep open at a time.", - (gptr*) &global_system_variables.max_tmp_tables, - (gptr*) &max_system_variables.max_tmp_tables, 0, GET_ULONG, + (uchar**) &global_system_variables.max_tmp_tables, + (uchar**) &max_system_variables.max_tmp_tables, 0, GET_ULONG, REQUIRED_ARG, 32, 1, ~0L, 0, 1, 0}, {"max_user_connections", OPT_MAX_USER_CONNECTIONS, "The maximum number of active connections for a single user (0 = no limit).", - (gptr*) &max_user_connections, (gptr*) &max_user_connections, 0, GET_UINT, + (uchar**) &max_user_connections, (uchar**) &max_user_connections, 0, GET_UINT, REQUIRED_ARG, 0, 1, ~0, 0, 1, 0}, {"max_write_lock_count", OPT_MAX_WRITE_LOCK_COUNT, "After this many write locks, allow some read locks to run in between.", - (gptr*) &max_write_lock_count, (gptr*) &max_write_lock_count, 0, GET_ULONG, + (uchar**) &max_write_lock_count, (uchar**) &max_write_lock_count, 0, GET_ULONG, REQUIRED_ARG, ~0L, 1, ~0L, 0, 1, 0}, {"multi_range_count", OPT_MULTI_RANGE_COUNT, "Number of key ranges to request at once.", - (gptr*) &global_system_variables.multi_range_count, - (gptr*) &max_system_variables.multi_range_count, 0, + (uchar**) &global_system_variables.multi_range_count, + (uchar**) &max_system_variables.multi_range_count, 0, GET_ULONG, REQUIRED_ARG, 256, 1, ~0L, 0, 1, 0}, {"myisam_block_size", OPT_MYISAM_BLOCK_SIZE, "Block size to be used for MyISAM index pages.", - (gptr*) &opt_myisam_block_size, - (gptr*) &opt_myisam_block_size, 0, GET_ULONG, REQUIRED_ARG, + (uchar**) &opt_myisam_block_size, + (uchar**) &opt_myisam_block_size, 0, GET_ULONG, REQUIRED_ARG, MI_KEY_BLOCK_LENGTH, MI_MIN_KEY_BLOCK_LENGTH, MI_MAX_KEY_BLOCK_LENGTH, 0, MI_MIN_KEY_BLOCK_LENGTH, 0}, {"myisam_data_pointer_size", OPT_MYISAM_DATA_POINTER_SIZE, "Default pointer size to be used for MyISAM tables.", - (gptr*) &myisam_data_pointer_size, - (gptr*) &myisam_data_pointer_size, 0, GET_ULONG, REQUIRED_ARG, + (uchar**) &myisam_data_pointer_size, + (uchar**) &myisam_data_pointer_size, 0, GET_ULONG, REQUIRED_ARG, 6, 2, 7, 0, 1, 0}, {"myisam_max_extra_sort_file_size", OPT_MYISAM_MAX_EXTRA_SORT_FILE_SIZE, "Deprecated option", - (gptr*) &global_system_variables.myisam_max_extra_sort_file_size, - (gptr*) &max_system_variables.myisam_max_extra_sort_file_size, + (uchar**) &global_system_variables.myisam_max_extra_sort_file_size, + (uchar**) &max_system_variables.myisam_max_extra_sort_file_size, 0, GET_ULL, REQUIRED_ARG, (ulonglong) MI_MAX_TEMP_LENGTH, 0, (ulonglong) MAX_FILE_SIZE, 0, 1, 0}, {"myisam_max_sort_file_size", OPT_MYISAM_MAX_SORT_FILE_SIZE, "Don't use the fast sort index method to created index if the temporary file would get bigger than this.", - (gptr*) &global_system_variables.myisam_max_sort_file_size, - (gptr*) &max_system_variables.myisam_max_sort_file_size, 0, + (uchar**) &global_system_variables.myisam_max_sort_file_size, + (uchar**) &max_system_variables.myisam_max_sort_file_size, 0, GET_ULL, REQUIRED_ARG, (longlong) LONG_MAX, 0, (ulonglong) MAX_FILE_SIZE, 0, 1024*1024, 0}, {"myisam_repair_threads", OPT_MYISAM_REPAIR_THREADS, "Number of threads to use when repairing MyISAM tables. The value of 1 disables parallel repair.", - (gptr*) &global_system_variables.myisam_repair_threads, - (gptr*) &max_system_variables.myisam_repair_threads, 0, + (uchar**) &global_system_variables.myisam_repair_threads, + (uchar**) &max_system_variables.myisam_repair_threads, 0, GET_ULONG, REQUIRED_ARG, 1, 1, ~0L, 0, 1, 0}, {"myisam_sort_buffer_size", OPT_MYISAM_SORT_BUFFER_SIZE, "The buffer that is allocated when sorting the index when doing a REPAIR or when creating indexes with CREATE INDEX or ALTER TABLE.", - (gptr*) &global_system_variables.myisam_sort_buff_size, - (gptr*) &max_system_variables.myisam_sort_buff_size, 0, + (uchar**) &global_system_variables.myisam_sort_buff_size, + (uchar**) &max_system_variables.myisam_sort_buff_size, 0, GET_ULONG, REQUIRED_ARG, 8192*1024, 4, ~0L, 0, 1, 0}, {"myisam_use_mmap", OPT_MYISAM_USE_MMAP, "Use memory mapping for reading and writing MyISAM tables", - (gptr*) &opt_myisam_use_mmap, - (gptr*) &opt_myisam_use_mmap, 0, GET_BOOL, NO_ARG, 0, + (uchar**) &opt_myisam_use_mmap, + (uchar**) &opt_myisam_use_mmap, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"myisam_stats_method", OPT_MYISAM_STATS_METHOD, "Specifies how MyISAM index statistics collection code should threat NULLs. " "Possible values of name are \"nulls_unequal\" (default behavior for 4.1/5.0), " "\"nulls_equal\" (emulate 4.0 behavior), and \"nulls_ignored\".", - (gptr*) &myisam_stats_method_str, (gptr*) &myisam_stats_method_str, 0, + (uchar**) &myisam_stats_method_str, (uchar**) &myisam_stats_method_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"net_buffer_length", OPT_NET_BUFFER_LENGTH, "Buffer length for TCP/IP and socket communication.", - (gptr*) &global_system_variables.net_buffer_length, - (gptr*) &max_system_variables.net_buffer_length, 0, GET_ULONG, + (uchar**) &global_system_variables.net_buffer_length, + (uchar**) &max_system_variables.net_buffer_length, 0, GET_ULONG, REQUIRED_ARG, 16384, 1024, 1024*1024L, 0, 1024, 0}, {"net_read_timeout", OPT_NET_READ_TIMEOUT, "Number of seconds to wait for more data from a connection before aborting the read.", - (gptr*) &global_system_variables.net_read_timeout, - (gptr*) &max_system_variables.net_read_timeout, 0, GET_ULONG, + (uchar**) &global_system_variables.net_read_timeout, + (uchar**) &max_system_variables.net_read_timeout, 0, GET_ULONG, REQUIRED_ARG, NET_READ_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0}, {"net_retry_count", OPT_NET_RETRY_COUNT, "If a read on a communication port is interrupted, retry this many times before giving up.", - (gptr*) &global_system_variables.net_retry_count, - (gptr*) &max_system_variables.net_retry_count,0, + (uchar**) &global_system_variables.net_retry_count, + (uchar**) &max_system_variables.net_retry_count,0, GET_ULONG, REQUIRED_ARG, MYSQLD_NET_RETRY_COUNT, 1, ~0L, 0, 1, 0}, {"net_write_timeout", OPT_NET_WRITE_TIMEOUT, "Number of seconds to wait for a block to be written to a connection before aborting the write.", - (gptr*) &global_system_variables.net_write_timeout, - (gptr*) &max_system_variables.net_write_timeout, 0, GET_ULONG, + (uchar**) &global_system_variables.net_write_timeout, + (uchar**) &max_system_variables.net_write_timeout, 0, GET_ULONG, REQUIRED_ARG, NET_WRITE_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0}, { "old", OPT_OLD_MODE, "Use compatible behavior.", - (gptr*) &global_system_variables.old_mode, - (gptr*) &max_system_variables.old_mode, 0, GET_BOOL, NO_ARG, + (uchar**) &global_system_variables.old_mode, + (uchar**) &max_system_variables.old_mode, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"open_files_limit", OPT_OPEN_FILES_LIMIT, "If this is not 0, then mysqld will use this value to reserve file descriptors to use with setrlimit(). If this value is 0 then mysqld will reserve max_connections*5 or max_connections + table_cache*2 (whichever is larger) number of files.", - (gptr*) &open_files_limit, (gptr*) &open_files_limit, 0, GET_ULONG, + (uchar**) &open_files_limit, (uchar**) &open_files_limit, 0, GET_ULONG, REQUIRED_ARG, 0, 0, OS_FILE_LIMIT, 0, 1, 0}, {"optimizer_prune_level", OPT_OPTIMIZER_PRUNE_LEVEL, "Controls the heuristic(s) applied during query optimization to prune less-promising partial plans from the optimizer search space. Meaning: 0 - do not apply any heuristic, thus perform exhaustive search; 1 - prune plans based on number of retrieved rows.", - (gptr*) &global_system_variables.optimizer_prune_level, - (gptr*) &max_system_variables.optimizer_prune_level, + (uchar**) &global_system_variables.optimizer_prune_level, + (uchar**) &max_system_variables.optimizer_prune_level, 0, GET_ULONG, OPT_ARG, 1, 0, 1, 0, 1, 0}, {"optimizer_search_depth", OPT_OPTIMIZER_SEARCH_DEPTH, "Maximum depth of search performed by the query optimizer. Values larger than the number of relations in a query result in better query plans, but take longer to compile a query. Smaller values than the number of tables in a relation result in faster optimization, but may produce very bad query plans. If set to 0, the system will automatically pick a reasonable value; if set to MAX_TABLES+2, the optimizer will switch to the original find_best (used for testing/comparison).", - (gptr*) &global_system_variables.optimizer_search_depth, - (gptr*) &max_system_variables.optimizer_search_depth, + (uchar**) &global_system_variables.optimizer_search_depth, + (uchar**) &max_system_variables.optimizer_search_depth, 0, GET_ULONG, OPT_ARG, MAX_TABLES+1, 0, MAX_TABLES+2, 0, 1, 0}, {"plugin_dir", OPT_PLUGIN_DIR, "Directory for plugins.", - (gptr*) &opt_plugin_dir_ptr, (gptr*) &opt_plugin_dir_ptr, 0, + (uchar**) &opt_plugin_dir_ptr, (uchar**) &opt_plugin_dir_ptr, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"plugin_load", OPT_PLUGIN_LOAD, "Optional colon separated list of plugins to load, where each plugin is " "identified by name and path to library seperated by an equals.", - (gptr*) &opt_plugin_load, (gptr*) &opt_plugin_load, 0, + (uchar**) &opt_plugin_load, (uchar**) &opt_plugin_load, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"preload_buffer_size", OPT_PRELOAD_BUFFER_SIZE, + {"preload_buffer_size", OPT_PRELOAD_BUFFER_SIZE, "The size of the buffer that is allocated when preloading indexes", - (gptr*) &global_system_variables.preload_buff_size, - (gptr*) &max_system_variables.preload_buff_size, 0, GET_ULONG, + (uchar**) &global_system_variables.preload_buff_size, + (uchar**) &max_system_variables.preload_buff_size, 0, GET_ULONG, REQUIRED_ARG, 32*1024L, 1024, 1024*1024*1024L, 0, 1, 0}, {"query_alloc_block_size", OPT_QUERY_ALLOC_BLOCK_SIZE, "Allocation block size for query parsing and execution", - (gptr*) &global_system_variables.query_alloc_block_size, - (gptr*) &max_system_variables.query_alloc_block_size, 0, GET_ULONG, + (uchar**) &global_system_variables.query_alloc_block_size, + (uchar**) &max_system_variables.query_alloc_block_size, 0, GET_ULONG, REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ~0L, 0, 1024, 0}, #ifdef HAVE_QUERY_CACHE {"query_cache_limit", OPT_QUERY_CACHE_LIMIT, "Don't cache results that are bigger than this.", - (gptr*) &query_cache_limit, (gptr*) &query_cache_limit, 0, GET_ULONG, + (uchar**) &query_cache_limit, (uchar**) &query_cache_limit, 0, GET_ULONG, REQUIRED_ARG, 1024*1024L, 0, (longlong) ULONG_MAX, 0, 1, 0}, {"query_cache_min_res_unit", OPT_QUERY_CACHE_MIN_RES_UNIT, "minimal size of unit in wich space for results is allocated (last unit will be trimed after writing all result data.", - (gptr*) &query_cache_min_res_unit, (gptr*) &query_cache_min_res_unit, + (uchar**) &query_cache_min_res_unit, (uchar**) &query_cache_min_res_unit, 0, GET_ULONG, REQUIRED_ARG, QUERY_CACHE_MIN_RESULT_DATA_SIZE, 0, (longlong) ULONG_MAX, 0, 1, 0}, #endif /*HAVE_QUERY_CACHE*/ {"query_cache_size", OPT_QUERY_CACHE_SIZE, "The memory allocated to store results from old queries.", - (gptr*) &query_cache_size, (gptr*) &query_cache_size, 0, GET_ULONG, + (uchar**) &query_cache_size, (uchar**) &query_cache_size, 0, GET_ULONG, REQUIRED_ARG, 0, 0, (longlong) ULONG_MAX, 0, 1024, 0}, #ifdef HAVE_QUERY_CACHE {"query_cache_type", OPT_QUERY_CACHE_TYPE, "0 = OFF = Don't cache or retrieve results. 1 = ON = Cache all results except SELECT SQL_NO_CACHE ... queries. 2 = DEMAND = Cache only SELECT SQL_CACHE ... queries.", - (gptr*) &global_system_variables.query_cache_type, - (gptr*) &max_system_variables.query_cache_type, + (uchar**) &global_system_variables.query_cache_type, + (uchar**) &max_system_variables.query_cache_type, 0, GET_ULONG, REQUIRED_ARG, 1, 0, 2, 0, 1, 0}, {"query_cache_wlock_invalidate", OPT_QUERY_CACHE_WLOCK_INVALIDATE, "Invalidate queries in query cache on LOCK for write", - (gptr*) &global_system_variables.query_cache_wlock_invalidate, - (gptr*) &max_system_variables.query_cache_wlock_invalidate, + (uchar**) &global_system_variables.query_cache_wlock_invalidate, + (uchar**) &max_system_variables.query_cache_wlock_invalidate, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0}, #endif /*HAVE_QUERY_CACHE*/ {"query_prealloc_size", OPT_QUERY_PREALLOC_SIZE, "Persistent buffer for query parsing and execution", - (gptr*) &global_system_variables.query_prealloc_size, - (gptr*) &max_system_variables.query_prealloc_size, 0, GET_ULONG, + (uchar**) &global_system_variables.query_prealloc_size, + (uchar**) &max_system_variables.query_prealloc_size, 0, GET_ULONG, REQUIRED_ARG, QUERY_ALLOC_PREALLOC_SIZE, QUERY_ALLOC_PREALLOC_SIZE, ~0L, 0, 1024, 0}, {"range_alloc_block_size", OPT_RANGE_ALLOC_BLOCK_SIZE, "Allocation block size for storing ranges during optimization", - (gptr*) &global_system_variables.range_alloc_block_size, - (gptr*) &max_system_variables.range_alloc_block_size, 0, GET_ULONG, + (uchar**) &global_system_variables.range_alloc_block_size, + (uchar**) &max_system_variables.range_alloc_block_size, 0, GET_ULONG, REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, 4096, ~0L, 0, 1024, 0}, {"read_buffer_size", OPT_RECORD_BUFFER, "Each thread that does a sequential scan allocates a buffer of this size for each table it scans. If you do many sequential scans, you may want to increase this value.", - (gptr*) &global_system_variables.read_buff_size, - (gptr*) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG, + (uchar**) &global_system_variables.read_buff_size, + (uchar**) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, SSIZE_MAX, MALLOC_OVERHEAD, IO_SIZE, 0}, {"read_only", OPT_READONLY, "Make all non-temporary tables read-only, with the exception for replication (slave) threads and users with the SUPER privilege", - (gptr*) &opt_readonly, - (gptr*) &opt_readonly, + (uchar**) &opt_readonly, + (uchar**) &opt_readonly, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0}, {"read_rnd_buffer_size", OPT_RECORD_RND_BUFFER, "When reading rows in sorted order after a sort, the rows are read through this buffer to avoid a disk seeks. If not set, then it's set to the value of record_buffer.", - (gptr*) &global_system_variables.read_rnd_buff_size, - (gptr*) &max_system_variables.read_rnd_buff_size, 0, + (uchar**) &global_system_variables.read_rnd_buff_size, + (uchar**) &max_system_variables.read_rnd_buff_size, 0, GET_ULONG, REQUIRED_ARG, 256*1024L, IO_SIZE*2+MALLOC_OVERHEAD, SSIZE_MAX, MALLOC_OVERHEAD, IO_SIZE, 0}, {"record_buffer", OPT_RECORD_BUFFER, "Alias for read_buffer_size", - (gptr*) &global_system_variables.read_buff_size, - (gptr*) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG, + (uchar**) &global_system_variables.read_buff_size, + (uchar**) &max_system_variables.read_buff_size,0, GET_ULONG, REQUIRED_ARG, 128*1024L, IO_SIZE*2+MALLOC_OVERHEAD, SSIZE_MAX, MALLOC_OVERHEAD, IO_SIZE, 0}, #ifdef HAVE_REPLICATION {"relay_log_purge", OPT_RELAY_LOG_PURGE, "0 = do not purge relay logs. 1 = purge them as soon as they are no more needed.", - (gptr*) &relay_log_purge, - (gptr*) &relay_log_purge, 0, GET_BOOL, NO_ARG, + (uchar**) &relay_log_purge, + (uchar**) &relay_log_purge, 0, GET_BOOL, NO_ARG, 1, 0, 1, 0, 1, 0}, {"relay_log_space_limit", OPT_RELAY_LOG_SPACE_LIMIT, "Maximum space to use for all relay logs.", - (gptr*) &relay_log_space_limit, - (gptr*) &relay_log_space_limit, 0, GET_ULL, REQUIRED_ARG, 0L, 0L, + (uchar**) &relay_log_space_limit, + (uchar**) &relay_log_space_limit, 0, GET_ULL, REQUIRED_ARG, 0L, 0L, (longlong) ULONG_MAX, 0, 1, 0}, {"slave_compressed_protocol", OPT_SLAVE_COMPRESSED_PROTOCOL, "Use compression on master/slave protocol.", - (gptr*) &opt_slave_compressed_protocol, - (gptr*) &opt_slave_compressed_protocol, + (uchar**) &opt_slave_compressed_protocol, + (uchar**) &opt_slave_compressed_protocol, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0}, {"slave_net_timeout", OPT_SLAVE_NET_TIMEOUT, "Number of seconds to wait for more data from a master/slave connection before aborting the read.", - (gptr*) &slave_net_timeout, (gptr*) &slave_net_timeout, 0, + (uchar**) &slave_net_timeout, (uchar**) &slave_net_timeout, 0, GET_ULONG, REQUIRED_ARG, SLAVE_NET_TIMEOUT, 1, LONG_TIMEOUT, 0, 1, 0}, {"slave_transaction_retries", OPT_SLAVE_TRANS_RETRIES, "Number of times the slave SQL thread will retry a transaction in case " "it failed with a deadlock or elapsed lock wait timeout, " "before giving up and stopping.", - (gptr*) &slave_trans_retries, (gptr*) &slave_trans_retries, 0, + (uchar**) &slave_trans_retries, (uchar**) &slave_trans_retries, 0, GET_ULONG, REQUIRED_ARG, 10L, 0L, (longlong) ULONG_MAX, 0, 1, 0}, #endif /* HAVE_REPLICATION */ {"slow_launch_time", OPT_SLOW_LAUNCH_TIME, "If creating the thread takes longer than this value (in seconds), the Slow_launch_threads counter will be incremented.", - (gptr*) &slow_launch_time, (gptr*) &slow_launch_time, 0, GET_ULONG, + (uchar**) &slow_launch_time, (uchar**) &slow_launch_time, 0, GET_ULONG, REQUIRED_ARG, 2L, 0L, LONG_TIMEOUT, 0, 1, 0}, {"sort_buffer_size", OPT_SORT_BUFFER, "Each thread that needs to do a sort allocates a buffer of this size.", - (gptr*) &global_system_variables.sortbuff_size, - (gptr*) &max_system_variables.sortbuff_size, 0, GET_ULONG, REQUIRED_ARG, + (uchar**) &global_system_variables.sortbuff_size, + (uchar**) &max_system_variables.sortbuff_size, 0, GET_ULONG, REQUIRED_ARG, MAX_SORT_MEMORY, MIN_SORT_MEMORY+MALLOC_OVERHEAD*2, ~0L, MALLOC_OVERHEAD, 1, 0}, {"sync-binlog", OPT_SYNC_BINLOG, "Synchronously flush binary log to disk after every #th event. " "Use 0 (default) to disable synchronous flushing.", - (gptr*) &sync_binlog_period, (gptr*) &sync_binlog_period, 0, GET_ULONG, + (uchar**) &sync_binlog_period, (uchar**) &sync_binlog_period, 0, GET_ULONG, REQUIRED_ARG, 0, 0, ~0L, 0, 1, 0}, {"sync-frm", OPT_SYNC_FRM, "Sync .frm to disk on create. Enabled by default.", - (gptr*) &opt_sync_frm, (gptr*) &opt_sync_frm, 0, GET_BOOL, NO_ARG, 1, 0, + (uchar**) &opt_sync_frm, (uchar**) &opt_sync_frm, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0}, {"table_cache", OPT_TABLE_OPEN_CACHE, "Deprecated; use --table_open_cache instead.", - (gptr*) &table_cache_size, (gptr*) &table_cache_size, 0, GET_ULONG, + (uchar**) &table_cache_size, (uchar**) &table_cache_size, 0, GET_ULONG, REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0}, {"table_definition_cache", OPT_TABLE_DEF_CACHE, "The number of cached table definitions.", - (gptr*) &table_def_size, (gptr*) &table_def_size, + (uchar**) &table_def_size, (uchar**) &table_def_size, 0, GET_ULONG, REQUIRED_ARG, 128, 1, 512*1024L, 0, 1, 0}, {"table_open_cache", OPT_TABLE_OPEN_CACHE, "The number of cached open tables.", - (gptr*) &table_cache_size, (gptr*) &table_cache_size, 0, GET_ULONG, + (uchar**) &table_cache_size, (uchar**) &table_cache_size, 0, GET_ULONG, REQUIRED_ARG, TABLE_OPEN_CACHE_DEFAULT, 1, 512*1024L, 0, 1, 0}, {"table_lock_wait_timeout", OPT_TABLE_LOCK_WAIT_TIMEOUT, "Timeout in seconds to wait for a table level lock before returning an " "error. Used only if the connection has active cursors.", - (gptr*) &table_lock_wait_timeout, (gptr*) &table_lock_wait_timeout, + (uchar**) &table_lock_wait_timeout, (uchar**) &table_lock_wait_timeout, 0, GET_ULONG, REQUIRED_ARG, 50, 1, 1024 * 1024 * 1024, 0, 1, 0}, {"thread_cache_size", OPT_THREAD_CACHE_SIZE, "How many threads we should keep in a cache for reuse.", - (gptr*) &thread_cache_size, (gptr*) &thread_cache_size, 0, GET_ULONG, + (uchar**) &thread_cache_size, (uchar**) &thread_cache_size, 0, GET_ULONG, REQUIRED_ARG, 0, 0, 16384, 0, 1, 0}, {"thread_concurrency", OPT_THREAD_CONCURRENCY, "Permits the application to give the threads system a hint for the desired number of threads that should be run at the same time.", - (gptr*) &concurrency, (gptr*) &concurrency, 0, GET_ULONG, REQUIRED_ARG, + (uchar**) &concurrency, (uchar**) &concurrency, 0, GET_ULONG, REQUIRED_ARG, DEFAULT_CONCURRENCY, 1, 512, 0, 1, 0}, #if HAVE_POOL_OF_THREADS == 1 {"thread_pool_size", OPT_THREAD_CACHE_SIZE, "How many threads we should create to handle query requests in case of 'thread_handling=pool-of-threads'", - (gptr*) &thread_pool_size, (gptr*) &thread_pool_size, 0, GET_ULONG, + (uchar**) &thread_pool_size, (uchar**) &thread_pool_size, 0, GET_ULONG, REQUIRED_ARG, 20, 1, 16384, 0, 1, 0}, #endif {"thread_stack", OPT_THREAD_STACK, - "The stack size for each thread.", (gptr*) &thread_stack, - (gptr*) &thread_stack, 0, GET_ULONG, REQUIRED_ARG,DEFAULT_THREAD_STACK, + "The stack size for each thread.", (uchar**) &thread_stack, + (uchar**) &thread_stack, 0, GET_ULONG, REQUIRED_ARG,DEFAULT_THREAD_STACK, 1024L*128L, ~0L, 0, 1024, 0}, { "time_format", OPT_TIME_FORMAT, "The TIME format (for future).", - (gptr*) &opt_date_time_formats[MYSQL_TIMESTAMP_TIME], - (gptr*) &opt_date_time_formats[MYSQL_TIMESTAMP_TIME], + (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_TIME], + (uchar**) &opt_date_time_formats[MYSQL_TIMESTAMP_TIME], 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"tmp_table_size", OPT_TMP_TABLE_SIZE, "If an in-memory temporary table exceeds this size, MySQL will automatically convert it to an on-disk MyISAM table.", - (gptr*) &global_system_variables.tmp_table_size, - (gptr*) &max_system_variables.tmp_table_size, 0, GET_ULL, + (uchar**) &global_system_variables.tmp_table_size, + (uchar**) &max_system_variables.tmp_table_size, 0, GET_ULL, REQUIRED_ARG, 16*1024*1024L, 1024, MAX_MEM_TABLE_SIZE, 0, 1, 0}, {"transaction_alloc_block_size", OPT_TRANS_ALLOC_BLOCK_SIZE, "Allocation block size for various transaction-related structures", - (gptr*) &global_system_variables.trans_alloc_block_size, - (gptr*) &max_system_variables.trans_alloc_block_size, 0, GET_ULONG, + (uchar**) &global_system_variables.trans_alloc_block_size, + (uchar**) &max_system_variables.trans_alloc_block_size, 0, GET_ULONG, REQUIRED_ARG, QUERY_ALLOC_BLOCK_SIZE, 1024, ~0L, 0, 1024, 0}, {"transaction_prealloc_size", OPT_TRANS_PREALLOC_SIZE, "Persistent buffer for various transaction-related structures", - (gptr*) &global_system_variables.trans_prealloc_size, - (gptr*) &max_system_variables.trans_prealloc_size, 0, GET_ULONG, + (uchar**) &global_system_variables.trans_prealloc_size, + (uchar**) &max_system_variables.trans_prealloc_size, 0, GET_ULONG, REQUIRED_ARG, TRANS_ALLOC_PREALLOC_SIZE, 1024, ~0L, 0, 1024, 0}, {"thread_handling", OPT_THREAD_HANDLING, "Define threads usage for handling queries: " @@ -6295,13 +6299,13 @@ The minimum value for this variable is 4096.", 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"updatable_views_with_limit", OPT_UPDATABLE_VIEWS_WITH_LIMIT, "1 = YES = Don't issue an error message (warning only) if a VIEW without presence of a key of the underlying table is used in queries with a LIMIT clause for updating. 0 = NO = Prohibit update of a VIEW, which does not contain a key of the underlying table and the query uses a LIMIT clause (usually get from GUI tools).", - (gptr*) &global_system_variables.updatable_views_with_limit, - (gptr*) &max_system_variables.updatable_views_with_limit, + (uchar**) &global_system_variables.updatable_views_with_limit, + (uchar**) &max_system_variables.updatable_views_with_limit, 0, GET_ULONG, REQUIRED_ARG, 1, 0, 1, 0, 1, 0}, {"wait_timeout", OPT_WAIT_TIMEOUT, "The number of seconds the server waits for activity on a connection before closing it.", - (gptr*) &global_system_variables.net_wait_timeout, - (gptr*) &max_system_variables.net_wait_timeout, 0, GET_ULONG, + (uchar**) &global_system_variables.net_wait_timeout, + (uchar**) &max_system_variables.net_wait_timeout, 0, GET_ULONG, REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT), 0, 1, 0}, {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} @@ -7000,7 +7004,7 @@ static void mysql_init_variables(void) prepared_stmt_count= 0; errmesg= 0; mysqld_unix_port= opt_mysql_tmpdir= my_bind_addr_str= NullS; - bzero((gptr) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list)); + bzero((uchar*) &mysql_tmpdir_list, sizeof(mysql_tmpdir_list)); bzero((char *) &global_status_var, sizeof(global_status_var)); opt_large_pages= 0; key_map_full.set_all(); @@ -7648,7 +7652,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), break; } case OPT_FT_BOOLEAN_SYNTAX: - if (ft_boolean_check_syntax_string((byte*) argument)) + if (ft_boolean_check_syntax_string((uchar*) argument)) { fprintf(stderr, "Invalid ft-boolean-syntax string: %s\n", argument); exit(1); @@ -7669,7 +7673,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), } /* Initiates DEBUG - but no debugging here ! */ -static gptr * +static uchar* * mysql_getopt_value(const char *keyname, uint key_length, const struct my_option *option) { @@ -7684,13 +7688,13 @@ mysql_getopt_value(const char *keyname, uint key_length, exit(1); switch (option->id) { case OPT_KEY_BUFFER_SIZE: - return (gptr*) &key_cache->param_buff_size; + return (uchar**) &key_cache->param_buff_size; case OPT_KEY_CACHE_BLOCK_SIZE: - return (gptr*) &key_cache->param_block_size; + return (uchar**) &key_cache->param_block_size; case OPT_KEY_CACHE_DIVISION_LIMIT: - return (gptr*) &key_cache->param_division_limit; + return (uchar**) &key_cache->param_division_limit; case OPT_KEY_CACHE_AGE_THRESHOLD: - return (gptr*) &key_cache->param_age_threshold; + return (uchar**) &key_cache->param_age_threshold; } } } @@ -7842,7 +7846,7 @@ static char *get_relative_path(const char *path) */ bool -fn_format_relative_to_data_home(my_string to, const char *name, +fn_format_relative_to_data_home(char * to, const char *name, const char *dir, const char *extension) { char tmp_path[FN_REFLEN]; @@ -7960,7 +7964,7 @@ static ulong find_bit_type(const char *x, TYPELIB *bit_lib) found=0; found_end= 0; - pos=(my_string) x; + pos=(char *) x; while (*pos == ' ') pos++; found_end= *pos == 0; while (!found_end) @@ -8057,7 +8061,7 @@ static void create_pid_file() char buff[21], *end; end= int10_to_str((long) getpid(), buff, 10); *end++= '\n'; - if (!my_write(file, (byte*) buff, (uint) (end-buff), MYF(MY_WME | MY_NABP))) + if (!my_write(file, (uchar*) buff, (uint) (end-buff), MYF(MY_WME | MY_NABP))) { (void) my_close(file, MYF(0)); return; diff --git a/sql/net_serv.cc b/sql/net_serv.cc index 719e2ee0d3c..ec12c4cabf3 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -108,7 +108,7 @@ extern void query_cache_insert(NET *net, const char *packet, ulong length); #define TEST_BLOCKING 8 #define MAX_PACKET_LENGTH (256L*256L*256L-1) -static my_bool net_write_buff(NET *net,const char *packet,ulong len); +static my_bool net_write_buff(NET *net,const uchar *packet,ulong len); /* Init with packet info */ @@ -117,7 +117,7 @@ my_bool my_net_init(NET *net, Vio* vio) { DBUG_ENTER("my_net_init"); my_net_local_init(net); /* Set some limits */ - if (!(net->buff=(uchar*) my_malloc((uint32) net->max_packet+ + if (!(net->buff=(uchar*) my_malloc((size_t) net->max_packet+ NET_HEADER_SIZE + COMP_HEADER_SIZE, MYF(MY_WME)))) DBUG_RETURN(1); @@ -157,7 +157,7 @@ my_bool my_net_init(NET *net, Vio* vio) void net_end(NET *net) { DBUG_ENTER("net_end"); - my_free((gptr) net->buff,MYF(MY_ALLOW_ZERO_PTR)); + my_free(net->buff,MYF(MY_ALLOW_ZERO_PTR)); net->buff=0; DBUG_VOID_RETURN; } @@ -165,17 +165,17 @@ void net_end(NET *net) /* Realloc the packet buffer */ -my_bool net_realloc(NET *net, ulong length) +my_bool net_realloc(NET *net, size_t length) { uchar *buff; - ulong pkt_length; + size_t pkt_length; DBUG_ENTER("net_realloc"); - DBUG_PRINT("enter",("length: %lu", length)); + DBUG_PRINT("enter",("length: %lu", (ulong) length)); if (length >= net->max_packet_size) { DBUG_PRINT("error", ("Packet too large. Max size: %lu", - net->max_packet_size)); + net->max_packet_size)); net->error= 1; net->report_error= 1; net->last_errno= ER_NET_PACKET_TOO_LARGE; @@ -186,9 +186,9 @@ my_bool net_realloc(NET *net, ulong length) We must allocate some extra bytes for the end 0 and to be able to read big compressed blocks */ - if (!(buff=(uchar*) my_realloc((char*) net->buff, (uint32) pkt_length + - NET_HEADER_SIZE + COMP_HEADER_SIZE, - MYF(MY_WME)))) + if (!(buff= (uchar*) my_realloc((char*) net->buff, pkt_length + + NET_HEADER_SIZE + COMP_HEADER_SIZE, + MYF(MY_WME)))) { net->error= 1; net->report_error= 1; @@ -196,7 +196,7 @@ my_bool net_realloc(NET *net, ulong length) DBUG_RETURN(1); } net->buff=net->write_pos=buff; - net->buff_end=buff+(net->max_packet=pkt_length); + net->buff_end=buff+(net->max_packet= (ulong) pkt_length); DBUG_RETURN(0); } @@ -283,7 +283,8 @@ static int net_data_is_ready(my_socket sd) void net_clear(NET *net, my_bool clear_buffer) { #if !defined(EMBEDDED_LIBRARY) - int count, ready; + size_t count; + int ready; #endif DBUG_ENTER("net_clear"); @@ -293,14 +294,14 @@ void net_clear(NET *net, my_bool clear_buffer) while ((ready= net_data_is_ready(net->vio->sd)) > 0) { /* The socket is ready */ - if ((count= vio_read(net->vio, (char*) (net->buff), - (uint32) net->max_packet)) > 0) + if ((long) (count= vio_read(net->vio, net->buff, + (size_t) net->max_packet)) > 0) { - DBUG_PRINT("info",("skipped %d bytes from file: %s", - count, vio_description(net->vio))); + DBUG_PRINT("info",("skipped %ld bytes from file: %s", + (long) count, vio_description(net->vio))); #if defined(EXTRA_DEBUG) - fprintf(stderr,"Note: net_clear() skipped %d bytes from file: %s\n", - count, vio_description(net->vio)); + fprintf(stderr,"Note: net_clear() skipped %ld bytes from file: %s\n", + (long) count, vio_description(net->vio)); #endif } else @@ -318,10 +319,10 @@ void net_clear(NET *net, my_bool clear_buffer) my_bool old_mode; if (!vio_blocking(net->vio, FALSE, &old_mode)) { - while ((count= vio_read(net->vio, (char*) (net->buff), - (uint32) net->max_packet)) > 0) - DBUG_PRINT("info",("skipped %d bytes from file: %s", - count, vio_description(net->vio))); + while ((long) (count= vio_read(net->vio, net->buff, + (size_t) net->max_packet)) > 0) + DBUG_PRINT("info",("skipped %ld bytes from file: %s", + (long) count, vio_description(net->vio))); vio_blocking(net->vio, TRUE, &old_mode); } } @@ -342,8 +343,8 @@ my_bool net_flush(NET *net) DBUG_ENTER("net_flush"); if (net->buff != net->write_pos) { - error=test(net_real_write(net,(char*) net->buff, - (ulong) (net->write_pos - net->buff))); + error=test(net_real_write(net, net->buff, + (size_t) (net->write_pos - net->buff))); net->write_pos=net->buff; } /* Sync packet number if using compression */ @@ -367,7 +368,7 @@ my_bool net_flush(NET *net) */ my_bool -my_net_write(NET *net,const char *packet,ulong len) +my_net_write(NET *net,const uchar *packet,size_t len) { uchar buff[NET_HEADER_SIZE]; if (unlikely(!net->vio)) /* nowhere to write */ @@ -382,7 +383,7 @@ my_net_write(NET *net,const char *packet,ulong len) const ulong z_size = MAX_PACKET_LENGTH; int3store(buff, z_size); buff[3]= (uchar) net->pkt_nr++; - if (net_write_buff(net, (char*) buff, NET_HEADER_SIZE) || + if (net_write_buff(net, buff, NET_HEADER_SIZE) || net_write_buff(net, packet, z_size)) return 1; packet += z_size; @@ -391,10 +392,10 @@ my_net_write(NET *net,const char *packet,ulong len) /* Write last packet */ int3store(buff,len); buff[3]= (uchar) net->pkt_nr++; - if (net_write_buff(net,(char*) buff,NET_HEADER_SIZE)) + if (net_write_buff(net, buff, NET_HEADER_SIZE)) return 1; #ifndef DEBUG_DATA_PACKETS - DBUG_DUMP("packet_header",(char*) buff,NET_HEADER_SIZE); + DBUG_DUMP("packet_header", buff, NET_HEADER_SIZE); #endif return test(net_write_buff(net,packet,len)); } @@ -429,8 +430,8 @@ my_net_write(NET *net,const char *packet,ulong len) my_bool net_write_command(NET *net,uchar command, - const char *header, ulong head_len, - const char *packet, ulong len) + const uchar *header, size_t head_len, + const uchar *packet, size_t len) { ulong length=len+1+head_len; /* 1 extra byte for command */ uchar buff[NET_HEADER_SIZE+1]; @@ -448,7 +449,7 @@ net_write_command(NET *net,uchar command, { int3store(buff, MAX_PACKET_LENGTH); buff[3]= (uchar) net->pkt_nr++; - if (net_write_buff(net,(char*) buff, header_size) || + if (net_write_buff(net, buff, header_size) || net_write_buff(net, header, head_len) || net_write_buff(net, packet, len)) DBUG_RETURN(1); @@ -462,9 +463,9 @@ net_write_command(NET *net,uchar command, } int3store(buff,length); buff[3]= (uchar) net->pkt_nr++; - DBUG_RETURN(test(net_write_buff(net, (char*) buff, header_size) || - (head_len && net_write_buff(net, (char*) header, head_len)) || - net_write_buff(net, packet, len) || net_flush(net))); + DBUG_RETURN(test(net_write_buff(net, buff, header_size) || + (head_len && net_write_buff(net, header, head_len)) || + net_write_buff(net, packet, len) || net_flush(net))); } /* @@ -497,7 +498,7 @@ net_write_command(NET *net,uchar command, */ static my_bool -net_write_buff(NET *net,const char *packet,ulong len) +net_write_buff(NET *net, const uchar *packet, ulong len) { ulong left_length; if (net->compress && net->max_packet > MAX_PACKET_LENGTH) @@ -514,8 +515,8 @@ net_write_buff(NET *net,const char *packet,ulong len) { /* Fill up already used packet and write it */ memcpy((char*) net->write_pos,packet,left_length); - if (net_real_write(net,(char*) net->buff, - (ulong) (net->write_pos - net->buff) + left_length)) + if (net_real_write(net, net->buff, + (size_t) (net->write_pos - net->buff) + left_length)) return 1; net->write_pos= net->buff; packet+= left_length; @@ -552,10 +553,10 @@ net_write_buff(NET *net,const char *packet,ulong len) */ int -net_real_write(NET *net,const char *packet,ulong len) +net_real_write(NET *net,const uchar *packet, size_t len) { - long int length; - char *pos,*end; + size_t length; + const uchar *pos,*end; thr_alarm_t alarmed; #ifndef NO_ALARM ALARM alarm_buff; @@ -565,7 +566,7 @@ net_real_write(NET *net,const char *packet,ulong len) DBUG_ENTER("net_real_write"); #if defined(MYSQL_SERVER) && defined(USE_QUERY_CACHE) - query_cache_insert(net, packet, len); + query_cache_insert(net, (char*) packet, len); #endif if (net->error == 2) @@ -575,11 +576,11 @@ net_real_write(NET *net,const char *packet,ulong len) #ifdef HAVE_COMPRESS if (net->compress) { - ulong complen; + size_t complen; uchar *b; uint header_length=NET_HEADER_SIZE+COMP_HEADER_SIZE; - if (!(b=(uchar*) my_malloc((uint32) len + NET_HEADER_SIZE + - COMP_HEADER_SIZE, MYF(MY_WME)))) + if (!(b= (uchar*) my_malloc(len + NET_HEADER_SIZE + + COMP_HEADER_SIZE, MYF(MY_WME)))) { #ifdef MYSQL_SERVER net->last_errno= ER_OUT_OF_RESOURCES; @@ -592,18 +593,18 @@ net_real_write(NET *net,const char *packet,ulong len) } memcpy(b+header_length,packet,len); - if (my_compress((byte*) b+header_length,&len,&complen)) + if (my_compress(b+header_length, &len, &complen)) complen=0; int3store(&b[NET_HEADER_SIZE],complen); int3store(b,len); b[3]=(uchar) (net->compress_pkt_nr++); len+= header_length; - packet= (char*) b; + packet= b; } #endif /* HAVE_COMPRESS */ #ifdef DEBUG_DATA_PACKETS - DBUG_DUMP("data",packet,len); + DBUG_DUMP("data", packet, len); #endif #ifndef NO_ALARM @@ -615,14 +616,15 @@ net_real_write(NET *net,const char *packet,ulong len) /* Write timeout is set in net_set_write_timeout */ #endif /* NO_ALARM */ - pos=(char*) packet; end=pos+len; + pos= packet; + end=pos+len; while (pos != end) { - if ((long) (length=vio_write(net->vio,pos,(uint32) (end-pos))) <= 0) + if ((long) (length= vio_write(net->vio,pos,(size_t) (end-pos))) <= 0) { my_bool interrupted = vio_should_retry(net->vio); #if !defined(__WIN__) - if ((interrupted || length==0) && !thr_alarm_in_use(&alarmed)) + if ((interrupted || length == 0) && !thr_alarm_in_use(&alarmed)) { if (!thr_alarm(&alarmed,(uint) net->write_timeout,&alarm_buff)) { /* Always true for client */ @@ -701,14 +703,14 @@ net_real_write(NET *net,const char *packet,ulong len) #ifndef NO_ALARM -static my_bool net_safe_read(NET *net, char *buff, uint32 length, +static my_bool net_safe_read(NET *net, uchar *buff, size_t length, thr_alarm_t *alarmed) { uint retry_count=0; while (length > 0) { - int tmp; - if ((tmp=vio_read(net->vio,(char*) net->buff, length)) <= 0) + size_t tmp; + if ((long) (tmp= vio_read(net->vio, buff, length)) <= 0) { my_bool interrupted = vio_should_retry(net->vio); if (!thr_got_alarm(alarmed) && interrupted) @@ -719,6 +721,7 @@ static my_bool net_safe_read(NET *net, char *buff, uint32 length, return 1; } length-= tmp; + buff+= tmp; } return 0; } @@ -759,15 +762,15 @@ static my_bool my_net_skip_rest(NET *net, uint32 remain, thr_alarm_t *alarmed, { while (remain > 0) { - uint length= min(remain, net->max_packet); - if (net_safe_read(net, (char*) net->buff, length, alarmed)) + size_t length= min(remain, net->max_packet); + if (net_safe_read(net, net->buff, length, alarmed)) DBUG_RETURN(1); update_statistics(thd_increment_bytes_received(length)); remain -= (uint32) length; } if (old != MAX_PACKET_LENGTH) break; - if (net_safe_read(net, (char*) net->buff, NET_HEADER_SIZE, alarmed)) + if (net_safe_read(net, net->buff, NET_HEADER_SIZE, alarmed)) DBUG_RETURN(1); old=remain= uint3korr(net->buff); net->pkt_nr++; @@ -784,10 +787,10 @@ static my_bool my_net_skip_rest(NET *net, uint32 remain, thr_alarm_t *alarmed, */ static ulong -my_real_read(NET *net, ulong *complen) +my_real_read(NET *net, size_t *complen) { uchar *pos; - long length; + size_t length; uint i,retry_count=0; ulong len=packet_error; thr_alarm_t alarmed; @@ -814,12 +817,12 @@ my_real_read(NET *net, ulong *complen) while (remain > 0) { /* First read is done with non blocking mode */ - if ((int) (length=vio_read(net->vio,(char*) pos,remain)) <= 0L) + if ((long) (length= vio_read(net->vio, pos, remain)) <= 0L) { my_bool interrupted = vio_should_retry(net->vio); DBUG_PRINT("info",("vio_read returned %ld errno: %d", - length, vio_errno(net->vio))); + (long) length, vio_errno(net->vio))); #if !defined(__WIN__) || defined(MYSQL_SERVER) /* We got an error that there was no data on the socket. We now set up @@ -875,7 +878,7 @@ my_real_read(NET *net, ulong *complen) } #endif DBUG_PRINT("error",("Couldn't read packet: remain: %u errno: %d length: %ld", - remain, vio_errno(net->vio), length)); + remain, vio_errno(net->vio), (long) length)); len= packet_error; net->error= 2; /* Close socket */ net->report_error= 1; @@ -886,13 +889,13 @@ my_real_read(NET *net, ulong *complen) goto end; } remain -= (uint32) length; - pos+= (ulong) length; + pos+= length; update_statistics(thd_increment_bytes_received(length)); } if (i == 0) { /* First parts is packet length */ ulong helping; - DBUG_DUMP("packet_header",(char*) net->buff+net->where_b, + DBUG_DUMP("packet_header", net->buff+net->where_b, NET_HEADER_SIZE); if (net->buff[net->where_b + 3] != (uchar) net->pkt_nr) { @@ -963,7 +966,7 @@ end: net->reading_or_writing=0; #ifdef DEBUG_DATA_PACKETS if (len != packet_error) - DBUG_DUMP("data",(char*) net->buff+net->where_b, len); + DBUG_DUMP("data", net->buff+net->where_b, len); #endif return(len); } @@ -985,7 +988,7 @@ end: ulong my_net_read(NET *net) { - ulong len,complen; + size_t len, complen; #ifdef HAVE_COMPRESS if (!net->compress) @@ -996,7 +999,7 @@ my_net_read(NET *net) { /* First packet of a multi-packet. Concatenate the packets */ ulong save_pos = net->where_b; - ulong total_length=0; + size_t total_length= 0; do { net->where_b += len; @@ -1094,7 +1097,7 @@ my_net_read(NET *net) net->where_b=buf_length; if ((packet_len = my_real_read(net,&complen)) == packet_error) return packet_error; - if (my_uncompress((byte*) net->buff + net->where_b, &packet_len, + if (my_uncompress(net->buff + net->where_b, packet_len, &complen)) { net->error= 2; /* caller will close socket */ @@ -1104,7 +1107,7 @@ my_net_read(NET *net) #endif return packet_error; } - buf_length+=packet_len; + buf_length+= complen; } net->read_pos= net->buff+ first_packet_offset + NET_HEADER_SIZE; diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 96ae6174fdb..4944c994d3d 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -80,9 +80,9 @@ */ #define double2rows(x) ((ha_rows)(x)) -static int sel_cmp(Field *f,char *a,char *b,uint8 a_flag,uint8 b_flag); +static int sel_cmp(Field *f,uchar *a,uchar *b,uint8 a_flag,uint8 b_flag); -static char is_null_string[2]= {1,0}; +static uchar is_null_string[2]= {1,0}; class RANGE_OPT_PARAM; /* @@ -274,7 +274,7 @@ public: ulong use_count; Field *field; - char *min_value,*max_value; // Pointer to range + uchar *min_value,*max_value; // Pointer to range SEL_ARG *left,*right; /* R-B tree children */ SEL_ARG *next,*prev; /* Links for bi-directional interval list */ @@ -287,8 +287,8 @@ public: SEL_ARG() {} SEL_ARG(SEL_ARG &); - SEL_ARG(Field *,const char *,const char *); - SEL_ARG(Field *field, uint8 part, char *min_value, char *max_value, + SEL_ARG(Field *,const uchar *, const uchar *); + SEL_ARG(Field *field, uint8 part, uchar *min_value, uchar *max_value, uint8 min_flag, uint8 max_flag, uint8 maybe_flag); SEL_ARG(enum Type type_arg) :min_flag(0),elements(1),use_count(1),left(0),next_key_part(0), @@ -324,7 +324,7 @@ public: } SEL_ARG *clone_and(SEL_ARG* arg) { // Get overlapping range - char *new_min,*new_max; + uchar *new_min,*new_max; uint8 flag_min,flag_max; if (cmp_min_to_min(arg) >= 0) { @@ -398,7 +398,7 @@ public: min_flag=arg->max_flag & NEAR_MAX ? 0 : NEAR_MIN; } /* returns a number of keypart values (0 or 1) appended to the key buffer */ - int store_min(uint length,char **min_key,uint min_key_flag) + int store_min(uint length, uchar **min_key,uint min_key_flag) { if ((min_flag & GEOM_FLAG) || (!(min_flag & NO_MIN_RANGE) && @@ -417,7 +417,7 @@ public: return 0; } /* returns a number of keypart values (0 or 1) appended to the key buffer */ - int store_max(uint length,char **max_key, uint max_key_flag) + int store_max(uint length, uchar **max_key, uint max_key_flag) { if (!(max_flag & NO_MAX_RANGE) && !(max_key_flag & (NO_MAX_RANGE | NEAR_MAX))) @@ -436,7 +436,7 @@ public: } /* returns a number of keypart values appended to the key buffer */ - int store_min_key(KEY_PART *key,char **range_key, uint *range_key_flag) + int store_min_key(KEY_PART *key, uchar **range_key, uint *range_key_flag) { SEL_ARG *key_tree= first(); uint res= key_tree->store_min(key[key_tree->part].store_length, @@ -452,7 +452,7 @@ public: } /* returns a number of keypart values appended to the key buffer */ - int store_max_key(KEY_PART *key,char **range_key, uint *range_key_flag) + int store_max_key(KEY_PART *key, uchar **range_key, uint *range_key_flag) { SEL_ARG *key_tree= last(); uint res=key_tree->store_max(key[key_tree->part].store_length, @@ -534,8 +534,8 @@ public: */ if (min_flag || max_flag) return FALSE; - byte *min_val= (byte *)min_value; - byte *max_val= (byte *)max_value; + uchar *min_val= min_value; + uchar *max_val= max_value; if (maybe_null) { @@ -641,8 +641,7 @@ public: longlong baseflag; uint max_key_part, range_count; - - char min_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH], + uchar min_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH], max_key[MAX_KEY_LENGTH+MAX_FIELD_WIDTH]; bool quick; // Don't calulate possible keys @@ -683,8 +682,8 @@ static bool is_key_scan_ror(PARAM *param, uint keynr, uint8 nparts); static ha_rows check_quick_select(PARAM *param,uint index,SEL_ARG *key_tree, bool update_tbl_stats); static ha_rows check_quick_keys(PARAM *param,uint index,SEL_ARG *key_tree, - char *min_key, uint min_key_flag, int, - char *max_key, uint max_key_flag, int); + uchar *min_key, uint min_key_flag, int, + uchar *max_key, uint max_key_flag, int); QUICK_RANGE_SELECT *get_quick_select(PARAM *param,uint index, SEL_ARG *key_tree, @@ -726,12 +725,12 @@ static SEL_ARG *key_and(RANGE_OPT_PARAM *param, SEL_ARG *key1, SEL_ARG *key2, uint clone_flag); static bool get_range(SEL_ARG **e1,SEL_ARG **e2,SEL_ARG *root1); bool get_quick_keys(PARAM *param,QUICK_RANGE_SELECT *quick,KEY_PART *key, - SEL_ARG *key_tree,char *min_key,uint min_key_flag, - char *max_key,uint max_key_flag); + SEL_ARG *key_tree, uchar *min_key,uint min_key_flag, + uchar *max_key,uint max_key_flag); static bool eq_tree(SEL_ARG* a,SEL_ARG *b); static SEL_ARG null_element(SEL_ARG::IMPOSSIBLE); -static bool null_part_in_key(KEY_PART *key_part, const char *key, +static bool null_part_in_key(KEY_PART *key_part, const uchar *key, uint length); bool sel_trees_can_be_ored(SEL_TREE *tree1, SEL_TREE *tree2, RANGE_OPT_PARAM* param); @@ -986,7 +985,7 @@ SQL_SELECT *make_select(TABLE *head, table_map const_tables, select->file= *head->sort.io_cache; select->records=(ha_rows) (select->file.end_of_file/ head->file->ref_length); - my_free((gptr) (head->sort.io_cache),MYF(0)); + my_free(head->sort.io_cache, MYF(0)); head->sort.io_cache=0; } DBUG_RETURN(select); @@ -1192,8 +1191,8 @@ QUICK_ROR_INTERSECT_SELECT::QUICK_ROR_INTERSECT_SELECT(THD *thd_param, init_sql_alloc(&alloc, thd->variables.range_alloc_block_size, 0); else bzero(&alloc, sizeof(MEM_ROOT)); - last_rowid= (byte*)alloc_root(parent_alloc? parent_alloc : &alloc, - head->file->ref_length); + last_rowid= (uchar*) alloc_root(parent_alloc? parent_alloc : &alloc, + head->file->ref_length); } @@ -1450,7 +1449,7 @@ int QUICK_ROR_UNION_SELECT::init() DBUG_RETURN(1); } - if (!(cur_rowid= (byte*)alloc_root(&alloc, 2*head->file->ref_length))) + if (!(cur_rowid= (uchar*) alloc_root(&alloc, 2*head->file->ref_length))) DBUG_RETURN(1); prev_rowid= cur_rowid + head->file->ref_length; DBUG_RETURN(0); @@ -1468,7 +1467,7 @@ int QUICK_ROR_UNION_SELECT::init() val2 Second merged select */ -int QUICK_ROR_UNION_SELECT::queue_cmp(void *arg, byte *val1, byte *val2) +int QUICK_ROR_UNION_SELECT::queue_cmp(void *arg, uchar *val1, uchar *val2) { QUICK_ROR_UNION_SELECT *self= (QUICK_ROR_UNION_SELECT*)arg; return self->head->file->cmp_ref(((QUICK_SELECT_I*)val1)->last_rowid, @@ -1519,7 +1518,7 @@ int QUICK_ROR_UNION_SELECT::reset() DBUG_RETURN(error); } quick->save_last_pos(); - queue_insert(&queue, (byte*)quick); + queue_insert(&queue, (uchar*)quick); } if (head->file->ha_rnd_init(1)) @@ -1580,16 +1579,18 @@ inline void SEL_ARG::make_root() use_count=0; elements=1; } -SEL_ARG::SEL_ARG(Field *f,const char *min_value_arg,const char *max_value_arg) +SEL_ARG::SEL_ARG(Field *f,const uchar *min_value_arg, + const uchar *max_value_arg) :min_flag(0), max_flag(0), maybe_flag(0), maybe_null(f->real_maybe_null()), - elements(1), use_count(1), field(f), min_value((char*) min_value_arg), - max_value((char*) max_value_arg), next(0),prev(0), + elements(1), use_count(1), field(f), min_value((uchar*) min_value_arg), + max_value((uchar*) max_value_arg), next(0),prev(0), next_key_part(0),color(BLACK),type(KEY_RANGE) { left=right= &null_element; } -SEL_ARG::SEL_ARG(Field *field_,uint8 part_,char *min_value_,char *max_value_, +SEL_ARG::SEL_ARG(Field *field_,uint8 part_, + uchar *min_value_, uchar *max_value_, uint8 min_flag_,uint8 max_flag_,uint8 maybe_flag_) :min_flag(min_flag_),max_flag(max_flag_),maybe_flag(maybe_flag_), part(part_),maybe_null(field_->real_maybe_null()), elements(1),use_count(1), @@ -1667,7 +1668,8 @@ SEL_ARG *SEL_ARG::last() Returns -2 or 2 if the ranges where 'joined' like < 2 and >= 2 */ -static int sel_cmp(Field *field, char *a,char *b,uint8 a_flag,uint8 b_flag) +static int sel_cmp(Field *field, uchar *a, uchar *b, uint8 a_flag, + uint8 b_flag) { int cmp; /* First check if there was a compare to a min or max element */ @@ -1691,7 +1693,7 @@ static int sel_cmp(Field *field, char *a,char *b,uint8 a_flag,uint8 b_flag) goto end; // NULL where equal a++; b++; // Skip NULL marker } - cmp=field->key_cmp((byte*) a,(byte*) b); + cmp=field->key_cmp(a , b); if (cmp) return cmp < 0 ? -1 : 1; // The values differed // Check if the compared equal arguments was defined with open/closed range @@ -1970,7 +1972,7 @@ private: KEY *index_info; uint index; uint key_infix_len; - byte key_infix[MAX_KEY_LENGTH]; + uchar key_infix[MAX_KEY_LENGTH]; SEL_TREE *range_tree; /* Represents all range predicates in the query. */ SEL_ARG *index_tree; /* The SEL_ARG sub-tree corresponding to index_info. */ uint param_idx; /* Index of used key in param->key. */ @@ -1983,7 +1985,7 @@ public: uint group_prefix_len_arg, uint used_key_parts_arg, uint group_key_parts_arg, KEY *index_info_arg, uint index_arg, uint key_infix_len_arg, - byte *key_infix_arg, + uchar *key_infix_arg, SEL_TREE *tree_arg, SEL_ARG *index_tree_arg, uint param_idx_arg, ha_rows quick_prefix_records_arg) : have_min(have_min_arg), have_max(have_max_arg), @@ -2714,7 +2716,7 @@ end: format. */ -void store_key_image_to_rec(Field *field, char *ptr, uint len) +void store_key_image_to_rec(Field *field, uchar *ptr, uint len) { /* Do the same as print_key() does */ my_bitmap_map *old_map; @@ -3416,7 +3418,7 @@ static void dbug_print_segment_range(SEL_ARG *arg, KEY_PART *part) DBUG_LOCK_FILE; if (!(arg->min_flag & NO_MIN_RANGE)) { - store_key_image_to_rec(part->field, (char*)(arg->min_value), part->length); + store_key_image_to_rec(part->field, arg->min_value, part->length); dbug_print_field(part->field); if (arg->min_flag & NEAR_MIN) fputs(" < ", DBUG_FILE); @@ -3432,7 +3434,7 @@ static void dbug_print_segment_range(SEL_ARG *arg, KEY_PART *part) fputs(" < ", DBUG_FILE); else fputs(" <= ", DBUG_FILE); - store_key_image_to_rec(part->field, (char*)(arg->max_value), part->length); + store_key_image_to_rec(part->field, arg->max_value, part->length); dbug_print_field(part->field); } fputs("\n", DBUG_FILE); @@ -4169,8 +4171,8 @@ static double ror_scan_selectivity(const ROR_INTERSECT_INFO *info, { double selectivity_mult= 1.0; KEY_PART_INFO *key_part= info->param->table->key_info[scan->keynr].key_part; - byte key_val[MAX_KEY_LENGTH+MAX_FIELD_WIDTH]; /* key values tuple */ - char *key_ptr= (char*) key_val; + uchar key_val[MAX_KEY_LENGTH+MAX_FIELD_WIDTH]; /* key values tuple */ + uchar *key_ptr= key_val; SEL_ARG *sel_arg, *tuple_arg= NULL; key_part_map keypart_map= 0; bool cur_covered; @@ -4178,9 +4180,9 @@ static double ror_scan_selectivity(const ROR_INTERSECT_INFO *info, key_part->fieldnr-1)); key_range min_range; key_range max_range; - min_range.key= (byte*) key_val; + min_range.key= key_val; min_range.flag= HA_READ_KEY_EXACT; - max_range.key= (byte*) key_val; + max_range.key= key_val; max_range.flag= HA_READ_AFTER_KEY; ha_rows prev_records= info->param->table->file->stats.records; DBUG_ENTER("ror_scan_selectivity"); @@ -4209,7 +4211,7 @@ static double ror_scan_selectivity(const ROR_INTERSECT_INFO *info, &key_ptr, 0); keypart_map= (keypart_map << 1) | 1; } - min_range.length= max_range.length= ((char*) key_ptr - (char*) key_val); + min_range.length= max_range.length= (size_t) (key_ptr - key_val); min_range.keypart_map= max_range.keypart_map= keypart_map; records= (info->param->table->file-> records_in_range(scan->keynr, &min_range, &max_range)); @@ -5549,7 +5551,7 @@ get_mm_leaf(RANGE_OPT_PARAM *param, COND *conf_func, Field *field, bool optimize_range; SEL_ARG *tree= 0; MEM_ROOT *alloc= param->mem_root; - char *str; + uchar *str; ulong orig_sql_mode; int err; DBUG_ENTER("get_mm_leaf"); @@ -5611,9 +5613,10 @@ get_mm_leaf(RANGE_OPT_PARAM *param, COND *conf_func, Field *field, if (type == Item_func::LIKE_FUNC) { bool like_error; - char buff1[MAX_FIELD_WIDTH],*min_str,*max_str; + char buff1[MAX_FIELD_WIDTH]; + uchar *min_str,*max_str; String tmp(buff1,sizeof(buff1),value->collation.collation),*res; - uint length,offset,min_length,max_length; + size_t length, offset, min_length, max_length; uint field_length= field->pack_length()+maybe_null; if (!optimize_range) @@ -5660,7 +5663,7 @@ get_mm_leaf(RANGE_OPT_PARAM *param, COND *conf_func, Field *field, field_length= length; } length+=offset; - if (!(min_str= (char*) alloc_root(alloc, length*2))) + if (!(min_str= (uchar*) alloc_root(alloc, length*2))) goto end; max_str=min_str+length; @@ -5673,7 +5676,7 @@ get_mm_leaf(RANGE_OPT_PARAM *param, COND *conf_func, Field *field, ((Item_func_like*)(param->cond))->escape, wild_one, wild_many, field_length, - min_str+offset, max_str+offset, + (char*) min_str+offset, (char*) max_str+offset, &min_length, &max_length); if (like_error) // Can't optimize with LIKE goto end; @@ -5735,12 +5738,13 @@ get_mm_leaf(RANGE_OPT_PARAM *param, COND *conf_func, Field *field, goto end; } field->table->in_use->variables.sql_mode= orig_sql_mode; - str= (char*) alloc_root(alloc, key_part->store_length+1); + str= (uchar*) alloc_root(alloc, key_part->store_length+1); if (!str) goto end; if (maybe_null) - *str= (char) field->is_real_null(); // Set to 1 if null - field->get_key_image(str+maybe_null, key_part->length, key_part->image_type); + *str= (uchar) field->is_real_null(); // Set to 1 if null + field->get_key_image(str+maybe_null, key_part->length, + key_part->image_type); if (!(tree= new (alloc) SEL_ARG(field, str, str))) goto end; // out of memory @@ -7244,13 +7248,13 @@ check_quick_select(PARAM *param,uint idx,SEL_ARG *tree, bool update_tbl_stats) static ha_rows check_quick_keys(PARAM *param, uint idx, SEL_ARG *key_tree, - char *min_key, uint min_key_flag, int min_keypart, - char *max_key, uint max_key_flag, int max_keypart) + uchar *min_key, uint min_key_flag, int min_keypart, + uchar *max_key, uint max_key_flag, int max_keypart) { ha_rows records=0, tmp; uint tmp_min_flag, tmp_max_flag, keynr, min_key_length, max_key_length; uint tmp_min_keypart= min_keypart, tmp_max_keypart= max_keypart; - char *tmp_min_key, *tmp_max_key; + uchar *tmp_min_key, *tmp_max_key; uint8 save_first_null_comp= param->first_null_comp; param->max_key_part=max(param->max_key_part,key_tree->part); @@ -7370,7 +7374,7 @@ check_quick_keys(PARAM *param, uint idx, SEL_ARG *key_tree, if (tmp_min_flag & GEOM_FLAG) { key_range min_range; - min_range.key= (byte*) param->min_key; + min_range.key= param->min_key; min_range.length= min_key_length; min_range.keypart_map= make_keypart_map(tmp_min_keypart); /* In this case tmp_min_flag contains the handler-read-function */ @@ -7383,12 +7387,12 @@ check_quick_keys(PARAM *param, uint idx, SEL_ARG *key_tree, { key_range min_range, max_range; - min_range.key= (byte*) param->min_key; + min_range.key= param->min_key; min_range.length= min_key_length; min_range.flag= (tmp_min_flag & NEAR_MIN ? HA_READ_AFTER_KEY : HA_READ_KEY_EXACT); min_range.keypart_map= make_keypart_map(tmp_min_keypart); - max_range.key= (byte*) param->max_key; + max_range.key= param->max_key; max_range.length= max_key_length; max_range.flag= (tmp_max_flag & NEAR_MAX ? HA_READ_BEFORE_KEY : HA_READ_AFTER_KEY); @@ -7557,8 +7561,8 @@ get_quick_select(PARAM *param,uint idx,SEL_ARG *key_tree, */ bool get_quick_keys(PARAM *param,QUICK_RANGE_SELECT *quick,KEY_PART *key, - SEL_ARG *key_tree,char *min_key,uint min_key_flag, - char *max_key, uint max_key_flag) + SEL_ARG *key_tree, uchar *min_key,uint min_key_flag, + uchar *max_key, uint max_key_flag) { QUICK_RANGE *range; uint flag; @@ -7571,7 +7575,7 @@ get_quick_keys(PARAM *param,QUICK_RANGE_SELECT *quick,KEY_PART *key, min_key,min_key_flag, max_key, max_key_flag)) return 1; } - char *tmp_min_key=min_key,*tmp_max_key=max_key; + uchar *tmp_min_key=min_key,*tmp_max_key=max_key; min_part+= key_tree->store_min(key[key_tree->part].store_length, &tmp_min_key,min_key_flag); max_part+= key_tree->store_max(key[key_tree->part].store_length, @@ -7595,10 +7599,10 @@ get_quick_keys(PARAM *param,QUICK_RANGE_SELECT *quick,KEY_PART *key, uint tmp_min_flag=key_tree->min_flag,tmp_max_flag=key_tree->max_flag; if (!tmp_min_flag) min_part+= key_tree->next_key_part->store_min_key(key, &tmp_min_key, - &tmp_min_flag); + &tmp_min_flag); if (!tmp_max_flag) max_part+= key_tree->next_key_part->store_max_key(key, &tmp_max_key, - &tmp_max_flag); + &tmp_max_flag); flag=tmp_min_flag | tmp_max_flag; } } @@ -7646,10 +7650,10 @@ get_quick_keys(PARAM *param,QUICK_RANGE_SELECT *quick,KEY_PART *key, } /* Get range for retrieving rows in QUICK_SELECT::get_next */ - if (!(range= new QUICK_RANGE((const char *) param->min_key, + if (!(range= new QUICK_RANGE(param->min_key, (uint) (tmp_min_key - param->min_key), min_part >=0 ? make_keypart_map(min_part) : 0, - (const char *) param->max_key, + param->max_key, (uint) (tmp_max_key - param->max_key), max_part >=0 ? make_keypart_map(max_part) : 0, flag))) @@ -7658,7 +7662,7 @@ get_quick_keys(PARAM *param,QUICK_RANGE_SELECT *quick,KEY_PART *key, set_if_bigger(quick->max_used_key_length, range->min_length); set_if_bigger(quick->max_used_key_length, range->max_length); set_if_bigger(quick->used_key_parts, (uint) key_tree->part+1); - if (insert_dynamic(&quick->ranges, (gptr)&range)) + if (insert_dynamic(&quick->ranges, (uchar*) &range)) return 1; end: @@ -7691,9 +7695,9 @@ bool QUICK_RANGE_SELECT::unique_key_range() /* Returns TRUE if any part of the key is NULL */ -static bool null_part_in_key(KEY_PART *key_part, const char *key, uint length) +static bool null_part_in_key(KEY_PART *key_part, const uchar *key, uint length) { - for (const char *end=key+length ; + for (const uchar *end=key+length ; key < end; key+= key_part++->store_length) { @@ -7796,7 +7800,7 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table, !(range= new(alloc) QUICK_RANGE())) goto err; // out of memory - range->min_key= range->max_key= (char*) ref->key_buff; + range->min_key= range->max_key= ref->key_buff; range->min_length= range->max_length= ref->key_length; range->min_keypart_map= range->max_keypart_map= make_prev_keypart_map(ref->key_parts); @@ -7817,7 +7821,7 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table, key_part->null_bit= key_info->key_part[part].null_bit; key_part->flag= (uint8) key_info->key_part[part].key_part_flag; } - if (insert_dynamic(&quick->ranges,(gptr)&range)) + if (insert_dynamic(&quick->ranges,(uchar*)&range)) goto err; /* @@ -7832,13 +7836,13 @@ QUICK_RANGE_SELECT *get_quick_select_for_ref(THD *thd, TABLE *table, *ref->null_ref_key= 1; // Set null byte then create a range if (!(null_range= new (alloc) - QUICK_RANGE((char*)ref->key_buff, ref->key_length, + QUICK_RANGE(ref->key_buff, ref->key_length, make_prev_keypart_map(ref->key_parts), - (char*)ref->key_buff, ref->key_length, + ref->key_buff, ref->key_length, make_prev_keypart_map(ref->key_parts), EQ_RANGE))) goto err; *ref->null_ref_key= 0; // Clear null byte - if (insert_dynamic(&quick->ranges,(gptr)&null_range)) + if (insert_dynamic(&quick->ranges,(uchar*)&null_range)) goto err; } @@ -8093,7 +8097,7 @@ int QUICK_ROR_UNION_SELECT::get_next() { int error, dup_row; QUICK_SELECT_I *quick; - byte *tmp; + uchar *tmp; DBUG_ENTER("QUICK_ROR_UNION_SELECT::get_next"); do @@ -8143,7 +8147,7 @@ int QUICK_ROR_UNION_SELECT::get_next() int QUICK_RANGE_SELECT::reset() { uint mrange_bufsiz; - byte *mrange_buff; + uchar *mrange_buff; DBUG_ENTER("QUICK_RANGE_SELECT::reset"); next=0; last_range= NULL; @@ -8186,8 +8190,9 @@ int QUICK_RANGE_SELECT::reset() while (mrange_bufsiz && ! my_multi_malloc(MYF(MY_WME), - &multi_range_buff, sizeof(*multi_range_buff), - &mrange_buff, mrange_bufsiz, + &multi_range_buff, + (uint) sizeof(*multi_range_buff), + &mrange_buff, (uint) mrange_bufsiz, NullS)) { /* Try to shrink the buffers until both are 0. */ @@ -8282,13 +8287,13 @@ int QUICK_RANGE_SELECT::get_next() end_key= &mrange_slot->end_key; last_range= *(cur_range++); - start_key->key= (const byte*) last_range->min_key; + start_key->key= (const uchar*) last_range->min_key; start_key->length= last_range->min_length; start_key->flag= ((last_range->flag & NEAR_MIN) ? HA_READ_AFTER_KEY : (last_range->flag & EQ_RANGE) ? HA_READ_KEY_EXACT : HA_READ_KEY_OR_NEXT); start_key->keypart_map= last_range->min_keypart_map; - end_key->key= (const byte*) last_range->max_key; + end_key->key= (const uchar*) last_range->max_key; end_key->length= last_range->max_length; /* We use HA_READ_AFTER_KEY here because if we are reading on a key @@ -8348,7 +8353,7 @@ end: int QUICK_RANGE_SELECT::get_next_prefix(uint prefix_length, key_part_map keypart_map, - byte *cur_prefix) + uchar *cur_prefix) { DBUG_ENTER("QUICK_RANGE_SELECT::get_next_prefix"); @@ -8374,13 +8379,13 @@ int QUICK_RANGE_SELECT::get_next_prefix(uint prefix_length, } last_range= *(cur_range++); - start_key.key= (const byte*) last_range->min_key; + start_key.key= (const uchar*) last_range->min_key; start_key.length= min(last_range->min_length, prefix_length); start_key.keypart_map= last_range->min_keypart_map & keypart_map; start_key.flag= ((last_range->flag & NEAR_MIN) ? HA_READ_AFTER_KEY : (last_range->flag & EQ_RANGE) ? HA_READ_KEY_EXACT : HA_READ_KEY_OR_NEXT); - end_key.key= (const byte*) last_range->max_key; + end_key.key= (const uchar*) last_range->max_key; end_key.length= min(last_range->max_length, prefix_length); end_key.keypart_map= last_range->max_keypart_map & keypart_map; /* @@ -8416,7 +8421,7 @@ int QUICK_RANGE_SELECT_GEOM::get_next() if (last_range) { // Already read through key - result= file->index_next_same(record, (byte*) last_range->min_key, + result= file->index_next_same(record, last_range->min_key, last_range->min_length); if (result != HA_ERR_END_OF_FILE) DBUG_RETURN(result); @@ -8431,7 +8436,7 @@ int QUICK_RANGE_SELECT_GEOM::get_next() } last_range= *(cur_range++); - result= file->index_read(record, (byte*) last_range->min_key, + result= file->index_read(record, last_range->min_key, last_range->min_keypart_map, (ha_rkey_function)(last_range->flag ^ GEOM_FLAG)); if (result != HA_ERR_KEY_NOT_FOUND && result != HA_ERR_END_OF_FILE) @@ -8536,7 +8541,7 @@ int QUICK_SELECT_DESC::get_next() if (last_range) { // Already read through key result = ((last_range->flag & EQ_RANGE) - ? file->index_next_same(record, (byte*) last_range->min_key, + ? file->index_next_same(record, last_range->min_key, last_range->min_length) : file->index_prev(record)); if (!result) @@ -8564,14 +8569,14 @@ int QUICK_SELECT_DESC::get_next() if (last_range->flag & EQ_RANGE) { - result = file->index_read(record, (byte*) last_range->max_key, + result = file->index_read(record, last_range->max_key, last_range->max_keypart_map, HA_READ_KEY_EXACT); } else { DBUG_ASSERT(last_range->flag & NEAR_MAX || range_reads_after_key(last_range)); - result=file->index_read(record, (byte*) last_range->max_key, + result=file->index_read(record, last_range->max_key, last_range->max_keypart_map, ((last_range->flag & NEAR_MAX) ? HA_READ_BEFORE_KEY : @@ -8608,7 +8613,7 @@ int QUICK_RANGE_SELECT::cmp_next(QUICK_RANGE *range_arg) KEY_PART *key_part=key_parts; uint store_length; - for (char *key=range_arg->max_key, *end=key+range_arg->max_length; + for (uchar *key=range_arg->max_key, *end=key+range_arg->max_length; key < end; key+= store_length, key_part++) { @@ -8627,7 +8632,7 @@ int QUICK_RANGE_SELECT::cmp_next(QUICK_RANGE *range_arg) key++; // Skip null byte store_length--; } - if ((cmp=key_part->field->key_cmp((byte*) key, key_part->length)) < 0) + if ((cmp=key_part->field->key_cmp(key, key_part->length)) < 0) return 0; if (cmp > 0) return 1; @@ -8646,7 +8651,7 @@ int QUICK_RANGE_SELECT::cmp_prev(QUICK_RANGE *range_arg) if (range_arg->flag & NO_MIN_RANGE) return 0; /* key can't be to small */ - cmp= key_cmp(key_part_info, (byte*) range_arg->min_key, + cmp= key_cmp(key_part_info, range_arg->min_key, range_arg->min_length); if (cmp > 0 || cmp == 0 && !(range_arg->flag & NEAR_MIN)) return 0; @@ -8896,7 +8901,7 @@ static bool get_constant_key_infix(KEY *index_info, SEL_ARG *index_range_tree, KEY_PART_INFO *first_non_group_part, KEY_PART_INFO *min_max_arg_part, KEY_PART_INFO *last_part, THD *thd, - byte *key_infix, uint *key_infix_len, + uchar *key_infix, uint *key_infix_len, KEY_PART_INFO **first_non_infix_part); static bool check_group_min_max_predicates(COND *cond, Item_field *min_max_arg_item, @@ -9053,7 +9058,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree) uint index= 0; /* The id of the chosen index. */ uint group_key_parts= 0; // Number of index key parts in the group prefix. uint used_key_parts= 0; /* Number of index key parts used for access. */ - byte key_infix[MAX_KEY_LENGTH]; /* Constants from equality predicates.*/ + uchar key_infix[MAX_KEY_LENGTH]; /* Constants from equality predicates.*/ uint key_infix_len= 0; /* Length of key_infix. */ TRP_GROUP_MIN_MAX *read_plan= NULL; /* The eventually constructed TRP. */ uint key_part_nr; @@ -9337,7 +9342,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree) /* Check if cur_part is referenced in the WHERE clause. */ if (join->conds->walk(&Item::find_item_in_field_list_processor, 0, - (byte*) key_part_range)) + (uchar*) key_part_range)) goto next_index; } } @@ -9607,7 +9612,7 @@ get_constant_key_infix(KEY *index_info, SEL_ARG *index_range_tree, KEY_PART_INFO *first_non_group_part, KEY_PART_INFO *min_max_arg_part, KEY_PART_INFO *last_part, THD *thd, - byte *key_infix, uint *key_infix_len, + uchar *key_infix, uint *key_infix_len, KEY_PART_INFO **first_non_infix_part) { SEL_ARG *cur_range; @@ -9616,7 +9621,7 @@ get_constant_key_infix(KEY *index_info, SEL_ARG *index_range_tree, KEY_PART_INFO *end_part= min_max_arg_part ? min_max_arg_part : last_part; *key_infix_len= 0; - byte *key_ptr= key_infix; + uchar *key_ptr= key_infix; for (cur_part= first_non_group_part; cur_part != end_part; cur_part++) { /* @@ -10006,7 +10011,7 @@ QUICK_GROUP_MIN_MAX_SELECT(TABLE *table, JOIN *join_arg, bool have_min_arg, uint used_key_parts_arg, KEY *index_info_arg, uint use_index, double read_cost_arg, ha_rows records_arg, uint key_infix_len_arg, - byte *key_infix_arg, MEM_ROOT *parent_alloc) + uchar *key_infix_arg, MEM_ROOT *parent_alloc) :join(join_arg), index_info(index_info_arg), group_prefix_len(group_prefix_len_arg), group_key_parts(group_key_parts_arg), have_min(have_min_arg), @@ -10065,13 +10070,13 @@ int QUICK_GROUP_MIN_MAX_SELECT::init() if (group_prefix) /* Already initialized. */ return 0; - if (!(last_prefix= (byte*) alloc_root(&alloc, group_prefix_len))) + if (!(last_prefix= (uchar*) alloc_root(&alloc, group_prefix_len))) return 1; /* We may use group_prefix to store keys with all select fields, so allocate enough space for it. */ - if (!(group_prefix= (byte*) alloc_root(&alloc, + if (!(group_prefix= (uchar*) alloc_root(&alloc, real_prefix_len + min_max_arg_len))) return 1; @@ -10081,7 +10086,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::init() The memory location pointed to by key_infix will be deleted soon, so allocate a new buffer and copy the key_infix into it. */ - byte *tmp_key_infix= (byte*) alloc_root(&alloc, key_infix_len); + uchar *tmp_key_infix= (uchar*) alloc_root(&alloc, key_infix_len); if (!tmp_key_infix) return 1; memcpy(tmp_key_infix, this->key_infix, key_infix_len); @@ -10196,7 +10201,7 @@ bool QUICK_GROUP_MIN_MAX_SELECT::add_range(SEL_ARG *sel_range) range_flag); if (!range) return TRUE; - if (insert_dynamic(&min_max_ranges, (gptr)&range)) + if (insert_dynamic(&min_max_ranges, (uchar*)&range)) return TRUE; return FALSE; } @@ -10231,7 +10236,7 @@ void QUICK_GROUP_MIN_MAX_SELECT::adjust_prefix_ranges () { QUICK_RANGE *range; - get_dynamic(arr, (gptr)&range, inx); + get_dynamic(arr, (uchar*)&range, inx); range->flag &= ~(NEAR_MIN | NEAR_MAX); } } @@ -10267,7 +10272,7 @@ void QUICK_GROUP_MIN_MAX_SELECT::update_key_stat() QUICK_RANGE *cur_range; if (have_min) { /* Check if the right-most range has a lower boundary. */ - get_dynamic(&min_max_ranges, (gptr)&cur_range, + get_dynamic(&min_max_ranges, (uchar*)&cur_range, min_max_ranges.elements - 1); if (!(cur_range->flag & NO_MIN_RANGE)) { @@ -10278,7 +10283,7 @@ void QUICK_GROUP_MIN_MAX_SELECT::update_key_stat() } if (have_max) { /* Check if the left-most range has an upper boundary. */ - get_dynamic(&min_max_ranges, (gptr)&cur_range, 0); + get_dynamic(&min_max_ranges, (uchar*)&cur_range, 0); if (!(cur_range->flag & NO_MAX_RANGE)) { max_used_key_length+= min_max_arg_len; @@ -10604,7 +10609,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_prefix() if (quick_prefix_select) { - byte *cur_prefix= seen_first_key ? group_prefix : NULL; + uchar *cur_prefix= seen_first_key ? group_prefix : NULL; if ((result= quick_prefix_select->get_next_prefix(group_prefix_len, make_prev_keypart_map(group_key_parts), cur_prefix))) DBUG_RETURN(result); @@ -10674,14 +10679,14 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_min_in_range() for (uint range_idx= 0; range_idx < min_max_ranges.elements; range_idx++) { /* Search from the left-most range to the right. */ - get_dynamic(&min_max_ranges, (gptr)&cur_range, range_idx); + get_dynamic(&min_max_ranges, (uchar*)&cur_range, range_idx); /* If the current value for the min/max argument is bigger than the right boundary of cur_range, there is no need to check this range. */ if (range_idx != 0 && !(cur_range->flag & NO_MAX_RANGE) && - (key_cmp(min_max_arg_part, (const byte*) cur_range->max_key, + (key_cmp(min_max_arg_part, (const uchar*) cur_range->max_key, min_max_arg_len) == 1)) continue; @@ -10742,7 +10747,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_min_in_range() if ( !(cur_range->flag & NO_MAX_RANGE) ) { /* Compose the MAX key for the range. */ - byte *max_key= (byte*) my_alloca(real_prefix_len + min_max_arg_len); + uchar *max_key= (uchar*) my_alloca(real_prefix_len + min_max_arg_len); memcpy(max_key, group_prefix, real_prefix_len); memcpy(max_key + real_prefix_len, cur_range->max_key, cur_range->max_length); @@ -10806,7 +10811,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_max_in_range() for (uint range_idx= min_max_ranges.elements; range_idx > 0; range_idx--) { /* Search from the right-most range to the left. */ - get_dynamic(&min_max_ranges, (gptr)&cur_range, range_idx - 1); + get_dynamic(&min_max_ranges, (uchar*)&cur_range, range_idx - 1); /* If the current value for the min/max argument is smaller than the left @@ -10814,7 +10819,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_max_in_range() */ if (range_idx != min_max_ranges.elements && !(cur_range->flag & NO_MIN_RANGE) && - (key_cmp(min_max_arg_part, (const byte*) cur_range->min_key, + (key_cmp(min_max_arg_part, (const uchar*) cur_range->min_key, min_max_arg_len) == -1)) continue; @@ -10860,7 +10865,7 @@ int QUICK_GROUP_MIN_MAX_SELECT::next_max_in_range() if ( !(cur_range->flag & NO_MIN_RANGE) ) { /* Compose the MIN key for the range. */ - byte *min_key= (byte*) my_alloca(real_prefix_len + min_max_arg_len); + uchar *min_key= (uchar*) my_alloca(real_prefix_len + min_max_arg_len); memcpy(min_key, group_prefix, real_prefix_len); memcpy(min_key + real_prefix_len, cur_range->min_key, cur_range->min_length); @@ -11031,10 +11036,10 @@ static void print_ror_scans_arr(TABLE *table, const char *msg, *****************************************************************************/ static void -print_key(KEY_PART *key_part,const char *key,uint used_length) +print_key(KEY_PART *key_part, const uchar *key, uint used_length) { char buff[1024]; - const char *key_end= key+used_length; + const uchar *key_end= key+used_length; String tmp(buff,sizeof(buff),&my_charset_bin); uint store_length; TABLE *table= key_part->field->table; @@ -11057,7 +11062,7 @@ print_key(KEY_PART *key_part,const char *key,uint used_length) key++; // Skip null byte store_length--; } - field->set_key_image((char*) key, key_part->length); + field->set_key_image(key, key_part->length); if (field->type() == MYSQL_TYPE_BIT) (void) field->val_int_as_str(&tmp, 1); else @@ -11112,7 +11117,7 @@ void QUICK_RANGE_SELECT::dbug_dump(int indent, bool verbose) range= *pr; if (!(range->flag & NO_MIN_RANGE)) { - print_key(key_parts,range->min_key,range->min_length); + print_key(key_parts, range->min_key, range->min_length); if (range->flag & NEAR_MIN) fputs(" < ",DBUG_FILE); else @@ -11126,7 +11131,7 @@ void QUICK_RANGE_SELECT::dbug_dump(int indent, bool verbose) fputs(" < ",DBUG_FILE); else fputs(" <= ",DBUG_FILE); - print_key(key_parts,range->max_key,range->max_length); + print_key(key_parts, range->max_key, range->max_length); } fputs("\n",DBUG_FILE); } diff --git a/sql/opt_range.h b/sql/opt_range.h index 76a4caa1ccb..dd219129167 100644 --- a/sql/opt_range.h +++ b/sql/opt_range.h @@ -35,7 +35,7 @@ typedef struct st_key_part { class QUICK_RANGE :public Sql_alloc { public: - char *min_key,*max_key; + uchar *min_key,*max_key; uint16 min_length,max_length,flag; key_part_map min_keypart_map, // bitmap of used keyparts in min_key max_keypart_map; // bitmap of used keyparts in max_key @@ -43,13 +43,13 @@ class QUICK_RANGE :public Sql_alloc { uint16 dummy; /* Avoid warnings on 'flag' */ #endif QUICK_RANGE(); /* Full range */ - QUICK_RANGE(const char *min_key_arg, uint min_length_arg, + QUICK_RANGE(const uchar *min_key_arg, uint min_length_arg, key_part_map min_keypart_map_arg, - const char *max_key_arg, uint max_length_arg, + const uchar *max_key_arg, uint max_length_arg, key_part_map max_keypart_map_arg, uint flag_arg) - : min_key((char*) sql_memdup(min_key_arg,min_length_arg+1)), - max_key((char*) sql_memdup(max_key_arg,max_length_arg+1)), + : min_key((uchar*) sql_memdup(min_key_arg,min_length_arg+1)), + max_key((uchar*) sql_memdup(max_key_arg,max_length_arg+1)), min_length((uint16) min_length_arg), max_length((uint16) max_length_arg), flag((uint16) flag_arg), @@ -241,12 +241,12 @@ public: rowid of last row retrieved by this quick select. This is used only when doing ROR-index_merge selects */ - byte *last_rowid; + uchar *last_rowid; /* Table record buffer used by this quick select. */ - byte *record; + uchar *record; #ifndef DBUG_OFF /* Print quick select information to DBUG_FILE. Caller is responsible @@ -296,8 +296,8 @@ protected: friend bool get_quick_keys(PARAM *param, QUICK_RANGE_SELECT *quick,KEY_PART *key, SEL_ARG *key_tree, - char *min_key, uint min_key_flag, - char *max_key, uint max_key_flag); + uchar *min_key, uint min_key_flag, + uchar *max_key, uint max_key_flag); friend QUICK_RANGE_SELECT *get_quick_select(PARAM*,uint idx, SEL_ARG *key_tree, MEM_ROOT *alloc); @@ -327,7 +327,7 @@ public: int get_next(); void range_end(); int get_next_prefix(uint prefix_length, key_part_map keypart_map, - byte *cur_prefix); + uchar *cur_prefix); bool reverse_sorted() { return 0; } bool unique_key_range(); int init_ror_merged_scan(bool reuse_handler); @@ -561,12 +561,12 @@ public: MEM_ROOT alloc; /* Memory pool for this and merged quick selects data. */ THD *thd; /* current thread */ - byte *cur_rowid; /* buffer used in get_next() */ - byte *prev_rowid; /* rowid of last row returned by get_next() */ + uchar *cur_rowid; /* buffer used in get_next() */ + uchar *prev_rowid; /* rowid of last row returned by get_next() */ bool have_prev_rowid; /* true if prev_rowid has valid data */ uint rowid_length; /* table rowid length */ private: - static int queue_cmp(void *arg, byte *val1, byte *val2); + static int queue_cmp(void *arg, uchar *val1, uchar *val2); bool scans_inited; }; @@ -610,19 +610,19 @@ private: handler *file; /* The handler used to get data. */ JOIN *join; /* Descriptor of the current query */ KEY *index_info; /* The index chosen for data access */ - byte *record; /* Buffer where the next record is returned. */ - byte *tmp_record; /* Temporary storage for next_min(), next_max(). */ - byte *group_prefix; /* Key prefix consisting of the GROUP fields. */ + uchar *record; /* Buffer where the next record is returned. */ + uchar *tmp_record; /* Temporary storage for next_min(), next_max(). */ + uchar *group_prefix; /* Key prefix consisting of the GROUP fields. */ uint group_prefix_len; /* Length of the group prefix. */ uint group_key_parts; /* A number of keyparts in the group prefix */ - byte *last_prefix; /* Prefix of the last group for detecting EOF. */ + uchar *last_prefix; /* Prefix of the last group for detecting EOF. */ bool have_min; /* Specify whether we are computing */ bool have_max; /* a MIN, a MAX, or both. */ bool seen_first_key; /* Denotes whether the first key was retrieved.*/ KEY_PART_INFO *min_max_arg_part; /* The keypart of the only argument field */ /* of all MIN/MAX functions. */ uint min_max_arg_len; /* The length of the MIN/MAX argument field */ - byte *key_infix; /* Infix of constants from equality predicates. */ + uchar *key_infix; /* Infix of constants from equality predicates. */ uint key_infix_len; DYNAMIC_ARRAY min_max_ranges; /* Array of range ptrs for the MIN/MAX field. */ uint real_prefix_len; /* Length of key prefix extended with key_infix. */ @@ -652,7 +652,7 @@ public: uint group_prefix_len, uint group_key_parts, uint used_key_parts, KEY *index_info, uint use_index, double read_cost, ha_rows records, uint - key_infix_len, byte *key_infix, MEM_ROOT + key_infix_len, uchar *key_infix, MEM_ROOT *parent_alloc); ~QUICK_GROUP_MIN_MAX_SELECT(); bool add_range(SEL_ARG *sel_range); @@ -736,7 +736,7 @@ uint get_index_for_order(TABLE *table, ORDER *order, ha_rows limit); #ifdef WITH_PARTITION_STORAGE_ENGINE bool prune_partitions(THD *thd, TABLE *table, Item *pprune_cond); -void store_key_image_to_rec(Field *field, char *ptr, uint len); +void store_key_image_to_rec(Field *field, uchar *ptr, uint len); #endif #endif diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 60df49bd318..8851401d21f 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -222,7 +222,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) Item *expr=item_sum->args[0]; if (expr->real_item()->type() == Item::FIELD_ITEM) { - byte key_buff[MAX_KEY_LENGTH]; + uchar key_buff[MAX_KEY_LENGTH]; TABLE_REF ref; uint range_fl, prefix_len; @@ -366,7 +366,7 @@ int opt_sum_query(TABLE_LIST *tables, List<Item> &all_fields,COND *conds) Item *expr=item_sum->args[0]; if (expr->real_item()->type() == Item::FIELD_ITEM) { - byte key_buff[MAX_KEY_LENGTH]; + uchar key_buff[MAX_KEY_LENGTH]; TABLE_REF ref; uint range_fl, prefix_len; @@ -660,7 +660,7 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo, less_fl= 1-less_fl; // Convert '<' -> '>' (etc) /* Check if field is part of the tested partial key */ - byte *key_ptr= ref->key_buff; + uchar *key_ptr= ref->key_buff; KEY_PART_INFO *part; for (part= keyinfo->key_part; ; key_ptr+= part++->store_length) @@ -709,15 +709,15 @@ static bool matching_cond(bool max_fl, TABLE_REF *ref, KEY *keyinfo, if (is_null) { part->field->set_null(); - *key_ptr= (byte) 1; + *key_ptr= (uchar) 1; } else { store_val_in_field(part->field, args[between && max_fl ? 2 : 1], CHECK_FIELD_IGNORE); if (part->null_bit) - *key_ptr++= (byte) test(part->field->is_null()); - part->field->get_key_image((char*) key_ptr, part->length, Field::itRAW); + *key_ptr++= (uchar) test(part->field->is_null()); + part->field->get_key_image(key_ptr, part->length, Field::itRAW); } if (is_field_part) { diff --git a/sql/parse_file.cc b/sql/parse_file.cc index f06c7c15202..5ea49396cb4 100644 --- a/sql/parse_file.cc +++ b/sql/parse_file.cc @@ -49,27 +49,27 @@ write_escaped_string(IO_CACHE *file, LEX_STRING *val_s) */ switch(*ptr) { case '\\': // escape character - if (my_b_append(file, (const byte *)STRING_WITH_LEN("\\\\"))) + if (my_b_append(file, (const uchar *)STRING_WITH_LEN("\\\\"))) return TRUE; break; case '\n': // parameter value delimiter - if (my_b_append(file, (const byte *)STRING_WITH_LEN("\\n"))) + if (my_b_append(file, (const uchar *)STRING_WITH_LEN("\\n"))) return TRUE; break; case '\0': // problem for some string processing utilities - if (my_b_append(file, (const byte *)STRING_WITH_LEN("\\0"))) + if (my_b_append(file, (const uchar *)STRING_WITH_LEN("\\0"))) return TRUE; break; case 26: // problem for windows utilities (Ctrl-Z) - if (my_b_append(file, (const byte *)STRING_WITH_LEN("\\z"))) + if (my_b_append(file, (const uchar *)STRING_WITH_LEN("\\z"))) return TRUE; break; case '\'': // list of string delimiter - if (my_b_append(file, (const byte *)STRING_WITH_LEN("\\\'"))) + if (my_b_append(file, (const uchar *)STRING_WITH_LEN("\\\'"))) return TRUE; break; default: - if (my_b_append(file, (const byte *)ptr, 1)) + if (my_b_append(file, (const uchar *)ptr, 1)) return TRUE; } } @@ -93,7 +93,7 @@ write_escaped_string(IO_CACHE *file, LEX_STRING *val_s) */ static my_bool -write_parameter(IO_CACHE *file, gptr base, File_option *parameter, +write_parameter(IO_CACHE *file, uchar* base, File_option *parameter, ulonglong *old_version) { char num_buf[20]; // buffer for numeric operations @@ -105,7 +105,7 @@ write_parameter(IO_CACHE *file, gptr base, File_option *parameter, case FILE_OPTIONS_STRING: { LEX_STRING *val_s= (LEX_STRING *)(base + parameter->offset); - if (my_b_append(file, (const byte *)val_s->str, val_s->length)) + if (my_b_append(file, (const uchar *)val_s->str, val_s->length)) DBUG_RETURN(TRUE); break; } @@ -118,7 +118,7 @@ write_parameter(IO_CACHE *file, gptr base, File_option *parameter, case FILE_OPTIONS_ULONGLONG: { num.set(*((ulonglong *)(base + parameter->offset)), &my_charset_bin); - if (my_b_append(file, (const byte *)num.ptr(), num.length())) + if (my_b_append(file, (const uchar *)num.ptr(), num.length())) DBUG_RETURN(TRUE); break; } @@ -127,7 +127,7 @@ write_parameter(IO_CACHE *file, gptr base, File_option *parameter, ulonglong *val_i= (ulonglong *)(base + parameter->offset); *old_version= (*val_i)++; num.set(*val_i, &my_charset_bin); - if (my_b_append(file, (const byte *)num.ptr(), num.length())) + if (my_b_append(file, (const uchar *)num.ptr(), num.length())) DBUG_RETURN(TRUE); break; } @@ -140,7 +140,7 @@ write_parameter(IO_CACHE *file, gptr base, File_option *parameter, get_date(val_s->str, GETDATE_DATE_TIME|GETDATE_GMT|GETDATE_FIXEDLENGTH, tm); val_s->length= PARSE_FILE_TIMESTAMPLENGTH; - if (my_b_append(file, (const byte *)val_s->str, + if (my_b_append(file, (const uchar *)val_s->str, PARSE_FILE_TIMESTAMPLENGTH)) DBUG_RETURN(TRUE); break; @@ -154,10 +154,10 @@ write_parameter(IO_CACHE *file, gptr base, File_option *parameter, while ((str= it++)) { // We need ' ' after string to detect list continuation - if ((!first && my_b_append(file, (const byte *)STRING_WITH_LEN(" "))) || - my_b_append(file, (const byte *)STRING_WITH_LEN("\'")) || + if ((!first && my_b_append(file, (const uchar *)STRING_WITH_LEN(" "))) || + my_b_append(file, (const uchar *)STRING_WITH_LEN("\'")) || write_escaped_string(file, str) || - my_b_append(file, (const byte *)STRING_WITH_LEN("\'"))) + my_b_append(file, (const uchar *)STRING_WITH_LEN("\'"))) { DBUG_RETURN(TRUE); } @@ -175,8 +175,8 @@ write_parameter(IO_CACHE *file, gptr base, File_option *parameter, { num.set(*val, &my_charset_bin); // We need ' ' after string to detect list continuation - if ((!first && my_b_append(file, (const byte *)STRING_WITH_LEN(" "))) || - my_b_append(file, (const byte *)num.ptr(), num.length())) + if ((!first && my_b_append(file, (const uchar *)STRING_WITH_LEN(" "))) || + my_b_append(file, (const uchar *)num.ptr(), num.length())) { DBUG_RETURN(TRUE); } @@ -212,7 +212,7 @@ write_parameter(IO_CACHE *file, gptr base, File_option *parameter, my_bool sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name, const LEX_STRING *type, - gptr base, File_option *parameters, + uchar* base, File_option *parameters, uint max_versions) { File handler; @@ -254,19 +254,19 @@ sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name, goto err_w_file; // write header (file signature) - if (my_b_append(&file, (const byte *)STRING_WITH_LEN("TYPE=")) || - my_b_append(&file, (const byte *)type->str, type->length) || - my_b_append(&file, (const byte *)STRING_WITH_LEN("\n"))) + if (my_b_append(&file, (const uchar *)STRING_WITH_LEN("TYPE=")) || + my_b_append(&file, (const uchar *)type->str, type->length) || + my_b_append(&file, (const uchar *)STRING_WITH_LEN("\n"))) goto err_w_file; // write parameters to temporary file for (param= parameters; param->name.str; param++) { - if (my_b_append(&file, (const byte *)param->name.str, + if (my_b_append(&file, (const uchar *)param->name.str, param->name.length) || - my_b_append(&file, (const byte *)STRING_WITH_LEN("=")) || + my_b_append(&file, (const uchar *)STRING_WITH_LEN("=")) || write_parameter(&file, base, param, &old_version) || - my_b_append(&file, (const byte *)STRING_WITH_LEN("\n"))) + my_b_append(&file, (const uchar *)STRING_WITH_LEN("\n"))) goto err_w_cache; } @@ -423,7 +423,7 @@ sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root, bool bad_format_errors) { MY_STAT stat_info; - uint len; + size_t len; char *end, *sign; File_parser *parser; File file; @@ -445,7 +445,7 @@ sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root, DBUG_RETURN(0); } - if (!(parser->buff= alloc_root(mem_root, stat_info.st_size+1))) + if (!(parser->buff= (char*) alloc_root(mem_root, stat_info.st_size+1))) { DBUG_RETURN(0); } @@ -455,7 +455,7 @@ sql_parse_prepare(const LEX_STRING *file_name, MEM_ROOT *mem_root, DBUG_RETURN(0); } - if ((len= my_read(file, (byte *)parser->buff, + if ((len= my_read(file, (uchar *)parser->buff, stat_info.st_size, MYF(MY_WME))) == MY_FILE_ERROR) { @@ -533,11 +533,8 @@ parse_string(char *ptr, char *end, MEM_ROOT *mem_root, LEX_STRING *str) str->length= eol - ptr; - if (!(str->str= alloc_root(mem_root, str->length+1))) + if (!(str->str= strmake_root(mem_root, ptr, str->length))) return 0; - - memcpy(str->str, ptr, str->length); - str->str[str->length]= '\0'; // just for safety return eol+1; } @@ -623,7 +620,7 @@ parse_escaped_string(char *ptr, char *end, MEM_ROOT *mem_root, LEX_STRING *str) char *eol= strchr(ptr, '\n'); if (eol == 0 || eol >= end || - !(str->str= alloc_root(mem_root, (eol - ptr) + 1)) || + !(str->str= (char*) alloc_root(mem_root, (eol - ptr) + 1)) || read_escaped_string(ptr, eol, str)) return 0; @@ -668,7 +665,7 @@ parse_quoted_escaped_string(char *ptr, char *end, // process string if (eol >= end || - !(str->str= alloc_root(mem_root, result_len + 1)) || + !(str->str= (char*) alloc_root(mem_root, result_len + 1)) || read_escaped_string(ptr, eol, str)) return 0; @@ -691,7 +688,7 @@ parse_quoted_escaped_string(char *ptr, char *end, */ bool get_file_options_ulllist(char *&ptr, char *end, char *line, - gptr base, File_option *parameter, + uchar* base, File_option *parameter, MEM_ROOT *mem_root) { List<ulonglong> *nlist= (List<ulonglong>*)(base + parameter->offset); @@ -754,7 +751,7 @@ nlist_err: */ my_bool -File_parser::parse(gptr base, MEM_ROOT *mem_root, +File_parser::parse(uchar* base, MEM_ROOT *mem_root, struct File_option *parameters, uint required, Unknown_key_hook *hook) { @@ -963,7 +960,7 @@ list_err: bool File_parser_dummy_hook::process_unknown_string(char *&unknown_key, - gptr base, MEM_ROOT *mem_root, + uchar* base, MEM_ROOT *mem_root, char *end) { DBUG_ENTER("file_parser_dummy_hook::process_unknown_string"); diff --git a/sql/parse_file.h b/sql/parse_file.h index 21873b32904..91700959681 100644 --- a/sql/parse_file.h +++ b/sql/parse_file.h @@ -50,7 +50,7 @@ class Unknown_key_hook public: Unknown_key_hook() {} /* Remove gcc warning */ virtual ~Unknown_key_hook() {} /* Remove gcc warning */ - virtual bool process_unknown_string(char *&unknown_key, gptr base, + virtual bool process_unknown_string(char *&unknown_key, uchar* base, MEM_ROOT *mem_root, char *end)= 0; }; @@ -61,14 +61,14 @@ class File_parser_dummy_hook: public Unknown_key_hook { public: File_parser_dummy_hook() {} /* Remove gcc warning */ - virtual bool process_unknown_string(char *&unknown_key, gptr base, + virtual bool process_unknown_string(char *&unknown_key, uchar* base, MEM_ROOT *mem_root, char *end); }; extern File_parser_dummy_hook file_parser_dummy_hook; bool get_file_options_ulllist(char *&ptr, char *end, char *line, - gptr base, File_option *parameter, + uchar* base, File_option *parameter, MEM_ROOT *mem_root); char * @@ -81,7 +81,7 @@ File_parser *sql_parse_prepare(const LEX_STRING *file_name, my_bool sql_create_definition_file(const LEX_STRING *dir, const LEX_STRING *file_name, const LEX_STRING *type, - gptr base, File_option *parameters, uint versions); + uchar* base, File_option *parameters, uint versions); my_bool rename_in_schema_file(const char *schema, const char *old_name, const char *new_name, ulonglong revision, uint num_view_backups); @@ -97,7 +97,7 @@ public: my_bool ok() { return content_ok; } LEX_STRING *type() { return &file_type; } - my_bool parse(gptr base, MEM_ROOT *mem_root, + my_bool parse(uchar* base, MEM_ROOT *mem_root, struct File_option *parameters, uint required, Unknown_key_hook *hook); diff --git a/sql/partition_info.cc b/sql/partition_info.cc index 3e0257f5b1d..23bc3c96e8f 100644 --- a/sql/partition_info.cc +++ b/sql/partition_info.cc @@ -90,10 +90,11 @@ partition_info *partition_info::get_clone() #define MAX_PART_NAME_SIZE 8 -char *partition_info::create_default_partition_names(uint part_no, uint no_parts, +char *partition_info::create_default_partition_names(uint part_no, + uint no_parts, uint start_no) { - char *ptr= sql_calloc(no_parts*MAX_PART_NAME_SIZE); + char *ptr= (char*) sql_calloc(no_parts*MAX_PART_NAME_SIZE); char *move_ptr= ptr; uint i= 0; DBUG_ENTER("create_default_partition_names"); @@ -129,7 +130,7 @@ char *partition_info::create_subpartition_name(uint subpart_no, const char *part_name) { uint size_alloc= strlen(part_name) + MAX_PART_NAME_SIZE; - char *ptr= sql_calloc(size_alloc); + char *ptr= (char*) sql_calloc(size_alloc); DBUG_ENTER("create_subpartition_name"); if (likely(ptr != NULL)) @@ -902,7 +903,7 @@ void partition_info::print_no_partition_found(TABLE *table) bool partition_info::set_up_charset_field_preps() { Field *field, **ptr; - char **char_ptrs; + uchar **char_ptrs; unsigned i; bool found; size_t size; @@ -927,14 +928,14 @@ bool partition_info::set_up_charset_field_preps() } } size= tot_part_fields * sizeof(char*); - if (!(char_ptrs= (char**)sql_calloc(size))) + if (!(char_ptrs= (uchar**)sql_calloc(size))) goto error; part_field_buffers= char_ptrs; - if (!(char_ptrs= (char**)sql_calloc(size))) + if (!(char_ptrs= (uchar**)sql_calloc(size))) goto error; restore_part_field_ptrs= char_ptrs; size= (tot_part_fields + 1) * sizeof(Field*); - if (!(char_ptrs= (char**)sql_alloc(size))) + if (!(char_ptrs= (uchar**)sql_alloc(size))) goto error; part_charset_field_array= (Field**)char_ptrs; ptr= part_field_array; @@ -943,9 +944,9 @@ bool partition_info::set_up_charset_field_preps() { if (field_is_partition_charset(field)) { - char *field_buf; + uchar *field_buf; size= field->pack_length(); - if (!(field_buf= sql_calloc(size))) + if (!(field_buf= (uchar*) sql_calloc(size))) goto error; part_charset_field_array[i]= field; part_field_buffers[i++]= field_buf; @@ -964,14 +965,14 @@ bool partition_info::set_up_charset_field_preps() tot_subpart_fields++; } size= tot_subpart_fields * sizeof(char*); - if (!(char_ptrs= (char**)sql_calloc(size))) + if (!(char_ptrs= (uchar**) sql_calloc(size))) goto error; subpart_field_buffers= char_ptrs; - if (!(char_ptrs= (char**)sql_calloc(size))) + if (!(char_ptrs= (uchar**) sql_calloc(size))) goto error; restore_subpart_field_ptrs= char_ptrs; size= (tot_subpart_fields + 1) * sizeof(Field*); - if (!(char_ptrs= (char**)sql_alloc(size))) + if (!(char_ptrs= (uchar**) sql_alloc(size))) goto error; subpart_charset_field_array= (Field**)char_ptrs; i= 0; @@ -979,7 +980,7 @@ bool partition_info::set_up_charset_field_preps() { unsigned j= 0; CHARSET_INFO *cs; - char *field_buf; + uchar *field_buf; LINT_INIT(field_buf); if (!field_is_partition_charset(field)) @@ -995,12 +996,12 @@ bool partition_info::set_up_charset_field_preps() if (!found) { tot_fields++; - if (!(field_buf= sql_calloc(size))) + if (!(field_buf= (uchar*) sql_calloc(size))) goto error; } subpart_field_buffers[i++]= field_buf; } - if (!(char_ptrs= (char**)sql_calloc(size))) + if (!(char_ptrs= (uchar**) sql_calloc(size))) goto error; restore_subpart_field_ptrs= char_ptrs; } @@ -1009,14 +1010,14 @@ bool partition_info::set_up_charset_field_preps() uint j,k,l; size= tot_fields*sizeof(char**); - if (!(char_ptrs= (char**)sql_calloc(size))) + if (!(char_ptrs= (uchar**)sql_calloc(size))) goto error; full_part_field_buffers= char_ptrs; - if (!(char_ptrs= (char**)sql_calloc(size))) + if (!(char_ptrs= (uchar**)sql_calloc(size))) goto error; restore_full_part_field_ptrs= char_ptrs; size= (tot_fields + 1) * sizeof(char**); - if (!(char_ptrs= (char**)sql_calloc(size))) + if (!(char_ptrs= (uchar**)sql_calloc(size))) goto error; full_part_charset_field_array= (Field**)char_ptrs; for (i= 0; i < tot_part_fields; i++) diff --git a/sql/partition_info.h b/sql/partition_info.h index 6c21002c184..ce2f2a7b358 100644 --- a/sql/partition_info.h +++ b/sql/partition_info.h @@ -87,12 +87,12 @@ public: partition functions we must allocate field buffers for the field of the fields in the partition function. */ - char **part_field_buffers; - char **subpart_field_buffers; - char **full_part_field_buffers; - char **restore_part_field_ptrs; - char **restore_subpart_field_ptrs; - char **restore_full_part_field_ptrs; + uchar **part_field_buffers; + uchar **subpart_field_buffers; + uchar **full_part_field_buffers; + uchar **restore_part_field_ptrs; + uchar **restore_subpart_field_ptrs; + uchar **restore_full_part_field_ptrs; Item *part_expr; Item *subpart_expr; diff --git a/sql/protocol.cc b/sql/protocol.cc index d537fd346f9..2ed241c4c98 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -33,9 +33,9 @@ static void write_eof_packet(THD *thd, NET *net); #endif #ifndef EMBEDDED_LIBRARY -bool Protocol::net_store_data(const char *from, uint length) +bool Protocol::net_store_data(const uchar *from, size_t length) #else -bool Protocol_binary::net_store_data(const char *from, uint length) +bool Protocol_binary::net_store_data(const uchar *from, size_t length) #endif { ulong packet_length=packet->length(); @@ -46,10 +46,9 @@ bool Protocol_binary::net_store_data(const char *from, uint length) if (packet_length+9+length > packet->alloced_length() && packet->realloc(packet_length+9+length)) return 1; - char *to=(char*) net_store_length((char*) packet->ptr()+packet_length, - length); + uchar *to= net_store_length((uchar*) packet->ptr()+packet_length, length); memcpy(to,from,length); - packet->length((uint) (to+length-packet->ptr())); + packet->length((uint) (to+length-(uchar*) packet->ptr())); return 0; } @@ -227,7 +226,7 @@ net_printf_error(THD *thd, uint errcode, ...) memcpy(pos+3, mysql_errno_to_sqlstate(errcode), SQLSTATE_LENGTH); } } - VOID(net_real_write(net,(char*) net->buff,length+head_length+1+offset)); + VOID(net_real_write(net, net->buff, length+head_length+1+offset)); #else net->last_errno= errcode; strmake(net->last_error, text_pos, length); @@ -271,7 +270,7 @@ void send_ok(THD *thd, ha_rows affected_rows, ulonglong id, const char *message) { NET *net= &thd->net; - char buff[MYSQL_ERRMSG_SIZE+10],*pos; + uchar buff[MYSQL_ERRMSG_SIZE+10],*pos; DBUG_ENTER("send_ok"); if (net->no_send_ok || !net->vio) // hack for re-parsing queries @@ -307,8 +306,8 @@ send_ok(THD *thd, ha_rows affected_rows, ulonglong id, const char *message) pos+=2; } if (message) - pos=net_store_data((char*) pos, message, strlen(message)); - VOID(my_net_write(net,buff,(uint) (pos-buff))); + pos= net_store_data(pos, (uchar*) message, strlen(message)); + VOID(my_net_write(net, buff, (size_t) (pos-buff))); VOID(net_flush(net)); /* We can't anymore send an error to the client */ thd->net.report_error= 0; @@ -318,7 +317,7 @@ send_ok(THD *thd, ha_rows affected_rows, ulonglong id, const char *message) DBUG_VOID_RETURN; } -static char eof_buff[1]= { (char) 254 }; /* Marker for end of fields */ +static uchar eof_buff[1]= { (uchar) 254 }; /* Marker for end of fields */ /* Send eof (= end of result set) to the client @@ -383,7 +382,7 @@ static void write_eof_packet(THD *thd, NET *net) if (thd->is_fatal_error) thd->server_status&= ~SERVER_MORE_RESULTS_EXISTS; int2store(buff+3, thd->server_status); - VOID(my_net_write(net, (char*) buff, 5)); + VOID(my_net_write(net, buff, 5)); } else VOID(my_net_write(net, eof_buff, 1)); @@ -411,7 +410,7 @@ void net_send_error_packet(THD *thd, uint sql_errno, const char *err) { NET *net= &thd->net; uint length; - char buff[MYSQL_ERRMSG_SIZE+2], *pos; + uchar buff[MYSQL_ERRMSG_SIZE+2], *pos; DBUG_ENTER("send_error_packet"); @@ -433,17 +432,19 @@ void net_send_error_packet(THD *thd, uint sql_errno, const char *err) { /* The first # is to make the protocol backward compatible */ buff[2]= '#'; - pos= strmov(buff+3, mysql_errno_to_sqlstate(sql_errno)); + pos= (uchar*) strmov((char*) buff+3, mysql_errno_to_sqlstate(sql_errno)); } - length= (uint) (strmake(pos, err, MYSQL_ERRMSG_SIZE-1) - buff); - err=buff; + length= (uint) (strmake((char*) pos, err, MYSQL_ERRMSG_SIZE-1) - + (char*) buff); + err= (char*) buff; } else { length=(uint) strlen(err); set_if_smaller(length,MYSQL_ERRMSG_SIZE-1); } - VOID(net_write_command(net,(uchar) 255, "", 0, (char*) err,length)); + VOID(net_write_command(net,(uchar) 255, (uchar*) "", 0, (uchar*) err, + length)); DBUG_VOID_RETURN; } @@ -459,17 +460,16 @@ void net_send_error_packet(THD *thd, uint sql_errno, const char *err) ulonglong for bigger numbers. */ -static char *net_store_length_fast(char *pkg, uint length) +static uchar *net_store_length_fast(uchar *packet, uint length) { - uchar *packet=(uchar*) pkg; if (length < 251) { *packet=(uchar) length; - return (char*) packet+1; + return packet+1; } *packet++=252; int2store(packet,(uint) length); - return (char*) packet+2; + return packet+2; } @@ -480,14 +480,14 @@ static char *net_store_length_fast(char *pkg, uint length) /* The following will only be used for short strings < 65K */ -char *net_store_data(char *to,const char *from, uint length) +uchar *net_store_data(uchar *to, const uchar *from, size_t length) { to=net_store_length_fast(to,length); memcpy(to,from,length); return to+length; } -char *net_store_data(char *to,int32 from) +uchar *net_store_data(uchar *to,int32 from) { char buff[20]; uint length=(uint) (int10_to_str(from,buff,10)-buff); @@ -496,7 +496,7 @@ char *net_store_data(char *to,int32 from) return to+length; } -char *net_store_data(char *to,longlong from) +uchar *net_store_data(uchar *to,longlong from) { char buff[22]; uint length=(uint) (longlong10_to_str(from,buff,10)-buff); @@ -555,7 +555,7 @@ bool Protocol::send_fields(List<Item> *list, uint flags) { List_iterator_fast<Item> it(*list); Item *item; - char buff[80]; + uchar buff[80]; String tmp((char*) buff,sizeof(buff),&my_charset_bin); Protocol_text prot(thd); String *local_packet= prot.storage_packet(); @@ -564,8 +564,8 @@ bool Protocol::send_fields(List<Item> *list, uint flags) if (flags & SEND_NUM_ROWS) { // Packet with number of elements - char *pos=net_store_length(buff, list->elements); - (void) my_net_write(&thd->net, buff,(uint) (pos-buff)); + uchar *pos= net_store_length(buff, list->elements); + (void) my_net_write(&thd->net, buff, (size_t) (pos-buff)); } #ifndef DBUG_OFF @@ -698,7 +698,8 @@ err: bool Protocol::write() { DBUG_ENTER("Protocol::write"); - DBUG_RETURN(my_net_write(&thd->net, packet->ptr(), packet->length())); + DBUG_RETURN(my_net_write(&thd->net, (uchar*) packet->ptr(), + packet->length())); } #endif /* EMBEDDED_LIBRARY */ @@ -785,7 +786,7 @@ bool Protocol_text::store_null() and store in network buffer. */ -bool Protocol::store_string_aux(const char *from, uint length, +bool Protocol::store_string_aux(const char *from, size_t length, CHARSET_INFO *fromcs, CHARSET_INFO *tocs) { /* 'tocs' is set 0 when client issues SET character_set_results=NULL */ @@ -794,15 +795,15 @@ bool Protocol::store_string_aux(const char *from, uint length, tocs != &my_charset_bin) { uint dummy_errors; - return convert->copy(from, length, fromcs, tocs, &dummy_errors) || - net_store_data(convert->ptr(), convert->length()); + return (convert->copy(from, length, fromcs, tocs, &dummy_errors) || + net_store_data((uchar*) convert->ptr(), convert->length())); } - return net_store_data(from, length); + return net_store_data((uchar*) from, length); } -bool Protocol_text::store(const char *from, uint length, - CHARSET_INFO *fromcs, CHARSET_INFO *tocs) +bool Protocol_text::store(const char *from, size_t length, + CHARSET_INFO *fromcs, CHARSET_INFO *tocs) { #ifndef DBUG_OFF DBUG_ASSERT(field_types == 0 || @@ -817,7 +818,7 @@ bool Protocol_text::store(const char *from, uint length, } -bool Protocol_text::store(const char *from, uint length, +bool Protocol_text::store(const char *from, size_t length, CHARSET_INFO *fromcs) { CHARSET_INFO *tocs= this->thd->variables.character_set_results; @@ -841,8 +842,8 @@ bool Protocol_text::store_tiny(longlong from) field_pos++; #endif char buff[20]; - return net_store_data((char*) buff, - (uint) (int10_to_str((int) from,buff, -10)-buff)); + return net_store_data((uchar*) buff, + (size_t) (int10_to_str((int) from, buff, -10) - buff)); } @@ -855,8 +856,9 @@ bool Protocol_text::store_short(longlong from) field_pos++; #endif char buff[20]; - return net_store_data((char*) buff, - (uint) (int10_to_str((int) from,buff, -10)-buff)); + return net_store_data((uchar*) buff, + (size_t) (int10_to_str((int) from, buff, -10) - + buff)); } @@ -869,8 +871,9 @@ bool Protocol_text::store_long(longlong from) field_pos++; #endif char buff[20]; - return net_store_data((char*) buff, - (uint) (int10_to_str((long int)from,buff, (from <0)?-10:10)-buff)); + return net_store_data((uchar*) buff, + (size_t) (int10_to_str((long int)from, buff, + (from <0)?-10:10)-buff)); } @@ -882,10 +885,10 @@ bool Protocol_text::store_longlong(longlong from, bool unsigned_flag) field_pos++; #endif char buff[22]; - return net_store_data((char*) buff, - (uint) (longlong10_to_str(from,buff, - unsigned_flag ? 10 : -10)- - buff)); + return net_store_data((uchar*) buff, + (size_t) (longlong10_to_str(from,buff, + unsigned_flag ? 10 : -10)- + buff)); } @@ -899,7 +902,7 @@ bool Protocol_text::store_decimal(const my_decimal *d) char buff[DECIMAL_MAX_STR_LENGTH]; String str(buff, sizeof(buff), &my_charset_bin); (void) my_decimal2string(E_DEC_FATAL_ERROR, d, 0, 0, 0, &str); - return net_store_data(str.ptr(), str.length()); + return net_store_data((uchar*) str.ptr(), str.length()); } @@ -911,7 +914,7 @@ bool Protocol_text::store(float from, uint32 decimals, String *buffer) field_pos++; #endif buffer->set_real((double) from, decimals, thd->charset()); - return net_store_data((char*) buffer->ptr(), buffer->length()); + return net_store_data((uchar*) buffer->ptr(), buffer->length()); } @@ -923,7 +926,7 @@ bool Protocol_text::store(double from, uint32 decimals, String *buffer) field_pos++; #endif buffer->set_real(from, decimals, thd->charset()); - return net_store_data((char*) buffer->ptr(), buffer->length()); + return net_store_data((uchar*) buffer->ptr(), buffer->length()); } @@ -979,8 +982,9 @@ bool Protocol_text::store(MYSQL_TIME *tm) (int) tm->minute, (int) tm->second)); if (tm->second_part) - length+= my_sprintf(buff+length,(buff+length, ".%06d", (int)tm->second_part)); - return net_store_data((char*) buff, length); + length+= my_sprintf(buff+length,(buff+length, ".%06d", + (int)tm->second_part)); + return net_store_data((uchar*) buff, length); } @@ -992,8 +996,8 @@ bool Protocol_text::store_date(MYSQL_TIME *tm) field_pos++; #endif char buff[MAX_DATE_STRING_REP_LENGTH]; - int length= my_date_to_str(tm, buff); - return net_store_data(buff, (uint) length); + size_t length= my_date_to_str(tm, buff); + return net_store_data((uchar*) buff, length); } @@ -1020,7 +1024,7 @@ bool Protocol_text::store_time(MYSQL_TIME *tm) (int) tm->second)); if (tm->second_part) length+= my_sprintf(buff+length,(buff+length, ".%06d", (int)tm->second_part)); - return net_store_data((char*) buff, length); + return net_store_data((uchar*) buff, length); } @@ -1057,12 +1061,12 @@ bool Protocol_binary::prepare_for_send(List<Item> *item_list) void Protocol_binary::prepare_for_resend() { packet->length(bit_fields+1); - bzero((char*) packet->ptr(), 1+bit_fields); + bzero((uchar*) packet->ptr(), 1+bit_fields); field_pos=0; } -bool Protocol_binary::store(const char *from, uint length, +bool Protocol_binary::store(const char *from, size_t length, CHARSET_INFO *fromcs) { CHARSET_INFO *tocs= thd->variables.character_set_results; @@ -1070,7 +1074,7 @@ bool Protocol_binary::store(const char *from, uint length, return store_string_aux(from, length, fromcs, tocs); } -bool Protocol_binary::store(const char *from,uint length, +bool Protocol_binary::store(const char *from, size_t length, CHARSET_INFO *fromcs, CHARSET_INFO *tocs) { field_pos++; diff --git a/sql/protocol.h b/sql/protocol.h index e0672240e0e..46a2b6d36b6 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -35,14 +35,14 @@ protected: #endif uint field_count; #ifndef EMBEDDED_LIBRARY - bool net_store_data(const char *from, uint length); + bool net_store_data(const uchar *from, size_t length); #else - virtual bool net_store_data(const char *from, uint length); + virtual bool net_store_data(const uchar *from, size_t length); char **next_field; MYSQL_FIELD *next_mysql_field; MEM_ROOT *alloc; #endif - bool store_string_aux(const char *from, uint length, + bool store_string_aux(const char *from, size_t length, CHARSET_INFO *fromcs, CHARSET_INFO *tocs); public: Protocol() {} @@ -83,8 +83,8 @@ public: virtual bool store_long(longlong from)=0; virtual bool store_longlong(longlong from, bool unsigned_flag)=0; virtual bool store_decimal(const my_decimal *)=0; - virtual bool store(const char *from, uint length, CHARSET_INFO *cs)=0; - virtual bool store(const char *from, uint length, + virtual bool store(const char *from, size_t length, CHARSET_INFO *cs)=0; + virtual bool store(const char *from, size_t length, CHARSET_INFO *fromcs, CHARSET_INFO *tocs)=0; virtual bool store(float from, uint32 decimals, String *buffer)=0; virtual bool store(double from, uint32 decimals, String *buffer)=0; @@ -124,8 +124,8 @@ public: virtual bool store_long(longlong from); virtual bool store_longlong(longlong from, bool unsigned_flag); virtual bool store_decimal(const my_decimal *); - virtual bool store(const char *from, uint length, CHARSET_INFO *cs); - virtual bool store(const char *from, uint length, + virtual bool store(const char *from, size_t length, CHARSET_INFO *cs); + virtual bool store(const char *from, size_t length, CHARSET_INFO *fromcs, CHARSET_INFO *tocs); virtual bool store(MYSQL_TIME *time); virtual bool store_date(MYSQL_TIME *time); @@ -151,7 +151,7 @@ public: virtual void prepare_for_resend(); #ifdef EMBEDDED_LIBRARY virtual bool write(); - bool net_store_data(const char *from, uint length); + bool net_store_data(const uchar *from, size_t length); #endif virtual bool store_null(); virtual bool store_tiny(longlong from); @@ -159,8 +159,8 @@ public: virtual bool store_long(longlong from); virtual bool store_longlong(longlong from, bool unsigned_flag); virtual bool store_decimal(const my_decimal *); - virtual bool store(const char *from,uint length, CHARSET_INFO *cs); - virtual bool store(const char *from, uint length, + virtual bool store(const char *from, size_t length, CHARSET_INFO *cs); + virtual bool store(const char *from, size_t length, CHARSET_INFO *fromcs, CHARSET_INFO *tocs); virtual bool store(MYSQL_TIME *time); virtual bool store_date(MYSQL_TIME *time); @@ -178,7 +178,7 @@ void send_ok(THD *thd, ha_rows affected_rows=0L, ulonglong id=0L, const char *info=0); void send_eof(THD *thd); bool send_old_password_request(THD *thd); -char *net_store_data(char *to,const char *from, uint length); -char *net_store_data(char *to,int32 from); -char *net_store_data(char *to,longlong from); +uchar *net_store_data(uchar *to,const uchar *from, size_t length); +uchar *net_store_data(uchar *to,int32 from); +uchar *net_store_data(uchar *to,longlong from); diff --git a/sql/records.cc b/sql/records.cc index 0fb9f4f9650..81c26da4b4d 100644 --- a/sql/records.cc +++ b/sql/records.cc @@ -432,7 +432,7 @@ static int rr_unpack_from_tempfile(READ_RECORD *info) static int rr_from_pointers(READ_RECORD *info) { int tmp; - byte *cache_pos; + uchar *cache_pos; for (;;) { @@ -502,7 +502,7 @@ static int init_rr_cache(THD *thd, READ_RECORD *info) // We have to allocate one more byte to use uint3korr (see comments for it) if (info->cache_records <= 2 || - !(info->cache=(byte*) my_malloc_lock(rec_cache_size+info->cache_records* + !(info->cache=(uchar*) my_malloc_lock(rec_cache_size+info->cache_records* info->struct_length+1, MYF(0)))) DBUG_RETURN(1); @@ -523,7 +523,7 @@ static int rr_from_cache(READ_RECORD *info) ulong length; my_off_t rest_of_file; int16 error; - byte *position,*ref_position,*record_pos; + uchar *position,*ref_position,*record_pos; ulong record; for (;;) @@ -560,7 +560,7 @@ static int rr_from_cache(READ_RECORD *info) ref_position=info->read_positions; for (i=0 ; i < length ; i++,position+=info->ref_length) { - memcpy(ref_position,position,(size_s) info->ref_length); + memcpy(ref_position,position,(size_t) info->ref_length); ref_position+=MAX_REFLENGTH; int3store(ref_position,(long) i); ref_position+=3; @@ -570,7 +570,7 @@ static int rr_from_cache(READ_RECORD *info) position=info->read_positions; for (i=0 ; i < length ; i++) { - memcpy(info->ref_pos,position,(size_s) info->ref_length); + memcpy(info->ref_pos,position,(size_t) info->ref_length); position+=MAX_REFLENGTH; record=uint3korr(position); position+=3; diff --git a/sql/repl_failsafe.cc b/sql/repl_failsafe.cc index 6470f15e458..8bab1ff1ca3 100644 --- a/sql/repl_failsafe.cc +++ b/sql/repl_failsafe.cc @@ -134,9 +134,9 @@ void unregister_slave(THD* thd, bool only_mine, bool need_mutex) SLAVE_INFO* old_si; if ((old_si = (SLAVE_INFO*)hash_search(&slave_list, - (byte*)&thd->server_id, 4)) && + (uchar*)&thd->server_id, 4)) && (!only_mine || old_si->thd == thd)) - hash_delete(&slave_list, (byte*)old_si); + hash_delete(&slave_list, (uchar*)old_si); if (need_mutex) pthread_mutex_unlock(&LOCK_slave_list); @@ -180,12 +180,12 @@ int register_slave(THD* thd, uchar* packet, uint packet_length) pthread_mutex_lock(&LOCK_slave_list); unregister_slave(thd,0,0); - res= my_hash_insert(&slave_list, (byte*) si); + res= my_hash_insert(&slave_list, (uchar*) si); pthread_mutex_unlock(&LOCK_slave_list); return res; err: - my_free((gptr) si, MYF(MY_WME)); + my_free(si, MYF(MY_WME)); my_message(ER_UNKNOWN_ERROR, "Wrong parameters to function register_slave", MYF(0)); err2: @@ -193,7 +193,7 @@ err2: } extern "C" uint32 -*slave_list_key(SLAVE_INFO* si, uint* len, +*slave_list_key(SLAVE_INFO* si, size_t *len, my_bool not_used __attribute__((unused))) { *len = 4; @@ -202,7 +202,7 @@ extern "C" uint32 extern "C" void slave_info_free(void *s) { - my_free((gptr) s, MYF(MY_WME)); + my_free(s, MYF(MY_WME)); } void init_slave_list() @@ -531,7 +531,7 @@ HOSTS"; SLAVE_INFO* si, *old_si; log_server_id = atoi(row[0]); if ((old_si= (SLAVE_INFO*)hash_search(&slave_list, - (byte*)&log_server_id,4))) + (uchar*)&log_server_id,4))) si = old_si; else { @@ -542,7 +542,7 @@ HOSTS"; goto err; } si->server_id = log_server_id; - my_hash_insert(&slave_list, (byte*)si); + my_hash_insert(&slave_list, (uchar*)si); } strmake(si->host, row[1], sizeof(si->host)-1); si->port = atoi(row[port_ind]); diff --git a/sql/rpl_filter.cc b/sql/rpl_filter.cc index f76f798f6a6..bb5db0106eb 100644 --- a/sql/rpl_filter.cc +++ b/sql/rpl_filter.cc @@ -103,12 +103,12 @@ Rpl_filter::tables_ok(const char* db, TABLE_LIST* tables) len= (uint) (strmov(end, tables->table_name) - hash_key); if (do_table_inited) // if there are any do's { - if (hash_search(&do_table, (byte*) hash_key, len)) + if (hash_search(&do_table, (uchar*) hash_key, len)) DBUG_RETURN(1); } if (ignore_table_inited) // if there are any ignores { - if (hash_search(&ignore_table, (byte*) hash_key, len)) + if (hash_search(&ignore_table, (uchar*) hash_key, len)) DBUG_RETURN(0); } if (wild_do_table_inited && @@ -319,7 +319,7 @@ Rpl_filter::add_table_rule(HASH* h, const char* table_spec) e->key_len= len; memcpy(e->db, table_spec, len); - return my_hash_insert(h, (byte*)e); + return my_hash_insert(h, (uchar*)e); } @@ -340,7 +340,7 @@ Rpl_filter::add_wild_table_rule(DYNAMIC_ARRAY* a, const char* table_spec) e->tbl_name= e->db + (dot - table_spec) + 1; e->key_len= len; memcpy(e->db, table_spec, len); - insert_dynamic(a, (gptr)&e); + insert_dynamic(a, (uchar*)&e); return 0; } @@ -363,13 +363,13 @@ Rpl_filter::add_ignore_db(const char* table_spec) } -static byte* get_table_key(const byte* a, uint* len, +static uchar* get_table_key(const uchar* a, size_t *len, my_bool __attribute__((unused))) { TABLE_RULE_ENT *e= (TABLE_RULE_ENT *) a; *len= e->key_len; - return (byte*)e->db; + return (uchar*)e->db; } @@ -377,7 +377,7 @@ static void free_table_ent(void* a) { TABLE_RULE_ENT *e= (TABLE_RULE_ENT *) a; - my_free((gptr) e, MYF(0)); + my_free((uchar*) e, MYF(0)); } @@ -408,7 +408,7 @@ Rpl_filter::find_wild(DYNAMIC_ARRAY *a, const char* key, int len) for (i= 0; i < a->elements; i++) { TABLE_RULE_ENT* e ; - get_dynamic(a, (gptr)&e, i); + get_dynamic(a, (uchar*)&e, i); if (!my_wildcmp(system_charset_info, key, key_end, (const char*)e->db, (const char*)(e->db + e->key_len), @@ -427,7 +427,7 @@ Rpl_filter::free_string_array(DYNAMIC_ARRAY *a) for (i= 0; i < a->elements; i++) { char* p; - get_dynamic(a, (gptr) &p, i); + get_dynamic(a, (uchar*) &p, i); my_free(p, MYF(MY_WME)); } delete_dynamic(a); @@ -474,7 +474,7 @@ Rpl_filter::table_rule_ent_dynamic_array_to_str(String* s, DYNAMIC_ARRAY* a, for (uint i= 0; i < a->elements; i++) { TABLE_RULE_ENT* e; - get_dynamic(a, (gptr)&e, i); + get_dynamic(a, (uchar*)&e, i); if (s->length()) s->append(','); s->append(e->db,e->key_len); @@ -512,7 +512,7 @@ Rpl_filter::get_wild_ignore_table(String* str) const char* -Rpl_filter::get_rewrite_db(const char* db, uint *new_len) +Rpl_filter::get_rewrite_db(const char* db, size_t *new_len) { if (rewrite_db.is_empty() || !db) return db; diff --git a/sql/rpl_filter.h b/sql/rpl_filter.h index 396207d3a28..ff7e4081bb1 100644 --- a/sql/rpl_filter.h +++ b/sql/rpl_filter.h @@ -69,7 +69,7 @@ public: void get_wild_do_table(String* str); void get_wild_ignore_table(String* str); - const char* get_rewrite_db(const char* db, uint *new_len); + const char* get_rewrite_db(const char* db, size_t *new_len); I_List<i_string>* get_do_db(); I_List<i_string>* get_ignore_db(); diff --git a/sql/rpl_injector.h b/sql/rpl_injector.h index 9c444ee20b3..4ece092c5b8 100644 --- a/sql/rpl_injector.h +++ b/sql/rpl_injector.h @@ -74,7 +74,7 @@ public: friend class injector; public: /* Convenience definitions */ - typedef byte* record_type; + typedef uchar* record_type; typedef uint32 server_id_type; /* diff --git a/sql/rpl_record.cc b/sql/rpl_record.cc index 4c6686cf446..45edb42374b 100644 --- a/sql/rpl_record.cc +++ b/sql/rpl_record.cc @@ -51,14 +51,14 @@ @return The number of bytes written at @c row_data. */ #if !defined(MYSQL_CLIENT) -my_size_t +size_t pack_row(TABLE *table, MY_BITMAP const* cols, - byte *row_data, const byte *record) + uchar *row_data, const uchar *record) { Field **p_field= table->field, *field; int const null_byte_count= (bitmap_bits_set(cols) + 7) / 8; - byte *pack_ptr = row_data + null_byte_count; - byte *null_ptr = row_data; + uchar *pack_ptr = row_data + null_byte_count; + uchar *null_ptr = row_data; my_ptrdiff_t const rec_offset= record - table->record[0]; my_ptrdiff_t const def_offset= table->s->default_values - table->record[0]; @@ -90,7 +90,7 @@ pack_row(TABLE *table, MY_BITMAP const* cols, /* We only store the data of the field if it is non-null */ - pack_ptr= (byte*)field->pack((char *) pack_ptr, field->ptr + offset); + pack_ptr= field->pack(pack_ptr, field->ptr + offset); } null_mask <<= 1; @@ -119,7 +119,7 @@ pack_row(TABLE *table, MY_BITMAP const* cols, */ DBUG_ASSERT(null_ptr == row_data + null_byte_count); - return static_cast<my_size_t>(pack_ptr - row_data); + return static_cast<size_t>(pack_ptr - row_data); } #endif @@ -164,17 +164,17 @@ pack_row(TABLE *table, MY_BITMAP const* cols, int unpack_row(RELAY_LOG_INFO const *rli, TABLE *table, uint const colcnt, - char const *const row_data, MY_BITMAP const *cols, - char const **const row_end, ulong *const master_reclength, + uchar const *const row_data, MY_BITMAP const *cols, + uchar const **const row_end, ulong *const master_reclength, MY_BITMAP* const rw_set, Log_event_type const event_type) { DBUG_ENTER("unpack_row"); DBUG_ASSERT(row_data); - my_size_t const master_null_byte_count= (bitmap_bits_set(cols) + 7) / 8; + size_t const master_null_byte_count= (bitmap_bits_set(cols) + 7) / 8; int error= 0; - char const *null_ptr= row_data; - char const *pack_ptr= row_data + master_null_byte_count; + uchar const *null_ptr= row_data; + uchar const *pack_ptr= row_data + master_null_byte_count; bitmap_clear_all(rw_set); @@ -239,7 +239,7 @@ unpack_row(RELAY_LOG_INFO const *rli, if (master_reclength) { if (*field_ptr) - *master_reclength = (*field_ptr)->ptr - (char*) table->record[0]; + *master_reclength = (*field_ptr)->ptr - table->record[0]; else *master_reclength = table->s->reclength; } diff --git a/sql/rpl_record.h b/sql/rpl_record.h index 7ff1bbc7c8e..12c2f1fc713 100644 --- a/sql/rpl_record.h +++ b/sql/rpl_record.h @@ -17,15 +17,15 @@ #define RPL_RECORD_H #if !defined(MYSQL_CLIENT) -my_size_t pack_row(TABLE* table, MY_BITMAP const* cols, - byte *row_data, const byte *data); +size_t pack_row(TABLE* table, MY_BITMAP const* cols, + uchar *row_data, const uchar *data); #endif #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) int unpack_row(RELAY_LOG_INFO const *rli, TABLE *table, uint const colcnt, - char const *const row_data, MY_BITMAP const *cols, - char const **const row_end, ulong *const master_reclength, + uchar const *const row_data, MY_BITMAP const *cols, + uchar const **const row_end, ulong *const master_reclength, MY_BITMAP* const rw_set, Log_event_type const event_type); #endif diff --git a/sql/rpl_record_old.cc b/sql/rpl_record_old.cc index 73e2f4e7344..b6f170082fe 100644 --- a/sql/rpl_record_old.cc +++ b/sql/rpl_record_old.cc @@ -2,13 +2,13 @@ #include "mysql_priv.h" #include "rpl_record_old.h" -my_size_t +size_t pack_row_old(TABLE *table, MY_BITMAP const* cols, - byte *row_data, const byte *record) + uchar *row_data, const uchar *record) { Field **p_field= table->field, *field; int n_null_bytes= table->s->null_bytes; - byte *ptr; + uchar *ptr; uint i; my_ptrdiff_t const rec_offset= record - table->record[0]; my_ptrdiff_t const def_offset= table->s->default_values - table->record[0]; @@ -22,11 +22,11 @@ pack_row_old(TABLE *table, MY_BITMAP const* cols, my_ptrdiff_t const offset= field->is_null(rec_offset) ? def_offset : rec_offset; field->move_field_offset(offset); - ptr= (byte*)field->pack((char *) ptr, field->ptr); + ptr= field->pack(ptr, field->ptr); field->move_field_offset(-offset); } } - return (static_cast<my_size_t>(ptr - row_data)); + return (static_cast<size_t>(ptr - row_data)); } @@ -70,14 +70,14 @@ pack_row_old(TABLE *table, MY_BITMAP const* cols, #if !defined(MYSQL_CLIENT) && defined(HAVE_REPLICATION) int unpack_row_old(RELAY_LOG_INFO *rli, - TABLE *table, uint const colcnt, byte *record, - char const *row, MY_BITMAP const *cols, - char const **row_end, ulong *master_reclength, + TABLE *table, uint const colcnt, uchar *record, + uchar const *row, MY_BITMAP const *cols, + uchar const **row_end, ulong *master_reclength, MY_BITMAP* const rw_set, Log_event_type const event_type) { DBUG_ASSERT(record && row); - my_ptrdiff_t const offset= record - (byte*) table->record[0]; - my_size_t master_null_bytes= table->s->null_bytes; + my_ptrdiff_t const offset= record - (uchar*) table->record[0]; + size_t master_null_bytes= table->s->null_bytes; if (colcnt != table->s->fields) { @@ -108,7 +108,7 @@ unpack_row_old(RELAY_LOG_INFO *rli, Field **const begin_ptr = table->field; Field **field_ptr; - char const *ptr= row + master_null_bytes; + uchar const *ptr= row + master_null_bytes; Field **const end_ptr= begin_ptr + colcnt; for (field_ptr= begin_ptr ; field_ptr < end_ptr ; ++field_ptr) { @@ -130,7 +130,7 @@ unpack_row_old(RELAY_LOG_INFO *rli, if (master_reclength) { if (*field_ptr) - *master_reclength = (*field_ptr)->ptr - (char*) table->record[0]; + *master_reclength = (*field_ptr)->ptr - table->record[0]; else *master_reclength = table->s->reclength; } diff --git a/sql/rpl_record_old.h b/sql/rpl_record_old.h index 6ddb01de07c..6af61141d47 100644 --- a/sql/rpl_record_old.h +++ b/sql/rpl_record_old.h @@ -17,14 +17,14 @@ #define RPL_RECORD_OLD_H #ifndef MYSQL_CLIENT -my_size_t pack_row_old(TABLE *table, MY_BITMAP const* cols, - byte *row_data, const byte *record); +size_t pack_row_old(TABLE *table, MY_BITMAP const* cols, + uchar *row_data, const uchar *record); #ifdef HAVE_REPLICATION int unpack_row_old(RELAY_LOG_INFO *rli, - TABLE *table, uint const colcnt, byte *record, - char const *row, MY_BITMAP const *cols, - char const **row_end, ulong *master_reclength, + TABLE *table, uint const colcnt, uchar *record, + uchar const *row, MY_BITMAP const *cols, + uchar const **row_end, ulong *master_reclength, MY_BITMAP* const rw_set, Log_event_type const event_type); #endif diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index 702dec72f56..0c8f74bb35e 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -1078,7 +1078,8 @@ bool st_relay_log_info::cached_charset_compare(char *charset) const { DBUG_ENTER("st_relay_log_info::cached_charset_compare"); - if (bcmp(cached_charset, charset, sizeof(cached_charset))) + if (bcmp((uchar*) cached_charset, (uchar*) charset, + sizeof(cached_charset))) { memcpy(const_cast<char*>(cached_charset), charset, sizeof(cached_charset)); DBUG_RETURN(1); @@ -1168,7 +1169,7 @@ void st_relay_log_info::clear_tables_to_lock() { while (tables_to_lock) { - gptr to_free= reinterpret_cast<gptr>(tables_to_lock); + uchar* to_free= reinterpret_cast<uchar*>(tables_to_lock); if (tables_to_lock->m_tabledef_valid) { tables_to_lock->m_tabledef.table_def::~table_def(); diff --git a/sql/rpl_tblmap.cc b/sql/rpl_tblmap.cc index 7df4bcbdde7..6c8b494dfa9 100644 --- a/sql/rpl_tblmap.cc +++ b/sql/rpl_tblmap.cc @@ -104,11 +104,11 @@ int table_mapping::set_table(ulong table_id, TABLE* table) m_free= m_free->next; } else - hash_delete(&m_table_ids,(byte *)e); + hash_delete(&m_table_ids,(uchar *)e); e->table_id= table_id; e->table= table; - my_hash_insert(&m_table_ids,(byte *)e); + my_hash_insert(&m_table_ids,(uchar *)e); DBUG_PRINT("info", ("tid %lu -> table 0x%lx (%s)", table_id, (long) e->table, @@ -121,7 +121,7 @@ int table_mapping::remove_table(ulong table_id) entry *e= find_entry(table_id); if (e) { - hash_delete(&m_table_ids,(byte *)e); + hash_delete(&m_table_ids,(uchar *)e); /* we add this entry to the chain of free (free for use) entries */ e->next= m_free; m_free= e; diff --git a/sql/rpl_tblmap.h b/sql/rpl_tblmap.h index dbc968d0f67..446833d5ed6 100644 --- a/sql/rpl_tblmap.h +++ b/sql/rpl_tblmap.h @@ -85,7 +85,7 @@ private: entry *find_entry(ulong table_id) { return (entry *)hash_search(&m_table_ids, - (byte*)&table_id, + (uchar*)&table_id, sizeof(table_id)); } int expand(); diff --git a/sql/rpl_utility.cc b/sql/rpl_utility.cc index 1d7cc808f0c..dcbf85f5939 100644 --- a/sql/rpl_utility.cc +++ b/sql/rpl_utility.cc @@ -17,7 +17,7 @@ uint32 field_length_from_packed(enum_field_types const field_type, - byte const *const data) + uchar const *const data) { uint32 length; diff --git a/sql/rpl_utility.h b/sql/rpl_utility.h index 82992eec690..2ce8def4577 100644 --- a/sql/rpl_utility.h +++ b/sql/rpl_utility.h @@ -26,7 +26,7 @@ struct st_relay_log_info; typedef st_relay_log_info RELAY_LOG_INFO; uint32 -field_length_from_packed(enum_field_types field_type, byte const *data); +field_length_from_packed(enum_field_types field_type, uchar const *data); /** A table definition from the master. @@ -58,7 +58,7 @@ public: @param types Array of types @param size Number of elements in array 'types' */ - table_def(field_type *types, my_size_t size) + table_def(field_type *types, ulong size) : m_size(size), m_type(new unsigned char [size]) { if (m_type) @@ -81,7 +81,7 @@ public: @return The number of fields that there is type data for. */ - my_size_t size() const { return m_size; } + ulong size() const { return m_size; } /* @@ -93,10 +93,9 @@ public: <code>index</code>. Currently, only the type identifier is returned. */ - field_type type(my_ptrdiff_t index) const + field_type type(ulong index) const { - DBUG_ASSERT(0 <= index); - DBUG_ASSERT(static_cast<my_size_t>(index) < m_size); + DBUG_ASSERT(index < m_size); return m_type[index]; } @@ -120,7 +119,7 @@ public: int compatible_with(RELAY_LOG_INFO const *rli, TABLE *table) const; private: - my_size_t m_size; // Number of elements in the types array + ulong m_size; // Number of elements in the types array field_type *m_type; // Array of type descriptors }; diff --git a/sql/set_var.cc b/sql/set_var.cc index a6fd3ab1242..a057945d977 100644 --- a/sql/set_var.cc +++ b/sql/set_var.cc @@ -122,9 +122,9 @@ static void fix_trans_mem_root(THD *thd, enum_var_type type); static void fix_server_id(THD *thd, enum_var_type type); static KEY_CACHE *create_key_cache(const char *name, uint length); void fix_sql_mode_var(THD *thd, enum_var_type type); -static byte *get_error_count(THD *thd); -static byte *get_warning_count(THD *thd); -static byte *get_tmpdir(THD *thd); +static uchar *get_error_count(THD *thd); +static uchar *get_warning_count(THD *thd); +static uchar *get_tmpdir(THD *thd); static int sys_check_log_path(THD *thd, set_var *var); static bool sys_update_general_log_path(THD *thd, set_var * var); static void sys_default_general_log_path(THD *thd, enum_var_type type); @@ -788,7 +788,7 @@ static void sys_default_init_slave(THD* thd, enum_var_type type) static int sys_check_ftb_syntax(THD *thd, set_var *var) { if (thd->security_ctx->master_access & SUPER_ACL) - return (ft_boolean_check_syntax_string((byte*) + return (ft_boolean_check_syntax_string((uchar*) var->value->str_value.c_ptr()) ? -1 : 0); else @@ -1179,9 +1179,9 @@ bool sys_var_enum::update(THD *thd, set_var *var) } -byte *sys_var_enum::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) +uchar *sys_var_enum::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { - return (byte*) enum_names->type_names[*value]; + return (uchar*) enum_names->type_names[*value]; } bool sys_var_thd_ulong::check(THD *thd, set_var *var) @@ -1226,12 +1226,12 @@ void sys_var_thd_ulong::set_default(THD *thd, enum_var_type type) } -byte *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type, +uchar *sys_var_thd_ulong::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { if (type == OPT_GLOBAL) - return (byte*) &(global_system_variables.*offset); - return (byte*) &(thd->variables.*offset); + return (uchar*) &(global_system_variables.*offset); + return (uchar*) &(thd->variables.*offset); } @@ -1272,12 +1272,12 @@ void sys_var_thd_ha_rows::set_default(THD *thd, enum_var_type type) } -byte *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type, +uchar *sys_var_thd_ha_rows::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { if (type == OPT_GLOBAL) - return (byte*) &(global_system_variables.*offset); - return (byte*) &(thd->variables.*offset); + return (uchar*) &(global_system_variables.*offset); + return (uchar*) &(thd->variables.*offset); } bool sys_var_thd_ulonglong::update(THD *thd, set_var *var) @@ -1315,12 +1315,12 @@ void sys_var_thd_ulonglong::set_default(THD *thd, enum_var_type type) } -byte *sys_var_thd_ulonglong::value_ptr(THD *thd, enum_var_type type, +uchar *sys_var_thd_ulonglong::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { if (type == OPT_GLOBAL) - return (byte*) &(global_system_variables.*offset); - return (byte*) &(thd->variables.*offset); + return (uchar*) &(global_system_variables.*offset); + return (uchar*) &(thd->variables.*offset); } @@ -1343,12 +1343,12 @@ void sys_var_thd_bool::set_default(THD *thd, enum_var_type type) } -byte *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type, +uchar *sys_var_thd_bool::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { if (type == OPT_GLOBAL) - return (byte*) &(global_system_variables.*offset); - return (byte*) &(thd->variables.*offset); + return (uchar*) &(global_system_variables.*offset); + return (uchar*) &(thd->variables.*offset); } @@ -1538,13 +1538,13 @@ void sys_var_thd_enum::set_default(THD *thd, enum_var_type type) } -byte *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type, +uchar *sys_var_thd_enum::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { ulong tmp= ((type == OPT_GLOBAL) ? global_system_variables.*offset : thd->variables.*offset); - return (byte*) enum_names->type_names[tmp]; + return (uchar*) enum_names->type_names[tmp]; } bool sys_var_thd_bit::check(THD *thd, set_var *var) @@ -1560,7 +1560,7 @@ bool sys_var_thd_bit::update(THD *thd, set_var *var) } -byte *sys_var_thd_bit::value_ptr(THD *thd, enum_var_type type, +uchar *sys_var_thd_bit::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { /* @@ -1569,7 +1569,7 @@ byte *sys_var_thd_bit::value_ptr(THD *thd, enum_var_type type, */ thd->sys_var_tmp.my_bool_value= ((thd->options & bit_flag) ? !reverse : reverse); - return (byte*) &thd->sys_var_tmp.my_bool_value; + return (uchar*) &thd->sys_var_tmp.my_bool_value; } @@ -1580,7 +1580,7 @@ void sys_var_thd_date_time_format::update2(THD *thd, enum_var_type type, { DATE_TIME_FORMAT *old; DBUG_ENTER("sys_var_date_time_format::update2"); - DBUG_DUMP("positions",(char*) new_value->positions, + DBUG_DUMP("positions", (uchar*) new_value->positions, sizeof(new_value->positions)); if (type == OPT_GLOBAL) @@ -1660,7 +1660,7 @@ void sys_var_thd_date_time_format::set_default(THD *thd, enum_var_type type) } -byte *sys_var_thd_date_time_format::value_ptr(THD *thd, enum_var_type type, +uchar *sys_var_thd_date_time_format::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { if (type == OPT_GLOBAL) @@ -1673,9 +1673,9 @@ byte *sys_var_thd_date_time_format::value_ptr(THD *thd, enum_var_type type, */ res= thd->strmake((global_system_variables.*offset)->format.str, (global_system_variables.*offset)->format.length); - return (byte*) res; + return (uchar*) res; } - return (byte*) (thd->variables.*offset)->format.str; + return (uchar*) (thd->variables.*offset)->format.str; } @@ -1796,11 +1796,11 @@ bool sys_var_character_set::update(THD *thd, set_var *var) } -byte *sys_var_character_set::value_ptr(THD *thd, enum_var_type type, +uchar *sys_var_character_set::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { CHARSET_INFO *cs= ci_ptr(thd,type)[0]; - return cs ? (byte*) cs->csname : (byte*) NULL; + return cs ? (uchar*) cs->csname : (uchar*) NULL; } @@ -1870,11 +1870,12 @@ void sys_var_collation_sv::set_default(THD *thd, enum_var_type type) } -byte *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) +uchar *sys_var_collation_sv::value_ptr(THD *thd, enum_var_type type, + LEX_STRING *base) { CHARSET_INFO *cs= ((type == OPT_GLOBAL) ? - global_system_variables.*offset : thd->variables.*offset); - return cs ? (byte*) cs->name : (byte*) "NULL"; + global_system_variables.*offset : thd->variables.*offset); + return cs ? (uchar*) cs->name : (uchar*) "NULL"; } @@ -1892,13 +1893,13 @@ KEY_CACHE *get_key_cache(LEX_STRING *cache_name) } -byte *sys_var_key_cache_param::value_ptr(THD *thd, enum_var_type type, +uchar *sys_var_key_cache_param::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { KEY_CACHE *key_cache= get_key_cache(base); if (!key_cache) key_cache= &zero_key_cache; - return (byte*) key_cache + offset ; + return (uchar*) key_cache + offset ; } @@ -2084,11 +2085,12 @@ static int sys_check_log_path(THD *thd, set_var *var) } else { + size_t path_length; /* Check if directory exists and we have permission to create file & write to file */ - (void) dirname_part(path, var_path); + (void) dirname_part(path, var_path, &path_length); if (my_access(path, (F_OK|W_OK))) return -1; } @@ -2214,7 +2216,7 @@ void sys_var_log_output::set_default(THD *thd, enum_var_type type) } -byte *sys_var_log_output::value_ptr(THD *thd, enum_var_type type, +uchar *sys_var_log_output::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { char buff[256]; @@ -2235,7 +2237,7 @@ byte *sys_var_log_output::value_ptr(THD *thd, enum_var_type type, if ((length= tmp.length())) length--; - return (byte*) thd->strmake(tmp.ptr(), length); + return (uchar*) thd->strmake(tmp.ptr(), length); } @@ -2274,11 +2276,11 @@ void sys_var_timestamp::set_default(THD *thd, enum_var_type type) } -byte *sys_var_timestamp::value_ptr(THD *thd, enum_var_type type, +uchar *sys_var_timestamp::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { thd->sys_var_tmp.long_value= (long) thd->start_time; - return (byte*) &thd->sys_var_tmp.long_value; + return (uchar*) &thd->sys_var_tmp.long_value; } @@ -2290,7 +2292,7 @@ bool sys_var_last_insert_id::update(THD *thd, set_var *var) } -byte *sys_var_last_insert_id::value_ptr(THD *thd, enum_var_type type, +uchar *sys_var_last_insert_id::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { /* @@ -2299,7 +2301,7 @@ byte *sys_var_last_insert_id::value_ptr(THD *thd, enum_var_type type, */ thd->sys_var_tmp.ulonglong_value= thd->read_first_successful_insert_id_in_prev_stmt(); - return (byte*) &thd->sys_var_tmp.ulonglong_value; + return (uchar*) &thd->sys_var_tmp.ulonglong_value; } @@ -2310,12 +2312,12 @@ bool sys_var_insert_id::update(THD *thd, set_var *var) } -byte *sys_var_insert_id::value_ptr(THD *thd, enum_var_type type, +uchar *sys_var_insert_id::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { thd->sys_var_tmp.ulonglong_value= thd->auto_inc_intervals_forced.minimum(); - return (byte*) &thd->sys_var_tmp.ulonglong_value; + return (uchar*) &thd->sys_var_tmp.ulonglong_value; } @@ -2362,7 +2364,7 @@ bool sys_var_thd_time_zone::update(THD *thd, set_var *var) } -byte *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type, +uchar *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { /* @@ -2370,7 +2372,7 @@ byte *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type, time zone name is guaranteed to be zero ended. */ if (type == OPT_GLOBAL) - return (byte *)(global_system_variables.time_zone->get_name()->ptr()); + return (uchar *)(global_system_variables.time_zone->get_name()->ptr()); else { /* @@ -2382,7 +2384,7 @@ byte *sys_var_thd_time_zone::value_ptr(THD *thd, enum_var_type type, (binlog code stores session value only). */ thd->time_zone_used= 1; - return (byte *)(thd->variables.time_zone->get_name()->ptr()); + return (uchar *)(thd->variables.time_zone->get_name()->ptr()); } } @@ -2444,13 +2446,13 @@ void sys_var_max_user_conn::set_default(THD *thd, enum_var_type type) } -byte *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type, +uchar *sys_var_max_user_conn::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { if (type != OPT_GLOBAL && thd->user_connect && thd->user_connect->user_resources.user_conn) - return (byte*) &(thd->user_connect->user_resources.user_conn); - return (byte*) &(max_user_connections); + return (uchar*) &(thd->user_connect->user_resources.user_conn); + return (uchar*) &(max_user_connections); } @@ -2501,12 +2503,12 @@ bool sys_var_thd_lc_time_names::update(THD *thd, set_var *var) } -byte *sys_var_thd_lc_time_names::value_ptr(THD *thd, enum_var_type type, +uchar *sys_var_thd_lc_time_names::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { return type == OPT_GLOBAL ? - (byte *) global_system_variables.lc_time_names->name : - (byte *) thd->variables.lc_time_names->name; + (uchar *) global_system_variables.lc_time_names->name : + (uchar *) thd->variables.lc_time_names->name; } @@ -2615,20 +2617,20 @@ static int check_pseudo_thread_id(THD *thd, set_var *var) #endif } -static byte *get_warning_count(THD *thd) +static uchar *get_warning_count(THD *thd) { thd->sys_var_tmp.long_value= (thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_NOTE] + thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR] + thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_WARN]); - return (byte*) &thd->sys_var_tmp.long_value; + return (uchar*) &thd->sys_var_tmp.long_value; } -static byte *get_error_count(THD *thd) +static uchar *get_error_count(THD *thd) { thd->sys_var_tmp.long_value= thd->warn_count[(uint) MYSQL_ERROR::WARN_LEVEL_ERROR]; - return (byte*) &thd->sys_var_tmp.long_value; + return (uchar*) &thd->sys_var_tmp.long_value; } @@ -2649,11 +2651,11 @@ static byte *get_error_count(THD *thd) RETURN VALUES ptr pointer to NUL-terminated string */ -static byte *get_tmpdir(THD *thd) +static uchar *get_tmpdir(THD *thd) { if (opt_mysql_tmpdir) - return (byte *)opt_mysql_tmpdir; - return (byte*)mysql_tmpdir; + return (uchar *)opt_mysql_tmpdir; + return (uchar*)mysql_tmpdir; } /**************************************************************************** @@ -2699,11 +2701,11 @@ static struct my_option *find_option(struct my_option *opt, const char *name) Return variable name and length for hashing of variables */ -static byte *get_sys_var_length(const sys_var *var, uint *length, - my_bool first) +static uchar *get_sys_var_length(const sys_var *var, size_t *length, + my_bool first) { *length= var->name_length; - return (byte*) var->name; + return (uchar*) var->name; } @@ -2720,6 +2722,7 @@ static byte *get_sys_var_length(const sys_var *var, uint *length, otherwise FAILURE */ + int mysql_add_sys_var_chain(sys_var *first, struct my_option *long_options) { sys_var *var; @@ -2730,7 +2733,7 @@ int mysql_add_sys_var_chain(sys_var *first, struct my_option *long_options) { var->name_length= strlen(var->name); /* this fails if there is a conflicting variable name. see HASH_UNIQUE */ - if (my_hash_insert(&system_variable_hash, (byte*) var)) + if (my_hash_insert(&system_variable_hash, (uchar*) var)) goto error; if (long_options) var->option_limits= find_option(long_options, var->name); @@ -2739,42 +2742,42 @@ int mysql_add_sys_var_chain(sys_var *first, struct my_option *long_options) error: for (; first != var; first= first->next) - hash_delete(&system_variable_hash, (byte*) first); + hash_delete(&system_variable_hash, (uchar*) first); return 1; } - - + + /* Remove variables to the dynamic hash of system variables - + SYNOPSIS mysql_del_sys_var_chain() first Pointer to first system variable to remove - + RETURN VALUES 0 SUCCESS otherwise FAILURE */ - + int mysql_del_sys_var_chain(sys_var *first) { int result= 0; - + /* A write lock should be held on LOCK_system_variables_hash */ - + for (sys_var *var= first; var; var= var->next) - result|= hash_delete(&system_variable_hash, (byte*) var); + result|= hash_delete(&system_variable_hash, (uchar*) var); return result; } - - + + static int show_cmp(SHOW_VAR *a, SHOW_VAR *b) { return strcmp(a->name, b->name); } - - + + /* Constructs an array of system variables for display to the user. @@ -2891,7 +2894,7 @@ void set_var_free() int mysql_append_static_vars(const SHOW_VAR *show_vars, uint count) { for (; count > 0; count--, show_vars++) - if (insert_dynamic(&fixed_show_vars, (char*) show_vars)) + if (insert_dynamic(&fixed_show_vars, (uchar*) show_vars)) return 1; return 0; } @@ -2920,7 +2923,7 @@ sys_var *intern_find_sys_var(const char *str, uint length, bool no_error) A lock on LOCK_system_variable_hash should be held */ var= (sys_var*) hash_search(&system_variable_hash, - (byte*) str, length ? length : strlen(str)); + (uchar*) str, length ? length : strlen(str)); if (!(var || no_error)) my_error(ER_UNKNOWN_SYSTEM_VARIABLE, MYF(0), (char*) str); @@ -3213,10 +3216,10 @@ err: } -byte *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type, +uchar *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { - byte* result; + uchar* result; handlerton *hton; LEX_STRING *name; plugin_ref plugin= thd->variables.*offset; @@ -3224,7 +3227,7 @@ byte *sys_var_thd_storage_engine::value_ptr(THD *thd, enum_var_type type, plugin= my_plugin_lock(thd, &(global_system_variables.*offset)); hton= plugin_data(plugin, handlerton*); name= &hton2plugin[hton->slot]->name; - result= (byte *) thd->strmake(name->str, name->length); + result= (uchar *) thd->strmake(name->str, name->length); if (type == OPT_GLOBAL) plugin_unlock(thd, plugin); return result; @@ -3326,14 +3329,14 @@ symbolic_mode_representation(THD *thd, ulonglong val, LEX_STRING *rep) } -byte *sys_var_thd_sql_mode::value_ptr(THD *thd, enum_var_type type, +uchar *sys_var_thd_sql_mode::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { LEX_STRING sql_mode; ulonglong val= ((type == OPT_GLOBAL) ? global_system_variables.*offset : thd->variables.*offset); (void) symbolic_mode_representation(thd, val, &sql_mode); - return (byte *) sql_mode.str; + return (uchar *) sql_mode.str; } @@ -3424,7 +3427,7 @@ ulong fix_sql_mode(ulong sql_mode) Named list handling ****************************************************************************/ -gptr find_named(I_List<NAMED_LIST> *list, const char *name, uint length, +uchar* find_named(I_List<NAMED_LIST> *list, const char *name, uint length, NAMED_LIST **found) { I_List_iterator<NAMED_LIST> it(*list); @@ -3443,7 +3446,7 @@ gptr find_named(I_List<NAMED_LIST> *list, const char *name, uint length, void delete_elements(I_List<NAMED_LIST> *list, - void (*free_element)(const char *name, gptr)) + void (*free_element)(const char *name, uchar*)) { NAMED_LIST *element; DBUG_ENTER("delete_elements"); @@ -3467,7 +3470,7 @@ static KEY_CACHE *create_key_cache(const char *name, uint length) if ((key_cache= (KEY_CACHE*) my_malloc(sizeof(KEY_CACHE), MYF(MY_ZEROFILL | MY_WME)))) { - if (!new NAMED_LIST(&key_caches, name, length, (gptr) key_cache)) + if (!new NAMED_LIST(&key_caches, name, length, (uchar*) key_cache)) { my_free((char*) key_cache, MYF(0)); key_cache= 0; @@ -3626,14 +3629,14 @@ bool sys_var_thd_dbug::update(THD *thd, set_var *var) } -byte *sys_var_thd_dbug::value_ptr(THD *thd, enum_var_type type, LEX_STRING *b) +uchar *sys_var_thd_dbug::value_ptr(THD *thd, enum_var_type type, LEX_STRING *b) { char buf[256]; if (type == OPT_GLOBAL) DBUG_EXPLAIN_INITIAL(buf, sizeof(buf)); else DBUG_EXPLAIN(buf, sizeof(buf)); - return (byte*) thd->strdup(buf); + return (uchar*) thd->strdup(buf); } @@ -3676,10 +3679,10 @@ sys_var_event_scheduler::update(THD *thd, set_var *var) } -byte *sys_var_event_scheduler::value_ptr(THD *thd, enum_var_type type, +uchar *sys_var_event_scheduler::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { - return (byte *) Events::get_opt_event_scheduler_str(); + return (uchar *) Events::get_opt_event_scheduler_str(); } diff --git a/sql/set_var.h b/sql/set_var.h index 5556e9c9587..a998dc93b84 100644 --- a/sql/set_var.h +++ b/sql/set_var.h @@ -36,7 +36,7 @@ typedef int (*sys_check_func)(THD *, set_var *); typedef bool (*sys_update_func)(THD *, set_var *); typedef void (*sys_after_update_func)(THD *,enum_var_type); typedef void (*sys_set_default_func)(THD *, enum_var_type); -typedef byte *(*sys_value_ptr_func)(THD *thd); +typedef uchar *(*sys_value_ptr_func)(THD *thd); struct sys_var_chain { @@ -73,7 +73,7 @@ public: virtual bool update(THD *thd, set_var *var)=0; virtual void set_default(THD *thd_arg, enum_var_type type) {} virtual SHOW_TYPE show_type() { return SHOW_UNDEF; } - virtual byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) + virtual uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { return 0; } virtual bool check_type(enum_var_type type) { return type != OPT_GLOBAL; } /* Error if not GLOBAL */ @@ -123,8 +123,8 @@ public: bool update(THD *thd, set_var *var); void set_default(THD *thd, enum_var_type type); SHOW_TYPE show_type() { return SHOW_LONG; } - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) - { return (byte*) value; } + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) + { return (uchar*) value; } }; @@ -154,8 +154,8 @@ public: bool update(THD *thd, set_var *var); void set_default(THD *thd, enum_var_type type); SHOW_TYPE show_type() { return SHOW_LONGLONG; } - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) - { return (byte*) value; } + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) + { return (uchar*) value; } }; @@ -173,8 +173,8 @@ public: bool update(THD *thd, set_var *var); void set_default(THD *thd, enum_var_type type); SHOW_TYPE show_type() { return SHOW_MY_BOOL; } - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) - { return (byte*) value; } + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) + { return (uchar*) value; } bool check_update_type(Item_result type) { return 0; } }; @@ -216,8 +216,8 @@ public: (*set_default_func)(thd, type); } SHOW_TYPE show_type() { return SHOW_CHAR; } - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) - { return (byte*) value; } + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) + { return (uchar*) value; } bool check_update_type(Item_result type) { return type != STRING_RESULT; /* Only accept strings */ @@ -242,9 +242,9 @@ public: return 1; } SHOW_TYPE show_type() { return SHOW_CHAR; } - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { - return (byte*) value; + return (uchar*) value; } bool check_update_type(Item_result type) { @@ -271,9 +271,9 @@ public: return 1; } SHOW_TYPE show_type() { return SHOW_CHAR; } - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { - return (byte*) *value; + return (uchar*) *value; } bool check_update_type(Item_result type) { @@ -299,7 +299,7 @@ public: } bool update(THD *thd, set_var *var); SHOW_TYPE show_type() { return SHOW_CHAR; } - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); bool check_update_type(Item_result type) { return 0; } }; @@ -335,7 +335,7 @@ public: bool update(THD *thd, set_var *var); void set_default(THD *thd, enum_var_type type); SHOW_TYPE show_type() { return SHOW_LONG; } - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); }; @@ -355,7 +355,7 @@ public: bool update(THD *thd, set_var *var); void set_default(THD *thd, enum_var_type type); SHOW_TYPE show_type() { return SHOW_HA_ROWS; } - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); }; @@ -377,7 +377,7 @@ public: bool update(THD *thd, set_var *var); void set_default(THD *thd, enum_var_type type); SHOW_TYPE show_type() { return SHOW_LONGLONG; } - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); bool check_default(enum_var_type type) { return type == OPT_GLOBAL && !option_limits; @@ -403,7 +403,7 @@ public: bool update(THD *thd, set_var *var); void set_default(THD *thd, enum_var_type type); SHOW_TYPE show_type() { return SHOW_MY_BOOL; } - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); bool check(THD *thd, set_var *var) { return check_enum(thd, var, &bool_typelib); @@ -446,7 +446,7 @@ public: bool update(THD *thd, set_var *var); void set_default(THD *thd, enum_var_type type); SHOW_TYPE show_type() { return SHOW_CHAR; } - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); bool check_update_type(Item_result type) { return 0; } }; @@ -466,7 +466,7 @@ public: return check_set(thd, var, enum_names); } void set_default(THD *thd, enum_var_type type); - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); static bool symbolic_mode_representation(THD *thd, ulonglong sql_mode, LEX_STRING *rep); }; @@ -489,7 +489,7 @@ public: } void set_default(THD *thd, enum_var_type type); bool update(THD *thd, set_var *var); - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); }; class sys_var_thd_table_type :public sys_var_thd_storage_engine @@ -522,7 +522,7 @@ public: bool check_update_type(Item_result type) { return 0; } bool check_type(enum_var_type type) { return type == OPT_GLOBAL; } SHOW_TYPE show_type() { return SHOW_MY_BOOL; } - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); }; class sys_var_thd_dbug :public sys_var_thd @@ -536,7 +536,7 @@ public: SHOW_TYPE show_type() { return SHOW_CHAR; } bool update(THD *thd, set_var *var); void set_default(THD *thd, enum_var_type type) { DBUG_POP(); } - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *b); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *b); }; @@ -554,7 +554,7 @@ public: bool check_type(enum_var_type type) { return type == OPT_GLOBAL; } bool check_default(enum_var_type type) { return 0; } SHOW_TYPE show_type() { return SHOW_LONG; } - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); }; @@ -567,7 +567,7 @@ public: bool update(THD *thd, set_var *var); bool check_type(enum_var_type type) { return type == OPT_GLOBAL; } SHOW_TYPE show_type() { return SHOW_LONGLONG; } - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); }; @@ -580,7 +580,7 @@ public: bool update(THD *thd, set_var *var); bool check_type(enum_var_type type) { return type == OPT_GLOBAL; } SHOW_TYPE show_type() { return SHOW_LONGLONG; } - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); }; @@ -644,23 +644,22 @@ public: } bool check_default(enum_var_type type) { return 0; } bool update(THD *thd, set_var *var); - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); virtual void set_default(THD *thd, enum_var_type type)= 0; virtual CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type)= 0; }; - class sys_var_character_set_sv :public sys_var_character_set { CHARSET_INFO *SV::*offset; CHARSET_INFO **global_default; public: sys_var_character_set_sv(sys_var_chain *chain, const char *name_arg, - CHARSET_INFO *SV::*offset_arg, - CHARSET_INFO **global_default_arg, - bool is_nullable= 0) + CHARSET_INFO *SV::*offset_arg, + CHARSET_INFO **global_default_arg, + bool is_nullable= 0) : sys_var_character_set(name_arg, is_nullable), - offset(offset_arg), global_default(global_default_arg) + offset(offset_arg), global_default(global_default_arg) { chain_sys_var(chain); } void set_default(THD *thd, enum_var_type type); CHARSET_INFO **ci_ptr(THD *thd, enum_var_type type); @@ -683,16 +682,16 @@ class sys_var_collation_sv :public sys_var_collation CHARSET_INFO **global_default; public: sys_var_collation_sv(sys_var_chain *chain, const char *name_arg, - CHARSET_INFO *SV::*offset_arg, - CHARSET_INFO **global_default_arg) + CHARSET_INFO *SV::*offset_arg, + CHARSET_INFO **global_default_arg) :sys_var_collation(name_arg), - offset(offset_arg), global_default(global_default_arg) + offset(offset_arg), global_default(global_default_arg) { chain_sys_var(chain); } bool update(THD *thd, set_var *var); void set_default(THD *thd, enum_var_type type); - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); }; @@ -705,7 +704,7 @@ public: size_t offset_arg) :sys_var(name_arg), offset(offset_arg) { chain_sys_var(chain); } - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); bool check_default(enum_var_type type) { return 1; } bool is_struct() { return 1; } }; @@ -754,7 +753,7 @@ public: bool check(THD *thd, set_var *var); bool update(THD *thd, set_var *var); void update2(THD *thd, enum_var_type type, DATE_TIME_FORMAT *new_value); - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); void set_default(THD *thd, enum_var_type type); }; @@ -785,7 +784,7 @@ public: return check_set(thd, var, enum_names); } bool update(THD *thd, set_var *var); - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); bool check_update_type(Item_result type) { return 0; } void set_default(THD *thd, enum_var_type type); SHOW_TYPE show_type() { return SHOW_CHAR; } @@ -810,7 +809,7 @@ public: bool check_default(enum_var_type type) { return 1; } bool check_type(enum_var_type type) { return type != var_type; } bool check_update_type(Item_result type) { return 1; } - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { return (*value_ptr_func)(thd); } @@ -827,9 +826,9 @@ public: sys_var_have_option(sys_var_chain *chain, const char *variable_name): sys_var(variable_name) { chain_sys_var(chain); } - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { - return (byte*) show_comp_option_name[get_option()]; + return (uchar*) show_comp_option_name[get_option()]; } bool update(THD *thd, set_var *var) { return 1; } bool check_default(enum_var_type type) { return 1; } @@ -890,7 +889,7 @@ public: } bool check_default(enum_var_type type) { return 0; } bool update(THD *thd, set_var *var); - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); virtual void set_default(THD *thd, enum_var_type type); }; @@ -909,15 +908,15 @@ public: } void set_default(THD *thd, enum_var_type type); SHOW_TYPE show_type() { return SHOW_INT; } - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); }; class sys_var_trust_routine_creators :public sys_var_bool_ptr { /* We need a derived class only to have a warn_deprecated() */ public: - sys_var_trust_routine_creators(sys_var_chain *chain, const char *name_arg, - my_bool *value_arg) : + sys_var_trust_routine_creators(sys_var_chain *chain, + const char *name_arg, my_bool *value_arg) : sys_var_bool_ptr(chain, name_arg, value_arg) {}; void warn_deprecated(THD *thd); void set_default(THD *thd, enum_var_type type); @@ -959,7 +958,7 @@ public: } bool check_default(enum_var_type type) { return 0; } bool update(THD *thd, set_var *var); - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); virtual void set_default(THD *thd, enum_var_type type); }; @@ -971,7 +970,7 @@ public: sys_var_event_scheduler(sys_var_chain *chain, const char *name_arg) : sys_var_long_ptr(chain, name_arg, NULL, NULL) {}; bool update(THD *thd, set_var *var); - byte *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar *value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); SHOW_TYPE show_type() { return SHOW_CHAR; } bool check(THD *thd, set_var *var); bool check_update_type(Item_result type) @@ -1114,10 +1113,10 @@ class NAMED_LIST :public ilink const char *name; uint name_length; public: - gptr data; + uchar* data; NAMED_LIST(I_List<NAMED_LIST> *links, const char *name_arg, - uint name_length_arg, gptr data_arg) + uint name_length_arg, uchar* data_arg) :name_length(name_length_arg), data(data_arg) { name= my_strndup(name_arg, name_length, MYF(MY_WME)); @@ -1129,12 +1128,12 @@ public: } ~NAMED_LIST() { - my_free((char*) name, MYF(0)); + my_free((uchar*) name, MYF(0)); } friend bool process_key_caches(int (* func) (const char *name, KEY_CACHE *)); friend void delete_elements(I_List<NAMED_LIST> *list, - void (*free_element)(const char*, gptr)); + void (*free_element)(const char*, uchar*)); }; /* updated in sql_acl.cc */ @@ -1171,7 +1170,7 @@ extern sys_var_str sys_init_slave; extern sys_var_thd_time_zone sys_time_zone; extern sys_var_thd_bit sys_autocommit; CHARSET_INFO *get_old_charset_by_name(const char *old_name); -gptr find_named(I_List<NAMED_LIST> *list, const char *name, uint length, +uchar* find_named(I_List<NAMED_LIST> *list, const char *name, uint length, NAMED_LIST **found); extern sys_var_str sys_var_general_log_path, sys_var_slow_log_path; @@ -1182,4 +1181,4 @@ KEY_CACHE *get_or_create_key_cache(const char *name, uint length); void free_key_cache(const char *name, KEY_CACHE *key_cache); bool process_key_caches(int (* func) (const char *name, KEY_CACHE *)); void delete_elements(I_List<NAMED_LIST> *list, - void (*free_element)(const char*, gptr)); + void (*free_element)(const char*, uchar*)); diff --git a/sql/slave.cc b/sql/slave.cc index f89a56e2087..aa42bad3265 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -450,7 +450,7 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start, #ifdef NOT_USED_YET -static int end_slave_on_walk(MASTER_INFO* mi, gptr /*unused*/) +static int end_slave_on_walk(MASTER_INFO* mi, uchar* /*unused*/) { DBUG_ENTER("end_slave_on_walk"); @@ -601,9 +601,9 @@ void slave_print_msg(enum loglevel level, RELAY_LOG_INFO const *rli, my_vsnprintf(pbuff, pbuffsize, msg, args); /* If the msg string ends with '.', do not add a ',' it would be ugly */ if (pbuff[0] && (*(strend(pbuff)-1) == '.')) - (*report_function)("Slave: %s Error_code: %d", pbuff, err_code); + (*report_function)("Slave: %s Error_code: %d", pbuff, err_code); else - (*report_function)("Slave: %s, Error_code: %d", pbuff, err_code); + (*report_function)("Slave: %s. Error_code: %d", pbuff, err_code); DBUG_VOID_RETURN; } @@ -620,7 +620,7 @@ void skip_load_data_infile(NET *net) (void)net_request_file(net, "/dev/null"); (void)my_net_read(net); // discard response - (void)net_write_command(net, 0, "", 0, "", 0); // Send ok + (void)net_write_command(net, 0, (uchar*) "", 0, (uchar*) "", 0); // ok DBUG_VOID_RETURN; } @@ -628,7 +628,8 @@ void skip_load_data_infile(NET *net) bool net_request_file(NET* net, const char* fname) { DBUG_ENTER("net_request_file"); - DBUG_RETURN(net_write_command(net, 251, fname, strlen(fname), "", 0)); + DBUG_RETURN(net_write_command(net, 251, (uchar*) fname, strlen(fname), + (uchar*) "", 0)); } /* @@ -1158,7 +1159,7 @@ static void write_ignored_events_info_to_relay_log(THD *thd, MASTER_INFO *mi) int register_slave_on_master(MYSQL* mysql) { - char buf[1024], *pos= buf; + uchar buf[1024], *pos= buf; uint report_host_len, report_user_len=0, report_password_len=0; DBUG_ENTER("register_slave_on_master"); @@ -1175,16 +1176,15 @@ int register_slave_on_master(MYSQL* mysql) DBUG_RETURN(0); // safety int4store(pos, server_id); pos+= 4; - pos= net_store_data(pos, report_host, report_host_len); - pos= net_store_data(pos, report_user, report_user_len); - pos= net_store_data(pos, report_password, report_password_len); + pos= net_store_data(pos, (uchar*) report_host, report_host_len); + pos= net_store_data(pos, (uchar*) report_user, report_user_len); + pos= net_store_data(pos, (uchar*) report_password, report_password_len); int2store(pos, (uint16) report_port); pos+= 2; int4store(pos, rpl_recovery_rank); pos+= 4; /* The master will fill in master_id */ int4store(pos, 0); pos+= 4; - if (simple_command(mysql, COM_REGISTER_SLAVE, (char*) buf, - (uint) (pos- buf), 0)) + if (simple_command(mysql, COM_REGISTER_SLAVE, buf, (size_t) (pos- buf), 0)) { sql_print_error("Error on COM_REGISTER_SLAVE: %d '%s'", mysql_errno(mysql), @@ -1371,7 +1371,7 @@ bool show_master_info(THD* thd, MASTER_INFO* mi) pthread_mutex_unlock(&mi->rli.data_lock); pthread_mutex_unlock(&mi->data_lock); - if (my_net_write(&thd->net, (char*)thd->packet.ptr(), packet->length())) + if (my_net_write(&thd->net, (uchar*) thd->packet.ptr(), packet->length())) DBUG_RETURN(TRUE); } send_eof(thd); @@ -1499,7 +1499,7 @@ static int safe_sleep(THD* thd, int sec, CHECK_KILLED_FUNC thread_killed, static int request_dump(MYSQL* mysql, MASTER_INFO* mi, bool *suppress_warnings) { - char buf[FN_REFLEN + 10]; + uchar buf[FN_REFLEN + 10]; int len; int binlog_flags = 0; // for now char* logname = mi->master_log_name; @@ -1533,10 +1533,9 @@ static int request_dump(MYSQL* mysql, MASTER_INFO* mi, static int request_table_dump(MYSQL* mysql, const char* db, const char* table) { - char buf[1024]; + uchar buf[1024], *p = buf; DBUG_ENTER("request_table_dump"); - char * p = buf; uint table_len = (uint) strlen(table); uint db_len = (uint) strlen(db); if (table_len + db_len > sizeof(buf) - 2) @@ -2581,7 +2580,8 @@ static int process_io_create_file(MASTER_INFO* mi, Create_file_log_event* cev) } if (unlikely(!num_bytes)) /* eof */ { - net_write_command(net, 0, "", 0, "", 0);/* 3.23 master wants it */ + /* 3.23 master wants it */ + net_write_command(net, 0, (uchar*) "", 0, (uchar*) "", 0); /* If we wrote Create_file_log_event, then we need to write Execute_load_log_event. If we did not write Create_file_log_event, @@ -3296,7 +3296,7 @@ bool flush_relay_log_info(RELAY_LOG_INFO* rli) *pos++='\n'; pos=longlong2str(rli->group_master_log_pos, pos, 10); *pos='\n'; - if (my_b_write(file, (byte*) buff, (ulong) (pos-buff)+1)) + if (my_b_write(file, (uchar*) buff, (size_t) (pos-buff)+1)) error=1; if (flush_io_cache(file)) error=1; diff --git a/sql/slave.h b/sql/slave.h index cb880c8125d..57806e65af7 100644 --- a/sql/slave.h +++ b/sql/slave.h @@ -94,9 +94,9 @@ class MASTER_INFO; extern ulong master_retry_count; extern MY_BITMAP slave_error_mask; extern bool use_slave_mask; -extern char* slave_load_tmpdir; -extern my_string master_info_file,relay_log_info_file; -extern my_string opt_relay_logname, opt_relaylog_index_name; +extern char *slave_load_tmpdir; +extern char *master_info_file, *relay_log_info_file; +extern char *opt_relay_logname, *opt_relaylog_index_name; extern my_bool opt_skip_slave_start, opt_reckless_slave; extern my_bool opt_log_slave_updates; extern ulonglong relay_log_space_limit; @@ -201,13 +201,13 @@ extern int disconnect_slave_event_count, abort_slave_event_count ; /* the master variables are defaults read from my.cnf or command line */ extern uint master_port, master_connect_retry, report_port; -extern my_string master_user, master_password, master_host, - master_info_file, relay_log_info_file, report_user, report_host, - report_password; +extern char * master_user, *master_password, *master_host; +extern char *master_info_file, *relay_log_info_file, *report_user; +extern char *report_host, *report_password; extern my_bool master_ssl; -extern my_string master_ssl_ca, master_ssl_capath, master_ssl_cert, - master_ssl_cipher, master_ssl_key; +extern char *master_ssl_ca, *master_ssl_capath, *master_ssl_cert; +extern char *master_ssl_cipher, *master_ssl_key; extern I_List<THD> threads; diff --git a/sql/sp.cc b/sql/sp.cc index 9ce245785d7..a73569fdcd9 100644 --- a/sql/sp.cc +++ b/sql/sp.cc @@ -147,10 +147,10 @@ static TABLE *open_proc_table_for_update(THD *thd) static int db_find_routine_aux(THD *thd, int type, sp_name *name, TABLE *table) { - byte key[MAX_KEY_LENGTH]; // db, name, optional key length type + uchar key[MAX_KEY_LENGTH]; // db, name, optional key length type DBUG_ENTER("db_find_routine_aux"); - DBUG_PRINT("enter", ("type: %d name: %.*s", - type, name->m_name.length, name->m_name.str)); + DBUG_PRINT("enter", ("type: %d name: %.*s", + type, (int) name->m_name.length, name->m_name.str)); /* Create key to find row. We have to use field->store() to be able to @@ -215,7 +215,7 @@ db_find_routine(THD *thd, int type, sp_name *name, sp_head **sphp) Open_tables_state open_tables_state_backup; DBUG_ENTER("db_find_routine"); DBUG_PRINT("enter", ("type: %d name: %.*s", - type, name->m_name.length, name->m_name.str)); + type, (int) name->m_name.length, name->m_name.str)); *sphp= 0; // In case of errors if (!(table= open_proc_table_for_read(thd, &open_tables_state_backup))) @@ -466,7 +466,7 @@ sp_create_routine(THD *thd, int type, sp_head *sp) char definer[USER_HOST_BUFF_SIZE]; DBUG_ENTER("sp_create_routine"); - DBUG_PRINT("enter", ("type: %d name: %.*s",type,sp->m_name.length, + DBUG_PRINT("enter", ("type: %d name: %.*s",type, (int) sp->m_name.length, sp->m_name.str)); DBUG_ASSERT(type == TYPE_ENUM_PROCEDURE || @@ -627,8 +627,8 @@ sp_drop_routine(THD *thd, int type, sp_name *name) TABLE *table; int ret; DBUG_ENTER("sp_drop_routine"); - DBUG_PRINT("enter", ("type: %d name: %.*s", - type, name->m_name.length, name->m_name.str)); + DBUG_PRINT("enter", ("type: %d name: %.*s", + type, (int) name->m_name.length, name->m_name.str)); DBUG_ASSERT(type == TYPE_ENUM_PROCEDURE || type == TYPE_ENUM_FUNCTION); @@ -688,15 +688,14 @@ sp_update_routine(THD *thd, int type, sp_name *name, st_sp_chistics *chistics) TABLE *table; int ret; DBUG_ENTER("sp_update_routine"); - DBUG_PRINT("enter", ("type: %d name: %.*s", - type, name->m_name.length, name->m_name.str)); - + DBUG_PRINT("enter", ("type: %d name: %.*s", + type, (int) name->m_name.length, name->m_name.str)); DBUG_ASSERT(type == TYPE_ENUM_PROCEDURE || type == TYPE_ENUM_FUNCTION); /* This statement will be replicated as a statement, even when using - row-based replication. The flag will be reset at the end of the + row-based replication. The flag will be reset at the end of the statement. */ thd->clear_current_stmt_binlog_row_based(); @@ -960,7 +959,7 @@ sp_drop_db_routines(THD *thd, char *db) ret= SP_OK; table->file->ha_index_init(0, 1); if (! table->file->index_read(table->record[0], - (byte *)table->field[MYSQL_PROC_FIELD_DB]->ptr, + (uchar *)table->field[MYSQL_PROC_FIELD_DB]->ptr, (key_part_map)1, HA_READ_KEY_EXACT)) { int nxtres; @@ -977,7 +976,7 @@ sp_drop_db_routines(THD *thd, char *db) break; } } while (! (nxtres= table->file->index_next_same(table->record[0], - (byte *)table->field[MYSQL_PROC_FIELD_DB]->ptr, + (uchar *)table->field[MYSQL_PROC_FIELD_DB]->ptr, key_len))); if (nxtres != HA_ERR_END_OF_FILE) ret= SP_KEY_NOT_FOUND; @@ -1075,9 +1074,9 @@ sp_find_routine(THD *thd, int type, sp_name *name, sp_cache **cp, thd->variables.max_sp_recursion_depth : 0); DBUG_ENTER("sp_find_routine"); - DBUG_PRINT("enter", ("name: %.*s.%.*s, type: %d, cache only %d", - name->m_db.length, name->m_db.str, - name->m_name.length, name->m_name.str, + DBUG_PRINT("enter", ("name: %.*s.%.*s type: %d cache only %d", + (int) name->m_db.length, name->m_db.str, + (int) name->m_name.length, name->m_name.str, type, cache_only)); if ((sp= sp_cache_lookup(cp, name))) @@ -1264,11 +1263,12 @@ struct Sroutine_hash_entry }; -extern "C" byte* sp_sroutine_key(const byte *ptr, uint *plen, my_bool first) +extern "C" uchar* sp_sroutine_key(const uchar *ptr, size_t *plen, + my_bool first) { Sroutine_hash_entry *rn= (Sroutine_hash_entry *)ptr; *plen= rn->key.length; - return (byte *)rn->key.str; + return (uchar *)rn->key.str; } @@ -1349,7 +1349,7 @@ static bool add_used_routine(LEX *lex, Query_arena *arena, Query_tables_list::START_SROUTINES_HASH_SIZE, 0, 0, sp_sroutine_key, 0, 0); - if (!hash_search(&lex->sroutines, (byte *)key->str, key->length)) + if (!hash_search(&lex->sroutines, (uchar *)key->str, key->length)) { Sroutine_hash_entry *rn= (Sroutine_hash_entry *)arena->alloc(sizeof(Sroutine_hash_entry) + @@ -1359,8 +1359,8 @@ static bool add_used_routine(LEX *lex, Query_arena *arena, rn->key.length= key->length; rn->key.str= (char *)rn + sizeof(Sroutine_hash_entry); memcpy(rn->key.str, key->str, key->length); - my_hash_insert(&lex->sroutines, (byte *)rn); - lex->sroutines_list.link_in_list((byte *)rn, (byte **)&rn->next); + my_hash_insert(&lex->sroutines, (uchar *)rn); + lex->sroutines_list.link_in_list((uchar *)rn, (uchar **)&rn->next); rn->belong_to_view= belong_to_view; return TRUE; } @@ -1418,7 +1418,7 @@ void sp_remove_not_own_routines(LEX *lex) but we want to be more future-proof. */ next_rt= not_own_rt->next; - hash_delete(&lex->sroutines, (byte *)not_own_rt); + hash_delete(&lex->sroutines, (uchar *)not_own_rt); } *(Sroutine_hash_entry **)lex->sroutines_list_own_last= NULL; @@ -1450,8 +1450,8 @@ void sp_update_sp_used_routines(HASH *dst, HASH *src) for (uint i=0 ; i < src->records ; i++) { Sroutine_hash_entry *rt= (Sroutine_hash_entry *)hash_element(src, i); - if (!hash_search(dst, (byte *)rt->key.str, rt->key.length)) - my_hash_insert(dst, (byte *)rt); + if (!hash_search(dst, (uchar *)rt->key.str, rt->key.length)) + my_hash_insert(dst, (uchar *)rt); } } @@ -76,7 +76,8 @@ int sp_cache_routines_and_add_tables_for_view(THD *thd, LEX *lex, int sp_cache_routines_and_add_tables_for_triggers(THD *thd, LEX *lex, TABLE_LIST *table); -extern "C" byte* sp_sroutine_key(const byte *ptr, uint *plen, my_bool first); +extern "C" uchar* sp_sroutine_key(const uchar *ptr, size_t *plen, + my_bool first); /* Routines which allow open/lock and close mysql.proc table even when diff --git a/sql/sp_cache.cc b/sql/sp_cache.cc index de4e1efd496..84b15ee15c4 100644 --- a/sql/sp_cache.cc +++ b/sql/sp_cache.cc @@ -39,12 +39,12 @@ public: inline void insert(sp_head *sp) { /* TODO: why don't we check return value? */ - my_hash_insert(&m_hashtable, (const byte *)sp); + my_hash_insert(&m_hashtable, (const uchar *)sp); } inline sp_head *lookup(char *name, uint namelen) { - return (sp_head *)hash_search(&m_hashtable, (const byte *)name, namelen); + return (sp_head *)hash_search(&m_hashtable, (const uchar *)name, namelen); } #ifdef NOT_USED @@ -53,7 +53,7 @@ public: sp_head *sp= lookup(name, namelen); if (sp) { - hash_delete(&m_hashtable, (byte *)sp); + hash_delete(&m_hashtable, (uchar *)sp); return TRUE; } return FALSE; @@ -130,7 +130,7 @@ void sp_cache_insert(sp_cache **cp, sp_head *sp) return; // End of memory error c->version= Cversion; // No need to lock when reading long variable } - DBUG_PRINT("info",("sp_cache: inserting: %.*s", sp->m_qname.length, + DBUG_PRINT("info",("sp_cache: inserting: %.*s", (int) sp->m_qname.length, sp->m_qname.str)); c->insert(sp); *cp= c; // Update *cp if it was NULL @@ -214,12 +214,12 @@ void sp_cache_flush_obsolete(sp_cache **cp) Internal functions *************************************************************************/ -static byte *hash_get_key_for_sp_head(const byte *ptr, uint *plen, - my_bool first) +static uchar *hash_get_key_for_sp_head(const uchar *ptr, size_t *plen, + my_bool first) { sp_head *sp= (sp_head *)ptr; *plen= sp->m_qname.length; - return (byte*) sp->m_qname.str; + return (uchar*) sp->m_qname.str; } diff --git a/sql/sp_head.cc b/sql/sp_head.cc index 566aadcc864..3d5f2f0f50d 100644 --- a/sql/sp_head.cc +++ b/sql/sp_head.cc @@ -385,13 +385,13 @@ void sp_name::init_qname(THD *thd) { m_sroutines_key.length= m_db.length + m_name.length + 2; - if (!(m_sroutines_key.str= thd->alloc(m_sroutines_key.length + 1))) + if (!(m_sroutines_key.str= (char*) thd->alloc(m_sroutines_key.length + 1))) return; m_qname.length= m_sroutines_key.length - 1; m_qname.str= m_sroutines_key.str + 1; sprintf(m_qname.str, "%.*s.%.*s", - m_db.length, (m_db.length ? m_db.str : ""), - m_name.length, m_name.str); + (int) m_db.length, (m_db.length ? m_db.str : ""), + (int) m_name.length, m_name.str); } @@ -485,8 +485,7 @@ sp_head::sp_head() */ m_db= m_name= m_qname= str_reset; - extern byte * - sp_table_key(const byte *ptr, uint *plen, my_bool first); + extern uchar *sp_table_key(const uchar *ptr, size_t *plen, my_bool first); DBUG_ENTER("sp_head::sp_head"); m_backpatch.empty(); @@ -707,7 +706,7 @@ sp_head::create_result_field(uint field_max_length, const char *field_name, field_max_length : m_return_field_def.length; field= ::make_field(table->s, /* TABLE_SHARE ptr */ - (char*) 0, /* field ptr */ + (uchar*) 0, /* field ptr */ field_length, /* field [max] length */ (uchar*) "", /* null ptr */ 0, /* null bit */ @@ -971,7 +970,7 @@ sp_head::execute(THD *thd) String old_packet; /* Use some extra margin for possible SP recursion and functions */ - if (check_stack_overrun(thd, 8 * STACK_MIN_SIZE, (char*)&old_packet)) + if (check_stack_overrun(thd, 8 * STACK_MIN_SIZE, (uchar*)&old_packet)) DBUG_RETURN(TRUE); /* init per-instruction memroot */ @@ -1658,7 +1657,7 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) { List_iterator<Item> it_args(*args); - DBUG_PRINT("info",(" %.*s: eval args", m_name.length, m_name.str)); + DBUG_PRINT("info",(" %.*s: eval args", (int) m_name.length, m_name.str)); for (uint i= 0 ; i < params ; i++) { @@ -1716,7 +1715,8 @@ sp_head::execute_procedure(THD *thd, List<Item> *args) if (!thd->in_sub_stmt) close_thread_tables(thd, 0, 0); - DBUG_PRINT("info",(" %.*s: eval args done", m_name.length, m_name.str)); + DBUG_PRINT("info",(" %.*s: eval args done", + (int) m_name.length, m_name.str)); } if (!(m_flags & LOG_SLOW_STATEMENTS) && thd->enable_slow_log) { @@ -2207,7 +2207,7 @@ void sp_head::add_instr(sp_instr *instr) entire stored procedure, as their life span is equal. */ instr->mem_root= &main_mem_root; - insert_dynamic(&m_instr, (gptr)&instr); + insert_dynamic(&m_instr, (uchar*)&instr); } @@ -2251,7 +2251,7 @@ void sp_head::optimize() sp_instr *ibp; List_iterator_fast<sp_instr> li(bp); - set_dynamic(&m_instr, (gptr)&i, dst); + set_dynamic(&m_instr, (uchar*)&i, dst); while ((ibp= li++)) { sp_instr_opt_meta *im= static_cast<sp_instr_opt_meta *>(ibp); @@ -3452,12 +3452,12 @@ typedef struct st_sp_table uint query_lock_count; } SP_TABLE; -byte * -sp_table_key(const byte *ptr, uint *plen, my_bool first) +uchar * +sp_table_key(const uchar *ptr, size_t *plen, my_bool first) { SP_TABLE *tab= (SP_TABLE *)ptr; *plen= tab->qname.length; - return (byte *)tab->qname.str; + return (uchar *)tab->qname.str; } @@ -3526,8 +3526,8 @@ sp_head::merge_table_list(THD *thd, TABLE_LIST *table, LEX *lex_for_tmp_check) (and therefore should not be prelocked). Otherwise we will erroneously treat table with same name but with different alias as non-temporary. */ - if ((tab= (SP_TABLE *)hash_search(&m_sptabs, (byte *)tname, tlen)) || - ((tab= (SP_TABLE *)hash_search(&m_sptabs, (byte *)tname, + if ((tab= (SP_TABLE *)hash_search(&m_sptabs, (uchar *)tname, tlen)) || + ((tab= (SP_TABLE *)hash_search(&m_sptabs, (uchar *)tname, tlen - alen - 1)) && tab->temp)) { @@ -3557,7 +3557,7 @@ sp_head::merge_table_list(THD *thd, TABLE_LIST *table, LEX *lex_for_tmp_check) tab->db_length= table->db_length; tab->lock_type= table->lock_type; tab->lock_count= tab->query_lock_count= 1; - my_hash_insert(&m_sptabs, (byte *)tab); + my_hash_insert(&m_sptabs, (uchar *)tab); } } return TRUE; diff --git a/sql/sp_head.h b/sql/sp_head.h index 4e3e11e468d..eacc2ccdcf6 100644 --- a/sql/sp_head.h +++ b/sql/sp_head.h @@ -242,7 +242,7 @@ public: { sp_instr *i; - get_dynamic(&m_instr, (gptr)&i, m_instr.elements-1); + get_dynamic(&m_instr, (uchar*)&i, m_instr.elements-1); return i; } @@ -324,7 +324,7 @@ public: sp_instr *ip; if (i < m_instr.elements) - get_dynamic(&m_instr, (gptr)&ip, i); + get_dynamic(&m_instr, (uchar*)&ip, i); else ip= NULL; return ip; diff --git a/sql/sp_pcontext.cc b/sql/sp_pcontext.cc index 780243cc79f..9c96485b8ec 100644 --- a/sql/sp_pcontext.cc +++ b/sql/sp_pcontext.cc @@ -211,7 +211,7 @@ sp_pcontext::find_variable(LEX_STRING *name, my_bool scoped) { sp_variable_t *p; - get_dynamic(&m_vars, (gptr)&p, i); + get_dynamic(&m_vars, (uchar*)&p, i); if (my_strnncoll(system_charset_info, (const uchar *)name->str, name->length, (const uchar *)p->name.str, p->name.length) == 0) @@ -238,7 +238,7 @@ sp_pcontext::find_variable(uint offset) { // This frame sp_variable_t *p; - get_dynamic(&m_vars, (gptr)&p, offset - m_var_offset); + get_dynamic(&m_vars, (uchar*)&p, offset - m_var_offset); return p; } if (m_parent) @@ -263,7 +263,7 @@ sp_pcontext::push_variable(LEX_STRING *name, enum enum_field_types type, p->mode= mode; p->offset= current_var_count(); p->dflt= NULL; - insert_dynamic(&m_vars, (gptr)&p); + insert_dynamic(&m_vars, (uchar*)&p); return p; } @@ -318,7 +318,7 @@ sp_pcontext::push_cond(LEX_STRING *name, sp_cond_type_t *val) p->name.str= name->str; p->name.length= name->length; p->val= val; - insert_dynamic(&m_conds, (gptr)&p); + insert_dynamic(&m_conds, (uchar*)&p); } } @@ -334,7 +334,7 @@ sp_pcontext::find_cond(LEX_STRING *name, my_bool scoped) { sp_cond_t *p; - get_dynamic(&m_conds, (gptr)&p, i); + get_dynamic(&m_conds, (uchar*)&p, i); if (my_strnncoll(system_charset_info, (const uchar *)name->str, name->length, (const uchar *)p->name.str, p->name.length) == 0) @@ -361,7 +361,7 @@ sp_pcontext::find_handler(sp_cond_type_t *cond) { sp_cond_type_t *p; - get_dynamic(&m_handlers, (gptr)&p, i); + get_dynamic(&m_handlers, (uchar*)&p, i); if (cond->type == p->type) { switch (p->type) @@ -391,7 +391,7 @@ sp_pcontext::push_cursor(LEX_STRING *name) m_max_cursor_index+= 1; n.str= name->str; n.length= name->length; - insert_dynamic(&m_cursors, (gptr)&n); + insert_dynamic(&m_cursors, (uchar*)&n); } /* @@ -406,7 +406,7 @@ sp_pcontext::find_cursor(LEX_STRING *name, uint *poff, my_bool scoped) { LEX_STRING n; - get_dynamic(&m_cursors, (gptr)&n, i); + get_dynamic(&m_cursors, (uchar*)&n, i); if (my_strnncoll(system_charset_info, (const uchar *)name->str, name->length, (const uchar *)n.str, n.length) == 0) @@ -429,7 +429,7 @@ sp_pcontext::retrieve_field_definitions(List<create_field> *field_def_lst) for (uint i = 0; i < m_vars.elements; ++i) { sp_variable_t *var_def; - get_dynamic(&m_vars, (gptr) &var_def, i); + get_dynamic(&m_vars, (uchar*) &var_def, i); field_def_lst->push_back(&var_def->field_def); } @@ -453,7 +453,7 @@ sp_pcontext::find_cursor(uint offset, LEX_STRING *n) if (m_cursor_offset <= offset && offset < m_cursor_offset + m_cursors.elements) { // This frame - get_dynamic(&m_cursors, (gptr)n, offset - m_cursor_offset); + get_dynamic(&m_cursors, (uchar*)n, offset - m_cursor_offset); return TRUE; } if (m_parent) diff --git a/sql/sp_pcontext.h b/sql/sp_pcontext.h index 5bffda79f98..3b8b165a6e0 100644 --- a/sql/sp_pcontext.h +++ b/sql/sp_pcontext.h @@ -273,7 +273,7 @@ public: inline bool push_case_expr_id(int case_expr_id) { - return insert_dynamic(&m_case_expr_id_lst, (gptr) &case_expr_id); + return insert_dynamic(&m_case_expr_id_lst, (uchar*) &case_expr_id); } inline void @@ -287,7 +287,7 @@ public: { int case_expr_id; - get_dynamic((DYNAMIC_ARRAY*)&m_case_expr_id_lst, (gptr) &case_expr_id, + get_dynamic((DYNAMIC_ARRAY*)&m_case_expr_id_lst, (uchar*) &case_expr_id, m_case_expr_id_lst.elements - 1); return case_expr_id; @@ -343,7 +343,7 @@ public: inline void push_handler(sp_cond_type_t *cond) { - insert_dynamic(&m_handlers, (gptr)&cond); + insert_dynamic(&m_handlers, (uchar*)&cond); } bool diff --git a/sql/sql_acl.cc b/sql/sql_acl.cc index 02cd527c544..59e3c0a7dd4 100644 --- a/sql/sql_acl.cc +++ b/sql/sql_acl.cc @@ -160,11 +160,11 @@ public: }; -static byte* acl_entry_get_key(acl_entry *entry,uint *length, - my_bool not_used __attribute__((unused))) +static uchar* acl_entry_get_key(acl_entry *entry, size_t *length, + my_bool not_used __attribute__((unused))) { *length=(uint) entry->length; - return (byte*) entry->key; + return (uchar*) entry->key; } #define IP_ADDR_STRLEN (3+1+3+1+3+1+3) @@ -362,9 +362,9 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) host.access|=REFERENCES_ACL | INDEX_ACL | ALTER_ACL | CREATE_TMP_ACL; } #endif - VOID(push_dynamic(&acl_hosts,(gptr) &host)); + VOID(push_dynamic(&acl_hosts,(uchar*) &host)); } - qsort((gptr) dynamic_element(&acl_hosts,0,ACL_HOST*),acl_hosts.elements, + qsort((uchar*) dynamic_element(&acl_hosts,0,ACL_HOST*),acl_hosts.elements, sizeof(ACL_HOST),(qsort_cmp) acl_compare); end_read_record(&read_record_info); freeze_size(&acl_hosts); @@ -546,13 +546,13 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) user.access|= SUPER_ACL | EXECUTE_ACL; #endif } - VOID(push_dynamic(&acl_users,(gptr) &user)); + VOID(push_dynamic(&acl_users,(uchar*) &user)); if (!user.host.hostname || (user.host.hostname[0] == wild_many && !user.host.hostname[1])) allow_all_hosts=1; // Anyone can connect } } - qsort((gptr) dynamic_element(&acl_users,0,ACL_USER*),acl_users.elements, + qsort((uchar*) dynamic_element(&acl_users,0,ACL_USER*),acl_users.elements, sizeof(ACL_USER),(qsort_cmp) acl_compare); end_read_record(&read_record_info); freeze_size(&acl_users); @@ -609,9 +609,9 @@ static my_bool acl_load(THD *thd, TABLE_LIST *tables) db.access|=REFERENCES_ACL | INDEX_ACL | ALTER_ACL; } #endif - VOID(push_dynamic(&acl_dbs,(gptr) &db)); + VOID(push_dynamic(&acl_dbs,(uchar*) &db)); } - qsort((gptr) dynamic_element(&acl_dbs,0,ACL_DB*),acl_dbs.elements, + qsort((uchar*) dynamic_element(&acl_dbs,0,ACL_DB*),acl_dbs.elements, sizeof(ACL_DB),(qsort_cmp) acl_compare); end_read_record(&read_record_info); freeze_size(&acl_dbs); @@ -1152,11 +1152,11 @@ bool acl_getroot_no_password(Security_context *sctx, char *user, char *host, DBUG_RETURN(res); } -static byte* check_get_key(ACL_USER *buff,uint *length, - my_bool not_used __attribute__((unused))) +static uchar* check_get_key(ACL_USER *buff, size_t *length, + my_bool not_used __attribute__((unused))) { *length=buff->hostname_length; - return (byte*) buff->host.hostname; + return (uchar*) buff->host.hostname; } @@ -1237,11 +1237,11 @@ static void acl_insert_user(const char *user, const char *host, set_user_salt(&acl_user, password, password_len); - VOID(push_dynamic(&acl_users,(gptr) &acl_user)); + VOID(push_dynamic(&acl_users,(uchar*) &acl_user)); if (!acl_user.host.hostname || (acl_user.host.hostname[0] == wild_many && !acl_user.host.hostname[1])) allow_all_hosts=1; // Anyone can connect /* purecov: tested */ - qsort((gptr) dynamic_element(&acl_users,0,ACL_USER*),acl_users.elements, + qsort((uchar*) dynamic_element(&acl_users,0,ACL_USER*),acl_users.elements, sizeof(ACL_USER),(qsort_cmp) acl_compare); /* Rebuild 'acl_check_hosts' since 'acl_users' has been modified */ @@ -1303,8 +1303,8 @@ static void acl_insert_db(const char *user, const char *host, const char *db, acl_db.db=strdup_root(&mem,db); acl_db.access=privileges; acl_db.sort=get_sort(3,acl_db.host.hostname,acl_db.db,acl_db.user); - VOID(push_dynamic(&acl_dbs,(gptr) &acl_db)); - qsort((gptr) dynamic_element(&acl_dbs,0,ACL_DB*),acl_dbs.elements, + VOID(push_dynamic(&acl_dbs,(uchar*) &acl_db)); + qsort((uchar*) dynamic_element(&acl_dbs,0,ACL_DB*),acl_dbs.elements, sizeof(ACL_DB),(qsort_cmp) acl_compare); } @@ -1321,7 +1321,8 @@ ulong acl_get(const char *host, const char *ip, const char *user, const char *db, my_bool db_is_pattern) { ulong host_access= ~(ulong)0, db_access= 0; - uint i,key_length; + uint i; + size_t key_length; char key[ACL_KEY_LENGTH],*tmp_db,*end; acl_entry *entry; DBUG_ENTER("acl_get"); @@ -1333,8 +1334,9 @@ ulong acl_get(const char *host, const char *ip, my_casedn_str(files_charset_info, tmp_db); db=tmp_db; } - key_length=(uint) (end-key); - if (!db_is_pattern && (entry=(acl_entry*) acl_cache->search(key,key_length))) + key_length= (size_t) (end-key); + if (!db_is_pattern && (entry=(acl_entry*) acl_cache->search((uchar*) key, + key_length))) { db_access=entry->access; VOID(pthread_mutex_unlock(&acl_cache->lock)); @@ -1388,7 +1390,7 @@ exit: { entry->access=(db_access & host_access); entry->length=key_length; - memcpy((gptr) entry->key,key,key_length); + memcpy((uchar*) entry->key,key,key_length); acl_cache->add(entry); } VOID(pthread_mutex_unlock(&acl_cache->lock)); @@ -1430,12 +1432,12 @@ static void init_check_host(void) break; // already stored } if (j == acl_wild_hosts.elements) // If new - (void) push_dynamic(&acl_wild_hosts,(char*) &acl_user->host); + (void) push_dynamic(&acl_wild_hosts,(uchar*) &acl_user->host); } - else if (!hash_search(&acl_check_hosts,(byte*) acl_user->host.hostname, - (uint) strlen(acl_user->host.hostname))) + else if (!hash_search(&acl_check_hosts,(uchar*) acl_user->host.hostname, + strlen(acl_user->host.hostname))) { - if (my_hash_insert(&acl_check_hosts,(byte*) acl_user)) + if (my_hash_insert(&acl_check_hosts,(uchar*) acl_user)) { // End of memory allow_all_hosts=1; // Should never happen DBUG_VOID_RETURN; @@ -1473,8 +1475,8 @@ bool acl_check_host(const char *host, const char *ip) return 0; VOID(pthread_mutex_lock(&acl_cache->lock)); - if (host && hash_search(&acl_check_hosts,(byte*) host,(uint) strlen(host)) || - ip && hash_search(&acl_check_hosts,(byte*) ip,(uint) strlen(ip))) + if (host && hash_search(&acl_check_hosts,(uchar*) host,strlen(host)) || + ip && hash_search(&acl_check_hosts,(uchar*) ip, strlen(ip))) { VOID(pthread_mutex_unlock(&acl_cache->lock)); return 0; // Found host @@ -1533,7 +1535,7 @@ bool check_change_password(THD *thd, const char *host, const char *user, MYF(0)); return(1); } - uint len=strlen(new_password); + size_t len= strlen(new_password); if (len && len != SCRAMBLED_PASSWORD_CHAR_LENGTH && len != SCRAMBLED_PASSWORD_CHAR_LENGTH_323) { @@ -1567,7 +1569,7 @@ bool change_password(THD *thd, const char *host, const char *user, /* Buffer should be extended when password length is extended. */ char buff[512]; ulong query_length; - uint new_password_len= strlen(new_password); + uint new_password_len= (uint) strlen(new_password); bool result= 1; DBUG_ENTER("change_password"); DBUG_PRINT("enter",("host: '%s' user: '%s' new_password: '%s'", @@ -1768,8 +1770,8 @@ bool hostname_requires_resolving(const char *hostname) char cur; if (!hostname) return FALSE; - int namelen= strlen(hostname); - int lhlen= strlen(my_localhost); + size_t namelen= strlen(hostname); + size_t lhlen= strlen(my_localhost); if ((namelen == lhlen) && !my_strnncoll(system_charset_info, (const uchar *)hostname, namelen, (const uchar *)my_localhost, strlen(my_localhost))) @@ -1809,11 +1811,11 @@ static bool update_user_table(THD *thd, TABLE *table, table->use_all_columns(); table->field[0]->store(host,(uint) strlen(host), system_charset_info); table->field[1]->store(user,(uint) strlen(user), system_charset_info); - key_copy((byte *) user_key, table->record[0], table->key_info, + key_copy((uchar *) user_key, table->record[0], table->key_info, table->key_info->key_length); if (table->file->index_read_idx(table->record[0], 0, - (byte *) user_key, HA_WHOLE_KEY, + (uchar *) user_key, HA_WHOLE_KEY, HA_READ_KEY_EXACT)) { my_message(ER_PASSWORD_NO_MATCH, ER(ER_PASSWORD_NO_MATCH), @@ -1878,7 +1880,7 @@ static int replace_user_table(THD *thd, TABLE *table, const LEX_USER &combo, const char *password= ""; uint password_len= 0; char what= (revoke_grant) ? 'N' : 'Y'; - byte user_key[MAX_KEY_LENGTH]; + uchar user_key[MAX_KEY_LENGTH]; LEX *lex= thd->lex; DBUG_ENTER("replace_user_table"); @@ -2096,7 +2098,7 @@ static int replace_db_table(TABLE *table, const char *db, bool old_row_exists=0; int error; char what= (revoke_grant) ? 'N' : 'Y'; - byte user_key[MAX_KEY_LENGTH]; + uchar user_key[MAX_KEY_LENGTH]; DBUG_ENTER("replace_db_table"); if (!initialized) @@ -2198,16 +2200,16 @@ public: uint key_length; GRANT_COLUMN(String &c, ulong y) :rights (y) { - column= memdup_root(&memex,c.ptr(), key_length=c.length()); + column= (char*) memdup_root(&memex,c.ptr(), key_length=c.length()); } }; -static byte* get_key_column(GRANT_COLUMN *buff,uint *length, +static uchar* get_key_column(GRANT_COLUMN *buff, size_t *length, my_bool not_used __attribute__((unused))) { *length=buff->key_length; - return (byte*) buff->column; + return (uchar*) buff->column; } @@ -2218,7 +2220,7 @@ public: char *db, *user, *tname, *hash_key; ulong privs; ulong sort; - uint key_length; + size_t key_length; GRANT_NAME(const char *h, const char *d,const char *u, const char *t, ulong p); GRANT_NAME (TABLE *form); @@ -2257,8 +2259,8 @@ GRANT_NAME::GRANT_NAME(const char *h, const char *d,const char *u, my_casedn_str(files_charset_info, db); my_casedn_str(files_charset_info, tname); } - key_length =(uint) strlen(d)+(uint) strlen(u)+(uint) strlen(t)+3; - hash_key = (char*) alloc_root(&memex,key_length); + key_length= strlen(d) + strlen(u)+ strlen(t)+3; + hash_key= (char*) alloc_root(&memex,key_length); strmov(strmov(strmov(hash_key,user)+1,db)+1,tname); } @@ -2292,9 +2294,8 @@ GRANT_NAME::GRANT_NAME(TABLE *form) my_casedn_str(files_charset_info, db); my_casedn_str(files_charset_info, tname); } - key_length = ((uint) strlen(db) + (uint) strlen(user) + - (uint) strlen(tname) + 3); - hash_key = (char*) alloc_root(&memex,key_length); + key_length= (strlen(db) + strlen(user) + strlen(tname) + 3); + hash_key= (char*) alloc_root(&memex, key_length); strmov(strmov(strmov(hash_key,user)+1,db)+1,tname); privs = (ulong) form->field[6]->val_int(); privs = fix_rights_for_table(privs); @@ -2304,7 +2305,7 @@ GRANT_NAME::GRANT_NAME(TABLE *form) GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs) :GRANT_NAME(form) { - byte key[MAX_KEY_LENGTH]; + uchar key[MAX_KEY_LENGTH]; if (!db || !tname) { @@ -2338,7 +2339,7 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs) col_privs->field[4]->store("",0, &my_charset_latin1); col_privs->file->ha_index_init(0, 1); - if (col_privs->file->index_read(col_privs->record[0], (byte*) key, + if (col_privs->file->index_read(col_privs->record[0], (uchar*) key, (key_part_map)15, HA_READ_KEY_EXACT)) { cols = 0; /* purecov: deadcode */ @@ -2359,7 +2360,7 @@ GRANT_TABLE::GRANT_TABLE(TABLE *form, TABLE *col_privs) privs = cols = 0; /* purecov: deadcode */ return; /* purecov: deadcode */ } - my_hash_insert(&hash_columns, (byte *) mem_check); + my_hash_insert(&hash_columns, (uchar *) mem_check); } while (!col_privs->file->index_next(col_privs->record[0]) && !key_cmp_if_same(col_privs,key,0,key_prefix_len)); col_privs->file->ha_index_end(); @@ -2373,11 +2374,11 @@ GRANT_TABLE::~GRANT_TABLE() } -static byte* get_grant_table(GRANT_NAME *buff,uint *length, +static uchar* get_grant_table(GRANT_NAME *buff, size_t *length, my_bool not_used __attribute__((unused))) { *length=buff->key_length; - return (byte*) buff->hash_key; + return (uchar*) buff->hash_key; } @@ -2401,10 +2402,10 @@ static GRANT_NAME *name_hash_search(HASH *name_hash, HASH_SEARCH_STATE state; len = (uint) (strmov(strmov(strmov(helping,user)+1,db)+1,tname)-helping)+ 1; - for (grant_name= (GRANT_NAME*) hash_first(name_hash, (byte*) helping, + for (grant_name= (GRANT_NAME*) hash_first(name_hash, (uchar*) helping, len, &state); grant_name ; - grant_name= (GRANT_NAME*) hash_next(name_hash,(byte*) helping, + grant_name= (GRANT_NAME*) hash_next(name_hash,(uchar*) helping, len, &state)) { if (exact) @@ -2449,7 +2450,7 @@ table_hash_search(const char *host, const char *ip, const char *db, inline GRANT_COLUMN * column_hash_search(GRANT_TABLE *t, const char *cname, uint length) { - return (GRANT_COLUMN*) hash_search(&t->hash_columns, (byte*) cname,length); + return (GRANT_COLUMN*) hash_search(&t->hash_columns, (uchar*) cname,length); } @@ -2460,7 +2461,7 @@ static int replace_column_table(GRANT_TABLE *g_t, ulong rights, bool revoke_grant) { int error=0,result=0; - byte key[MAX_KEY_LENGTH]; + uchar key[MAX_KEY_LENGTH]; uint key_prefix_length; KEY_PART_INFO *key_part= table->key_info->key_part; DBUG_ENTER("replace_column_table"); @@ -2491,7 +2492,7 @@ static int replace_column_table(GRANT_TABLE *g_t, { ulong privileges= column->rights; bool old_row_exists=0; - byte user_key[MAX_KEY_LENGTH]; + uchar user_key[MAX_KEY_LENGTH]; key_restore(table->record[0],key,table->key_info, key_prefix_length); @@ -2562,7 +2563,7 @@ static int replace_column_table(GRANT_TABLE *g_t, goto end; /* purecov: inspected */ } grant_column= new GRANT_COLUMN(column->column,privileges); - my_hash_insert(&g_t->hash_columns,(byte*) grant_column); + my_hash_insert(&g_t->hash_columns,(uchar*) grant_column); } } @@ -2573,7 +2574,7 @@ static int replace_column_table(GRANT_TABLE *g_t, if (revoke_grant) { - byte user_key[MAX_KEY_LENGTH]; + uchar user_key[MAX_KEY_LENGTH]; key_copy(user_key, table->record[0], table->key_info, key_prefix_length); @@ -2625,7 +2626,7 @@ static int replace_column_table(GRANT_TABLE *g_t, goto end; /* purecov: deadcode */ } if (grant_column) - hash_delete(&g_t->hash_columns,(byte*) grant_column); + hash_delete(&g_t->hash_columns,(uchar*) grant_column); } } } while (!table->file->index_next(table->record[0]) && @@ -2648,7 +2649,7 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table, int old_row_exists = 1; int error=0; ulong store_table_rights, store_col_rights; - byte user_key[MAX_KEY_LENGTH]; + uchar user_key[MAX_KEY_LENGTH]; DBUG_ENTER("replace_table_table"); strxmov(grantor, thd->security_ctx->user, "@", @@ -2748,7 +2749,7 @@ static int replace_table_table(THD *thd, GRANT_TABLE *grant_table, } else { - hash_delete(&column_priv_hash,(byte*) grant_table); + hash_delete(&column_priv_hash,(uchar*) grant_table); } DBUG_RETURN(0); @@ -2802,7 +2803,7 @@ static int replace_routine_table(THD *thd, GRANT_NAME *grant_name, store_record(table,record[1]); // store at pos 1 if (table->file->index_read_idx(table->record[0], 0, - (byte*) table->field[0]->ptr, HA_WHOLE_KEY, + (uchar*) table->field[0]->ptr, HA_WHOLE_KEY, HA_READ_KEY_EXACT)) { /* @@ -2865,7 +2866,7 @@ static int replace_routine_table(THD *thd, GRANT_NAME *grant_name, } else { - hash_delete(is_proc ? &proc_priv_hash : &func_priv_hash,(byte*) grant_name); + hash_delete(is_proc ? &proc_priv_hash : &func_priv_hash,(uchar*) grant_name); } DBUG_RETURN(0); @@ -3081,7 +3082,7 @@ bool mysql_table_grant(THD *thd, TABLE_LIST *table_list, result= TRUE; /* purecov: deadcode */ continue; /* purecov: deadcode */ } - my_hash_insert(&column_priv_hash,(byte*) grant_table); + my_hash_insert(&column_priv_hash,(uchar*) grant_table); } /* If revoke_grant, calculate the new column privilege for tables_priv */ @@ -3299,7 +3300,7 @@ bool mysql_routine_grant(THD *thd, TABLE_LIST *table_list, bool is_proc, result= TRUE; continue; } - my_hash_insert(is_proc ? &proc_priv_hash : &func_priv_hash,(byte*) grant_name); + my_hash_insert(is_proc ? &proc_priv_hash : &func_priv_hash,(uchar*) grant_name); } if (replace_routine_table(thd, grant_name, tables[1].table, *Str, @@ -3567,7 +3568,7 @@ static my_bool grant_load(TABLE_LIST *tables) if (! mem_check->ok()) delete mem_check; - else if (my_hash_insert(&column_priv_hash,(byte*) mem_check)) + else if (my_hash_insert(&column_priv_hash,(uchar*) mem_check)) { delete mem_check; goto end_unlock; @@ -3621,7 +3622,7 @@ static my_bool grant_load(TABLE_LIST *tables) mem_check->privs= fix_rights_for_procedure(mem_check->privs); if (! mem_check->ok()) delete mem_check; - else if (my_hash_insert(hash, (byte*) mem_check)) + else if (my_hash_insert(hash, (uchar*) mem_check)) { delete mem_check; goto end_unlock; @@ -4984,7 +4985,7 @@ static int handle_grant_table(TABLE_LIST *tables, uint table_no, bool drop, char *user_str= user_from->user.str; const char *host; const char *user; - byte user_key[MAX_KEY_LENGTH]; + uchar user_key[MAX_KEY_LENGTH]; uint key_prefix_length; DBUG_ENTER("handle_grant_table"); @@ -5221,11 +5222,11 @@ static int handle_grant_struct(uint struct_no, bool drop, break; case 2: - hash_delete(&column_priv_hash, (byte*) grant_name); + hash_delete(&column_priv_hash, (uchar*) grant_name); break; case 3: - hash_delete(&proc_priv_hash, (byte*) grant_name); + hash_delete(&proc_priv_hash, (uchar*) grant_name); break; } elements--; @@ -6063,15 +6064,15 @@ void update_schema_privilege(TABLE *table, char *buff, const char* db, int i= 2; CHARSET_INFO *cs= system_charset_info; restore_record(table, s->default_values); - table->field[0]->store(buff, strlen(buff), cs); + table->field[0]->store(buff, (uint) strlen(buff), cs); if (db) - table->field[i++]->store(db, strlen(db), cs); + table->field[i++]->store(db, (uint) strlen(db), cs); if (t_name) - table->field[i++]->store(t_name, strlen(t_name), cs); + table->field[i++]->store(t_name, (uint) strlen(t_name), cs); if (column) table->field[i++]->store(column, col_length, cs); table->field[i++]->store(priv, priv_length, cs); - table->field[i]->store(is_grantable, strlen(is_grantable), cs); + table->field[i]->store(is_grantable, (uint) strlen(is_grantable), cs); table->file->ha_write_row(table->record[0]); } diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index e7decf4a8fc..6b4aaa26236 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -498,7 +498,7 @@ void field_decimal::add() if (room_in_tree) { - char buf[DECIMAL_MAX_FIELD_SIZE]; + uchar buf[DECIMAL_MAX_FIELD_SIZE]; my_decimal2binary(E_DEC_FATAL_ERROR, dec, buf, item->max_length, item->decimals); if (!(element = tree_insert(&tree, (void*)buf, 0, tree.custom_arg))) @@ -1108,7 +1108,7 @@ int collect_real(double *element, element_count count __attribute__((unused)), } // collect_real -int collect_decimal(char *element, element_count count, +int collect_decimal(uchar *element, element_count count, TREE_INFO *info) { char buff[DECIMAL_MAX_STR_LENGTH]; diff --git a/sql/sql_analyse.h b/sql/sql_analyse.h index ac671b85e1e..ae5d88bf93e 100644 --- a/sql/sql_analyse.h +++ b/sql/sql_analyse.h @@ -143,7 +143,7 @@ public: }; -int collect_decimal(char *element, element_count count, +int collect_decimal(uchar *element, element_count count, TREE_INFO *info); class field_decimal :public field_info @@ -165,7 +165,7 @@ public: String *get_min_arg(String *); String *get_max_arg(String *); String *avg(String *s, ha_rows rows); - friend int collect_decimal(char *element, element_count count, + friend int collect_decimal(uchar *element, element_count count, TREE_INFO *info); tree_walk_action collect_enum() { return (tree_walk_action) collect_decimal; } diff --git a/sql/sql_array.h b/sql/sql_array.h index e2e12bee241..ab6fdd0c5c0 100644 --- a/sql/sql_array.h +++ b/sql/sql_array.h @@ -45,7 +45,7 @@ public: bool append(Elem &el) { - return (insert_dynamic(&array, (gptr)&el)); + return (insert_dynamic(&array, (uchar*)&el)); } int elements() diff --git a/sql/sql_base.cc b/sql/sql_base.cc index a97d285810e..b21dc9d47f8 100644 --- a/sql/sql_base.cc +++ b/sql/sql_base.cc @@ -103,19 +103,19 @@ static bool has_two_write_locked_tables_with_auto_increment(TABLE_LIST *tables); -extern "C" byte *table_cache_key(const byte *record,uint *length, +extern "C" uchar *table_cache_key(const uchar *record, size_t *length, my_bool not_used __attribute__((unused))) { TABLE *entry=(TABLE*) record; *length= entry->s->table_cache_key.length; - return (byte*) entry->s->table_cache_key.str; + return (uchar*) entry->s->table_cache_key.str; } bool table_cache_init(void) { return hash_init(&open_cache, &my_charset_bin, table_cache_size+16, - 0, 0,table_cache_key, + 0, 0, table_cache_key, (hash_free_key) free_cache_entry, 0) != 0; } @@ -242,12 +242,12 @@ uint create_table_def_key(THD *thd, char *key, TABLE_LIST *table_list, Functions to handle table definition cach (TABLE_SHARE) *****************************************************************************/ -extern "C" byte *table_def_key(const byte *record, uint *length, +extern "C" uchar *table_def_key(const uchar *record, size_t *length, my_bool not_used __attribute__((unused))) { TABLE_SHARE *entry=(TABLE_SHARE*) record; *length= entry->table_cache_key.length; - return (byte*) entry->table_cache_key.str; + return (uchar*) entry->table_cache_key.str; } @@ -333,7 +333,7 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key, *error= 0; /* Read table definition from cache */ - if ((share= (TABLE_SHARE*) hash_search(&table_def_cache,(byte*) key, + if ((share= (TABLE_SHARE*) hash_search(&table_def_cache,(uchar*) key, key_length))) goto found; @@ -350,7 +350,7 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key, pthread_mutex_unlock(&LOCK_open); pthread_mutex_lock(&LOCK_open); /* Check that another thread didn't insert the same table in between */ - if ((old_share= hash_search(&table_def_cache, (byte*) key, key_length))) + if ((old_share= hash_search(&table_def_cache, (uchar*) key, key_length))) { (void) pthread_mutex_lock(&share->mutex); free_table_share(share); @@ -380,7 +380,7 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key, */ assign_new_table_id(share); - if (my_hash_insert(&table_def_cache, (byte*) share)) + if (my_hash_insert(&table_def_cache, (uchar*) share)) { #ifdef WAITING_FOR_TABLE_DEF_CACHE_STAGE_3 pthread_mutex_unlock(&LOCK_open); @@ -406,7 +406,7 @@ TABLE_SHARE *get_table_share(THD *thd, TABLE_LIST *table_list, char *key, (void) pthread_mutex_lock(&share->mutex); #endif *error= share->error; - (void) hash_delete(&table_def_cache, (byte*) share); + (void) hash_delete(&table_def_cache, (uchar*) share); DBUG_RETURN(0); } share->ref_count++; // Mark in use @@ -461,7 +461,7 @@ found: oldest_unused_share->next) { pthread_mutex_lock(&oldest_unused_share->mutex); - VOID(hash_delete(&table_def_cache, (byte*) oldest_unused_share)); + VOID(hash_delete(&table_def_cache, (uchar*) oldest_unused_share)); } DBUG_PRINT("exit", ("share: 0x%lx ref_count: %u", @@ -584,7 +584,7 @@ void release_table_share(TABLE_SHARE *share, enum release_type type) if (to_be_deleted) { DBUG_PRINT("info", ("Deleting share")); - hash_delete(&table_def_cache, (byte*) share); + hash_delete(&table_def_cache, (uchar*) share); DBUG_VOID_RETURN; } pthread_mutex_unlock(&share->mutex); @@ -610,13 +610,13 @@ void release_table_share(TABLE_SHARE *share, enum release_type type) This code is execured when someone does FLUSH TABLES while on has locked tables. */ - (void) hash_search(&def_cache,(byte*) key,key_length); - hash_replace(&def_cache, def_cache.current_record,(byte*) name_lock); + (void) hash_search(&def_cache,(uchar*) key,key_length); + hash_replace(&def_cache, def_cache.current_record,(uchar*) name_lock); } else { /* Remove table definition */ - hash_delete(&def_cache,(byte*) share); + hash_delete(&def_cache,(uchar*) share); } pthread_mutex_unlock(&LOCK_open); free_table_share(share); @@ -661,7 +661,7 @@ TABLE_SHARE *get_cached_table_share(const char *db, const char *table_name) table_list.db= (char*) db; table_list.table_name= (char*) table_name; key_length= create_table_def_key((THD*) 0, key, &table_list, 0); - return (TABLE_SHARE*) hash_search(&table_def_cache,(byte*) key, key_length); + return (TABLE_SHARE*) hash_search(&table_def_cache,(uchar*) key, key_length); } @@ -841,7 +841,7 @@ static void free_cache_entry(TABLE *table) } check_unused(); // consisty check } - my_free((gptr) table,MYF(0)); + my_free((uchar*) table,MYF(0)); DBUG_VOID_RETURN; } @@ -853,7 +853,7 @@ void free_io_cache(TABLE *table) if (table->sort.io_cache) { close_cached_file(table->sort.io_cache); - my_free((gptr) table->sort.io_cache,MYF(0)); + my_free((uchar*) table->sort.io_cache,MYF(0)); table->sort.io_cache=0; } DBUG_VOID_RETURN; @@ -882,17 +882,17 @@ bool close_cached_tables(THD *thd, bool if_wait_for_refresh, while (unused_tables) { #ifdef EXTRA_DEBUG - if (hash_delete(&open_cache,(byte*) unused_tables)) + if (hash_delete(&open_cache,(uchar*) unused_tables)) printf("Warning: Couldn't delete open table from hash\n"); #else - VOID(hash_delete(&open_cache,(byte*) unused_tables)); + VOID(hash_delete(&open_cache,(uchar*) unused_tables)); #endif } /* Free table shares */ while (oldest_unused_share->next) { pthread_mutex_lock(&oldest_unused_share->mutex); - VOID(hash_delete(&table_def_cache, (byte*) oldest_unused_share)); + VOID(hash_delete(&table_def_cache, (uchar*) oldest_unused_share)); } } else @@ -1231,7 +1231,7 @@ void close_thread_tables(THD *thd, bool lock_in_use, bool skip_derived) /* Free tables to hold down open files */ while (open_cache.records > table_cache_size && unused_tables) - VOID(hash_delete(&open_cache,(byte*) unused_tables)); /* purecov: tested */ + VOID(hash_delete(&open_cache,(uchar*) unused_tables)); /* purecov: tested */ check_unused(); if (found_old_table) { @@ -1270,7 +1270,7 @@ bool close_thread_table(THD *thd, TABLE **table_ptr) if (table->needs_reopen_or_name_lock() || thd->version != refresh_version || !table->db_stat) { - VOID(hash_delete(&open_cache,(byte*) table)); + VOID(hash_delete(&open_cache,(uchar*) table)); found_old_table=1; } else @@ -1834,7 +1834,7 @@ void unlink_open_table(THD *thd, TABLE *find, bool unlock) { if (unlock && thd->locked_tables) mysql_lock_remove(thd, thd->locked_tables,list); - VOID(hash_delete(&open_cache,(byte*) list)); // Close table + VOID(hash_delete(&open_cache,(uchar*) list)); // Close table } else { @@ -2057,9 +2057,9 @@ TABLE *table_cache_insert_placeholder(THD *thd, const char *key, table->in_use= thd; table->locked_by_name=1; - if (my_hash_insert(&open_cache, (byte*)table)) + if (my_hash_insert(&open_cache, (uchar*)table)) { - my_free((gptr) table, MYF(0)); + my_free((uchar*) table, MYF(0)); DBUG_RETURN(NULL); } @@ -2099,7 +2099,7 @@ bool lock_table_name_if_not_cached(THD *thd, const char *db, key_length= (uint)(strmov(strmov(key, db) + 1, table_name) - key) + 1; VOID(pthread_mutex_lock(&LOCK_open)); - if (hash_search(&open_cache, (byte *)key, key_length)) + if (hash_search(&open_cache, (uchar *)key, key_length)) { VOID(pthread_mutex_unlock(&LOCK_open)); DBUG_PRINT("info", ("Table is cached, name-lock is not obtained")); @@ -2231,7 +2231,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, *refresh=0; /* an open table operation needs a lot of the stack space */ - if (check_stack_overrun(thd, STACK_MIN_SIZE_FOR_OPEN, (char *)&alias)) + if (check_stack_overrun(thd, STACK_MIN_SIZE_FOR_OPEN, (uchar *)&alias)) DBUG_RETURN(0); if (thd->killed) @@ -2458,10 +2458,10 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, an implicit "pending locks queue" - see wait_for_locked_table_names for details. */ - for (table= (TABLE*) hash_first(&open_cache, (byte*) key, key_length, + for (table= (TABLE*) hash_first(&open_cache, (uchar*) key, key_length, &state); table && table->in_use ; - table= (TABLE*) hash_next(&open_cache, (byte*) key, key_length, + table= (TABLE*) hash_next(&open_cache, (uchar*) key, key_length, &state)) { /* @@ -2566,7 +2566,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, int error; /* Free cache if too big */ while (open_cache.records > table_cache_size && unused_tables) - VOID(hash_delete(&open_cache,(byte*) unused_tables)); /* purecov: tested */ + VOID(hash_delete(&open_cache,(uchar*) unused_tables)); /* purecov: tested */ if (table_list->create) { @@ -2613,7 +2613,7 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, mem_root, (flags & OPEN_VIEW_NO_PARSE)); if (error > 0) { - my_free((gptr)table, MYF(0)); + my_free((uchar*)table, MYF(0)); VOID(pthread_mutex_unlock(&LOCK_open)); DBUG_RETURN(NULL); } @@ -2626,12 +2626,12 @@ TABLE *open_table(THD *thd, TABLE_LIST *table_list, MEM_ROOT *mem_root, if (error < 0) table_list->view= (st_lex*)1; - my_free((gptr)table, MYF(0)); + my_free((uchar*)table, MYF(0)); VOID(pthread_mutex_unlock(&LOCK_open)); DBUG_RETURN(0); // VIEW } DBUG_PRINT("info", ("inserting table 0x%lx into the cache", (long) table)); - VOID(my_hash_insert(&open_cache,(byte*) table)); + VOID(my_hash_insert(&open_cache,(uchar*) table)); } check_unused(); // Debugging call @@ -2897,7 +2897,7 @@ bool reopen_tables(THD *thd,bool get_locks,bool in_refresh) if (!tables || (!db_stat && reopen_table(table))) { my_error(ER_CANT_REOPEN_TABLE, MYF(0), table->alias); - VOID(hash_delete(&open_cache,(byte*) table)); + VOID(hash_delete(&open_cache,(uchar*) table)); error=1; } else @@ -2928,7 +2928,7 @@ bool reopen_tables(THD *thd,bool get_locks,bool in_refresh) } if (get_locks && tables) { - my_afree((gptr) tables); + my_afree((uchar*) tables); } broadcast_refresh(); *prev=0; @@ -3025,10 +3025,10 @@ bool table_is_used(TABLE *table, bool wait_for_name_lock) DBUG_PRINT("loop", ("table_name: %s", table->alias)); HASH_SEARCH_STATE state; - for (TABLE *search= (TABLE*) hash_first(&open_cache, (byte*) key, + for (TABLE *search= (TABLE*) hash_first(&open_cache, (uchar*) key, key_length, &state); search ; - search= (TABLE*) hash_next(&open_cache, (byte*) key, + search= (TABLE*) hash_next(&open_cache, (uchar*) key, key_length, &state)) { DBUG_PRINT("info", ("share: 0x%lx locked_by_logger: %d " @@ -3142,7 +3142,7 @@ TABLE *drop_locked_tables(THD *thd,const char *db, const char *table_name) else { /* We already have a name lock, remove copy */ - VOID(hash_delete(&open_cache,(byte*) table)); + VOID(hash_delete(&open_cache,(uchar*) table)); } } else @@ -3156,7 +3156,7 @@ TABLE *drop_locked_tables(THD *thd,const char *db, const char *table_name) broadcast_refresh(); if (thd->locked_tables && thd->locked_tables->table_count == 0) { - my_free((gptr) thd->locked_tables,MYF(0)); + my_free((uchar*) thd->locked_tables,MYF(0)); thd->locked_tables=0; } DBUG_RETURN(found); @@ -4558,7 +4558,7 @@ find_field_in_table(THD *thd, TABLE *table, const char *name, uint length, field_ptr= table->field + cached_field_index; else if (table->s->name_hash.records) { - field_ptr= (Field**) hash_search(&table->s->name_hash, (byte*) name, + field_ptr= (Field**) hash_search(&table->s->name_hash, (uchar*) name, length); if (field_ptr) { @@ -4766,7 +4766,7 @@ find_field_in_table_ref(THD *thd, TABLE_LIST *table_list, else { if (thd->mark_used_columns == MARK_COLUMNS_READ) - it->walk(&Item::register_field_in_read_map, 1, (byte *) 0); + it->walk(&Item::register_field_in_read_map, 1, (uchar *) 0); } } else @@ -4805,7 +4805,7 @@ Field *find_field_in_table_sef(TABLE *table, const char *name) Field **field_ptr; if (table->s->name_hash.records) { - field_ptr= (Field**)hash_search(&table->s->name_hash,(byte*) name, + field_ptr= (Field**)hash_search(&table->s->name_hash,(uchar*) name, strlen(name)); if (field_ptr) { @@ -6897,14 +6897,15 @@ my_bool mysql_rm_tmp_tables(void) (file->name[1] == '.' && !file->name[2]))) continue; - if (!bcmp(file->name,tmp_file_prefix,tmp_file_prefix_length)) + if (!bcmp((uchar*) file->name, (uchar*) tmp_file_prefix, + tmp_file_prefix_length)) { char *ext= fn_ext(file->name); uint ext_len= strlen(ext); uint filePath_len= my_snprintf(filePath, sizeof(filePath), "%s%c%s", tmpdir, FN_LIBCHAR, file->name); - if (!bcmp(reg_ext, ext, ext_len)) + if (!bcmp((uchar*) reg_ext, (uchar*) ext, ext_len)) { handler *handler_file= 0; /* We should cut file extention before deleting of table */ @@ -6967,7 +6968,7 @@ void remove_db_from_cache(const char *db) } } while (unused_tables && !unused_tables->s->version) - VOID(hash_delete(&open_cache,(byte*) unused_tables)); + VOID(hash_delete(&open_cache,(uchar*) unused_tables)); } @@ -6983,7 +6984,7 @@ void flush_tables() { (void) pthread_mutex_lock(&LOCK_open); while (unused_tables) - hash_delete(&open_cache,(byte*) unused_tables); + hash_delete(&open_cache,(uchar*) unused_tables); (void) pthread_mutex_unlock(&LOCK_open); } @@ -7020,10 +7021,10 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name, HASH_SEARCH_STATE state; result= signalled= 0; - for (table= (TABLE*) hash_first(&open_cache, (byte*) key, key_length, + for (table= (TABLE*) hash_first(&open_cache, (uchar*) key, key_length, &state); table; - table= (TABLE*) hash_next(&open_cache, (byte*) key, key_length, + table= (TABLE*) hash_next(&open_cache, (uchar*) key, key_length, &state)) { THD *in_use; @@ -7078,11 +7079,11 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name, } } while (unused_tables && !unused_tables->s->version) - VOID(hash_delete(&open_cache,(byte*) unused_tables)); + VOID(hash_delete(&open_cache,(uchar*) unused_tables)); DBUG_PRINT("info", ("Removing table from table_def_cache")); /* Remove table from table definition cache if it's not in use */ - if ((share= (TABLE_SHARE*) hash_search(&table_def_cache,(byte*) key, + if ((share= (TABLE_SHARE*) hash_search(&table_def_cache,(uchar*) key, key_length))) { DBUG_PRINT("info", ("share version: %lu ref_count: %u", @@ -7091,7 +7092,7 @@ bool remove_table_from_cache(THD *thd, const char *db, const char *table_name, if (share->ref_count == 0) { pthread_mutex_lock(&share->mutex); - VOID(hash_delete(&table_def_cache, (byte*) share)); + VOID(hash_delete(&table_def_cache, (uchar*) share)); } } @@ -7333,10 +7334,10 @@ void mysql_wait_completed_table(ALTER_PARTITION_PARAM_TYPE *lpt, TABLE *my_table key_length=(uint) (strmov(strmov(key,lpt->db)+1,lpt->table_name)-key)+1; VOID(pthread_mutex_lock(&LOCK_open)); HASH_SEARCH_STATE state; - for (table= (TABLE*) hash_first(&open_cache,(byte*) key,key_length, + for (table= (TABLE*) hash_first(&open_cache,(uchar*) key,key_length, &state) ; table; - table= (TABLE*) hash_next(&open_cache,(byte*) key,key_length, + table= (TABLE*) hash_next(&open_cache,(uchar*) key,key_length, &state)) { THD *in_use= table->in_use; diff --git a/sql/sql_binlog.cc b/sql/sql_binlog.cc index d3fdd95707c..77432ce518e 100644 --- a/sql/sql_binlog.cc +++ b/sql/sql_binlog.cc @@ -33,8 +33,8 @@ void mysql_client_binlog_statement(THD* thd) { DBUG_ENTER("mysql_client_binlog_statement"); DBUG_PRINT("info",("binlog base64: '%*s'", - (thd->lex->comment.length < 2048 ? - thd->lex->comment.length : 2048), + (int) (thd->lex->comment.length < 2048 ? + thd->lex->comment.length : 2048), thd->lex->comment.str)); /* @@ -44,8 +44,8 @@ void mysql_client_binlog_statement(THD* thd) my_bool nsok= thd->net.no_send_ok; thd->net.no_send_ok= TRUE; - my_size_t coded_len= thd->lex->comment.length + 1; - my_size_t decoded_len= base64_needed_decoded_length(coded_len); + size_t coded_len= thd->lex->comment.length + 1; + size_t decoded_len= base64_needed_decoded_length(coded_len); DBUG_ASSERT(coded_len > 0); /* diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc index 1ae0e861313..04f142c5dfb 100644 --- a/sql/sql_cache.cc +++ b/sql/sql_cache.cc @@ -365,7 +365,7 @@ TYPELIB query_cache_type_typelib= inline Query_cache_block * Query_cache_block_table::block() { - return (Query_cache_block *)(((byte*)this) - + return (Query_cache_block *)(((uchar*)this) - ALIGN_SIZE(sizeof(Query_cache_block_table)*n) - ALIGN_SIZE(sizeof(Query_cache_block))); } @@ -401,9 +401,9 @@ inline uint Query_cache_block::headers_len() ALIGN_SIZE(sizeof(Query_cache_block))); } -inline gptr Query_cache_block::data(void) +inline uchar* Query_cache_block::data(void) { - return (gptr)( ((byte*)this) + headers_len() ); + return (uchar*)( ((uchar*)this) + headers_len() ); } inline Query_cache_query * Query_cache_block::query() @@ -437,7 +437,7 @@ inline Query_cache_result * Query_cache_block::result() inline Query_cache_block_table * Query_cache_block::table(TABLE_COUNTER_TYPE n) { return ((Query_cache_block_table *) - (((byte*)this)+ALIGN_SIZE(sizeof(Query_cache_block)) + + (((uchar*)this)+ALIGN_SIZE(sizeof(Query_cache_block)) + n*sizeof(Query_cache_block_table))); } @@ -448,13 +448,13 @@ inline Query_cache_block_table * Query_cache_block::table(TABLE_COUNTER_TYPE n) extern "C" { -byte *query_cache_table_get_key(const byte *record, uint *length, +uchar *query_cache_table_get_key(const uchar *record, size_t *length, my_bool not_used __attribute__((unused))) { Query_cache_block* table_block = (Query_cache_block*) record; *length = (table_block->used - table_block->headers_len() - ALIGN_SIZE(sizeof(Query_cache_table))); - return (((byte *) table_block->data()) + + return (((uchar *) table_block->data()) + ALIGN_SIZE(sizeof(Query_cache_table))); } } @@ -522,7 +522,7 @@ void Query_cache_query::init_n_lock() my_rwlock_init(&lock, NULL); lock_writing(); DBUG_PRINT("qcache", ("inited & locked query for block 0x%lx", - (long) (((byte*) this) - + (long) (((uchar*) this) - ALIGN_SIZE(sizeof(Query_cache_block))))); DBUG_VOID_RETURN; } @@ -532,7 +532,7 @@ void Query_cache_query::unlock_n_destroy() { DBUG_ENTER("Query_cache_query::unlock_n_destroy"); DBUG_PRINT("qcache", ("destroyed & unlocked query for block 0x%lx", - (long) (((byte*) this) - + (long) (((uchar*) this) - ALIGN_SIZE(sizeof(Query_cache_block))))); /* The following call is not needed on system where one can destroy an @@ -546,13 +546,13 @@ void Query_cache_query::unlock_n_destroy() extern "C" { -byte *query_cache_query_get_key(const byte *record, uint *length, +uchar *query_cache_query_get_key(const uchar *record, size_t *length, my_bool not_used) { Query_cache_block *query_block = (Query_cache_block*) record; *length = (query_block->used - query_block->headers_len() - ALIGN_SIZE(sizeof(Query_cache_query))); - return (((byte *) query_block->data()) + + return (((uchar *) query_block->data()) + ALIGN_SIZE(sizeof(Query_cache_query))); } } @@ -639,7 +639,7 @@ void query_cache_insert(NET *net, const char *packet, ulong length) done by query_cache.append_result_data if success (if not we need query_cache.structure_guard_mutex locked to free query) */ - if (!query_cache.append_result_data(&result, length, (gptr) packet, + if (!query_cache.append_result_data(&result, length, (uchar*) packet, query_block)) { DBUG_PRINT("warning", ("Can't append data")); @@ -946,13 +946,13 @@ def_week_frmt: %lu", /* Check if another thread is processing the same query? */ Query_cache_block *competitor = (Query_cache_block *) - hash_search(&queries, (byte*) thd->query, tot_length); + hash_search(&queries, (uchar*) thd->query, tot_length); DBUG_PRINT("qcache", ("competitor 0x%lx", (ulong) competitor)); if (competitor == 0) { /* Query is not in cache and no one is working with it; Store it */ Query_cache_block *query_block; - query_block= write_block_data(tot_length, (gptr) thd->query, + query_block= write_block_data(tot_length, (uchar*) thd->query, ALIGN_SIZE(sizeof(Query_cache_query)), Query_cache_block::QUERY, local_tables, 1); if (query_block != 0) @@ -962,7 +962,7 @@ def_week_frmt: %lu", Query_cache_query *header = query_block->query(); header->init_n_lock(); - if (my_hash_insert(&queries, (byte*) query_block)) + if (my_hash_insert(&queries, (uchar*) query_block)) { refused++; DBUG_PRINT("qcache", ("insertion in query hash")); @@ -975,7 +975,7 @@ def_week_frmt: %lu", { refused++; DBUG_PRINT("warning", ("tables list including failed")); - hash_delete(&queries, (byte *) query_block); + hash_delete(&queries, (uchar *) query_block); header->unlock_n_destroy(); free_memory_block(query_block); STRUCT_UNLOCK(&structure_guard_mutex); @@ -984,7 +984,7 @@ def_week_frmt: %lu", double_linked_list_simple_include(query_block, &queries_blocks); inserts++; queries_in_cache++; - net->query_cache_query= (gptr) query_block; + net->query_cache_query= (uchar*) query_block; header->writer(net); header->tables_type(tables_type); @@ -1154,9 +1154,9 @@ def_week_frmt: %lu", flags.group_concat_max_len, flags.div_precision_increment, flags.default_week_format)); - memcpy((void *)(sql + (tot_length - QUERY_CACHE_FLAGS_SIZE)), - &flags, QUERY_CACHE_FLAGS_SIZE); - query_block = (Query_cache_block *) hash_search(&queries, (byte*) sql, + memcpy((uchar *)(sql + (tot_length - QUERY_CACHE_FLAGS_SIZE)), + (uchar*) &flags, QUERY_CACHE_FLAGS_SIZE); + query_block = (Query_cache_block *) hash_search(&queries, (uchar*) sql, tot_length); /* Quick abort on unlocked data */ if (query_block == 0 || @@ -1267,7 +1267,7 @@ def_week_frmt: %lu", ("Handler require invalidation queries of %s.%s %lu-%lu", table_list.db, table_list.alias, (ulong) engine_data, (ulong) table->engine_data())); - invalidate_table((byte *) table->db(), table->key_length()); + invalidate_table((uchar *) table->db(), table->key_length()); } else thd->lex->safe_to_cache_query= 0; // Don't try to cache this @@ -1371,7 +1371,7 @@ void Query_cache::invalidate(CHANGED_TABLE_LIST *tables_used) DUMP(this); for (; tables_used; tables_used= tables_used->next) { - invalidate_table((byte*) tables_used->key, tables_used->key_length); + invalidate_table((uchar*) tables_used->key, tables_used->key_length); DBUG_PRINT("qcache", ("db: %s table: %s", tables_used->key, tables_used->key+ strlen(tables_used->key)+1)); @@ -1452,7 +1452,7 @@ void Query_cache::invalidate(THD *thd, const char *key, uint32 key_length, if (using_transactions) // used for innodb => has_transactions() is TRUE thd->add_changed_table(key, key_length); else - invalidate_table((byte*)key, key_length); + invalidate_table((uchar*)key, key_length); } STRUCT_UNLOCK(&structure_guard_mutex); @@ -1513,8 +1513,8 @@ void Query_cache::invalidate_by_MyISAM_filename(const char *filename) uint key_length= filename_2_table_key(key, filename, &db_length); Query_cache_block *table_block; if ((table_block = (Query_cache_block*) hash_search(&tables, - (byte*) key, - key_length))) + (uchar*) key, + key_length))) invalidate_table(table_block); } STRUCT_UNLOCK(&structure_guard_mutex); @@ -1601,7 +1601,7 @@ ulong Query_cache::init_cache() DBUG_ENTER("Query_cache::init_cache"); approx_additional_data_size = (sizeof(Query_cache) + - sizeof(gptr)*(def_query_hash_size+ + sizeof(uchar*)*(def_query_hash_size+ def_table_hash_size)); if (query_cache_size < approx_additional_data_size) goto err; @@ -1657,7 +1657,7 @@ ulong Query_cache::init_cache() goto err; query_cache_size -= additional_data_size; - if (!(cache= (byte *) + if (!(cache= (uchar *) my_malloc_lock(query_cache_size+additional_data_size, MYF(0)))) goto err; @@ -1796,7 +1796,7 @@ void Query_cache::free_cache() { DBUG_ENTER("Query_cache::free_cache"); - my_free((gptr) cache, MYF(MY_ALLOW_ZERO_PTR)); + my_free((uchar*) cache, MYF(MY_ALLOW_ZERO_PTR)); make_disabled(); hash_free(&queries); hash_free(&tables); @@ -1999,7 +1999,7 @@ void Query_cache::free_query(Query_cache_block *query_block) (ulong) query_block, query_block->query()->length() )); - hash_delete(&queries,(byte *) query_block); + hash_delete(&queries,(uchar *) query_block); free_query_internal(query_block); DBUG_VOID_RETURN; @@ -2010,7 +2010,7 @@ void Query_cache::free_query(Query_cache_block *query_block) *****************************************************************************/ Query_cache_block * -Query_cache::write_block_data(ulong data_len, gptr data, +Query_cache::write_block_data(ulong data_len, uchar* data, ulong header_len, Query_cache_block::block_type type, TABLE_COUNTER_TYPE ntab, @@ -2033,8 +2033,7 @@ Query_cache::write_block_data(ulong data_len, gptr data, block->n_tables = ntab; block->used = len; - memcpy((void*) (((byte *) block)+ all_headers_len), - (void*) data, data_len); + memcpy((uchar *) block+ all_headers_len, data, data_len); } DBUG_RETURN(block); } @@ -2046,7 +2045,7 @@ Query_cache::write_block_data(ulong data_len, gptr data, my_bool Query_cache::append_result_data(Query_cache_block **current_block, - ulong data_len, gptr data, + ulong data_len, uchar* data, Query_cache_block *query_block) { DBUG_ENTER("Query_cache::append_result_data"); @@ -2102,7 +2101,7 @@ Query_cache::append_result_data(Query_cache_block **current_block, by the next call */ success = write_result_data(&new_block, data_len-last_block_free_space, - (gptr)(((byte*)data)+last_block_free_space), + (uchar*)(((uchar*)data)+last_block_free_space), query_block, Query_cache_block::RES_CONT); /* @@ -2124,8 +2123,7 @@ Query_cache::append_result_data(Query_cache_block **current_block, ulong to_copy = min(data_len,last_block_free_space); DBUG_PRINT("qcache", ("use free space %lub at block 0x%lx to copy %lub", last_block_free_space, (ulong)last_block, to_copy)); - memcpy((void*) (((byte*) last_block) + last_block->used), (void*) data, - to_copy); + memcpy((uchar*) last_block + last_block->used, data, to_copy); last_block->used+=to_copy; } DBUG_RETURN(success); @@ -2133,7 +2131,7 @@ Query_cache::append_result_data(Query_cache_block **current_block, my_bool Query_cache::write_result_data(Query_cache_block **result_block, - ulong data_len, gptr data, + ulong data_len, uchar* data, Query_cache_block *query_block, Query_cache_block::block_type type) { @@ -2159,7 +2157,7 @@ my_bool Query_cache::write_result_data(Query_cache_block **result_block, ALIGN_SIZE(sizeof(Query_cache_result))); #ifndef EMBEDDED_LIBRARY Query_cache_block *block= *result_block; - byte *rest= (byte*) data; + uchar *rest= data; // Now fill list of blocks that created by allocate_data_chain do { @@ -2167,7 +2165,7 @@ my_bool Query_cache::write_result_data(Query_cache_block **result_block, ulong length = block->used - headers_len; DBUG_PRINT("qcache", ("write %lu byte in block 0x%lx",length, (ulong)block)); - memcpy((void*)(((byte*) block)+headers_len), (void*) rest, length); + memcpy((uchar*) block+headers_len, rest, length); rest += length; block = block->next; type = Query_cache_block::RES_CONT; @@ -2302,18 +2300,18 @@ void Query_cache::invalidate_table(TABLE_LIST *table_list) // We don't store temporary tables => no key_length+=4 ... if ((table_block = (Query_cache_block*) - hash_search(&tables,(byte*) key,key_length))) + hash_search(&tables,(uchar*) key,key_length))) invalidate_table(table_block); } } void Query_cache::invalidate_table(TABLE *table) { - invalidate_table((byte*) table->s->table_cache_key.str, + invalidate_table((uchar*) table->s->table_cache_key.str, table->s->table_cache_key.length); } -void Query_cache::invalidate_table(byte * key, uint32 key_length) +void Query_cache::invalidate_table(uchar * key, uint32 key_length) { Query_cache_block *table_block; if ((table_block = ((Query_cache_block*) @@ -2391,11 +2389,11 @@ Query_cache::register_tables_from_list(TABLE_LIST *tables_used, else { DBUG_PRINT("qcache", - ("table: %s db: %s openinfo: 0x%lx keylen: %u key: 0x%lx", + ("table: %s db: %s openinfo: 0x%lx keylen: %lu key: 0x%lx", tables_used->table->s->table_name.str, tables_used->table->s->table_cache_key.str, (ulong) tables_used->table, - tables_used->table->s->table_cache_key.length, + (ulong) tables_used->table->s->table_cache_key.length, (ulong) tables_used->table->s->table_cache_key.str)); if (!insert_table(tables_used->table->s->table_cache_key.length, tables_used->table->s->table_cache_key.str, @@ -2492,7 +2490,7 @@ Query_cache::insert_table(uint key_len, char *key, (ulong)node, key_len)); Query_cache_block *table_block = ((Query_cache_block *) - hash_search(&tables, (byte*) key, + hash_search(&tables, (uchar*) key, key_len)); if (table_block && @@ -2516,7 +2514,7 @@ Query_cache::insert_table(uint key_len, char *key, { DBUG_PRINT("qcache", ("new table block from 0x%lx (%u)", (ulong) key, (int) key_len)); - table_block = write_block_data(key_len, (gptr) key, + table_block = write_block_data(key_len, (uchar*) key, ALIGN_SIZE(sizeof(Query_cache_table)), Query_cache_block::TABLE, 1, 1); @@ -2531,7 +2529,7 @@ Query_cache::insert_table(uint key_len, char *key, Query_cache_block_table *list_root = table_block->table(0); list_root->n = 0; list_root->next = list_root->prev = list_root; - if (my_hash_insert(&tables, (const byte *) table_block)) + if (my_hash_insert(&tables, (const uchar *) table_block)) { DBUG_PRINT("qcache", ("Can't insert table to hash")); // write_block_data return locked block @@ -2568,7 +2566,7 @@ void Query_cache::unlink_table(Query_cache_block_table *node) Query_cache_block *table_block = neighbour->block(); double_linked_list_exclude(table_block, &tables_blocks); - hash_delete(&tables,(byte *) table_block); + hash_delete(&tables,(uchar *) table_block); free_memory_block(table_block); } DBUG_VOID_RETURN; @@ -2723,7 +2721,7 @@ void Query_cache::free_memory_block(Query_cache_block *block) void Query_cache::split_block(Query_cache_block *block, ulong len) { DBUG_ENTER("Query_cache::split_block"); - Query_cache_block *new_block = (Query_cache_block*)(((byte*) block)+len); + Query_cache_block *new_block = (Query_cache_block*)(((uchar*) block)+len); new_block->init(block->length - len); total_blocks++; @@ -3156,7 +3154,7 @@ void Query_cache::pack_cache() DBUG_EXECUTE("check_querycache",query_cache.check_integrity(1);); - byte *border = 0; + uchar *border = 0; Query_cache_block *before = 0; ulong gap = 0; my_bool ok = 1; @@ -3192,7 +3190,7 @@ void Query_cache::pack_cache() } -my_bool Query_cache::move_by_type(byte **border, +my_bool Query_cache::move_by_type(uchar **border, Query_cache_block **before, ulong *gap, Query_cache_block *block) { @@ -3205,7 +3203,7 @@ my_bool Query_cache::move_by_type(byte **border, DBUG_PRINT("qcache", ("block 0x%lx FREE", (ulong) block)); if (*border == 0) { - *border = (byte *) block; + *border = (uchar *) block; *before = block->pprev; DBUG_PRINT("qcache", ("gap beginning here")); } @@ -3235,10 +3233,10 @@ my_bool Query_cache::move_by_type(byte **border, *new_block =(Query_cache_block *) *border; uint tablename_offset = block->table()->table() - block->table()->db(); char *data = (char*) block->data(); - byte *key; - uint key_length; - key=query_cache_table_get_key((byte*) block, &key_length, 0); - hash_first(&tables, (byte*) key, key_length, &record_idx); + uchar *key; + size_t key_length; + key=query_cache_table_get_key((uchar*) block, &key_length, 0); + hash_first(&tables, (uchar*) key, key_length, &record_idx); block->destroy(); new_block->init(len); @@ -3272,7 +3270,7 @@ my_bool Query_cache::move_by_type(byte **border, /* Fix pointer to table name */ new_block->table()->table(new_block->table()->db() + tablename_offset); /* Fix hash to point at moved block */ - hash_replace(&tables, &record_idx, (byte*) new_block); + hash_replace(&tables, &record_idx, (uchar*) new_block); DBUG_PRINT("qcache", ("moved %lu bytes to 0x%lx, new gap at 0x%lx", len, (ulong) new_block, (ulong) *border)); @@ -3295,10 +3293,10 @@ my_bool Query_cache::move_by_type(byte **border, char *data = (char*) block->data(); Query_cache_block *first_result_block = ((Query_cache_query *) block->data())->result(); - byte *key; - uint key_length; - key=query_cache_query_get_key((byte*) block, &key_length, 0); - hash_first(&queries, (byte*) key, key_length, &record_idx); + uchar *key; + size_t key_length; + key=query_cache_query_get_key((uchar*) block, &key_length, 0); + hash_first(&queries, (uchar*) key, key_length, &record_idx); // Move table of used tables memmove((char*) new_block->table(0), (char*) block->table(0), ALIGN_SIZE(n_tables*sizeof(Query_cache_block_table))); @@ -3314,7 +3312,7 @@ my_bool Query_cache::move_by_type(byte **border, queries_blocks = new_block; Query_cache_block_table *beg_of_table_table= block->table(0), *end_of_table_table= block->table(n_tables); - byte *beg_of_new_table_table= (byte*) new_block->table(0); + uchar *beg_of_new_table_table= (uchar*) new_block->table(0); for (TABLE_COUNTER_TYPE j=0; j < n_tables; j++) { @@ -3324,8 +3322,8 @@ my_bool Query_cache::move_by_type(byte **border, if ((beg_of_table_table <= block_table->next) && (block_table->next < end_of_table_table)) ((Query_cache_block_table *)(beg_of_new_table_table + - (((byte*)block_table->next) - - ((byte*)beg_of_table_table))))->prev= + (((uchar*)block_table->next) - + ((uchar*)beg_of_table_table))))->prev= block_table; else block_table->next->prev= block_table; @@ -3334,8 +3332,8 @@ my_bool Query_cache::move_by_type(byte **border, if ((beg_of_table_table <= block_table->prev) && (block_table->prev < end_of_table_table)) ((Query_cache_block_table *)(beg_of_new_table_table + - (((byte*)block_table->prev) - - ((byte*)beg_of_table_table))))->next= + (((uchar*)block_table->prev) - + ((uchar*)beg_of_table_table))))->next= block_table; else block_table->prev->next = block_table; @@ -3363,10 +3361,10 @@ my_bool Query_cache::move_by_type(byte **border, NET *net = new_block->query()->writer(); if (net != 0) { - net->query_cache_query= (gptr) new_block; + net->query_cache_query= (uchar*) new_block; } /* Fix hash to point at moved block */ - hash_replace(&queries, &record_idx, (byte*) new_block); + hash_replace(&queries, &record_idx, (uchar*) new_block); DBUG_PRINT("qcache", ("moved %lu bytes to 0x%lx, new gap at 0x%lx", len, (ulong) new_block, (ulong) *border)); break; @@ -3502,7 +3500,7 @@ my_bool Query_cache::join_results(ulong join_limit) Query_cache_result *new_result = new_result_block->result(); new_result->parent(block); - byte *write_to = (byte*) new_result->data(); + uchar *write_to = (uchar*) new_result->data(); Query_cache_block *result_block = first_result; do { @@ -3686,18 +3684,18 @@ void Query_cache::queries_dump() Query_cache_block *block = queries_blocks; do { - uint len; - char *str = (char*) query_cache_query_get_key((byte*) block, &len, 0); + size_t len; + char *str = (char*) query_cache_query_get_key((uchar*) block, &len, 0); len-= QUERY_CACHE_FLAGS_SIZE; // Point at flags Query_cache_query_flags flags; memcpy(&flags, str+len, QUERY_CACHE_FLAGS_SIZE); str[len]= 0; // make zero ending DB name - DBUG_PRINT("qcache", ("F: %u C: %u L: %lu T: '%s' (%u) '%s' '%s'", + DBUG_PRINT("qcache", ("F: %u C: %u L: %lu T: '%s' (%lu) '%s' '%s'", flags.client_long_flag, flags.character_set_client_num, (ulong)flags.limit, flags.time_zone->get_name()->ptr(), - len, str, strend(str)+1)); + (ulong) len, str, strend(str)+1)); DBUG_PRINT("qcache", ("-b- 0x%lx 0x%lx 0x%lx 0x%lx 0x%lx", (ulong) block, (ulong) block->next, (ulong) block->prev, (ulong)block->pnext, (ulong)block->pprev)); @@ -3811,25 +3809,25 @@ my_bool Query_cache::check_integrity(bool locked) // Check memory allocation if (block->pnext == first_block) // Is it last block? { - if (((byte*)block) + block->length != - ((byte*)first_block) + query_cache_size) + if (((uchar*)block) + block->length != + ((uchar*)first_block) + query_cache_size) { DBUG_PRINT("error", ("block 0x%lx, type %u, ended at 0x%lx, but cache ended at 0x%lx", (ulong) block, (uint) block->type, - (ulong) (((byte*)block) + block->length), - (ulong) (((byte*)first_block) + query_cache_size))); + (ulong) (((uchar*)block) + block->length), + (ulong) (((uchar*)first_block) + query_cache_size))); result = 1; } } else - if (((byte*)block) + block->length != ((byte*)block->pnext)) + if (((uchar*)block) + block->length != ((uchar*)block->pnext)) { DBUG_PRINT("error", ("block 0x%lx, type %u, ended at 0x%lx, but next block begining at 0x%lx", (ulong) block, (uint) block->type, - (ulong) (((byte*)block) + block->length), - (ulong) ((byte*)block->pnext))); + (ulong) (((uchar*)block) + block->length), + (ulong) ((uchar*)block->pnext))); } if (block->type == Query_cache_block::FREE) free+= block->length; @@ -3841,8 +3839,8 @@ my_bool Query_cache::check_integrity(bool locked) Query_cache_memory_bin *bin = *((Query_cache_memory_bin **) block->data()); //is it correct pointer? - if (((byte*)bin) < ((byte*)bins) || - ((byte*)bin) >= ((byte*)first_block)) + if (((uchar*)bin) < ((uchar*)bins) || + ((uchar*)bin) >= ((uchar*)first_block)) { DBUG_PRINT("error", ("free block 0x%lx have bin pointer 0x%lx beyaond of bins array bounds [0x%lx,0x%lx]", @@ -3854,7 +3852,7 @@ my_bool Query_cache::check_integrity(bool locked) } else { - int idx = (((byte*)bin) - ((byte*)bins)) / + int idx = (((uchar*)bin) - ((uchar*)bins)) / sizeof(Query_cache_memory_bin); if (in_list(bins[idx].free_blocks, block, "free memory")) result = 1; @@ -3876,7 +3874,7 @@ my_bool Query_cache::check_integrity(bool locked) Query_cache_block_table *block_table = block->table(j); Query_cache_block_table *block_table_root = (Query_cache_block_table *) - (((byte*)block_table->parent) - + (((uchar*)block_table->parent) - ALIGN_SIZE(sizeof(Query_cache_block_table))); if (in_table_list(block_table, block_table_root, "table list")) @@ -3892,15 +3890,15 @@ my_bool Query_cache::check_integrity(bool locked) case Query_cache_block::RESULT: { Query_cache_block * query_block = block->result()->parent(); - if (((byte*)query_block) < ((byte*)first_block) || - ((byte*)query_block) >= (((byte*)first_block) + query_cache_size)) + if (((uchar*)query_block) < ((uchar*)first_block) || + ((uchar*)query_block) >= (((uchar*)first_block) + query_cache_size)) { DBUG_PRINT("error", ("result block 0x%lx have query block pointer 0x%lx beyaond of block pool bounds [0x%lx,0x%lx]", (ulong) block, (ulong) query_block, (ulong) first_block, - (ulong) (((byte*)first_block) + query_cache_size))); + (ulong) (((uchar*)first_block) + query_cache_size))); result = 1; } else @@ -3947,10 +3945,10 @@ my_bool Query_cache::check_integrity(bool locked) { DBUG_PRINT("qcache", ("block 0x%lx, type %u...", (ulong) block, (uint) block->type)); - uint length; - byte *key = query_cache_query_get_key((byte*) block, &length, 0); - gptr val = hash_search(&queries, key, length); - if (((gptr)block) != val) + size_t length; + uchar *key = query_cache_query_get_key((uchar*) block, &length, 0); + uchar* val = hash_search(&queries, key, length); + if (((uchar*)block) != val) { DBUG_PRINT("error", ("block 0x%lx found in queries hash like 0x%lx", (ulong) block, (ulong) val)); @@ -3982,10 +3980,10 @@ my_bool Query_cache::check_integrity(bool locked) { DBUG_PRINT("qcache", ("block 0x%lx, type %u...", (ulong) block, (uint) block->type)); - uint length; - byte *key = query_cache_table_get_key((byte*) block, &length, 0); - gptr val = hash_search(&tables, key, length); - if (((gptr)block) != val) + size_t length; + uchar *key = query_cache_table_get_key((uchar*) block, &length, 0); + uchar* val = hash_search(&tables, key, length); + if (((uchar*)block) != val) { DBUG_PRINT("error", ("block 0x%lx found in tables hash like 0x%lx", (ulong) block, (ulong) val)); diff --git a/sql/sql_cache.h b/sql/sql_cache.h index bc00f7ea629..3c5d784ce94 100644 --- a/sql/sql_cache.h +++ b/sql/sql_cache.h @@ -98,7 +98,7 @@ struct Query_cache_block void init(ulong length); void destroy(); inline uint headers_len(); - inline gptr data(void); + inline uchar* data(void); inline Query_cache_query *query(); inline Query_cache_table *table(); inline Query_cache_result *result(); @@ -128,17 +128,15 @@ struct Query_cache_query inline ulong length() { return len; } inline ulong add(ulong packet_len) { return(len+= packet_len); } inline void length(ulong length_arg) { len= length_arg; } - inline gptr query() + inline uchar* query() { - return (gptr)(((byte*)this)+ - ALIGN_SIZE(sizeof(Query_cache_query))); + return (((uchar*)this) + ALIGN_SIZE(sizeof(Query_cache_query))); } void lock_writing(); void lock_reading(); my_bool try_lock_writing(); void unlock_writing(); void unlock_reading(); - static byte *cache_key(const byte *record, uint *length, my_bool not_used); }; @@ -164,9 +162,9 @@ struct Query_cache_table inline void callback(qc_engine_callback fn){ callback_func= fn; } inline ulonglong engine_data() { return engine_data_buff; } inline void engine_data(ulonglong data_arg){ engine_data_buff= data_arg; } - inline gptr data() + inline uchar* data() { - return (gptr)(((byte*)this)+ + return (uchar*)(((uchar*)this)+ ALIGN_SIZE(sizeof(Query_cache_table))); } }; @@ -176,9 +174,9 @@ struct Query_cache_result Query_cache_result() {} /* Remove gcc warning */ Query_cache_block *query; - inline gptr data() + inline uchar* data() { - return (gptr)(((byte*) this)+ + return (uchar*)(((uchar*) this)+ ALIGN_SIZE(sizeof(Query_cache_result))); } /* data_continue (if not whole packet contained by this block) */ @@ -189,10 +187,10 @@ struct Query_cache_result extern "C" { - byte *query_cache_query_get_key(const byte *record, uint *length, - my_bool not_used); - byte *query_cache_table_get_key(const byte *record, uint *length, - my_bool not_used); + uchar *query_cache_query_get_key(const uchar *record, size_t *length, + my_bool not_used); + uchar *query_cache_table_get_key(const uchar *record, size_t *length, + my_bool not_used); } extern "C" void query_cache_invalidate_by_MyISAM_filename(const char* filename); @@ -261,7 +259,7 @@ protected: till the end of a flush operation. */ pthread_mutex_t structure_guard_mutex; - byte *cache; // cache memory + uchar *cache; // cache memory Query_cache_block *first_block; // physical location block list Query_cache_block *queries_blocks; // query list (LIFO) Query_cache_block *tables_blocks; @@ -299,7 +297,7 @@ protected: my_bool first_block); void invalidate_table(TABLE_LIST *table); void invalidate_table(TABLE *table); - void invalidate_table(byte *key, uint32 key_length); + void invalidate_table(uchar *key, uint32 key_length); void invalidate_table(Query_cache_block *table_block); TABLE_COUNTER_TYPE register_tables_from_list(TABLE_LIST *tables_used, @@ -324,7 +322,7 @@ protected: ulong add_size); void exclude_from_free_memory_list(Query_cache_block *free_block); void insert_into_free_memory_list(Query_cache_block *new_block); - my_bool move_by_type(byte **border, Query_cache_block **before, + my_bool move_by_type(uchar **border, Query_cache_block **before, ulong *gap, Query_cache_block *i); uint find_bin(ulong size); void move_to_query_list_end(Query_cache_block *block); @@ -346,16 +344,16 @@ protected: ulong init_cache(); void make_disabled(); void free_cache(); - Query_cache_block *write_block_data(ulong data_len, gptr data, + Query_cache_block *write_block_data(ulong data_len, uchar* data, ulong header_len, Query_cache_block::block_type type, TABLE_COUNTER_TYPE ntab = 0, my_bool under_guard=0); my_bool append_result_data(Query_cache_block **result, - ulong data_len, gptr data, + ulong data_len, uchar* data, Query_cache_block *parent); my_bool write_result_data(Query_cache_block **result, - ulong data_len, gptr data, + ulong data_len, uchar* data, Query_cache_block *parent, Query_cache_block::block_type type=Query_cache_block::RESULT); diff --git a/sql/sql_class.cc b/sql/sql_class.cc index 018425099bb..9dbc79344a9 100644 --- a/sql/sql_class.cc +++ b/sql/sql_class.cc @@ -71,11 +71,11 @@ template class List_iterator<Alter_column>; ** User variables ****************************************************************************/ -extern "C" byte *get_var_key(user_var_entry *entry, uint *length, - my_bool not_used __attribute__((unused))) +extern "C" uchar *get_var_key(user_var_entry *entry, size_t *length, + my_bool not_used __attribute__((unused))) { - *length=(uint) entry->name.length; - return (byte*) entry->name.str; + *length= entry->name.length; + return (uchar*) entry->name.str; } extern "C" void free_user_var(user_var_entry *entry) @@ -679,7 +679,7 @@ THD::~THD() void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var) { - ulong *end= (ulong*) ((byte*) to_var + + ulong *end= (ulong*) ((uchar*) to_var + offsetof(STATUS_VAR, last_system_status_var) + sizeof(ulong)); ulong *to= (ulong*) to_var, *from= (ulong*) from_var; @@ -704,7 +704,7 @@ void add_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var) void add_diff_to_status(STATUS_VAR *to_var, STATUS_VAR *from_var, STATUS_VAR *dec_var) { - ulong *end= (ulong*) ((byte*) to_var + offsetof(STATUS_VAR, + ulong *end= (ulong*) ((uchar*) to_var + offsetof(STATUS_VAR, last_system_status_var) + sizeof(ulong)); ulong *to= (ulong*) to_var, *from= (ulong*) from_var, *dec= (ulong*) dec_var; @@ -875,9 +875,9 @@ bool THD::convert_string(LEX_STRING *to, CHARSET_INFO *to_cs, CHARSET_INFO *from_cs) { DBUG_ENTER("convert_string"); - size_s new_length= to_cs->mbmaxlen * from_length; + size_t new_length= to_cs->mbmaxlen * from_length; uint dummy_errors; - if (!(to->str= alloc(new_length+1))) + if (!(to->str= (char*) alloc(new_length+1))) { to->length= 0; // Safety fix DBUG_RETURN(1); // EOM @@ -961,7 +961,7 @@ void THD::add_changed_table(TABLE *table) DBUG_ASSERT((options & (OPTION_NOT_AUTOCOMMIT | OPTION_BEGIN)) && table->file->has_transactions()); add_changed_table(table->s->table_cache_key.str, - table->s->table_cache_key.length); + (long) table->s->table_cache_key.length); DBUG_VOID_RETURN; } @@ -1021,8 +1021,7 @@ CHANGED_TABLE_LIST* THD::changed_table_dup(const char *key, long key_length) return 0; } - new_table->key = (char *) (((byte*)new_table)+ - ALIGN_SIZE(sizeof(CHANGED_TABLE_LIST))); + new_table->key= ((char*)new_table)+ ALIGN_SIZE(sizeof(CHANGED_TABLE_LIST)); new_table->next = 0; new_table->key_length = key_length; ::memcpy(new_table->key, key, key_length); @@ -1476,7 +1475,7 @@ bool select_export::send_data(List<Item> &items) uint used_length=0,items_left=items.elements; List_iterator_fast<Item> li(items); - if (my_b_write(&cache,(byte*) exchange->line_start->ptr(), + if (my_b_write(&cache,(uchar*) exchange->line_start->ptr(), exchange->line_start->length())) goto err; while ((item=li++)) @@ -1485,7 +1484,7 @@ bool select_export::send_data(List<Item> &items) res=item->str_result(&tmp); if (res && (!exchange->opt_enclosed || result_type == STRING_RESULT)) { - if (my_b_write(&cache,(byte*) exchange->enclosed->ptr(), + if (my_b_write(&cache,(uchar*) exchange->enclosed->ptr(), exchange->enclosed->length())) goto err; } @@ -1497,10 +1496,10 @@ bool select_export::send_data(List<Item> &items) { null_buff[0]=escape_char; null_buff[1]='N'; - if (my_b_write(&cache,(byte*) null_buff,2)) + if (my_b_write(&cache,(uchar*) null_buff,2)) goto err; } - else if (my_b_write(&cache,(byte*) "NULL",4)) + else if (my_b_write(&cache,(uchar*) "NULL",4)) goto err; } else @@ -1540,16 +1539,16 @@ bool select_export::send_data(List<Item> &items) char tmp_buff[2]; tmp_buff[0]= escape_char; tmp_buff[1]= *pos ? *pos : '0'; - if (my_b_write(&cache,(byte*) start,(uint) (pos-start)) || - my_b_write(&cache,(byte*) tmp_buff,2)) + if (my_b_write(&cache,(uchar*) start,(uint) (pos-start)) || + my_b_write(&cache,(uchar*) tmp_buff,2)) goto err; start=pos+1; } } - if (my_b_write(&cache,(byte*) start,(uint) (pos-start))) + if (my_b_write(&cache,(uchar*) start,(uint) (pos-start))) goto err; } - else if (my_b_write(&cache,(byte*) res->ptr(),used_length)) + else if (my_b_write(&cache,(uchar*) res->ptr(),used_length)) goto err; } if (fixed_row_size) @@ -1565,27 +1564,27 @@ bool select_export::send_data(List<Item> &items) uint length=item->max_length-used_length; for (; length > sizeof(space) ; length-=sizeof(space)) { - if (my_b_write(&cache,(byte*) space,sizeof(space))) + if (my_b_write(&cache,(uchar*) space,sizeof(space))) goto err; } - if (my_b_write(&cache,(byte*) space,length)) + if (my_b_write(&cache,(uchar*) space,length)) goto err; } } if (res && (!exchange->opt_enclosed || result_type == STRING_RESULT)) { - if (my_b_write(&cache, (byte*) exchange->enclosed->ptr(), + if (my_b_write(&cache, (uchar*) exchange->enclosed->ptr(), exchange->enclosed->length())) goto err; } if (--items_left) { - if (my_b_write(&cache, (byte*) exchange->field_term->ptr(), + if (my_b_write(&cache, (uchar*) exchange->field_term->ptr(), field_term_length)) goto err; } } - if (my_b_write(&cache,(byte*) exchange->line_term->ptr(), + if (my_b_write(&cache,(uchar*) exchange->line_term->ptr(), exchange->line_term->length())) goto err; DBUG_RETURN(0); @@ -1632,10 +1631,10 @@ bool select_dump::send_data(List<Item> &items) res=item->str_result(&tmp); if (!res) // If NULL { - if (my_b_write(&cache,(byte*) "",1)) + if (my_b_write(&cache,(uchar*) "",1)) goto err; } - else if (my_b_write(&cache,(byte*) res->ptr(),res->length())) + else if (my_b_write(&cache,(uchar*) res->ptr(),res->length())) { my_error(ER_ERROR_ON_WRITE, MYF(0), path, my_errno); goto err; @@ -1970,13 +1969,13 @@ Statement::~Statement() C_MODE_START -static byte * -get_statement_id_as_hash_key(const byte *record, uint *key_length, +static uchar * +get_statement_id_as_hash_key(const uchar *record, size_t *key_length, my_bool not_used __attribute__((unused))) { const Statement *statement= (const Statement *) record; *key_length= sizeof(statement->id); - return (byte *) &((const Statement *) statement)->id; + return (uchar *) &((const Statement *) statement)->id; } static void delete_statement_as_hash_key(void *key) @@ -1984,11 +1983,11 @@ static void delete_statement_as_hash_key(void *key) delete (Statement *) key; } -static byte *get_stmt_name_hash_key(Statement *entry, uint *length, +static uchar *get_stmt_name_hash_key(Statement *entry, size_t *length, my_bool not_used __attribute__((unused))) { - *length=(uint) entry->name.length; - return (byte*) entry->name.str; + *length= entry->name.length; + return (uchar*) entry->name.str; } C_MODE_END @@ -2033,7 +2032,7 @@ Statement_map::Statement_map() : int Statement_map::insert(THD *thd, Statement *statement) { - if (my_hash_insert(&st_hash, (byte*) statement)) + if (my_hash_insert(&st_hash, (uchar*) statement)) { /* Delete is needed only in case of an insert failure. In all other @@ -2043,7 +2042,7 @@ int Statement_map::insert(THD *thd, Statement *statement) my_error(ER_OUT_OF_RESOURCES, MYF(0)); goto err_st_hash; } - if (statement->name.str && my_hash_insert(&names_hash, (byte*) statement)) + if (statement->name.str && my_hash_insert(&names_hash, (uchar*) statement)) { my_error(ER_OUT_OF_RESOURCES, MYF(0)); goto err_names_hash; @@ -2071,9 +2070,9 @@ int Statement_map::insert(THD *thd, Statement *statement) err_max: if (statement->name.str) - hash_delete(&names_hash, (byte*) statement); + hash_delete(&names_hash, (uchar*) statement); err_names_hash: - hash_delete(&st_hash, (byte*) statement); + hash_delete(&st_hash, (uchar*) statement); err_st_hash: return 1; } @@ -2094,9 +2093,9 @@ void Statement_map::erase(Statement *statement) if (statement == last_found_statement) last_found_statement= 0; if (statement->name.str) - hash_delete(&names_hash, (byte *) statement); + hash_delete(&names_hash, (uchar *) statement); - hash_delete(&st_hash, (byte *) statement); + hash_delete(&st_hash, (uchar *) statement); pthread_mutex_lock(&LOCK_prepared_stmt_count); DBUG_ASSERT(prepared_stmt_count > 0); prepared_stmt_count--; @@ -2511,7 +2510,7 @@ void THD::restore_sub_statement_state(Sub_statement_state *backup) pthread_mutex_t LOCK_xid_cache; HASH xid_cache; -static byte *xid_get_hash_key(const byte *ptr,uint *length, +static uchar *xid_get_hash_key(const uchar *ptr, size_t *length, my_bool not_used __attribute__((unused))) { *length=((XID_STATE*)ptr)->xid.key_length(); @@ -2521,7 +2520,7 @@ static byte *xid_get_hash_key(const byte *ptr,uint *length, static void xid_free_hash (void *ptr) { if (!((XID_STATE*)ptr)->in_thd) - my_free((gptr)ptr, MYF(0)); + my_free((uchar*)ptr, MYF(0)); } bool xid_cache_init() @@ -2563,7 +2562,7 @@ bool xid_cache_insert(XID *xid, enum xa_states xa_state) xs->xa_state=xa_state; xs->xid.set(xid); xs->in_thd=0; - res=my_hash_insert(&xid_cache, (byte*)xs); + res=my_hash_insert(&xid_cache, (uchar*)xs); } pthread_mutex_unlock(&LOCK_xid_cache); return res; @@ -2575,7 +2574,7 @@ bool xid_cache_insert(XID_STATE *xid_state) pthread_mutex_lock(&LOCK_xid_cache); DBUG_ASSERT(hash_search(&xid_cache, xid_state->xid.key(), xid_state->xid.key_length())==0); - my_bool res=my_hash_insert(&xid_cache, (byte*)xid_state); + my_bool res=my_hash_insert(&xid_cache, (uchar*)xid_state); pthread_mutex_unlock(&LOCK_xid_cache); return res; } @@ -2584,7 +2583,7 @@ bool xid_cache_insert(XID_STATE *xid_state) void xid_cache_delete(XID_STATE *xid_state) { pthread_mutex_lock(&LOCK_xid_cache); - hash_delete(&xid_cache, (byte *)xid_state); + hash_delete(&xid_cache, (uchar *)xid_state); pthread_mutex_unlock(&LOCK_xid_cache); } @@ -2620,8 +2619,8 @@ void xid_cache_delete(XID_STATE *xid_state) template <class RowsEventT> Rows_log_event* THD::binlog_prepare_pending_rows_event(TABLE* table, uint32 serv_id, MY_BITMAP const* cols, - my_size_t colcnt, - my_size_t needed, + size_t colcnt, + size_t needed, bool is_transactional, RowsEventT *hint __attribute__((unused))) { @@ -2691,17 +2690,17 @@ THD::binlog_prepare_pending_rows_event(TABLE* table, uint32 serv_id, */ template Rows_log_event* THD::binlog_prepare_pending_rows_event(TABLE*, uint32, MY_BITMAP const*, - my_size_t, my_size_t, bool, + size_t, size_t, bool, Write_rows_log_event*); template Rows_log_event* THD::binlog_prepare_pending_rows_event(TABLE*, uint32, MY_BITMAP const*, - my_size_t colcnt, my_size_t, bool, + size_t colcnt, size_t, bool, Delete_rows_log_event *); template Rows_log_event* THD::binlog_prepare_pending_rows_event(TABLE*, uint32, MY_BITMAP const*, - my_size_t colcnt, my_size_t, bool, + size_t colcnt, size_t, bool, Update_rows_log_event *); #endif @@ -2770,27 +2769,6 @@ field_type_name(enum_field_types type) #endif -my_size_t THD::max_row_length_blob(TABLE *table, const byte *data) const -{ - my_size_t length= 0; - TABLE_SHARE *table_s= table->s; - uint* const beg= table_s->blob_field; - uint* const end= beg + table_s->blob_fields; - - for (uint *ptr= beg ; ptr != end ; ++ptr) - { - Field_blob* const blob= (Field_blob*) table->field[*ptr]; - length+= blob->get_length((const char*) (data + - blob->offset(table->record[0]))) + - HA_KEY_BLOB_LENGTH; - } - - return length; -} - - - - namespace { /** Class to handle temporary allocation of memory for row data. @@ -2819,7 +2797,7 @@ namespace { @param length Length of data that is needed, if the record contain blobs. */ - Row_data_memory(TABLE *table, my_size_t const len1) + Row_data_memory(TABLE *table, size_t const len1) : m_memory(0) { #ifndef DBUG_OFF @@ -2830,7 +2808,7 @@ namespace { m_ptr[1]= 0; } - Row_data_memory(TABLE *table, my_size_t const len1, my_size_t const len2) + Row_data_memory(TABLE *table, size_t const len1, size_t const len2) : m_memory(0) { #ifndef DBUG_OFF @@ -2844,7 +2822,7 @@ namespace { ~Row_data_memory() { if (m_memory != 0 && m_release_memory_on_destruction) - my_free((gptr) m_memory, MYF(MY_WME)); + my_free((uchar*) m_memory, MYF(MY_WME)); } /** @@ -2860,7 +2838,7 @@ namespace { return m_memory != 0; } - byte *slot(uint s) + uchar *slot(uint s) { DBUG_ASSERT(s < sizeof(m_ptr)/sizeof(*m_ptr)); DBUG_ASSERT(m_ptr[s] != 0); @@ -2869,7 +2847,7 @@ namespace { } private: - void allocate_memory(TABLE *const table, my_size_t const total_length) + void allocate_memory(TABLE *const table, size_t const total_length) { if (table->s->blob_fields == 0) { @@ -2883,7 +2861,7 @@ namespace { to add two bytes for each field, which can potentially be added to hold the length of a packed field. */ - my_size_t const maxlen= table->s->reclength + 2 * table->s->fields; + size_t const maxlen= table->s->reclength + 2 * table->s->fields; /* Allocate memory for two records if memory hasn't been @@ -2892,13 +2870,13 @@ namespace { */ if (table->write_row_record == 0) table->write_row_record= - (byte *) alloc_root(&table->mem_root, 2 * maxlen); + (uchar *) alloc_root(&table->mem_root, 2 * maxlen); m_memory= table->write_row_record; m_release_memory_on_destruction= FALSE; } else { - m_memory= (byte *) my_malloc(total_length, MYF(MY_WME)); + m_memory= (uchar *) my_malloc(total_length, MYF(MY_WME)); m_release_memory_on_destruction= TRUE; } } @@ -2907,15 +2885,15 @@ namespace { mutable bool m_alloc_checked; #endif bool m_release_memory_on_destruction; - byte *m_memory; - byte *m_ptr[2]; + uchar *m_memory; + uchar *m_ptr[2]; }; } int THD::binlog_write_row(TABLE* table, bool is_trans, - MY_BITMAP const* cols, my_size_t colcnt, - byte const *record) + MY_BITMAP const* cols, size_t colcnt, + uchar const *record) { DBUG_ASSERT(current_stmt_binlog_row_based && mysql_bin_log.is_open()); @@ -2927,9 +2905,9 @@ int THD::binlog_write_row(TABLE* table, bool is_trans, if (!memory.has_memory()) return HA_ERR_OUT_OF_MEM; - byte *row_data= memory.slot(0); + uchar *row_data= memory.slot(0); - my_size_t const len= pack_row(table, cols, row_data, record); + size_t const len= pack_row(table, cols, row_data, record); Rows_log_event* const ev= binlog_prepare_pending_rows_event(table, server_id, cols, colcnt, @@ -2943,25 +2921,25 @@ int THD::binlog_write_row(TABLE* table, bool is_trans, } int THD::binlog_update_row(TABLE* table, bool is_trans, - MY_BITMAP const* cols, my_size_t colcnt, - const byte *before_record, - const byte *after_record) + MY_BITMAP const* cols, size_t colcnt, + const uchar *before_record, + const uchar *after_record) { DBUG_ASSERT(current_stmt_binlog_row_based && mysql_bin_log.is_open()); - my_size_t const before_maxlen = max_row_length(table, before_record); - my_size_t const after_maxlen = max_row_length(table, after_record); + size_t const before_maxlen = max_row_length(table, before_record); + size_t const after_maxlen = max_row_length(table, after_record); Row_data_memory row_data(table, before_maxlen, after_maxlen); if (!row_data.has_memory()) return HA_ERR_OUT_OF_MEM; - byte *before_row= row_data.slot(0); - byte *after_row= row_data.slot(1); + uchar *before_row= row_data.slot(0); + uchar *after_row= row_data.slot(1); - my_size_t const before_size= pack_row(table, cols, before_row, + size_t const before_size= pack_row(table, cols, before_row, before_record); - my_size_t const after_size= pack_row(table, cols, after_row, + size_t const after_size= pack_row(table, cols, after_row, after_record); /* @@ -2969,10 +2947,10 @@ int THD::binlog_update_row(TABLE* table, bool is_trans, trigger false warnings. */ #ifndef HAVE_purify - DBUG_DUMP("before_record", (const char *)before_record, table->s->reclength); - DBUG_DUMP("after_record", (const char *)after_record, table->s->reclength); - DBUG_DUMP("before_row", (const char *)before_row, before_size); - DBUG_DUMP("after_row", (const char *)after_row, after_size); + DBUG_DUMP("before_record", before_record, table->s->reclength); + DBUG_DUMP("after_record", after_record, table->s->reclength); + DBUG_DUMP("before_row", before_row, before_size); + DBUG_DUMP("after_row", after_row, after_size); #endif Rows_log_event* const ev= @@ -2989,8 +2967,8 @@ int THD::binlog_update_row(TABLE* table, bool is_trans, } int THD::binlog_delete_row(TABLE* table, bool is_trans, - MY_BITMAP const* cols, my_size_t colcnt, - byte const *record) + MY_BITMAP const* cols, size_t colcnt, + uchar const *record) { DBUG_ASSERT(current_stmt_binlog_row_based && mysql_bin_log.is_open()); @@ -3002,9 +2980,9 @@ int THD::binlog_delete_row(TABLE* table, bool is_trans, if (unlikely(!memory.has_memory())) return HA_ERR_OUT_OF_MEM; - byte *row_data= memory.slot(0); + uchar *row_data= memory.slot(0); - my_size_t const len= pack_row(table, cols, row_data, record); + size_t const len= pack_row(table, cols, row_data, record); Rows_log_event* const ev= binlog_prepare_pending_rows_event(table, server_id, cols, colcnt, diff --git a/sql/sql_class.h b/sql/sql_class.h index a0b1402d060..7729b597098 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -472,30 +472,31 @@ public: inline bool is_conventional() const { return state == CONVENTIONAL_EXECUTION; } - inline gptr alloc(unsigned int size) { return alloc_root(mem_root,size); } - inline gptr calloc(unsigned int size) + inline void* alloc(size_t size) { return alloc_root(mem_root,size); } + inline void* calloc(size_t size) { - gptr ptr; + void *ptr; if ((ptr=alloc_root(mem_root,size))) - bzero((char*) ptr,size); + bzero(ptr, size); return ptr; } inline char *strdup(const char *str) { return strdup_root(mem_root,str); } - inline char *strmake(const char *str, uint size) + inline char *strmake(const char *str, size_t size) { return strmake_root(mem_root,str,size); } - inline bool LEX_STRING_make(LEX_STRING *lex_str, const char *str, uint size) + inline bool LEX_STRING_make(LEX_STRING *lex_str, const char *str, + size_t size) { return ((lex_str->str= strmake_root(mem_root, str, (lex_str->length= size)))) == 0; } - inline char *memdup(const char *str, uint size) + inline void *memdup(const void *str, size_t size) { return memdup_root(mem_root,str,size); } - inline char *memdup_w_gap(const char *str, uint size, uint gap) + inline void *memdup_w_gap(const void *str, size_t size, uint gap) { - gptr ptr; - if ((ptr=alloc_root(mem_root,size+gap))) + void *ptr; + if ((ptr= alloc_root(mem_root,size+gap))) memcpy(ptr,str,size); return ptr; } @@ -617,7 +618,7 @@ public: Statement *find_by_name(LEX_STRING *name) { Statement *stmt; - stmt= (Statement*)hash_search(&names_hash, (byte*)name->str, + stmt= (Statement*)hash_search(&names_hash, (uchar*)name->str, name->length); return stmt; } @@ -627,7 +628,7 @@ public: if (last_found_statement == 0 || id != last_found_statement->id) { Statement *stmt; - stmt= (Statement *) hash_search(&st_hash, (byte *) &id, sizeof(id)); + stmt= (Statement *) hash_search(&st_hash, (uchar *) &id, sizeof(id)); if (stmt && stmt->name.str) return NULL; last_found_statement= stmt; @@ -1070,14 +1071,14 @@ public: void binlog_set_stmt_begin(); int binlog_write_table_map(TABLE *table, bool is_transactional); int binlog_write_row(TABLE* table, bool is_transactional, - MY_BITMAP const* cols, my_size_t colcnt, - const byte *buf); + MY_BITMAP const* cols, size_t colcnt, + const uchar *buf); int binlog_delete_row(TABLE* table, bool is_transactional, - MY_BITMAP const* cols, my_size_t colcnt, - const byte *buf); + MY_BITMAP const* cols, size_t colcnt, + const uchar *buf); int binlog_update_row(TABLE* table, bool is_transactional, - MY_BITMAP const* cols, my_size_t colcnt, - const byte *old_data, const byte *new_data); + MY_BITMAP const* cols, size_t colcnt, + const uchar *old_data, const uchar *new_data); void set_server_id(uint32 sid) { server_id = sid; } @@ -1087,24 +1088,12 @@ public: template <class RowsEventT> Rows_log_event* binlog_prepare_pending_rows_event(TABLE* table, uint32 serv_id, MY_BITMAP const* cols, - my_size_t colcnt, - my_size_t needed, + size_t colcnt, + size_t needed, bool is_transactional, RowsEventT* hint); Rows_log_event* binlog_get_pending_rows_event() const; void binlog_set_pending_rows_event(Rows_log_event* ev); - - my_size_t max_row_length_blob(TABLE* table, const byte *data) const; - my_size_t max_row_length(TABLE* table, const byte *data) const - { - TABLE_SHARE *table_s= table->s; - my_size_t length= table_s->reclength + 2 * table_s->fields; - if (table_s->blob_fields == 0) - return length; - - return (length+max_row_length_blob(table,data)); - } - int binlog_flush_pending_rows_event(bool stmt_end); void binlog_delete_pending_rows_event(); @@ -1584,7 +1573,7 @@ public: { return !stmt_arena->is_stmt_prepare(); } - inline gptr trans_alloc(unsigned int size) + inline void* trans_alloc(unsigned int size) { return alloc_root(&transaction.mem_root,size); } @@ -1736,7 +1725,7 @@ public: This way the user will notice the error as there will be no current database selected (in addition to the error message set by malloc). */ - bool set_db(const char *new_db, uint new_db_len) + bool set_db(const char *new_db, size_t new_db_len) { /* Do not reallocate memory if current chunk is big enough. */ if (db && new_db && db_length >= new_db_len) @@ -1749,7 +1738,7 @@ public: db_length= db ? new_db_len : 0; return new_db && !db; } - void reset_db(char *new_db, uint new_db_len) + void reset_db(char *new_db, size_t new_db_len) { db= new_db; db_length= new_db_len; @@ -1759,7 +1748,7 @@ public: allocate memory for a deep copy: current database may be freed after a statement is parsed but before it's executed. */ - bool copy_db_to(char **p_db, uint *p_db_length) + bool copy_db_to(char **p_db, size_t *p_db_length) { if (db == NULL) { @@ -2038,7 +2027,7 @@ public: List<Item> save_copy_funcs; Copy_field *copy_field, *copy_field_end; Copy_field *save_copy_field, *save_copy_field_end; - byte *group_buff; + uchar *group_buff; Item **items_to_copy; /* Fields in tmp table */ MI_COLUMNDEF *recinfo,*start_recinfo; KEY *keyinfo; @@ -2244,7 +2233,7 @@ class Unique :public Sql_alloc ulonglong max_in_memory_size; IO_CACHE file; TREE tree; - byte *record_pointers; + uchar *record_pointers; bool flush(); uint size; @@ -2277,8 +2266,8 @@ public: void reset(); bool walk(tree_walk_action action, void *walk_action_arg); - friend int unique_write_to_file(gptr key, element_count count, Unique *unique); - friend int unique_write_to_ptrs(gptr key, element_count count, Unique *unique); + friend int unique_write_to_file(uchar* key, element_count count, Unique *unique); + friend int unique_write_to_ptrs(uchar* key, element_count count, Unique *unique); }; diff --git a/sql/sql_connect.cc b/sql/sql_connect.cc index 6c07c6ba6d5..d23c9bb3454 100644 --- a/sql/sql_connect.cc +++ b/sql/sql_connect.cc @@ -80,7 +80,7 @@ static int get_or_create_user_conn(THD *thd, const char *user, temp_len= (strmov(strmov(temp_user, user)+1, host) - temp_user)+1; (void) pthread_mutex_lock(&LOCK_user_conn); if (!(uc = (struct user_conn *) hash_search(&hash_user_connections, - (byte*) temp_user, temp_len))) + (uchar*) temp_user, temp_len))) { /* First connection for user; Create a user connection object */ if (!(uc= ((struct user_conn*) @@ -98,7 +98,7 @@ static int get_or_create_user_conn(THD *thd, const char *user, uc->connections= uc->questions= uc->updates= uc->conn_per_hour= 0; uc->user_resources= *mqh; uc->intime= thd->thr_create_time; - if (my_hash_insert(&hash_user_connections, (byte*) uc)) + if (my_hash_insert(&hash_user_connections, (uchar*) uc)) { my_free((char*) uc,0); net_send_error(thd, 0, NullS); // Out of memory @@ -200,7 +200,7 @@ void decrease_user_connections(USER_CONN *uc) if (!--uc->connections && !mqh_used) { /* Last connection for user; Delete it */ - (void) hash_delete(&hash_user_connections,(byte*) uc); + (void) hash_delete(&hash_user_connections,(uchar*) uc); } (void) pthread_mutex_unlock(&LOCK_user_conn); DBUG_VOID_RETURN; @@ -512,11 +512,11 @@ int check_user(THD *thd, enum enum_server_command command, started with corresponding variable that is greater then 0. */ -extern "C" byte *get_key_conn(user_conn *buff, uint *length, +extern "C" uchar *get_key_conn(user_conn *buff, size_t *length, my_bool not_used __attribute__((unused))) { - *length=buff->len; - return (byte*) buff->user; + *length= buff->len; + return (uchar*) buff->user; } @@ -559,7 +559,7 @@ void reset_mqh(LEX_USER *lu, bool get_them= 0) memcpy(temp_user+lu->user.length+1,lu->host.str,lu->host.length); temp_user[lu->user.length]='\0'; temp_user[temp_len-1]=0; if ((uc = (struct user_conn *) hash_search(&hash_user_connections, - (byte*) temp_user, temp_len))) + (uchar*) temp_user, temp_len))) { uc->questions=0; get_mqh(temp_user,&temp_user[lu->user.length+1],uc); @@ -747,8 +747,8 @@ static int check_connection(THD *thd) SCRAMBLE_LENGTH - SCRAMBLE_LENGTH_323) + 1; /* At this point we write connection message and read reply */ - if (net_write_command(net, (uchar) protocol_version, "", 0, buff, - (uint) (end-buff)) || + if (net_write_command(net, (uchar) protocol_version, (uchar*) "", 0, + (uchar*) buff, (size_t) (end-buff)) || (pkt_len= my_net_read(net)) == packet_error || pkt_len < MIN_HANDSHAKE_SIZE) { diff --git a/sql/sql_db.cc b/sql/sql_db.cc index a8f7eaa6394..82938184245 100644 --- a/sql/sql_db.cc +++ b/sql/sql_db.cc @@ -59,11 +59,11 @@ typedef struct my_dblock_st lock_db key. */ -static byte* lock_db_get_key(my_dblock_t *ptr, uint *length, - my_bool not_used __attribute__((unused))) +static uchar* lock_db_get_key(my_dblock_t *ptr, size_t *length, + my_bool not_used __attribute__((unused))) { *length= ptr->name_length; - return (byte*) ptr->name; + return (uchar*) ptr->name; } @@ -73,7 +73,7 @@ static byte* lock_db_get_key(my_dblock_t *ptr, uint *length, static void lock_db_free_element(void *ptr) { - my_free((gptr) ptr, MYF(0)); + my_free(ptr, MYF(0)); } @@ -98,12 +98,12 @@ static my_bool lock_db_insert(const char *dbname, uint length) safe_mutex_assert_owner(&LOCK_lock_db); if (!(opt= (my_dblock_t*) hash_search(&lock_db_cache, - (byte*) dbname, length))) + (uchar*) dbname, length))) { /* Db is not in the hash, insert it */ char *tmp_name; if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL), - &opt, (uint) sizeof(*opt), &tmp_name, length+1, + &opt, (uint) sizeof(*opt), &tmp_name, (uint) length+1, NullS)) { error= 1; @@ -114,11 +114,8 @@ static my_bool lock_db_insert(const char *dbname, uint length) strmov(opt->name, dbname); opt->name_length= length; - if ((error= my_hash_insert(&lock_db_cache, (byte*) opt))) - { - my_free((gptr) opt, MYF(0)); - goto end; - } + if ((error= my_hash_insert(&lock_db_cache, (uchar*) opt))) + my_free(opt, MYF(0)); } end: @@ -135,8 +132,8 @@ void lock_db_delete(const char *name, uint length) my_dblock_t *opt; safe_mutex_assert_owner(&LOCK_lock_db); if ((opt= (my_dblock_t *)hash_search(&lock_db_cache, - (const byte*) name, length))) - hash_delete(&lock_db_cache, (byte*) opt); + (const uchar*) name, length))) + hash_delete(&lock_db_cache, (uchar*) opt); } @@ -158,11 +155,11 @@ typedef struct my_dbopt_st Function we use in the creation of our hash to get key. */ -static byte* dboptions_get_key(my_dbopt_t *opt, uint *length, - my_bool not_used __attribute__((unused))) +static uchar* dboptions_get_key(my_dbopt_t *opt, size_t *length, + my_bool not_used __attribute__((unused))) { *length= opt->name_length; - return (byte*) opt->name; + return (uchar*) opt->name; } @@ -187,7 +184,7 @@ static inline void write_to_binlog(THD *thd, char *query, uint q_len, static void free_dbopt(void *dbopt) { - my_free((gptr) dbopt, MYF(0)); + my_free((uchar*) dbopt, MYF(0)); } @@ -280,7 +277,7 @@ static my_bool get_dbopt(const char *dbname, HA_CREATE_INFO *create) length= (uint) strlen(dbname); rw_rdlock(&LOCK_dboptions); - if ((opt= (my_dbopt_t*) hash_search(&dboptions, (byte*) dbname, length))) + if ((opt= (my_dbopt_t*) hash_search(&dboptions, (uchar*) dbname, length))) { create->default_table_charset= opt->charset; error= 0; @@ -312,12 +309,12 @@ static my_bool put_dbopt(const char *dbname, HA_CREATE_INFO *create) length= (uint) strlen(dbname); rw_wrlock(&LOCK_dboptions); - if (!(opt= (my_dbopt_t*) hash_search(&dboptions, (byte*) dbname, length))) + if (!(opt= (my_dbopt_t*) hash_search(&dboptions, (uchar*) dbname, length))) { /* Options are not in the hash, insert them */ char *tmp_name; if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL), - &opt, (uint) sizeof(*opt), &tmp_name, length+1, + &opt, (uint) sizeof(*opt), &tmp_name, (uint) length+1, NullS)) { error= 1; @@ -328,9 +325,9 @@ static my_bool put_dbopt(const char *dbname, HA_CREATE_INFO *create) strmov(opt->name, dbname); opt->name_length= length; - if ((error= my_hash_insert(&dboptions, (byte*) opt))) + if ((error= my_hash_insert(&dboptions, (uchar*) opt))) { - my_free((gptr) opt, MYF(0)); + my_free(opt, MYF(0)); goto end; } } @@ -352,9 +349,9 @@ void del_dbopt(const char *path) { my_dbopt_t *opt; rw_wrlock(&LOCK_dboptions); - if ((opt= (my_dbopt_t *)hash_search(&dboptions, (const byte*) path, + if ((opt= (my_dbopt_t *)hash_search(&dboptions, (const uchar*) path, strlen(path)))) - hash_delete(&dboptions, (byte*) opt); + hash_delete(&dboptions, (uchar*) opt); rw_unlock(&LOCK_dboptions); } @@ -392,7 +389,7 @@ static bool write_db_opt(THD *thd, const char *path, HA_CREATE_INFO *create) "\n", NullS) - buf); /* Error is written by my_write */ - if (!my_write(file,(byte*) buf, length, MYF(MY_NABP+MY_WME))) + if (!my_write(file,(uchar*) buf, length, MYF(MY_NABP+MY_WME))) error=0; my_close(file,MYF(0)); } @@ -920,7 +917,7 @@ bool mysql_rm_db(THD *thd,char *db,bool if_exists, bool silent) TABLE_LIST *tbl; uint db_len; - if (!(query= thd->alloc(MAX_DROP_TABLE_Q_LEN))) + if (!(query= (char*) thd->alloc(MAX_DROP_TABLE_Q_LEN))) goto exit; /* not much else we can do */ query_pos= query_data_start= strmov(query,"drop table "); query_end= query + MAX_DROP_TABLE_Q_LEN; @@ -1021,7 +1018,7 @@ static long mysql_rm_known_files(THD *thd, MY_DIR *dirp, const char *db, DBUG_PRINT("my",("New subdir found: %s", newpath)); if ((mysql_rm_known_files(thd, new_dirp, NullS, newpath,1,0)) < 0) goto err; - if (!(copy_of_path= thd->memdup(newpath, length+1)) || + if (!(copy_of_path= (char*) thd->memdup(newpath, length+1)) || !(dir= new (thd->mem_root) String(copy_of_path, length, &my_charset_bin)) || raid_dirs.push_back(dir)) @@ -1511,8 +1508,8 @@ lock_databases(THD *thd, const char *db1, uint length1, { pthread_mutex_lock(&LOCK_lock_db); while (!thd->killed && - (hash_search(&lock_db_cache,(byte*) db1, length1) || - hash_search(&lock_db_cache,(byte*) db2, length2))) + (hash_search(&lock_db_cache,(uchar*) db1, length1) || + hash_search(&lock_db_cache,(uchar*) db2, length2))) { wait_for_condition(thd, &LOCK_lock_db, &COND_refresh); pthread_mutex_lock(&LOCK_lock_db); @@ -1654,7 +1651,7 @@ bool mysql_rename_db(THD *thd, LEX_STRING *old_db, LEX_STRING *new_db) table_str.length= filename_to_tablename(file->name, tname, sizeof(tname)-1); - table_str.str= sql_memdup(tname, table_str.length + 1); + table_str.str= (char*) sql_memdup(tname, table_str.length + 1); Table_ident *old_ident= new Table_ident(thd, *old_db, table_str, 0); Table_ident *new_ident= new Table_ident(thd, *new_db, table_str, 0); if (!old_ident || !new_ident || diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index a0bcca3e238..fe54a12e4dc 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -438,7 +438,7 @@ bool mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds) extern "C" int refpos_order_cmp(void* arg, const void *a,const void *b) { handler *file= (handler*)arg; - return file->cmp_ref((const byte*)a, (const byte*)b); + return file->cmp_ref((const uchar*)a, (const uchar*)b); } /* diff --git a/sql/sql_handler.cc b/sql/sql_handler.cc index aaca6373f37..300ec7f3c62 100644 --- a/sql/sql_handler.cc +++ b/sql/sql_handler.cc @@ -92,7 +92,7 @@ static int mysql_ha_flush_table(THD *thd, TABLE **table_ptr, uint mode_flags); Pointer to the TABLE_LIST struct. */ -static char *mysql_ha_hash_get_key(TABLE_LIST *tables, uint *key_len_p, +static char *mysql_ha_hash_get_key(TABLE_LIST *tables, size_t *key_len_p, my_bool first __attribute__((unused))) { *key_len_p= strlen(tables->alias) + 1 ; /* include '\0' in comparisons */ @@ -167,7 +167,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen) } else if (! reopen) /* Otherwise we have 'tables' already. */ { - if (hash_search(&thd->handler_tables_hash, (byte*) tables->alias, + if (hash_search(&thd->handler_tables_hash, (uchar*) tables->alias, strlen(tables->alias) + 1)) { DBUG_PRINT("info",("duplicate '%s'", tables->alias)); @@ -208,10 +208,10 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen) namelen= strlen(tables->table_name) + 1; aliaslen= strlen(tables->alias) + 1; if (!(my_multi_malloc(MYF(MY_WME), - &hash_tables, sizeof(*hash_tables), - &db, dblen, - &name, namelen, - &alias, aliaslen, + &hash_tables, (uint) sizeof(*hash_tables), + &db, (uint) dblen, + &name, (uint) namelen, + &alias, (uint) aliaslen, NullS))) goto err; /* structure copy */ @@ -224,7 +224,7 @@ bool mysql_ha_open(THD *thd, TABLE_LIST *tables, bool reopen) memcpy(hash_tables->alias, tables->alias, aliaslen); /* add to hash */ - if (my_hash_insert(&thd->handler_tables_hash, (byte*) hash_tables)) + if (my_hash_insert(&thd->handler_tables_hash, (uchar*) hash_tables)) { my_free((char*) hash_tables, MYF(0)); mysql_ha_close(thd, tables); @@ -270,7 +270,7 @@ bool mysql_ha_close(THD *thd, TABLE_LIST *tables) tables->db, tables->table_name, tables->alias)); if ((hash_tables= (TABLE_LIST*) hash_search(&thd->handler_tables_hash, - (byte*) tables->alias, + (uchar*) tables->alias, strlen(tables->alias) + 1))) { /* @@ -295,7 +295,7 @@ bool mysql_ha_close(THD *thd, TABLE_LIST *tables) } VOID(pthread_mutex_unlock(&LOCK_open)); } - hash_delete(&thd->handler_tables_hash, (byte*) hash_tables); + hash_delete(&thd->handler_tables_hash, (uchar*) hash_tables); } else { @@ -345,7 +345,7 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables, String buffer(buff, sizeof(buff), system_charset_info); int error, keyno= -1; uint num_rows; - byte *key; + uchar *key; uint key_len; bool not_used; DBUG_ENTER("mysql_ha_read"); @@ -362,7 +362,7 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables, it++; if ((hash_tables= (TABLE_LIST*) hash_search(&thd->handler_tables_hash, - (byte*) tables->alias, + (uchar*) tables->alias, strlen(tables->alias) + 1))) { table= hash_tables->table; @@ -536,7 +536,7 @@ bool mysql_ha_read(THD *thd, TABLE_LIST *tables, keypart_map= (keypart_map << 1) | 1; } - if (!(key= (byte*) thd->calloc(ALIGN_SIZE(key_len)))) + if (!(key= (uchar*) thd->calloc(ALIGN_SIZE(key_len)))) goto err; table->file->ha_index_or_rnd_end(); table->file->ha_index_init(keyno, 1); @@ -732,13 +732,13 @@ static int mysql_ha_flush_table(THD *thd, TABLE **table_ptr, uint mode_flags) table->alias, mode_flags)); if ((hash_tables= (TABLE_LIST*) hash_search(&thd->handler_tables_hash, - (byte*) table->alias, + (uchar*) table->alias, strlen(table->alias) + 1))) { if (! (mode_flags & MYSQL_HA_REOPEN_ON_USAGE)) { /* This is a final close. Remove from hash. */ - hash_delete(&thd->handler_tables_hash, (byte*) hash_tables); + hash_delete(&thd->handler_tables_hash, (uchar*) hash_tables); } else { @@ -791,7 +791,7 @@ void mysql_ha_mark_tables_for_reopen(THD *thd, TABLE *table) { TABLE_LIST *hash_tables; if ((hash_tables= (TABLE_LIST*) hash_search(&thd->handler_tables_hash, - (byte*) table->alias, + (uchar*) table->alias, strlen(table->alias) + 1))) { /* Mark table as ready for reopen. */ diff --git a/sql/sql_help.cc b/sql/sql_help.cc index 79d658c2a85..023bd1fec94 100644 --- a/sql/sql_help.cc +++ b/sql/sql_help.cc @@ -272,7 +272,7 @@ int get_topics_for_keyword(THD *thd, TABLE *topics, TABLE *relations, List<String> *names, String *name, String *description, String *example) { - char buff[8]; // Max int length + uchar buff[8]; // Max int length int count= 0; int iindex_topic, iindex_relations; Field *rtopic_id, *rkey_id; @@ -295,20 +295,20 @@ int get_topics_for_keyword(THD *thd, TABLE *topics, TABLE *relations, rkey_id->store((longlong) key_id, TRUE); rkey_id->get_key_image(buff, rkey_id->pack_length(), Field::itRAW); int key_res= relations->file->index_read(relations->record[0], - (byte *) buff, (key_part_map)1, + buff, (key_part_map) 1, HA_READ_KEY_EXACT); for ( ; !key_res && key_id == (int16) rkey_id->val_int() ; key_res= relations->file->index_next(relations->record[0])) { - char topic_id_buff[8]; + uchar topic_id_buff[8]; longlong topic_id= rtopic_id->val_int(); Field *field= find_fields[help_topic_help_topic_id].field; field->store((longlong) topic_id, TRUE); field->get_key_image(topic_id_buff, field->pack_length(), Field::itRAW); - if (!topics->file->index_read(topics->record[0], (byte *)topic_id_buff, + if (!topics->file->index_read(topics->record[0], topic_id_buff, (key_part_map)1, HA_READ_KEY_EXACT)) { memorize_variant_topic(thd,topics,count,find_fields, @@ -637,7 +637,7 @@ bool mysqld_help(THD *thd, const char *mask) MEM_ROOT *mem_root= thd->mem_root; DBUG_ENTER("mysqld_help"); - bzero((gptr)tables,sizeof(tables)); + bzero((uchar*)tables,sizeof(tables)); tables[0].alias= tables[0].table_name= (char*) "help_topic"; tables[0].lock_type= TL_READ; tables[0].next_global= tables[0].next_local= diff --git a/sql/sql_insert.cc b/sql/sql_insert.cc index 5fd0ec669bd..9067df2f014 100644 --- a/sql/sql_insert.cc +++ b/sql/sql_insert.cc @@ -1380,9 +1380,9 @@ int write_record(THD *thd, TABLE *table,COPY_INFO *info) goto err; } } - key_copy((byte*) key,table->record[0],table->key_info+key_nr,0); + key_copy((uchar*) key,table->record[0],table->key_info+key_nr,0); if ((error=(table->file->index_read_idx(table->record[1],key_nr, - (byte*) key, HA_WHOLE_KEY, + (uchar*) key, HA_WHOLE_KEY, HA_READ_KEY_EXACT)))) goto err; } @@ -1853,8 +1853,8 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list) thd->proc_info="got old table"; if (tmp->thd.killed) { - if (tmp->thd.net.report_error) - { + if (tmp->thd.net.report_error) + { /* Copy the error message. Note that we don't treat fatal errors in the delayed thread as fatal errors in the @@ -1870,7 +1870,7 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list) if (thd->killed) { tmp->unlock(); - goto end_create; + goto end_create; } } pthread_mutex_unlock(&LOCK_delayed_create); @@ -1886,7 +1886,7 @@ bool delayed_get_table(THD *thd, TABLE_LIST *table_list) } /* Unlock the delayed insert object after its last access. */ tmp->unlock(); - DBUG_RETURN(table_list->table == NULL); + DBUG_RETURN((table_list->table == NULL)); end_create: pthread_mutex_unlock(&LOCK_delayed_create); @@ -1916,7 +1916,7 @@ TABLE *Delayed_insert::get_local_table(THD* client_thd) Field **field,**org_field, *found_next_number_field; TABLE *copy; TABLE_SHARE *share= table->s; - byte *bitmap; + uchar *bitmap; DBUG_ENTER("Delayed_insert::get_local_table"); /* First request insert thread to get a lock */ @@ -1960,7 +1960,7 @@ TABLE *Delayed_insert::get_local_table(THD* client_thd) /* We don't need to change the file handler here */ /* Assign the pointers for the field pointers array and the record. */ field= copy->field= (Field**) (copy + 1); - bitmap= (byte*) (field + share->fields + 1); + bitmap= (uchar*) (field + share->fields + 1); copy->record[0]= (bitmap + share->column_bitmap_size * 2); memcpy((char*) copy->record[0], (char*) table->record[0], share->reclength); /* @@ -2029,7 +2029,8 @@ int write_delayed(THD *thd, TABLE *table, enum_duplicates duplic, Delayed_insert *di=thd->di; const Discrete_interval *forced_auto_inc; DBUG_ENTER("write_delayed"); - DBUG_PRINT("enter", ("query = '%s' length %u", query.str, query.length)); + DBUG_PRINT("enter", ("query = '%s' length %lu", query.str, + (ulong) query.length)); thd->proc_info="waiting for handler insert"; pthread_mutex_lock(&di->mutex); @@ -2416,7 +2417,7 @@ static void free_delayed_insert_blobs(register TABLE *table) { if ((*ptr)->flags & BLOB_FLAG) { - char *str; + uchar *str; ((Field_blob *) (*ptr))->get_ptr(&str); my_free(str,MYF(MY_ALLOW_ZERO_PTR)); ((Field_blob *) (*ptr))->reset(); @@ -2478,8 +2479,9 @@ bool Delayed_insert::handle_inserts(void) use values from the previous interval (of the previous rows). */ bool log_query= (row->log_query && row->query.str != NULL); - DBUG_PRINT("delayed", ("query: '%s' length: %u", row->query.str ? - row->query.str : "[NULL]", row->query.length)); + DBUG_PRINT("delayed", ("query: '%s' length: %lu", row->query.str ? + row->query.str : "[NULL]", + (ulong) row->query.length)); if (log_query) { /* @@ -2811,7 +2813,7 @@ select_insert::prepare(List<Item> &values, SELECT_LEX_UNIT *u) while ((item= li++)) { item->transform(&Item::update_value_transformer, - (byte*)lex->current_select); + (uchar*)lex->current_select); } } @@ -3286,7 +3288,6 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, create_info, alter_info, 0, select_field_count)) { - if (create_info->table_existed && !(create_info->options & HA_LEX_CREATE_TMP_TABLE)) { @@ -3328,7 +3329,6 @@ static TABLE *create_table_from_items(THD *thd, HA_CREATE_INFO *create_info, close_temporary_table(thd, create_table); } } - } reenable_binlog(thd); if (!table) // open failed diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index c19c224f0a3..d8846d3fc9d 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -1266,7 +1266,7 @@ void st_select_lex::init_select() linkage= UNSPECIFIED_TYPE; order_list.elements= 0; order_list.first= 0; - order_list.next= (byte**) &order_list.first; + order_list.next= (uchar**) &order_list.first; /* Set limit and offset to default values */ select_limit= 0; /* denotes the default limit = HA_POS_ERROR */ offset_limit= 0; /* denotes the default offset = 0 */ @@ -2088,7 +2088,7 @@ TABLE_LIST *st_lex::unlink_first_table(bool *link_to_local) { select_lex.context.table_list= select_lex.context.first_name_resolution_table= first->next_local; - select_lex.table_list.first= (byte*) (first->next_local); + select_lex.table_list.first= (uchar*) (first->next_local); select_lex.table_list.elements--; //safety first->next_local= 0; /* @@ -2169,7 +2169,7 @@ void st_lex::link_first_table_back(TABLE_LIST *first, { first->next_local= (TABLE_LIST*) select_lex.table_list.first; select_lex.context.table_list= first; - select_lex.table_list.first= (byte*) first; + select_lex.table_list.first= (uchar*) first; select_lex.table_list.elements++; //safety } } diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 68a3092cd77..6d96dded088 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -221,7 +221,7 @@ enum tablespace_op_type Keep in sync with index_hint_type. */ extern const char * index_hint_type_name[]; -typedef byte index_clause_map; +typedef uchar index_clause_map; /* Bits in index_clause_map : one for each possible FOR clause in @@ -409,7 +409,7 @@ public: static void *operator new(size_t size) { - return (void*) sql_alloc((uint) size); + return sql_alloc(size); } static void *operator new(size_t size, MEM_ROOT *mem_root) { return (void*) alloc_root(mem_root, (uint) size); } @@ -733,7 +733,7 @@ public: { order_list.elements= 0; order_list.first= 0; - order_list.next= (byte**) &order_list.first; + order_list.next= (uchar**) &order_list.first; } /* This method created for reiniting LEX in mysql_admin_table() and can be @@ -947,7 +947,7 @@ public: in which it was right after query parsing. */ SQL_LIST sroutines_list; - byte **sroutines_list_own_last; + uchar **sroutines_list_own_last; uint sroutines_list_own_elements; /* @@ -1111,7 +1111,7 @@ typedef struct st_lex : public Query_tables_list LEX_STRING comment, ident; LEX_USER *grant_user; XID *xid; - gptr yacc_yyss,yacc_yyvs; + uchar* yacc_yyss, *yacc_yyvs; THD *thd; /* maintain a list of used plugins for this LEX */ @@ -1400,7 +1400,7 @@ struct st_lex_local: public st_lex { static void *operator new(size_t size) { - return (void*) sql_alloc((uint) size); + return sql_alloc(size); } static void *operator new(size_t size, MEM_ROOT *mem_root) { diff --git a/sql/sql_list.h b/sql/sql_list.h index 486e297bd67..2e068f7f961 100644 --- a/sql/sql_list.h +++ b/sql/sql_list.h @@ -27,16 +27,16 @@ class Sql_alloc public: static void *operator new(size_t size) throw () { - return (void*) sql_alloc((uint) size); + return sql_alloc(size); } static void *operator new[](size_t size) { - return (void*) sql_alloc((uint) size); + return sql_alloc(size); } static void *operator new[](size_t size, MEM_ROOT *mem_root) throw () - { return (void*) alloc_root(mem_root, (uint) size); } + { return alloc_root(mem_root, size); } static void *operator new(size_t size, MEM_ROOT *mem_root) throw () - { return (void*) alloc_root(mem_root, (uint) size); } + { return alloc_root(mem_root, size); } static void operator delete(void *ptr, size_t size) { TRASH(ptr, size); } static void operator delete(void *ptr, MEM_ROOT *mem_root) { /* never called */ } @@ -456,7 +456,7 @@ struct ilink } static void operator delete(void* ptr_arg, size_t size) { - my_free((gptr)ptr_arg, MYF(MY_WME|MY_ALLOW_ZERO_PTR)); + my_free((uchar*)ptr_arg, MYF(MY_WME|MY_ALLOW_ZERO_PTR)); } inline ilink() diff --git a/sql/sql_load.cc b/sql/sql_load.cc index 5c7a29df33b..0138030487b 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -25,7 +25,7 @@ class READ_INFO { File file; - byte *buffer, /* Buffer for read text */ + uchar *buffer, /* Buffer for read text */ *end_of_buff; /* Data in bufferts ends here */ uint buff_length, /* Length of buffert */ max_length; /* Max length of row */ @@ -40,7 +40,7 @@ class READ_INFO { public: bool error,line_cuted,found_null,enclosed; - byte *row_start, /* Found row starts here */ + uchar *row_start, /* Found row starts here */ *row_end; /* Found row ends here */ CHARSET_INFO *read_charset; @@ -576,7 +576,7 @@ read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, continue; } it.rewind(); - byte *pos=read_info.row_start; + uchar *pos=read_info.row_start; #ifdef HAVE_purify read_info.row_end[0]=0; #endif @@ -611,7 +611,7 @@ read_fixed_length(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, else { uint length; - byte save_chr; + uchar save_chr; if ((length=(uint) (read_info.row_end-pos)) > field->field_length) length=field->field_length; @@ -705,7 +705,7 @@ read_sep_field(THD *thd, COPY_INFO &info, TABLE_LIST *table_list, while ((item= it++)) { uint length; - byte *pos; + uchar *pos; if (read_info.read_field()) break; @@ -914,7 +914,7 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, CHARSET_INFO *cs, set_if_bigger(length,line_start.length()); stack=stack_pos=(int*) sql_alloc(sizeof(int)*length); - if (!(buffer=(byte*) my_malloc(buff_length+1,MYF(0)))) + if (!(buffer=(uchar*) my_malloc(buff_length+1,MYF(0)))) error=1; /* purecov: inspected */ else { @@ -924,7 +924,7 @@ READ_INFO::READ_INFO(File file_par, uint tot_length, CHARSET_INFO *cs, (is_fifo ? READ_FIFO : READ_CACHE),0L,1, MYF(MY_WME))) { - my_free((gptr) buffer,MYF(0)); /* purecov: inspected */ + my_free((uchar*) buffer,MYF(0)); /* purecov: inspected */ error=1; } else @@ -955,7 +955,7 @@ READ_INFO::~READ_INFO() { if (need_end_io_cache) ::end_io_cache(&cache); - my_free((gptr) buffer,MYF(0)); + my_free((uchar*) buffer,MYF(0)); error=1; } } @@ -988,7 +988,7 @@ inline int READ_INFO::terminator(char *ptr,uint length) int READ_INFO::read_field() { int chr,found_enclosed_char; - byte *to,*new_buffer; + uchar *to,*new_buffer; found_null=0; if (found_end_of_line) @@ -1011,7 +1011,7 @@ int READ_INFO::read_field() if (chr == enclosed_char) { found_enclosed_char=enclosed_char; - *to++=(byte) chr; // If error + *to++=(uchar) chr; // If error } else { @@ -1053,7 +1053,7 @@ int READ_INFO::read_field() { if ((chr=GET) == my_b_EOF) { - *to++= (byte) escape_char; + *to++= (uchar) escape_char; goto found_eof; } /* @@ -1065,7 +1065,7 @@ int READ_INFO::read_field() */ if (escape_char != enclosed_char || chr == escape_char) { - *to++ = (byte) unescape((char) chr); + *to++ = (uchar) unescape((char) chr); continue; } PUSH(chr); @@ -1090,7 +1090,7 @@ int READ_INFO::read_field() { if ((chr=GET) == found_enclosed_char) { // Remove dupplicated - *to++ = (byte) chr; + *to++ = (uchar) chr; continue; } // End of enclosed field if followed by field_term or line_term @@ -1130,12 +1130,12 @@ int READ_INFO::read_field() return 0; } } - *to++ = (byte) chr; + *to++ = (uchar) chr; } /* ** We come here if buffer is too small. Enlarge it and continue */ - if (!(new_buffer=(byte*) my_realloc((char*) buffer,buff_length+1+IO_SIZE, + if (!(new_buffer=(uchar*) my_realloc((char*) buffer,buff_length+1+IO_SIZE, MYF(MY_WME)))) return (error=1); to=new_buffer + (to-buffer); @@ -1170,7 +1170,7 @@ found_eof: int READ_INFO::read_fixed_length() { int chr; - byte *to; + uchar *to; if (found_end_of_line) return 1; // One have to call next_line @@ -1190,10 +1190,10 @@ int READ_INFO::read_fixed_length() { if ((chr=GET) == my_b_EOF) { - *to++= (byte) escape_char; + *to++= (uchar) escape_char; goto found_eof; } - *to++ =(byte) unescape((char) chr); + *to++ =(uchar) unescape((char) chr); continue; } if (chr == line_term_char) @@ -1205,7 +1205,7 @@ int READ_INFO::read_fixed_length() return 0; } } - *to++ = (byte) chr; + *to++ = (uchar) chr; } row_end=to; // Found full line return 0; @@ -1236,7 +1236,7 @@ int READ_INFO::next_line() #ifdef USE_MB if (my_mbcharlen(read_charset, chr) > 1) { - for (int i=1; + for (uint i=1; chr != my_b_EOF && i<my_mbcharlen(read_charset, chr); i++) chr = GET; diff --git a/sql/sql_manager.cc b/sql/sql_manager.cc index b0ca7667a62..171ab55145a 100644 --- a/sql/sql_manager.cc +++ b/sql/sql_manager.cc @@ -118,7 +118,7 @@ pthread_handler_t handle_manager(void *arg __attribute__((unused))) { struct handler_cb *next= cb->next; cb->action(); - my_free((gptr)cb, MYF(0)); + my_free((uchar*)cb, MYF(0)); cb= next; } diff --git a/sql/sql_map.cc b/sql/sql_map.cc index 36a47f1aefc..7b707f813fc 100644 --- a/sql/sql_map.cc +++ b/sql/sql_map.cc @@ -24,7 +24,7 @@ #include <sys/mman.h> #endif -mapped_files::mapped_files(const my_string filename,byte *magic,uint magic_length) +mapped_files::mapped_files(const char * filename,uchar *magic,uint magic_length) { #ifdef HAVE_MMAP name=my_strdup(filename,MYF(0)); @@ -37,18 +37,18 @@ mapped_files::mapped_files(const my_string filename,byte *magic,uint magic_lengt struct stat stat_buf; if (!fstat(file,&stat_buf)) { - if (!(map=(byte*) my_mmap(0,(size=(ulong) stat_buf.st_size),PROT_READ, + if (!(map=(uchar*) my_mmap(0,(size=(ulong) stat_buf.st_size),PROT_READ, MAP_SHARED | MAP_NORESERVE,file, 0L))) { error=errno; - my_error(ER_NO_FILE_MAPPING, MYF(0), (my_string) name, error); + my_error(ER_NO_FILE_MAPPING, MYF(0), (char *) name, error); } } if (map && memcmp(map,magic,magic_length)) { my_error(ER_WRONG_MAGIC, MYF(0), name); - VOID(my_munmap(map,size)); + VOID(my_munmap((char*) map,size)); map=0; } if (!map) @@ -66,7 +66,7 @@ mapped_files::~mapped_files() #ifdef HAVE_MMAP if (file >= 0) { - VOID(my_munmap(map,size)); + VOID(my_munmap((char*) map,size)); VOID(my_close(file,MYF(0))); file= -1; map=0; } @@ -82,7 +82,7 @@ static I_List<mapped_files> maps_in_use; ** else alloc new object */ -mapped_files *map_file(const my_string name,byte *magic,uint magic_length) +mapped_files *map_file(const char * name,uchar *magic,uint magic_length) { #ifdef HAVE_MMAP VOID(pthread_mutex_lock(&LOCK_mapped_file)); diff --git a/sql/sql_map.h b/sql/sql_map.h index d8eb64995aa..a1efba0da6f 100644 --- a/sql/sql_map.h +++ b/sql/sql_map.h @@ -21,11 +21,11 @@ #endif class mapped_files; -mapped_files *map_file(const my_string name,byte *magic,uint magic_length); +mapped_files *map_file(const char * name,uchar *magic,uint magic_length); void unmap_file(mapped_files *map); class mapped_files :public ilink { - byte *map; + uchar *map; ha_rows size; char *name; // name of mapped file File file; // >= 0 if open @@ -33,11 +33,11 @@ class mapped_files :public ilink { uint use_count; public: - mapped_files(const my_string name,byte *magic,uint magic_length); + mapped_files(const char * name,uchar *magic,uint magic_length); ~mapped_files(); friend class mapped_file; - friend mapped_files *map_file(const my_string name,byte *magic, + friend mapped_files *map_file(const char * name,uchar *magic, uint magic_length); friend void unmap_file(mapped_files *map); }; @@ -47,7 +47,7 @@ class mapped_file { mapped_files *file; public: - mapped_file(const my_string name,byte *magic,uint magic_length) + mapped_file(const char * name,uchar *magic,uint magic_length) { file=map_file(name,magic,magic_length); /* old or new map */ } @@ -55,7 +55,7 @@ public: { unmap_file(file); /* free map */ } - byte *map() + uchar *map() { return file->map; } diff --git a/sql/sql_olap.cc b/sql/sql_olap.cc index 818825d566b..dccfcbaf8ac 100644 --- a/sql/sql_olap.cc +++ b/sql/sql_olap.cc @@ -54,8 +54,8 @@ static int make_new_olap_select(LEX *lex, SELECT_LEX *select_lex, List<Item> new new_select->linkage=OLAP_TYPE; new_select->olap=NON_EXISTING_ONE; new_select->group_list.elements=0; - new_select->group_list.first=(byte *)0; - new_select->group_list.next=(byte **)&new_select->group_list.first; + new_select->group_list.first=(uchar *)0; + new_select->group_list.next=(uchar **)&new_select->group_list.first; List<Item> privlist; List_iterator<Item> list_it(select_lex->item_list); diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 9222f9f49db..8e55610df36 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -193,7 +193,7 @@ uint sql_command_flags[SQLCOM_END+1]; void init_update_queries(void) { - bzero((gptr) &sql_command_flags, sizeof(sql_command_flags)); + bzero((uchar*) &sql_command_flags, sizeof(sql_command_flags)); sql_command_flags[SQLCOM_CREATE_TABLE]= CF_CHANGES_DATA; sql_command_flags[SQLCOM_CREATE_INDEX]= CF_CHANGES_DATA; @@ -372,8 +372,9 @@ pthread_handler_t handle_bootstrap(void *arg) continue; thd->query_length=length; - thd->query= thd->memdup_w_gap(buff, length+1, - thd->db_length+1+QUERY_CACHE_FLAGS_SIZE); + thd->query= (char*) thd->memdup_w_gap(buff, length+1, + thd->db_length+1+ + QUERY_CACHE_FLAGS_SIZE); thd->query[length] = '\0'; DBUG_PRINT("query",("%-.4096s",thd->query)); /* @@ -759,13 +760,13 @@ bool dispatch_command(enum enum_server_command command, THD *thd, status_var_increment(thd->status_var.com_other); thd->enable_slow_log= opt_log_slow_admin_statements; - db.str= thd->alloc(db_len + tbl_len + 2); - db.length= db_len; + db.str= (char*) thd->alloc(db_len + tbl_len + 2); if (!db.str) { my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0)); break; } + db.length= db_len; tbl_name= strmake(db.str, packet + 1, db_len)+1; strmake(tbl_name, packet + db_len + 2, tbl_len); mysql_table_dump(thd, &db, tbl_name); @@ -853,8 +854,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd, if (save_user_connect) decrease_user_connections(save_user_connect); #endif /* NO_EMBEDDED_ACCESS_CHECKS */ - x_free((gptr) save_db); - x_free((gptr) save_security_ctx.user); + x_free((uchar*) save_db); + x_free((uchar*) save_security_ctx.user); } break; } @@ -951,7 +952,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, /* Locked closure of all tables */ TABLE_LIST table_list; LEX_STRING conv_name; - uint dummy; + size_t dummy; /* used as fields initializator */ lex_start(thd); @@ -978,7 +979,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, } thd->query_length= (uint) (packet_end - packet); // Don't count end \0 - if (!(thd->query=fields=thd->memdup(packet,thd->query_length+1))) + if (!(thd->query=fields= (char*) thd->memdup(packet,thd->query_length+1))) break; general_log_print(thd, command, "%s %s", table_list.table_name, fields); if (lower_case_table_names) @@ -996,8 +997,8 @@ bool dispatch_command(enum enum_server_command command, THD *thd, mysql_reset_thd_for_next_command(thd); thd->lex-> - select_lex.table_list.link_in_list((byte*) &table_list, - (byte**) &table_list.next_local); + select_lex.table_list.link_in_list((uchar*) &table_list, + (uchar**) &table_list.next_local); thd->lex->add_to_query_tables(&table_list); /* switch on VIEW optimisation: do not fill temporary tables */ @@ -1189,7 +1190,7 @@ bool dispatch_command(enum enum_server_command command, THD *thd, } #endif #ifndef EMBEDDED_LIBRARY - VOID(my_net_write(net, buff, length)); + VOID(my_net_write(net, (uchar*) buff, length)); VOID(net_flush(net)); #endif break; @@ -1386,7 +1387,7 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident, #else { LEX_STRING db; - uint dummy; + size_t dummy; if (lex->select_lex.db == NULL && thd->copy_db_to(&lex->select_lex.db, &dummy)) { @@ -1487,7 +1488,7 @@ bool alloc_query(THD *thd, const char *packet, uint packet_length) } /* We must allocate some extra memory for query cache */ thd->query_length= 0; // Extra safety: Avoid races - if (!(thd->query= (char*) thd->memdup_w_gap((gptr) (packet), + if (!(thd->query= (char*) thd->memdup_w_gap((uchar*) (packet), packet_length, thd->db_length+ 1 + QUERY_CACHE_FLAGS_SIZE))) @@ -1951,7 +1952,7 @@ mysql_execute_command(THD *thd) goto error; /* purecov: inspected */ thd->enable_slow_log= opt_log_slow_admin_statements; res = mysql_backup_table(thd, first_table); - select_lex->table_list.first= (byte*) first_table; + select_lex->table_list.first= (uchar*) first_table; lex->query_tables=all_tables; break; } @@ -1963,7 +1964,7 @@ mysql_execute_command(THD *thd) goto error; /* purecov: inspected */ thd->enable_slow_log= opt_log_slow_admin_statements; res = mysql_restore_table(thd, first_table); - select_lex->table_list.first= (byte*) first_table; + select_lex->table_list.first= (uchar*) first_table; lex->query_tables=all_tables; break; } @@ -2509,7 +2510,7 @@ end_with_restore_list: thd->query, thd->query_length, 0, FALSE); } } - select_lex->table_list.first= (byte*) first_table; + select_lex->table_list.first= (uchar*) first_table; lex->query_tables=all_tables; break; } @@ -2520,7 +2521,7 @@ end_with_restore_list: goto error; /* purecov: inspected */ thd->enable_slow_log= opt_log_slow_admin_statements; res = mysql_check_table(thd, first_table, &lex->check_opt); - select_lex->table_list.first= (byte*) first_table; + select_lex->table_list.first= (uchar*) first_table; lex->query_tables=all_tables; break; } @@ -2544,7 +2545,7 @@ end_with_restore_list: thd->query, thd->query_length, 0, FALSE); } } - select_lex->table_list.first= (byte*) first_table; + select_lex->table_list.first= (uchar*) first_table; lex->query_tables=all_tables; break; } @@ -2571,7 +2572,7 @@ end_with_restore_list: thd->query, thd->query_length, 0, FALSE); } } - select_lex->table_list.first= (byte*) first_table; + select_lex->table_list.first= (uchar*) first_table; lex->query_tables=all_tables; break; } @@ -2737,7 +2738,7 @@ end_with_restore_list: { /* Skip first table, which is the table we are inserting in */ TABLE_LIST *second_table= first_table->next_local; - select_lex->table_list.first= (byte*) second_table; + select_lex->table_list.first= (uchar*) second_table; select_lex->context.table_list= select_lex->context.first_name_resolution_table= second_table; res= mysql_insert_select_prepare(thd); @@ -2770,7 +2771,7 @@ end_with_restore_list: delete sel_result; } /* revert changes for SP */ - select_lex->table_list.first= (byte*) first_table; + select_lex->table_list.first= (uchar*) first_table; } /* @@ -5039,7 +5040,7 @@ long max_stack_used; - Passing to check_stack_overrun() prevents the compiler from removing it. */ bool check_stack_overrun(THD *thd, long margin, - char *buf __attribute__((unused))) + uchar *buf __attribute__((unused))) { long stack_used; DBUG_ASSERT(thd == current_thd); @@ -5071,19 +5072,19 @@ bool my_yyoverflow(short **yyss, YYSTYPE **yyvs, ulong *yystacksize) if (!lex->yacc_yyvs) old_info= *yystacksize; *yystacksize= set_zone((*yystacksize)*2,MY_YACC_INIT,MY_YACC_MAX); - if (!(lex->yacc_yyvs= (char*) - my_realloc((gptr) lex->yacc_yyvs, + if (!(lex->yacc_yyvs= (uchar*) + my_realloc(lex->yacc_yyvs, *yystacksize*sizeof(**yyvs), MYF(MY_ALLOW_ZERO_PTR | MY_FREE_ON_ERROR))) || - !(lex->yacc_yyss= (char*) - my_realloc((gptr) lex->yacc_yyss, + !(lex->yacc_yyss= (uchar*) + my_realloc(lex->yacc_yyss, *yystacksize*sizeof(**yyss), MYF(MY_ALLOW_ZERO_PTR | MY_FREE_ON_ERROR)))) return 1; if (old_info) { // Copy old info from stack - memcpy(lex->yacc_yyss, (gptr) *yyss, old_info*sizeof(**yyss)); - memcpy(lex->yacc_yyvs, (gptr) *yyvs, old_info*sizeof(**yyvs)); + memcpy(lex->yacc_yyss, (uchar*) *yyss, old_info*sizeof(**yyss)); + memcpy(lex->yacc_yyvs, (uchar*) *yyvs, old_info*sizeof(**yyvs)); } *yyss=(short*) lex->yacc_yyss; *yyvs=(YYSTYPE*) lex->yacc_yyvs; @@ -5570,7 +5571,7 @@ add_proc_to_list(THD* thd, Item *item) *item_ptr= item; order->item=item_ptr; order->free_me=0; - thd->lex->proc_list.link_in_list((byte*) order,(byte**) &order->next); + thd->lex->proc_list.link_in_list((uchar*) order,(uchar**) &order->next); return 0; } @@ -5592,7 +5593,7 @@ bool add_to_list(THD *thd, SQL_LIST &list,Item *item,bool asc) order->free_me=0; order->used=0; order->counter_used= 0; - list.link_in_list((byte*) order,(byte**) &order->next); + list.link_in_list((uchar*) order,(uchar**) &order->next); DBUG_RETURN(0); } @@ -5657,7 +5658,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, ER(ER_DERIVED_MUST_HAVE_ALIAS), MYF(0)); DBUG_RETURN(0); } - if (!(alias_str=thd->memdup(alias_str,table->table.length+1))) + if (!(alias_str= (char*) thd->memdup(alias_str,table->table.length+1))) DBUG_RETURN(0); } if (!(ptr = (TABLE_LIST *) thd->calloc(sizeof(TABLE_LIST)))) @@ -5744,7 +5745,7 @@ TABLE_LIST *st_select_lex::add_table_to_list(THD *thd, previous table reference to 'ptr'. Here we also add one element to the list 'table_list'. */ - table_list.link_in_list((byte*) ptr, (byte**) &ptr->next_local); + table_list.link_in_list((uchar*) ptr, (uchar**) &ptr->next_local); ptr->next_name_resolution_table= NULL; /* Link table in global list (all used tables) */ lex->add_to_query_tables(ptr); @@ -5783,7 +5784,7 @@ bool st_select_lex::init_nested_join(THD *thd) sizeof(NESTED_JOIN)))) DBUG_RETURN(1); nested_join= ptr->nested_join= - ((NESTED_JOIN*) ((byte*) ptr + ALIGN_SIZE(sizeof(TABLE_LIST)))); + ((NESTED_JOIN*) ((uchar*) ptr + ALIGN_SIZE(sizeof(TABLE_LIST)))); join_list->push_front(ptr); ptr->embedding= embedding; @@ -5869,7 +5870,7 @@ TABLE_LIST *st_select_lex::nest_last_join(THD *thd) sizeof(NESTED_JOIN)))) DBUG_RETURN(0); nested_join= ptr->nested_join= - ((NESTED_JOIN*) ((byte*) ptr + ALIGN_SIZE(sizeof(TABLE_LIST)))); + ((NESTED_JOIN*) ((uchar*) ptr + ALIGN_SIZE(sizeof(TABLE_LIST)))); ptr->embedding= embedding; ptr->join_list= join_list; @@ -6462,7 +6463,7 @@ bool append_file_to_dir(THD *thd, const char **filename_ptr, /* Fix is using unix filename format on dos */ strmov(buff,*filename_ptr); end=convert_dirname(buff, *filename_ptr, NullS); - if (!(ptr=thd->alloc((uint) (end-buff)+(uint) strlen(table_name)+1))) + if (!(ptr= (char*) thd->alloc((size_t) (end-buff) + strlen(table_name)+1))) return 1; // End of memory *filename_ptr=ptr; strxmov(ptr,buff,table_name,NullS); diff --git a/sql/sql_partition.cc b/sql/sql_partition.cc index fda15a613a0..d47aacee924 100644 --- a/sql/sql_partition.cc +++ b/sql/sql_partition.cc @@ -123,23 +123,23 @@ uint32 get_partition_id_hash_sub(partition_info *part_info); uint32 get_partition_id_key_sub(partition_info *part_info); uint32 get_partition_id_linear_hash_sub(partition_info *part_info); uint32 get_partition_id_linear_key_sub(partition_info *part_info); -#endif - static uint32 get_next_partition_via_walking(PARTITION_ITERATOR*); +static void set_up_range_analysis_info(partition_info *part_info); static uint32 get_next_subpartition_via_walking(PARTITION_ITERATOR*); +#endif + uint32 get_next_partition_id_range(PARTITION_ITERATOR* part_iter); uint32 get_next_partition_id_list(PARTITION_ITERATOR* part_iter); int get_part_iter_for_interval_via_mapping(partition_info *part_info, bool is_subpart, - char *min_value, char *max_value, + uchar *min_value, uchar *max_value, uint flags, PARTITION_ITERATOR *part_iter); int get_part_iter_for_interval_via_walking(partition_info *part_info, bool is_subpart, - char *min_value, char *max_value, + uchar *min_value, uchar *max_value, uint flags, PARTITION_ITERATOR *part_iter); -static void set_up_range_analysis_info(partition_info *part_info); #ifdef WITH_PARTITION_STORAGE_ENGINE /* @@ -294,8 +294,8 @@ bool check_reorganise_list(partition_info *new_part_info, > 0 Error code */ -int get_parts_for_update(const byte *old_data, byte *new_data, - const byte *rec0, partition_info *part_info, +int get_parts_for_update(const uchar *old_data, uchar *new_data, + const uchar *rec0, partition_info *part_info, uint32 *old_part_id, uint32 *new_part_id, longlong *new_func_value) { @@ -368,7 +368,7 @@ int get_parts_for_update(const byte *old_data, byte *new_data, calculate the partition id. */ -int get_part_for_delete(const byte *buf, const byte *rec0, +int get_part_for_delete(const uchar *buf, const uchar *rec0, partition_info *part_info, uint32 *part_id) { int error; @@ -907,7 +907,7 @@ bool fix_fields_part_func(THD *thd, Item* func_expr, TABLE *table, context->table_list= &tables; context->first_name_resolution_table= &tables; context->last_name_resolution_table= NULL; - func_expr->walk(&Item::change_context_processor, 0, (byte*) context); + func_expr->walk(&Item::change_context_processor, 0, (uchar*) context); save_where= thd->where; thd->where= "partition function"; /* @@ -1673,7 +1673,7 @@ end: static int add_write(File fptr, const char *buf, uint len) { - uint len_written= my_write(fptr, (const byte*)buf, len, MYF(0)); + uint len_written= my_write(fptr, (const uchar*)buf, len, MYF(0)); if (likely(len == len_written)) return 0; @@ -2120,13 +2120,13 @@ char *generate_partition_syntax(partition_info *part_info, goto close_file; *buf_length= (uint)buffer_length; if (use_sql_alloc) - buf= sql_alloc(*buf_length+1); + buf= (char*) sql_alloc(*buf_length+1); else - buf= my_malloc(*buf_length+1, MYF(MY_WME)); + buf= (char*) my_malloc(*buf_length+1, MYF(MY_WME)); if (!buf) goto close_file; - if (unlikely(my_read(fptr, (byte*)buf, *buf_length, MYF(MY_FNABP)))) + if (unlikely(my_read(fptr, (uchar*)buf, *buf_length, MYF(MY_FNABP)))) { if (!use_sql_alloc) my_free(buf, MYF(0)); @@ -2389,8 +2389,8 @@ static uint32 get_part_id_linear_key(partition_info *part_info, */ static void copy_to_part_field_buffers(Field **ptr, - char **field_bufs, - char **restore_ptr) + uchar **field_bufs, + uchar **restore_ptr) { Field *field; while ((field= *(ptr++))) @@ -2401,7 +2401,7 @@ static void copy_to_part_field_buffers(Field **ptr, { CHARSET_INFO *cs= ((Field_str*)field)->charset(); uint len= field->pack_length(); - char *field_buf= *field_bufs; + uchar *field_buf= *field_bufs; /* We only use the field buffer for VARCHAR and CHAR strings which isn't of a binary collation. We also only use the @@ -2412,17 +2412,17 @@ static void copy_to_part_field_buffers(Field **ptr, if (field->type() == MYSQL_TYPE_VARCHAR) { uint len_bytes= ((Field_varstring*)field)->length_bytes; - my_strnxfrm(cs, (uchar*)(field_buf + len_bytes), (len - len_bytes), - (uchar*)(field->ptr + len_bytes), field->field_length); + my_strnxfrm(cs, field_buf + len_bytes, (len - len_bytes), + field->ptr + len_bytes, field->field_length); if (len_bytes == 1) - *field_buf= (uchar)field->field_length; + *field_buf= (uchar) field->field_length; else int2store(field_buf, field->field_length); } else { - my_strnxfrm(cs, (uchar*)field_buf, len, - (uchar*)field->ptr, field->field_length); + my_strnxfrm(cs, field_buf, len, + field->ptr, field->field_length); } field->ptr= field_buf; } @@ -2441,7 +2441,7 @@ static void copy_to_part_field_buffers(Field **ptr, RETURN VALUES */ -static void restore_part_field_pointers(Field **ptr, char **restore_ptr) +static void restore_part_field_pointers(Field **ptr, uchar **restore_ptr) { Field *field; while ((field= *(ptr++))) @@ -3283,16 +3283,16 @@ static bool check_part_func_bound(Field **ptr) get the partition identity and restore field pointers afterwards. */ -static uint32 get_sub_part_id_from_key(const TABLE *table,byte *buf, +static uint32 get_sub_part_id_from_key(const TABLE *table,uchar *buf, KEY *key_info, const key_range *key_spec) { - byte *rec0= table->record[0]; + uchar *rec0= table->record[0]; partition_info *part_info= table->part_info; uint32 part_id; DBUG_ENTER("get_sub_part_id_from_key"); - key_restore(buf, (byte*)key_spec->key, key_info, key_spec->length); + key_restore(buf, (uchar*)key_spec->key, key_info, key_spec->length); if (likely(rec0 == buf)) part_id= part_info->get_subpartition_id(part_info); else @@ -3326,16 +3326,16 @@ static uint32 get_sub_part_id_from_key(const TABLE *table,byte *buf, get the partition identity and restore field pointers afterwards. */ -bool get_part_id_from_key(const TABLE *table, byte *buf, KEY *key_info, +bool get_part_id_from_key(const TABLE *table, uchar *buf, KEY *key_info, const key_range *key_spec, uint32 *part_id) { bool result; - byte *rec0= table->record[0]; + uchar *rec0= table->record[0]; partition_info *part_info= table->part_info; longlong func_value; DBUG_ENTER("get_part_id_from_key"); - key_restore(buf, (byte*)key_spec->key, key_info, key_spec->length); + key_restore(buf, (uchar*)key_spec->key, key_info, key_spec->length); if (likely(rec0 == buf)) result= part_info->get_part_partition_id(part_info, part_id, &func_value); @@ -3371,18 +3371,18 @@ bool get_part_id_from_key(const TABLE *table, byte *buf, KEY *key_info, get the partition identity and restore field pointers afterwards. */ -void get_full_part_id_from_key(const TABLE *table, byte *buf, +void get_full_part_id_from_key(const TABLE *table, uchar *buf, KEY *key_info, const key_range *key_spec, part_id_range *part_spec) { bool result; partition_info *part_info= table->part_info; - byte *rec0= table->record[0]; + uchar *rec0= table->record[0]; longlong func_value; DBUG_ENTER("get_full_part_id_from_key"); - key_restore(buf, (byte*)key_spec->key, key_info, key_spec->length); + key_restore(buf, (uchar*)key_spec->key, key_info, key_spec->length); if (likely(rec0 == buf)) result= part_info->get_partition_id(part_info, &part_spec->start_part, &func_value); @@ -3470,7 +3470,7 @@ void prune_partition_set(const TABLE *table, part_id_range *part_spec) RETURN VALUE part_spec */ -void get_partition_set(const TABLE *table, byte *buf, const uint index, +void get_partition_set(const TABLE *table, uchar *buf, const uint index, const key_range *key_spec, part_id_range *part_spec) { partition_info *part_info= table->part_info; @@ -3806,9 +3806,9 @@ bool mysql_unpack_partition(THD *thd, char *part_func_string= NULL; char *subpart_func_string= NULL; if ((part_func_len && - !((part_func_string= thd->alloc(part_func_len)))) || + !((part_func_string= (char*) thd->alloc(part_func_len)))) || (subpart_func_len && - !((subpart_func_string= thd->alloc(subpart_func_len))))) + !((subpart_func_string= (char*) thd->alloc(subpart_func_len))))) { mem_alloc_error(part_func_len); thd->free_items(); @@ -6374,8 +6374,8 @@ uint fast_alter_partition_table(THD *thd, TABLE *table, also for other programs. */ -void set_field_ptr(Field **ptr, const byte *new_buf, - const byte *old_buf) +void set_field_ptr(Field **ptr, const uchar *new_buf, + const uchar *old_buf) { my_ptrdiff_t diff= (new_buf - old_buf); DBUG_ENTER("set_field_ptr"); @@ -6408,8 +6408,8 @@ void set_field_ptr(Field **ptr, const byte *new_buf, also for other programs. */ -void set_key_field_ptr(KEY *key_info, const byte *new_buf, - const byte *old_buf) +void set_key_field_ptr(KEY *key_info, const uchar *new_buf, + const uchar *old_buf) { KEY_PART_INFO *key_part= key_info->key_part; uint key_parts= key_info->key_parts; @@ -6660,7 +6660,7 @@ typedef uint32 (*get_endpoint_func)(partition_info*, bool left_endpoint, int get_part_iter_for_interval_via_mapping(partition_info *part_info, bool is_subpart, - char *min_value, char *max_value, + uchar *min_value, uchar *max_value, uint flags, PARTITION_ITERATOR *part_iter) { @@ -6816,7 +6816,7 @@ int get_part_iter_for_interval_via_mapping(partition_info *part_info, int get_part_iter_for_interval_via_walking(partition_info *part_info, bool is_subpart, - char *min_value, char *max_value, + uchar *min_value, uchar *max_value, uint flags, PARTITION_ITERATOR *part_iter) { diff --git a/sql/sql_partition.h b/sql/sql_partition.h index e0c0f1c5bd3..d0c66083768 100644 --- a/sql/sql_partition.h +++ b/sql/sql_partition.h @@ -56,11 +56,11 @@ bool check_reorganise_list(partition_info *new_part_info, partition_info *old_part_info, List<char> list_part_names); handler *get_ha_partition(partition_info *part_info); -int get_parts_for_update(const byte *old_data, byte *new_data, - const byte *rec0, partition_info *part_info, +int get_parts_for_update(const uchar *old_data, uchar *new_data, + const uchar *rec0, partition_info *part_info, uint32 *old_part_id, uint32 *new_part_id, longlong *func_value); -int get_part_for_delete(const byte *buf, const byte *rec0, +int get_part_for_delete(const uchar *buf, const uchar *rec0, partition_info *part_info, uint32 *part_id); void prune_partition_set(const TABLE *table, part_id_range *part_spec); bool check_partition_info(partition_info *part_info,handlerton **eng_type, @@ -70,10 +70,10 @@ char *generate_partition_syntax(partition_info *part_info, uint *buf_length, bool use_sql_alloc, bool show_partition_options); bool partition_key_modified(TABLE *table, const MY_BITMAP *fields); -void get_partition_set(const TABLE *table, byte *buf, const uint index, +void get_partition_set(const TABLE *table, uchar *buf, const uint index, const key_range *key_spec, part_id_range *part_spec); -void get_full_part_id_from_key(const TABLE *table, byte *buf, +void get_full_part_id_from_key(const TABLE *table, uchar *buf, KEY *key_info, const key_range *key_spec, part_id_range *part_spec); @@ -201,7 +201,7 @@ typedef struct st_partition_iter typedef int (*get_partitions_in_range_iter)(partition_info *part_info, bool is_subpart, - char *min_val, char *max_val, + uchar *min_val, uchar *max_val, uint flags, PARTITION_ITERATOR *part_iter); diff --git a/sql/sql_plugin.cc b/sql/sql_plugin.cc index 5f8513a4a9e..37301751d03 100644 --- a/sql/sql_plugin.cc +++ b/sql/sql_plugin.cc @@ -177,9 +177,9 @@ public: { return !(plugin_var->flags & PLUGIN_VAR_THDLOCAL) && type != OPT_GLOBAL; } bool check_update_type(Item_result type); SHOW_TYPE show_type(); - byte* real_value_ptr(THD *thd, enum_var_type type); + uchar* real_value_ptr(THD *thd, enum_var_type type); TYPELIB* plugin_var_typelib(void); - byte* value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); + uchar* value_ptr(THD *thd, enum_var_type type, LEX_STRING *base); bool check(THD *thd, set_var *var); void set_default(THD *thd, enum_var_type type); bool update(THD *thd, set_var *var); @@ -303,7 +303,7 @@ static st_plugin_dl *plugin_dl_insert_or_reuse(struct st_plugin_dl *plugin_dl) DBUG_RETURN(tmp); } } - if (insert_dynamic(&plugin_dl_array, (gptr)plugin_dl)) + if (insert_dynamic(&plugin_dl_array, (uchar*)plugin_dl)) DBUG_RETURN(0); DBUG_RETURN(dynamic_element(&plugin_dl_array, plugin_dl_array.elements - 1, struct st_plugin_dl *)); @@ -319,7 +319,7 @@ static inline void free_plugin_mem(struct st_plugin_dl *p) #endif my_free(p->dl.str, MYF(MY_ALLOW_ZERO_PTR)); if (p->version != MYSQL_PLUGIN_INTERFACE_VERSION) - my_free((gptr)p->plugins, MYF(MY_ALLOW_ZERO_PTR)); + my_free((uchar*)p->plugins, MYF(MY_ALLOW_ZERO_PTR)); } @@ -471,7 +471,7 @@ static st_plugin_dl *plugin_dl_add(const LEX_STRING *dl, int report) /* Duplicate and convert dll name */ plugin_dl.dl.length= dl->length * files_charset_info->mbmaxlen + 1; - if (! (plugin_dl.dl.str= my_malloc(plugin_dl.dl.length, MYF(0)))) + if (! (plugin_dl.dl.str= (char*) my_malloc(plugin_dl.dl.length, MYF(0)))) { free_plugin_mem(&plugin_dl); if (report & REPORT_TO_USER) @@ -551,14 +551,14 @@ static struct st_plugin_int *plugin_find_internal(const LEX_STRING *name, int ty for (i= 0; i < MYSQL_MAX_PLUGIN_TYPE_NUM; i++) { struct st_plugin_int *plugin= (st_plugin_int *) - hash_search(&plugin_hash[i], (const byte *)name->str, name->length); + hash_search(&plugin_hash[i], (const uchar *)name->str, name->length); if (plugin) DBUG_RETURN(plugin); } } else DBUG_RETURN((st_plugin_int *) - hash_search(&plugin_hash[type], (const byte *)name->str, name->length)); + hash_search(&plugin_hash[type], (const uchar *)name->str, name->length)); DBUG_RETURN(0); } @@ -628,7 +628,7 @@ static plugin_ref intern_plugin_lock(LEX *lex, plugin_ref rc CALLER_INFO_PROTO) (long) current_thd, pi->name.str, pi->ref_count)); if (lex) - insert_dynamic(&lex->plugins, (gptr)&plugin); + insert_dynamic(&lex->plugins, (uchar*)&plugin); DBUG_RETURN(plugin); } DBUG_RETURN(NULL); @@ -676,7 +676,7 @@ static st_plugin_int *plugin_insert_or_reuse(struct st_plugin_int *plugin) DBUG_RETURN(tmp); } } - if (insert_dynamic(&plugin_array, (gptr)plugin)) + if (insert_dynamic(&plugin_array, (uchar*)plugin)) DBUG_RETURN(0); DBUG_RETURN(dynamic_element(&plugin_array, plugin_array.elements - 1, struct st_plugin_int *)); @@ -737,13 +737,12 @@ static bool plugin_add(MEM_ROOT *tmp_root, tmp.name.length= name_len; tmp.ref_count= 0; tmp.state= PLUGIN_IS_UNINITIALIZED; - if (!test_plugin_options(tmp_root, &tmp, argc, argv, true)) { if ((tmp_plugin_ptr= plugin_insert_or_reuse(&tmp))) { plugin_array_version++; - if (!my_hash_insert(&plugin_hash[plugin->type], (byte*)tmp_plugin_ptr)) + if (!my_hash_insert(&plugin_hash[plugin->type], (uchar*)tmp_plugin_ptr)) { init_alloc_root(&tmp_plugin_ptr->mem_root, 4096, 4096); DBUG_RETURN(FALSE); @@ -832,7 +831,7 @@ static void plugin_del(struct st_plugin_int *plugin) safe_mutex_assert_owner(&LOCK_plugin); /* Free allocated strings before deleting the plugin. */ plugin_vars_free_values(plugin->system_vars); - hash_delete(&plugin_hash[plugin->plugin->type], (byte*)plugin); + hash_delete(&plugin_hash[plugin->plugin->type], (uchar*)plugin); if (plugin->plugin_dl) plugin_dl_del(&plugin->plugin_dl->dl); plugin->state= PLUGIN_IS_FREED; @@ -914,7 +913,7 @@ static void intern_plugin_unlock(LEX *lex, plugin_ref plugin) if (!pi->plugin_dl) DBUG_VOID_RETURN; #else - my_free((gptr) plugin, MYF(MY_WME)); + my_free((uchar*) plugin, MYF(MY_WME)); #endif DBUG_PRINT("info",("unlocking plugin, name= %s, ref_count= %d", @@ -1048,21 +1047,21 @@ err: } -static byte *get_hash_key(const byte *buff, uint *length, +static uchar *get_hash_key(const uchar *buff, size_t *length, my_bool not_used __attribute__((unused))) { struct st_plugin_int *plugin= (st_plugin_int *)buff; *length= (uint)plugin->name.length; - return((byte *)plugin->name.str); + return((uchar *)plugin->name.str); } -static byte *get_bookmark_hash_key(const byte *buff, uint *length, +static uchar *get_bookmark_hash_key(const uchar *buff, size_t *length, my_bool not_used __attribute__((unused))) { struct st_bookmark *var= (st_bookmark *)buff; *length= var->name_len + 1; - return (byte*) var->key; + return (uchar*) var->key; } @@ -1179,6 +1178,7 @@ int plugin_init(int *argc, char **argv, int flags) /* Now we initialize all remaining plugins */ + pthread_mutex_lock(&LOCK_plugin); reap= (st_plugin_int **) my_alloca((plugin_array.elements+1) * sizeof(void*)); *(reap++)= NULL; @@ -1212,6 +1212,7 @@ int plugin_init(int *argc, char **argv, int flags) end: free_root(&tmp_root, MYF(0)); + DBUG_RETURN(0); err_unlock: @@ -1232,13 +1233,13 @@ static bool register_builtin(struct st_mysql_plugin *plugin, tmp->ref_count= 0; tmp->plugin_dl= 0; - if (insert_dynamic(&plugin_array, (gptr)tmp)) + if (insert_dynamic(&plugin_array, (uchar*)tmp)) DBUG_RETURN(1); *ptr= dynamic_element(&plugin_array, plugin_array.elements - 1, struct st_plugin_int *); - if (my_hash_insert(&plugin_hash[plugin->type],(byte*) *ptr)) + if (my_hash_insert(&plugin_hash[plugin->type],(uchar*) *ptr)) DBUG_RETURN(1); DBUG_RETURN(0); @@ -1310,7 +1311,7 @@ static void plugin_load(MEM_ROOT *tmp_root, int *argc, char **argv) new_thd->store_globals(); new_thd->db= my_strdup("mysql", MYF(0)); new_thd->db_length= 5; - bzero((gptr)&tables, sizeof(tables)); + bzero((uchar*)&tables, sizeof(tables)); tables.alias= tables.table_name= (char*)"plugin"; tables.lock_type= TL_READ; tables.db= new_thd->db; @@ -1672,7 +1673,7 @@ bool mysql_uninstall_plugin(THD *thd, const LEX_STRING *name) table->use_all_columns(); table->field[0]->store(name->str, name->length, system_charset_info); if (! table->file->index_read_idx(table->record[0], 0, - (byte *)table->field[0]->ptr, HA_WHOLE_KEY, + (uchar *)table->field[0]->ptr, HA_WHOLE_KEY, HA_READ_KEY_EXACT)) { int error; @@ -1789,7 +1790,7 @@ typedef DECLARE_MYSQL_THDVAR_SIMPLE(thdvar_ulonglong_t, ulonglong); #define SET_PLUGIN_VAR_RESOLVE(opt)\ *(mysql_sys_var_ptr_p*)&((opt)->resolve)= mysql_sys_var_ptr -typedef byte *(*mysql_sys_var_ptr_p)(void* a_thd, int offset); +typedef uchar *(*mysql_sys_var_ptr_p)(void* a_thd, int offset); /**************************************************************************** @@ -2102,7 +2103,7 @@ static st_bookmark *find_bookmark(const char *plugin, const char *name, varname[0]= flags & PLUGIN_VAR_TYPEMASK; result= (st_bookmark*) hash_search(&bookmark_hash, - (const byte*) varname, length - 1); + (const uchar*) varname, length - 1); my_afree(varname); return result; @@ -2170,10 +2171,10 @@ static st_bookmark *register_var(const char *plugin, const char *name, if (new_size > global_variables_dynamic_size) { - global_system_variables.dynamic_variables_ptr= + global_system_variables.dynamic_variables_ptr= (char*) my_realloc(global_system_variables.dynamic_variables_ptr, new_size, MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR)); - max_system_variables.dynamic_variables_ptr= + max_system_variables.dynamic_variables_ptr= (char*) my_realloc(max_system_variables.dynamic_variables_ptr, new_size, MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR)); /* @@ -2200,7 +2201,7 @@ static st_bookmark *register_var(const char *plugin, const char *name, result->version= global_system_variables.dynamic_variables_version; /* this should succeed because we have already checked if a dup exists */ - if (my_hash_insert(&bookmark_hash, (byte*) result)) + if (my_hash_insert(&bookmark_hash, (uchar*) result)) { fprintf(stderr, "failed to add placeholder to hash"); DBUG_ASSERT(0); @@ -2217,13 +2218,13 @@ static st_bookmark *register_var(const char *plugin, const char *name, If required, will sync with global variables if the requested variable has not yet been allocated in the current thread. */ -static byte *intern_sys_var_ptr(THD* thd, int offset, bool global_lock) +static uchar *intern_sys_var_ptr(THD* thd, int offset, bool global_lock) { DBUG_ASSERT(offset >= 0); DBUG_ASSERT((uint)offset <= global_system_variables.dynamic_variables_head); if (!thd) - return (byte*) global_system_variables.dynamic_variables_ptr + offset; + return (uchar*) global_system_variables.dynamic_variables_ptr + offset; /* dynamic_variables_head points to the largest valid offset @@ -2235,7 +2236,7 @@ static byte *intern_sys_var_ptr(THD* thd, int offset, bool global_lock) rw_rdlock(&LOCK_system_variables_hash); - thd->variables.dynamic_variables_ptr= + thd->variables.dynamic_variables_ptr= (char*) my_realloc(thd->variables.dynamic_variables_ptr, global_variables_dynamic_size, MYF(MY_WME | MY_FAE | MY_ALLOW_ZERO_PTR)); @@ -2293,10 +2294,10 @@ static byte *intern_sys_var_ptr(THD* thd, int offset, bool global_lock) rw_unlock(&LOCK_system_variables_hash); } - return (byte*)thd->variables.dynamic_variables_ptr + offset; + return (uchar*)thd->variables.dynamic_variables_ptr + offset; } -static byte *mysql_sys_var_ptr(void* a_thd, int offset) +static uchar *mysql_sys_var_ptr(void* a_thd, int offset) { return intern_sys_var_ptr((THD *)a_thd, offset, true); } @@ -2397,7 +2398,7 @@ void plugin_thdvar_cleanup(THD *thd) { list= ((plugin_ref*) thd->lex->plugins.buffer) + idx - 1; DBUG_PRINT("info",("unlocking %d plugins", idx)); - while ((char*) list >= thd->lex->plugins.buffer) + while ((uchar*) list >= thd->lex->plugins.buffer) intern_plugin_unlock(NULL, *list--); } @@ -2484,7 +2485,7 @@ SHOW_TYPE sys_var_pluginvar::show_type() } -byte* sys_var_pluginvar::real_value_ptr(THD *thd, enum_var_type type) +uchar* sys_var_pluginvar::real_value_ptr(THD *thd, enum_var_type type) { DBUG_ASSERT(thd || (type == OPT_GLOBAL)); if (plugin_var->flags & PLUGIN_VAR_THDLOCAL) @@ -2494,7 +2495,7 @@ byte* sys_var_pluginvar::real_value_ptr(THD *thd, enum_var_type type) return intern_sys_var_ptr(thd, *(int*) (plugin_var+1), false); } - return *(byte**) (plugin_var+1); + return *(uchar**) (plugin_var+1); } @@ -2516,15 +2517,15 @@ TYPELIB* sys_var_pluginvar::plugin_var_typelib(void) } -byte* sys_var_pluginvar::value_ptr(THD *thd, enum_var_type type, +uchar* sys_var_pluginvar::value_ptr(THD *thd, enum_var_type type, LEX_STRING *base) { - byte* result; + uchar* result; result= real_value_ptr(thd, type); if ((plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_ENUM) - result= (byte*) get_type(plugin_var_typelib(), *(ulong*)result); + result= (uchar*) get_type(plugin_var_typelib(), *(ulong*)result); else if ((plugin_var->flags & PLUGIN_VAR_TYPEMASK) == PLUGIN_VAR_SET) { char buffer[STRING_BUFFER_USUAL_SIZE]; @@ -2542,9 +2543,9 @@ byte* sys_var_pluginvar::value_ptr(THD *thd, enum_var_type type, str.append(','); } - result= (byte*) ""; + result= (uchar*) ""; if (str.length()) - result= (byte*) thd->strmake(str.ptr(), str.length()-1); + result= (uchar*) thd->strmake(str.ptr(), str.length()-1); } return result; } @@ -2799,7 +2800,7 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, options[0].arg_type= options[1].arg_type= NO_ARG; options[0].def_value= options[1].def_value= **enabled; options[0].value= options[0].u_max_value= - options[1].value= options[1].u_max_value= (gptr*) (name - 1); + options[1].value= options[1].u_max_value= (uchar**) (name - 1); options+= 2; /* @@ -2878,9 +2879,9 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, if (!opt->update) { opt->update= update_func_str; - if (!(opt->flags & PLUGIN_VAR_MEMALLOC)) + if (!(opt->flags & PLUGIN_VAR_MEMALLOC | PLUGIN_VAR_READONLY)) { - opt->flags |= PLUGIN_VAR_READONLY; + opt->flags|= PLUGIN_VAR_READONLY; sql_print_warning("Server variable %s of plugin %s was forced " "to be read-only: string variable without " "update_func and PLUGIN_VAR_MEMALLOC flag", @@ -2924,7 +2925,7 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, optnamelen= namelen + optnamelen + 1; } else - optname= memdup_root(mem_root, v->key + 1, (optnamelen= v->name_len) + 1); + optname= (char*) memdup_root(mem_root, v->key + 1, (optnamelen= v->name_len) + 1); /* convert '_' to '-' */ for (p= optname; *p; p++) @@ -2945,10 +2946,10 @@ static int construct_options(MEM_ROOT *mem_root, struct st_plugin_int *tmp, (opt->flags & PLUGIN_VAR_TYPEMASK) != PLUGIN_VAR_SET) { if (opt->flags & PLUGIN_VAR_THDLOCAL) - options->value= options->u_max_value= (gptr*) + options->value= options->u_max_value= (uchar**) (global_system_variables.dynamic_variables_ptr + offset); else - options->value= options->u_max_value= *(gptr**) (opt + 1); + options->value= options->u_max_value= *(uchar***) (opt + 1); } options[1]= options[0]; @@ -3148,16 +3149,16 @@ void my_print_help_inc_plugins(my_option *main_options, uint size) /* Only options with a non-NULL comment are displayed in help text */ for (;opt->id; opt++) if (opt->comment) - insert_dynamic(&all_options, (gptr) opt); + insert_dynamic(&all_options, (uchar*) opt); } for (;main_options->id; main_options++) - insert_dynamic(&all_options, (gptr) main_options); + insert_dynamic(&all_options, (uchar*) main_options); sort_dynamic(&all_options, (qsort_cmp) option_cmp); /* main_options now points to the empty option terminator */ - insert_dynamic(&all_options, (gptr) main_options); + insert_dynamic(&all_options, (uchar*) main_options); my_print_help((my_option*) all_options.buffer); my_print_variables((my_option*) all_options.buffer); diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index cb01d14258b..c54b2358b37 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -229,7 +229,7 @@ find_prepared_statement(THD *thd, ulong id, const char *where) static bool send_prep_stmt(Prepared_statement *stmt, uint columns) { NET *net= &stmt->thd->net; - char buff[12]; + uchar buff[12]; uint tmp; DBUG_ENTER("send_prep_stmt"); @@ -946,7 +946,7 @@ static bool insert_params_from_vars(Prepared_statement *stmt, Item_param *param= *it; varname= var_it++; entry= (user_var_entry*)hash_search(&stmt->thd->user_vars, - (byte*) varname->str, + (uchar*) varname->str, varname->length); if (param->set_from_user_var(stmt->thd, entry) || param->convert_str_value(stmt->thd)) @@ -1077,7 +1077,7 @@ static bool mysql_test_insert(Prepared_statement *stmt, if (table_list->table) { // don't allocate insert_values - table_list->table->insert_values=(byte *)1; + table_list->table->insert_values=(uchar *)1; } if (mysql_prepare_insert(thd, table_list, table_list->table, @@ -1604,7 +1604,7 @@ static bool mysql_insert_select_prepare_tester(THD *thd) next_local; /* Skip first table, which is the table we are inserting in */ - first_select->table_list.first= (byte *) second_table; + first_select->table_list.first= (uchar *) second_table; thd->lex->select_lex.context.table_list= thd->lex->select_lex.context.first_name_resolution_table= second_table; @@ -1635,7 +1635,7 @@ static bool mysql_test_insert_select(Prepared_statement *stmt, if (tables->table) { // don't allocate insert_values - tables->table->insert_values=(byte *)1; + tables->table->insert_values=(uchar *)1; } if (insert_precheck(stmt->thd, tables)) @@ -1650,7 +1650,7 @@ static bool mysql_test_insert_select(Prepared_statement *stmt, &mysql_insert_select_prepare_tester, OPTION_SETUP_TABLES_DONE); /* revert changes made by mysql_insert_select_prepare_tester */ - lex->select_lex.table_list.first= (byte*) first_local_table; + lex->select_lex.table_list.first= (uchar*) first_local_table; return res; } @@ -1987,7 +1987,7 @@ static const char *get_dynamic_sql_string(LEX *lex, uint *query_len) */ if ((entry= (user_var_entry*)hash_search(&thd->user_vars, - (byte*)lex->prepared_stmt_code.str, + (uchar*)lex->prepared_stmt_code.str, lex->prepared_stmt_code.length)) && entry->value) { @@ -2016,7 +2016,7 @@ static const char *get_dynamic_sql_string(LEX *lex, uint *query_len) len= (needs_conversion ? var_value->length() * to_cs->mbmaxlen : var_value->length()); - if (!(query_str= alloc_root(thd->mem_root, len+1))) + if (!(query_str= (char*) alloc_root(thd->mem_root, len+1))) goto end; if (needs_conversion) @@ -2369,7 +2369,7 @@ void mysql_sql_stmt_execute(THD *thd) /* Query text for binary, general or slow log, if any of them is open */ String expanded_query; DBUG_ENTER("mysql_sql_stmt_execute"); - DBUG_PRINT("info", ("EXECUTE: %.*s\n", name->length, name->str)); + DBUG_PRINT("info", ("EXECUTE: %.*s\n", (int) name->length, name->str)); if (!(stmt= (Prepared_statement*) thd->stmt_map.find_by_name(name))) { @@ -2557,7 +2557,8 @@ void mysql_sql_stmt_close(THD *thd) { Prepared_statement* stmt; LEX_STRING *name= &thd->lex->prepared_stmt_name; - DBUG_PRINT("info", ("DEALLOCATE PREPARE: %.*s\n", name->length, name->str)); + DBUG_PRINT("info", ("DEALLOCATE PREPARE: %.*s\n", (int) name->length, + name->str)); if (! (stmt= (Prepared_statement*) thd->stmt_map.find_by_name(name))) { @@ -2802,7 +2803,7 @@ void Prepared_statement::cleanup_stmt() bool Prepared_statement::set_name(LEX_STRING *name_arg) { name.length= name_arg->length; - name.str= memdup_root(mem_root, (char*) name_arg->str, name_arg->length); + name.str= (char*) memdup_root(mem_root, name_arg->str, name_arg->length); return name.str == 0; } diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index d68dcf81282..6125a00c8e1 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -72,7 +72,7 @@ static int fake_rotate_event(NET* net, String* packet, char* log_file_name, int8store(buf+R_POS_OFFSET,position); packet->append(buf, ROTATE_HEADER_LEN); packet->append(p,ident_len); - if (my_net_write(net, (char*)packet->ptr(), packet->length())) + if (my_net_write(net, (uchar*) packet->ptr(), packet->length())) { *errmsg = "failed on my_net_write()"; DBUG_RETURN(-1); @@ -83,12 +83,13 @@ static int fake_rotate_event(NET* net, String* packet, char* log_file_name, static int send_file(THD *thd) { NET* net = &thd->net; - int fd = -1,bytes, error = 1; + int fd = -1, error = 1; + size_t bytes; char fname[FN_REFLEN+1]; const char *errmsg = 0; int old_timeout; unsigned long packet_len; - char buf[IO_SIZE]; // It's safe to alloc this + uchar buf[IO_SIZE]; // It's safe to alloc this DBUG_ENTER("send_file"); /* @@ -121,7 +122,7 @@ static int send_file(THD *thd) goto err; } - while ((bytes = (int) my_read(fd, (byte*) buf, IO_SIZE, MYF(0))) > 0) + while ((long) (bytes= my_read(fd, buf, IO_SIZE, MYF(0))) > 0) { if (my_net_write(net, buf, bytes)) { @@ -131,7 +132,7 @@ static int send_file(THD *thd) } end: - if (my_net_write(net, "", 0) || net_flush(net) || + if (my_net_write(net, (uchar*) "", 0) || net_flush(net) || (my_net_read(net) == packet_error)) { errmsg = "while negotiating file transfer close"; @@ -217,7 +218,8 @@ bool log_in_use(const char* log_name) if ((linfo = tmp->current_linfo)) { pthread_mutex_lock(&linfo->lock); - result = !bcmp(log_name, linfo->log_file_name, log_name_len); + result = !bcmp((uchar*) log_name, (uchar*) linfo->log_file_name, + log_name_len); pthread_mutex_unlock(&linfo->lock); if (result) break; @@ -480,7 +482,7 @@ impossible position"; int4store((char*) packet->ptr()+LOG_EVENT_MINIMAL_HEADER_LEN+ ST_CREATED_OFFSET+1, (ulong) 0); /* send it */ - if (my_net_write(net, (char*)packet->ptr(), packet->length())) + if (my_net_write(net, (uchar*) packet->ptr(), packet->length())) { errmsg = "Failed on my_net_write()"; my_errno= ER_UNKNOWN_ERROR; @@ -538,7 +540,7 @@ impossible position"; else if ((*packet)[EVENT_TYPE_OFFSET+1] == STOP_EVENT) binlog_can_be_corrupted= FALSE; - if (my_net_write(net, (char*)packet->ptr(), packet->length())) + if (my_net_write(net, (uchar*) packet->ptr(), packet->length())) { errmsg = "Failed on my_net_write()"; my_errno= ER_UNKNOWN_ERROR; @@ -651,7 +653,7 @@ impossible position"; if (read_packet) { thd->proc_info = "Sending binlog event to slave"; - if (my_net_write(net, (char*)packet->ptr(), packet->length()) ) + if (my_net_write(net, (uchar*) packet->ptr(), packet->length()) ) { errmsg = "Failed on my_net_write()"; my_errno= ER_UNKNOWN_ERROR; diff --git a/sql/sql_select.cc b/sql/sql_select.cc index ac2fd0ba0d2..c6ef16d46a3 100644 --- a/sql/sql_select.cc +++ b/sql/sql_select.cc @@ -76,7 +76,7 @@ static double prev_record_reads(JOIN *join, uint idx, table_map found_ref); static bool get_best_combination(JOIN *join); static store_key *get_store_key(THD *thd, KEYUSE *keyuse, table_map used_tables, - KEY_PART_INFO *key_part, char *key_buff, + KEY_PART_INFO *key_part, uchar *key_buff, uint maybe_null); static bool make_simple_join(JOIN *join,TABLE *tmp_table); static void make_outerjoin_info(JOIN *join); @@ -1304,7 +1304,7 @@ JOIN::optimize() for (ORDER *tmp_order= order; tmp_order ; tmp_order=tmp_order->next) { Item *item= *tmp_order->item; - if (item->walk(&Item::is_expensive_processor, 0, (byte*)0)) + if (item->walk(&Item::is_expensive_processor, 0, (uchar*)0)) { /* Force tmp table without sort */ need_tmp=1; simple_order=simple_group=0; @@ -1537,7 +1537,7 @@ JOIN::save_join_tab() { if (!join_tab_save && select_lex->master_unit()->uncacheable) { - if (!(join_tab_save= (JOIN_TAB*)thd->memdup((gptr) join_tab, + if (!(join_tab_save= (JOIN_TAB*)thd->memdup((uchar*) join_tab, sizeof(JOIN_TAB) * tables))) return 1; } @@ -2759,7 +2759,7 @@ make_join_statistics(JOIN *join, TABLE_LIST *tables, COND *conds, } else { - memcpy((gptr) join->best_positions,(gptr) join->positions, + memcpy((uchar*) join->best_positions,(uchar*) join->positions, sizeof(POSITION)*join->const_tables); join->best_read=1.0; } @@ -3380,7 +3380,7 @@ add_key_part(DYNAMIC_ARRAY *keyuse_array,KEY_FIELD *key_field) keyuse.optimize= key_field->optimize & KEY_OPTIMIZE_REF_OR_NULL; keyuse.null_rejecting= key_field->null_rejecting; keyuse.cond_guard= key_field->cond_guard; - VOID(insert_dynamic(keyuse_array,(gptr) &keyuse)); + VOID(insert_dynamic(keyuse_array,(uchar*) &keyuse)); } } } @@ -3447,7 +3447,7 @@ add_ft_keys(DYNAMIC_ARRAY *keyuse_array, keyuse.used_tables=cond_func->key_item()->used_tables(); keyuse.optimize= 0; keyuse.keypart_map= 0; - VOID(insert_dynamic(keyuse_array,(gptr) &keyuse)); + VOID(insert_dynamic(keyuse_array,(uchar*) &keyuse)); } @@ -3662,7 +3662,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab, (qsort_cmp) sort_keyuse); bzero((char*) &key_end,sizeof(key_end)); /* Add for easy testing */ - VOID(insert_dynamic(keyuse,(gptr) &key_end)); + VOID(insert_dynamic(keyuse,(uchar*) &key_end)); use=save_pos=dynamic_element(keyuse,0,KEYUSE*); prev= &key_end; @@ -3697,7 +3697,7 @@ update_ref_and_keys(THD *thd, DYNAMIC_ARRAY *keyuse,JOIN_TAB *join_tab, save_pos++; } i=(uint) (save_pos-(KEYUSE*) keyuse->buffer); - VOID(set_dynamic(keyuse,(gptr) &key_end,i)); + VOID(set_dynamic(keyuse,(uchar*) &key_end,i)); keyuse->elements=i; } return FALSE; @@ -3778,7 +3778,7 @@ add_group_and_distinct_keys(JOIN *join, JOIN_TAB *join_tab) { /* Collect all query fields referenced in the GROUP clause. */ for (cur_group= join->group_list; cur_group; cur_group= cur_group->next) (*cur_group->item)->walk(&Item::collect_item_field_processor, 0, - (byte*) &indexed_fields); + (uchar*) &indexed_fields); } else if (join->select_distinct) { /* Collect all query fields referenced in the SELECT clause. */ @@ -3787,7 +3787,7 @@ add_group_and_distinct_keys(JOIN *join, JOIN_TAB *join_tab) Item *item; while ((item= select_items_it++)) item->walk(&Item::collect_item_field_processor, 0, - (byte*) &indexed_fields); + (uchar*) &indexed_fields); } else return; @@ -4608,7 +4608,7 @@ optimize_straight_join(JOIN *join, table_map join_tables) if (join->sort_by_table && join->sort_by_table != join->positions[join->const_tables].table->table) read_time+= record_count; // We have to make a temp table - memcpy((gptr) join->best_positions, (gptr) join->positions, + memcpy((uchar*) join->best_positions, (uchar*) join->positions, sizeof(POSITION)*idx); join->best_read= read_time; } @@ -4990,7 +4990,7 @@ best_extension_by_limited_search(JOIN *join, current_read_time+= current_record_count; if ((search_depth == 1) || (current_read_time < join->best_read)) { - memcpy((gptr) join->best_positions, (gptr) join->positions, + memcpy((uchar*) join->best_positions, (uchar*) join->positions, sizeof(POSITION) * (idx + 1)); join->best_read= current_read_time - 0.001; } @@ -5028,7 +5028,7 @@ find_best(JOIN *join,table_map rest_tables,uint idx,double record_count, read_time+=record_count; // We have to make a temp table if (read_time < join->best_read) { - memcpy((gptr) join->best_positions,(gptr) join->positions, + memcpy((uchar*) join->best_positions,(uchar*) join->positions, sizeof(POSITION)*idx); join->best_read= read_time - 0.001; } @@ -5339,7 +5339,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse, j->ref.key_parts=keyparts; j->ref.key_length=length; j->ref.key=(int) key; - if (!(j->ref.key_buff= (byte*) thd->calloc(ALIGN_SIZE(length)*2)) || + if (!(j->ref.key_buff= (uchar*) thd->calloc(ALIGN_SIZE(length)*2)) || !(j->ref.key_copy= (store_key**) thd->alloc((sizeof(store_key*) * (keyparts+1)))) || !(j->ref.items= (Item**) thd->alloc(sizeof(Item*)*keyparts)) || @@ -5353,7 +5353,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse, keyuse=org_keyuse; store_key **ref_key= j->ref.key_copy; - byte *key_buff=j->ref.key_buff, *null_ref_key= 0; + uchar *key_buff=j->ref.key_buff, *null_ref_key= 0; bool keyuse_uses_no_tables= TRUE; if (ftkey) { @@ -5384,8 +5384,8 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse, !(join->select_options & SELECT_DESCRIBE)) { // Compare against constant store_key_item tmp(thd, keyinfo->key_part[i].field, - (char*)key_buff + maybe_null, - maybe_null ? (char*) key_buff : 0, + key_buff + maybe_null, + maybe_null ? key_buff : 0, keyinfo->key_part[i].length, keyuse->val); if (thd->is_fatal_error) DBUG_RETURN(TRUE); @@ -5395,7 +5395,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse, *ref_key++= get_store_key(thd, keyuse,join->const_table_map, &keyinfo->key_part[i], - (char*) key_buff,maybe_null); + key_buff, maybe_null); /* Remember if we are going to use REF_OR_NULL But only if field _really_ can be null i.e. we force JT_REF @@ -5439,7 +5439,7 @@ static bool create_ref_for_key(JOIN *join, JOIN_TAB *j, KEYUSE *org_keyuse, static store_key * get_store_key(THD *thd, KEYUSE *keyuse, table_map used_tables, - KEY_PART_INFO *key_part, char *key_buff, uint maybe_null) + KEY_PART_INFO *key_part, uchar *key_buff, uint maybe_null) { if (!((~used_tables) & keyuse->used_tables)) // if const item { @@ -5938,7 +5938,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) { DBUG_EXECUTE("where",print_where(tmp,tab->table->alias);); SQL_SELECT *sel= tab->select= ((SQL_SELECT*) - thd->memdup((gptr) select, + thd->memdup((uchar*) select, sizeof(*select))); if (!sel) DBUG_RETURN(1); // End of memory @@ -6090,7 +6090,7 @@ make_join_select(JOIN *join,SQL_SELECT *select,COND *cond) { DBUG_EXECUTE("where",print_where(tmp,"cache");); tab->cache.select=(SQL_SELECT*) - thd->memdup((gptr) sel, sizeof(SQL_SELECT)); + thd->memdup((uchar*) sel, sizeof(SQL_SELECT)); tab->cache.select->cond=tmp; tab->cache.select->read_tables=join->const_table_map; } @@ -7527,11 +7527,11 @@ static COND *build_equal_items_for_cond(THD *thd, COND *cond, as soon the field is not of a string type or the field reference is an argument of a comparison predicate. */ - byte *is_subst_valid= (byte *) 1; + uchar *is_subst_valid= (uchar *) 1; cond= cond->compile(&Item::subst_argument_checker, &is_subst_valid, &Item::equal_fields_propagator, - (byte *) inherited); + (uchar *) inherited); cond->update_used_tables(); } return cond; @@ -9290,7 +9290,7 @@ Field *create_tmp_field(THD *thd, TABLE *table,Item *item, Item::Type type, a tmp_set bitmap to be used by things like filesort. */ -void setup_tmp_table_column_bitmaps(TABLE *table, byte *bitmaps) +void setup_tmp_table_column_bitmaps(TABLE *table, uchar *bitmaps) { uint field_count= table->s->fields; bitmap_init(&table->def_read_set, (my_bitmap_map*) bitmaps, field_count, @@ -9360,7 +9360,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, bool use_packed_rows= 0; bool not_all_columns= !(select_options & TMP_TABLE_ALL_COLUMNS); char *tmpname,path[FN_REFLEN]; - byte *pos, *group_buff, *bitmaps; + uchar *pos, *group_buff, *bitmaps; uchar *null_flags; Field **reg_field, **from_field, **default_field; uint *blob_field; @@ -9704,7 +9704,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, { uint alloc_length=ALIGN_SIZE(reclength+MI_UNIQUE_HASH_LENGTH+1); share->rec_buff_length= alloc_length; - if (!(table->record[0]= (byte*) + if (!(table->record[0]= (uchar*) alloc_root(&table->mem_root, alloc_length*3))) goto err; table->record[1]= table->record[0]+alloc_length; @@ -9720,7 +9720,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, pos=table->record[0]+ null_pack_length; if (null_pack_length) { - bzero((byte*) recinfo,sizeof(*recinfo)); + bzero((uchar*) recinfo,sizeof(*recinfo)); recinfo->type=FIELD_NORMAL; recinfo->length=null_pack_length; recinfo++; @@ -9736,7 +9736,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, { Field *field= *reg_field; uint length; - bzero((byte*) recinfo,sizeof(*recinfo)); + bzero((uchar*) recinfo,sizeof(*recinfo)); if (!(field->flags & NOT_NULL_FLAG)) { @@ -9750,19 +9750,19 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, recinfo->length=1; recinfo->type=FIELD_NORMAL; recinfo++; - bzero((byte*) recinfo,sizeof(*recinfo)); + bzero((uchar*) recinfo,sizeof(*recinfo)); } else { recinfo->null_bit= 1 << (null_count & 7); recinfo->null_pos= null_count/8; } - field->move_field((char*) pos,null_flags+null_count/8, + field->move_field(pos,null_flags+null_count/8, 1 << (null_count & 7)); null_count++; } else - field->move_field((char*) pos,(uchar*) 0,0); + field->move_field(pos,(uchar*) 0,0); if (field->type() == MYSQL_TYPE_BIT) { /* We have to reserve place for extra bits among null bits */ @@ -9880,10 +9880,10 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, { cur_group->buff=(char*) group_buff; if (!(cur_group->field= field->new_key_field(thd->mem_root,table, - (char*) group_buff + - test(maybe_null), - field->null_ptr, - field->null_bit))) + group_buff + + test(maybe_null), + field->null_ptr, + field->null_bit))) goto err; /* purecov: inspected */ if (maybe_null) { @@ -9945,7 +9945,7 @@ create_tmp_table(THD *thd,TMP_TABLE_PARAM *param,List<Item> &fields, key_part_info->null_bit=0; key_part_info->offset=hidden_null_pack_length; key_part_info->length=null_pack_length; - key_part_info->field= new Field_string((char*) table->record[0], + key_part_info->field= new Field_string(table->record[0], (uint32) key_part_info->length, (uchar*) 0, (uint) 0, @@ -10034,7 +10034,7 @@ TABLE *create_virtual_tmp_table(THD *thd, List<create_field> &field_list) uint null_count= 0; /* number of columns which may be null */ uint null_pack_length; /* NULL representation array length */ uint *blob_field; - byte *bitmaps; + uchar *bitmaps; TABLE *table; TABLE_SHARE *share; @@ -10085,7 +10085,7 @@ TABLE *create_virtual_tmp_table(THD *thd, List<create_field> &field_list) null_pack_length= (null_count + 7)/8; share->reclength= record_length + null_pack_length; share->rec_buff_length= ALIGN_SIZE(share->reclength + 1); - table->record[0]= (byte*) thd->alloc(share->rec_buff_length); + table->record[0]= (uchar*) thd->alloc(share->rec_buff_length); if (!table->record[0]) goto error; @@ -10099,18 +10099,18 @@ TABLE *create_virtual_tmp_table(THD *thd, List<create_field> &field_list) table->in_use= thd; /* field->reset() may access table->in_use */ { /* Set up field pointers */ - byte *null_pos= table->record[0]; - byte *field_pos= null_pos + share->null_bytes; + uchar *null_pos= table->record[0]; + uchar *field_pos= null_pos + share->null_bytes; uint null_bit= 1; for (field= table->field; *field; ++field) { Field *cur_field= *field; if ((cur_field->flags & NOT_NULL_FLAG)) - cur_field->move_field((char*) field_pos); + cur_field->move_field(field_pos); else { - cur_field->move_field((char*) field_pos, (uchar*) null_pos, null_bit); + cur_field->move_field(field_pos, (uchar*) null_pos, null_bit); null_bit<<= 1; if (null_bit == (1 << 8)) { @@ -10179,7 +10179,7 @@ static bool create_myisam_tmp_table(TABLE *table,TMP_TABLE_PARAM *param, uniquedef.null_are_equal=1; /* Create extra column for hash value */ - bzero((byte*) param->recinfo,sizeof(*param->recinfo)); + bzero((uchar*) param->recinfo,sizeof(*param->recinfo)); param->recinfo->type= FIELD_CHECK; param->recinfo->length=MI_UNIQUE_HASH_LENGTH; param->recinfo++; @@ -11228,7 +11228,7 @@ join_read_const(JOIN_TAB *tab) else { error=table->file->index_read_idx(table->record[0],tab->ref.key, - (byte*) tab->ref.key_buff, + (uchar*) tab->ref.key_buff, make_prev_keypart_map(tab->ref.key_parts), HA_READ_KEY_EXACT); } @@ -11805,7 +11805,7 @@ end_write(JOIN *join, JOIN_TAB *join_tab __attribute__((unused)), if (item->maybe_null) { Field *field=item->get_tmp_table_field(); - field->ptr[-1]= (byte) (field->is_null() ? 1 : 0); + field->ptr[-1]= (uchar) (field->is_null() ? 1 : 0); } } } @@ -12994,7 +12994,7 @@ static int remove_dup_with_compare(THD *thd, TABLE *table, Field **first_field, { handler *file=table->file; char *org_record,*new_record; - byte *record; + uchar *record; int error; ulong reclength= table->s->reclength-offset; DBUG_ENTER("remove_dup_with_compare"); @@ -13085,7 +13085,7 @@ static int remove_dup_with_hash_index(THD *thd, TABLE *table, ulong key_length, Item *having) { - byte *key_buffer, *key_pos, *record=table->record[0]; + uchar *key_buffer, *key_pos, *record=table->record[0]; int error; handler *file= table->file; ulong extra_length= ALIGN_SIZE(key_length)-key_length; @@ -13129,7 +13129,7 @@ static int remove_dup_with_hash_index(THD *thd, TABLE *table, key_pos=key_buffer; for (;;) { - byte *org_key_pos; + uchar *org_key_pos; if (thd->killed) { thd->send_kill_message(); @@ -13156,7 +13156,7 @@ static int remove_dup_with_hash_index(THD *thd, TABLE *table, field_length=field_lengths; for (Field **ptr= first_field ; *ptr ; ptr++) { - (*ptr)->sort_string((char*) key_pos,*field_length); + (*ptr)->sort_string(key_pos,*field_length); key_pos+= *field_length++; } /* Check if it exists before */ @@ -13259,7 +13259,7 @@ join_init_cache(THD *thd,JOIN_TAB *tables,uint table_count) sizeof(CACHE_FIELD*)))) { - my_free((gptr) cache->buff,MYF(0)); /* purecov: inspected */ + my_free((uchar*) cache->buff,MYF(0)); /* purecov: inspected */ cache->buff=0; /* purecov: inspected */ DBUG_RETURN(1); /* purecov: inspected */ } @@ -13292,7 +13292,7 @@ join_init_cache(THD *thd,JOIN_TAB *tables,uint table_count) /* Copy null bits from table */ if (null_fields && tables[i].table->s->null_fields) { /* must copy null bits */ - copy->str=(char*) tables[i].table->null_flags; + copy->str= tables[i].table->null_flags; copy->length= tables[i].table->s->null_bytes; copy->strip=0; copy->blob_field=0; @@ -13303,7 +13303,7 @@ join_init_cache(THD *thd,JOIN_TAB *tables,uint table_count) /* If outer join table, copy null_row flag */ if (tables[i].table->maybe_null) { - copy->str= (char*) &tables[i].table->null_row; + copy->str= (uchar*) &tables[i].table->null_row; copy->length=sizeof(tables[i].table->null_row); copy->strip=0; copy->blob_field=0; @@ -13366,13 +13366,13 @@ store_record_in_cache(JOIN_CACHE *cache) { if (last_record) { - copy->blob_field->get_image((char*) pos,copy->length+sizeof(char*), + copy->blob_field->get_image(pos, copy->length+sizeof(char*), copy->blob_field->charset()); pos+=copy->length+sizeof(char*); } else { - copy->blob_field->get_image((char*) pos,copy->length, // blob length + copy->blob_field->get_image(pos, copy->length, // blob length copy->blob_field->charset()); memcpy(pos+copy->length,copy->str,copy->blob_length); // Blob data pos+=copy->length+copy->blob_length; @@ -13382,7 +13382,7 @@ store_record_in_cache(JOIN_CACHE *cache) { if (copy->strip) { - char *str,*end; + uchar *str,*end; for (str=copy->str,end= str+copy->length; end > str && end[-1] == ' ' ; end--) ; @@ -13438,13 +13438,13 @@ read_cached_record(JOIN_TAB *tab) { if (last_record) { - copy->blob_field->set_image((char*) pos,copy->length+sizeof(char*), + copy->blob_field->set_image(pos, copy->length+sizeof(char*), copy->blob_field->charset()); pos+=copy->length+sizeof(char*); } else { - copy->blob_field->set_ptr((char*) pos,(char*) pos+copy->length); + copy->blob_field->set_ptr(pos, pos+copy->length); pos+=copy->length+copy->blob_field->get_length(); } } @@ -14194,7 +14194,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, for (i= 0; (pos= li++); i++) { Field *field; - char *tmp; + uchar *tmp; Item *real_pos= pos->real_item(); if (real_pos->type() == Item::FIELD_ITEM) { @@ -14239,8 +14239,7 @@ setup_copy_fields(THD *thd, TMP_TABLE_PARAM *param, another extra byte to not get warnings from purify in Field_string::val_int */ - tmp= (char*) sql_alloc(field->pack_length()+2); - if (!tmp) + if (!(tmp= (uchar*) sql_alloc(field->pack_length()+2))) goto err; if (copy) { diff --git a/sql/sql_select.h b/sql/sql_select.h index 971b7caf69d..290a0f5d992 100644 --- a/sql/sql_select.h +++ b/sql/sql_select.h @@ -56,8 +56,8 @@ typedef struct st_table_ref uint key_parts; // num of ... uint key_length; // length of key_buff int key; // key no - byte *key_buff; // value to look for with key - byte *key_buff2; // key_buff+key_length + uchar *key_buff; // value to look for with key + uchar *key_buff2; // key_buff+key_length store_key **key_copy; // Item **items; // val()'s for each keypart /* @@ -79,7 +79,7 @@ typedef struct st_table_ref key_part_map null_rejecting; table_map depend_map; // Table depends on these tables. /* null byte position in the key_buf. Used for REF_OR_NULL optimization */ - byte *null_ref_key; + uchar *null_ref_key; } TABLE_REF; @@ -89,8 +89,8 @@ typedef struct st_table_ref */ typedef struct st_cache_field { - char *str; - uint length,blob_length; + uchar *str; + uint length, blob_length; Field_blob *blob_field; bool strip; } CACHE_FIELD; @@ -538,20 +538,20 @@ class store_key :public Sql_alloc public: bool null_key; /* TRUE <=> the value of the key has a null part */ enum store_key_result { STORE_KEY_OK, STORE_KEY_FATAL, STORE_KEY_CONV }; - store_key(THD *thd, Field *field_arg, char *ptr, char *null, uint length) + store_key(THD *thd, Field *field_arg, uchar *ptr, uchar *null, uint length) :null_key(0), null_ptr(null), err(0) { if (field_arg->type() == MYSQL_TYPE_BLOB) { /* Key segments are always packed with a 2 byte length prefix */ - to_field= new Field_varstring(ptr, length, 2, (uchar*) null, 1, + to_field= new Field_varstring(ptr, length, 2, null, 1, Field::NONE, field_arg->field_name, field_arg->table->s, field_arg->charset()); to_field->init(field_arg->table); } else to_field=field_arg->new_key_field(thd->mem_root, field_arg->table, - ptr, (uchar*) null, 1); + ptr, null, 1); } virtual ~store_key() {} /* Not actually needed */ virtual const char *name() const=0; @@ -579,8 +579,8 @@ public: protected: Field *to_field; // Store data here - char *null_ptr; - char err; + uchar *null_ptr; + uchar err; virtual enum store_key_result copy_inner()=0; }; @@ -591,11 +591,12 @@ class store_key_field: public store_key Copy_field copy_field; const char *field_name; public: - store_key_field(THD *thd, Field *to_field_arg, char *ptr, char *null_ptr_arg, + store_key_field(THD *thd, Field *to_field_arg, uchar *ptr, + uchar *null_ptr_arg, uint length, Field *from_field, const char *name_arg) :store_key(thd, to_field_arg,ptr, null_ptr_arg ? null_ptr_arg : from_field->maybe_null() ? &err - : NullS,length), field_name(name_arg) + : (uchar*) 0, length), field_name(name_arg) { if (to_field) { @@ -623,11 +624,11 @@ class store_key_item :public store_key protected: Item *item; public: - store_key_item(THD *thd, Field *to_field_arg, char *ptr, char *null_ptr_arg, - uint length, Item *item_arg) - :store_key(thd, to_field_arg,ptr, + store_key_item(THD *thd, Field *to_field_arg, uchar *ptr, + uchar *null_ptr_arg, uint length, Item *item_arg) + :store_key(thd, to_field_arg, ptr, null_ptr_arg ? null_ptr_arg : item_arg->maybe_null ? - &err : NullS, length), item(item_arg) + &err : (uchar*) 0, length), item(item_arg) {} const char *name() const { return "func"; } @@ -649,12 +650,12 @@ class store_key_const_item :public store_key_item { bool inited; public: - store_key_const_item(THD *thd, Field *to_field_arg, char *ptr, - char *null_ptr_arg, uint length, + store_key_const_item(THD *thd, Field *to_field_arg, uchar *ptr, + uchar *null_ptr_arg, uint length, Item *item_arg) :store_key_item(thd, to_field_arg,ptr, null_ptr_arg ? null_ptr_arg : item_arg->maybe_null ? - &err : NullS, length, item_arg), inited(0) + &err : (uchar*) 0, length, item_arg), inited(0) { } const char *name() const { return "const"; } diff --git a/sql/sql_servers.cc b/sql/sql_servers.cc index a62ce98850b..195e6743a72 100644 --- a/sql/sql_servers.cc +++ b/sql/sql_servers.cc @@ -77,7 +77,7 @@ static void merge_server_struct(FOREIGN_SERVER *from, FOREIGN_SERVER *to); -static byte *servers_cache_get_key(FOREIGN_SERVER *server, uint *length, +static uchar *servers_cache_get_key(FOREIGN_SERVER *server, size_t *length, my_bool not_used __attribute__((unused))) { DBUG_ENTER("servers_cache_get_key"); @@ -86,7 +86,7 @@ static byte *servers_cache_get_key(FOREIGN_SERVER *server, uint *length, server->server_name)); *length= (uint) server->server_name_length; - DBUG_RETURN((byte*) server->server_name); + DBUG_RETURN((uchar*) server->server_name); } @@ -323,7 +323,7 @@ get_server_from_table_to_cache(TABLE *table) DBUG_PRINT("info", ("server->username %s", server->username)); DBUG_PRINT("info", ("server->password %s", server->password)); DBUG_PRINT("info", ("server->socket %s", server->socket)); - if (my_hash_insert(&servers_cache, (byte*) server)) + if (my_hash_insert(&servers_cache, (uchar*) server)) { DBUG_PRINT("info", ("had a problem inserting server %s at %lx", server->server_name, (long unsigned int) server)); @@ -411,7 +411,7 @@ insert_server_record_into_cache(FOREIGN_SERVER *server) DBUG_PRINT("info", ("inserting server %s at %lx, length %d", server->server_name, (long unsigned int) server, server->server_name_length)); - if (my_hash_insert(&servers_cache, (byte*) server)) + if (my_hash_insert(&servers_cache, (uchar*) server)) { DBUG_PRINT("info", ("had a problem inserting server %s at %lx", server->server_name, (long unsigned int) server)); @@ -517,7 +517,7 @@ int insert_server_record(TABLE *table, FOREIGN_SERVER *server) /* read index until record is that specified in server_name */ if ((error= table->file->index_read_idx(table->record[0], 0, - (byte *)table->field[0]->ptr, HA_WHOLE_KEY, + (uchar *)table->field[0]->ptr, HA_WHOLE_KEY, HA_READ_KEY_EXACT))) { /* if not found, err */ @@ -642,7 +642,7 @@ delete_server_record_in_cache(LEX_SERVER_OPTIONS *server_options) if (!(server= (FOREIGN_SERVER *) hash_search(&servers_cache, - (byte*) server_options->server_name, + (uchar*) server_options->server_name, server_options->server_name_length))) { DBUG_PRINT("info", ("server_name %s length %d not found!", @@ -658,7 +658,7 @@ delete_server_record_in_cache(LEX_SERVER_OPTIONS *server_options) server->server_name, server->server_name_length)); - VOID(hash_delete(&servers_cache, (byte*) server)); + VOID(hash_delete(&servers_cache, (uchar*) server)); error= 0; @@ -765,12 +765,12 @@ int update_server_record_in_cache(FOREIGN_SERVER *existing, /* delete the existing server struct from the server cache */ - VOID(hash_delete(&servers_cache, (byte*)existing)); + VOID(hash_delete(&servers_cache, (uchar*)existing)); /* Insert the altered server struct into the server cache */ - if (my_hash_insert(&servers_cache, (byte*)altered)) + if (my_hash_insert(&servers_cache, (uchar*)altered)) { DBUG_PRINT("info", ("had a problem inserting server %s at %lx", altered->server_name, (long unsigned int) altered)); @@ -859,7 +859,7 @@ update_server_record(TABLE *table, FOREIGN_SERVER *server) system_charset_info); if ((error= table->file->index_read_idx(table->record[0], 0, - (byte *)table->field[0]->ptr, ~(longlong)0, + (uchar *)table->field[0]->ptr, ~(longlong)0, HA_READ_KEY_EXACT))) { if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE) @@ -911,7 +911,7 @@ delete_server_record(TABLE *table, table->field[0]->store(server_name, server_name_length, system_charset_info); if ((error= table->file->index_read_idx(table->record[0], 0, - (byte *)table->field[0]->ptr, HA_WHOLE_KEY, + (uchar *)table->field[0]->ptr, HA_WHOLE_KEY, HA_READ_KEY_EXACT))) { if (error != HA_ERR_KEY_NOT_FOUND && error != HA_ERR_END_OF_FILE) @@ -954,7 +954,7 @@ int create_server(THD *thd, LEX_SERVER_OPTIONS *server_options) rw_wrlock(&THR_LOCK_servers); /* hit the memory first */ - if (hash_search(&servers_cache, (byte*) server_options->server_name, + if (hash_search(&servers_cache, (uchar*) server_options->server_name, server_options->server_name_length)) goto end; @@ -1000,7 +1000,7 @@ int alter_server(THD *thd, LEX_SERVER_OPTIONS *server_options) rw_wrlock(&THR_LOCK_servers); if (!(existing= (FOREIGN_SERVER *) hash_search(&servers_cache, - (byte*) name.str, + (uchar*) name.str, name.length))) goto end; @@ -1260,7 +1260,7 @@ FOREIGN_SERVER *get_server_by_name(MEM_ROOT *mem, const char *server_name, DBUG_PRINT("info", ("locking servers_cache")); rw_rdlock(&THR_LOCK_servers); if (!(server= (FOREIGN_SERVER *) hash_search(&servers_cache, - (byte*) server_name, + (uchar*) server_name, server_name_length))) { DBUG_PRINT("info", ("server_name %s length %d not found!", diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 84ddbc50712..9aa444aa4c0 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -831,7 +831,7 @@ mysqld_dump_create_info(THD *thd, TABLE_LIST *table_list, int fd) } else { - if (my_write(fd, (const byte*) packet->ptr(), packet->length(), + if (my_write(fd, (const uchar*) packet->ptr(), packet->length(), MYF(MY_WME))) DBUG_RETURN(-1); } @@ -1660,7 +1660,7 @@ void mysqld_list_processes(THD *thd,const char *user, bool verbose) if (tmp->peer_port && (tmp_sctx->host || tmp_sctx->ip) && thd->security_ctx->host_or_ip[0]) { - if ((thd_info->host= thd->alloc(LIST_PROCESS_HOST_LEN+1))) + if ((thd_info->host= (char*) thd->alloc(LIST_PROCESS_HOST_LEN+1))) my_snprintf((char *) thd_info->host, LIST_PROCESS_HOST_LEN, "%s:%u", tmp_sctx->host_or_ip, tmp->peer_port); } @@ -1912,8 +1912,8 @@ int add_status_vars(SHOW_VAR *list) goto err; } while (list->name) - res|= insert_dynamic(&all_status_vars, (gptr)list++); - res|= insert_dynamic(&all_status_vars, (gptr)list); // appending NULL-element + res|= insert_dynamic(&all_status_vars, (uchar*)list++); + res|= insert_dynamic(&all_status_vars, (uchar*)list); // appending NULL-element all_status_vars.elements--; // but next insert_dynamic should overwite it if (status_vars_inited) sort_dynamic(&all_status_vars, show_var_cmp); @@ -3098,7 +3098,7 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, for (ptr=show_table->field; (field= *ptr) ; ptr++) { const char *tmp_buff; - byte *pos; + uchar *pos; bool is_blob; uint flags=field->flags; char tmp[MAX_FIELD_WIDTH]; @@ -3176,7 +3176,7 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, table->field[5]->store("",0, cs); table->field[5]->set_notnull(); } - pos=(byte*) ((flags & NOT_NULL_FLAG) ? "NO" : "YES"); + pos=(uchar*) ((flags & NOT_NULL_FLAG) ? "NO" : "YES"); table->field[6]->store((const char*) pos, strlen((const char*) pos), cs); is_blob= (field->type() == MYSQL_TYPE_BLOB); @@ -3244,16 +3244,16 @@ static int get_schema_column_record(THD *thd, struct st_table_list *tables, if (field->has_charset()) { - pos=(byte*) field->charset()->csname; + pos=(uchar*) field->charset()->csname; table->field[12]->store((const char*) pos, strlen((const char*) pos), cs); table->field[12]->set_notnull(); - pos=(byte*) field->charset()->name; + pos=(uchar*) field->charset()->name; table->field[13]->store((const char*) pos, strlen((const char*) pos), cs); table->field[13]->set_notnull(); } - pos=(byte*) ((field->flags & PRI_KEY_FLAG) ? "PRI" : + pos=(uchar*) ((field->flags & PRI_KEY_FLAG) ? "PRI" : (field->flags & UNIQUE_KEY_FLAG) ? "UNI" : (field->flags & MULTIPLE_KEY_FLAG) ? "MUL":""); table->field[15]->store((const char*) pos, @@ -3974,6 +3974,7 @@ static int get_schema_key_column_usage_record(THD *thd, } +#ifdef WITH_PARTITION_STORAGE_ENGINE static void collect_partition_expr(List<char> &field_list, String *str) { List_iterator<char> part_it(field_list); @@ -3988,6 +3989,7 @@ static void collect_partition_expr(List<char> &field_list, String *str) } return; } +#endif static void store_schema_partitions_record(THD *thd, TABLE *schema_table, @@ -5852,7 +5854,7 @@ int initialize_schema_table(st_plugin_int *plugin) DBUG_RETURN(0); err: - my_free((gptr)schema_table, MYF(0)); + my_free(schema_table, MYF(0)); DBUG_RETURN(1); } @@ -5869,8 +5871,7 @@ int finalize_schema_table(st_plugin_int *plugin) DBUG_PRINT("warning", ("Plugin '%s' deinit function returned error.", plugin->name.str)); } - my_free((gptr)schema_table, MYF(0)); + my_free(schema_table, MYF(0)); } - DBUG_RETURN(0); } diff --git a/sql/sql_string.cc b/sql/sql_string.cc index 52af2f2dd90..6c7dea6bf22 100644 --- a/sql/sql_string.cc +++ b/sql/sql_string.cc @@ -32,7 +32,7 @@ required by the string function */ -extern gptr sql_alloc(unsigned size); +extern uchar* sql_alloc(unsigned size); extern void sql_element_free(void *ptr); #include "sql_string.h" @@ -496,7 +496,7 @@ bool String::append(FILE* file, uint32 arg_length, myf my_flags) { if (realloc(str_length+arg_length)) return TRUE; - if (my_fread(file, (byte*) Ptr + str_length, arg_length, my_flags)) + if (my_fread(file, (uchar*) Ptr + str_length, arg_length, my_flags)) { shrink(str_length); return TRUE; @@ -510,7 +510,7 @@ bool String::append(IO_CACHE* file, uint32 arg_length) { if (realloc(str_length+arg_length)) return TRUE; - if (my_b_read(file, (byte*) Ptr + str_length, arg_length)) + if (my_b_read(file, (uchar*) Ptr + str_length, arg_length)) { shrink(str_length); return TRUE; @@ -635,7 +635,7 @@ bool String::replace(uint32 offset,uint32 arg_length, { if (realloc(str_length+(uint32) diff)) return TRUE; - bmove_upp(Ptr+str_length+diff,Ptr+str_length, + bmove_upp((uchar*) Ptr+str_length+diff, (uchar*) Ptr+str_length, str_length-offset-arg_length); } if (to_length) diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 0662747d6b2..dbcd7cf07c6 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -319,11 +319,11 @@ static bool read_ddl_log_file_entry(uint entry_no) { bool error= FALSE; File file_id= global_ddl_log.file_id; - char *file_entry_buf= (char*)global_ddl_log.file_entry_buf; + uchar *file_entry_buf= (uchar*)global_ddl_log.file_entry_buf; uint io_size= global_ddl_log.io_size; DBUG_ENTER("read_ddl_log_file_entry"); - if (my_pread(file_id, (byte*)file_entry_buf, io_size, io_size * entry_no, + if (my_pread(file_id, file_entry_buf, io_size, io_size * entry_no, MYF(MY_WME)) != io_size) error= TRUE; DBUG_RETURN(error); @@ -347,7 +347,7 @@ static bool write_ddl_log_file_entry(uint entry_no) char *file_entry_buf= (char*)global_ddl_log.file_entry_buf; DBUG_ENTER("write_ddl_log_file_entry"); - if (my_pwrite(file_id, (byte*)file_entry_buf, + if (my_pwrite(file_id, (uchar*)file_entry_buf, IO_SIZE, IO_SIZE * entry_no, MYF(MY_WME)) != IO_SIZE) error= TRUE; DBUG_RETURN(error); @@ -560,7 +560,9 @@ static int execute_ddl_log_action(THD *thd, DDL_LOG_ENTRY *ddl_log_entry) int error= TRUE; char to_path[FN_REFLEN]; char from_path[FN_REFLEN]; +#ifdef WITH_PARTITION_STORAGE_ENGINE char *par_ext= (char*)".par"; +#endif handlerton *hton; DBUG_ENTER("execute_ddl_log_action"); @@ -1143,13 +1145,13 @@ void release_ddl_log() while (used_list) { DDL_LOG_MEMORY_ENTRY *tmp= used_list->next_log_entry; - my_free((char*)used_list, MYF(0)); + my_free(used_list, MYF(0)); used_list= tmp; } while (free_list) { DDL_LOG_MEMORY_ENTRY *tmp= free_list->next_log_entry; - my_free((char*)free_list, MYF(0)); + my_free(free_list, MYF(0)); free_list= tmp; } close_ddl_log(); @@ -1268,13 +1270,13 @@ bool mysql_write_frm(ALTER_PARTITION_PARAM_TYPE *lpt, uint flags) handlers that have the main version of the frm file stored in the handler. */ - const void *data= 0; - uint length= 0; + uchar *data; + size_t length; if (readfrm(shadow_path, &data, &length) || packfrm(data, length, &lpt->pack_frm_data, &lpt->pack_frm_len)) { - my_free((char*)data, MYF(MY_ALLOW_ZERO_PTR)); - my_free((char*)lpt->pack_frm_data, MYF(MY_ALLOW_ZERO_PTR)); + my_free(data, MYF(MY_ALLOW_ZERO_PTR)); + my_free(lpt->pack_frm_data, MYF(MY_ALLOW_ZERO_PTR)); mem_alloc_error(length); error= 1; goto end; @@ -2926,7 +2928,7 @@ mysql_prepare_create_table(THD *thd, HA_CREATE_INFO *create_info, DBUG_RETURN(TRUE); } /* Sort keys in optimized order */ - qsort((gptr) *key_info_buffer, *key_count, sizeof(KEY), + qsort((uchar*) *key_info_buffer, *key_count, sizeof(KEY), (qsort_cmp) sort_keys); create_info->null_bits= null_fields; @@ -3478,7 +3480,7 @@ bool mysql_create_table(THD *thd, const char *db, const char *table_name, /* Wait for any database locks */ pthread_mutex_lock(&LOCK_lock_db); while (!thd->killed && - hash_search(&lock_db_cache,(byte*) db, strlen(db))) + hash_search(&lock_db_cache,(uchar*) db, strlen(db))) { wait_for_condition(thd, &LOCK_lock_db, &COND_refresh); pthread_mutex_lock(&LOCK_lock_db); @@ -4021,7 +4023,7 @@ static bool mysql_admin_table(THD* thd, TABLE_LIST* tables, table->next_global= 0; save_next_local= table->next_local; table->next_local= 0; - select->table_list.first= (byte*)table; + select->table_list.first= (uchar*)table; /* Time zone tables and SP tables can be add to lex->query_tables list, so it have to be prepared. @@ -6438,7 +6440,7 @@ view_err: { /* Close the intermediate table that will be the new table */ intern_close_table(new_table); - my_free((gptr) new_table,MYF(0)); + my_free(new_table,MYF(0)); } VOID(pthread_mutex_lock(&LOCK_open)); if (error) @@ -6619,7 +6621,7 @@ view_err: if (t_table) { intern_close_table(t_table); - my_free((char*) t_table, MYF(0)); + my_free(t_table, MYF(0)); } else sql_print_warning("Could not open table %s.%s after rename\n", @@ -6815,7 +6817,7 @@ copy_data_between_tables(TABLE *from,TABLE *to, copy_ptr->do_copy(copy_ptr); } prev_insert_id= to->file->next_insert_id; - error=to->file->write_row((byte*) to->record[0]); + error=to->file->write_row(to->record[0]); to->auto_increment_field_not_null= FALSE; if (error) { @@ -6996,10 +6998,10 @@ bool mysql_checksum_table(THD *thd, TABLE_LIST *tables, { String tmp; f->val_str(&tmp); - row_crc= my_checksum(row_crc, (byte*) tmp.ptr(), tmp.length()); + row_crc= my_checksum(row_crc, (uchar*) tmp.ptr(), tmp.length()); } else - row_crc= my_checksum(row_crc, (byte*) f->ptr, + row_crc= my_checksum(row_crc, f->ptr, f->pack_length()); } diff --git a/sql/sql_test.cc b/sql/sql_test.cc index 86744fb1bf5..5bd01eea68c 100644 --- a/sql/sql_test.cc +++ b/sql/sql_test.cc @@ -349,7 +349,7 @@ static void push_locks_into_array(DYNAMIC_ARRAY *ar, THR_LOCK_DATA *data, table_lock_info.lock_text=text; // lock_type is also obtainable from THR_LOCK_DATA table_lock_info.type=table->reginfo.lock_type; - VOID(push_dynamic(ar,(gptr) &table_lock_info)); + VOID(push_dynamic(ar,(uchar*) &table_lock_info)); } } } @@ -394,7 +394,7 @@ static void display_table_locks(void) VOID(pthread_mutex_unlock(&THR_LOCK_lock)); if (!saved_table_locks.elements) goto end; - qsort((gptr) dynamic_element(&saved_table_locks,0,TABLE_LOCK_INFO *),saved_table_locks.elements,sizeof(TABLE_LOCK_INFO),(qsort_cmp) dl_compare); + qsort((uchar*) dynamic_element(&saved_table_locks,0,TABLE_LOCK_INFO *),saved_table_locks.elements,sizeof(TABLE_LOCK_INFO),(qsort_cmp) dl_compare); freeze_size(&saved_table_locks); puts("\nThread database.table_name Locked/Waiting Lock_type\n"); diff --git a/sql/sql_trigger.cc b/sql/sql_trigger.cc index bdfcef23101..e15003ab243 100644 --- a/sql/sql_trigger.cc +++ b/sql/sql_trigger.cc @@ -114,7 +114,7 @@ public: Handle_old_incorrect_sql_modes_hook(char *file_path) :path(file_path) {}; - virtual bool process_unknown_string(char *&unknown_key, gptr base, + virtual bool process_unknown_string(char *&unknown_key, uchar* base, MEM_ROOT *mem_root, char *end); }; @@ -125,7 +125,7 @@ public: LEX_STRING *trigger_table_arg) :path(file_path), trigger_table_value(trigger_table_arg) {}; - virtual bool process_unknown_string(char *&unknown_key, gptr base, + virtual bool process_unknown_string(char *&unknown_key, uchar* base, MEM_ROOT *mem_root, char *end); private: char *path; @@ -484,7 +484,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables, trigname.trigger_table.length= tables->table_name_length; if (sql_create_definition_file(NULL, &trigname_file, &trigname_file_type, - (gptr)&trigname, trigname_file_parameters, 0)) + (uchar*)&trigname, trigname_file_parameters, 0)) return 1; /* @@ -574,7 +574,7 @@ bool Table_triggers_list::create_trigger(THD *thd, TABLE_LIST *tables, /* Create trigger definition file. */ if (!sql_create_definition_file(NULL, &file, &triggers_file_type, - (gptr)this, triggers_file_parameters, 0)) + (uchar*)this, triggers_file_parameters, 0)) return 0; err_with_cleanup: @@ -654,7 +654,7 @@ static bool save_trigger_file(Table_triggers_list *triggers, const char *db, triggers_file_ext, 0); file.str= file_buff; return sql_create_definition_file(NULL, &file, &triggers_file_type, - (gptr)triggers, triggers_file_parameters, + (uchar*)triggers, triggers_file_parameters, 0); } @@ -865,7 +865,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, triggers->definition_modes_list.empty(); triggers->definers_list.empty(); - if (parser->parse((gptr)triggers, &table->mem_root, + if (parser->parse((uchar*)triggers, &table->mem_root, triggers_file_parameters, TRG_NUM_REQUIRED_PARAMETERS, &sql_modes_hook)) @@ -945,7 +945,7 @@ bool Table_triggers_list::check_n_load(THD *thd, const char *db, of routines used by statement. */ triggers->sroutines_key.length= 1+strlen(db)+1+strlen(table_name)+1; - if (!(triggers->sroutines_key.str= + if (!(triggers->sroutines_key.str= (char*) alloc_root(&table->mem_root, triggers->sroutines_key.length))) DBUG_RETURN(1); triggers->sroutines_key.str[0]= TYPE_ENUM_TRIGGER; @@ -1223,7 +1223,7 @@ add_table_for_trigger(THD *thd, sp_name *trig, bool if_exists, DBUG_RETURN(1); } - if (parser->parse((gptr)&trigname, thd->mem_root, + if (parser->parse((uchar*)&trigname, thd->mem_root, trigname_file_parameters, 1, &trigger_table_hook)) DBUG_RETURN(1); @@ -1360,8 +1360,8 @@ Table_triggers_list::change_table_name_in_triggers(THD *thd, It is OK to allocate some memory on table's MEM_ROOT since this table instance will be thrown out at the end of rename anyway. */ - new_def.str= memdup_root(&trigger_table->mem_root, buff.ptr(), - buff.length()); + new_def.str= (char*) memdup_root(&trigger_table->mem_root, buff.ptr(), + buff.length()); new_def.length= buff.length(); on_table_name->str= new_def.str + before_on_len; on_table_name->length= on_q_table_name_len; @@ -1422,7 +1422,7 @@ Table_triggers_list::change_table_name_in_trignames(const char *db_name, trigname.trigger_table= *new_table_name; if (sql_create_definition_file(NULL, &trigname_file, &trigname_file_type, - (gptr)&trigname, trigname_file_parameters, + (uchar*)&trigname, trigname_file_parameters, 0)) return trigger; } @@ -1663,7 +1663,7 @@ void Table_triggers_list::mark_fields_used(trg_event_type event) bool Handle_old_incorrect_sql_modes_hook::process_unknown_string(char *&unknown_key, - gptr base, + uchar* base, MEM_ROOT *mem_root, char *end) { @@ -1706,7 +1706,7 @@ Handle_old_incorrect_sql_modes_hook::process_unknown_string(char *&unknown_key, bool Handle_old_incorrect_trigger_table_hook:: -process_unknown_string(char *&unknown_key, gptr base, MEM_ROOT *mem_root, +process_unknown_string(char *&unknown_key, uchar* base, MEM_ROOT *mem_root, char *end) { DBUG_ENTER("Handle_old_incorrect_trigger_table_hook::process_unknown_string"); diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 505f7a9a765..20ce614f361 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -92,12 +92,12 @@ static char *init_syms(udf_func *tmp, char *nm) } -extern "C" byte* get_hash_key(const byte *buff,uint *length, +extern "C" uchar* get_hash_key(const uchar *buff, size_t *length, my_bool not_used __attribute__((unused))) { udf_func *udf=(udf_func*) buff; *length=(uint) udf->name.length; - return (byte*) udf->name.str; + return (uchar*) udf->name.str; } @@ -137,7 +137,7 @@ void udf_init() new_thd->store_globals(); new_thd->set_db(db, sizeof(db)-1); - bzero((gptr) &tables,sizeof(tables)); + bzero((uchar*) &tables,sizeof(tables)); tables.alias= tables.table_name= (char*) "func"; tables.lock_type = TL_READ; tables.db= db; @@ -267,7 +267,7 @@ static void del_udf(udf_func *udf) DBUG_ENTER("del_udf"); if (!--udf->usage_count) { - hash_delete(&udf_hash,(byte*) udf); + hash_delete(&udf_hash,(uchar*) udf); using_udf_functions=udf_hash.records != 0; } else @@ -281,7 +281,7 @@ static void del_udf(udf_func *udf) uint name_length=udf->name.length; udf->name.str=(char*) "*"; udf->name.length=1; - hash_update(&udf_hash,(byte*) udf,(byte*) name,name_length); + hash_update(&udf_hash,(uchar*) udf,(uchar*) name,name_length); } DBUG_VOID_RETURN; } @@ -301,7 +301,7 @@ void free_udf(udf_func *udf) We come here when someone has deleted the udf function while another thread still was using the udf */ - hash_delete(&udf_hash,(byte*) udf); + hash_delete(&udf_hash,(uchar*) udf); using_udf_functions=udf_hash.records != 0; if (!find_udf_dl(udf->dl)) dlclose(udf->dlhandle); @@ -327,7 +327,7 @@ udf_func *find_udf(const char *name,uint length,bool mark_used) else rw_rdlock(&THR_LOCK_udf); /* Called during parsing */ - if ((udf=(udf_func*) hash_search(&udf_hash,(byte*) name, + if ((udf=(udf_func*) hash_search(&udf_hash,(uchar*) name, length ? length : (uint) strlen(name)))) { if (!udf->dlhandle) @@ -374,7 +374,7 @@ static udf_func *add_udf(LEX_STRING *name, Item_result ret, char *dl, tmp->returns = ret; tmp->type = type; tmp->usage_count=1; - if (my_hash_insert(&udf_hash,(byte*) tmp)) + if (my_hash_insert(&udf_hash,(uchar*) tmp)) return 0; using_udf_functions=1; return tmp; @@ -427,7 +427,7 @@ int mysql_create_function(THD *thd,udf_func *udf) thd->clear_current_stmt_binlog_row_based(); rw_wrlock(&THR_LOCK_udf); - if ((hash_search(&udf_hash,(byte*) udf->name.str, udf->name.length))) + if ((hash_search(&udf_hash,(uchar*) udf->name.str, udf->name.length))) { my_error(ER_UDF_EXISTS, MYF(0), udf->name); goto err; @@ -533,7 +533,7 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name) thd->clear_current_stmt_binlog_row_based(); rw_wrlock(&THR_LOCK_udf); - if (!(udf=(udf_func*) hash_search(&udf_hash,(byte*) udf_name->str, + if (!(udf=(udf_func*) hash_search(&udf_hash,(uchar*) udf_name->str, (uint) udf_name->length))) { my_error(ER_FUNCTION_NOT_DEFINED, MYF(0), udf_name->str); @@ -557,7 +557,7 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name) table->use_all_columns(); table->field[0]->store(exact_name_str, exact_name_len, &my_charset_bin); if (!table->file->index_read_idx(table->record[0], 0, - (byte*) table->field[0]->ptr, HA_WHOLE_KEY, + (uchar*) table->field[0]->ptr, HA_WHOLE_KEY, HA_READ_KEY_EXACT)) { int error; diff --git a/sql/sql_union.cc b/sql/sql_union.cc index dbae7977d62..c872d3cb241 100644 --- a/sql/sql_union.cc +++ b/sql/sql_union.cc @@ -144,8 +144,8 @@ void st_select_lex_unit::init_prepare_fake_select_lex(THD *thd_arg) { thd_arg->lex->current_select= fake_select_lex; - fake_select_lex->table_list.link_in_list((byte *)&result_table_list, - (byte **) + fake_select_lex->table_list.link_in_list((uchar *)&result_table_list, + (uchar **) &result_table_list.next_local); fake_select_lex->context.table_list= fake_select_lex->context.first_name_resolution_table= @@ -162,7 +162,7 @@ st_select_lex_unit::init_prepare_fake_select_lex(THD *thd_arg) order=order->next) { (*order->item)->walk(&Item::change_context_processor, 0, - (byte*) &fake_select_lex->context); + (uchar*) &fake_select_lex->context); } } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index daa59c72f28..66f69ae0421 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -545,8 +545,8 @@ int mysql_update(THD *thd, else { /* Non-batched update */ - error= table->file->ha_update_row((byte*) table->record[1], - (byte*) table->record[0]); + error= table->file->ha_update_row(table->record[1], + table->record[0]); } if (!error) { @@ -1163,7 +1163,7 @@ int multi_update::prepare(List<Item> ¬_used_values, sizeof(*tl)); if (!tl) DBUG_RETURN(1); - update.link_in_list((byte*) tl, (byte**) &tl->next_local); + update.link_in_list((uchar*) tl, (uchar**) &tl->next_local); tl->shared= table_count++; table->no_keyread=1; table->covering_keys.clear_all(); @@ -1568,7 +1568,7 @@ int multi_update::do_updates(bool from_send_error) DBUG_RETURN(0); for (cur_table= update_tables; cur_table; cur_table= cur_table->next_local) { - byte *ref_pos; + uchar *ref_pos; bool can_compare_record; table = cur_table->table; @@ -1601,7 +1601,7 @@ int multi_update::do_updates(bool from_send_error) bitmap_is_subset(table->write_set, table->read_set)); - ref_pos= (byte*) tmp_table->field[0]->ptr; + ref_pos= tmp_table->field[0]->ptr; for (;;) { if (thd->killed && trans_safe) diff --git a/sql/sql_view.cc b/sql/sql_view.cc index 8645cc60d89..c86083e52fc 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -754,7 +754,7 @@ static int mysql_register_view(THD *thd, TABLE_LIST *view, TODO: read dependence list, too, to process cascade/restrict TODO: special cascade/restrict procedure for alter? */ - if (parser->parse((gptr)view, thd->mem_root, + if (parser->parse((uchar*)view, thd->mem_root, view_parameters + revision_number_position, 1, &file_parser_dummy_hook)) { @@ -846,7 +846,7 @@ loop_out: } if (sql_create_definition_file(&dir, &file, view_file_type, - (gptr)view, view_parameters, num_view_backups)) + (uchar*)view, view_parameters, num_view_backups)) { DBUG_RETURN(thd->net.report_error? -1 : 1); } @@ -945,7 +945,7 @@ bool mysql_make_view(THD *thd, File_parser *parser, TABLE_LIST *table, TODO: when VIEWs will be stored in cache, table mem_root should be used here */ - if (parser->parse((gptr)table, thd->mem_root, view_parameters, + if (parser->parse((uchar*)table, thd->mem_root, view_parameters, required_view_parameters, &file_parser_dummy_hook)) goto err; @@ -1488,7 +1488,7 @@ frm_type_enum mysql_frm_type(THD *thd, char *path, enum legacy_db_type *dbt) if ((file= my_open(path, O_RDONLY | O_SHARE, MYF(0))) < 0) DBUG_RETURN(FRMTYPE_ERROR); - error= my_read(file, (byte*) header, sizeof(header), MYF(MY_WME | MY_NABP)); + error= my_read(file, (uchar*) header, sizeof(header), MYF(MY_WME | MY_NABP)); my_close(file, MYF(MY_WME)); if (error) @@ -1751,7 +1751,7 @@ mysql_rename_view(THD *thd, view_def.view_suid= TRUE; /* get view definition and source */ - if (parser->parse((gptr)&view_def, thd->mem_root, view_parameters, + if (parser->parse((uchar*)&view_def, thd->mem_root, view_parameters, array_elements(view_parameters)-1, &file_parser_dummy_hook)) goto err; @@ -1773,7 +1773,7 @@ mysql_rename_view(THD *thd, file.length= pathstr.length - dir.length; if (sql_create_definition_file(&dir, &file, view_file_type, - (gptr)&view_def, view_parameters, + (uchar*)&view_def, view_parameters, num_view_backups)) { /* restore renamed view in case of error */ diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 3092b35a012..7875b4244a8 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -4332,10 +4332,10 @@ create_table_option: lex->create_info.merge_list= lex->select_lex.table_list; lex->create_info.merge_list.elements--; lex->create_info.merge_list.first= - (byte*) (table_list->next_local); + (uchar*) (table_list->next_local); lex->select_lex.table_list.elements=1; lex->select_lex.table_list.next= - (byte**) &(table_list->next_local); + (uchar**) &(table_list->next_local); table_list->next_local= 0; lex->create_info.used_fields|= HA_CREATE_USED_UNION; } @@ -5570,10 +5570,10 @@ alter_list_item: { THD *thd= YYTHD; LEX *lex= thd->lex; - uint dummy; + size_t dummy; lex->select_lex.db=$3->db.str; if (lex->select_lex.db == NULL && - thd->copy_db_to(&lex->select_lex.db, &dummy)) + thd->copy_db_to(&lex->select_lex.db, &dummy)) { MYSQL_YYABORT; } @@ -7979,7 +7979,7 @@ procedure_clause: } lex->proc_list.elements=0; lex->proc_list.first=0; - lex->proc_list.next= (byte**) &lex->proc_list.first; + lex->proc_list.next= (uchar**) &lex->proc_list.first; if (add_proc_to_list(lex->thd, new Item_field(&lex-> current_select-> context, @@ -9550,8 +9550,9 @@ simple_ident_q: Let us add this item to list of all Item_trigger_field objects in trigger. */ - lex->trg_table_fields.link_in_list((byte *)trg_fld, - (byte**)&trg_fld->next_trg_field); + lex->trg_table_fields.link_in_list((uchar*) trg_fld, + (uchar**) &trg_fld-> + next_trg_field); $$= (Item *)trg_fld; } @@ -10179,7 +10180,8 @@ option_type_value: else qbuff.length= lip->tok_end - sp->m_tmp_query; - if (!(qbuff.str= alloc_root(thd->mem_root, qbuff.length + 5))) + if (!(qbuff.str= (char*) alloc_root(thd->mem_root, + qbuff.length + 5))) MYSQL_YYABORT; strmake(strmake(qbuff.str, "SET ", 4), sp->m_tmp_query, @@ -10265,8 +10267,9 @@ sys_option_value: Let us add this item to list of all Item_trigger_field objects in trigger. */ - lex->trg_table_fields.link_in_list((byte *)trg_fld, - (byte **)&trg_fld->next_trg_field); + lex->trg_table_fields.link_in_list((uchar *)trg_fld, + (uchar **) &trg_fld-> + next_trg_field); lex->sphead->add_instr(sp_fld); } @@ -10839,7 +10842,7 @@ grant_ident: { THD *thd= YYTHD; LEX *lex= thd->lex; - uint dummy; + size_t dummy; if (thd->copy_db_to(&lex->current_select->db, &dummy)) MYSQL_YYABORT; if (lex->grant == GLOBAL_ACLS) diff --git a/sql/stacktrace.c b/sql/stacktrace.c index 078f62c6b2b..40507907120 100644 --- a/sql/stacktrace.c +++ b/sql/stacktrace.c @@ -94,7 +94,7 @@ inline uint32* find_prev_pc(uint32* pc, uchar** fp) #endif /* defined(__alpha__) && defined(__GNUC__) */ -void print_stacktrace(gptr stack_bottom, ulong thread_stack) +void print_stacktrace(uchar* stack_bottom, ulong thread_stack) { uchar** fp; uint frame_count = 0, sigreturn_frame_count; @@ -129,11 +129,11 @@ terribly wrong...\n"); return; } - if (!stack_bottom || (gptr) stack_bottom > (gptr) &fp) + if (!stack_bottom || (uchar*) stack_bottom > (uchar*) &fp) { ulong tmp= min(0x10000,thread_stack); /* Assume that the stack starts at the previous even 65K */ - stack_bottom= (gptr) (((ulong) &fp + tmp) & + stack_bottom= (uchar*) (((ulong) &fp + tmp) & ~(ulong) 0xFFFF); fprintf(stderr, "Cannot determine thread, fp=%p, backtrace may not be correct.\n", fp); } @@ -206,9 +206,11 @@ terribly wrong...\n"); fprintf(stderr, "Stack trace seems successful - bottom reached\n"); end: - fprintf(stderr, "Please read http://dev.mysql.com/doc/mysql/en/using-stack-trace.html and follow instructions on how to resolve the stack trace. Resolved\n\ -stack trace is much more helpful in diagnosing the problem, so please do \n\ -resolve it\n"); + fprintf(stderr, + "Please read http://dev.mysql.com/doc/refman/5.1/en/resolve-stack-dump.html\n" + "and follow instructions on how to resolve the stack trace.\n" + "Resolved stack trace is much more helpful in diagnosing the\n" + "problem, so please do resolve it\n"); } #endif /* TARGET_OS_LINUX */ #endif /* HAVE_STACKTRACE */ diff --git a/sql/stacktrace.h b/sql/stacktrace.h index 56b9877180a..1a0b80c88d3 100644 --- a/sql/stacktrace.h +++ b/sql/stacktrace.h @@ -28,7 +28,7 @@ extern char* heap_start; #define init_stacktrace() do { \ heap_start = (char*) &__bss_start; \ } while(0); -void print_stacktrace(gptr stack_bottom, ulong thread_stack); +void print_stacktrace(uchar* stack_bottom, ulong thread_stack); void safe_print_str(const char* name, const char* val, int max_len); #endif /* (defined (__i386__) || (defined(__alpha__) && defined(__GNUC__))) */ #endif /* TARGET_OS_LINUX */ diff --git a/sql/structs.h b/sql/structs.h index 139c07c90d6..da2339d27f8 100644 --- a/sql/structs.h +++ b/sql/structs.h @@ -28,8 +28,8 @@ typedef struct st_date_time_format { typedef struct st_keyfile_info { /* used with ha_info() */ - byte ref[MAX_REFLENGTH]; /* Pointer to current row */ - byte dupp_ref[MAX_REFLENGTH]; /* Pointer to dupp row */ + uchar ref[MAX_REFLENGTH]; /* Pointer to current row */ + uchar dupp_ref[MAX_REFLENGTH]; /* Pointer to dupp row */ uint ref_length; /* Length of ref (1-8) */ uint block_size; /* index block size */ File filenr; /* (uniq) filenr for table */ @@ -126,10 +126,10 @@ typedef struct st_read_record { /* Parameter to read_record */ uint cache_records; uint ref_length,struct_length,reclength,rec_cache_size,error_offset; uint index; - byte *ref_pos; /* pointer to form->refpos */ - byte *record; - byte *rec_buf; /* to read field values after filesort */ - byte *cache,*cache_pos,*cache_end,*read_positions; + uchar *ref_pos; /* pointer to form->refpos */ + uchar *record; + uchar *rec_buf; /* to read field values after filesort */ + uchar *cache,*cache_pos,*cache_end,*read_positions; IO_CACHE *io_cache; bool print_error, ignore_not_found_rows; } READ_RECORD; diff --git a/sql/table.cc b/sql/table.cc index 8eb01f06302..a70b5bd4bef 100644 --- a/sql/table.cc +++ b/sql/table.cc @@ -29,16 +29,16 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, File file); static void fix_type_pointers(const char ***array, TYPELIB *point_to_type, uint types, char **names); -static uint find_field(Field **fields, byte *record, uint start, uint length); +static uint find_field(Field **fields, uchar *record, uint start, uint length); /* Get column name from column hash */ -static byte *get_field_name(Field **buff, uint *length, - my_bool not_used __attribute__((unused))) +static uchar *get_field_name(Field **buff, size_t *length, + my_bool not_used __attribute__((unused))) { *length= (uint) strlen((*buff)->field_name); - return (byte*) (*buff)->field_name; + return (uchar*) (*buff)->field_name; } @@ -373,7 +373,7 @@ int open_table_def(THD *thd, TABLE_SHARE *share, uint db_flags) } error= 4; - if (my_read(file,(byte*) head, 64, MYF(MY_NABP))) + if (my_read(file, head, 64, MYF(MY_NABP))) goto err; if (head[0] == (uchar) 254 && head[1] == 1) @@ -463,7 +463,8 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, uint extra_rec_buf_length; uint i,j; bool use_hash; - char *keynames, *record, *names, *comment_pos; + char *keynames, *names, *comment_pos; + uchar *record; uchar *disk_buff, *strpos, *null_flags, *null_pos; ulong pos, record_offset, *rec_per_key, rec_buff_length; handler *handler_file= 0; @@ -548,7 +549,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, /* Read keyinformation */ key_info_length= (uint) uint2korr(head+28); VOID(my_seek(file,(ulong) uint2korr(head+6),MY_SEEK_SET,MYF(0))); - if (read_string(file,(gptr*) &disk_buff,key_info_length)) + if (read_string(file,(uchar**) &disk_buff,key_info_length)) goto err; /* purecov: inspected */ if (disk_buff[0] & 0x80) { @@ -647,19 +648,21 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, if ((n_length= uint4korr(head+55))) { /* Read extra data segment */ - char *buff, *next_chunk, *buff_end; + uchar *buff, *next_chunk, *buff_end; DBUG_PRINT("info", ("extra segment size is %u bytes", n_length)); - if (!(next_chunk= buff= my_malloc(n_length, MYF(MY_WME)))) + if (!(next_chunk= buff= (uchar*) my_malloc(n_length, MYF(MY_WME)))) goto err; - if (my_pread(file, (byte*)buff, n_length, record_offset + share->reclength, + if (my_pread(file, buff, n_length, record_offset + share->reclength, MYF(MY_NABP))) { my_free(buff, MYF(0)); goto err; } share->connect_string.length= uint2korr(buff); - if (! (share->connect_string.str= strmake_root(&share->mem_root, - next_chunk + 2, share->connect_string.length))) + if (!(share->connect_string.str= strmake_root(&share->mem_root, + (char*) next_chunk + 2, + share->connect_string. + length))) { my_free(buff, MYF(0)); goto err; @@ -669,7 +672,10 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, if (next_chunk + 2 < buff_end) { uint str_db_type_length= uint2korr(next_chunk); - LEX_STRING name= { next_chunk + 2, str_db_type_length }; + LEX_STRING name; + name.str= (char*) next_chunk + 2; + name.length= str_db_type_length; + plugin_ref tmp_plugin= ha_resolve_by_name(thd, &name); if (tmp_plugin != NULL && !plugin_equals(tmp_plugin, share->db_plugin)) { @@ -698,7 +704,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, { LEX_STRING pname= { C_STRING_WITH_LEN( "partition" ) }; if (str_db_type_length == pname.length && - !strncmp(next_chunk + 2, pname.str, pname.length)) + !strncmp((char *) next_chunk + 2, pname.str, pname.length)) { /* Use partition handler @@ -722,7 +728,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, #ifdef WITH_PARTITION_STORAGE_ENGINE if ((share->partition_info_len= partition_info_len)) { - if (!(share->partition_info= + if (!(share->partition_info= (char*) memdup_root(&share->mem_root, next_chunk + 4, partition_info_len + 1))) { @@ -774,8 +780,8 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, my_free(buff, MYF(0)); goto err; } - parser_name.str= next_chunk; - parser_name.length= strlen(next_chunk); + parser_name.str= (char*) next_chunk; + parser_name.length= strlen((char*) next_chunk); keyinfo->parser= my_plugin_lock_by_name(NULL, &parser_name, MYSQL_FTPARSER_PLUGIN); if (! keyinfo->parser) @@ -794,16 +800,16 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, extra_rec_buf_length= uint2korr(head+59); rec_buff_length= ALIGN_SIZE(share->reclength + 1 + extra_rec_buf_length); share->rec_buff_length= rec_buff_length; - if (!(record= (char *) alloc_root(&share->mem_root, - rec_buff_length))) + if (!(record= (uchar *) alloc_root(&share->mem_root, + rec_buff_length))) goto err; /* purecov: inspected */ - share->default_values= (byte *) record; - if (my_pread(file,(byte*) record, (uint) share->reclength, + share->default_values= record; + if (my_pread(file, record, (size_t) share->reclength, record_offset, MYF(MY_NABP))) goto err; /* purecov: inspected */ VOID(my_seek(file,pos,MY_SEEK_SET,MYF(0))); - if (my_read(file,(byte*) head,288,MYF(MY_NABP))) + if (my_read(file, head,288,MYF(MY_NABP))) goto err; #ifdef HAVE_CRYPTED_FRM if (crypted) @@ -833,14 +839,14 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, (uint) ((share->fields+1)*sizeof(Field*)+ interval_count*sizeof(TYPELIB)+ (share->fields+interval_parts+ - keys+3)*sizeof(my_string)+ + keys+3)*sizeof(char *)+ (n_length+int_length+com_length))))) goto err; /* purecov: inspected */ share->field= field_ptr; read_length=(uint) (share->fields * field_pack_length + pos+ (uint) (n_length+int_length+com_length)); - if (read_string(file,(gptr*) &disk_buff,read_length)) + if (read_string(file,(uchar**) &disk_buff,read_length)) goto err; /* purecov: inspected */ #ifdef HAVE_CRYPTED_FRM if (crypted) @@ -896,7 +902,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, share->db_type()))) goto err; - record= (char*) share->default_values-1; /* Fieldstart = 1 */ + record= share->default_values-1; /* Fieldstart = 1 */ if (share->null_field_first) { null_flags= null_pos= (uchar*) record+1; @@ -1090,7 +1096,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, if (use_hash) (void) my_hash_insert(&share->name_hash, - (byte*) field_ptr); // never fail + (uchar*) field_ptr); // never fail } *field_ptr=0; // End marker @@ -1149,7 +1155,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, key_part->type= field->key_type(); if (field->null_ptr) { - key_part->null_offset=(uint) ((byte*) field->null_ptr - + key_part->null_offset=(uint) ((uchar*) field->null_ptr - share->default_values); key_part->null_bit= field->null_bit; key_part->store_length+=HA_KEY_NULL_LENGTH; @@ -1290,7 +1296,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, } else share->primary_key= MAX_KEY; - x_free((gptr) disk_buff); + x_free((uchar*) disk_buff); disk_buff=0; if (new_field_pack_flag <= 1) { @@ -1362,7 +1368,7 @@ static int open_binary_frm(THD *thd, TABLE_SHARE *share, uchar *head, share->error= error; share->open_errno= my_errno; share->errarg= errarg; - x_free((gptr) disk_buff); + x_free((uchar*) disk_buff); delete crypted; delete handler_file; hash_free(&share->name_hash); @@ -1404,7 +1410,7 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, int error; uint records, i, bitmap_size; bool error_reported= FALSE; - byte *record, *bitmaps; + uchar *record, *bitmaps; Field **field_ptr; DBUG_ENTER("open_table_from_share"); DBUG_PRINT("enter",("name: '%s.%s' form: 0x%lx", share->db.str, @@ -1439,7 +1445,7 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, if (prgflag & (READ_ALL+EXTRA_RECORD)) records++; - if (!(record= (byte*) alloc_root(&outparam->mem_root, + if (!(record= (uchar*) alloc_root(&outparam->mem_root, share->rec_buff_length * records))) goto err; /* purecov: inspected */ @@ -1479,7 +1485,7 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, outparam->field= field_ptr; - record= (byte*) outparam->record[0]-1; /* Fieldstart = 1 */ + record= (uchar*) outparam->record[0]-1; /* Fieldstart = 1 */ if (share->null_field_first) outparam->null_flags= (uchar*) record+1; else @@ -1601,7 +1607,7 @@ int open_table_from_share(THD *thd, TABLE_SHARE *share, const char *alias, /* Allocate bitmaps */ bitmap_size= share->column_bitmap_size; - if (!(bitmaps= (byte*) alloc_root(&outparam->mem_root, bitmap_size*3))) + if (!(bitmaps= (uchar*) alloc_root(&outparam->mem_root, bitmap_size*3))) goto err; bitmap_init(&outparam->def_read_set, (my_bitmap_map*) bitmaps, share->fields, FALSE); @@ -1768,7 +1774,7 @@ ulong get_form_pos(File file, uchar *head, TYPELIB *save_names) DBUG_ENTER("get_form_pos"); names=uint2korr(head+8); - a_length=(names+2)*sizeof(my_string); /* Room for two extra */ + a_length=(names+2)*sizeof(char *); /* Room for two extra */ if (!save_names) a_length=0; @@ -1779,12 +1785,12 @@ ulong get_form_pos(File file, uchar *head, TYPELIB *save_names) { length=uint2korr(head+4); VOID(my_seek(file,64L,MY_SEEK_SET,MYF(0))); - if (!(buf= (uchar*) my_malloc((uint) length+a_length+names*4, + if (!(buf= (uchar*) my_malloc((size_t) length+a_length+names*4, MYF(MY_WME))) || - my_read(file,(byte*) buf+a_length,(uint) (length+names*4), + my_read(file, buf+a_length, (size_t) (length+names*4), MYF(MY_NABP))) { /* purecov: inspected */ - x_free((gptr) buf); /* purecov: inspected */ + x_free((uchar*) buf); /* purecov: inspected */ DBUG_RETURN(0L); /* purecov: inspected */ } pos= buf+a_length+length; @@ -1793,7 +1799,7 @@ ulong get_form_pos(File file, uchar *head, TYPELIB *save_names) if (! save_names) { if (names) - my_free((gptr) buf,MYF(0)); + my_free((uchar*) buf,MYF(0)); } else if (!names) bzero((char*) save_names,sizeof(save_names)); @@ -1807,19 +1813,24 @@ ulong get_form_pos(File file, uchar *head, TYPELIB *save_names) } - /* Read string from a file with malloc */ +/* + Read string from a file with malloc -int read_string(File file, gptr *to, uint length) + NOTES: + We add an \0 at end of the read string to make reading of C strings easier +*/ + +int read_string(File file, uchar**to, size_t length) { DBUG_ENTER("read_string"); - x_free((gptr) *to); - if (!(*to= (gptr) my_malloc(length+1,MYF(MY_WME))) || - my_read(file,(byte*) *to,length,MYF(MY_NABP))) + x_free(*to); + if (!(*to= (uchar*) my_malloc(length+1,MYF(MY_WME))) || + my_read(file, *to, length,MYF(MY_NABP))) { - x_free((gptr) *to); /* purecov: inspected */ - *to= 0; /* purecov: inspected */ - DBUG_RETURN(1); /* purecov: inspected */ + x_free(*to); /* purecov: inspected */ + *to= 0; /* purecov: inspected */ + DBUG_RETURN(1); /* purecov: inspected */ } *((char*) *to+length)= '\0'; DBUG_RETURN (0); @@ -1833,7 +1844,7 @@ ulong make_new_entry(File file, uchar *fileinfo, TYPELIB *formnames, { uint i,bufflength,maxlength,n_length,length,names; ulong endpos,newpos; - char buff[IO_SIZE]; + uchar buff[IO_SIZE]; uchar *pos; DBUG_ENTER("make_new_entry"); @@ -1853,17 +1864,17 @@ ulong make_new_entry(File file, uchar *fileinfo, TYPELIB *formnames, while (endpos > maxlength) { VOID(my_seek(file,(ulong) (endpos-bufflength),MY_SEEK_SET,MYF(0))); - if (my_read(file,(byte*) buff,bufflength,MYF(MY_NABP+MY_WME))) + if (my_read(file, buff, bufflength, MYF(MY_NABP+MY_WME))) DBUG_RETURN(0L); VOID(my_seek(file,(ulong) (endpos-bufflength+IO_SIZE),MY_SEEK_SET, MYF(0))); - if ((my_write(file,(byte*) buff,bufflength,MYF(MY_NABP+MY_WME)))) + if ((my_write(file, buff,bufflength,MYF(MY_NABP+MY_WME)))) DBUG_RETURN(0); endpos-=bufflength; bufflength=IO_SIZE; } bzero(buff,IO_SIZE); /* Null new block */ VOID(my_seek(file,(ulong) maxlength,MY_SEEK_SET,MYF(0))); - if (my_write(file,(byte*) buff,bufflength,MYF(MY_NABP+MY_WME))) + if (my_write(file,buff,bufflength,MYF(MY_NABP+MY_WME))) DBUG_RETURN(0L); maxlength+=IO_SIZE; /* Fix old ref */ int2store(fileinfo+6,maxlength); @@ -1878,15 +1889,15 @@ ulong make_new_entry(File file, uchar *fileinfo, TYPELIB *formnames, if (n_length == 1 ) { /* First name */ length++; - VOID(strxmov(buff,"/",newname,"/",NullS)); + VOID(strxmov((char*) buff,"/",newname,"/",NullS)); } else - VOID(strxmov(buff,newname,"/",NullS)); /* purecov: inspected */ + VOID(strxmov((char*) buff,newname,"/",NullS)); /* purecov: inspected */ VOID(my_seek(file,63L+(ulong) n_length,MY_SEEK_SET,MYF(0))); - if (my_write(file,(byte*) buff,(uint) length+1,MYF(MY_NABP+MY_WME)) || - (names && my_write(file,(byte*) (*formnames->type_names+n_length-1), + if (my_write(file, buff, (size_t) length+1,MYF(MY_NABP+MY_WME)) || + (names && my_write(file,(uchar*) (*formnames->type_names+n_length-1), names*4, MYF(MY_NABP+MY_WME))) || - my_write(file,(byte*) fileinfo+10,(uint) 4,MYF(MY_NABP+MY_WME))) + my_write(file, fileinfo+10, 4,MYF(MY_NABP+MY_WME))) DBUG_RETURN(0L); /* purecov: inspected */ int2store(fileinfo+8,names+1); @@ -2046,7 +2057,7 @@ TYPELIB *typelib(MEM_ROOT *mem_root, List<String> &strings) # field number +1 */ -static uint find_field(Field **fields, byte *record, uint start, uint length) +static uint find_field(Field **fields, uchar *record, uint start, uint length) { Field **field; uint i, pos; @@ -2159,7 +2170,7 @@ File create_frm(THD *thd, const char *name, const char *db, { register File file; ulong length; - char fill[IO_SIZE]; + uchar fill[IO_SIZE]; int create_flags= O_RDWR | O_TRUNC; if (create_info->options & HA_LEX_CREATE_TMP_TABLE) @@ -2222,7 +2233,7 @@ File create_frm(THD *thd, const char *name, const char *db, bzero(fill,IO_SIZE); for (; length > IO_SIZE ; length-= IO_SIZE) { - if (my_write(file,(byte*) fill,IO_SIZE,MYF(MY_WME | MY_NABP))) + if (my_write(file,fill, IO_SIZE, MYF(MY_WME | MY_NABP))) { VOID(my_close(file,MYF(0))); VOID(my_delete(name,MYF(0))); @@ -2333,7 +2344,7 @@ char *get_field(MEM_ROOT *mem, Field *field) given a buffer with a key value, and a map of keyparts that are present in this value, returns the length of the value */ -uint calculate_key_len(TABLE *table, uint key, const byte *buf, +uint calculate_key_len(TABLE *table, uint key, const uchar *buf, key_part_map keypart_map) { /* works only with key prefixes */ @@ -2778,7 +2789,7 @@ bool st_table_list::setup_underlying(THD *thd) List_iterator_fast<Item> it(select->item_list); uint field_count= 0; - if (check_stack_overrun(thd, STACK_MIN_SIZE, (char *)&field_count)) + if (check_stack_overrun(thd, STACK_MIN_SIZE, (uchar*) &field_count)) { DBUG_RETURN(TRUE); } @@ -3153,7 +3164,7 @@ bool st_table_list::set_insert_values(MEM_ROOT *mem_root) if (table) { if (!table->insert_values && - !(table->insert_values= (byte *)alloc_root(mem_root, + !(table->insert_values= (uchar *)alloc_root(mem_root, table->s->rec_buff_length))) return TRUE; } @@ -4406,6 +4417,24 @@ bool st_table_list::process_index_hints(TABLE *table) return 0; } + +size_t max_row_length(TABLE *table, const uchar *data) +{ + TABLE_SHARE *table_s= table->s; + size_t length= table_s->reclength + 2 * table_s->fields; + uint *const beg= table_s->blob_field; + uint *const end= beg + table_s->blob_fields; + + for (uint *ptr= beg ; ptr != end ; ++ptr) + { + Field_blob* const blob= (Field_blob*) table->field[*ptr]; + length+= blob->get_length((const uchar*) + (data + blob->offset(table->record[0]))) + + HA_KEY_BLOB_LENGTH; + } + return length; +} + /***************************************************************************** ** Instansiate templates *****************************************************************************/ diff --git a/sql/table.h b/sql/table.h index 99fbf57bb52..c4c7da7d0c2 100644 --- a/sql/table.h +++ b/sql/table.h @@ -73,16 +73,16 @@ enum release_type { RELEASE_NORMAL, RELEASE_WAIT_FOR_DROP }; typedef struct st_filesort_info { - IO_CACHE *io_cache; /* If sorted through filebyte */ - uchar **sort_keys; /* Buffer for sorting keys */ - byte *buffpek; /* Buffer for buffpek structures */ - uint buffpek_len; /* Max number of buffpeks in the buffer */ - byte *addon_buf; /* Pointer to a buffer if sorted with fields */ - uint addon_length; /* Length of the buffer */ + IO_CACHE *io_cache; /* If sorted through filesort */ + uchar **sort_keys; /* Buffer for sorting keys */ + uchar *buffpek; /* Buffer for buffpek structures */ + uint buffpek_len; /* Max number of buffpeks in the buffer */ + uchar *addon_buf; /* Pointer to a buffer if sorted with fields */ + size_t addon_length; /* Length of the buffer */ struct st_sort_addon_field *addon_field; /* Pointer to the fields info */ - void (*unpack)(struct st_sort_addon_field *, byte *); /* To unpack back */ - byte *record_pointers; /* If sorted in memory */ - ha_rows found_records; /* How many records in sort */ + void (*unpack)(struct st_sort_addon_field *, uchar *); /* To unpack back */ + uchar *record_pointers; /* If sorted in memory */ + ha_rows found_records; /* How many records in sort */ } FILESORT_INFO; @@ -137,7 +137,7 @@ typedef struct st_table_share KEY *key_info; /* data of keys in database */ uint *blob_field; /* Index to blobs in Field arrray*/ - byte *default_values; /* row with default values */ + uchar *default_values; /* row with default values */ LEX_STRING comment; /* Comment about table */ CHARSET_INFO *table_charset; /* Default charset of string fields */ @@ -328,10 +328,10 @@ struct st_table { THD *in_use; /* Which thread uses this */ Field **field; /* Pointer to fields */ - byte *record[2]; /* Pointer to records */ - byte *write_row_record; /* Used as optimisation in + uchar *record[2]; /* Pointer to records */ + uchar *write_row_record; /* Used as optimisation in THD::write_row */ - byte *insert_values; /* used by INSERT ... UPDATE */ + uchar *insert_values; /* used by INSERT ... UPDATE */ /* Map of keys that can be used to retrieve all data from this table needed by the query without reading the row. @@ -429,12 +429,14 @@ struct st_table { /* If true, the current table row is considered to have all columns set to NULL, including columns declared as "not null" (see maybe_null). + */ + my_bool null_row; - TODO: Each of these flags take up 8 bits. They can just as easily + /* + TODO: Each of the following flags take up 8 bits. They can just as easily be put into one single unsigned long and instead of taking up 18 bytes, it would take up 4. */ - my_bool null_row; my_bool force_index; my_bool distinct,const_table,no_rows; my_bool key_read, no_keyread; @@ -887,8 +889,8 @@ typedef struct st_table_list thr_lock_type lock_type; uint outer_join; /* Which join type */ uint shared; /* Used in multi-upd */ - uint db_length; - uint32 table_name_length; + size_t db_length; + size_t table_name_length; bool updatable; /* VIEW/TABLE can be updated now */ bool straight; /* optimize with prev table */ bool updating; /* for replicate-do/ignore table */ @@ -1192,3 +1194,6 @@ static inline void dbug_tmp_restore_column_map(MY_BITMAP *bitmap, tmp_restore_column_map(bitmap, old); #endif } + +size_t max_row_length(TABLE *table, const uchar *data); + diff --git a/sql/thr_malloc.cc b/sql/thr_malloc.cc index 392db9224c3..ddf35002880 100644 --- a/sql/thr_malloc.cc +++ b/sql/thr_malloc.cc @@ -35,26 +35,25 @@ void init_sql_alloc(MEM_ROOT *mem_root, uint block_size, uint pre_alloc) } -gptr sql_alloc(uint Size) +void *sql_alloc(size_t Size) { MEM_ROOT *root= *my_pthread_getspecific_ptr(MEM_ROOT**,THR_MALLOC); - char *ptr= (char*) alloc_root(root,Size); - return ptr; + return alloc_root(root,Size); } -gptr sql_calloc(uint size) +void *sql_calloc(size_t size) { - gptr ptr; + void *ptr; if ((ptr=sql_alloc(size))) - bzero((char*) ptr,size); + bzero(ptr,size); return ptr; } char *sql_strdup(const char *str) { - uint len=(uint) strlen(str)+1; + size_t len= strlen(str)+1; char *pos; if ((pos= (char*) sql_alloc(len))) memcpy(pos,str,len); @@ -62,7 +61,7 @@ char *sql_strdup(const char *str) } -char *sql_strmake(const char *str,uint len) +char *sql_strmake(const char *str, size_t len) { char *pos; if ((pos= (char*) sql_alloc(len+1))) @@ -74,10 +73,10 @@ char *sql_strmake(const char *str,uint len) } -gptr sql_memdup(const void *ptr,uint len) +void* sql_memdup(const void *ptr, size_t len) { - char *pos; - if ((pos= (char*) sql_alloc(len))) + void *pos; + if ((pos= sql_alloc(len))) memcpy(pos,ptr,len); return pos; } @@ -87,17 +86,17 @@ void sql_element_free(void *ptr __attribute__((unused))) -char *sql_strmake_with_convert(const char *str, uint32 arg_length, +char *sql_strmake_with_convert(const char *str, size_t arg_length, CHARSET_INFO *from_cs, - uint32 max_res_length, - CHARSET_INFO *to_cs, uint32 *result_length) + size_t max_res_length, + CHARSET_INFO *to_cs, size_t *result_length) { char *pos; - uint32 new_length= to_cs->mbmaxlen*arg_length; + size_t new_length= to_cs->mbmaxlen*arg_length; max_res_length--; // Reserve place for end null set_if_smaller(new_length, max_res_length); - if (!(pos= sql_alloc(new_length+1))) + if (!(pos= (char*) sql_alloc(new_length+1))) return pos; // Error if ((from_cs == &my_charset_bin) || (to_cs == &my_charset_bin)) diff --git a/sql/tzfile.h b/sql/tzfile.h index 1a57c0c5f69..1ff82d62329 100644 --- a/sql/tzfile.h +++ b/sql/tzfile.h @@ -34,14 +34,14 @@ #define TZ_MAGIC "TZif" struct tzhead { - char tzh_magic[4]; /* TZ_MAGIC */ - char tzh_reserved[16]; /* reserved for future use */ - char tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */ - char tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ - char tzh_leapcnt[4]; /* coded number of leap seconds */ - char tzh_timecnt[4]; /* coded number of transition times */ - char tzh_typecnt[4]; /* coded number of local time types */ - char tzh_charcnt[4]; /* coded number of abbr. chars */ + uchar tzh_magic[4]; /* TZ_MAGIC */ + uchar tzh_reserved[16]; /* reserved for future use */ + uchar tzh_ttisgmtcnt[4]; /* coded number of trans. time flags */ + uchar tzh_ttisstdcnt[4]; /* coded number of trans. time flags */ + uchar tzh_leapcnt[4]; /* coded number of leap seconds */ + uchar tzh_timecnt[4]; /* coded number of transition times */ + uchar tzh_typecnt[4]; /* coded number of local time types */ + uchar tzh_charcnt[4]; /* coded number of abbr. chars */ }; /* diff --git a/sql/tztime.cc b/sql/tztime.cc index 08b93cfd203..0c717dd2ece 100644 --- a/sql/tztime.cc +++ b/sql/tztime.cc @@ -153,7 +153,7 @@ static my_bool prepare_tz_info(TIME_ZONE_INFO *sp, MEM_ROOT *storage); static my_bool tz_load(const char *name, TIME_ZONE_INFO *sp, MEM_ROOT *storage) { - char *p; + uchar *p; int read_from_file; uint i; FILE *file; @@ -164,8 +164,8 @@ tz_load(const char *name, TIME_ZONE_INFO *sp, MEM_ROOT *storage) union { struct tzhead tzhead; - char buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES + - TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES + + uchar buf[sizeof(struct tzhead) + sizeof(my_time_t) * TZ_MAX_TIMES + + TZ_MAX_TIMES + sizeof(TRAN_TYPE_INFO) * TZ_MAX_TYPES + #ifdef ABBR_ARE_USED max(TZ_MAX_CHARS + 1, (2 * (MY_TZNAME_MAX + 1))) + #endif @@ -189,7 +189,7 @@ tz_load(const char *name, TIME_ZONE_INFO *sp, MEM_ROOT *storage) sp->timecnt= int4net(u.tzhead.tzh_timecnt); sp->typecnt= int4net(u.tzhead.tzh_typecnt); sp->charcnt= int4net(u.tzhead.tzh_charcnt); - p= u.tzhead.tzh_charcnt + sizeof u.tzhead.tzh_charcnt; + p= u.tzhead.tzh_charcnt + sizeof(u.tzhead.tzh_charcnt); if (sp->leapcnt > TZ_MAX_LEAPS || sp->typecnt == 0 || sp->typecnt > TZ_MAX_TYPES || sp->timecnt > TZ_MAX_TIMES || @@ -1489,18 +1489,21 @@ public: they should obey C calling conventions. */ -extern "C" byte* my_tz_names_get_key(Tz_names_entry *entry, uint *length, - my_bool not_used __attribute__((unused))) +extern "C" uchar * +my_tz_names_get_key(Tz_names_entry *entry, size_t *length, + my_bool not_used __attribute__((unused))) { *length= entry->name.length(); - return (byte*) entry->name.ptr(); + return (uchar*) entry->name.ptr(); } -extern "C" byte* my_offset_tzs_get_key(Time_zone_offset *entry, uint *length, - my_bool not_used __attribute__((unused))) +extern "C" uchar * +my_offset_tzs_get_key(Time_zone_offset *entry, + size_t *length, + my_bool not_used __attribute__((unused))) { *length= sizeof(long); - return (byte*) &entry->offset; + return (uchar*) &entry->offset; } @@ -1586,7 +1589,7 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap) /* Init all memory structures that require explicit destruction */ if (hash_init(&tz_names, &my_charset_latin1, 20, - 0, 0, (hash_get_key)my_tz_names_get_key, 0, 0)) + 0, 0, (hash_get_key) my_tz_names_get_key, 0, 0)) { sql_print_error("Fatal error: OOM while initializing time zones"); goto end; @@ -1610,7 +1613,7 @@ my_tz_init(THD *org_thd, const char *default_tzname, my_bool bootstrap) } tmp_tzname->name.set(STRING_WITH_LEN("SYSTEM"), &my_charset_latin1); tmp_tzname->tz= my_tz_SYSTEM; - if (my_hash_insert(&tz_names, (const byte *)tmp_tzname)) + if (my_hash_insert(&tz_names, (const uchar *)tmp_tzname)) { sql_print_error("Fatal error: OOM while initializing time zones"); goto end_with_cleanup; @@ -1832,8 +1835,8 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) DBUG_ENTER("tz_load_from_open_tables"); /* Prepare tz_info for loading also let us make copy of time zone name */ - if (!(alloc_buff= alloc_root(&tz_storage, sizeof(TIME_ZONE_INFO) + - tz_name->length() + 1))) + if (!(alloc_buff= (char*) alloc_root(&tz_storage, sizeof(TIME_ZONE_INFO) + + tz_name->length() + 1))) { sql_print_error("Out of memory while loading time zone description"); return 0; @@ -1862,7 +1865,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) */ (void)table->file->ha_index_init(0, 1); - if (table->file->index_read(table->record[0], (byte*)table->field[0]->ptr, + if (table->file->index_read(table->record[0], table->field[0]->ptr, HA_WHOLE_KEY, HA_READ_KEY_EXACT)) { #ifdef EXTRA_DEBUG @@ -1889,7 +1892,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) table->field[0]->store((longlong) tzid, TRUE); (void)table->file->ha_index_init(0, 1); - if (table->file->index_read(table->record[0], (byte*)table->field[0]->ptr, + if (table->file->index_read(table->record[0], table->field[0]->ptr, HA_WHOLE_KEY, HA_READ_KEY_EXACT)) { sql_print_error("Can't find description of time zone '%u'", tzid); @@ -1916,7 +1919,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) table->field[0]->store((longlong) tzid, TRUE); (void)table->file->ha_index_init(0, 1); - res= table->file->index_read(table->record[0], (byte*)table->field[0]->ptr, + res= table->file->index_read(table->record[0], table->field[0]->ptr, (key_part_map)1, HA_READ_KEY_EXACT); while (!res) { @@ -1965,7 +1968,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) tz_info->typecnt= ttid + 1; res= table->file->index_next_same(table->record[0], - (byte*)table->field[0]->ptr, 4); + table->field[0]->ptr, 4); } if (res != HA_ERR_END_OF_FILE) @@ -1987,7 +1990,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) table->field[0]->store((longlong) tzid, TRUE); (void)table->file->ha_index_init(0, 1); - res= table->file->index_read(table->record[0], (byte*)table->field[0]->ptr, + res= table->file->index_read(table->record[0], table->field[0]->ptr, (key_part_map)1, HA_READ_KEY_EXACT); while (!res) { @@ -2018,7 +2021,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) tzid, (ulong) ttime, ttid)); res= table->file->index_next_same(table->record[0], - (byte*)table->field[0]->ptr, 4); + table->field[0]->ptr, 4); } /* @@ -2038,21 +2041,21 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) /* Now we will allocate memory and init TIME_ZONE_INFO structure. */ - if (!(alloc_buff= alloc_root(&tz_storage, - ALIGN_SIZE(sizeof(my_time_t) * - tz_info->timecnt) + - ALIGN_SIZE(tz_info->timecnt) + + if (!(alloc_buff= (char*) alloc_root(&tz_storage, + ALIGN_SIZE(sizeof(my_time_t) * + tz_info->timecnt) + + ALIGN_SIZE(tz_info->timecnt) + #ifdef ABBR_ARE_USED - ALIGN_SIZE(tz_info->charcnt) + + ALIGN_SIZE(tz_info->charcnt) + #endif - sizeof(TRAN_TYPE_INFO) * tz_info->typecnt))) + sizeof(TRAN_TYPE_INFO) * + tz_info->typecnt))) { sql_print_error("Out of memory while loading time zone description"); goto end; } - - tz_info->ats= (my_time_t *)alloc_buff; + tz_info->ats= (my_time_t *) alloc_buff; memcpy(tz_info->ats, ats, tz_info->timecnt * sizeof(my_time_t)); alloc_buff+= ALIGN_SIZE(sizeof(my_time_t) * tz_info->timecnt); tz_info->types= (uchar *)alloc_buff; @@ -2087,7 +2090,7 @@ tz_load_from_open_tables(const String *tz_name, TABLE_LIST *tz_tables) &(tmp_tzname->name))) || (tmp_tzname->name.set(tz_name_buff, tz_name->length(), &my_charset_latin1), - my_hash_insert(&tz_names, (const byte *)tmp_tzname))) + my_hash_insert(&tz_names, (const uchar *)tmp_tzname))) { sql_print_error("Out of memory while loading time zone"); goto end; @@ -2244,13 +2247,13 @@ my_tz_find(THD *thd, const String *name) { if (!(result_tz= (Time_zone_offset *)hash_search(&offset_tzs, - (const byte *)&offset, + (const uchar *)&offset, sizeof(long)))) { DBUG_PRINT("info", ("Creating new Time_zone_offset object")); if (!(result_tz= new (&tz_storage) Time_zone_offset(offset)) || - my_hash_insert(&offset_tzs, (const byte *) result_tz)) + my_hash_insert(&offset_tzs, (const uchar *) result_tz)) { result_tz= 0; sql_print_error("Fatal error: Out of memory " @@ -2262,7 +2265,7 @@ my_tz_find(THD *thd, const String *name) { result_tz= 0; if ((tmp_tzname= (Tz_names_entry *)hash_search(&tz_names, - (const byte *)name->ptr(), + (const uchar *)name->ptr(), name->length()))) result_tz= tmp_tzname->tz; else if (time_zone_tables_exist) diff --git a/sql/uniques.cc b/sql/uniques.cc index 9eb827f62a3..7a05ceaddfc 100644 --- a/sql/uniques.cc +++ b/sql/uniques.cc @@ -34,7 +34,7 @@ #include "sql_sort.h" -int unique_write_to_file(gptr key, element_count count, Unique *unique) +int unique_write_to_file(uchar* key, element_count count, Unique *unique) { /* Use unique->size (size of element stored in the tree) and not @@ -42,11 +42,10 @@ int unique_write_to_file(gptr key, element_count count, Unique *unique) when tree implementation chooses to store pointer to key in TREE_ELEMENT (instead of storing the element itself there) */ - return my_b_write(&unique->file, (byte*) key, - unique->size) ? 1 : 0; + return my_b_write(&unique->file, key, unique->size) ? 1 : 0; } -int unique_write_to_ptrs(gptr key, element_count count, Unique *unique) +int unique_write_to_ptrs(uchar* key, element_count count, Unique *unique) { memcpy(unique->record_pointers, key, unique->size); unique->record_pointers+=unique->size; @@ -330,7 +329,7 @@ bool Unique::flush() if (tree_walk(&tree, (tree_walk_action) unique_write_to_file, (void*) this, left_root_right) || - insert_dynamic(&file_ptrs, (gptr) &file_ptr)) + insert_dynamic(&file_ptrs, (uchar*) &file_ptr)) return 1; delete_tree(&tree); return 0; @@ -374,11 +373,11 @@ struct BUFFPEK_COMPARE_CONTEXT C_MODE_START -static int buffpek_compare(void *arg, byte *key_ptr1, byte *key_ptr2) +static int buffpek_compare(void *arg, uchar *key_ptr1, uchar *key_ptr2) { BUFFPEK_COMPARE_CONTEXT *ctx= (BUFFPEK_COMPARE_CONTEXT *) arg; return ctx->key_compare(ctx->key_compare_arg, - *((byte **) key_ptr1), *((byte **)key_ptr2)); + *((uchar **) key_ptr1), *((uchar **)key_ptr2)); } C_MODE_END @@ -455,7 +454,7 @@ static bool merge_walk(uchar *merge_buffer, ulong merge_buffer_size, if (bytes_read == (uint) (-1)) goto end; DBUG_ASSERT(bytes_read); - queue_insert(&queue, (byte *) top); + queue_insert(&queue, (uchar *) top); } top= (BUFFPEK *) queue_top(&queue); while (queue.elements > 1) @@ -586,7 +585,7 @@ bool Unique::get(TABLE *table) if (my_b_tell(&file) == 0) { /* Whole tree is in memory; Don't use disk if you don't need to */ - if ((record_pointers=table->sort.record_pointers= (byte*) + if ((record_pointers=table->sort.record_pointers= (uchar*) my_malloc(size * tree.elements_in_tree, MYF(0)))) { (void) tree_walk(&tree, (tree_walk_action) unique_write_to_ptrs, @@ -641,7 +640,7 @@ bool Unique::get(TABLE *table) goto err; error=0; err: - x_free((gptr) sort_buffer); + x_free(sort_buffer); if (flush_io_cache(outfile)) error=1; diff --git a/sql/unireg.cc b/sql/unireg.cc index a69a9be6a43..a02d24d8ae5 100644 --- a/sql/unireg.cc +++ b/sql/unireg.cc @@ -104,7 +104,7 @@ bool mysql_create_frm(THD *thd, const char *file_name, screens, create_info->table_options, data_offset, db_file)) { - my_free((gptr) screen_buff,MYF(0)); + my_free(screen_buff, MYF(0)); if (thd->net.last_errno != ER_TOO_MANY_FIELDS) DBUG_RETURN(1); @@ -116,7 +116,7 @@ bool mysql_create_frm(THD *thd, const char *file_name, create_fields,info_length, screens, create_info->table_options, data_offset, db_file)) { - my_free((gptr) screen_buff,MYF(0)); + my_free(screen_buff, MYF(0)); DBUG_RETURN(1); } } @@ -152,7 +152,7 @@ bool mysql_create_frm(THD *thd, const char *file_name, if ((file=create_frm(thd, file_name, db, table, reclength, fileinfo, create_info, keys)) < 0) { - my_free((gptr) screen_buff,MYF(0)); + my_free(screen_buff, MYF(0)); DBUG_RETURN(1); } @@ -200,8 +200,8 @@ bool mysql_create_frm(THD *thd, const char *file_name, #endif int2store(fileinfo+59,db_file->extra_rec_buf_length()); - if (my_pwrite(file,(byte*) fileinfo,64,0L,MYF_RW) || - my_pwrite(file,(byte*) keybuff,key_info_length, + if (my_pwrite(file, fileinfo, 64, 0L, MYF_RW) || + my_pwrite(file, keybuff, key_info_length, (ulong) uint2korr(fileinfo+6),MYF_RW)) goto err; VOID(my_seek(file, @@ -213,14 +213,14 @@ bool mysql_create_frm(THD *thd, const char *file_name, goto err; int2store(buff, create_info->connect_string.length); - if (my_write(file, (const byte*)buff, 2, MYF(MY_NABP)) || - my_write(file, (const byte*)create_info->connect_string.str, + if (my_write(file, (const uchar*)buff, 2, MYF(MY_NABP)) || + my_write(file, (const uchar*)create_info->connect_string.str, create_info->connect_string.length, MYF(MY_NABP))) goto err; int2store(buff, str_db_type.length); - if (my_write(file, (const byte*)buff, 2, MYF(MY_NABP)) || - my_write(file, (const byte*)str_db_type.str, + if (my_write(file, (const uchar*)buff, 2, MYF(MY_NABP)) || + my_write(file, (const uchar*)str_db_type.str, str_db_type.length, MYF(MY_NABP))) goto err; @@ -229,32 +229,32 @@ bool mysql_create_frm(THD *thd, const char *file_name, { char auto_partitioned= part_info->is_auto_partitioned ? 1 : 0; int4store(buff, part_info->part_info_len); - if (my_write(file, (const byte*)buff, 4, MYF_RW) || - my_write(file, (const byte*)part_info->part_info_string, + if (my_write(file, (const uchar*)buff, 4, MYF_RW) || + my_write(file, (const uchar*)part_info->part_info_string, part_info->part_info_len + 1, MYF_RW) || - my_write(file, (const byte*)&auto_partitioned, 1, MYF_RW)) + my_write(file, (const uchar*)&auto_partitioned, 1, MYF_RW)) goto err; } else #endif { - bzero(buff, 6); - if (my_write(file, (byte*) buff, 6, MYF_RW)) + bzero((uchar*) buff, 6); + if (my_write(file, (uchar*) buff, 6, MYF_RW)) goto err; } for (i= 0; i < keys; i++) { if (key_info[i].parser_name) { - if (my_write(file, (const byte*)key_info[i].parser_name->str, + if (my_write(file, (const uchar*)key_info[i].parser_name->str, key_info[i].parser_name->length + 1, MYF(MY_NABP))) goto err; } } VOID(my_seek(file,filepos,MY_SEEK_SET,MYF(0))); - if (my_write(file,(byte*) forminfo,288,MYF_RW) || - my_write(file,(byte*) screen_buff,info_length,MYF_RW) || + if (my_write(file, forminfo, 288, MYF_RW) || + my_write(file, screen_buff, info_length, MYF_RW) || pack_fields(file, create_fields, data_offset)) goto err; @@ -267,7 +267,7 @@ bool mysql_create_frm(THD *thd, const char *file_name, goto err; uint read_length=uint2korr(forminfo)-256; VOID(my_seek(file,filepos+256,MY_SEEK_SET,MYF(0))); - if (read_string(file,(gptr*) &disk_buff,read_length)) + if (read_string(file,(uchar**) &disk_buff,read_length)) goto err; crypted->encode(disk_buff,read_length); delete crypted; @@ -280,8 +280,8 @@ bool mysql_create_frm(THD *thd, const char *file_name, } #endif - my_free((gptr) screen_buff,MYF(0)); - my_free((gptr) keybuff, MYF(0)); + my_free(screen_buff,MYF(0)); + my_free(keybuff, MYF(0)); if (opt_sync_frm && !(create_info->options & HA_LEX_CREATE_TMP_TABLE) && my_sync(file, MYF(MY_WME))) @@ -308,8 +308,8 @@ bool mysql_create_frm(THD *thd, const char *file_name, DBUG_RETURN(0); err: - my_free((gptr) screen_buff,MYF(0)); - my_free((gptr) keybuff, MYF(0)); + my_free(screen_buff, MYF(0)); + my_free(keybuff, MYF(0)); err2: VOID(my_close(file,MYF(MY_WME))); err3: @@ -417,7 +417,7 @@ static uchar *pack_screens(List<create_field> &create_fields, pos[0]= (uchar) start_row-2; /* Header string */ pos[1]= (uchar) (cols >> 2); pos[2]= (uchar) (cols >> 1) +1; - strfill((my_string) pos+3,(uint) (cols >> 1),' '); + strfill((char *) pos+3,(uint) (cols >> 1),' '); pos+=(cols >> 1)+4; } length=(uint) strlen(cfield->field_name); @@ -626,7 +626,8 @@ static bool pack_header(uchar *forminfo, enum legacy_db_type table_type, length= field->save_interval->type_lengths[pos]; hex_length= length * 2; field->interval->type_lengths[pos]= hex_length; - field->interval->type_names[pos]= dst= sql_alloc(hex_length + 1); + field->interval->type_names[pos]= dst= (char*) sql_alloc(hex_length + + 1); octet2hex(dst, src, length); } } @@ -756,13 +757,13 @@ static bool pack_fields(File file, List<create_field> &create_fields, int2store(buff+15, field->comment.length); comment_length+= field->comment.length; set_if_bigger(int_count,field->interval_id); - if (my_write(file,(byte*) buff,FCOMP,MYF_RW)) + if (my_write(file, buff, FCOMP, MYF_RW)) DBUG_RETURN(1); } /* Write fieldnames */ buff[0]=(uchar) NAMES_SEP_CHAR; - if (my_write(file,(byte*) buff,1,MYF_RW)) + if (my_write(file, buff, 1, MYF_RW)) DBUG_RETURN(1); i=0; it.rewind(); @@ -772,7 +773,7 @@ static bool pack_fields(File file, List<create_field> &create_fields, *pos++=NAMES_SEP_CHAR; if (i == create_fields.elements-1) *pos++=0; - if (my_write(file,(byte*) buff,(uint) (pos-(char*) buff),MYF_RW)) + if (my_write(file, buff, (size_t) (pos-(char*) buff),MYF_RW)) DBUG_RETURN(1); i++; } @@ -832,7 +833,7 @@ static bool pack_fields(File file, List<create_field> &create_fields, tmp.append('\0'); // End of intervall } } - if (my_write(file,(byte*) tmp.ptr(),tmp.length(),MYF_RW)) + if (my_write(file,(uchar*) tmp.ptr(),tmp.length(),MYF_RW)) DBUG_RETURN(1); } if (comment_length) @@ -842,7 +843,7 @@ static bool pack_fields(File file, List<create_field> &create_fields, while ((field=it++)) { if (field->comment.length) - if (my_write(file, (byte*) field->comment.str, field->comment.length, + if (my_write(file, (uchar*) field->comment.str, field->comment.length, MYF_RW)) DBUG_RETURN(1); } @@ -875,7 +876,7 @@ static bool make_empty_rec(THD *thd, File file,enum legacy_db_type table_type, bzero((char*) &share, sizeof(share)); table.s= &share; - if (!(buff=(uchar*) my_malloc((uint) reclength,MYF(MY_WME | MY_ZEROFILL)))) + if (!(buff=(uchar*) my_malloc((size_t) reclength,MYF(MY_WME | MY_ZEROFILL)))) { DBUG_RETURN(1); } @@ -900,7 +901,7 @@ static bool make_empty_rec(THD *thd, File file,enum legacy_db_type table_type, regfield don't have to be deleted as it's allocated with sql_alloc() */ Field *regfield= make_field(&share, - (char*) buff+field->offset + data_offset, + buff+field->offset + data_offset, field->length, null_pos + null_count / 8, null_count & 7, @@ -968,10 +969,10 @@ static bool make_empty_rec(THD *thd, File file,enum legacy_db_type table_type, if (null_count & 7) *(null_pos + null_count / 8)|= ~(((uchar) 1 << (null_count & 7)) - 1); - error=(int) my_write(file,(byte*) buff, (uint) reclength,MYF_RW); + error= my_write(file, buff, (size_t) reclength,MYF_RW) != 0; err: - my_free((gptr) buff,MYF(MY_FAE)); + my_free(buff, MYF(MY_FAE)); thd->count_cuted_fields= old_count_cuted_fields; DBUG_RETURN(error); } /* make_empty_rec */ diff --git a/storage/archive/archive_reader.c b/storage/archive/archive_reader.c index 14018217dea..d3c11f1dce2 100644 --- a/storage/archive/archive_reader.c +++ b/storage/archive/archive_reader.c @@ -110,7 +110,7 @@ int main(int argc, char *argv[]) if (opt_check) { - byte size_buffer[ARCHIVE_ROW_HEADER_SIZE]; + uchar size_buffer[ARCHIVE_ROW_HEADER_SIZE]; int error; unsigned int x; unsigned int read; @@ -118,7 +118,7 @@ int main(int argc, char *argv[]) unsigned long long row_count= 0; char buffer; - while ((read= azread(&reader_handle, (byte *)size_buffer, + while ((read= azread(&reader_handle, (uchar *)size_buffer, ARCHIVE_ROW_HEADER_SIZE, &error))) { if (error == Z_STREAM_ERROR || (read && read < ARCHIVE_ROW_HEADER_SIZE)) @@ -171,7 +171,7 @@ int main(int argc, char *argv[]) if (opt_backup) { - byte size_buffer[ARCHIVE_ROW_HEADER_SIZE]; + uchar size_buffer[ARCHIVE_ROW_HEADER_SIZE]; int error; unsigned int read; unsigned int row_len; @@ -213,7 +213,7 @@ int main(int argc, char *argv[]) my_free(ptr, MYF(0)); } - while ((read= azread(&reader_handle, (byte *)size_buffer, + while ((read= azread(&reader_handle, (uchar *)size_buffer, ARCHIVE_ROW_HEADER_SIZE, &error))) { if (error == Z_STREAM_ERROR || (read && read < ARCHIVE_ROW_HEADER_SIZE)) @@ -355,15 +355,15 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"set-auto-increment", 'A', "Force auto_increment to start at this or higher value. If no value is given, then sets the next auto_increment value to the highest used value for the auto key + 1.", - (gptr*) &new_auto_increment, - (gptr*) &new_auto_increment, + (uchar**) &new_auto_increment, + (uchar**) &new_auto_increment, 0, GET_ULL, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"silent", 's', "Only print errors. One can use two -s to make archive_reader very silent.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"tmpdir", 't', "Path for temporary files.", - (gptr*) &opt_tmpdir, + (uchar**) &opt_tmpdir, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Print version and exit.", diff --git a/storage/archive/azio.c b/storage/archive/azio.c index 6b01d9c3c88..ee2fee34953 100644 --- a/storage/archive/azio.c +++ b/storage/archive/azio.c @@ -19,7 +19,7 @@ static int const gz_magic[2] = {0x1f, 0x8b}; /* gzip magic header */ static int const az_magic[3] = {0xfe, 0x03, 0x01}; /* az magic header */ -/* gzip flag byte */ +/* gzip flag uchar */ #define ASCII_FLAG 0x01 /* bit 0 set: file probably ascii text */ #define HEAD_CRC 0x02 /* bit 1 set: header CRC present */ #define EXTRA_FIELD 0x04 /* bit 2 set: extra field present */ @@ -139,8 +139,8 @@ int az_open (azio_stream *s, const char *path, int Flags, File fd) } else if (s->mode == 'w') { - unsigned char buffer[AZHEADER_SIZE + AZMETA_BUFFER_SIZE]; - my_pread(s->file, (byte*) buffer, AZHEADER_SIZE + AZMETA_BUFFER_SIZE, 0, + uchar buffer[AZHEADER_SIZE + AZMETA_BUFFER_SIZE]; + my_pread(s->file, buffer, AZHEADER_SIZE + AZMETA_BUFFER_SIZE, 0, MYF(0)); read_header(s, buffer); /* skip the .az header */ my_seek(s->file, 0, MY_SEEK_END, MYF(0)); @@ -224,7 +224,7 @@ int get_byte(s) if (s->stream.avail_in == 0) { errno = 0; - s->stream.avail_in = my_read(s->file, (byte *)s->inbuf, AZ_BUFSIZE_READ, MYF(0)); + s->stream.avail_in = my_read(s->file, (uchar *)s->inbuf, AZ_BUFSIZE_READ, MYF(0)); if (s->stream.avail_in == 0) { s->z_eof = 1; @@ -248,8 +248,8 @@ int get_byte(s) */ void check_header(azio_stream *s) { - int method; /* method byte */ - int flags; /* flags byte */ + int method; /* method uchar */ + int flags; /* flags uchar */ uInt len; int c; @@ -260,7 +260,7 @@ void check_header(azio_stream *s) if (len < 2) { if (len) s->inbuf[0] = s->stream.next_in[0]; errno = 0; - len = (uInt)my_read(s->file, (byte *)s->inbuf + len, AZ_BUFSIZE_READ >> len, MYF(0)); + len = (uInt)my_read(s->file, (uchar *)s->inbuf + len, AZ_BUFSIZE_READ >> len, MYF(0)); if (len == 0) s->z_err = Z_ERRNO; s->stream.avail_in += len; s->stream.next_in = s->inbuf; @@ -442,7 +442,7 @@ unsigned int ZEXPORT azread ( azio_stream *s, voidp buf, unsigned int len, int * if (s->stream.avail_out > 0) { s->stream.avail_out -= - (uInt)my_read(s->file, (byte *)next_out, s->stream.avail_out, MYF(0)); + (uInt)my_read(s->file, (uchar *)next_out, s->stream.avail_out, MYF(0)); } len -= s->stream.avail_out; s->in += len; @@ -455,7 +455,7 @@ unsigned int ZEXPORT azread ( azio_stream *s, voidp buf, unsigned int len, int * if (s->stream.avail_in == 0 && !s->z_eof) { errno = 0; - s->stream.avail_in = (uInt)my_read(s->file, (byte *)s->inbuf, AZ_BUFSIZE_READ, MYF(0)); + s->stream.avail_in = (uInt)my_read(s->file, (uchar *)s->inbuf, AZ_BUFSIZE_READ, MYF(0)); if (s->stream.avail_in == 0) { s->z_eof = 1; @@ -522,7 +522,7 @@ unsigned int azwrite (azio_stream *s, voidpc buf, unsigned int len) { s->stream.next_out = s->outbuf; - if (my_write(s->file, (byte *)s->outbuf, AZ_BUFSIZE_WRITE, + if (my_write(s->file, (uchar *)s->outbuf, AZ_BUFSIZE_WRITE, MYF(0)) != AZ_BUFSIZE_WRITE) { s->z_err = Z_ERRNO; @@ -557,6 +557,7 @@ int do_flush (azio_stream *s, int flush) { uInt len; int done = 0; + my_off_t afterwrite_pos; if (s == NULL || s->mode != 'w') return Z_STREAM_ERROR; @@ -569,7 +570,7 @@ int do_flush (azio_stream *s, int flush) if (len != 0) { s->check_point= my_tell(s->file, MYF(0)); - if ((uInt)my_write(s->file, (byte *)s->outbuf, len, MYF(0)) != len) + if ((uInt)my_write(s->file, (uchar *)s->outbuf, len, MYF(0)) != len) { s->z_err = Z_ERRNO; return Z_ERRNO; @@ -597,7 +598,10 @@ int do_flush (azio_stream *s, int flush) s->dirty= AZ_STATE_CLEAN; /* Mark it clean, we should be good now */ else s->dirty= AZ_STATE_SAVED; /* Mark it clean, we should be good now */ + + afterwrite_pos= my_tell(s->file, MYF(0)); write_header(s); + my_seek(s->file, afterwrite_pos, SEEK_SET, MYF(0)); return s->z_err == Z_STREAM_END ? Z_OK : s->z_err; } @@ -611,7 +615,7 @@ int ZEXPORT azflush (s, flush) if (s->mode == 'r') { unsigned char buffer[AZHEADER_SIZE + AZMETA_BUFFER_SIZE]; - my_pread(s->file, (byte*) buffer, AZHEADER_SIZE + AZMETA_BUFFER_SIZE, 0, + my_pread(s->file, (uchar*) buffer, AZHEADER_SIZE + AZMETA_BUFFER_SIZE, 0, MYF(0)); read_header(s, buffer); /* skip the .az header */ @@ -748,7 +752,7 @@ my_off_t ZEXPORT aztell (file) void putLong (File file, uLong x) { int n; - byte buffer[1]; + uchar buffer[1]; for (n = 0; n < 4; n++) { diff --git a/storage/archive/ha_archive.cc b/storage/archive/ha_archive.cc index 6853e879f55..d1482de18ec 100644 --- a/storage/archive/ha_archive.cc +++ b/storage/archive/ha_archive.cc @@ -113,9 +113,9 @@ static handler *archive_create_handler(handlerton *hton, TABLE_SHARE *table, MEM_ROOT *mem_root); int archive_discover(handlerton *hton, THD* thd, const char *db, - const char *name, - const void** frmblob, - uint* frmlen); + const char *name, + uchar **frmblob, + size_t *frmlen); /* Number of rows that will force a bulk insert. @@ -137,11 +137,11 @@ static handler *archive_create_handler(handlerton *hton, /* Used for hash table that tracks open tables. */ -static byte* archive_get_key(ARCHIVE_SHARE *share,uint *length, +static uchar* archive_get_key(ARCHIVE_SHARE *share, size_t *length, my_bool not_used __attribute__((unused))) { *length=share->table_name_length; - return (byte*) share->table_name; + return (uchar*) share->table_name; } @@ -216,9 +216,9 @@ ha_archive::ha_archive(handlerton *hton, TABLE_SHARE *table_arg) } int archive_discover(handlerton *hton, THD* thd, const char *db, - const char *name, - const void** frmblob, - uint* frmlen) + const char *name, + uchar **frmblob, + size_t *frmlen) { DBUG_ENTER("archive_discover"); DBUG_PRINT("archive_discover", ("db: %s, name: %s", db, name)); @@ -247,7 +247,7 @@ int archive_discover(handlerton *hton, THD* thd, const char *db, azclose(&frm_stream); *frmlen= frm_stream.frm_length; - *frmblob= frm_ptr; + *frmblob= (uchar*) frm_ptr; DBUG_RETURN(0); err: @@ -316,7 +316,7 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc) length=(uint) strlen(table_name); if (!(share=(ARCHIVE_SHARE*) hash_search(&archive_open_tables, - (byte*) table_name, + (uchar*) table_name, length))) { char *tmp_name; @@ -362,7 +362,7 @@ ARCHIVE_SHARE *ha_archive::get_share(const char *table_name, int *rc) share->crashed= archive_tmp.dirty; azclose(&archive_tmp); - VOID(my_hash_insert(&archive_open_tables, (byte*) share)); + VOID(my_hash_insert(&archive_open_tables, (uchar*) share)); thr_lock_init(&share->lock); } share->use_count++; @@ -393,7 +393,7 @@ int ha_archive::free_share() pthread_mutex_lock(&archive_mutex); if (!--share->use_count) { - hash_delete(&archive_open_tables, (byte*) share); + hash_delete(&archive_open_tables, (uchar*) share); thr_lock_delete(&share->lock); VOID(pthread_mutex_destroy(&share->mutex)); /* @@ -408,7 +408,7 @@ int ha_archive::free_share() if (azclose(&(share->archive_write))) rc= 1; } - my_free((gptr) share, MYF(0)); + my_free((uchar*) share, MYF(0)); } pthread_mutex_unlock(&archive_mutex); @@ -579,7 +579,7 @@ int ha_archive::create(const char *name, TABLE *table_arg, azio_stream create_stream; /* Archive file we are working with */ File frm_file; /* File handler for readers */ MY_STAT file_stat; // Stat information for the data file - byte *frm_ptr; + uchar *frm_ptr; DBUG_ENTER("ha_archive::create"); @@ -651,12 +651,12 @@ int ha_archive::create(const char *name, TABLE *table_arg, { if (!my_fstat(frm_file, &file_stat, MYF(MY_WME))) { - frm_ptr= (byte *)my_malloc(sizeof(byte) * file_stat.st_size , MYF(0)); + frm_ptr= (uchar *)my_malloc(sizeof(uchar) * file_stat.st_size, MYF(0)); if (frm_ptr) { my_read(frm_file, frm_ptr, file_stat.st_size, MYF(0)); azwrite_frm(&create_stream, (char *)frm_ptr, file_stat.st_size); - my_free((gptr)frm_ptr, MYF(0)); + my_free((uchar*)frm_ptr, MYF(0)); } } my_close(frm_file, MYF(0)); @@ -696,7 +696,7 @@ error: /* This is where the actual row is written out. */ -int ha_archive::real_write_row(byte *buf, azio_stream *writer) +int ha_archive::real_write_row(uchar *buf, azio_stream *writer) { my_off_t written; unsigned int r_pack_length; @@ -726,7 +726,7 @@ int ha_archive::real_write_row(byte *buf, azio_stream *writer) the bytes required for the length in the header. */ -uint32 ha_archive::max_row_length(const byte *buf) +uint32 ha_archive::max_row_length(const uchar *buf) { uint32 length= (uint32)(table->s->reclength + table->s->fields*2); length+= ARCHIVE_ROW_HEADER_SIZE; @@ -743,9 +743,9 @@ uint32 ha_archive::max_row_length(const byte *buf) } -unsigned int ha_archive::pack_row(byte *record) +unsigned int ha_archive::pack_row(uchar *record) { - byte *ptr; + uchar *ptr; DBUG_ENTER("ha_archive::pack_row"); @@ -761,8 +761,7 @@ unsigned int ha_archive::pack_row(byte *record) for (Field **field=table->field ; *field ; field++) { if (!((*field)->is_null())) - ptr=(byte*) (*field)->pack((char*) ptr, - (char*) record + (*field)->offset(record)); + ptr= (*field)->pack(ptr, record + (*field)->offset(record)); } int4store(record_buffer->buffer, (int)(ptr - record_buffer->buffer - @@ -784,12 +783,12 @@ unsigned int ha_archive::pack_row(byte *record) for implementing start_bulk_insert() is that we could skip setting dirty to true each time. */ -int ha_archive::write_row(byte *buf) +int ha_archive::write_row(uchar *buf) { int rc; - byte *read_buf= NULL; + uchar *read_buf= NULL; ulonglong temp_auto; - byte *record= table->record[0]; + uchar *record= table->record[0]; DBUG_ENTER("ha_archive::write_row"); if (share->crashed) @@ -832,7 +831,7 @@ int ha_archive::write_row(byte *buf) First we create a buffer that we can use for reading rows, and can pass to get_row(). */ - if (!(read_buf= (byte*) my_malloc(table->s->reclength, MYF(MY_WME)))) + if (!(read_buf= (uchar*) my_malloc(table->s->reclength, MYF(MY_WME)))) { rc= HA_ERR_OUT_OF_MEM; goto error; @@ -882,7 +881,7 @@ int ha_archive::write_row(byte *buf) error: pthread_mutex_unlock(&share->mutex); if (read_buf) - my_free((gptr) read_buf, MYF(0)); + my_free((uchar*) read_buf, MYF(0)); DBUG_RETURN(rc); } @@ -910,7 +909,7 @@ int ha_archive::index_init(uint keynr, bool sorted) No indexes, so if we get a request for an index search since we tell the optimizer that we have unique indexes, we scan */ -int ha_archive::index_read(byte *buf, const byte *key, +int ha_archive::index_read(uchar *buf, const uchar *key, uint key_len, enum ha_rkey_function find_flag) { int rc; @@ -920,7 +919,7 @@ int ha_archive::index_read(byte *buf, const byte *key, } -int ha_archive::index_read_idx(byte *buf, uint index, const byte *key, +int ha_archive::index_read_idx(uchar *buf, uint index, const uchar *key, uint key_len, enum ha_rkey_function find_flag) { int rc; @@ -955,7 +954,7 @@ error: } -int ha_archive::index_next(byte * buf) +int ha_archive::index_next(uchar * buf) { bool found= 0; @@ -1024,7 +1023,7 @@ int ha_archive::rnd_init(bool scan) This is the method that is used to read a row. It assumes that the row is positioned where you want it. */ -int ha_archive::get_row(azio_stream *file_to_read, byte *buf) +int ha_archive::get_row(azio_stream *file_to_read, uchar *buf) { int rc; DBUG_ENTER("ha_archive::get_row"); @@ -1051,8 +1050,8 @@ bool ha_archive::fix_rec_buff(unsigned int length) if (length > record_buffer->length) { - byte *newptr; - if (!(newptr=(byte*) my_realloc((gptr) record_buffer->buffer, + uchar *newptr; + if (!(newptr=(uchar*) my_realloc((uchar*) record_buffer->buffer, length, MYF(MY_ALLOW_ZERO_PTR)))) DBUG_RETURN(1); @@ -1065,17 +1064,17 @@ bool ha_archive::fix_rec_buff(unsigned int length) DBUG_RETURN(0); } -int ha_archive::unpack_row(azio_stream *file_to_read, byte *record) +int ha_archive::unpack_row(azio_stream *file_to_read, uchar *record) { DBUG_ENTER("ha_archive::unpack_row"); unsigned int read; int error; - byte size_buffer[ARCHIVE_ROW_HEADER_SIZE]; + uchar size_buffer[ARCHIVE_ROW_HEADER_SIZE]; unsigned int row_len; /* First we grab the length stored */ - read= azread(file_to_read, (byte *)size_buffer, ARCHIVE_ROW_HEADER_SIZE, &error); + read= azread(file_to_read, size_buffer, ARCHIVE_ROW_HEADER_SIZE, &error); if (error == Z_STREAM_ERROR || (read && read < ARCHIVE_ROW_HEADER_SIZE)) DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); @@ -1100,21 +1099,21 @@ int ha_archive::unpack_row(azio_stream *file_to_read, byte *record) } /* Copy null bits */ - const char *ptr= (const char*) record_buffer->buffer; + const uchar *ptr= record_buffer->buffer; memcpy(record, ptr, table->s->null_bytes); ptr+= table->s->null_bytes; for (Field **field=table->field ; *field ; field++) + { if (!((*field)->is_null())) { - ptr= (*field)->unpack((char *)record + - (*field)->offset(table->record[0]), ptr); + ptr= (*field)->unpack(record + (*field)->offset(table->record[0]), ptr); } - + } DBUG_RETURN(0); } -int ha_archive::get_row_version3(azio_stream *file_to_read, byte *buf) +int ha_archive::get_row_version3(azio_stream *file_to_read, uchar *buf) { DBUG_ENTER("ha_archive::get_row_version3"); @@ -1124,7 +1123,7 @@ int ha_archive::get_row_version3(azio_stream *file_to_read, byte *buf) } -int ha_archive::get_row_version2(azio_stream *file_to_read, byte *buf) +int ha_archive::get_row_version2(azio_stream *file_to_read, uchar *buf) { unsigned int read; int error; @@ -1190,7 +1189,7 @@ int ha_archive::get_row_version2(azio_stream *file_to_read, byte *buf) if ((size_t) read != size) DBUG_RETURN(HA_ERR_END_OF_FILE); - ((Field_blob*) table->field[*ptr])->set_ptr(size, last); + ((Field_blob*) table->field[*ptr])->set_ptr(size, (uchar*) last); last += size; } else @@ -1208,7 +1207,7 @@ int ha_archive::get_row_version2(azio_stream *file_to_read, byte *buf) or by having had ha_archive::rnd_pos() called before it is called. */ -int ha_archive::rnd_next(byte *buf) +int ha_archive::rnd_next(uchar *buf) { int rc; DBUG_ENTER("ha_archive::rnd_next"); @@ -1238,7 +1237,7 @@ int ha_archive::rnd_next(byte *buf) needed. */ -void ha_archive::position(const byte *record) +void ha_archive::position(const uchar *record) { DBUG_ENTER("ha_archive::position"); my_store_ptr(ref, ref_length, current_position); @@ -1253,7 +1252,7 @@ void ha_archive::position(const byte *record) correctly ordered row. */ -int ha_archive::rnd_pos(byte * buf, byte *pos) +int ha_archive::rnd_pos(uchar * buf, uchar *pos) { DBUG_ENTER("ha_archive::rnd_pos"); ha_statistic_increment(&SSV::ha_read_rnd_next_count); @@ -1346,8 +1345,8 @@ int ha_archive::optimize(THD* thd, HA_CHECK_OPT* check_opt) { Field *field= table->found_next_number_field; ulonglong auto_value= - (ulonglong) field->val_int((char*)(table->record[0] + - field->offset(table->record[0]))); + (ulonglong) field->val_int(table->record[0] + + field->offset(table->record[0])); if (share->archive_write.auto_increment < auto_value) stats.auto_increment_value= share->archive_write.auto_increment= auto_value; @@ -1549,7 +1548,7 @@ bool ha_archive::is_crashed() const int ha_archive::check(THD* thd, HA_CHECK_OPT* check_opt) { int rc= 0; - byte *buf; + uchar *buf; const char *old_proc_info; ha_rows count= share->rows_recorded; DBUG_ENTER("ha_archive::check"); @@ -1562,7 +1561,7 @@ int ha_archive::check(THD* thd, HA_CHECK_OPT* check_opt) First we create a buffer that we can use for reading rows, and can pass to get_row(). */ - if (!(buf= (byte*) my_malloc(table->s->reclength, MYF(MY_WME)))) + if (!(buf= (uchar*) my_malloc(table->s->reclength, MYF(MY_WME)))) rc= HA_ERR_OUT_OF_MEM; /* @@ -1618,7 +1617,7 @@ archive_record_buffer *ha_archive::create_record_buffer(unsigned int length) } r->length= (int)length; - if (!(r->buffer= (byte*) my_malloc(r->length, + if (!(r->buffer= (uchar*) my_malloc(r->length, MYF(MY_WME)))) { my_free((char*) r, MYF(MY_ALLOW_ZERO_PTR)); diff --git a/storage/archive/ha_archive.h b/storage/archive/ha_archive.h index 8fc54f6715f..936bb6e253d 100644 --- a/storage/archive/ha_archive.h +++ b/storage/archive/ha_archive.h @@ -27,7 +27,7 @@ */ typedef struct st_archive_record_buffer { - byte *buffer; + uchar *buffer; uint32 length; } archive_record_buffer; @@ -62,12 +62,12 @@ class ha_archive: public handler azio_stream archive; /* Archive file we are working with */ my_off_t current_position; /* The position of the row we just read */ - byte byte_buffer[IO_SIZE]; /* Initial buffer for our string */ + uchar byte_buffer[IO_SIZE]; /* Initial buffer for our string */ String buffer; /* Buffer used for blob storage */ ha_rows scan_rows; /* Number of rows left in scan */ bool delayed_insert; /* If the insert is delayed */ bool bulk_insert; /* If we are performing a bulk insert */ - const byte *current_key; + const uchar *current_key; uint current_key_len; uint current_k_offset; archive_record_buffer *record_buffer; @@ -101,29 +101,29 @@ public: uint max_supported_key_length() const { return sizeof(ulonglong); } uint max_supported_key_part_length() const { return sizeof(ulonglong); } int index_init(uint keynr, bool sorted); - virtual int index_read(byte * buf, const byte * key, + virtual int index_read(uchar * buf, const uchar * key, uint key_len, enum ha_rkey_function find_flag); - virtual int index_read_idx(byte * buf, uint index, const byte * key, + virtual int index_read_idx(uchar * buf, uint index, const uchar * key, uint key_len, enum ha_rkey_function find_flag); - int index_next(byte * buf); + int index_next(uchar * buf); int open(const char *name, int mode, uint test_if_locked); int close(void); - int write_row(byte * buf); - int real_write_row(byte *buf, azio_stream *writer); + int write_row(uchar * buf); + int real_write_row(uchar *buf, azio_stream *writer); int delete_all_rows(); int rnd_init(bool scan=1); - int rnd_next(byte *buf); - int rnd_pos(byte * buf, byte *pos); - int get_row(azio_stream *file_to_read, byte *buf); - int get_row_version2(azio_stream *file_to_read, byte *buf); - int get_row_version3(azio_stream *file_to_read, byte *buf); + int rnd_next(uchar *buf); + int rnd_pos(uchar * buf, uchar *pos); + int get_row(azio_stream *file_to_read, uchar *buf); + int get_row_version2(azio_stream *file_to_read, uchar *buf); + int get_row_version3(azio_stream *file_to_read, uchar *buf); ARCHIVE_SHARE *get_share(const char *table_name, int *rc); int free_share(); int init_archive_writer(); int init_archive_reader(); bool auto_repair() const { return 1; } // For the moment we just do this int read_data_header(azio_stream *file_to_read); - void position(const byte *record); + void position(const uchar *record); int info(uint); void update_create_info(HA_CREATE_INFO *create_info); int create(const char *name, TABLE *form, HA_CREATE_INFO *create_info); @@ -140,9 +140,9 @@ public: bool is_crashed() const; int check(THD* thd, HA_CHECK_OPT* check_opt); bool check_and_repair(THD *thd); - uint32 max_row_length(const byte *buf); + uint32 max_row_length(const uchar *buf); bool fix_rec_buff(unsigned int length); - int unpack_row(azio_stream *file_to_read, byte *record); - unsigned int pack_row(byte *record); + int unpack_row(azio_stream *file_to_read, uchar *record); + unsigned int pack_row(uchar *record); }; diff --git a/storage/blackhole/ha_blackhole.cc b/storage/blackhole/ha_blackhole.cc index 23fdc014114..03da7808948 100644 --- a/storage/blackhole/ha_blackhole.cc +++ b/storage/blackhole/ha_blackhole.cc @@ -94,7 +94,7 @@ const char *ha_blackhole::index_type(uint key_number) HA_KEY_ALG_RTREE) ? "RTREE" : "BTREE"); } -int ha_blackhole::write_row(byte * buf) +int ha_blackhole::write_row(uchar * buf) { DBUG_ENTER("ha_blackhole::write_row"); DBUG_RETURN(0); @@ -107,14 +107,14 @@ int ha_blackhole::rnd_init(bool scan) } -int ha_blackhole::rnd_next(byte *buf) +int ha_blackhole::rnd_next(uchar *buf) { DBUG_ENTER("ha_blackhole::rnd_next"); DBUG_RETURN(HA_ERR_END_OF_FILE); } -int ha_blackhole::rnd_pos(byte * buf, byte *pos) +int ha_blackhole::rnd_pos(uchar * buf, uchar *pos) { DBUG_ENTER("ha_blackhole::rnd_pos"); DBUG_ASSERT(0); @@ -122,7 +122,7 @@ int ha_blackhole::rnd_pos(byte * buf, byte *pos) } -void ha_blackhole::position(const byte *record) +void ha_blackhole::position(const uchar *record) { DBUG_ENTER("ha_blackhole::position"); DBUG_ASSERT(0); @@ -184,7 +184,7 @@ THR_LOCK_DATA **ha_blackhole::store_lock(THD *thd, } -int ha_blackhole::index_read(byte * buf, const byte * key, +int ha_blackhole::index_read(uchar * buf, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag) { @@ -193,7 +193,7 @@ int ha_blackhole::index_read(byte * buf, const byte * key, } -int ha_blackhole::index_read_idx(byte * buf, uint idx, const byte * key, +int ha_blackhole::index_read_idx(uchar * buf, uint idx, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag) { @@ -202,7 +202,7 @@ int ha_blackhole::index_read_idx(byte * buf, uint idx, const byte * key, } -int ha_blackhole::index_read_last(byte * buf, const byte * key, +int ha_blackhole::index_read_last(uchar * buf, const uchar * key, key_part_map keypart_map) { DBUG_ENTER("ha_blackhole::index_read_last"); @@ -210,28 +210,28 @@ int ha_blackhole::index_read_last(byte * buf, const byte * key, } -int ha_blackhole::index_next(byte * buf) +int ha_blackhole::index_next(uchar * buf) { DBUG_ENTER("ha_blackhole::index_next"); DBUG_RETURN(HA_ERR_END_OF_FILE); } -int ha_blackhole::index_prev(byte * buf) +int ha_blackhole::index_prev(uchar * buf) { DBUG_ENTER("ha_blackhole::index_prev"); DBUG_RETURN(HA_ERR_END_OF_FILE); } -int ha_blackhole::index_first(byte * buf) +int ha_blackhole::index_first(uchar * buf) { DBUG_ENTER("ha_blackhole::index_first"); DBUG_RETURN(HA_ERR_END_OF_FILE); } -int ha_blackhole::index_last(byte * buf) +int ha_blackhole::index_last(uchar * buf) { DBUG_ENTER("ha_blackhole::index_last"); DBUG_RETURN(HA_ERR_END_OF_FILE); @@ -247,7 +247,7 @@ static st_blackhole_share *get_share(const char *table_name) pthread_mutex_lock(&blackhole_mutex); if (!(share= (st_blackhole_share*) hash_search(&blackhole_open_tables, - (byte*) table_name, length))) + (uchar*) table_name, length))) { if (!(share= (st_blackhole_share*) my_malloc(sizeof(st_blackhole_share) + length, @@ -257,9 +257,9 @@ static st_blackhole_share *get_share(const char *table_name) share->table_name_length= length; strmov(share->table_name, table_name); - if (my_hash_insert(&blackhole_open_tables, (byte*) share)) + if (my_hash_insert(&blackhole_open_tables, (uchar*) share)) { - my_free((gptr) share, MYF(0)); + my_free((uchar*) share, MYF(0)); share= NULL; goto error; } @@ -277,21 +277,21 @@ static void free_share(st_blackhole_share *share) { pthread_mutex_lock(&blackhole_mutex); if (!--share->use_count) - hash_delete(&blackhole_open_tables, (byte*) share); + hash_delete(&blackhole_open_tables, (uchar*) share); pthread_mutex_unlock(&blackhole_mutex); } static void blackhole_free_key(st_blackhole_share *share) { thr_lock_delete(&share->lock); - my_free((gptr) share, MYF(0)); + my_free((uchar*) share, MYF(0)); } -static byte* blackhole_get_key(st_blackhole_share *share, uint *length, - my_bool not_used __attribute__((unused))) +static uchar* blackhole_get_key(st_blackhole_share *share, size_t *length, + my_bool not_used __attribute__((unused))) { *length= share->table_name_length; - return (byte*) share->table_name; + return (uchar*) share->table_name; } static int blackhole_init(void *p) diff --git a/storage/blackhole/ha_blackhole.h b/storage/blackhole/ha_blackhole.h index 1fd4df7ea78..9b511fc2e0c 100644 --- a/storage/blackhole/ha_blackhole.h +++ b/storage/blackhole/ha_blackhole.h @@ -71,20 +71,20 @@ public: uint max_supported_key_part_length() const { return BLACKHOLE_MAX_KEY_LENGTH; } int open(const char *name, int mode, uint test_if_locked); int close(void); - int write_row(byte * buf); + int write_row(uchar * buf); int rnd_init(bool scan); - int rnd_next(byte *buf); - int rnd_pos(byte * buf, byte *pos); - int index_read(byte * buf, const byte * key, key_part_map keypart_map, + int rnd_next(uchar *buf); + int rnd_pos(uchar * buf, uchar *pos); + int index_read(uchar * buf, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag); - int index_read_idx(byte * buf, uint idx, const byte * key, + int index_read_idx(uchar * buf, uint idx, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag); - int index_read_last(byte * buf, const byte * key, key_part_map keypart_map); - int index_next(byte * buf); - int index_prev(byte * buf); - int index_first(byte * buf); - int index_last(byte * buf); - void position(const byte *record); + int index_read_last(uchar * buf, const uchar * key, key_part_map keypart_map); + int index_next(uchar * buf); + int index_prev(uchar * buf); + int index_first(uchar * buf); + int index_last(uchar * buf); + void position(const uchar *record); int info(uint flag); int external_lock(THD *thd, int lock_type); int create(const char *name, TABLE *table_arg, diff --git a/storage/csv/ha_tina.cc b/storage/csv/ha_tina.cc index 07a4ffc65c5..9eead7a059c 100644 --- a/storage/csv/ha_tina.cc +++ b/storage/csv/ha_tina.cc @@ -93,11 +93,11 @@ int sort_set (tina_set *a, tina_set *b) return ( a->begin > b->begin ? 1 : ( a->begin < b->begin ? -1 : 0 ) ); } -static byte* tina_get_key(TINA_SHARE *share,uint *length, +static uchar* tina_get_key(TINA_SHARE *share, size_t *length, my_bool not_used __attribute__((unused))) { *length=share->table_name_length; - return (byte*) share->table_name; + return (uchar*) share->table_name; } static int tina_init_func(void *p) @@ -144,7 +144,7 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table) initialize its members. */ if (!(share=(TINA_SHARE*) hash_search(&tina_open_tables, - (byte*) table_name, + (uchar*) table_name, length))) { if (!my_multi_malloc(MYF(MY_WME | MY_ZEROFILL), @@ -174,7 +174,7 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table) goto error; share->saved_data_file_length= file_stat.st_size; - if (my_hash_insert(&tina_open_tables, (byte*) share)) + if (my_hash_insert(&tina_open_tables, (uchar*) share)) goto error; thr_lock_init(&share->lock); pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST); @@ -203,7 +203,7 @@ static TINA_SHARE *get_share(const char *table_name, TABLE *table) error: pthread_mutex_unlock(&tina_mutex); - my_free((gptr) share, MYF(0)); + my_free((uchar*) share, MYF(0)); return NULL; } @@ -236,7 +236,7 @@ static int read_meta_file(File meta_file, ha_rows *rows) DBUG_ENTER("ha_tina::read_meta_file"); VOID(my_seek(meta_file, 0, MY_SEEK_SET, MYF(0))); - if (my_read(meta_file, (byte*)meta_buffer, META_BUFFER_SIZE, 0) + if (my_read(meta_file, (uchar*)meta_buffer, META_BUFFER_SIZE, 0) != META_BUFFER_SIZE) DBUG_RETURN(HA_ERR_CRASHED_ON_USAGE); @@ -305,7 +305,7 @@ static int write_meta_file(File meta_file, ha_rows rows, bool dirty) *ptr= (uchar)dirty; VOID(my_seek(meta_file, 0, MY_SEEK_SET, MYF(0))); - if (my_write(meta_file, (byte *)meta_buffer, META_BUFFER_SIZE, 0) + if (my_write(meta_file, (uchar *)meta_buffer, META_BUFFER_SIZE, 0) != META_BUFFER_SIZE) DBUG_RETURN(-1); @@ -376,10 +376,10 @@ static int free_share(TINA_SHARE *share) share->tina_write_opened= FALSE; } - hash_delete(&tina_open_tables, (byte*) share); + hash_delete(&tina_open_tables, (uchar*) share); thr_lock_delete(&share->lock); pthread_mutex_destroy(&share->mutex); - my_free((gptr) share, MYF(0)); + my_free((uchar*) share, MYF(0)); } pthread_mutex_unlock(&tina_mutex); @@ -454,7 +454,7 @@ ha_tina::ha_tina(handlerton *hton, TABLE_SHARE *table_arg) Encode a buffer into the quoted format. */ -int ha_tina::encode_quote(byte *buf) +int ha_tina::encode_quote(uchar *buf) { char attribute_buffer[1024]; String attribute(attribute_buffer, sizeof(attribute_buffer), @@ -558,7 +558,7 @@ int ha_tina::chain_append() if (chain_alloced) { /* Must cast since my_malloc unlike malloc doesn't have a void ptr */ - if ((chain= (tina_set *) my_realloc((gptr)chain, + if ((chain= (tina_set *) my_realloc((uchar*)chain, chain_size, MYF(MY_WME))) == NULL) return -1; } @@ -584,7 +584,7 @@ int ha_tina::chain_append() /* Scans for a row. */ -int ha_tina::find_current_row(byte *buf) +int ha_tina::find_current_row(uchar *buf) { off_t end_offset, curr_offset= current_position; int eoln_len; @@ -851,7 +851,7 @@ int ha_tina::close(void) of the file and appends the data. In an error case it really should just truncate to the original position (this is not done yet). */ -int ha_tina::write_row(byte * buf) +int ha_tina::write_row(uchar * buf) { int size; DBUG_ENTER("ha_tina::write_row"); @@ -871,7 +871,7 @@ int ha_tina::write_row(byte * buf) DBUG_RETURN(-1); /* use pwrite, as concurrent reader could have changed the position */ - if (my_write(share->tina_write_filedes, (byte*)buffer.ptr(), size, + if (my_write(share->tina_write_filedes, (uchar*)buffer.ptr(), size, MYF(MY_WME | MY_NABP))) DBUG_RETURN(-1); @@ -916,7 +916,7 @@ int ha_tina::open_update_temp_file_if_needed() This will be called in a table scan right before the previous ::rnd_next() call. */ -int ha_tina::update_row(const byte * old_data, byte * new_data) +int ha_tina::update_row(const uchar * old_data, uchar * new_data) { int size; DBUG_ENTER("ha_tina::update_row"); @@ -934,7 +934,7 @@ int ha_tina::update_row(const byte * old_data, byte * new_data) if (open_update_temp_file_if_needed()) DBUG_RETURN(-1); - if (my_write(update_temp_file, (byte*)buffer.ptr(), size, + if (my_write(update_temp_file, (uchar*)buffer.ptr(), size, MYF(MY_WME | MY_NABP))) DBUG_RETURN(-1); @@ -954,7 +954,7 @@ int ha_tina::update_row(const byte * old_data, byte * new_data) The table will then be deleted/positioned based on the ORDER (so RANDOM, DESC, ASC). */ -int ha_tina::delete_row(const byte * buf) +int ha_tina::delete_row(const uchar * buf) { DBUG_ENTER("ha_tina::delete_row"); ha_statistic_increment(&SSV::ha_delete_count); @@ -1033,7 +1033,7 @@ int ha_tina::rnd_init(bool scan) NULL and "". This is ok since this table handler is for spreadsheets and they don't know about them either :) */ -int ha_tina::rnd_next(byte *buf) +int ha_tina::rnd_next(uchar *buf) { int rc; DBUG_ENTER("ha_tina::rnd_next"); @@ -1065,7 +1065,7 @@ int ha_tina::rnd_next(byte *buf) its just a position. Look at the bdb code if you want to see a case where something other then a number is stored. */ -void ha_tina::position(const byte *record) +void ha_tina::position(const uchar *record) { DBUG_ENTER("ha_tina::position"); my_store_ptr(ref, ref_length, current_position); @@ -1078,7 +1078,7 @@ void ha_tina::position(const byte *record) my_get_ptr() retrieves the data for you. */ -int ha_tina::rnd_pos(byte * buf, byte *pos) +int ha_tina::rnd_pos(uchar * buf, uchar *pos) { DBUG_ENTER("ha_tina::rnd_pos"); ha_statistic_increment(&SSV::ha_read_rnd_next_count); @@ -1178,7 +1178,7 @@ int ha_tina::rnd_end() /* if there is something to write, write it */ if ((write_end - write_begin) && (my_write(update_temp_file, - (byte*)(file_buff->ptr() + + (uchar*)(file_buff->ptr() + (write_begin - file_buff->start())), write_end - write_begin, MYF_RW))) goto error; @@ -1266,7 +1266,7 @@ error: int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt) { char repaired_fname[FN_REFLEN]; - byte *buf; + uchar *buf; File repair_file; int rc; ha_rows rows_repaired= 0; @@ -1282,7 +1282,7 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt) /* Don't assert in field::val() functions */ table->use_all_columns(); - if (!(buf= (byte*) my_malloc(table->s->reclength, MYF(MY_WME)))) + if (!(buf= (uchar*) my_malloc(table->s->reclength, MYF(MY_WME)))) DBUG_RETURN(HA_ERR_OUT_OF_MEM); /* position buffer to the start of the file */ @@ -1338,7 +1338,7 @@ int ha_tina::repair(THD* thd, HA_CHECK_OPT* check_opt) { write_end= min(file_buff->end(), current_position); if ((write_end - write_begin) && - (my_write(repair_file, (byte*)file_buff->ptr(), + (my_write(repair_file, (uchar*)file_buff->ptr(), write_end - write_begin, MYF_RW))) DBUG_RETURN(-1); @@ -1442,13 +1442,13 @@ int ha_tina::create(const char *name, TABLE *table_arg, int ha_tina::check(THD* thd, HA_CHECK_OPT* check_opt) { int rc= 0; - byte *buf; + uchar *buf; const char *old_proc_info; ha_rows count= share->rows_recorded; DBUG_ENTER("ha_tina::check"); old_proc_info= thd_proc_info(thd, "Checking table"); - if (!(buf= (byte*) my_malloc(table->s->reclength, MYF(MY_WME)))) + if (!(buf= (uchar*) my_malloc(table->s->reclength, MYF(MY_WME)))) DBUG_RETURN(HA_ERR_OUT_OF_MEM); /* position buffer to the start of the file */ diff --git a/storage/csv/ha_tina.h b/storage/csv/ha_tina.h index c096f21fca2..ecb7f006cc4 100644 --- a/storage/csv/ha_tina.h +++ b/storage/csv/ha_tina.h @@ -63,7 +63,7 @@ class ha_tina: public handler off_t current_position; /* Current position in the file during a file scan */ off_t next_position; /* Next position in the file scan */ off_t local_saved_data_file_length; /* save position for reads */ - byte byte_buffer[IO_SIZE]; + uchar byte_buffer[IO_SIZE]; Transparent_file *file_buff; File data_file; /* File handler for readers */ File update_temp_file; @@ -76,7 +76,7 @@ class ha_tina: public handler tina_set chain_buffer[DEFAULT_CHAIN_LENGTH]; tina_set *chain; tina_set *chain_ptr; - byte chain_alloced; + uchar chain_alloced; uint32 chain_size; bool records_is_known; @@ -90,7 +90,7 @@ public: ~ha_tina() { if (chain_alloced) - my_free((gptr)chain, 0); + my_free(chain, 0); if (file_buff) delete file_buff; } @@ -133,12 +133,12 @@ public: bool called_by_logger_thread); int open(const char *name, int mode, uint open_options); int close(void); - int write_row(byte * buf); - int update_row(const byte * old_data, byte * new_data); - int delete_row(const byte * buf); + int write_row(uchar * buf); + int update_row(const uchar * old_data, uchar * new_data); + int delete_row(const uchar * buf); int rnd_init(bool scan=1); - int rnd_next(byte *buf); - int rnd_pos(byte * buf, byte *pos); + int rnd_next(uchar *buf); + int rnd_pos(uchar * buf, uchar *pos); bool check_and_repair(THD *thd); int check(THD* thd, HA_CHECK_OPT* check_opt); bool is_crashed() const; @@ -146,7 +146,7 @@ public: int repair(THD* thd, HA_CHECK_OPT* check_opt); /* This is required for SQL layer to know that we support autorepair */ bool auto_repair() const { return 1; } - void position(const byte *record); + void position(const uchar *record); int info(uint); int extra(enum ha_extra_function operation); int delete_all_rows(void); @@ -165,8 +165,8 @@ public: void update_status(); /* The following methods were added just for TINA */ - int encode_quote(byte *buf); - int find_current_row(byte *buf); + int encode_quote(uchar *buf); + int find_current_row(uchar *buf); int chain_append(); }; diff --git a/storage/csv/transparent_file.cc b/storage/csv/transparent_file.cc index 27cc8c024b4..a200fa6ac36 100644 --- a/storage/csv/transparent_file.cc +++ b/storage/csv/transparent_file.cc @@ -22,12 +22,12 @@ Transparent_file::Transparent_file() : lower_bound(0), buff_size(IO_SIZE) { - buff= (byte *) my_malloc(buff_size*sizeof(byte), MYF(MY_WME)); + buff= (uchar *) my_malloc(buff_size*sizeof(uchar), MYF(MY_WME)); } Transparent_file::~Transparent_file() { - my_free((gptr)buff, MYF(MY_ALLOW_ZERO_PTR)); + my_free((uchar*)buff, MYF(MY_ALLOW_ZERO_PTR)); } void Transparent_file::init_buff(File filedes_arg) @@ -40,7 +40,7 @@ void Transparent_file::init_buff(File filedes_arg) upper_bound= my_read(filedes, buff, buff_size, MYF(0)); } -byte *Transparent_file::ptr() +uchar *Transparent_file::ptr() { return buff; } @@ -57,18 +57,18 @@ off_t Transparent_file::end() off_t Transparent_file::read_next() { - off_t bytes_read; + size_t bytes_read; /* No need to seek here, as the file managed by Transparent_file class always points to upper_bound byte */ if ((bytes_read= my_read(filedes, buff, buff_size, MYF(0))) == MY_FILE_ERROR) - return -1; + return (off_t) -1; /* end of file */ if (!bytes_read) - return -1; + return (off_t) -1; lower_bound= upper_bound; upper_bound+= bytes_read; @@ -79,26 +79,24 @@ off_t Transparent_file::read_next() char Transparent_file::get_value(off_t offset) { - off_t bytes_read; + size_t bytes_read; /* check boundaries */ if ((lower_bound <= offset) && (offset < upper_bound)) return buff[offset - lower_bound]; - else - { - VOID(my_seek(filedes, offset, MY_SEEK_SET, MYF(0))); - /* read appropriate portion of the file */ - if ((bytes_read= my_read(filedes, buff, buff_size, - MYF(0))) == MY_FILE_ERROR) - return 0; - - lower_bound= offset; - upper_bound= lower_bound + bytes_read; - - /* end of file */ - if (upper_bound == offset) - return 0; - - return buff[0]; - } + + VOID(my_seek(filedes, offset, MY_SEEK_SET, MYF(0))); + /* read appropriate portion of the file */ + if ((bytes_read= my_read(filedes, buff, buff_size, + MYF(0))) == MY_FILE_ERROR) + return 0; + + lower_bound= offset; + upper_bound= lower_bound + bytes_read; + + /* end of file */ + if (upper_bound == offset) + return 0; + + return buff[0]; } diff --git a/storage/csv/transparent_file.h b/storage/csv/transparent_file.h index ceb59ec7caf..4c0f4cce7e7 100644 --- a/storage/csv/transparent_file.h +++ b/storage/csv/transparent_file.h @@ -21,7 +21,7 @@ class Transparent_file { File filedes; - byte *buff; /* in-memory window to the file or mmaped area */ + uchar *buff; /* in-memory window to the file or mmaped area */ /* current window sizes */ off_t lower_bound; off_t upper_bound; @@ -33,7 +33,7 @@ public: ~Transparent_file(); void init_buff(File filedes_arg); - byte *ptr(); + uchar *ptr(); off_t start(); off_t end(); char get_value (off_t offset); diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc index 53af99dee97..06efc727837 100644 --- a/storage/example/ha_example.cc +++ b/storage/example/ha_example.cc @@ -114,11 +114,11 @@ pthread_mutex_t example_mutex; Function we use in the creation of our hash to get key. */ -static byte* example_get_key(EXAMPLE_SHARE *share,uint *length, +static uchar* example_get_key(EXAMPLE_SHARE *share, size_t *length, my_bool not_used __attribute__((unused))) { *length=share->table_name_length; - return (byte*) share->table_name; + return (uchar*) share->table_name; } @@ -172,7 +172,7 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table) length=(uint) strlen(table_name); if (!(share=(EXAMPLE_SHARE*) hash_search(&example_open_tables, - (byte*) table_name, + (uchar*) table_name, length))) { if (!(share=(EXAMPLE_SHARE *) @@ -189,7 +189,7 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table) share->table_name_length=length; share->table_name=tmp_name; strmov(share->table_name,table_name); - if (my_hash_insert(&example_open_tables, (byte*) share)) + if (my_hash_insert(&example_open_tables, (uchar*) share)) goto error; thr_lock_init(&share->lock); pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST); @@ -201,7 +201,7 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table) error: pthread_mutex_destroy(&share->mutex); - my_free((gptr) share, MYF(0)); + my_free(share, MYF(0)); return NULL; } @@ -218,10 +218,10 @@ static int free_share(EXAMPLE_SHARE *share) pthread_mutex_lock(&example_mutex); if (!--share->use_count) { - hash_delete(&example_open_tables, (byte*) share); + hash_delete(&example_open_tables, (uchar*) share); thr_lock_delete(&share->lock); pthread_mutex_destroy(&share->mutex); - my_free((gptr) share, MYF(0)); + my_free(share, MYF(0)); } pthread_mutex_unlock(&example_mutex); @@ -349,7 +349,7 @@ int ha_example::close(void) sql_insert.cc, sql_select.cc, sql_table.cc, sql_udf.cc and sql_update.cc */ -int ha_example::write_row(byte * buf) +int ha_example::write_row(uchar *buf) { DBUG_ENTER("ha_example::write_row"); DBUG_RETURN(HA_ERR_WRONG_COMMAND); @@ -378,7 +378,7 @@ int ha_example::write_row(byte * buf) @see sql_select.cc, sql_acl.cc, sql_update.cc and sql_insert.cc */ -int ha_example::update_row(const byte * old_data, byte * new_data) +int ha_example::update_row(const uchar *old_data, uchar *new_data) { DBUG_ENTER("ha_example::update_row"); @@ -406,7 +406,7 @@ int ha_example::update_row(const byte * old_data, byte * new_data) sql_acl.cc, sql_udf.cc, sql_delete.cc, sql_insert.cc and sql_select.cc */ -int ha_example::delete_row(const byte * buf) +int ha_example::delete_row(const uchar *buf) { DBUG_ENTER("ha_example::delete_row"); DBUG_RETURN(HA_ERR_WRONG_COMMAND); @@ -420,7 +420,7 @@ int ha_example::delete_row(const byte * buf) index. */ -int ha_example::index_read(byte * buf, const byte * key, +int ha_example::index_read(uchar *buf, const uchar *key, key_part_map keypart_map __attribute__((unused)), enum ha_rkey_function find_flag __attribute__((unused))) @@ -435,7 +435,7 @@ int ha_example::index_read(byte * buf, const byte * key, Used to read forward through the index. */ -int ha_example::index_next(byte * buf) +int ha_example::index_next(uchar *buf) { DBUG_ENTER("ha_example::index_next"); DBUG_RETURN(HA_ERR_WRONG_COMMAND); @@ -447,7 +447,7 @@ int ha_example::index_next(byte * buf) Used to read backwards through the index. */ -int ha_example::index_prev(byte * buf) +int ha_example::index_prev(uchar *buf) { DBUG_ENTER("ha_example::index_prev"); DBUG_RETURN(HA_ERR_WRONG_COMMAND); @@ -464,7 +464,7 @@ int ha_example::index_prev(byte * buf) @see opt_range.cc, opt_sum.cc, sql_handler.cc and sql_select.cc */ -int ha_example::index_first(byte * buf) +int ha_example::index_first(uchar *buf) { DBUG_ENTER("ha_example::index_first"); DBUG_RETURN(HA_ERR_WRONG_COMMAND); @@ -481,7 +481,7 @@ int ha_example::index_first(byte * buf) @see opt_range.cc, opt_sum.cc, sql_handler.cc and sql_select.cc */ -int ha_example::index_last(byte * buf) +int ha_example::index_last(uchar *buf) { DBUG_ENTER("ha_example::index_last"); DBUG_RETURN(HA_ERR_WRONG_COMMAND); @@ -528,7 +528,7 @@ int ha_example::rnd_end() @see filesort.cc, records.cc, sql_handler.cc, sql_select.cc, sql_table.cc and sql_update.cc */ -int ha_example::rnd_next(byte *buf) +int ha_example::rnd_next(uchar *buf) { DBUG_ENTER("ha_example::rnd_next"); DBUG_RETURN(HA_ERR_END_OF_FILE); @@ -556,7 +556,7 @@ int ha_example::rnd_next(byte *buf) @see filesort.cc, sql_select.cc, sql_delete.cc and sql_update.cc */ -void ha_example::position(const byte *record) +void ha_example::position(const uchar *record) { DBUG_ENTER("ha_example::position"); DBUG_VOID_RETURN; @@ -576,7 +576,7 @@ void ha_example::position(const byte *record) @see filesort.cc, records.cc, sql_insert.cc, sql_select.cc and sql_update.cc */ -int ha_example::rnd_pos(byte * buf, byte *pos) +int ha_example::rnd_pos(uchar *buf, uchar *pos) { DBUG_ENTER("ha_example::rnd_pos"); DBUG_RETURN(HA_ERR_WRONG_COMMAND); diff --git a/storage/example/ha_example.h b/storage/example/ha_example.h index 9777a478209..69b7cf4d336 100644 --- a/storage/example/ha_example.h +++ b/storage/example/ha_example.h @@ -172,50 +172,50 @@ public: We implement this in ha_example.cc. It's not an obligatory method; skip it and and MySQL will treat it as not implemented. */ - int write_row(byte * buf); + int write_row(uchar *buf); /** @brief We implement this in ha_example.cc. It's not an obligatory method; skip it and and MySQL will treat it as not implemented. */ - int update_row(const byte * old_data, byte * new_data); + int update_row(const uchar *old_data, uchar *new_data); /** @brief We implement this in ha_example.cc. It's not an obligatory method; skip it and and MySQL will treat it as not implemented. */ - int delete_row(const byte * buf); + int delete_row(const uchar *buf); /** @brief We implement this in ha_example.cc. It's not an obligatory method; skip it and and MySQL will treat it as not implemented. */ - int index_read(byte * buf, const byte * key, + int index_read(uchar *buf, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag); /** @brief We implement this in ha_example.cc. It's not an obligatory method; skip it and and MySQL will treat it as not implemented. */ - int index_next(byte * buf); + int index_next(uchar *buf); /** @brief We implement this in ha_example.cc. It's not an obligatory method; skip it and and MySQL will treat it as not implemented. */ - int index_prev(byte * buf); + int index_prev(uchar *buf); /** @brief We implement this in ha_example.cc. It's not an obligatory method; skip it and and MySQL will treat it as not implemented. */ - int index_first(byte * buf); + int index_first(uchar *buf); /** @brief We implement this in ha_example.cc. It's not an obligatory method; skip it and and MySQL will treat it as not implemented. */ - int index_last(byte * buf); + int index_last(uchar *buf); /** @brief Unlike index_init(), rnd_init() can be called two consecutive times @@ -227,9 +227,9 @@ public: */ int rnd_init(bool scan); //required int rnd_end(); - int rnd_next(byte *buf); ///< required - int rnd_pos(byte * buf, byte *pos); ///< required - void position(const byte *record); ///< required + int rnd_next(uchar *buf); ///< required + int rnd_pos(uchar *buf, uchar *pos); ///< required + void position(const uchar *record); ///< required int info(uint); ///< required int extra(enum ha_extra_function operation); int external_lock(THD *thd, int lock_type); ///< required diff --git a/storage/federated/ha_federated.cc b/storage/federated/ha_federated.cc index da8ad46f96d..96ce0013587 100644 --- a/storage/federated/ha_federated.cc +++ b/storage/federated/ha_federated.cc @@ -414,11 +414,11 @@ static handler *federated_create_handler(handlerton *hton, /* Function we use in the creation of our hash to get key */ -static byte *federated_get_key(FEDERATED_SHARE *share, uint *length, +static uchar *federated_get_key(FEDERATED_SHARE *share, size_t *length, my_bool not_used __attribute__ ((unused))) { *length= share->share_key_length; - return (byte*) share->share_key; + return (uchar*) share->share_key; } /* @@ -725,8 +725,8 @@ static int parse_url(MEM_ROOT *mem_root, FEDERATED_SHARE *share, TABLE *table, share->port= 0; share->socket= 0; DBUG_PRINT("info", ("share at %lx", (long unsigned int) share)); - DBUG_PRINT("info", ("Length: %d", table->s->connect_string.length)); - DBUG_PRINT("info", ("String: '%.*s'", table->s->connect_string.length, + DBUG_PRINT("info", ("Length: %u", (uint) table->s->connect_string.length)); + DBUG_PRINT("info", ("String: '%.*s'", (int) table->s->connect_string.length, table->s->connect_string.str)); share->connection_string= strmake_root(mem_root, table->s->connect_string.str, table->s->connect_string.length); @@ -930,7 +930,7 @@ ha_federated::ha_federated(handlerton *hton, 0 After fields have had field values stored from record */ -uint ha_federated::convert_row_to_internal_format(byte *record, +uint ha_federated::convert_row_to_internal_format(uchar *record, MYSQL_ROW row, MYSQL_RES *result) { @@ -978,7 +978,7 @@ static bool emit_key_part_name(String *to, KEY_PART_INFO *part) static bool emit_key_part_element(String *to, KEY_PART_INFO *part, bool needs_quotes, bool is_like, - const byte *ptr, uint len) + const uchar *ptr, uint len) { Field *field= part->field; DBUG_ENTER("emit_key_part_element"); @@ -1019,7 +1019,7 @@ static bool emit_key_part_element(String *to, KEY_PART_INFO *part, char strbuff[MAX_FIELD_WIDTH]; String str(strbuff, sizeof(strbuff), part->field->charset()), *res; - res= field->val_str(&str, (char *)ptr); + res= field->val_str(&str, ptr); if (field->result_type() == STRING_RESULT) { @@ -1286,7 +1286,7 @@ bool ha_federated::create_where_from_key(String *to, { bool both_not_null= (start_key != NULL && end_key != NULL) ? TRUE : FALSE; - const byte *ptr; + const uchar *ptr; uint remainder, length; char tmpbuff[FEDERATED_QUERY_BUFFER_SIZE]; String tmp(tmpbuff, sizeof(tmpbuff), system_charset_info); @@ -1325,7 +1325,7 @@ bool ha_federated::create_where_from_key(String *to, uint store_length= key_part->store_length; uint part_length= min(store_length, length); needs_quotes= field->str_needs_quotes(); - DBUG_DUMP("key, start of loop", (char *) ptr, length); + DBUG_DUMP("key, start of loop", ptr, length); if (key_part->null_bit) { @@ -1507,7 +1507,7 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table) /* TODO: change tmp_share.scheme to LEX_STRING object */ if (!(share= (FEDERATED_SHARE *) hash_search(&federated_open_tables, - (byte*) tmp_share.share_key, + (uchar*) tmp_share.share_key, tmp_share. share_key_length))) { @@ -1537,7 +1537,7 @@ static FEDERATED_SHARE *get_share(const char *table_name, TABLE *table) DBUG_PRINT("info", ("share->select_query %s", share->select_query)); - if (my_hash_insert(&federated_open_tables, (byte*) share)) + if (my_hash_insert(&federated_open_tables, (uchar*) share)) goto error; thr_lock_init(&share->lock); pthread_mutex_init(&share->mutex, MY_MUTEX_INIT_FAST); @@ -1571,7 +1571,7 @@ static int free_share(FEDERATED_SHARE *share) pthread_mutex_lock(&federated_mutex); if (!--share->use_count) { - hash_delete(&federated_open_tables, (byte*) share); + hash_delete(&federated_open_tables, (uchar*) share); thr_lock_delete(&share->lock); VOID(pthread_mutex_destroy(&share->mutex)); free_root(&mem_root, MYF(0)); @@ -1755,7 +1755,7 @@ static inline uint field_in_record_is_null(TABLE *table, sql_insert.cc, sql_select.cc, sql_table.cc, sql_udf.cc, and sql_update.cc. */ -int ha_federated::write_row(byte *buf) +int ha_federated::write_row(uchar *buf) { /* I need a bool again, in 5.0, I used table->s->fields to accomplish this. @@ -2010,7 +2010,7 @@ int ha_federated::repair(THD* thd, HA_CHECK_OPT* check_opt) Called from sql_select.cc, sql_acl.cc, sql_update.cc, and sql_insert.cc. */ -int ha_federated::update_row(const byte *old_data, byte *new_data) +int ha_federated::update_row(const uchar *old_data, uchar *new_data) { /* This used to control how the query was built. If there was a @@ -2044,7 +2044,7 @@ int ha_federated::update_row(const byte *old_data, byte *new_data) String where_string(where_buffer, sizeof(where_buffer), &my_charset_bin); - byte *record= table->record[0]; + uchar *record= table->record[0]; DBUG_ENTER("ha_federated::update_row"); /* set string lengths to 0 to avoid misc chars in string @@ -2103,7 +2103,7 @@ int ha_federated::update_row(const byte *old_data, byte *new_data) bool needs_quote= (*field)->str_needs_quotes(); where_string.append(STRING_WITH_LEN(" = ")); (*field)->val_str(&field_value, - (char*) (old_data + (*field)->offset(record))); + (old_data + (*field)->offset(record))); if (needs_quote) where_string.append('\''); field_value.print(&where_string); @@ -2155,7 +2155,7 @@ int ha_federated::update_row(const byte *old_data, byte *new_data) calls. */ -int ha_federated::delete_row(const byte *buf) +int ha_federated::delete_row(const uchar *buf) { char delete_buffer[FEDERATED_QUERY_BUFFER_SIZE]; char data_buffer[FEDERATED_QUERY_BUFFER_SIZE]; @@ -2225,7 +2225,7 @@ int ha_federated::delete_row(const byte *buf) a WHERE clause on a non-primary key index, simply calls index_read_idx. */ -int ha_federated::index_read(byte *buf, const byte *key, +int ha_federated::index_read(uchar *buf, const uchar *key, uint key_len, ha_rkey_function find_flag) { DBUG_ENTER("ha_federated::index_read"); @@ -2251,7 +2251,7 @@ int ha_federated::index_read(byte *buf, const byte *key, returns. We need to be able to be calable from ha_rnd_pos() */ -int ha_federated::index_read_idx(byte *buf, uint index, const byte *key, +int ha_federated::index_read_idx(uchar *buf, uint index, const uchar *key, uint key_len, enum ha_rkey_function find_flag) { int retval; @@ -2277,8 +2277,8 @@ int ha_federated::index_read_idx(byte *buf, uint index, const byte *key, table->status == STATUS_NOT_FOUND */ -int ha_federated::index_read_idx_with_result_set(byte *buf, uint index, - const byte *key, +int ha_federated::index_read_idx_with_result_set(uchar *buf, uint index, + const uchar *key, uint key_len, ha_rkey_function find_flag, MYSQL_RES **result) @@ -2410,7 +2410,7 @@ int ha_federated::read_range_next() /* Used to read forward through the index. */ -int ha_federated::index_next(byte *buf) +int ha_federated::index_next(uchar *buf) { DBUG_ENTER("ha_federated::index_next"); ha_statistic_increment(&SSV::ha_read_next_count); @@ -2523,7 +2523,7 @@ int ha_federated::index_end(void) sql_table.cc, and sql_update.cc. */ -int ha_federated::rnd_next(byte *buf) +int ha_federated::rnd_next(uchar *buf) { DBUG_ENTER("ha_federated::rnd_next"); @@ -2560,7 +2560,7 @@ int ha_federated::rnd_next(byte *buf) 0 no error */ -int ha_federated::read_next(byte *buf, MYSQL_RES *result) +int ha_federated::read_next(uchar *buf, MYSQL_RES *result) { int retval; MYSQL_ROW row; @@ -2589,11 +2589,11 @@ int ha_federated::read_next(byte *buf, MYSQL_RES *result) Called from filesort.cc, sql_select.cc, sql_delete.cc and sql_update.cc. */ -void ha_federated::position(const byte *record) +void ha_federated::position(const uchar *record) { DBUG_ENTER("ha_federated::position"); if (table->s->primary_key != MAX_KEY) - key_copy(ref, (byte *)record, table->key_info + table->s->primary_key, + key_copy(ref, (uchar *)record, table->key_info + table->s->primary_key, ref_length); else memcpy(ref, record, ref_length); @@ -2610,7 +2610,7 @@ void ha_federated::position(const byte *record) Called from filesort.cc records.cc sql_insert.cc sql_select.cc sql_update.cc. */ -int ha_federated::rnd_pos(byte *buf, byte *pos) +int ha_federated::rnd_pos(uchar *buf, uchar *pos) { int result; DBUG_ENTER("ha_federated::rnd_pos"); diff --git a/storage/federated/ha_federated.h b/storage/federated/ha_federated.h index 4d2eefdd986..94f61af96c3 100644 --- a/storage/federated/ha_federated.h +++ b/storage/federated/ha_federated.h @@ -94,7 +94,7 @@ private: return 0 on success return errorcode otherwise */ - uint convert_row_to_internal_format(byte *buf, MYSQL_ROW row, + uint convert_row_to_internal_format(uchar *buf, MYSQL_ROW row, MYSQL_RES *result); bool create_where_from_key(String *to, KEY *key_info, const key_range *start_key, @@ -188,15 +188,15 @@ public: int open(const char *name, int mode, uint test_if_locked); // required int close(void); // required - int write_row(byte *buf); - int update_row(const byte *old_data, byte *new_data); - int delete_row(const byte *buf); + int write_row(uchar *buf); + int update_row(const uchar *old_data, uchar *new_data); + int delete_row(const uchar *buf); int index_init(uint keynr, bool sorted); - int index_read(byte *buf, const byte *key, + int index_read(uchar *buf, const uchar *key, uint key_len, enum ha_rkey_function find_flag); - int index_read_idx(byte *buf, uint idx, const byte *key, + int index_read_idx(uchar *buf, uint idx, const uchar *key, uint key_len, enum ha_rkey_function find_flag); - int index_next(byte *buf); + int index_next(uchar *buf); int index_end(); int read_range_first(const key_range *start_key, const key_range *end_key, @@ -212,9 +212,9 @@ public: */ int rnd_init(bool scan); //required int rnd_end(); - int rnd_next(byte *buf); //required - int rnd_pos(byte *buf, byte *pos); //required - void position(const byte *record); //required + int rnd_next(uchar *buf); //required + int rnd_pos(uchar *buf, uchar *pos); //required + void position(const uchar *record); //required int info(uint); //required void update_auto_increment(void); @@ -237,9 +237,9 @@ public: int connection_autocommit(bool state); int execute_simple_query(const char *query, int len); - int read_next(byte *buf, MYSQL_RES *result); - int index_read_idx_with_result_set(byte *buf, uint index, - const byte *key, + int read_next(uchar *buf, MYSQL_RES *result); + int index_read_idx_with_result_set(uchar *buf, uint index, + const uchar *key, uint key_len, ha_rkey_function find_flag, MYSQL_RES **result); diff --git a/storage/heap/_check.c b/storage/heap/_check.c index 05f12dade0d..08b6da62ae1 100644 --- a/storage/heap/_check.c +++ b/storage/heap/_check.c @@ -167,7 +167,7 @@ static int check_one_rb_key(HP_INFO *info, uint keynr, ulong records, HP_KEYDEF *keydef= info->s->keydef + keynr; int error= 0; ulong found= 0; - byte *key, *recpos; + uchar *key, *recpos; uint key_length; uint not_used[2]; @@ -176,7 +176,7 @@ static int check_one_rb_key(HP_INFO *info, uint keynr, ulong records, { do { - memcpy(&recpos, key + (*keydef->get_key_length)(keydef,key), sizeof(byte*)); + memcpy(&recpos, key + (*keydef->get_key_length)(keydef,key), sizeof(uchar*)); key_length= hp_rb_make_key(keydef, info->recbuf, recpos, 0); if (ha_key_cmp(keydef->seg, (uchar*) info->recbuf, (uchar*) key, key_length, SEARCH_FIND | SEARCH_SAME, not_used)) diff --git a/storage/heap/_rectest.c b/storage/heap/_rectest.c index 2fd2d39bed7..068fedf719c 100644 --- a/storage/heap/_rectest.c +++ b/storage/heap/_rectest.c @@ -18,7 +18,7 @@ #include "heapdef.h" -int hp_rectest(register HP_INFO *info, register const byte *old) +int hp_rectest(register HP_INFO *info, register const uchar *old) { DBUG_ENTER("hp_rectest"); diff --git a/storage/heap/ha_heap.cc b/storage/heap/ha_heap.cc index 096b0f63b5e..86bc2cc516e 100644 --- a/storage/heap/ha_heap.cc +++ b/storage/heap/ha_heap.cc @@ -178,7 +178,7 @@ void ha_heap::update_key_stats() } -int ha_heap::write_row(byte * buf) +int ha_heap::write_row(uchar * buf) { int res; ha_statistic_increment(&SSV::ha_write_count); @@ -202,7 +202,7 @@ int ha_heap::write_row(byte * buf) return res; } -int ha_heap::update_row(const byte * old_data, byte * new_data) +int ha_heap::update_row(const uchar * old_data, uchar * new_data) { int res; ha_statistic_increment(&SSV::ha_update_count); @@ -221,7 +221,7 @@ int ha_heap::update_row(const byte * old_data, byte * new_data) return res; } -int ha_heap::delete_row(const byte * buf) +int ha_heap::delete_row(const uchar * buf) { int res; ha_statistic_increment(&SSV::ha_delete_count); @@ -238,7 +238,7 @@ int ha_heap::delete_row(const byte * buf) return res; } -int ha_heap::index_read(byte * buf, const byte * key, key_part_map keypart_map, +int ha_heap::index_read(uchar * buf, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag) { DBUG_ASSERT(inited==INDEX); @@ -248,7 +248,7 @@ int ha_heap::index_read(byte * buf, const byte * key, key_part_map keypart_map, return error; } -int ha_heap::index_read_last(byte *buf, const byte *key, key_part_map keypart_map) +int ha_heap::index_read_last(uchar *buf, const uchar *key, key_part_map keypart_map) { DBUG_ASSERT(inited==INDEX); ha_statistic_increment(&SSV::ha_read_key_count); @@ -258,7 +258,7 @@ int ha_heap::index_read_last(byte *buf, const byte *key, key_part_map keypart_ma return error; } -int ha_heap::index_read_idx(byte * buf, uint index, const byte * key, +int ha_heap::index_read_idx(uchar * buf, uint index, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag) { @@ -268,7 +268,7 @@ int ha_heap::index_read_idx(byte * buf, uint index, const byte * key, return error; } -int ha_heap::index_next(byte * buf) +int ha_heap::index_next(uchar * buf) { DBUG_ASSERT(inited==INDEX); ha_statistic_increment(&SSV::ha_read_next_count); @@ -277,7 +277,7 @@ int ha_heap::index_next(byte * buf) return error; } -int ha_heap::index_prev(byte * buf) +int ha_heap::index_prev(uchar * buf) { DBUG_ASSERT(inited==INDEX); ha_statistic_increment(&SSV::ha_read_prev_count); @@ -286,7 +286,7 @@ int ha_heap::index_prev(byte * buf) return error; } -int ha_heap::index_first(byte * buf) +int ha_heap::index_first(uchar * buf) { DBUG_ASSERT(inited==INDEX); ha_statistic_increment(&SSV::ha_read_first_count); @@ -295,7 +295,7 @@ int ha_heap::index_first(byte * buf) return error; } -int ha_heap::index_last(byte * buf) +int ha_heap::index_last(uchar * buf) { DBUG_ASSERT(inited==INDEX); ha_statistic_increment(&SSV::ha_read_last_count); @@ -309,7 +309,7 @@ int ha_heap::rnd_init(bool scan) return scan ? heap_scan_init(file) : 0; } -int ha_heap::rnd_next(byte *buf) +int ha_heap::rnd_next(uchar *buf) { ha_statistic_increment(&SSV::ha_read_rnd_next_count); int error=heap_scan(file, buf); @@ -317,7 +317,7 @@ int ha_heap::rnd_next(byte *buf) return error; } -int ha_heap::rnd_pos(byte * buf, byte *pos) +int ha_heap::rnd_pos(uchar * buf, uchar *pos) { int error; HEAP_PTR heap_position; @@ -328,7 +328,7 @@ int ha_heap::rnd_pos(byte * buf, byte *pos) return error; } -void ha_heap::position(const byte *record) +void ha_heap::position(const uchar *record) { *(HEAP_PTR*) ref= heap_position(file); // Ref is aligned } @@ -668,7 +668,7 @@ int ha_heap::create(const char *name, TABLE *table_arg, share->max_rows) ? share->max_rows : max_rows), (ulong) share->min_rows, &hp_create_info); - my_free((gptr) keydef, MYF(0)); + my_free((uchar*) keydef, MYF(0)); if (file) info(HA_STATUS_NO_LOCK | HA_STATUS_CONST | HA_STATUS_VARIABLE); return (error); diff --git a/storage/heap/ha_heap.h b/storage/heap/ha_heap.h index a2d531fc515..c93a33b524b 100644 --- a/storage/heap/ha_heap.h +++ b/storage/heap/ha_heap.h @@ -68,26 +68,26 @@ public: int open(const char *name, int mode, uint test_if_locked); int close(void); void set_keys_for_scanning(void); - int write_row(byte * buf); - int update_row(const byte * old_data, byte * new_data); - int delete_row(const byte * buf); + int write_row(uchar * buf); + int update_row(const uchar * old_data, uchar * new_data); + int delete_row(const uchar * buf); virtual void get_auto_increment(ulonglong offset, ulonglong increment, ulonglong nb_desired_values, ulonglong *first_value, ulonglong *nb_reserved_values); - int index_read(byte * buf, const byte * key, key_part_map keypart_map, + int index_read(uchar * buf, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag); - int index_read_last(byte *buf, const byte *key, key_part_map keypart_map); - int index_read_idx(byte * buf, uint index, const byte * key, + int index_read_last(uchar *buf, const uchar *key, key_part_map keypart_map); + int index_read_idx(uchar * buf, uint index, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag); - int index_next(byte * buf); - int index_prev(byte * buf); - int index_first(byte * buf); - int index_last(byte * buf); + int index_next(uchar * buf); + int index_prev(uchar * buf); + int index_first(uchar * buf); + int index_last(uchar * buf); int rnd_init(bool scan); - int rnd_next(byte *buf); - int rnd_pos(byte * buf, byte *pos); - void position(const byte *record); + int rnd_next(uchar *buf); + int rnd_pos(uchar * buf, uchar *pos); + void position(const uchar *record); int info(uint); int extra(enum ha_extra_function operation); int reset(); @@ -105,7 +105,7 @@ public: THR_LOCK_DATA **store_lock(THD *thd, THR_LOCK_DATA **to, enum thr_lock_type lock_type); - int cmp_ref(const byte *ref1, const byte *ref2) + int cmp_ref(const uchar *ref1, const uchar *ref2) { HEAP_PTR ptr1=*(HEAP_PTR*)ref1; HEAP_PTR ptr2=*(HEAP_PTR*)ref2; diff --git a/storage/heap/heapdef.h b/storage/heap/heapdef.h index b52a6c60ac6..c43d73eb96d 100644 --- a/storage/heap/heapdef.h +++ b/storage/heap/heapdef.h @@ -48,7 +48,7 @@ if (!(info->update & HA_STATE_AKTIV))\ typedef struct st_hp_hash_info { struct st_hp_hash_info *next_key; - byte *ptr_to_rec; + uchar *ptr_to_rec; } HASH_INFO; typedef struct { @@ -60,42 +60,42 @@ typedef struct { /* Prototypes for intern functions */ extern HP_SHARE *hp_find_named_heap(const char *name); -extern int hp_rectest(HP_INFO *info,const byte *old); -extern byte *hp_find_block(HP_BLOCK *info,ulong pos); -extern int hp_get_new_block(HP_BLOCK *info, ulong* alloc_length); +extern int hp_rectest(HP_INFO *info,const uchar *old); +extern uchar *hp_find_block(HP_BLOCK *info,ulong pos); +extern int hp_get_new_block(HP_BLOCK *info, size_t* alloc_length); extern void hp_free(HP_SHARE *info); -extern byte *hp_free_level(HP_BLOCK *block,uint level,HP_PTRS *pos, - byte *last_pos); +extern uchar *hp_free_level(HP_BLOCK *block,uint level,HP_PTRS *pos, + uchar *last_pos); extern int hp_write_key(HP_INFO *info, HP_KEYDEF *keyinfo, - const byte *record, byte *recpos); + const uchar *record, uchar *recpos); extern int hp_rb_write_key(HP_INFO *info, HP_KEYDEF *keyinfo, - const byte *record, byte *recpos); + const uchar *record, uchar *recpos); extern int hp_rb_delete_key(HP_INFO *info,HP_KEYDEF *keyinfo, - const byte *record,byte *recpos,int flag); + const uchar *record,uchar *recpos,int flag); extern int hp_delete_key(HP_INFO *info,HP_KEYDEF *keyinfo, - const byte *record,byte *recpos,int flag); + const uchar *record,uchar *recpos,int flag); extern HASH_INFO *_heap_find_hash(HP_BLOCK *block,ulong pos); -extern byte *hp_search(HP_INFO *info,HP_KEYDEF *keyinfo,const byte *key, +extern uchar *hp_search(HP_INFO *info,HP_KEYDEF *keyinfo,const uchar *key, uint nextflag); -extern byte *hp_search_next(HP_INFO *info, HP_KEYDEF *keyinfo, - const byte *key, HASH_INFO *pos); -extern ulong hp_hashnr(HP_KEYDEF *keyinfo,const byte *key); -extern ulong hp_rec_hashnr(HP_KEYDEF *keyinfo,const byte *rec); +extern uchar *hp_search_next(HP_INFO *info, HP_KEYDEF *keyinfo, + const uchar *key, HASH_INFO *pos); +extern ulong hp_hashnr(HP_KEYDEF *keyinfo,const uchar *key); +extern ulong hp_rec_hashnr(HP_KEYDEF *keyinfo,const uchar *rec); extern ulong hp_mask(ulong hashnr,ulong buffmax,ulong maxlength); extern void hp_movelink(HASH_INFO *pos,HASH_INFO *next_link, HASH_INFO *newlink); -extern int hp_rec_key_cmp(HP_KEYDEF *keydef,const byte *rec1, - const byte *rec2, +extern int hp_rec_key_cmp(HP_KEYDEF *keydef,const uchar *rec1, + const uchar *rec2, my_bool diff_if_only_endspace_difference); -extern int hp_key_cmp(HP_KEYDEF *keydef,const byte *rec, - const byte *key); -extern void hp_make_key(HP_KEYDEF *keydef,byte *key,const byte *rec); -extern uint hp_rb_make_key(HP_KEYDEF *keydef, byte *key, - const byte *rec, byte *recpos); -extern uint hp_rb_key_length(HP_KEYDEF *keydef, const byte *key); -extern uint hp_rb_null_key_length(HP_KEYDEF *keydef, const byte *key); -extern uint hp_rb_var_key_length(HP_KEYDEF *keydef, const byte *key); -extern my_bool hp_if_null_in_key(HP_KEYDEF *keyinfo, const byte *record); +extern int hp_key_cmp(HP_KEYDEF *keydef,const uchar *rec, + const uchar *key); +extern void hp_make_key(HP_KEYDEF *keydef,uchar *key,const uchar *rec); +extern uint hp_rb_make_key(HP_KEYDEF *keydef, uchar *key, + const uchar *rec, uchar *recpos); +extern uint hp_rb_key_length(HP_KEYDEF *keydef, const uchar *key); +extern uint hp_rb_null_key_length(HP_KEYDEF *keydef, const uchar *key); +extern uint hp_rb_var_key_length(HP_KEYDEF *keydef, const uchar *key); +extern my_bool hp_if_null_in_key(HP_KEYDEF *keyinfo, const uchar *record); extern int hp_close(register HP_INFO *info); extern void hp_clear(HP_SHARE *info); extern void hp_clear_keys(HP_SHARE *info); diff --git a/storage/heap/hp_block.c b/storage/heap/hp_block.c index 85219380287..c622a9e52f8 100644 --- a/storage/heap/hp_block.c +++ b/storage/heap/hp_block.c @@ -26,7 +26,7 @@ {p_0, p_1, ...} serve as indexes to descend the blocks tree. */ -byte *hp_find_block(HP_BLOCK *block, ulong pos) +uchar *hp_find_block(HP_BLOCK *block, ulong pos) { reg1 int i; reg3 HP_PTRS *ptr; /* block base ptr */ @@ -36,12 +36,13 @@ byte *hp_find_block(HP_BLOCK *block, ulong pos) ptr=(HP_PTRS*)ptr->blocks[pos/block->level_info[i].records_under_level]; pos%=block->level_info[i].records_under_level; } - return (byte*) ptr+ pos*block->recbuffer; + return (uchar*) ptr+ pos*block->recbuffer; } /* Get one new block-of-records. Alloc ptr to block if needed + SYNOPSIS hp_get_new_block() block HP_BLOCK tree-like block @@ -53,7 +54,7 @@ byte *hp_find_block(HP_BLOCK *block, ulong pos) 1 Out of memory */ -int hp_get_new_block(HP_BLOCK *block, ulong *alloc_length) +int hp_get_new_block(HP_BLOCK *block, size_t *alloc_length) { reg1 uint i,j; HP_PTRS *root; @@ -101,13 +102,13 @@ int hp_get_new_block(HP_BLOCK *block, ulong *alloc_length) /* Occupy the free slot we've found at level i */ block->level_info[i].last_blocks-> blocks[HP_PTRS_IN_NOD - block->level_info[i].free_ptrs_in_block--]= - (byte*) root; + (uchar*) root; /* Add a block subtree with each node having one left-most child */ for (j=i-1 ; j >0 ; j--) { block->level_info[j].last_blocks= root++; - block->level_info[j].last_blocks->blocks[0]=(byte*) root; + block->level_info[j].last_blocks->blocks[0]=(uchar*) root; block->level_info[j].free_ptrs_in_block=HP_PTRS_IN_NOD-1; } @@ -124,27 +125,27 @@ int hp_get_new_block(HP_BLOCK *block, ulong *alloc_length) /* free all blocks under level */ -byte *hp_free_level(HP_BLOCK *block, uint level, HP_PTRS *pos, byte *last_pos) +uchar *hp_free_level(HP_BLOCK *block, uint level, HP_PTRS *pos, uchar *last_pos) { int i,max_pos; - byte *next_ptr; + uchar *next_ptr; if (level == 1) - next_ptr=(byte*) pos+block->recbuffer; + next_ptr=(uchar*) pos+block->recbuffer; else { max_pos= (block->level_info[level-1].last_blocks == pos) ? HP_PTRS_IN_NOD - block->level_info[level-1].free_ptrs_in_block : HP_PTRS_IN_NOD; - next_ptr=(byte*) (pos+1); + next_ptr=(uchar*) (pos+1); for (i=0 ; i < max_pos ; i++) next_ptr=hp_free_level(block,level-1, (HP_PTRS*) pos->blocks[i],next_ptr); } - if ((byte*) pos != last_pos) + if ((uchar*) pos != last_pos) { - my_free((gptr) pos,MYF(0)); + my_free((uchar*) pos,MYF(0)); return last_pos; } return next_ptr; /* next memory position */ diff --git a/storage/heap/hp_clear.c b/storage/heap/hp_clear.c index 2d8b8b394d5..babfcbd6f41 100644 --- a/storage/heap/hp_clear.c +++ b/storage/heap/hp_clear.c @@ -32,7 +32,7 @@ void hp_clear(HP_SHARE *info) if (info->block.levels) VOID(hp_free_level(&info->block,info->block.levels,info->block.root, - (byte*) 0)); + (uchar*) 0)); info->block.levels=0; hp_clear_keys(info); info->records= info->deleted= 0; @@ -94,7 +94,7 @@ void hp_clear_keys(HP_SHARE *info) { HP_BLOCK *block= &keyinfo->block; if (block->levels) - VOID(hp_free_level(block,block->levels,block->root,(byte*) 0)); + VOID(hp_free_level(block,block->levels,block->root,(uchar*) 0)); block->levels=0; block->last_allocated=0; keyinfo->hash_buckets= 0; diff --git a/storage/heap/hp_close.c b/storage/heap/hp_close.c index 5f6fc3249b5..79fed859487 100644 --- a/storage/heap/hp_close.c +++ b/storage/heap/hp_close.c @@ -45,6 +45,6 @@ int hp_close(register HP_INFO *info) heap_open_list=list_delete(heap_open_list,&info->open_list); if (!--info->s->open_count && info->s->delete_on_close) hp_free(info->s); /* Table was deleted */ - my_free((gptr) info,MYF(0)); + my_free((uchar*) info,MYF(0)); DBUG_RETURN(error); } diff --git a/storage/heap/hp_create.c b/storage/heap/hp_create.c index 4e1347966b9..b910b89ffcd 100644 --- a/storage/heap/hp_create.c +++ b/storage/heap/hp_create.c @@ -42,10 +42,10 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, DBUG_PRINT("info",("Initializing new table")); /* - We have to store sometimes byte* del_link in records, - so the record length should be at least sizeof(byte*) + We have to store sometimes uchar* del_link in records, + so the record length should be at least sizeof(uchar*) */ - set_if_bigger(reclength, sizeof (byte*)); + set_if_bigger(reclength, sizeof (uchar*)); for (i= key_segs= max_length= 0, keyinfo= keydef; i < keys; i++, keyinfo++) { @@ -112,7 +112,7 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, } keyinfo->length= length; length+= keyinfo->rb_tree.size_of_element + - ((keyinfo->algorithm == HA_KEY_ALG_BTREE) ? sizeof(byte*) : 0); + ((keyinfo->algorithm == HA_KEY_ALG_BTREE) ? sizeof(uchar*) : 0); if (length > max_length) max_length= length; key_segs+= keyinfo->keysegs; @@ -152,12 +152,12 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, { /* additional HA_KEYTYPE_END keyseg */ keyseg->type= HA_KEYTYPE_END; - keyseg->length= sizeof(byte*); + keyseg->length= sizeof(uchar*); keyseg->flag= 0; keyseg->null_bit= 0; keyseg++; - init_tree(&keyinfo->rb_tree, 0, 0, sizeof(byte*), + init_tree(&keyinfo->rb_tree, 0, 0, sizeof(uchar*), (qsort_cmp2)keys_compare, 1, NULL, NULL); keyinfo->delete_key= hp_rb_delete_key; keyinfo->write_key= hp_rb_write_key; @@ -188,7 +188,7 @@ int heap_create(const char *name, uint keys, HP_KEYDEF *keydef, /* Must be allocated separately for rename to work */ if (!(share->name= my_strdup(name,MYF(0)))) { - my_free((gptr) share,MYF(0)); + my_free((uchar*) share,MYF(0)); pthread_mutex_unlock(&THR_LOCK_heap); DBUG_RETURN(1); } @@ -218,7 +218,7 @@ static void init_block(HP_BLOCK *block, uint reclength, ulong min_records, max_records= max(min_records,max_records); if (!max_records) max_records= 1000; /* As good as quess as anything */ - recbuffer= (uint) (reclength + sizeof(byte**) - 1) & ~(sizeof(byte**) - 1); + recbuffer= (uint) (reclength + sizeof(uchar**) - 1) & ~(sizeof(uchar**) - 1); records_in_block= max_records / 10; if (records_in_block < 10 && max_records) records_in_block= 10; @@ -285,7 +285,7 @@ void hp_free(HP_SHARE *share) thr_lock_delete(&share->lock); VOID(pthread_mutex_destroy(&share->intern_lock)); #endif - my_free((gptr) share->name, MYF(0)); - my_free((gptr) share, MYF(0)); + my_free((uchar*) share->name, MYF(0)); + my_free((uchar*) share, MYF(0)); return; } diff --git a/storage/heap/hp_delete.c b/storage/heap/hp_delete.c index 637e5f1a497..1dd79a42e0b 100644 --- a/storage/heap/hp_delete.c +++ b/storage/heap/hp_delete.c @@ -17,9 +17,9 @@ #include "heapdef.h" -int heap_delete(HP_INFO *info, const byte *record) +int heap_delete(HP_INFO *info, const uchar *record) { - byte *pos; + uchar *pos; HP_SHARE *share=info->s; HP_KEYDEF *keydef, *end, *p_lastinx; DBUG_ENTER("heap_delete"); @@ -43,7 +43,7 @@ int heap_delete(HP_INFO *info, const byte *record) } info->update=HA_STATE_DELETED; - *((byte**) pos)=share->del_link; + *((uchar**) pos)=share->del_link; share->del_link=pos; pos[share->reclength]=0; /* Record deleted */ share->deleted++; @@ -65,7 +65,7 @@ err: */ int hp_rb_delete_key(HP_INFO *info, register HP_KEYDEF *keyinfo, - const byte *record, byte *recpos, int flag) + const uchar *record, uchar *recpos, int flag) { heap_rb_param custom_arg; uint old_allocated; @@ -105,7 +105,7 @@ int hp_rb_delete_key(HP_INFO *info, register HP_KEYDEF *keyinfo, */ int hp_delete_key(HP_INFO *info, register HP_KEYDEF *keyinfo, - const byte *record, byte *recpos, int flag) + const uchar *record, uchar *recpos, int flag) { ulong blength,pos2,pos_hashnr,lastpos_hashnr; HASH_INFO *lastpos,*gpos,*pos,*pos3,*empty,*last_ptr; diff --git a/storage/heap/hp_hash.c b/storage/heap/hp_hash.c index 5ee0168d4b4..aaaa0fe833f 100644 --- a/storage/heap/hp_hash.c +++ b/storage/heap/hp_hash.c @@ -97,7 +97,7 @@ ha_rows hp_rb_records_in_range(HP_INFO *info, int inx, key_range *min_key, /* Sets info->current_ptr to found record */ /* next_flag: Search=0, next=1, prev =2, same =3 */ -byte *hp_search(HP_INFO *info, HP_KEYDEF *keyinfo, const byte *key, +uchar *hp_search(HP_INFO *info, HP_KEYDEF *keyinfo, const uchar *key, uint nextflag) { reg1 HASH_INFO *pos,*prev_ptr; @@ -175,7 +175,7 @@ byte *hp_search(HP_INFO *info, HP_KEYDEF *keyinfo, const byte *key, since last read ! */ -byte *hp_search_next(HP_INFO *info, HP_KEYDEF *keyinfo, const byte *key, +uchar *hp_search_next(HP_INFO *info, HP_KEYDEF *keyinfo, const uchar *key, HASH_INFO *pos) { DBUG_ENTER("hp_search_next"); @@ -238,7 +238,7 @@ void hp_movelink(HASH_INFO *pos, HASH_INFO *next_link, HASH_INFO *newlink) /* Calc hashvalue for a key */ -ulong hp_hashnr(register HP_KEYDEF *keydef, register const byte *key) +ulong hp_hashnr(register HP_KEYDEF *keydef, register const uchar *key) { /*register*/ ulong nr=1, nr2=4; @@ -304,7 +304,7 @@ ulong hp_hashnr(register HP_KEYDEF *keydef, register const byte *key) /* Calc hashvalue for a key in a record */ -ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec) +ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const uchar *rec) { ulong nr=1, nr2=4; HA_KEYSEG *seg,*endseg; @@ -377,7 +377,7 @@ ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec) * far, and works well on both numbers and strings. */ -ulong hp_hashnr(register HP_KEYDEF *keydef, register const byte *key) +ulong hp_hashnr(register HP_KEYDEF *keydef, register const uchar *key) { /* Note, if a key consists of a combination of numeric and @@ -433,7 +433,7 @@ ulong hp_hashnr(register HP_KEYDEF *keydef, register const byte *key) /* Calc hashvalue for a key in a record */ -ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec) +ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const uchar *rec) { ulong nr= 1, nr2= 4; HA_KEYSEG *seg,*endseg; @@ -499,7 +499,7 @@ ulong hp_rec_hashnr(register HP_KEYDEF *keydef, register const byte *rec) <> 0 Key differes */ -int hp_rec_key_cmp(HP_KEYDEF *keydef, const byte *rec1, const byte *rec2, +int hp_rec_key_cmp(HP_KEYDEF *keydef, const uchar *rec1, const uchar *rec2, my_bool diff_if_only_endspace_difference) { HA_KEYSEG *seg,*endseg; @@ -586,7 +586,7 @@ int hp_rec_key_cmp(HP_KEYDEF *keydef, const byte *rec1, const byte *rec2, /* Compare a key in a record to a whole key */ -int hp_key_cmp(HP_KEYDEF *keydef, const byte *rec, const byte *key) +int hp_key_cmp(HP_KEYDEF *keydef, const uchar *rec, const uchar *key) { HA_KEYSEG *seg,*endseg; @@ -670,7 +670,7 @@ int hp_key_cmp(HP_KEYDEF *keydef, const byte *rec, const byte *key) /* Copy a key from a record to a keybuffer */ -void hp_make_key(HP_KEYDEF *keydef, byte *key, const byte *rec) +void hp_make_key(HP_KEYDEF *keydef, uchar *key, const uchar *rec) { HA_KEYSEG *seg,*endseg; @@ -702,10 +702,10 @@ void hp_make_key(HP_KEYDEF *keydef, byte *key, const byte *rec) } while(0) -uint hp_rb_make_key(HP_KEYDEF *keydef, byte *key, - const byte *rec, byte *recpos) +uint hp_rb_make_key(HP_KEYDEF *keydef, uchar *key, + const uchar *rec, uchar *recpos) { - byte *start_key= key; + uchar *start_key= key; HA_KEYSEG *seg, *endseg; for (seg= keydef->seg, endseg= seg + keydef->keysegs; seg < endseg; seg++) @@ -719,7 +719,7 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, byte *key, if (seg->flag & HA_SWAP_KEY) { uint length= seg->length; - byte *pos= (byte*) rec + seg->start; + uchar *pos= (uchar*) rec + seg->start; #ifdef HAVE_ISNAN if (seg->type == HA_KEYTYPE_FLOAT) @@ -768,7 +768,7 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, byte *key, set_if_smaller(length,tmp_length); FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); - memcpy((byte*) key,(byte*) pos,(size_t) char_length); + memcpy((uchar*) key,(uchar*) pos,(size_t) char_length); key+= char_length; continue; } @@ -787,7 +787,7 @@ uint hp_rb_make_key(HP_KEYDEF *keydef, byte *key, memcpy(key, rec + seg->start, (size_t) char_length); key+= seg->length; } - memcpy(key, &recpos, sizeof(byte*)); + memcpy(key, &recpos, sizeof(uchar*)); return (uint) (key - start_key); } @@ -811,7 +811,7 @@ uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old, if (seg->flag & HA_SWAP_KEY) { uint length= seg->length; - byte *pos= (byte*) old + length; + uchar *pos= (uchar*) old + length; while (length--) { @@ -831,7 +831,7 @@ uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old, set_if_smaller(length,tmp_length); /* Safety */ FIX_LENGTH(cs, old, length, char_length); store_key_length_inc(key,char_length); - memcpy((byte*) key, old,(size_t) char_length); + memcpy((uchar*) key, old,(size_t) char_length); key+= char_length; continue; } @@ -853,15 +853,15 @@ uint hp_rb_pack_key(HP_KEYDEF *keydef, uchar *key, const uchar *old, uint hp_rb_key_length(HP_KEYDEF *keydef, - const byte *key __attribute__((unused))) + const uchar *key __attribute__((unused))) { return keydef->length; } -uint hp_rb_null_key_length(HP_KEYDEF *keydef, const byte *key) +uint hp_rb_null_key_length(HP_KEYDEF *keydef, const uchar *key) { - const byte *start_key= key; + const uchar *start_key= key; HA_KEYSEG *seg, *endseg; for (seg= keydef->seg, endseg= seg + keydef->keysegs; seg < endseg; seg++) @@ -874,9 +874,9 @@ uint hp_rb_null_key_length(HP_KEYDEF *keydef, const byte *key) } -uint hp_rb_var_key_length(HP_KEYDEF *keydef, const byte *key) +uint hp_rb_var_key_length(HP_KEYDEF *keydef, const uchar *key) { - const byte *start_key= key; + const uchar *start_key= key; HA_KEYSEG *seg, *endseg; for (seg= keydef->seg, endseg= seg + keydef->keysegs; seg < endseg; seg++) @@ -901,7 +901,7 @@ uint hp_rb_var_key_length(HP_KEYDEF *keydef, const byte *key) 0 otherwise */ -my_bool hp_if_null_in_key(HP_KEYDEF *keydef, const byte *record) +my_bool hp_if_null_in_key(HP_KEYDEF *keydef, const uchar *record) { HA_KEYSEG *seg,*endseg; for (seg=keydef->seg,endseg=seg+keydef->keysegs ; seg < endseg ; seg++) @@ -927,7 +927,7 @@ my_bool hp_if_null_in_key(HP_KEYDEF *keydef, const byte *record) less than zero. */ -void heap_update_auto_increment(HP_INFO *info, const byte *record) +void heap_update_auto_increment(HP_INFO *info, const uchar *record) { ulonglong value= 0; /* Store unsigned values here */ longlong s_value= 0; /* Store signed values here */ diff --git a/storage/heap/hp_info.c b/storage/heap/hp_info.c index 2c58604eed1..ea78c53fd40 100644 --- a/storage/heap/hp_info.c +++ b/storage/heap/hp_info.c @@ -18,7 +18,7 @@ #include "heapdef.h" -byte *heap_position(HP_INFO *info) +uchar *heap_position(HP_INFO *info) { return ((info->update & HA_STATE_AKTIV) ? info->current_ptr : (HEAP_PTR) 0); diff --git a/storage/heap/hp_open.c b/storage/heap/hp_open.c index 02a8d4f95ca..d252704a11b 100644 --- a/storage/heap/hp_open.c +++ b/storage/heap/hp_open.c @@ -51,8 +51,8 @@ HP_INFO *heap_open(const char *name, int mode) pthread_mutex_unlock(&THR_LOCK_heap); info->s= share; - info->lastkey= (byte*) (info + 1); - info->recbuf= (byte*) (info->lastkey + share->max_key_length); + info->lastkey= (uchar*) (info + 1); + info->recbuf= (uchar*) (info->lastkey + share->max_key_length); info->mode= mode; info->current_record= (ulong) ~0L; /* No current record */ info->current_ptr= 0; diff --git a/storage/heap/hp_rfirst.c b/storage/heap/hp_rfirst.c index d1842949421..48c1e625bd8 100644 --- a/storage/heap/hp_rfirst.c +++ b/storage/heap/hp_rfirst.c @@ -17,7 +17,7 @@ /* Read first record with the current key */ -int heap_rfirst(HP_INFO *info, byte *record, int inx) +int heap_rfirst(HP_INFO *info, uchar *record, int inx) { HP_SHARE *share = info->s; HP_KEYDEF *keyinfo = share->keydef + inx; @@ -26,13 +26,13 @@ int heap_rfirst(HP_INFO *info, byte *record, int inx) info->lastinx= inx; if (keyinfo->algorithm == HA_KEY_ALG_BTREE) { - byte *pos; + uchar *pos; if ((pos = tree_search_edge(&keyinfo->rb_tree, info->parents, &info->last_pos, offsetof(TREE_ELEMENT, left)))) { memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), - sizeof(byte*)); + sizeof(uchar*)); info->current_ptr = pos; memcpy(record, pos, (size_t)share->reclength); info->update = HA_STATE_AKTIV; diff --git a/storage/heap/hp_rkey.c b/storage/heap/hp_rkey.c index ced81985f99..6eeac6acd7b 100644 --- a/storage/heap/hp_rkey.c +++ b/storage/heap/hp_rkey.c @@ -15,10 +15,10 @@ #include "heapdef.h" -int heap_rkey(HP_INFO *info, byte *record, int inx, const byte *key, +int heap_rkey(HP_INFO *info, uchar *record, int inx, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag) { - byte *pos; + uchar *pos; HP_SHARE *share= info->s; HP_KEYDEF *keyinfo= share->keydef + inx; DBUG_ENTER("heap_rkey"); @@ -53,7 +53,7 @@ int heap_rkey(HP_INFO *info, byte *record, int inx, const byte *key, info->update= 0; DBUG_RETURN(my_errno= HA_ERR_KEY_NOT_FOUND); } - memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), sizeof(byte*)); + memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), sizeof(uchar*)); info->current_ptr= pos; } else @@ -74,7 +74,7 @@ int heap_rkey(HP_INFO *info, byte *record, int inx, const byte *key, /* Quick find of record */ -gptr heap_find(HP_INFO *info, int inx, const byte *key) +uchar* heap_find(HP_INFO *info, int inx, const uchar *key) { return hp_search(info, info->s->keydef + inx, key, 0); } diff --git a/storage/heap/hp_rlast.c b/storage/heap/hp_rlast.c index b72e815147f..45ad7c21f49 100644 --- a/storage/heap/hp_rlast.c +++ b/storage/heap/hp_rlast.c @@ -18,7 +18,7 @@ /* Read first record with the current key */ -int heap_rlast(HP_INFO *info, byte *record, int inx) +int heap_rlast(HP_INFO *info, uchar *record, int inx) { HP_SHARE *share= info->s; HP_KEYDEF *keyinfo= share->keydef + inx; @@ -27,13 +27,13 @@ int heap_rlast(HP_INFO *info, byte *record, int inx) info->lastinx= inx; if (keyinfo->algorithm == HA_KEY_ALG_BTREE) { - byte *pos; + uchar *pos; if ((pos = tree_search_edge(&keyinfo->rb_tree, info->parents, &info->last_pos, offsetof(TREE_ELEMENT, right)))) { memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), - sizeof(byte*)); + sizeof(uchar*)); info->current_ptr = pos; memcpy(record, pos, (size_t)share->reclength); info->update = HA_STATE_AKTIV; diff --git a/storage/heap/hp_rnext.c b/storage/heap/hp_rnext.c index 3b436fe87aa..262754e9e64 100644 --- a/storage/heap/hp_rnext.c +++ b/storage/heap/hp_rnext.c @@ -17,9 +17,9 @@ /* Read next record with the same key */ -int heap_rnext(HP_INFO *info, byte *record) +int heap_rnext(HP_INFO *info, uchar *record) { - byte *pos; + uchar *pos; HP_SHARE *share=info->s; HP_KEYDEF *keyinfo; DBUG_ENTER("heap_rnext"); @@ -47,7 +47,7 @@ int heap_rnext(HP_INFO *info, byte *record) if (pos) { memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), - sizeof(byte*)); + sizeof(uchar*)); info->current_ptr = pos; } else diff --git a/storage/heap/hp_rprev.c b/storage/heap/hp_rprev.c index bfdd2f9d47a..63bfffffba9 100644 --- a/storage/heap/hp_rprev.c +++ b/storage/heap/hp_rprev.c @@ -18,9 +18,9 @@ /* Read prev record for key */ -int heap_rprev(HP_INFO *info, byte *record) +int heap_rprev(HP_INFO *info, uchar *record) { - byte *pos; + uchar *pos; HP_SHARE *share=info->s; HP_KEYDEF *keyinfo; DBUG_ENTER("heap_rprev"); @@ -47,7 +47,7 @@ int heap_rprev(HP_INFO *info, byte *record) if (pos) { memcpy(&pos, pos + (*keyinfo->get_key_length)(keyinfo, pos), - sizeof(byte*)); + sizeof(uchar*)); info->current_ptr = pos; } else diff --git a/storage/heap/hp_rrnd.c b/storage/heap/hp_rrnd.c index ad0190cc00c..3ac23d293f2 100644 --- a/storage/heap/hp_rrnd.c +++ b/storage/heap/hp_rrnd.c @@ -24,7 +24,7 @@ HA_ERR_END_OF_FILE = EOF. */ -int heap_rrnd(register HP_INFO *info, byte *record, byte *pos) +int heap_rrnd(register HP_INFO *info, uchar *record, uchar *pos) { HP_SHARE *share=info->s; DBUG_ENTER("heap_rrnd"); @@ -59,7 +59,7 @@ int heap_rrnd(register HP_INFO *info, byte *record, byte *pos) HA_ERR_END_OF_FILE = EOF. */ -int heap_rrnd_old(register HP_INFO *info, byte *record, ulong pos) +int heap_rrnd_old(register HP_INFO *info, uchar *record, ulong pos) { HP_SHARE *share=info->s; DBUG_ENTER("heap_rrnd"); diff --git a/storage/heap/hp_rsame.c b/storage/heap/hp_rsame.c index 10513f91726..1a3724672b6 100644 --- a/storage/heap/hp_rsame.c +++ b/storage/heap/hp_rsame.c @@ -25,7 +25,7 @@ HA_ERR_KEY_NOT_FOUND = Record not found with key */ -int heap_rsame(register HP_INFO *info, byte *record, int inx) +int heap_rsame(register HP_INFO *info, uchar *record, int inx) { HP_SHARE *share=info->s; DBUG_ENTER("heap_rsame"); diff --git a/storage/heap/hp_scan.c b/storage/heap/hp_scan.c index 4249ac4148a..e8913e92c86 100644 --- a/storage/heap/hp_scan.c +++ b/storage/heap/hp_scan.c @@ -34,7 +34,7 @@ int heap_scan_init(register HP_INFO *info) DBUG_RETURN(0); } -int heap_scan(register HP_INFO *info, byte *record) +int heap_scan(register HP_INFO *info, uchar *record) { HP_SHARE *share=info->s; ulong pos; diff --git a/storage/heap/hp_test1.c b/storage/heap/hp_test1.c index 31c9b8f2f30..aad5677db69 100644 --- a/storage/heap/hp_test1.c +++ b/storage/heap/hp_test1.c @@ -55,7 +55,7 @@ int main(int argc, char **argv) keyinfo[0].flag = HA_NOSAME; deleted=0; - bzero((gptr) flags,sizeof(flags)); + bzero((uchar*) flags,sizeof(flags)); printf("- Creating heap-file\n"); if (heap_create(filename,1,keyinfo,30,(ulong) flag*100000L,10L, diff --git a/storage/heap/hp_test2.c b/storage/heap/hp_test2.c index dcca5fb44b9..46b1fd61d46 100644 --- a/storage/heap/hp_test2.c +++ b/storage/heap/hp_test2.c @@ -42,7 +42,7 @@ static my_bool key3[MAX_RECORDS]; static int reclength=39; -static int calc_check(byte *buf,uint length); +static int calc_check(uchar *buf,uint length); static void make_record(char *record, uint n1, uint n2, uint n3, const char *mark, uint count); @@ -674,7 +674,7 @@ static sig_handler endprog(int sig_number __attribute__((unused))) } } -static int calc_check(byte *buf, uint length) +static int calc_check(uchar *buf, uint length) { int check=0; while (length--) diff --git a/storage/heap/hp_update.c b/storage/heap/hp_update.c index e7314e3d38c..11dca974ad4 100644 --- a/storage/heap/hp_update.c +++ b/storage/heap/hp_update.c @@ -17,10 +17,10 @@ #include "heapdef.h" -int heap_update(HP_INFO *info, const byte *old, const byte *heap_new) +int heap_update(HP_INFO *info, const uchar *old, const uchar *heap_new) { HP_KEYDEF *keydef, *end, *p_lastinx; - byte *pos; + uchar *pos; bool auto_key_changed= 0; HP_SHARE *share= info->s; DBUG_ENTER("heap_update"); diff --git a/storage/heap/hp_write.c b/storage/heap/hp_write.c index 19215fcf017..2abef2d9b43 100644 --- a/storage/heap/hp_write.c +++ b/storage/heap/hp_write.c @@ -25,14 +25,14 @@ #define HIGHFIND 4 #define HIGHUSED 8 -static byte *next_free_record_pos(HP_SHARE *info); +static uchar *next_free_record_pos(HP_SHARE *info); static HASH_INFO *hp_find_free_hash(HP_SHARE *info, HP_BLOCK *block, ulong records); -int heap_write(HP_INFO *info, const byte *record) +int heap_write(HP_INFO *info, const uchar *record) { HP_KEYDEF *keydef, *end; - byte *pos; + uchar *pos; HP_SHARE *share=info->s; DBUG_ENTER("heap_write"); #ifndef DBUG_OFF @@ -88,7 +88,7 @@ err: } share->deleted++; - *((byte**) pos)=share->del_link; + *((uchar**) pos)=share->del_link; share->del_link=pos; pos[share->reclength]=0; /* Record deleted */ @@ -99,8 +99,8 @@ err: Write a key to rb_tree-index */ -int hp_rb_write_key(HP_INFO *info, HP_KEYDEF *keyinfo, const byte *record, - byte *recpos) +int hp_rb_write_key(HP_INFO *info, HP_KEYDEF *keyinfo, const uchar *record, + uchar *recpos) { heap_rb_param custom_arg; uint old_allocated; @@ -130,17 +130,17 @@ int hp_rb_write_key(HP_INFO *info, HP_KEYDEF *keyinfo, const byte *record, /* Find where to place new record */ -static byte *next_free_record_pos(HP_SHARE *info) +static uchar *next_free_record_pos(HP_SHARE *info) { int block_pos; - byte *pos; - ulong length; + uchar *pos; + size_t length; DBUG_ENTER("next_free_record_pos"); if (info->del_link) { pos=info->del_link; - info->del_link= *((byte**) pos); + info->del_link= *((uchar**) pos); info->deleted--; DBUG_PRINT("exit",("Used old position: 0x%lx",(long) pos)); DBUG_RETURN(pos); @@ -158,9 +158,9 @@ static byte *next_free_record_pos(HP_SHARE *info) info->data_length+=length; } DBUG_PRINT("exit",("Used new position: 0x%lx", - (long) ((byte*) info->block.level_info[0].last_blocks+ + (long) ((uchar*) info->block.level_info[0].last_blocks+ block_pos * info->block.recbuffer))); - DBUG_RETURN((byte*) info->block.level_info[0].last_blocks+ + DBUG_RETURN((uchar*) info->block.level_info[0].last_blocks+ block_pos*info->block.recbuffer); } @@ -191,12 +191,12 @@ static byte *next_free_record_pos(HP_SHARE *info) */ int hp_write_key(HP_INFO *info, HP_KEYDEF *keyinfo, - const byte *record, byte *recpos) + const uchar *record, uchar *recpos) { HP_SHARE *share = info->s; int flag; ulong halfbuff,hashnr,first_index; - byte *ptr_to_rec,*ptr_to_rec2; + uchar *ptr_to_rec,*ptr_to_rec2; HASH_INFO *empty,*gpos,*gpos2,*pos; DBUG_ENTER("hp_write_key"); @@ -390,7 +390,7 @@ static HASH_INFO *hp_find_free_hash(HP_SHARE *info, HP_BLOCK *block, ulong records) { uint block_pos; - ulong length; + size_t length; if (records < block->last_allocated) return hp_find_hash(block,records); @@ -401,6 +401,6 @@ static HASH_INFO *hp_find_free_hash(HP_SHARE *info, info->index_length+=length; } block->last_allocated=records+1; - return((HASH_INFO*) ((byte*) block->level_info[0].last_blocks+ + return((HASH_INFO*) ((uchar*) block->level_info[0].last_blocks+ block_pos*block->recbuffer)); } diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc index 30226fc6eb9..86cd7a758a9 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -60,7 +60,7 @@ static handlerton *innodb_hton_ptr; uses unsigned char; the header univ.i which we include next defines 'byte' as a macro which expands to 'unsigned char' */ -typedef byte mysql_byte; +typedef uchar mysql_byte; #define INSIDE_HA_INNOBASE_CC @@ -156,7 +156,7 @@ static HASH innobase_open_tables; bool nw_panic = FALSE; #endif -static mysql_byte* innobase_get_key(INNOBASE_SHARE *share,uint *length, +static mysql_byte* innobase_get_key(INNOBASE_SHARE *share, size_t *length, my_bool not_used __attribute__((unused))); static INNOBASE_SHARE *get_share(const char *table_name); static void free_share(INNOBASE_SHARE *share); @@ -693,12 +693,12 @@ innobase_mysql_print_thd( use the default max length */ { THD* thd; - char buffer[1024]; + char buffer[1024]; - thd = (THD*) input_thd; - fputs(thd_security_context(thd, buffer, sizeof(buffer), + thd = (THD*) input_thd; + fputs(thd_security_context(thd, buffer, sizeof(buffer), max_query_len), f); - putc('\n', f); + putc('\n', f); } /********************************************************************** @@ -1252,12 +1252,12 @@ innobase_print_identifier( output strings buffers must not be shared. The function only produces more output when the name contains other characters than [0-9A-Z_a-z]. */ - char* temp_name = my_malloc((uint) namelen + 1, MYF(MY_WME)); + char* temp_name = (char*) my_malloc((uint) namelen + 1, MYF(MY_WME)); uint qnamelen = (uint) (namelen + (1 + sizeof srv_mysql50_table_name_prefix)); if (temp_name) { - qname = my_malloc(qnamelen, MYF(MY_WME)); + qname = (char*) my_malloc(qnamelen, MYF(MY_WME)); if (qname) { memcpy(temp_name, name, namelen); temp_name[namelen] = 0; @@ -2395,7 +2395,7 @@ ha_innobase::open( "how you can resolve the problem.\n", norm_name); free_share(share); - my_free((gptr) upd_buff, MYF(0)); + my_free(upd_buff, MYF(0)); my_errno = ENOENT; DBUG_RETURN(HA_ERR_NO_SUCH_TABLE); @@ -2412,7 +2412,7 @@ ha_innobase::open( "how you can resolve the problem.\n", norm_name); free_share(share); - my_free((gptr) upd_buff, MYF(0)); + my_free(upd_buff, MYF(0)); my_errno = ENOENT; dict_table_decrement_handle_count(ib_table); @@ -2511,7 +2511,7 @@ ha_innobase::close(void) row_prebuilt_free(prebuilt); - my_free((gptr) upd_buff, MYF(0)); + my_free(upd_buff, MYF(0)); free_share(share); /* Tell InnoDB server that there might be work for @@ -2534,7 +2534,7 @@ get_field_offset( TABLE* table, /* in: MySQL table object */ Field* field) /* in: MySQL field object */ { - return((uint) (field->ptr - (char*) table->record[0])); + return((uint) (field->ptr - table->record[0])); } /****************************************************************** @@ -4388,7 +4388,7 @@ ha_innobase::rnd_pos( int error; uint keynr = active_index; DBUG_ENTER("rnd_pos"); - DBUG_DUMP("key", (char*) pos, ref_length); + DBUG_DUMP("key", pos, ref_length); ha_statistic_increment(&SSV::ha_read_rnd_count); @@ -4697,7 +4697,7 @@ create_index( error = convert_error_code_to_mysql(error, NULL); - my_free((gptr) field_lengths, MYF(0)); + my_free(field_lengths, MYF(0)); DBUG_RETURN(error); } @@ -5130,7 +5130,7 @@ innobase_drop_database( } ptr++; - namebuf = my_malloc((uint) len + 2, MYF(0)); + namebuf = (char*) my_malloc((uint) len + 2, MYF(0)); memcpy(namebuf, ptr, len); namebuf[len] = '/'; @@ -5327,7 +5327,7 @@ ha_innobase::records_in_range( dtuple_free_for_mysql(heap1); dtuple_free_for_mysql(heap2); - my_free((gptr) key_val_buff2, MYF(0)); + my_free(key_val_buff2, MYF(0)); prebuilt->trx->op_info = (char*)""; @@ -5784,7 +5784,7 @@ ha_innobase::update_table_comment( /* allocate buffer for the full string, and read the contents of the temporary file */ - str = my_malloc(length + flen + 3, MYF(0)); + str = (char*) my_malloc(length + flen + 3, MYF(0)); if (str) { char* pos = str + length; @@ -5852,7 +5852,7 @@ ha_innobase::get_foreign_key_create_info(void) /* allocate buffer for the string, and read the contents of the temporary file */ - str = my_malloc(flen + 1, MYF(0)); + str = (char*) my_malloc(flen + 1, MYF(0)); if (str) { rewind(srv_dict_tmpfile); @@ -5984,7 +5984,7 @@ ha_innobase::get_foreign_key_list(THD *thd, List<FOREIGN_KEY_INFO> *f_key_list) } FOREIGN_KEY_INFO *pf_key_info= ((FOREIGN_KEY_INFO *) - thd->memdup((gptr) &f_key_info, + thd->memdup(&f_key_info, sizeof(FOREIGN_KEY_INFO))); f_key_list->push_back(pf_key_info); foreign = UT_LIST_GET_NEXT(foreign_list, foreign); @@ -6521,7 +6521,7 @@ innodb_show_status( /* allocate buffer for the string, and read the contents of the temporary file */ - if (!(str = my_malloc(usable_len + 1, MYF(0)))) { + if (!(str = (char*) my_malloc(usable_len + 1, MYF(0)))) { mutex_exit_noninline(&srv_monitor_file_mutex); DBUG_RETURN(TRUE); } @@ -6682,7 +6682,7 @@ bool innobase_show_status(handlerton *hton, THD* thd, locking. ****************************************************************************/ -static mysql_byte* innobase_get_key(INNOBASE_SHARE* share, uint* length, +static mysql_byte* innobase_get_key(INNOBASE_SHARE* share, size_t *length, my_bool not_used __attribute__((unused))) { *length=share->table_name_length; @@ -6710,7 +6710,7 @@ static INNOBASE_SHARE* get_share(const char* table_name) if (my_hash_insert(&innobase_open_tables, (mysql_byte*) share)) { pthread_mutex_unlock(&innobase_share_mutex); - my_free((gptr) share,0); + my_free(share,0); return 0; } @@ -6733,7 +6733,7 @@ static void free_share(INNOBASE_SHARE* share) hash_delete(&innobase_open_tables, (mysql_byte*) share); thr_lock_delete(&share->lock); pthread_mutex_destroy(&share->mutex); - my_free((gptr) share, MYF(0)); + my_free(share, MYF(0)); } pthread_mutex_unlock(&innobase_share_mutex); @@ -7228,9 +7228,8 @@ ha_innobase::cmp_ref( ref1 += 2; ref2 += 2; - result = ((Field_blob*)field)->cmp( - (const char*)ref1, len1, - (const char*)ref2, len2); + result = ((Field_blob*)field)->cmp( ref1, len1, + ref2, len2); } else { result = field->key_cmp(ref1, ref2); } diff --git a/storage/innobase/handler/ha_innodb.h b/storage/innobase/handler/ha_innodb.h index 90fc7727044..1c864445ac0 100644 --- a/storage/innobase/handler/ha_innodb.h +++ b/storage/innobase/handler/ha_innodb.h @@ -47,8 +47,8 @@ class ha_innobase: public handler THR_LOCK_DATA lock; INNOBASE_SHARE *share; - byte* upd_buff; /* buffer used in updates */ - byte* key_val_buff; /* buffer used in converting + uchar* upd_buff; /* buffer used in updates */ + uchar* key_val_buff; /* buffer used in converting search key values from MySQL format to Innodb format */ ulong upd_and_key_val_buff_len; @@ -65,10 +65,10 @@ class ha_innobase: public handler uint num_write_row; /* number of write_row() calls */ uint store_key_val_for_row(uint keynr, char* buff, uint buff_len, - const byte* record); + const uchar* record); int update_thd(THD* thd); int change_active_index(uint keynr); - int general_fetch(byte* buf, uint direction, uint match_mode); + int general_fetch(uchar* buf, uint direction, uint match_mode); int innobase_read_and_init_auto_inc(longlong* ret); /* Init values for the class: */ @@ -110,32 +110,32 @@ class ha_innobase: public handler double scan_time(); double read_time(uint index, uint ranges, ha_rows rows); - int write_row(byte * buf); - int update_row(const byte * old_data, byte * new_data); - int delete_row(const byte * buf); + int write_row(uchar * buf); + int update_row(const uchar * old_data, uchar * new_data); + int delete_row(const uchar * buf); bool was_semi_consistent_read(); void try_semi_consistent_read(bool yes); void unlock_row(); int index_init(uint index, bool sorted); int index_end(); - int index_read(byte * buf, const byte * key, + int index_read(uchar * buf, const uchar * key, uint key_len, enum ha_rkey_function find_flag); - int index_read_idx(byte * buf, uint index, const byte * key, + int index_read_idx(uchar * buf, uint index, const uchar * key, uint key_len, enum ha_rkey_function find_flag); - int index_read_last(byte * buf, const byte * key, uint key_len); - int index_next(byte * buf); - int index_next_same(byte * buf, const byte *key, uint keylen); - int index_prev(byte * buf); - int index_first(byte * buf); - int index_last(byte * buf); + int index_read_last(uchar * buf, const uchar * key, uint key_len); + int index_next(uchar * buf); + int index_next_same(uchar * buf, const uchar *key, uint keylen); + int index_prev(uchar * buf); + int index_first(uchar * buf); + int index_last(uchar * buf); int rnd_init(bool scan); int rnd_end(); - int rnd_next(byte *buf); - int rnd_pos(byte * buf, byte *pos); + int rnd_next(uchar *buf); + int rnd_pos(uchar * buf, uchar *pos); - void position(const byte *record); + void position(const uchar *record); int info(uint); int analyze(THD* thd,HA_CHECK_OPT* check_opt); int optimize(THD* thd,HA_CHECK_OPT* check_opt); @@ -145,7 +145,7 @@ class ha_innobase: public handler int external_lock(THD *thd, int lock_type); int transactional_table_lock(THD *thd, int lock_type); int start_stmt(THD *thd, thr_lock_type lock_type); - void position(byte *record); + void position(uchar *record); ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key); ha_rows estimate_rows_upper_bound(); @@ -185,7 +185,7 @@ class ha_innobase: public handler static char *get_mysql_bin_log_name(); static ulonglong get_mysql_bin_log_pos(); bool primary_key_is_clustered() { return true; } - int cmp_ref(const byte *ref1, const byte *ref2); + int cmp_ref(const uchar *ref1, const uchar *ref2); bool check_if_incompatible_data(HA_CREATE_INFO *info, uint table_changes); }; diff --git a/storage/myisam/ft_boolean_search.c b/storage/myisam/ft_boolean_search.c index 68076d7e401..bf4c29f5b4e 100644 --- a/storage/myisam/ft_boolean_search.c +++ b/storage/myisam/ft_boolean_search.c @@ -111,7 +111,7 @@ typedef struct st_ftb_word uint ndepth; uint len; uchar off; - byte word[1]; + uchar word[1]; } FTB_WORD; typedef struct st_ft_info @@ -161,7 +161,7 @@ typedef struct st_my_ftb_param { FTB *ftb; FTB_EXPR *ftbe; - byte *up_quot; + uchar *up_quot; uint depth; } MY_FTB_PARAM; @@ -274,7 +274,7 @@ static int ftb_parse_query_internal(MYSQL_FTPARSER_PARAM *param, MY_FTB_PARAM *ftb_param= param->mysql_ftparam; MYSQL_FTPARSER_BOOLEAN_INFO info; CHARSET_INFO *cs= ftb_param->ftb->charset; - char **start= &query; + uchar **start= (uchar**) &query; char *end= query + len; FT_WORD w; @@ -286,7 +286,7 @@ static int ftb_parse_query_internal(MYSQL_FTPARSER_PARAM *param, } -static void _ftb_parse_query(FTB *ftb, byte *query, uint len, +static void _ftb_parse_query(FTB *ftb, uchar *query, uint len, struct st_mysql_ftparser *parser) { MYSQL_FTPARSER_PARAM *param; @@ -331,7 +331,7 @@ static int _ft2_search(FTB *ftb, FTB_WORD *ftbw, my_bool init_search) my_bool can_go_down; MI_INFO *info=ftb->info; uint off, extra=HA_FT_WLEN+info->s->base.rec_reflength; - byte *lastkey_buf=ftbw->word+ftbw->off; + uchar *lastkey_buf=ftbw->word+ftbw->off; LINT_INIT(off); if (ftbw->flags & FTB_FLAG_TRUNC) @@ -505,7 +505,7 @@ static void _ftb_init_index_search(FT_INFO *ftb) } -FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query, +FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, uchar *query, uint query_len, CHARSET_INFO *cs) { FTB *ftb; @@ -545,14 +545,14 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query, Hack: instead of init_queue, we'll use reinit queue to be able to alloc queue with alloc_root() */ - if (! (ftb->queue.root= (byte **)alloc_root(&ftb->mem_root, + if (! (ftb->queue.root= (uchar **)alloc_root(&ftb->mem_root, (ftb->queue.max_elements + 1) * sizeof(void *)))) goto err; reinit_queue(&ftb->queue, ftb->queue.max_elements, 0, 0, - (int (*)(void*, byte*, byte*))FTB_WORD_cmp, 0); + (int (*)(void*, uchar*, uchar*))FTB_WORD_cmp, 0); for (ftbw= ftb->last_word; ftbw; ftbw= ftbw->prev) - queue_insert(&ftb->queue, (byte *)ftbw); + queue_insert(&ftb->queue, (uchar *)ftbw); ftb->list=(FTB_WORD **)alloc_root(&ftb->mem_root, sizeof(FTB_WORD *)*ftb->queue.elements); memcpy(ftb->list, ftb->queue.root+1, sizeof(FTB_WORD *)*ftb->queue.elements); @@ -563,7 +563,7 @@ FT_INFO * ft_init_boolean_search(MI_INFO *info, uint keynr, byte *query, return ftb; err: free_root(& ftb->mem_root, MYF(0)); - my_free((gptr)ftb,MYF(0)); + my_free((uchar*)ftb,MYF(0)); return 0; } @@ -617,7 +617,8 @@ static int ftb_check_phrase_internal(MYSQL_FTPARSER_PARAM *param, FT_WORD word; MY_FTB_PHRASE_PARAM *phrase_param= param->mysql_ftparam; const char *docend= document + len; - while (ft_simple_get_word(phrase_param->cs, &document, docend, &word, FALSE)) + while (ft_simple_get_word(phrase_param->cs, (uchar**) &document, docend, + &word, FALSE)) { param->mysql_add_word(param, word.pos, word.len, 0); if (phrase_param->match) @@ -641,7 +642,7 @@ static int ftb_check_phrase_internal(MYSQL_FTPARSER_PARAM *param, 1 is returned if phrase found, 0 else. */ -static int _ftb_check_phrase(FTB *ftb, const byte *document, uint len, +static int _ftb_check_phrase(FTB *ftb, const uchar *document, uint len, FTB_EXPR *ftbe, struct st_mysql_ftparser *parser) { MY_FTB_PHRASE_PARAM ftb_param; @@ -663,7 +664,7 @@ static int _ftb_check_phrase(FTB *ftb, const byte *document, uint len, param->mysql_add_word= ftb_phrase_add_word; param->mysql_ftparam= (void *)&ftb_param; param->cs= ftb->charset; - param->doc= (byte *)document; + param->doc= (uchar *)document; param->length= len; param->flags= 0; param->mode= MYSQL_FTPARSER_WITH_STOPWORDS; @@ -867,13 +868,13 @@ static int ftb_find_relevance_parse(MYSQL_FTPARSER_PARAM *param, FT_INFO *ftb= ftb_param->ftb; char *end= doc + len; FT_WORD w; - while (ft_simple_get_word(ftb->charset, &doc, end, &w, TRUE)) + while (ft_simple_get_word(ftb->charset, (uchar**) &doc, end, &w, TRUE)) param->mysql_add_word(param, w.pos, w.len, 0); return(0); } -float ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length) +float ft_boolean_find_relevance(FT_INFO *ftb, uchar *record, uint length) { FTB_EXPR *ftbe; FT_SEG_ITERATOR ftsi, ftsi2; @@ -924,7 +925,7 @@ float ft_boolean_find_relevance(FT_INFO *ftb, byte *record, uint length) { if (!ftsi.pos) continue; - param->doc= (byte *)ftsi.pos; + param->doc= (uchar *)ftsi.pos; param->length= ftsi.len; parser->parse(param); } @@ -948,7 +949,7 @@ void ft_boolean_close_search(FT_INFO *ftb) delete_tree(& ftb->no_dupes); } free_root(& ftb->mem_root, MYF(0)); - my_free((gptr)ftb,MYF(0)); + my_free((uchar*)ftb,MYF(0)); } diff --git a/storage/myisam/ft_nlq_search.c b/storage/myisam/ft_nlq_search.c index 5c6f66897ee..bcf6c46d41f 100644 --- a/storage/myisam/ft_nlq_search.c +++ b/storage/myisam/ft_nlq_search.c @@ -189,7 +189,7 @@ static int walk_and_push(FT_SUPERDOC *from, DBUG_ENTER("walk_and_copy"); from->doc.weight+=from->tmp_weight*from->word_ptr->weight; set_if_smaller(best->elements, ft_query_expansion_limit-1); - queue_insert(best, (byte *)& from->doc); + queue_insert(best, (uchar *)& from->doc); DBUG_RETURN(0); } @@ -201,8 +201,8 @@ static int FT_DOC_cmp(void *unused __attribute__((unused)), } -FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, byte *query, - uint query_len, uint flags, byte *record) +FT_INFO *ft_init_nlq_search(MI_INFO *info, uint keynr, uchar *query, + uint query_len, uint flags, uchar *record) { TREE wtree; ALL_IN_ONE aio; @@ -323,7 +323,7 @@ int ft_nlq_read_next(FT_INFO *handler, char *record) float ft_nlq_find_relevance(FT_INFO *handler, - byte *record __attribute__((unused)), + uchar *record __attribute__((unused)), uint length __attribute__((unused))) { int a,b,c; @@ -352,7 +352,7 @@ float ft_nlq_find_relevance(FT_INFO *handler, void ft_nlq_close_search(FT_INFO *handler) { - my_free((gptr)handler,MYF(0)); + my_free((uchar*)handler,MYF(0)); } diff --git a/storage/myisam/ft_parser.c b/storage/myisam/ft_parser.c index 5992d9c118e..ba858c37aee 100644 --- a/storage/myisam/ft_parser.c +++ b/storage/myisam/ft_parser.c @@ -78,7 +78,7 @@ FT_WORD * ft_linearize(TREE *wtree, MEM_ROOT *mem_root) DBUG_RETURN(wlist); } -my_bool ft_boolean_check_syntax_string(const byte *str) +my_bool ft_boolean_check_syntax_string(const uchar *str) { uint i, j; @@ -106,10 +106,10 @@ my_bool ft_boolean_check_syntax_string(const byte *str) 3 - right bracket 4 - stopword found */ -byte ft_get_word(CHARSET_INFO *cs, byte **start, byte *end, - FT_WORD *word, MYSQL_FTPARSER_BOOLEAN_INFO *param) +uchar ft_get_word(CHARSET_INFO *cs, uchar **start, uchar *end, + FT_WORD *word, MYSQL_FTPARSER_BOOLEAN_INFO *param) { - byte *doc=*start; + uchar *doc=*start; int ctype; uint mwc, length, mbl; @@ -196,10 +196,10 @@ ret: return param->type; } -byte ft_simple_get_word(CHARSET_INFO *cs, byte **start, const byte *end, - FT_WORD *word, my_bool skip_stopwords) +uchar ft_simple_get_word(CHARSET_INFO *cs, uchar **start, const uchar *end, + FT_WORD *word, my_bool skip_stopwords) { - byte *doc= *start; + uchar *doc= *start; uint mwc, length, mbl; int ctype; DBUG_ENTER("ft_simple_get_word"); @@ -260,9 +260,9 @@ static int ft_add_word(MYSQL_FTPARSER_PARAM *param, wtree= ft_param->wtree; if (param->flags & MYSQL_FTFLAGS_NEED_COPY) { - byte *ptr; + uchar *ptr; DBUG_ASSERT(wtree->with_delete == 0); - ptr= (byte *)alloc_root(ft_param->mem_root, word_len); + ptr= (uchar *)alloc_root(ft_param->mem_root, word_len); memcpy(ptr, word, word_len); w.pos= ptr; } @@ -279,9 +279,10 @@ static int ft_add_word(MYSQL_FTPARSER_PARAM *param, static int ft_parse_internal(MYSQL_FTPARSER_PARAM *param, - char *doc, int doc_len) + char *doc_arg, int doc_len) { - byte *end=doc+doc_len; + uchar *doc= (uchar*) doc_arg; + uchar *end= doc + doc_len; MY_FT_PARSER_PARAM *ft_param=param->mysql_ftparam; TREE *wtree= ft_param->wtree; FT_WORD w; @@ -294,9 +295,9 @@ static int ft_parse_internal(MYSQL_FTPARSER_PARAM *param, } -int ft_parse(TREE *wtree, byte *doc, int doclen, - struct st_mysql_ftparser *parser, - MYSQL_FTPARSER_PARAM *param, MEM_ROOT *mem_root) +int ft_parse(TREE *wtree, uchar *doc, int doclen, + struct st_mysql_ftparser *parser, + MYSQL_FTPARSER_PARAM *param, MEM_ROOT *mem_root) { MY_FT_PARSER_PARAM my_param; DBUG_ENTER("ft_parse"); diff --git a/storage/myisam/ft_static.c b/storage/myisam/ft_static.c index 34608be1721..610c20eede6 100644 --- a/storage/myisam/ft_static.c +++ b/storage/myisam/ft_static.c @@ -56,8 +56,8 @@ const struct _ft_vft _ft_vft_boolean = { FT_INFO *ft_init_search(uint flags, void *info, uint keynr, - byte *query, uint query_len, CHARSET_INFO *cs, - byte *record) + uchar *query, uint query_len, CHARSET_INFO *cs, + uchar *record) { FT_INFO *res; if (flags & FT_BOOL) diff --git a/storage/myisam/ft_stopwords.c b/storage/myisam/ft_stopwords.c index 63732ebadc9..e6a90bc927a 100644 --- a/storage/myisam/ft_stopwords.c +++ b/storage/myisam/ft_stopwords.c @@ -38,7 +38,7 @@ static void FT_STOPWORD_free(FT_STOPWORD *w, TREE_FREE action, void *arg __attribute__((unused))) { if (action == free_free) - my_free((gptr) w->pos, MYF(0)); + my_free((uchar*) w->pos, MYF(0)); } static int ft_add_stopword(const char *w) @@ -65,7 +65,7 @@ int ft_init_stopwords() { File fd; uint len; - byte *buffer, *start, *end; + uchar *buffer, *start, *end; FT_WORD w; int error=-1; diff --git a/storage/myisam/ft_update.c b/storage/myisam/ft_update.c index e176d550b1d..e3e4c62158f 100644 --- a/storage/myisam/ft_update.c +++ b/storage/myisam/ft_update.c @@ -20,7 +20,7 @@ #include "ftdefs.h" #include <math.h> -void _mi_ft_segiterator_init(MI_INFO *info, uint keynr, const byte *record, +void _mi_ft_segiterator_init(MI_INFO *info, uint keynr, const uchar *record, FT_SEG_ITERATOR *ftsi) { DBUG_ENTER("_mi_ft_segiterator_init"); @@ -31,7 +31,7 @@ void _mi_ft_segiterator_init(MI_INFO *info, uint keynr, const byte *record, DBUG_VOID_RETURN; } -void _mi_ft_segiterator_dummy_init(const byte *record, uint len, +void _mi_ft_segiterator_dummy_init(const uchar *record, uint len, FT_SEG_ITERATOR *ftsi) { DBUG_ENTER("_mi_ft_segiterator_dummy_init"); @@ -94,7 +94,7 @@ uint _mi_ft_segiterator(register FT_SEG_ITERATOR *ftsi) /* parses a document i.e. calls ft_parse for every keyseg */ -uint _mi_ft_parse(TREE *parsed, MI_INFO *info, uint keynr, const byte *record, +uint _mi_ft_parse(TREE *parsed, MI_INFO *info, uint keynr, const uchar *record, MYSQL_FTPARSER_PARAM *param, MEM_ROOT *mem_root) { FT_SEG_ITERATOR ftsi; @@ -108,13 +108,13 @@ uint _mi_ft_parse(TREE *parsed, MI_INFO *info, uint keynr, const byte *record, while (_mi_ft_segiterator(&ftsi)) { if (ftsi.pos) - if (ft_parse(parsed, (byte *)ftsi.pos, ftsi.len, parser, param, mem_root)) + if (ft_parse(parsed, (uchar *)ftsi.pos, ftsi.len, parser, param, mem_root)) DBUG_RETURN(1); } DBUG_RETURN(0); } -FT_WORD *_mi_ft_parserecord(MI_INFO *info, uint keynr, const byte *record, +FT_WORD *_mi_ft_parserecord(MI_INFO *info, uint keynr, const uchar *record, MEM_ROOT *mem_root) { TREE ptree; @@ -130,7 +130,7 @@ FT_WORD *_mi_ft_parserecord(MI_INFO *info, uint keynr, const byte *record, DBUG_RETURN(ft_linearize(&ptree, mem_root)); } -static int _mi_ft_store(MI_INFO *info, uint keynr, byte *keybuf, +static int _mi_ft_store(MI_INFO *info, uint keynr, uchar *keybuf, FT_WORD *wlist, my_off_t filepos) { uint key_length; @@ -145,7 +145,7 @@ static int _mi_ft_store(MI_INFO *info, uint keynr, byte *keybuf, DBUG_RETURN(0); } -static int _mi_ft_erase(MI_INFO *info, uint keynr, byte *keybuf, +static int _mi_ft_erase(MI_INFO *info, uint keynr, uchar *keybuf, FT_WORD *wlist, my_off_t filepos) { uint key_length, err=0; @@ -168,7 +168,7 @@ static int _mi_ft_erase(MI_INFO *info, uint keynr, byte *keybuf, #define THOSE_TWO_DAMN_KEYS_ARE_REALLY_DIFFERENT 1 #define GEE_THEY_ARE_ABSOLUTELY_IDENTICAL 0 -int _mi_ft_cmp(MI_INFO *info, uint keynr, const byte *rec1, const byte *rec2) +int _mi_ft_cmp(MI_INFO *info, uint keynr, const uchar *rec1, const uchar *rec2) { FT_SEG_ITERATOR ftsi1, ftsi2; CHARSET_INFO *cs=info->s->keyinfo[keynr].seg->charset; @@ -190,8 +190,8 @@ int _mi_ft_cmp(MI_INFO *info, uint keynr, const byte *rec1, const byte *rec2) /* update a document entry */ -int _mi_ft_update(MI_INFO *info, uint keynr, byte *keybuf, - const byte *oldrec, const byte *newrec, my_off_t pos) +int _mi_ft_update(MI_INFO *info, uint keynr, uchar *keybuf, + const uchar *oldrec, const uchar *newrec, my_off_t pos) { int error= -1; FT_WORD *oldlist,*newlist, *old_word, *new_word; @@ -241,7 +241,7 @@ err: /* adds a document to the collection */ -int _mi_ft_add(MI_INFO *info, uint keynr, byte *keybuf, const byte *record, +int _mi_ft_add(MI_INFO *info, uint keynr, uchar *keybuf, const uchar *record, my_off_t pos) { int error= -1; @@ -260,7 +260,7 @@ int _mi_ft_add(MI_INFO *info, uint keynr, byte *keybuf, const byte *record, /* removes a document from the collection */ -int _mi_ft_del(MI_INFO *info, uint keynr, byte *keybuf, const byte *record, +int _mi_ft_del(MI_INFO *info, uint keynr, uchar *keybuf, const uchar *record, my_off_t pos) { int error= -1; @@ -276,10 +276,10 @@ int _mi_ft_del(MI_INFO *info, uint keynr, byte *keybuf, const byte *record, DBUG_RETURN(error); } -uint _ft_make_key(MI_INFO *info, uint keynr, byte *keybuf, FT_WORD *wptr, +uint _ft_make_key(MI_INFO *info, uint keynr, uchar *keybuf, FT_WORD *wptr, my_off_t filepos) { - byte buf[HA_FT_MAXBYTELEN+16]; + uchar buf[HA_FT_MAXBYTELEN+16]; DBUG_ENTER("_ft_make_key"); #if HA_FT_WTYPE == HA_KEYTYPE_FLOAT diff --git a/storage/myisam/ftdefs.h b/storage/myisam/ftdefs.h index 26f5e4f266e..22443807b87 100644 --- a/storage/myisam/ftdefs.h +++ b/storage/myisam/ftdefs.h @@ -96,44 +96,44 @@ #define FTB_RQUOT (ft_boolean_syntax[11]) typedef struct st_ft_word { - byte * pos; + uchar * pos; uint len; double weight; } FT_WORD; int is_stopword(char *word, uint len); -uint _ft_make_key(MI_INFO *, uint , byte *, FT_WORD *, my_off_t); +uint _ft_make_key(MI_INFO *, uint , uchar *, FT_WORD *, my_off_t); -byte ft_get_word(CHARSET_INFO *, byte **, byte *, FT_WORD *, - MYSQL_FTPARSER_BOOLEAN_INFO *); -byte ft_simple_get_word(CHARSET_INFO *, byte **, const byte *, - FT_WORD *, my_bool); +uchar ft_get_word(CHARSET_INFO *, uchar **, uchar *, FT_WORD *, + MYSQL_FTPARSER_BOOLEAN_INFO *); +uchar ft_simple_get_word(CHARSET_INFO *, uchar **, const uchar *, + FT_WORD *, my_bool); typedef struct _st_ft_seg_iterator { uint num, len; HA_KEYSEG *seg; - const byte *rec, *pos; + const uchar *rec, *pos; } FT_SEG_ITERATOR; -void _mi_ft_segiterator_init(MI_INFO *, uint, const byte *, FT_SEG_ITERATOR *); -void _mi_ft_segiterator_dummy_init(const byte *, uint, FT_SEG_ITERATOR *); +void _mi_ft_segiterator_init(MI_INFO *, uint, const uchar *, FT_SEG_ITERATOR *); +void _mi_ft_segiterator_dummy_init(const uchar *, uint, FT_SEG_ITERATOR *); uint _mi_ft_segiterator(FT_SEG_ITERATOR *); void ft_parse_init(TREE *, CHARSET_INFO *); -int ft_parse(TREE *, byte *, int, struct st_mysql_ftparser *parser, +int ft_parse(TREE *, uchar *, int, struct st_mysql_ftparser *parser, MYSQL_FTPARSER_PARAM *, MEM_ROOT *); FT_WORD * ft_linearize(TREE *, MEM_ROOT *); -FT_WORD * _mi_ft_parserecord(MI_INFO *, uint, const byte *, MEM_ROOT *); -uint _mi_ft_parse(TREE *, MI_INFO *, uint, const byte *, +FT_WORD * _mi_ft_parserecord(MI_INFO *, uint, const uchar *, MEM_ROOT *); +uint _mi_ft_parse(TREE *, MI_INFO *, uint, const uchar *, MYSQL_FTPARSER_PARAM *, MEM_ROOT *); -FT_INFO *ft_init_nlq_search(MI_INFO *, uint, byte *, uint, uint, byte *); -FT_INFO *ft_init_boolean_search(MI_INFO *, uint, byte *, uint, CHARSET_INFO *); +FT_INFO *ft_init_nlq_search(MI_INFO *, uint, uchar *, uint, uint, uchar *); +FT_INFO *ft_init_boolean_search(MI_INFO *, uint, uchar *, uint, CHARSET_INFO *); extern const struct _ft_vft _ft_vft_nlq; int ft_nlq_read_next(FT_INFO *, char *); -float ft_nlq_find_relevance(FT_INFO *, byte *, uint); +float ft_nlq_find_relevance(FT_INFO *, uchar *, uint); void ft_nlq_close_search(FT_INFO *); float ft_nlq_get_relevance(FT_INFO *); my_off_t ft_nlq_get_docid(FT_INFO *); @@ -141,7 +141,7 @@ void ft_nlq_reinit_search(FT_INFO *); extern const struct _ft_vft _ft_vft_boolean; int ft_boolean_read_next(FT_INFO *, char *); -float ft_boolean_find_relevance(FT_INFO *, byte *, uint); +float ft_boolean_find_relevance(FT_INFO *, uchar *, uint); void ft_boolean_close_search(FT_INFO *); float ft_boolean_get_relevance(FT_INFO *); my_off_t ft_boolean_get_docid(FT_INFO *); diff --git a/storage/myisam/fulltext.h b/storage/myisam/fulltext.h index bea2fa96969..856e93e034d 100644 --- a/storage/myisam/fulltext.h +++ b/storage/myisam/fulltext.h @@ -29,9 +29,9 @@ extern const HA_KEYSEG ft_keysegs[FT_SEGS]; -int _mi_ft_cmp(MI_INFO *, uint, const byte *, const byte *); -int _mi_ft_add(MI_INFO *, uint, byte *, const byte *, my_off_t); -int _mi_ft_del(MI_INFO *, uint, byte *, const byte *, my_off_t); +int _mi_ft_cmp(MI_INFO *, uint, const uchar *, const uchar *); +int _mi_ft_add(MI_INFO *, uint, uchar *, const uchar *, my_off_t); +int _mi_ft_del(MI_INFO *, uint, uchar *, const uchar *, my_off_t); uint _mi_ft_convert_to_ft2(MI_INFO *, uint, uchar *); diff --git a/storage/myisam/ha_myisam.cc b/storage/myisam/ha_myisam.cc index 56e428b1bc1..8b95cdb30fd 100644 --- a/storage/myisam/ha_myisam.cc +++ b/storage/myisam/ha_myisam.cc @@ -121,7 +121,7 @@ int table2myisam(TABLE *table_arg, MI_KEYDEF **keydef_out, { uint i, j, recpos, minpos, fieldpos, temp_length, length; enum ha_base_keytype type= HA_KEYTYPE_BINARY; - byte *record; + uchar *record; KEY *pos; MI_KEYDEF *keydef; MI_COLUMNDEF *recinfo, *recinfo_pos; @@ -531,7 +531,7 @@ int ha_myisam::net_read_dump(NET* net) error= -1; goto err; } - if (my_write(data_fd, (byte*)net->read_pos, (uint) packet_len, + if (my_write(data_fd, (uchar*)net->read_pos, (uint) packet_len, MYF(MY_WME|MY_FNABP))) { error = errno; @@ -550,7 +550,7 @@ int ha_myisam::dump(THD* thd, int fd) uint blocksize = share->blocksize; my_off_t bytes_to_read = share->state.state.data_file_length; int data_fd = file->dfile; - byte * buf = (byte*) my_malloc(blocksize, MYF(MY_WME)); + uchar *buf = (uchar*) my_malloc(blocksize, MYF(MY_WME)); if (!buf) return ENOMEM; @@ -558,7 +558,7 @@ int ha_myisam::dump(THD* thd, int fd) my_seek(data_fd, 0L, MY_SEEK_SET, MYF(MY_WME)); for (; bytes_to_read > 0;) { - uint bytes = my_read(data_fd, buf, blocksize, MYF(MY_WME)); + size_t bytes = my_read(data_fd, buf, blocksize, MYF(MY_WME)); if (bytes == MY_FILE_ERROR) { error = errno; @@ -575,7 +575,7 @@ int ha_myisam::dump(THD* thd, int fd) } else { - if (my_net_write(net, (char*) buf, bytes)) + if (my_net_write(net, buf, bytes)) { error = errno ? errno : EPIPE; goto err; @@ -586,13 +586,13 @@ int ha_myisam::dump(THD* thd, int fd) if (fd < 0) { - if (my_net_write(net, "", 0)) + if (my_net_write(net, (uchar*) "", 0)) error = errno ? errno : EPIPE; net_flush(net); } err: - my_free((gptr) buf, MYF(0)); + my_free((uchar*) buf, MYF(0)); return error; } #endif /* HAVE_REPLICATION */ @@ -710,7 +710,7 @@ int ha_myisam::open(const char *name, int mode, uint test_if_locked) recinfo must be freed. */ if (recinfo) - my_free((gptr) recinfo, MYF(0)); + my_free((uchar*) recinfo, MYF(0)); return my_errno; } @@ -721,7 +721,7 @@ int ha_myisam::close(void) return mi_close(tmp); } -int ha_myisam::write_row(byte * buf) +int ha_myisam::write_row(uchar *buf) { ha_statistic_increment(&SSV::ha_write_count); @@ -1594,7 +1594,7 @@ bool ha_myisam::is_crashed() const (my_disable_locking && file->s->state.open_count)); } -int ha_myisam::update_row(const byte * old_data, byte * new_data) +int ha_myisam::update_row(const uchar *old_data, uchar *new_data) { ha_statistic_increment(&SSV::ha_update_count); if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE) @@ -1602,13 +1602,13 @@ int ha_myisam::update_row(const byte * old_data, byte * new_data) return mi_update(file,old_data,new_data); } -int ha_myisam::delete_row(const byte * buf) +int ha_myisam::delete_row(const uchar *buf) { ha_statistic_increment(&SSV::ha_delete_count); return mi_delete(file,buf); } -int ha_myisam::index_read(byte *buf, const byte *key, key_part_map keypart_map, +int ha_myisam::index_read(uchar *buf, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag) { DBUG_ASSERT(inited==INDEX); @@ -1618,7 +1618,7 @@ int ha_myisam::index_read(byte *buf, const byte *key, key_part_map keypart_map, return error; } -int ha_myisam::index_read_idx(byte *buf, uint index, const byte *key, +int ha_myisam::index_read_idx(uchar *buf, uint index, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag) { @@ -1628,7 +1628,7 @@ int ha_myisam::index_read_idx(byte *buf, uint index, const byte *key, return error; } -int ha_myisam::index_read_last(byte *buf, const byte *key, +int ha_myisam::index_read_last(uchar *buf, const uchar *key, key_part_map keypart_map) { DBUG_ENTER("ha_myisam::index_read_last"); @@ -1640,7 +1640,7 @@ int ha_myisam::index_read_last(byte *buf, const byte *key, DBUG_RETURN(error); } -int ha_myisam::index_next(byte * buf) +int ha_myisam::index_next(uchar *buf) { DBUG_ASSERT(inited==INDEX); ha_statistic_increment(&SSV::ha_read_next_count); @@ -1649,7 +1649,7 @@ int ha_myisam::index_next(byte * buf) return error; } -int ha_myisam::index_prev(byte * buf) +int ha_myisam::index_prev(uchar *buf) { DBUG_ASSERT(inited==INDEX); ha_statistic_increment(&SSV::ha_read_prev_count); @@ -1658,7 +1658,7 @@ int ha_myisam::index_prev(byte * buf) return error; } -int ha_myisam::index_first(byte * buf) +int ha_myisam::index_first(uchar *buf) { DBUG_ASSERT(inited==INDEX); ha_statistic_increment(&SSV::ha_read_first_count); @@ -1667,7 +1667,7 @@ int ha_myisam::index_first(byte * buf) return error; } -int ha_myisam::index_last(byte * buf) +int ha_myisam::index_last(uchar *buf) { DBUG_ASSERT(inited==INDEX); ha_statistic_increment(&SSV::ha_read_last_count); @@ -1676,8 +1676,8 @@ int ha_myisam::index_last(byte * buf) return error; } -int ha_myisam::index_next_same(byte * buf, - const byte *key __attribute__((unused)), +int ha_myisam::index_next_same(uchar *buf, + const uchar *key __attribute__((unused)), uint length __attribute__((unused))) { DBUG_ASSERT(inited==INDEX); @@ -1695,7 +1695,7 @@ int ha_myisam::rnd_init(bool scan) return mi_reset(file); // Free buffers } -int ha_myisam::rnd_next(byte *buf) +int ha_myisam::rnd_next(uchar *buf) { ha_statistic_increment(&SSV::ha_read_rnd_next_count); int error=mi_scan(file, buf); @@ -1703,12 +1703,12 @@ int ha_myisam::rnd_next(byte *buf) return error; } -int ha_myisam::restart_rnd_next(byte *buf, byte *pos) +int ha_myisam::restart_rnd_next(uchar *buf, uchar *pos) { return rnd_pos(buf,pos); } -int ha_myisam::rnd_pos(byte * buf, byte *pos) +int ha_myisam::rnd_pos(uchar *buf, uchar *pos) { ha_statistic_increment(&SSV::ha_read_rnd_count); int error=mi_rrnd(file, buf, my_get_ptr(pos,ref_length)); @@ -1716,7 +1716,7 @@ int ha_myisam::rnd_pos(byte * buf, byte *pos) return error; } -void ha_myisam::position(const byte* record) +void ha_myisam::position(const uchar *record) { my_off_t row_position= mi_position(file); my_store_ptr(ref, ref_length, row_position); @@ -1901,7 +1901,7 @@ int ha_myisam::create(const char *name, register TABLE *table_arg, records, recinfo, 0, (MI_UNIQUEDEF*) 0, &create_info, create_flags); - my_free((gptr) recinfo, MYF(0)); + my_free((uchar*) recinfo, MYF(0)); DBUG_RETURN(error); } @@ -1919,7 +1919,7 @@ void ha_myisam::get_auto_increment(ulonglong offset, ulonglong increment, { ulonglong nr; int error; - byte key[MI_MAX_KEY_LENGTH]; + uchar key[MI_MAX_KEY_LENGTH]; if (!table->s->next_number_key_offset) { // Autoincrement at key-start @@ -1992,7 +1992,7 @@ ha_rows ha_myisam::records_in_range(uint inx, key_range *min_key, } -int ha_myisam::ft_read(byte * buf) +int ha_myisam::ft_read(uchar *buf) { int error; diff --git a/storage/myisam/ha_myisam.h b/storage/myisam/ha_myisam.h index bb439e9914d..6cc9f4811b0 100644 --- a/storage/myisam/ha_myisam.h +++ b/storage/myisam/ha_myisam.h @@ -67,19 +67,19 @@ class ha_myisam: public handler bool called_by_logger_thread); int open(const char *name, int mode, uint test_if_locked); int close(void); - int write_row(byte * buf); - int update_row(const byte * old_data, byte * new_data); - int delete_row(const byte * buf); - int index_read(byte *buf, const byte *key, key_part_map keypart_map, + int write_row(uchar * buf); + int update_row(const uchar * old_data, uchar * new_data); + int delete_row(const uchar * buf); + int index_read(uchar *buf, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag); - int index_read_idx(byte *buf, uint index, const byte *key, + int index_read_idx(uchar *buf, uint index, const uchar *key, key_part_map keypart_map, enum ha_rkey_function find_flag); - int index_read_last(byte *buf, const byte *key, key_part_map keypart_map); - int index_next(byte * buf); - int index_prev(byte * buf); - int index_first(byte * buf); - int index_last(byte * buf); - int index_next_same(byte *buf, const byte *key, uint keylen); + int index_read_last(uchar *buf, const uchar *key, key_part_map keypart_map); + int index_next(uchar * buf); + int index_prev(uchar * buf); + int index_first(uchar * buf); + int index_last(uchar * buf); + int index_next_same(uchar *buf, const uchar *key, uint keylen); int ft_init() { if (!ft_handler) @@ -90,15 +90,15 @@ class ha_myisam: public handler FT_INFO *ft_init_ext(uint flags, uint inx,String *key) { return ft_init_search(flags,file,inx, - (byte *)key->ptr(), key->length(), key->charset(), + (uchar *)key->ptr(), key->length(), key->charset(), table->record[0]); } - int ft_read(byte *buf); + int ft_read(uchar *buf); int rnd_init(bool scan); - int rnd_next(byte *buf); - int rnd_pos(byte * buf, byte *pos); - int restart_rnd_next(byte *buf, byte *pos); - void position(const byte *record); + int rnd_next(uchar *buf); + int rnd_pos(uchar * buf, uchar *pos); + int restart_rnd_next(uchar *buf, uchar *pos); + void position(const uchar *record); int info(uint); int extra(enum ha_extra_function operation); int extra_opt(enum ha_extra_function operation, ulong cache_size); diff --git a/storage/myisam/mi_cache.c b/storage/myisam/mi_cache.c index 59c9b2c8812..d6dcc431a8d 100644 --- a/storage/myisam/mi_cache.c +++ b/storage/myisam/mi_cache.c @@ -35,12 +35,12 @@ #include "myisamdef.h" -int _mi_read_cache(IO_CACHE *info, byte *buff, my_off_t pos, uint length, +int _mi_read_cache(IO_CACHE *info, uchar *buff, my_off_t pos, uint length, int flag) { uint read_length,in_buff_length; my_off_t offset; - char *in_buff_pos; + uchar *in_buff_pos; DBUG_ENTER("_mi_read_cache"); if (pos < info->pos_in_file) @@ -61,7 +61,7 @@ int _mi_read_cache(IO_CACHE *info, byte *buff, my_off_t pos, uint length, (my_off_t) (info->read_end - info->request_pos)) { in_buff_pos=info->request_pos+(uint) offset; - in_buff_length= min(length,(uint) (info->read_end-in_buff_pos)); + in_buff_length= min(length, (size_t) (info->read_end-in_buff_pos)); memcpy(buff,info->request_pos+(uint) offset,(size_t) in_buff_length); if (!(length-=in_buff_length)) DBUG_RETURN(0); diff --git a/storage/myisam/mi_check.c b/storage/myisam/mi_check.c index cd6ab65c223..255f17eada7 100644 --- a/storage/myisam/mi_check.c +++ b/storage/myisam/mi_check.c @@ -83,12 +83,12 @@ static int sort_delete_record(MI_SORT_PARAM *sort_param); /*static int flush_pending_blocks(MI_CHECK *param);*/ static SORT_KEY_BLOCKS *alloc_key_blocks(MI_CHECK *param, uint blocks, uint buffer_length); -static ha_checksum mi_byte_checksum(const byte *buf, uint length); +static ha_checksum mi_byte_checksum(const uchar *buf, uint length); static void set_data_file_type(SORT_INFO *sort_info, MYISAM_SHARE *share); void myisamchk_init(MI_CHECK *param) { - bzero((gptr) param,sizeof(*param)); + bzero((uchar*) param,sizeof(*param)); param->opt_follow_links=1; param->keys_in_use= ~(ulonglong) 0; param->search_after_block=HA_OFFSET_ERROR; @@ -296,7 +296,7 @@ static int check_k_link(MI_CHECK *param, register MI_INFO *info, uint nr) */ if (!(buff=key_cache_read(info->s->key_cache, info->s->kfile, next_link, DFLT_INIT_HITS, - (byte*) info->buff, MI_MIN_KEY_BLOCK_LENGTH, + (uchar*) info->buff, MI_MIN_KEY_BLOCK_LENGTH, MI_MIN_KEY_BLOCK_LENGTH, 1))) { /* purecov: begin tested */ @@ -531,7 +531,7 @@ int chk_key(MI_CHECK *param, register MI_INFO *info) /* Check that there isn't a row with auto_increment = 0 in the table */ mi_extra(info,HA_EXTRA_KEYREAD,0); bzero(info->lastkey,keyinfo->seg->length); - if (!mi_rkey(info, info->rec_buff, key, (const byte*) info->lastkey, + if (!mi_rkey(info, info->rec_buff, key, (const uchar*) info->lastkey, (key_part_map)1, HA_READ_KEY_EXACT)) { /* Don't count this as a real warning, as myisamchk can't correct it */ @@ -741,7 +741,7 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, char llbuff[22]; uint diff_pos[2]; DBUG_ENTER("chk_index"); - DBUG_DUMP("buff",(byte*) buff,mi_getint(buff)); + DBUG_DUMP("buff",(uchar*) buff,mi_getint(buff)); /* TODO: implement appropriate check for RTree keys */ if (keyinfo->flag & HA_SPATIAL) @@ -799,8 +799,8 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, (flag=ha_key_cmp(keyinfo->seg,info->lastkey,key,key_length, comp_flag, diff_pos)) >=0) { - DBUG_DUMP("old",(byte*) info->lastkey, info->lastkey_length); - DBUG_DUMP("new",(byte*) key, key_length); + DBUG_DUMP("old",(uchar*) info->lastkey, info->lastkey_length); + DBUG_DUMP("new",(uchar*) key, key_length); DBUG_DUMP("new_in_page",(char*) old_keypos,(uint) (keypos-old_keypos)); if (comp_flag & SEARCH_FIND && flag == 0) @@ -832,7 +832,7 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, key); } } - (*key_checksum)+= mi_byte_checksum((byte*) key, + (*key_checksum)+= mi_byte_checksum((uchar*) key, key_length- info->s->rec_reflength); record= _mi_dpos(info,0,key+key_length); if (keyinfo->flag & HA_FULLTEXT) /* special handling for ft2 */ @@ -870,7 +870,7 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, DBUG_PRINT("test",("page: %s record: %s filelength: %s", llstr(page,llbuff),llstr(record,llbuff2), llstr(info->state->data_file_length,llbuff3))); - DBUG_DUMP("key",(byte*) key,key_length); + DBUG_DUMP("key",(uchar*) key,key_length); DBUG_DUMP("new_in_page",(char*) old_keypos,(uint) (keypos-old_keypos)); goto err; } @@ -882,10 +882,10 @@ static int chk_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, llstr(page,llbuff), used_length, (keypos - buff)); goto err; } - my_afree((byte*) temp_buff); + my_afree((uchar*) temp_buff); DBUG_RETURN(0); err: - my_afree((byte*) temp_buff); + my_afree((uchar*) temp_buff); DBUG_RETURN(1); } /* chk_index */ @@ -940,7 +940,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) ha_rows records,del_blocks; my_off_t used,empty,pos,splits,start_recpos, del_length,link_used,start_block; - byte *record,*to; + uchar *record,*to; char llbuff[22],llbuff2[22],llbuff3[22]; ha_checksum intern_record_checksum; ha_checksum key_checksum[MI_MAX_POSSIBLE_KEY]; @@ -957,7 +957,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) puts("- check record links"); } - if (!(record= (byte*) my_malloc(info->s->base.pack_reclength,MYF(0)))) + if (!(record= (uchar*) my_malloc(info->s->base.pack_reclength,MYF(0)))) { mi_check_print_error(param,"Not enough memory for record"); DBUG_RETURN(-1); @@ -992,7 +992,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) goto err2; switch (info->s->data_file_type) { case STATIC_RECORD: - if (my_b_read(¶m->read_cache,(byte*) record, + if (my_b_read(¶m->read_cache,(uchar*) record, info->s->base.pack_reclength)) goto err; start_recpos=pos; @@ -1012,7 +1012,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) block_info.next_filepos=pos; do { - if (_mi_read_cache(¶m->read_cache,(byte*) block_info.header, + if (_mi_read_cache(¶m->read_cache,(uchar*) block_info.header, (start_block=block_info.next_filepos), sizeof(block_info.header), (flag ? 0 : READING_NEXT) | READING_HEADER)) @@ -1116,7 +1116,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) got_error=1; break; } - if (_mi_read_cache(¶m->read_cache,(byte*) to,block_info.filepos, + if (_mi_read_cache(¶m->read_cache,(uchar*) to,block_info.filepos, (uint) block_info.data_len, flag == 1 ? READING_NEXT : 0)) goto err; @@ -1177,7 +1177,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) pos=block_info.filepos+block_info.block_len; break; case COMPRESSED_RECORD: - if (_mi_read_cache(¶m->read_cache,(byte*) block_info.header, pos, + if (_mi_read_cache(¶m->read_cache,(uchar*) block_info.header, pos, info->s->pack.ref_length, READING_NEXT)) goto err; start_recpos=pos; @@ -1194,7 +1194,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) got_error=1; break; } - if (_mi_read_cache(¶m->read_cache,(byte*) info->rec_buff, + if (_mi_read_cache(¶m->read_cache,(uchar*) info->rec_buff, block_info.filepos, block_info.rec_len, READING_NEXT)) goto err; if (_mi_pack_rec_unpack(info, &info->bit_buff, record, @@ -1254,7 +1254,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) } } else - key_checksum[key]+=mi_byte_checksum((byte*) info->lastkey, + key_checksum[key]+=mi_byte_checksum((uchar*) info->lastkey, key_length); } } @@ -1364,12 +1364,12 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) printf("Lost space: %12s Linkdata: %10s\n", llstr(empty,llbuff),llstr(link_used,llbuff2)); } - my_free((gptr) record,MYF(0)); + my_free((uchar*) record,MYF(0)); DBUG_RETURN (error); err: mi_check_print_error(param,"got error: %d when reading datafile at record: %s",my_errno, llstr(records,llbuff)); err2: - my_free((gptr) record,MYF(0)); + my_free((uchar*) record,MYF(0)); param->testflag|=T_RETRY_WITHOUT_QUICK; DBUG_RETURN(1); } /* chk_data_link */ @@ -1379,7 +1379,7 @@ int chk_data_link(MI_CHECK *param, MI_INFO *info,int extend) /* Save new datafile-name in temp_filename */ int mi_repair(MI_CHECK *param, register MI_INFO *info, - my_string name, int rep_quick) + char * name, int rep_quick) { int error,got_error; uint i; @@ -1428,7 +1428,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, MYF(MY_WME | MY_WAIT_IF_FULL))) goto err; info->opt_flag|=WRITE_CACHE_USED; - if (!(sort_param.record=(byte*) my_malloc((uint) share->base.pack_reclength, + if (!(sort_param.record=(uchar*) my_malloc((uint) share->base.pack_reclength, MYF(0))) || !mi_alloc_rec_buff(info, -1, &sort_param.rec_buff)) { @@ -1515,7 +1515,7 @@ int mi_repair(MI_CHECK *param, register MI_INFO *info, { if (my_errno != HA_ERR_FOUND_DUPP_KEY) goto err; - DBUG_DUMP("record",(byte*) sort_param.record,share->base.pack_reclength); + DBUG_DUMP("record",(uchar*) sort_param.record,share->base.pack_reclength); mi_check_print_info(param,"Duplicate key %2d for record at %10s against new record at %10s", info->errkey+1, llstr(sort_param.start_recpos,llbuff), @@ -1661,7 +1661,7 @@ static int writekeys(MI_SORT_PARAM *sort_param) register uint i; uchar *key; MI_INFO *info= sort_param->sort_info->info; - byte *buff= sort_param->record; + uchar *buff= sort_param->record; my_off_t filepos= sort_param->filepos; DBUG_ENTER("writekeys"); @@ -1725,7 +1725,7 @@ static int writekeys(MI_SORT_PARAM *sort_param) /* Change all key-pointers that points to a records */ -int movepoint(register MI_INFO *info, byte *record, my_off_t oldpos, +int movepoint(register MI_INFO *info, uchar *record, my_off_t oldpos, my_off_t newpos, uint prot_key) { register uint i; @@ -1802,7 +1802,7 @@ int flush_blocks(MI_CHECK *param, KEY_CACHE *key_cache, File file) /* Sort index for more efficent reads */ -int mi_sort_index(MI_CHECK *param, register MI_INFO *info, my_string name) +int mi_sort_index(MI_CHECK *param, register MI_INFO *info, char * name) { reg2 uint key; reg1 MI_KEYDEF *keyinfo; @@ -1945,7 +1945,7 @@ static int sort_one_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, ("From page: %ld, keyoffset: %lu used_length: %d", (ulong) pagepos, (ulong) (keypos - buff), (int) used_length)); - DBUG_DUMP("buff",(byte*) buff,used_length); + DBUG_DUMP("buff",(uchar*) buff,used_length); goto err; } } @@ -1974,17 +1974,17 @@ static int sort_one_index(MI_CHECK *param, MI_INFO *info, MI_KEYDEF *keyinfo, /* Fill block with zero and write it to the new index file */ length=mi_getint(buff); - bzero((byte*) buff+length,keyinfo->block_length-length); - if (my_pwrite(new_file,(byte*) buff,(uint) keyinfo->block_length, + bzero((uchar*) buff+length,keyinfo->block_length-length); + if (my_pwrite(new_file,(uchar*) buff,(uint) keyinfo->block_length, new_page_pos,MYF(MY_NABP | MY_WAIT_IF_FULL))) { mi_check_print_error(param,"Can't write indexblock, error: %d",my_errno); goto err; } - my_afree((gptr) buff); + my_afree((uchar*) buff); DBUG_RETURN(0); err: - my_afree((gptr) buff); + my_afree((uchar*) buff); DBUG_RETURN(1); } /* sort_one_index */ @@ -2055,13 +2055,13 @@ int filecopy(MI_CHECK *param, File to,File from,my_off_t start, VOID(my_seek(from,start,MY_SEEK_SET,MYF(0))); while (length > buff_length) { - if (my_read(from,(byte*) buff,buff_length,MYF(MY_NABP)) || - my_write(to,(byte*) buff,buff_length,param->myf_rw)) + if (my_read(from,(uchar*) buff,buff_length,MYF(MY_NABP)) || + my_write(to,(uchar*) buff,buff_length,param->myf_rw)) goto err; length-= buff_length; } - if (my_read(from,(byte*) buff,(uint) length,MYF(MY_NABP)) || - my_write(to,(byte*) buff,(uint) length,param->myf_rw)) + if (my_read(from,(uchar*) buff,(uint) length,MYF(MY_NABP)) || + my_write(to,(uchar*) buff,(uint) length,param->myf_rw)) goto err; if (buff != tmp_buff) my_free(buff,MYF(0)); @@ -2142,7 +2142,7 @@ int mi_repair_by_sort(MI_CHECK *param, register MI_INFO *info, info->opt_flag|=WRITE_CACHE_USED; info->rec_cache.file=info->dfile; /* for sort_delete_record */ - if (!(sort_param.record=(byte*) my_malloc((uint) share->base.pack_reclength, + if (!(sort_param.record=(uchar*) my_malloc((uint) share->base.pack_reclength, MYF(0))) || !mi_alloc_rec_buff(info, -1, &sort_param.rec_buff)) { @@ -2455,8 +2455,8 @@ err: my_free(mi_get_rec_buff_ptr(info, sort_param.rec_buff), MYF(MY_ALLOW_ZERO_PTR)); my_free(sort_param.record,MYF(MY_ALLOW_ZERO_PTR)); - my_free((gptr) sort_info.key_block,MYF(MY_ALLOW_ZERO_PTR)); - my_free((gptr) sort_info.ft_buf, MYF(MY_ALLOW_ZERO_PTR)); + my_free((uchar*) sort_info.key_block,MYF(MY_ALLOW_ZERO_PTR)); + my_free((uchar*) sort_info.ft_buf, MYF(MY_ALLOW_ZERO_PTR)); my_free(sort_info.buff,MYF(MY_ALLOW_ZERO_PTR)); VOID(end_io_cache(¶m->read_cache)); info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); @@ -2988,9 +2988,9 @@ err: pthread_cond_destroy (&sort_info.cond); pthread_mutex_destroy(&sort_info.mutex); - my_free((gptr) sort_info.ft_buf, MYF(MY_ALLOW_ZERO_PTR)); - my_free((gptr) sort_info.key_block,MYF(MY_ALLOW_ZERO_PTR)); - my_free((gptr) sort_param,MYF(MY_ALLOW_ZERO_PTR)); + my_free((uchar*) sort_info.ft_buf, MYF(MY_ALLOW_ZERO_PTR)); + my_free((uchar*) sort_info.key_block,MYF(MY_ALLOW_ZERO_PTR)); + my_free((uchar*) sort_param,MYF(MY_ALLOW_ZERO_PTR)); my_free(sort_info.buff,MYF(MY_ALLOW_ZERO_PTR)); VOID(end_io_cache(¶m->read_cache)); info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); @@ -3120,7 +3120,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) int parallel_flag; uint found_record,b_type,left_length; my_off_t pos; - byte *to; + uchar *to; MI_BLOCK_INFO block_info; SORT_INFO *sort_info=sort_param->sort_info; MI_CHECK *param=sort_info->param; @@ -3198,7 +3198,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) llstr(param->search_after_block,llbuff), llstr(sort_param->start_recpos,llbuff2)); if (_mi_read_cache(&sort_param->read_cache, - (byte*) block_info.header,pos, + (uchar*) block_info.header,pos, MI_BLOCK_INFO_HEADER_LENGTH, (! found_record ? READING_NEXT : 0) | parallel_flag | READING_HEADER)) @@ -3462,7 +3462,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) case COMPRESSED_RECORD: for (searching=0 ;; searching=1, sort_param->pos++) { - if (_mi_read_cache(&sort_param->read_cache,(byte*) block_info.header, + if (_mi_read_cache(&sort_param->read_cache,(uchar*) block_info.header, sort_param->pos, share->pack.ref_length,READING_NEXT)) DBUG_RETURN(-1); @@ -3490,7 +3490,7 @@ static int sort_get_next_record(MI_SORT_PARAM *sort_param) llstr(sort_param->pos,llbuff)); continue; } - if (_mi_read_cache(&sort_param->read_cache,(byte*) sort_param->rec_buff, + if (_mi_read_cache(&sort_param->read_cache,(uchar*) sort_param->rec_buff, block_info.filepos, block_info.rec_len, READING_NEXT)) { @@ -3546,8 +3546,8 @@ int sort_write_record(MI_SORT_PARAM *sort_param) int flag; uint length; ulong block_length,reclength; - byte *from; - byte block_buff[8]; + uchar *from; + uchar block_buff[8]; SORT_INFO *sort_info=sort_param->sort_info; MI_CHECK *param=sort_info->param; MI_INFO *info=sort_info->info; @@ -3623,7 +3623,7 @@ int sort_write_record(MI_SORT_PARAM *sort_param) length+= save_pack_length((uint) share->pack.version, block_buff + length, info->blob_length); if (my_b_write(&info->rec_cache,block_buff,length) || - my_b_write(&info->rec_cache,(byte*) sort_param->rec_buff,reclength)) + my_b_write(&info->rec_cache,(uchar*) sort_param->rec_buff,reclength)) { mi_check_print_error(param,"%d when writing to datafile",my_errno); DBUG_RETURN(1); @@ -3923,7 +3923,7 @@ static int sort_insert_key(MI_SORT_PARAM *sort_param, /* Fill block with end-zero and write filled block */ mi_putint(anc_buff,key_block->last_length,nod_flag); - bzero((byte*) anc_buff+key_block->last_length, + bzero((uchar*) anc_buff+key_block->last_length, keyinfo->block_length- key_block->last_length); key_file_length=info->state->key_file_length; if ((filepos=_mi_new(info,keyinfo,DFLT_INIT_HITS)) == HA_OFFSET_ERROR) @@ -3935,10 +3935,10 @@ static int sort_insert_key(MI_SORT_PARAM *sort_param, if (_mi_write_keypage(info, keyinfo, filepos, DFLT_INIT_HITS, anc_buff)) DBUG_RETURN(1); } - else if (my_pwrite(info->s->kfile,(byte*) anc_buff, + else if (my_pwrite(info->s->kfile,(uchar*) anc_buff, (uint) keyinfo->block_length,filepos, param->myf_rw)) DBUG_RETURN(1); - DBUG_DUMP("buff",(byte*) anc_buff,mi_getint(anc_buff)); + DBUG_DUMP("buff",(uchar*) anc_buff,mi_getint(anc_buff)); /* Write separator-key to block in next level */ if (sort_insert_key(sort_param,key_block+1,key_block->lastkey,filepos)) @@ -4029,7 +4029,7 @@ int flush_pending_blocks(MI_SORT_PARAM *sort_param) if (nod_flag) _mi_kpointer(info,key_block->end_pos,filepos); key_file_length=info->state->key_file_length; - bzero((byte*) key_block->buff+length, keyinfo->block_length-length); + bzero((uchar*) key_block->buff+length, keyinfo->block_length-length); if ((filepos=_mi_new(info,keyinfo,DFLT_INIT_HITS)) == HA_OFFSET_ERROR) DBUG_RETURN(1); @@ -4040,10 +4040,10 @@ int flush_pending_blocks(MI_SORT_PARAM *sort_param) DFLT_INIT_HITS, key_block->buff)) DBUG_RETURN(1); } - else if (my_pwrite(info->s->kfile,(byte*) key_block->buff, + else if (my_pwrite(info->s->kfile,(uchar*) key_block->buff, (uint) keyinfo->block_length,filepos, myf_rw)) DBUG_RETURN(1); - DBUG_DUMP("buff",(byte*) key_block->buff,length); + DBUG_DUMP("buff",(uchar*) key_block->buff,length); nod_flag=1; } info->s->state.key_root[sort_param->key]=filepos; /* Last is root for tree */ @@ -4114,34 +4114,34 @@ int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename) (param->testflag & T_UNPACK); if (!(keyinfo=(MI_KEYDEF*) my_alloca(sizeof(MI_KEYDEF)*share.base.keys))) DBUG_RETURN(0); - memcpy((byte*) keyinfo,(byte*) share.keyinfo, + memcpy((uchar*) keyinfo,(uchar*) share.keyinfo, (size_t) (sizeof(MI_KEYDEF)*share.base.keys)); key_parts= share.base.all_key_parts; if (!(keysegs=(HA_KEYSEG*) my_alloca(sizeof(HA_KEYSEG)* (key_parts+share.base.keys)))) { - my_afree((gptr) keyinfo); + my_afree((uchar*) keyinfo); DBUG_RETURN(1); } if (!(recdef=(MI_COLUMNDEF*) my_alloca(sizeof(MI_COLUMNDEF)*(share.base.fields+1)))) { - my_afree((gptr) keyinfo); - my_afree((gptr) keysegs); + my_afree((uchar*) keyinfo); + my_afree((uchar*) keysegs); DBUG_RETURN(1); } if (!(uniquedef=(MI_UNIQUEDEF*) my_alloca(sizeof(MI_UNIQUEDEF)*(share.state.header.uniques+1)))) { - my_afree((gptr) recdef); - my_afree((gptr) keyinfo); - my_afree((gptr) keysegs); + my_afree((uchar*) recdef); + my_afree((uchar*) keyinfo); + my_afree((uchar*) keysegs); DBUG_RETURN(1); } /* Copy the column definitions */ - memcpy((byte*) recdef,(byte*) share.rec, + memcpy((uchar*) recdef,(uchar*) share.rec, (size_t) (sizeof(MI_COLUMNDEF)*(share.base.fields+1))); for (rec=recdef,end=recdef+share.base.fields; rec != end ; rec++) { @@ -4153,7 +4153,7 @@ int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename) } /* Change the new key to point at the saved key segments */ - memcpy((byte*) keysegs,(byte*) share.keyparts, + memcpy((uchar*) keysegs,(uchar*) share.keyparts, (size_t) (sizeof(HA_KEYSEG)*(key_parts+share.base.keys+ share.state.header.uniques))); keyseg=keysegs; @@ -4170,7 +4170,7 @@ int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename) /* Copy the unique definitions and change them to point at the new key segments*/ - memcpy((byte*) uniquedef,(byte*) share.uniqueinfo, + memcpy((uchar*) uniquedef,(uchar*) share.uniqueinfo, (size_t) (sizeof(MI_UNIQUEDEF)*(share.state.header.uniques))); for (u_ptr=uniquedef,u_end=uniquedef+share.state.header.uniques; u_ptr != u_end ; u_ptr++) @@ -4252,10 +4252,10 @@ int recreate_table(MI_CHECK *param, MI_INFO **org_info, char *filename) goto end; error=0; end: - my_afree((gptr) uniquedef); - my_afree((gptr) keyinfo); - my_afree((gptr) recdef); - my_afree((gptr) keysegs); + my_afree((uchar*) uniquedef); + my_afree((uchar*) keyinfo); + my_afree((uchar*) recdef); + my_afree((uchar*) keysegs); DBUG_RETURN(error); } @@ -4358,7 +4358,7 @@ err: void update_auto_increment_key(MI_CHECK *param, MI_INFO *info, my_bool repair_only) { - byte *record; + uchar *record; DBUG_ENTER("update_auto_increment_key"); if (!info->s->base.auto_key || @@ -4377,7 +4377,7 @@ void update_auto_increment_key(MI_CHECK *param, MI_INFO *info, We have to use an allocated buffer instead of info->rec_buff as _mi_put_key_in_record() may use info->rec_buff */ - if (!(record= (byte*) my_malloc((uint) info->s->base.pack_reclength, + if (!(record= (uchar*) my_malloc((uint) info->s->base.pack_reclength, MYF(0)))) { mi_check_print_error(param,"Not enough memory for extra record"); @@ -4505,10 +4505,10 @@ void update_key_parts(MI_KEYDEF *keyinfo, ulong *rec_per_key_part, } -static ha_checksum mi_byte_checksum(const byte *buf, uint length) +static ha_checksum mi_byte_checksum(const uchar *buf, uint length) { ha_checksum crc; - const byte *end=buf+length; + const uchar *end=buf+length; for (crc=0; buf != end; buf++) crc=((crc << 1) + *((uchar*) buf)) + test(crc & (((ha_checksum) 1) << (8*sizeof(ha_checksum)-1))); diff --git a/storage/myisam/mi_checksum.c b/storage/myisam/mi_checksum.c index 711e87c1547..4e87de373bd 100644 --- a/storage/myisam/mi_checksum.c +++ b/storage/myisam/mi_checksum.c @@ -17,7 +17,7 @@ #include "myisamdef.h" -ha_checksum mi_checksum(MI_INFO *info, const byte *buf) +ha_checksum mi_checksum(MI_INFO *info, const uchar *buf) { uint i; ha_checksum crc=0; @@ -25,7 +25,7 @@ ha_checksum mi_checksum(MI_INFO *info, const byte *buf) for (i=info->s->base.fields ; i-- ; buf+=(rec++)->length) { - const byte *pos; + const uchar *pos; ulong length; switch (rec->type) { case FIELD_BLOB: @@ -52,13 +52,13 @@ ha_checksum mi_checksum(MI_INFO *info, const byte *buf) pos=buf; break; } - crc=my_checksum(crc, pos ? pos : "", length); + crc=my_checksum(crc, pos ? pos : (uchar*) "", length); } return crc; } -ha_checksum mi_static_checksum(MI_INFO *info, const byte *pos) +ha_checksum mi_static_checksum(MI_INFO *info, const uchar *pos) { return my_checksum(0, pos, info->s->base.reclength); } diff --git a/storage/myisam/mi_close.c b/storage/myisam/mi_close.c index 47b7ba855c0..07105aea88d 100644 --- a/storage/myisam/mi_close.c +++ b/storage/myisam/mi_close.c @@ -87,8 +87,8 @@ int mi_close(register MI_INFO *info) #endif if (share->decode_trees) { - my_free((gptr) share->decode_trees,MYF(0)); - my_free((gptr) share->decode_tables,MYF(0)); + my_free((uchar*) share->decode_trees,MYF(0)); + my_free((uchar*) share->decode_tables,MYF(0)); } #ifdef THREAD thr_lock_delete(&share->lock); @@ -102,19 +102,19 @@ int mi_close(register MI_INFO *info) } } #endif - my_free((gptr) info->s,MYF(0)); + my_free((uchar*) info->s,MYF(0)); } pthread_mutex_unlock(&THR_LOCK_myisam); if (info->ftparser_param) { - my_free((gptr)info->ftparser_param, MYF(0)); + my_free((uchar*)info->ftparser_param, MYF(0)); info->ftparser_param= 0; } if (info->dfile >= 0 && my_close(info->dfile,MYF(0))) error = my_errno; myisam_log_command(MI_LOG_CLOSE,info,NULL,0,error); - my_free((gptr) info,MYF(0)); + my_free((uchar*) info,MYF(0)); if (error) { diff --git a/storage/myisam/mi_create.c b/storage/myisam/mi_create.c index 71d377c8b6b..c177aa8d987 100644 --- a/storage/myisam/mi_create.c +++ b/storage/myisam/mi_create.c @@ -76,7 +76,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, LINT_INIT(file); errpos=0; options=0; - bzero((byte*) &share,sizeof(share)); + bzero((uchar*) &share,sizeof(share)); if (flags & HA_DONT_TOUCH_DATA) { @@ -498,7 +498,7 @@ int mi_create(const char *name,uint keys,MI_KEYDEF *keydefs, goto err; } - bmove(share.state.header.file_version,(byte*) myisam_file_magic,4); + bmove(share.state.header.file_version,(uchar*) myisam_file_magic,4); ci->old_options=options| (ci->old_options & HA_OPTION_TEMP_COMPRESS_RECORD ? HA_OPTION_COMPRESS_RECORD | HA_OPTION_TEMP_COMPRESS_RECORD: 0); diff --git a/storage/myisam/mi_delete.c b/storage/myisam/mi_delete.c index 409930ff7fb..29a84570f1e 100644 --- a/storage/myisam/mi_delete.c +++ b/storage/myisam/mi_delete.c @@ -32,7 +32,7 @@ static int _mi_ck_real_delete(register MI_INFO *info,MI_KEYDEF *keyinfo, uchar *key, uint key_length, my_off_t *root); -int mi_delete(MI_INFO *info,const byte *record) +int mi_delete(MI_INFO *info,const uchar *record) { uint i; uchar *old_key; @@ -100,7 +100,7 @@ int mi_delete(MI_INFO *info,const byte *record) info->state->records--; mi_sizestore(lastpos,info->lastpos); - myisam_log_command(MI_LOG_DELETE,info,(byte*) lastpos,sizeof(lastpos),0); + myisam_log_command(MI_LOG_DELETE,info,(uchar*) lastpos,sizeof(lastpos),0); VOID(_mi_writeinfo(info,WRITEINFO_UPDATE_KEYFILE)); allow_break(); /* Allow SIGHUP & SIGINT */ if (info->invalidator != 0) @@ -114,7 +114,7 @@ int mi_delete(MI_INFO *info,const byte *record) err: save_errno=my_errno; mi_sizestore(lastpos,info->lastpos); - myisam_log_command(MI_LOG_DELETE,info,(byte*) lastpos, sizeof(lastpos),0); + myisam_log_command(MI_LOG_DELETE,info,(uchar*) lastpos, sizeof(lastpos),0); if (save_errno != HA_ERR_RECORD_CHANGED) { mi_print_error(info->s, HA_ERR_CRASHED); @@ -198,7 +198,7 @@ static int _mi_ck_real_delete(register MI_INFO *info, MI_KEYDEF *keyinfo, } } err: - my_afree((gptr) root_buff); + my_afree((uchar*) root_buff); DBUG_PRINT("exit",("Return: %d",error)); DBUG_RETURN(error); } /* _mi_ck_real_delete */ @@ -223,7 +223,7 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, my_off_t leaf_page,next_block; uchar lastkey[MI_MAX_KEY_BUFF]; DBUG_ENTER("d_search"); - DBUG_DUMP("page",(byte*) anc_buff,mi_getint(anc_buff)); + DBUG_DUMP("page",(uchar*) anc_buff,mi_getint(anc_buff)); search_key_length= (comp_flag & SEARCH_FIND) ? key_length : USE_WHOLE_KEY; flag=(*keyinfo->bin_search)(info,keyinfo,anc_buff,key, search_key_length, @@ -381,14 +381,14 @@ static int d_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, ret_value|=_mi_write_keypage(info,keyinfo,page,DFLT_INIT_HITS,anc_buff); else { - DBUG_DUMP("page",(byte*) anc_buff,mi_getint(anc_buff)); + DBUG_DUMP("page",(uchar*) anc_buff,mi_getint(anc_buff)); } - my_afree((byte*) leaf_buff); + my_afree((uchar*) leaf_buff); DBUG_PRINT("exit",("Return: %d",ret_value)); DBUG_RETURN(ret_value); err: - my_afree((byte*) leaf_buff); + my_afree((uchar*) leaf_buff); DBUG_PRINT("exit",("Error: %d",my_errno)); DBUG_RETURN (-1); } /* d_search */ @@ -411,7 +411,7 @@ static int del(register MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *key, DBUG_ENTER("del"); DBUG_PRINT("enter",("leaf_page: %ld keypos: 0x%lx", (long) leaf_page, (ulong) keypos)); - DBUG_DUMP("leaf_buff",(byte*) leaf_buff,mi_getint(leaf_buff)); + DBUG_DUMP("leaf_buff",(uchar*) leaf_buff,mi_getint(leaf_buff)); endpos=leaf_buff+mi_getint(leaf_buff); if (!(key_start=_mi_get_last_key(info,keyinfo,leaf_buff,keybuff,endpos, @@ -428,7 +428,7 @@ static int del(register MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *key, ret_value= -1; else { - DBUG_DUMP("next_page",(byte*) next_buff,mi_getint(next_buff)); + DBUG_DUMP("next_page",(uchar*) next_buff,mi_getint(next_buff)); if ((ret_value=del(info,keyinfo,key,anc_buff,next_page,next_buff, keypos,next_block,ret_key)) >0) { @@ -455,7 +455,7 @@ static int del(register MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *key, if (_mi_write_keypage(info,keyinfo,leaf_page,DFLT_INIT_HITS,leaf_buff)) goto err; } - my_afree((byte*) next_buff); + my_afree((uchar*) next_buff); DBUG_RETURN(ret_value); } @@ -479,7 +479,7 @@ static int del(register MI_INFO *info, register MI_KEYDEF *keyinfo, uchar *key, prev_key, prev_key, keybuff,&s_temp); if (length > 0) - bmove_upp((byte*) endpos+length,(byte*) endpos,(uint) (endpos-keypos)); + bmove_upp((uchar*) endpos+length,(uchar*) endpos,(uint) (endpos-keypos)); else bmove(keypos,keypos-length, (int) (endpos-keypos)+length); (*keyinfo->store_key)(keyinfo,keypos,&s_temp); @@ -517,8 +517,8 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, DBUG_ENTER("underflow"); DBUG_PRINT("enter",("leaf_page: %ld keypos: 0x%lx",(long) leaf_page, (ulong) keypos)); - DBUG_DUMP("anc_buff",(byte*) anc_buff,mi_getint(anc_buff)); - DBUG_DUMP("leaf_buff",(byte*) leaf_buff,mi_getint(leaf_buff)); + DBUG_DUMP("anc_buff",(uchar*) anc_buff,mi_getint(anc_buff)); + DBUG_DUMP("leaf_buff",(uchar*) leaf_buff,mi_getint(leaf_buff)); buff=info->buff; info->buff_used=1; @@ -554,10 +554,10 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, if (!_mi_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,buff,0)) goto err; buff_length=mi_getint(buff); - DBUG_DUMP("next",(byte*) buff,buff_length); + DBUG_DUMP("next",(uchar*) buff,buff_length); /* find keys to make a big key-page */ - bmove((byte*) next_keypos-key_reflength,(byte*) buff+2, + bmove((uchar*) next_keypos-key_reflength,(uchar*) buff+2, key_reflength); if (!_mi_get_last_key(info,keyinfo,anc_buff,anc_key,next_keypos,&length) || !_mi_get_last_key(info,keyinfo,leaf_buff,leaf_key, @@ -572,8 +572,8 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, length=buff_length-p_length; endpos=buff+length+leaf_length+t_length; /* buff will always be larger than before !*/ - bmove_upp((byte*) endpos, (byte*) buff+buff_length,length); - memcpy((byte*) buff, (byte*) leaf_buff,(size_t) leaf_length); + bmove_upp((uchar*) endpos, (uchar*) buff+buff_length,length); + memcpy((uchar*) buff, (uchar*) leaf_buff,(size_t) leaf_length); (*keyinfo->store_key)(keyinfo,buff+leaf_length,&s_temp); buff_length=(uint) (endpos-buff); mi_putint(buff,buff_length,nod_flag); @@ -589,7 +589,7 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, if (buff_length <= keyinfo->block_length) { /* Keys in one page */ - memcpy((byte*) leaf_buff,(byte*) buff,(size_t) buff_length); + memcpy((uchar*) leaf_buff,(uchar*) buff,(size_t) buff_length); if (_mi_dispose(info,keyinfo,next_page,DFLT_INIT_HITS)) goto err; } @@ -605,7 +605,7 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, &key_length, &after_key))) goto err; length=(uint) (half_pos-buff); - memcpy((byte*) leaf_buff,(byte*) buff,(size_t) length); + memcpy((uchar*) leaf_buff,(uchar*) buff,(size_t) length); mi_putint(leaf_buff,length,nod_flag); /* Correct new keypointer to leaf_page */ @@ -619,7 +619,7 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, prev_key, prev_key, leaf_key, &s_temp); if (t_length >= 0) - bmove_upp((byte*) endpos+t_length,(byte*) endpos, + bmove_upp((uchar*) endpos+t_length,(uchar*) endpos, (uint) (endpos-keypos)); else bmove(keypos,keypos-t_length,(uint) (endpos-keypos)+t_length); @@ -628,7 +628,7 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, /* Store key first in new page */ if (nod_flag) - bmove((byte*) buff+2,(byte*) half_pos-nod_flag,(size_t) nod_flag); + bmove((uchar*) buff+2,(uchar*) half_pos-nod_flag,(size_t) nod_flag); if (!(*keyinfo->get_key)(keyinfo,nod_flag,&half_pos,leaf_key)) goto err; t_length=(int) (*keyinfo->pack_key)(keyinfo, nod_flag, (uchar*) 0, @@ -636,7 +636,7 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, leaf_key, &s_temp); /* t_length will always be > 0 for a new page !*/ length=(uint) ((buff+mi_getint(buff))-half_pos); - bmove((byte*) buff+p_length+t_length,(byte*) half_pos,(size_t) length); + bmove((uchar*) buff+p_length+t_length,(uchar*) half_pos,(size_t) length); (*keyinfo->store_key)(keyinfo,buff+p_length,&s_temp); mi_putint(buff,length+t_length+p_length,nod_flag); @@ -659,10 +659,10 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, goto err; buff_length=mi_getint(buff); endpos=buff+buff_length; - DBUG_DUMP("prev",(byte*) buff,buff_length); + DBUG_DUMP("prev",(uchar*) buff,buff_length); /* find keys to make a big key-page */ - bmove((byte*) next_keypos - key_reflength,(byte*) leaf_buff+2, + bmove((uchar*) next_keypos - key_reflength,(uchar*) leaf_buff+2, key_reflength); next_keypos=keypos; if (!(*keyinfo->get_key)(keyinfo,key_reflength,&next_keypos, @@ -679,10 +679,10 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, prev_key, prev_key, anc_key, &s_temp); if (t_length >= 0) - bmove((byte*) endpos+t_length,(byte*) leaf_buff+p_length, + bmove((uchar*) endpos+t_length,(uchar*) leaf_buff+p_length, (size_t) (leaf_length-p_length)); else /* We gained space */ - bmove((byte*) endpos,(byte*) leaf_buff+((int) p_length-t_length), + bmove((uchar*) endpos,(uchar*) leaf_buff+((int) p_length-t_length), (size_t) (leaf_length-p_length+t_length)); (*keyinfo->store_key)(keyinfo,endpos,&s_temp); @@ -715,8 +715,8 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, goto err; _mi_kpointer(info,leaf_key+key_length,leaf_page); /* Save key in anc_buff */ - DBUG_DUMP("anc_buff",(byte*) anc_buff,anc_length); - DBUG_DUMP("key_to_anc",(byte*) leaf_key,key_length); + DBUG_DUMP("anc_buff",(uchar*) anc_buff,anc_length); + DBUG_DUMP("key_to_anc",(uchar*) leaf_key,key_length); temp_pos=anc_buff+anc_length; t_length=(*keyinfo->pack_key)(keyinfo,key_reflength, @@ -725,7 +725,7 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, anc_pos, anc_pos, leaf_key,&s_temp); if (t_length > 0) - bmove_upp((byte*) temp_pos+t_length,(byte*) temp_pos, + bmove_upp((uchar*) temp_pos+t_length,(uchar*) temp_pos, (uint) (temp_pos-keypos)); else bmove(keypos,keypos-t_length,(uint) (temp_pos-keypos)+t_length); @@ -734,15 +734,15 @@ static int underflow(register MI_INFO *info, register MI_KEYDEF *keyinfo, /* Store first key on new page */ if (nod_flag) - bmove((byte*) leaf_buff+2,(byte*) half_pos-nod_flag,(size_t) nod_flag); + bmove((uchar*) leaf_buff+2,(uchar*) half_pos-nod_flag,(size_t) nod_flag); if (!(length=(*keyinfo->get_key)(keyinfo,nod_flag,&half_pos,leaf_key))) goto err; - DBUG_DUMP("key_to_leaf",(byte*) leaf_key,length); + DBUG_DUMP("key_to_leaf",(uchar*) leaf_key,length); t_length=(*keyinfo->pack_key)(keyinfo,nod_flag, (uchar*) 0, (uchar*) 0, (uchar*) 0, leaf_key, &s_temp); length=(uint) ((buff+buff_length)-half_pos); DBUG_PRINT("info",("t_length: %d length: %d",t_length,(int) length)); - bmove((byte*) leaf_buff+p_length+t_length,(byte*) half_pos, + bmove((uchar*) leaf_buff+p_length+t_length,(uchar*) half_pos, (size_t) length); (*keyinfo->store_key)(keyinfo,leaf_buff+p_length,&s_temp); mi_putint(leaf_buff,length+t_length+p_length,nod_flag); @@ -886,7 +886,7 @@ static uint remove_key(MI_KEYDEF *keyinfo, uint nod_flag, } } end: - bmove((byte*) start,(byte*) start+s_length, + bmove((uchar*) start,(uchar*) start+s_length, (uint) (page_end-start-s_length)); DBUG_RETURN((uint) s_length); } /* remove_key */ diff --git a/storage/myisam/mi_delete_all.c b/storage/myisam/mi_delete_all.c index a17514486d5..dea0385cbca 100644 --- a/storage/myisam/mi_delete_all.c +++ b/storage/myisam/mi_delete_all.c @@ -47,7 +47,7 @@ int mi_delete_all_rows(MI_INFO *info) for (i=0 ; i < share->base.keys ; i++) state->key_root[i]= HA_OFFSET_ERROR; - myisam_log_command(MI_LOG_DELETE_ALL,info,(byte*) 0,0,0); + myisam_log_command(MI_LOG_DELETE_ALL,info,(uchar*) 0,0,0); /* If we are using delayed keys or if the user has done changes to the tables since it was locked then there may be key blocks in the key cache diff --git a/storage/myisam/mi_dynrec.c b/storage/myisam/mi_dynrec.c index 5342619c79b..eba868bfb82 100644 --- a/storage/myisam/mi_dynrec.c +++ b/storage/myisam/mi_dynrec.c @@ -28,15 +28,15 @@ /* Enough for comparing if number is zero */ static char zero_string[]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; -static int write_dynamic_record(MI_INFO *info,const byte *record, +static int write_dynamic_record(MI_INFO *info,const uchar *record, ulong reclength); static int _mi_find_writepos(MI_INFO *info,ulong reclength,my_off_t *filepos, ulong *length); -static int update_dynamic_record(MI_INFO *info,my_off_t filepos,byte *record, +static int update_dynamic_record(MI_INFO *info,my_off_t filepos,uchar *record, ulong reclength); static int delete_dynamic_record(MI_INFO *info,my_off_t filepos, uint second_read); -static int _mi_cmp_buffer(File file, const byte *buff, my_off_t filepos, +static int _mi_cmp_buffer(File file, const uchar *buff, my_off_t filepos, uint length); #ifdef THREAD @@ -79,13 +79,13 @@ my_bool mi_dynmap_file(MI_INFO *info, my_off_t size) mapping. When swap space is not reserved one might get SIGSEGV upon a write if no physical memory is available. */ - info->s->file_map= (byte*) + info->s->file_map= (uchar*) my_mmap(0, (size_t)(size + MEMMAP_EXTRA_MARGIN), info->s->mode==O_RDONLY ? PROT_READ : PROT_READ | PROT_WRITE, MAP_SHARED | MAP_NORESERVE, info->dfile, 0L); - if (info->s->file_map == (byte*) MAP_FAILED) + if (info->s->file_map == (uchar*) MAP_FAILED) { info->s->file_map= NULL; DBUG_RETURN(1); @@ -135,7 +135,7 @@ void mi_remap_file(MI_INFO *info, my_off_t size) 0 ok */ -uint mi_mmap_pread(MI_INFO *info, byte *Buffer, +uint mi_mmap_pread(MI_INFO *info, uchar *Buffer, uint Count, my_off_t offset, myf MyFlags) { DBUG_PRINT("info", ("mi_read with mmap %d\n", info->dfile)); @@ -167,7 +167,7 @@ uint mi_mmap_pread(MI_INFO *info, byte *Buffer, /* wrapper for my_pread in case if mmap isn't used */ -uint mi_nommap_pread(MI_INFO *info, byte *Buffer, +uint mi_nommap_pread(MI_INFO *info, uchar *Buffer, uint Count, my_off_t offset, myf MyFlags) { return my_pread(info->dfile, Buffer, Count, offset, MyFlags); @@ -190,7 +190,7 @@ uint mi_nommap_pread(MI_INFO *info, byte *Buffer, !=0 error. In this case return error from pwrite */ -uint mi_mmap_pwrite(MI_INFO *info, byte *Buffer, +uint mi_mmap_pwrite(MI_INFO *info, uchar *Buffer, uint Count, my_off_t offset, myf MyFlags) { DBUG_PRINT("info", ("mi_write with mmap %d\n", info->dfile)); @@ -224,28 +224,28 @@ uint mi_mmap_pwrite(MI_INFO *info, byte *Buffer, /* wrapper for my_pwrite in case if mmap isn't used */ -uint mi_nommap_pwrite(MI_INFO *info, byte *Buffer, +uint mi_nommap_pwrite(MI_INFO *info, uchar *Buffer, uint Count, my_off_t offset, myf MyFlags) { return my_pwrite(info->dfile, Buffer, Count, offset, MyFlags); } -int _mi_write_dynamic_record(MI_INFO *info, const byte *record) +int _mi_write_dynamic_record(MI_INFO *info, const uchar *record) { ulong reclength=_mi_rec_pack(info,info->rec_buff,record); return (write_dynamic_record(info,info->rec_buff,reclength)); } -int _mi_update_dynamic_record(MI_INFO *info, my_off_t pos, const byte *record) +int _mi_update_dynamic_record(MI_INFO *info, my_off_t pos, const uchar *record) { uint length=_mi_rec_pack(info,info->rec_buff,record); return (update_dynamic_record(info,pos,info->rec_buff,length)); } -int _mi_write_blob_record(MI_INFO *info, const byte *record) +int _mi_write_blob_record(MI_INFO *info, const uchar *record) { - byte *rec_buff; + uchar *rec_buff; int error; ulong reclength,reclength2,extra; @@ -260,7 +260,7 @@ int _mi_write_blob_record(MI_INFO *info, const byte *record) return -1; } #endif - if (!(rec_buff=(byte*) my_alloca(reclength))) + if (!(rec_buff=(uchar*) my_alloca(reclength))) { my_errno= HA_ERR_OUT_OF_MEM; /* purecov: inspected */ return(-1); @@ -277,9 +277,9 @@ int _mi_write_blob_record(MI_INFO *info, const byte *record) } -int _mi_update_blob_record(MI_INFO *info, my_off_t pos, const byte *record) +int _mi_update_blob_record(MI_INFO *info, my_off_t pos, const uchar *record) { - byte *rec_buff; + uchar *rec_buff; int error; ulong reclength,extra; @@ -294,7 +294,7 @@ int _mi_update_blob_record(MI_INFO *info, my_off_t pos, const byte *record) return -1; } #endif - if (!(rec_buff=(byte*) my_alloca(reclength))) + if (!(rec_buff=(uchar*) my_alloca(reclength))) { my_errno= HA_ERR_OUT_OF_MEM; /* purecov: inspected */ return(-1); @@ -317,7 +317,7 @@ int _mi_delete_dynamic_record(MI_INFO *info) /* Write record to data-file */ -static int write_dynamic_record(MI_INFO *info, const byte *record, +static int write_dynamic_record(MI_INFO *info, const uchar *record, ulong reclength) { int flag; @@ -333,7 +333,7 @@ static int write_dynamic_record(MI_INFO *info, const byte *record, if (_mi_write_part_record(info,filepos,length, (info->append_insert_at_end ? HA_OFFSET_ERROR : info->s->state.dellink), - (byte**) &record,&reclength,&flag)) + (uchar**) &record,&reclength,&flag)) goto err; } while (reclength); @@ -543,7 +543,7 @@ static int delete_dynamic_record(MI_INFO *info, my_off_t filepos, bfill(block_info.header+12,8,255); else mi_sizestore(block_info.header+12,block_info.next_filepos); - if (info->s->file_write(info,(byte*) block_info.header,20,filepos, + if (info->s->file_write(info,(uchar*) block_info.header,20,filepos, MYF(MY_NABP))) DBUG_RETURN(1); info->s->state.dellink = filepos; @@ -566,12 +566,12 @@ int _mi_write_part_record(MI_INFO *info, my_off_t filepos, /* points at empty block */ ulong length, /* length of block */ my_off_t next_filepos,/* Next empty block */ - byte **record, /* pointer to record ptr */ + uchar **record, /* pointer to record ptr */ ulong *reclength, /* length of *record */ int *flag) /* *flag == 0 if header */ { ulong head_length,res_length,extra_length,long_block,del_length; - byte *pos,*record_end; + uchar *pos,*record_end; my_off_t next_delete_block; uchar temp[MI_SPLIT_LENGTH+MI_DYN_DELETE_BLOCK_HEADER]; DBUG_ENTER("_mi_write_part_record"); @@ -615,7 +615,7 @@ int _mi_write_part_record(MI_INFO *info, temp[0]=13; mi_int4store(temp+1,*reclength); mi_int3store(temp+5,length-head_length); - mi_sizestore((byte*) temp+8,next_filepos); + mi_sizestore((uchar*) temp+8,next_filepos); } else { @@ -625,13 +625,13 @@ int _mi_write_part_record(MI_INFO *info, { mi_int3store(temp+1,*reclength); mi_int3store(temp+4,length-head_length); - mi_sizestore((byte*) temp+7,next_filepos); + mi_sizestore((uchar*) temp+7,next_filepos); } else { mi_int2store(temp+1,*reclength); mi_int2store(temp+3,length-head_length); - mi_sizestore((byte*) temp+5,next_filepos); + mi_sizestore((uchar*) temp+5,next_filepos); } } } @@ -642,12 +642,12 @@ int _mi_write_part_record(MI_INFO *info, if (long_block) { mi_int3store(temp+1,length-head_length); - mi_sizestore((byte*) temp+4,next_filepos); + mi_sizestore((uchar*) temp+4,next_filepos); } else { mi_int2store(temp+1,length-head_length); - mi_sizestore((byte*) temp+3,next_filepos); + mi_sizestore((uchar*) temp+3,next_filepos); } } } @@ -668,14 +668,14 @@ int _mi_write_part_record(MI_INFO *info, } length= *reclength+head_length; /* Write only what is needed */ } - DBUG_DUMP("header",(byte*) temp,head_length); + DBUG_DUMP("header",(uchar*) temp,head_length); /* Make a long block for one write */ record_end= *record+length-head_length; del_length=(res_length ? MI_DYN_DELETE_BLOCK_HEADER : 0); - bmove((byte*) (*record-head_length),(byte*) temp,head_length); + bmove((uchar*) (*record-head_length),(uchar*) temp,head_length); memcpy(temp,record_end,(size_t) (extra_length+del_length)); - bzero((byte*) record_end,extra_length); + bzero((uchar*) record_end,extra_length); if (res_length) { @@ -715,18 +715,18 @@ int _mi_write_part_record(MI_INFO *info, if (info->update & HA_STATE_EXTEND_BLOCK) { info->update&= ~HA_STATE_EXTEND_BLOCK; - if (my_block_write(&info->rec_cache,(byte*) *record-head_length, + if (my_block_write(&info->rec_cache,(uchar*) *record-head_length, length+extra_length+del_length,filepos)) goto err; } - else if (my_b_write(&info->rec_cache,(byte*) *record-head_length, + else if (my_b_write(&info->rec_cache,(uchar*) *record-head_length, length+extra_length+del_length)) goto err; } else { info->rec_cache.seek_not_done=1; - if (info->s->file_write(info,(byte*) *record-head_length,length+extra_length+ + if (info->s->file_write(info,(uchar*) *record-head_length,length+extra_length+ del_length,filepos,info->s->write_flag)) goto err; } @@ -752,7 +752,7 @@ err: /* update record from datafile */ -static int update_dynamic_record(MI_INFO *info, my_off_t filepos, byte *record, +static int update_dynamic_record(MI_INFO *info, my_off_t filepos, uchar *record, ulong reclength) { int flag; @@ -836,7 +836,7 @@ static int update_dynamic_record(MI_INFO *info, my_off_t filepos, byte *record, mi_int3store(del_block.header+1, rest_length); mi_sizestore(del_block.header+4,info->s->state.dellink); bfill(del_block.header+12,8,255); - if (info->s->file_write(info,(byte*) del_block.header,20, next_pos, + if (info->s->file_write(info,(uchar*) del_block.header,20, next_pos, MYF(MY_NABP))) DBUG_RETURN(1); info->s->state.dellink= next_pos; @@ -875,10 +875,11 @@ err: /* Pack a record. Return new reclength */ -uint _mi_rec_pack(MI_INFO *info, register byte *to, register const byte *from) +uint _mi_rec_pack(MI_INFO *info, register uchar *to, + register const uchar *from) { uint length,new_length,flag,bit,i; - char *pos,*end,*startpos,*packpos; + uchar *pos,*end,*startpos,*packpos; enum en_fieldtype type; reg3 MI_COLUMNDEF *rec; MI_BLOB *blob; @@ -901,7 +902,7 @@ uint _mi_rec_pack(MI_INFO *info, register byte *to, register const byte *from) { char *temp_pos; size_t tmp_length=length-mi_portable_sizeof_char_ptr; - memcpy((byte*) to,from,tmp_length); + memcpy((uchar*) to,from,tmp_length); memcpy_fixed(&temp_pos,from+tmp_length,sizeof(char*)); memcpy(to+tmp_length,temp_pos,(size_t) blob->length); to+=tmp_length+blob->length; @@ -910,17 +911,17 @@ uint _mi_rec_pack(MI_INFO *info, register byte *to, register const byte *from) } else if (type == FIELD_SKIP_ZERO) { - if (memcmp((byte*) from,zero_string,length) == 0) + if (memcmp((uchar*) from,zero_string,length) == 0) flag|=bit; else { - memcpy((byte*) to,from,(size_t) length); to+=length; + memcpy((uchar*) to,from,(size_t) length); to+=length; } } else if (type == FIELD_SKIP_ENDSPACE || type == FIELD_SKIP_PRESPACE) { - pos= (byte*) from; end= (byte*) from + length; + pos= (uchar*) from; end= (uchar*) from + length; if (type == FIELD_SKIP_ENDSPACE) { /* Pack trailing spaces */ while (end > from && *(end-1) == ' ') @@ -943,7 +944,7 @@ uint _mi_rec_pack(MI_INFO *info, register byte *to, register const byte *from) } else *to++= (char) new_length; - memcpy((byte*) to,pos,(size_t) new_length); to+=new_length; + memcpy((uchar*) to,pos,(size_t) new_length); to+=new_length; flag|=bit; } else @@ -1000,11 +1001,11 @@ uint _mi_rec_pack(MI_INFO *info, register byte *to, register const byte *from) Returns 0 if record is ok. */ -my_bool _mi_rec_check(MI_INFO *info,const char *record, byte *rec_buff, +my_bool _mi_rec_check(MI_INFO *info,const uchar *record, uchar *rec_buff, ulong packed_length, my_bool with_checksum) { uint length,new_length,flag,bit,i; - char *pos,*end,*packpos,*to; + uchar *pos,*end,*packpos,*to; enum en_fieldtype type; reg3 MI_COLUMNDEF *rec; DBUG_ENTER("_mi_rec_check"); @@ -1029,7 +1030,7 @@ my_bool _mi_rec_check(MI_INFO *info,const char *record, byte *rec_buff, } else if (type == FIELD_SKIP_ZERO) { - if (memcmp((byte*) record,zero_string,length) == 0) + if (memcmp((uchar*) record,zero_string,length) == 0) { if (!(flag & bit)) goto err; @@ -1040,7 +1041,7 @@ my_bool _mi_rec_check(MI_INFO *info,const char *record, byte *rec_buff, else if (type == FIELD_SKIP_ENDSPACE || type == FIELD_SKIP_PRESPACE) { - pos= (byte*) record; end= (byte*) record + length; + pos= (uchar*) record; end= (uchar*) record + length; if (type == FIELD_SKIP_ENDSPACE) { /* Pack trailing spaces */ while (end > record && *(end-1) == ' ') @@ -1122,12 +1123,12 @@ err: /* Returns -1 and my_errno =HA_ERR_RECORD_DELETED if reclength isn't */ /* right. Returns reclength (>0) if ok */ -ulong _mi_rec_unpack(register MI_INFO *info, register byte *to, byte *from, +ulong _mi_rec_unpack(register MI_INFO *info, register uchar *to, uchar *from, ulong found_length) { uint flag,bit,length,rec_length,min_pack_length; enum en_fieldtype type; - byte *from_end,*to_end,*packpos; + uchar *from_end,*to_end,*packpos; reg3 MI_COLUMNDEF *rec,*end_field; DBUG_ENTER("_mi_rec_unpack"); @@ -1173,7 +1174,7 @@ ulong _mi_rec_unpack(register MI_INFO *info, register byte *to, byte *from, if (flag & bit) { if (type == FIELD_BLOB || type == FIELD_SKIP_ZERO) - bzero((byte*) to,rec_length); + bzero((uchar*) to,rec_length); else if (type == FIELD_SKIP_ENDSPACE || type == FIELD_SKIP_PRESPACE) { @@ -1195,13 +1196,13 @@ ulong _mi_rec_unpack(register MI_INFO *info, register byte *to, byte *from, goto err; if (type == FIELD_SKIP_ENDSPACE) { - memcpy(to,(byte*) from,(size_t) length); - bfill((byte*) to+length,rec_length-length,' '); + memcpy(to,(uchar*) from,(size_t) length); + bfill((uchar*) to+length,rec_length-length,' '); } else { - bfill((byte*) to,rec_length-length,' '); - memcpy(to+rec_length-length,(byte*) from,(size_t) length); + bfill((uchar*) to,rec_length-length,' '); + memcpy(to+rec_length-length,(uchar*) from,(size_t) length); } from+=length; } @@ -1215,9 +1216,9 @@ ulong _mi_rec_unpack(register MI_INFO *info, register byte *to, byte *from, from_left - size_length < blob_length || from_left - size_length - blob_length < min_pack_length) goto err; - memcpy((byte*) to,(byte*) from,(size_t) size_length); + memcpy((uchar*) to,(uchar*) from,(size_t) size_length); from+=size_length; - memcpy_fixed((byte*) to+size_length,(byte*) &from,sizeof(char*)); + memcpy_fixed((uchar*) to+size_length,(uchar*) &from,sizeof(char*)); from+=blob_length; } else @@ -1226,7 +1227,7 @@ ulong _mi_rec_unpack(register MI_INFO *info, register byte *to, byte *from, min_pack_length--; if (min_pack_length + rec_length > (uint) (from_end - from)) goto err; - memcpy(to,(byte*) from,(size_t) rec_length); from+=rec_length; + memcpy(to,(uchar*) from,(size_t) rec_length); from+=rec_length; } if ((bit= bit << 1) >= 256) { @@ -1238,7 +1239,7 @@ ulong _mi_rec_unpack(register MI_INFO *info, register byte *to, byte *from, if (min_pack_length > (uint) (from_end - from)) goto err; min_pack_length-=rec_length; - memcpy(to, (byte*) from, (size_t) rec_length); + memcpy(to, (uchar*) from, (size_t) rec_length); from+=rec_length; } } @@ -1251,14 +1252,14 @@ err: my_errno= HA_ERR_WRONG_IN_RECORD; DBUG_PRINT("error",("to_end: 0x%lx -> 0x%lx from_end: 0x%lx -> 0x%lx", (long) to, (long) to_end, (long) from, (long) from_end)); - DBUG_DUMP("from",(byte*) info->rec_buff,info->s->base.min_pack_length); + DBUG_DUMP("from",(uchar*) info->rec_buff,info->s->base.min_pack_length); DBUG_RETURN(MY_FILE_ERROR); } /* _mi_rec_unpack */ /* Calc length of blob. Update info in blobs->length */ -ulong _my_calc_total_blob_length(MI_INFO *info, const byte *record) +ulong _my_calc_total_blob_length(MI_INFO *info, const uchar *record) { ulong length; MI_BLOB *blob,*end; @@ -1274,7 +1275,7 @@ ulong _my_calc_total_blob_length(MI_INFO *info, const byte *record) } -ulong _mi_calc_blob_length(uint length, const byte *pos) +ulong _mi_calc_blob_length(uint length, const uchar *pos) { switch (length) { case 1: @@ -1292,7 +1293,7 @@ ulong _mi_calc_blob_length(uint length, const byte *pos) } -void _my_store_blob_length(byte *pos,uint pack_length,uint length) +void _my_store_blob_length(uchar *pos,uint pack_length,uint length) { switch (pack_length) { case 1: @@ -1345,11 +1346,11 @@ void _my_store_blob_length(byte *pos,uint pack_length,uint length) -1 Error */ -int _mi_read_dynamic_record(MI_INFO *info, my_off_t filepos, byte *buf) +int _mi_read_dynamic_record(MI_INFO *info, my_off_t filepos, uchar *buf) { int block_of_record; uint b_type,left_length; - byte *to; + uchar *to; MI_BLOCK_INFO block_info; File file; DBUG_ENTER("mi_read_dynamic_record"); @@ -1405,7 +1406,7 @@ int _mi_read_dynamic_record(MI_INFO *info, my_off_t filepos, byte *buf) prefetch_len= block_info.data_len; if (prefetch_len) { - memcpy((byte*) to, block_info.header + offset, prefetch_len); + memcpy((uchar*) to, block_info.header + offset, prefetch_len); block_info.data_len-= prefetch_len; left_length-= prefetch_len; to+= prefetch_len; @@ -1423,7 +1424,7 @@ int _mi_read_dynamic_record(MI_INFO *info, my_off_t filepos, byte *buf) there is no equivalent without seeking. We are at the right position already. :( */ - if (info->s->file_read(info, (byte*) to, block_info.data_len, + if (info->s->file_read(info, (uchar*) to, block_info.data_len, filepos, MYF(MY_NABP))) goto panic; left_length-=block_info.data_len; @@ -1450,9 +1451,9 @@ err: /* compare unique constraint between stored rows */ int _mi_cmp_dynamic_unique(MI_INFO *info, MI_UNIQUEDEF *def, - const byte *record, my_off_t pos) + const uchar *record, my_off_t pos) { - byte *rec_buff,*old_record; + uchar *rec_buff,*old_record; int error; DBUG_ENTER("_mi_cmp_dynamic_unique"); @@ -1478,11 +1479,11 @@ int _mi_cmp_dynamic_unique(MI_INFO *info, MI_UNIQUEDEF *def, /* Compare of record one disk with packed record in memory */ -int _mi_cmp_dynamic_record(register MI_INFO *info, register const byte *record) +int _mi_cmp_dynamic_record(register MI_INFO *info, register const uchar *record) { uint flag,reclength,b_type; my_off_t filepos; - byte *buffer; + uchar *buffer; MI_BLOCK_INFO block_info; DBUG_ENTER("_mi_cmp_dynamic_record"); @@ -1504,7 +1505,7 @@ int _mi_cmp_dynamic_record(register MI_INFO *info, register const byte *record) { /* If check isn't disabled */ if (info->s->base.blobs) { - if (!(buffer=(byte*) my_alloca(info->s->base.pack_reclength+ + if (!(buffer=(uchar*) my_alloca(info->s->base.pack_reclength+ _my_calc_total_blob_length(info,record)))) DBUG_RETURN(-1); } @@ -1552,14 +1553,14 @@ int _mi_cmp_dynamic_record(register MI_INFO *info, register const byte *record) my_errno=0; err: if (buffer != info->rec_buff) - my_afree((gptr) buffer); + my_afree((uchar*) buffer); DBUG_RETURN(my_errno); } /* Compare file to buffert */ -static int _mi_cmp_buffer(File file, const byte *buff, my_off_t filepos, +static int _mi_cmp_buffer(File file, const uchar *buff, my_off_t filepos, uint length) { uint next_length; @@ -1571,7 +1572,7 @@ static int _mi_cmp_buffer(File file, const byte *buff, my_off_t filepos, while (length > IO_SIZE*2) { if (my_pread(file,temp_buff,next_length,filepos, MYF(MY_NABP)) || - memcmp((byte*) buff,temp_buff,next_length)) + memcmp((uchar*) buff,temp_buff,next_length)) goto err; filepos+=next_length; buff+=next_length; @@ -1580,7 +1581,7 @@ static int _mi_cmp_buffer(File file, const byte *buff, my_off_t filepos, } if (my_pread(file,temp_buff,length,filepos,MYF(MY_NABP))) goto err; - DBUG_RETURN(memcmp((byte*) buff,temp_buff,length)); + DBUG_RETURN(memcmp((uchar*) buff,temp_buff,length)); err: DBUG_RETURN(1); } @@ -1620,13 +1621,13 @@ err: != 0 Error */ -int _mi_read_rnd_dynamic_record(MI_INFO *info, byte *buf, +int _mi_read_rnd_dynamic_record(MI_INFO *info, uchar *buf, register my_off_t filepos, my_bool skip_deleted_blocks) { int block_of_record, info_read, save_errno; uint left_len,b_type; - byte *to; + uchar *to; MI_BLOCK_INFO block_info; MYISAM_SHARE *share=info->s; DBUG_ENTER("_mi_read_rnd_dynamic_record"); @@ -1672,7 +1673,7 @@ int _mi_read_rnd_dynamic_record(MI_INFO *info, byte *buf, } if (info->opt_flag & READ_CACHE_USED) { - if (_mi_read_cache(&info->rec_cache,(byte*) block_info.header,filepos, + if (_mi_read_cache(&info->rec_cache,(uchar*) block_info.header,filepos, sizeof(block_info.header), (!block_of_record && skip_deleted_blocks ? READING_NEXT : 0) | READING_HEADER)) @@ -1735,7 +1736,7 @@ int _mi_read_rnd_dynamic_record(MI_INFO *info, byte *buf, tmp_length= block_info.data_len; if (tmp_length) { - memcpy((byte*) to, block_info.header+offset,tmp_length); + memcpy((uchar*) to, block_info.header+offset,tmp_length); block_info.data_len-=tmp_length; left_len-=tmp_length; to+=tmp_length; @@ -1747,7 +1748,7 @@ int _mi_read_rnd_dynamic_record(MI_INFO *info, byte *buf, { if (info->opt_flag & READ_CACHE_USED) { - if (_mi_read_cache(&info->rec_cache,(byte*) to,filepos, + if (_mi_read_cache(&info->rec_cache,(uchar*) to,filepos, block_info.data_len, (!block_of_record && skip_deleted_blocks) ? READING_NEXT : 0)) @@ -1761,7 +1762,7 @@ int _mi_read_rnd_dynamic_record(MI_INFO *info, byte *buf, flush_io_cache(&info->rec_cache)) goto err; /* VOID(my_seek(info->dfile,filepos,MY_SEEK_SET,MYF(0))); */ - if (my_read(info->dfile,(byte*) to,block_info.data_len,MYF(MY_NABP))) + if (my_read(info->dfile,(uchar*) to,block_info.data_len,MYF(MY_NABP))) { if (my_errno == -1) my_errno= HA_ERR_WRONG_IN_RECORD; /* Unexpected end of file */ @@ -1818,7 +1819,7 @@ uint _mi_get_block_info(MI_BLOCK_INFO *info, File file, my_off_t filepos) sizeof(info->header)) goto err; } - DBUG_DUMP("header",(byte*) header,MI_BLOCK_INFO_HEADER_LENGTH); + DBUG_DUMP("header",(uchar*) header,MI_BLOCK_INFO_HEADER_LENGTH); if (info->second_read) { if (info->header[0] <= 6 || info->header[0] == 13) diff --git a/storage/myisam/mi_extra.c b/storage/myisam/mi_extra.c index 729174b6f88..72c40741a22 100644 --- a/storage/myisam/mi_extra.c +++ b/storage/myisam/mi_extra.c @@ -180,8 +180,8 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) case HA_EXTRA_KEYREAD: /* Read only keys to record */ case HA_EXTRA_REMEMBER_POS: info->opt_flag |= REMEMBER_OLD_POS; - bmove((byte*) info->lastkey+share->base.max_key_length*2, - (byte*) info->lastkey,info->lastkey_length); + bmove((uchar*) info->lastkey+share->base.max_key_length*2, + (uchar*) info->lastkey,info->lastkey_length); info->save_update= info->update; info->save_lastinx= info->lastinx; info->save_lastpos= info->lastpos; @@ -197,8 +197,8 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) case HA_EXTRA_RESTORE_POS: if (info->opt_flag & REMEMBER_OLD_POS) { - bmove((byte*) info->lastkey, - (byte*) info->lastkey+share->base.max_key_length*2, + bmove((uchar*) info->lastkey, + (uchar*) info->lastkey+share->base.max_key_length*2, info->save_lastkey_length); info->update= info->save_update | HA_STATE_WRITTEN; info->lastinx= info->save_lastinx; @@ -385,7 +385,7 @@ int mi_extra(MI_INFO *info, enum ha_extra_function function, void *extra_arg) { char tmp[1]; tmp[0]=function; - myisam_log_command(MI_LOG_EXTRA,info,(byte*) tmp,1,error); + myisam_log_command(MI_LOG_EXTRA,info,(uchar*) tmp,1,error); } DBUG_RETURN(error); } /* mi_extra */ diff --git a/storage/myisam/mi_key.c b/storage/myisam/mi_key.c index 2f4915dec39..230ebac3bb0 100644 --- a/storage/myisam/mi_key.c +++ b/storage/myisam/mi_key.c @@ -31,7 +31,7 @@ set_if_smaller(char_length,length); \ } while(0) -static int _mi_put_key_in_record(MI_INFO *info,uint keynr,byte *record); +static int _mi_put_key_in_record(MI_INFO *info,uint keynr,uchar *record); /* Make a intern key from a record @@ -49,9 +49,9 @@ static int _mi_put_key_in_record(MI_INFO *info,uint keynr,byte *record); */ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, - const byte *record, my_off_t filepos) + const uchar *record, my_off_t filepos) { - byte *pos; + uchar *pos; uchar *start; reg1 HA_KEYSEG *keyseg; my_bool is_ft= info->s->keyinfo[keynr].flag & HA_FULLTEXT; @@ -90,7 +90,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, char_length= ((!is_ft && cs && cs->mbmaxlen > 1) ? length/cs->mbmaxlen : length); - pos= (byte*) record+keyseg->start; + pos= (uchar*) record+keyseg->start; if (type == HA_KEYTYPE_BIT) { if (keyseg->bit_length) @@ -100,7 +100,7 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, *key++= bits; length--; } - memcpy((byte*) key, pos, length); + memcpy((uchar*) key, pos, length); key+= length; continue; } @@ -112,14 +112,14 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, } else { - byte *end= pos + length; + uchar *end= pos + length; while (pos < end && pos[0] == ' ') pos++; length=(uint) (end-pos); } FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); - memcpy((byte*) key,(byte*) pos,(size_t) char_length); + memcpy((uchar*) key,(uchar*) pos,(size_t) char_length); key+=char_length; continue; } @@ -132,18 +132,18 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, set_if_smaller(length,tmp_length); FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); - memcpy((byte*) key,(byte*) pos,(size_t) char_length); + memcpy((uchar*) key,(uchar*) pos,(size_t) char_length); key+= char_length; continue; } else if (keyseg->flag & HA_BLOB_PART) { uint tmp_length=_mi_calc_blob_length(keyseg->bit_start,pos); - memcpy_fixed((byte*) &pos,pos+keyseg->bit_start,sizeof(char*)); + memcpy_fixed((uchar*) &pos,pos+keyseg->bit_start,sizeof(char*)); set_if_smaller(length,tmp_length); FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); - memcpy((byte*) key,(byte*) pos,(size_t) char_length); + memcpy((uchar*) key,(uchar*) pos,(size_t) char_length); key+= char_length; continue; } @@ -182,14 +182,14 @@ uint _mi_make_key(register MI_INFO *info, uint keynr, uchar *key, continue; } FIX_LENGTH(cs, pos, length, char_length); - memcpy((byte*) key, pos, char_length); + memcpy((uchar*) key, pos, char_length); if (length > char_length) cs->cset->fill(cs, (char*) key+char_length, length-char_length, ' '); key+= length; } _mi_dpointer(info,key,filepos); DBUG_PRINT("exit",("keynr: %d",keynr)); - DBUG_DUMP("key",(byte*) start,(uint) (key-start)+keyseg->length); + DBUG_DUMP("key",(uchar*) start,(uint) (key-start)+keyseg->length); DBUG_EXECUTE("key", _mi_print_key(DBUG_FILE,info->s->keyinfo[keynr].seg,start, (uint) (key-start));); @@ -267,7 +267,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, length=(uint) (end-pos); FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); - memcpy((byte*) key,pos,(size_t) char_length); + memcpy((uchar*) key,pos,(size_t) char_length); key+= char_length; continue; } @@ -280,7 +280,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, FIX_LENGTH(cs, pos, length, char_length); store_key_length_inc(key,char_length); old+=2; /* Skip length */ - memcpy((byte*) key, pos,(size_t) char_length); + memcpy((uchar*) key, pos,(size_t) char_length); key+= char_length; continue; } @@ -292,7 +292,7 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, continue; } FIX_LENGTH(cs, pos, length, char_length); - memcpy((byte*) key, pos, char_length); + memcpy((uchar*) key, pos, char_length); if (length > char_length) cs->cset->fill(cs, (char*) key+char_length, length-char_length, ' '); key+= length; @@ -325,16 +325,16 @@ uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, */ static int _mi_put_key_in_record(register MI_INFO *info, uint keynr, - byte *record) + uchar *record) { - reg2 byte *key; - byte *pos,*key_end; + reg2 uchar *key; + uchar *pos,*key_end; reg1 HA_KEYSEG *keyseg; - byte *blob_ptr; + uchar *blob_ptr; DBUG_ENTER("_mi_put_key_in_record"); - blob_ptr= (byte*) info->lastkey2; /* Place to put blob parts */ - key=(byte*) info->lastkey; /* KEy that was read */ + blob_ptr= (uchar*) info->lastkey2; /* Place to put blob parts */ + key=(uchar*) info->lastkey; /* KEy that was read */ key_end=key+info->lastkey_length; for (keyseg=info->s->keyinfo[keynr].seg ; keyseg->type ;keyseg++) { @@ -363,7 +363,7 @@ static int _mi_put_key_in_record(register MI_INFO *info, uint keynr, clr_rec_bits(record + keyseg->bit_pos, keyseg->bit_start, keyseg->bit_length); } - memcpy(record + keyseg->start, (byte*) key, length); + memcpy(record + keyseg->start, (uchar*) key, length); key+= length; continue; } @@ -406,7 +406,7 @@ static int _mi_put_key_in_record(register MI_INFO *info, uint keynr, else int2store(record+keyseg->start, length); /* And key data */ - memcpy(record+keyseg->start + keyseg->bit_start, (byte*) key, length); + memcpy(record+keyseg->start + keyseg->bit_start, (uchar*) key, length); key+= length; } else if (keyseg->flag & HA_BLOB_PART) @@ -431,8 +431,8 @@ static int _mi_put_key_in_record(register MI_INFO *info, uint keynr, } else if (keyseg->flag & HA_SWAP_KEY) { - byte *to= record+keyseg->start+keyseg->length; - byte *end= key+keyseg->length; + uchar *to= record+keyseg->start+keyseg->length; + uchar *end= key+keyseg->length; #ifdef CHECK_KEYS if (end > key_end) goto err; @@ -449,7 +449,7 @@ static int _mi_put_key_in_record(register MI_INFO *info, uint keynr, if (key+keyseg->length > key_end) goto err; #endif - memcpy(record+keyseg->start,(byte*) key, + memcpy(record+keyseg->start,(uchar*) key, (size_t) keyseg->length); key+= keyseg->length; } @@ -463,7 +463,7 @@ err: /* Here when key reads are used */ -int _mi_read_key_record(MI_INFO *info, my_off_t filepos, byte *buf) +int _mi_read_key_record(MI_INFO *info, my_off_t filepos, uchar *buf) { fast_mi_writeinfo(info); if (filepos != HA_OFFSET_ERROR) @@ -498,7 +498,7 @@ int _mi_read_key_record(MI_INFO *info, my_off_t filepos, byte *buf) less than zero. */ -ulonglong retrieve_auto_increment(MI_INFO *info,const byte *record) +ulonglong retrieve_auto_increment(MI_INFO *info,const uchar *record) { ulonglong value= 0; /* Store unsigned values here */ longlong s_value= 0; /* Store signed values here */ diff --git a/storage/myisam/mi_locking.c b/storage/myisam/mi_locking.c index e822ea9e6da..6aa62b70ae3 100644 --- a/storage/myisam/mi_locking.c +++ b/storage/myisam/mi_locking.c @@ -254,7 +254,7 @@ int mi_lock_database(MI_INFO *info, int lock_type) pthread_mutex_unlock(&share->intern_lock); #if defined(FULL_LOG) || defined(_lint) lock_type|=(int) (flag << 8); /* Set bit to set if real lock */ - myisam_log_command(MI_LOG_LOCK,info,(byte*) &lock_type,sizeof(lock_type), + myisam_log_command(MI_LOG_LOCK,info,(uchar*) &lock_type,sizeof(lock_type), error); #endif DBUG_RETURN(error); diff --git a/storage/myisam/mi_log.c b/storage/myisam/mi_log.c index f720f752a06..91d3bb6f702 100644 --- a/storage/myisam/mi_log.c +++ b/storage/myisam/mi_log.c @@ -74,7 +74,7 @@ int mi_log(int activate_log) /* All logs starts with command(1) dfile(2) process(4) result(2) */ void _myisam_log(enum myisam_log_commands command, MI_INFO *info, - const byte *buffert, uint length) + const uchar *buffert, uint length) { char buff[11]; int error,old_errno; @@ -98,7 +98,7 @@ void _myisam_log(enum myisam_log_commands command, MI_INFO *info, void _myisam_log_command(enum myisam_log_commands command, MI_INFO *info, - const byte *buffert, uint length, int result) + const uchar *buffert, uint length, int result) { char buff[9]; int error,old_errno; @@ -122,7 +122,7 @@ void _myisam_log_command(enum myisam_log_commands command, MI_INFO *info, void _myisam_log_record(enum myisam_log_commands command, MI_INFO *info, - const byte *record, my_off_t filepos, int result) + const uchar *record, my_off_t filepos, int result) { char buff[21],*pos; int error,old_errno; @@ -143,7 +143,7 @@ void _myisam_log_record(enum myisam_log_commands command, MI_INFO *info, pthread_mutex_lock(&THR_LOCK_myisam); error=my_lock(myisam_log_file,F_WRLCK,0L,F_TO_EOF,MYF(MY_SEEK_NOT_DONE)); VOID(my_write(myisam_log_file,buff,sizeof(buff),MYF(0))); - VOID(my_write(myisam_log_file,(byte*) record,info->s->base.reclength,MYF(0))); + VOID(my_write(myisam_log_file,(uchar*) record,info->s->base.reclength,MYF(0))); if (info->s->base.blobs) { MI_BLOB *blob,*end; diff --git a/storage/myisam/mi_open.c b/storage/myisam/mi_open.c index f4e089b6313..9ff8ecdb14d 100644 --- a/storage/myisam/mi_open.c +++ b/storage/myisam/mi_open.c @@ -92,7 +92,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) lock_error=1; errpos=0; head_length=sizeof(share_buff.state.header); - bzero((byte*) &info,sizeof(info)); + bzero((uchar*) &info,sizeof(info)); my_realpath(name_buff, fn_format(org_name,name,"",MI_NAME_IEXT, MY_UNPACK_FILENAME),MYF(0)); @@ -100,7 +100,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) if (!(old_info=test_if_reopen(name_buff))) { share= &share_buff; - bzero((gptr) &share_buff,sizeof(share_buff)); + bzero((uchar*) &share_buff,sizeof(share_buff)); share_buff.state.rec_per_key_part=rec_per_key_part; share_buff.state.key_root=key_root; share_buff.state.key_del=key_del; @@ -127,8 +127,8 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) my_errno= HA_ERR_NOT_A_TABLE; goto err; } - if (memcmp((byte*) share->state.header.file_version, - (byte*) myisam_file_magic, 4)) + if (memcmp((uchar*) share->state.header.file_version, + (uchar*) myisam_file_magic, 4)) { DBUG_PRINT("error",("Wrong header in %s",name_buff)); DBUG_DUMP("error_dump",(char*) share->state.header.file_version, @@ -504,7 +504,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) } else if (share->options & HA_OPTION_PACK_RECORD) share->data_file_type = DYNAMIC_RECORD; - my_afree((gptr) disk_cache); + my_afree((uchar*) disk_cache); mi_setup_functions(share); share->is_log_table= FALSE; #ifdef THREAD @@ -642,7 +642,7 @@ MI_INFO *mi_open(const char *name, int mode, uint open_flags) if (myisam_log_file >= 0) { intern_filename(name_buff,share->index_file_name); - _myisam_log(MI_LOG_OPEN,m_info,name_buff,(uint) strlen(name_buff)); + _myisam_log(MI_LOG_OPEN, m_info,name_buff, strlen(name_buff)); } DBUG_RETURN(m_info); @@ -654,7 +654,7 @@ err: mi_report_error(save_errno, name); switch (errpos) { case 6: - my_free((gptr) m_info,MYF(0)); + my_free((uchar*) m_info,MYF(0)); /* fall through */ case 5: VOID(my_close(info.dfile,MYF(0))); @@ -662,14 +662,14 @@ err: break; /* Don't remove open table */ /* fall through */ case 4: - my_free((gptr) share,MYF(0)); + my_free((uchar*) share,MYF(0)); /* fall through */ case 3: if (! lock_error) VOID(my_lock(kfile, F_UNLCK, 0L, F_TO_EOF, MYF(MY_SEEK_NOT_DONE))); /* fall through */ case 2: - my_afree((gptr) disk_cache); + my_afree((uchar*) disk_cache); /* fall through */ case 1: VOID(my_close(kfile,MYF(0))); @@ -684,7 +684,7 @@ err: } /* mi_open */ -byte *mi_alloc_rec_buff(MI_INFO *info, ulong length, byte **buf) +uchar *mi_alloc_rec_buff(MI_INFO *info, ulong length, uchar **buf) { uint extra; uint32 old_length; @@ -692,7 +692,7 @@ byte *mi_alloc_rec_buff(MI_INFO *info, ulong length, byte **buf) if (! *buf || length > (old_length=mi_get_rec_buff_len(info, *buf))) { - byte *newptr = *buf; + uchar *newptr = *buf; /* to simplify initial init of info->rec_buf in mi_open and mi_extra */ if (length == (ulong) -1) @@ -709,7 +709,7 @@ byte *mi_alloc_rec_buff(MI_INFO *info, ulong length, byte **buf) MI_REC_BUFF_OFFSET : 0); if (extra && newptr) newptr-= MI_REC_BUFF_OFFSET; - if (!(newptr=(byte*) my_realloc((gptr)newptr, length+extra+8, + if (!(newptr=(uchar*) my_realloc((uchar*)newptr, length+extra+8, MYF(MY_ALLOW_ZERO_PTR)))) return newptr; *((uint32 *) newptr)= (uint32) length; @@ -899,10 +899,10 @@ uint mi_state_info_write(File file, MI_STATE_INFO *state, uint pWrite) } if (pWrite & 1) - DBUG_RETURN(my_pwrite(file,(char*) buff, (uint) (ptr-buff), 0L, - MYF(MY_NABP | MY_THREADSAFE))); - DBUG_RETURN(my_write(file, (char*) buff, (uint) (ptr-buff), - MYF(MY_NABP))); + DBUG_RETURN(my_pwrite(file, buff, (size_t) (ptr-buff), 0L, + MYF(MY_NABP | MY_THREADSAFE)) != 0); + DBUG_RETURN(my_write(file, buff, (size_t) (ptr-buff), + MYF(MY_NABP)) != 0); } @@ -968,10 +968,10 @@ uint mi_state_info_read_dsk(File file, MI_STATE_INFO *state, my_bool pRead) if (pRead) { if (my_pread(file, buff, state->state_length,0L, MYF(MY_NABP))) - return (MY_FILE_ERROR); + return 1; } else if (my_read(file, buff, state->state_length,MYF(MY_NABP))) - return (MY_FILE_ERROR); + return 1; mi_state_info_read((uchar*) buff, state); } return 0; @@ -1013,7 +1013,7 @@ uint mi_base_info_write(File file, MI_BASE_INFO *base) mi_int2store(ptr,base->raid_chunks); ptr +=2; mi_int4store(ptr,base->raid_chunksize); ptr +=4; bzero(ptr,6); ptr +=6; /* extra */ - return my_write(file,(char*) buff, (uint) (ptr-buff), MYF(MY_NABP)); + return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0; } @@ -1073,7 +1073,7 @@ uint mi_keydef_write(File file, MI_KEYDEF *keydef) mi_int2store(ptr,keydef->keylength); ptr +=2; mi_int2store(ptr,keydef->minlength); ptr +=2; mi_int2store(ptr,keydef->maxlength); ptr +=2; - return my_write(file,(char*) buff, (uint) (ptr-buff), MYF(MY_NABP)); + return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0; } char *mi_keydef_read(char *ptr, MI_KEYDEF *keydef) @@ -1117,7 +1117,7 @@ int mi_keyseg_write(File file, const HA_KEYSEG *keyseg) mi_int4store(ptr, pos); ptr+=4; - return my_write(file,(char*) buff, (uint) (ptr-buff), MYF(MY_NABP)); + return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0; } @@ -1157,7 +1157,7 @@ uint mi_uniquedef_write(File file, MI_UNIQUEDEF *def) *ptr++= (uchar) def->key; *ptr++ = (uchar) def->null_are_equal; - return my_write(file,(char*) buff, (uint) (ptr-buff), MYF(MY_NABP)); + return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0; } char *mi_uniquedef_read(char *ptr, MI_UNIQUEDEF *def) @@ -1181,7 +1181,7 @@ uint mi_recinfo_write(File file, MI_COLUMNDEF *recinfo) mi_int2store(ptr,recinfo->length); ptr +=2; *ptr++ = recinfo->null_bit; mi_int2store(ptr,recinfo->null_pos); ptr+= 2; - return my_write(file,(char*) buff, (uint) (ptr-buff), MYF(MY_NABP)); + return my_write(file, buff, (size_t) (ptr-buff), MYF(MY_NABP)) != 0; } char *mi_recinfo_read(char *ptr, MI_COLUMNDEF *recinfo) @@ -1202,7 +1202,8 @@ The argument file_to_dup is here for the future if there would on some OS exist a dup()-like call that would give us two different file descriptors. *************************************************************************/ -int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, File file_to_dup __attribute__((unused))) +int mi_open_datafile(MI_INFO *info, MYISAM_SHARE *share, + File file_to_dup __attribute__((unused))) { #ifdef USE_RAID if (share->base.raid_type) diff --git a/storage/myisam/mi_packrec.c b/storage/myisam/mi_packrec.c index a5a9aaededd..1231ef026f7 100644 --- a/storage/myisam/mi_packrec.c +++ b/storage/myisam/mi_packrec.c @@ -48,7 +48,7 @@ #define OFFSET_TABLE_SIZE 512 static uint read_huff_table(MI_BIT_BUFF *bit_buff,MI_DECODE_TREE *decode_tree, - uint16 **decode_table,byte **intervall_buff, + uint16 **decode_table,uchar **intervall_buff, uint16 *tmp_buff); static void make_quick_table(uint16 *to_table,uint16 *decode_table, uint *next_free,uint value,uint bits, @@ -107,7 +107,7 @@ static void fill_buffer(MI_BIT_BUFF *bit_buff); static uint max_bit(uint value); #ifdef HAVE_MMAP static uchar *_mi_mempack_get_block_info(MI_INFO *myisam, MI_BIT_BUFF *bit_buff, - MI_BLOCK_INFO *info, byte **rec_buff_p, + MI_BLOCK_INFO *info, uchar **rec_buff_p, uchar *header); #endif @@ -136,7 +136,8 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys) uint i,trees,huff_tree_bits,rec_reflength,length; uint16 *decode_table,*tmp_buff; ulong elements,intervall_length; - char *disk_cache,*intervall_buff; + char *disk_cache; + uchar *intervall_buff; uchar header[HEAD_LENGTH]; MYISAM_SHARE *share=info->s; MI_BIT_BUFF bit_buff; @@ -149,14 +150,14 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys) file=info->dfile; my_errno=0; - if (my_read(file,(byte*) header,sizeof(header),MYF(MY_NABP))) + if (my_read(file,(uchar*) header,sizeof(header),MYF(MY_NABP))) { if (!my_errno) my_errno=HA_ERR_END_OF_FILE; goto err0; } /* Only the first three bytes of magic number are independent of version. */ - if (memcmp((byte*) header, (byte*) myisam_pack_file_magic, 3)) + if (memcmp((uchar*) header, (uchar*) myisam_pack_file_magic, 3)) { my_errno=HA_ERR_WRONG_IN_RECORD; goto err0; @@ -195,10 +196,10 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys) */ if (!(share->decode_trees=(MI_DECODE_TREE*) my_malloc((uint) (trees*sizeof(MI_DECODE_TREE)+ - intervall_length*sizeof(byte)), + intervall_length*sizeof(uchar)), MYF(MY_WME)))) goto err0; - intervall_buff=(byte*) (share->decode_trees+trees); + intervall_buff=(uchar*) (share->decode_trees+trees); /* Memory segment #2: @@ -215,7 +216,7 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys) MYF(MY_WME | MY_ZEROFILL)))) goto err1; tmp_buff=share->decode_tables+length; - disk_cache=(byte*) (tmp_buff+OFFSET_TABLE_SIZE); + disk_cache=(uchar*) (tmp_buff+OFFSET_TABLE_SIZE); if (my_read(file,disk_cache, (uint) (share->pack.header_length-sizeof(header)), @@ -250,8 +251,8 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys) goto err3; /* Reallocate the decoding tables to the used size. */ decode_table=(uint16*) - my_realloc((gptr) share->decode_tables, - (uint) ((byte*) decode_table - (byte*) share->decode_tables), + my_realloc((uchar*) share->decode_tables, + (uint) ((uchar*) decode_table - (uchar*) share->decode_tables), MYF(MY_HOLD_ON_ERROR)); /* Fix the table addresses in the tree heads. */ { @@ -291,9 +292,9 @@ my_bool _mi_read_pack_info(MI_INFO *info, pbool fix_keys) err3: my_errno=HA_ERR_WRONG_IN_RECORD; err2: - my_free((gptr) share->decode_tables,MYF(0)); + my_free((uchar*) share->decode_tables,MYF(0)); err1: - my_free((gptr) share->decode_trees,MYF(0)); + my_free((uchar*) share->decode_trees,MYF(0)); err0: DBUG_RETURN(1); } @@ -318,7 +319,7 @@ err0: */ static uint read_huff_table(MI_BIT_BUFF *bit_buff, MI_DECODE_TREE *decode_tree, - uint16 **decode_table, byte **intervall_buff, + uint16 **decode_table, uchar **intervall_buff, uint16 *tmp_buff) { uint min_chr,elements,char_bits,offset_bits,size,intervall_length,table_bits, @@ -697,7 +698,7 @@ static uint find_longest_bitstream(uint16 *table, uint16 *end) HA_ERR_WRONG_IN_RECORD or -1 on error */ -int _mi_read_pack_record(MI_INFO *info, my_off_t filepos, byte *buf) +int _mi_read_pack_record(MI_INFO *info, my_off_t filepos, uchar *buf) { MI_BLOCK_INFO block_info; File file; @@ -710,7 +711,7 @@ int _mi_read_pack_record(MI_INFO *info, my_off_t filepos, byte *buf) if (_mi_pack_get_block_info(info, &info->bit_buff, &block_info, &info->rec_buff, file, filepos)) goto err; - if (my_read(file,(byte*) info->rec_buff + block_info.offset , + if (my_read(file,(uchar*) info->rec_buff + block_info.offset , block_info.rec_len - block_info.offset, MYF(MY_NABP))) goto panic; info->update|= HA_STATE_AKTIV; @@ -725,9 +726,9 @@ err: int _mi_pack_rec_unpack(register MI_INFO *info, MI_BIT_BUFF *bit_buff, - register byte *to, byte *from, ulong reclength) + register uchar *to, uchar *from, ulong reclength) { - byte *end_field; + uchar *end_field; reg3 MI_COLUMNDEF *end; MI_COLUMNDEF *current_field; MYISAM_SHARE *share=info->s; @@ -834,7 +835,7 @@ static void uf_space_normal(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, uchar *to, uchar *end) { if (get_bit(bit_buff)) - bfill((byte*) to,(end-to),' '); + bfill((uchar*) to,(end-to),' '); else decode_bytes(rec,bit_buff,to,end); } @@ -844,7 +845,7 @@ static void uf_space_endspace_selected(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, { uint spaces; if (get_bit(bit_buff)) - bfill((byte*) to,(end-to),' '); + bfill((uchar*) to,(end-to),' '); else { if (get_bit(bit_buff)) @@ -856,7 +857,7 @@ static void uf_space_endspace_selected(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, } if (to+spaces != end) decode_bytes(rec,bit_buff,to,end-spaces); - bfill((byte*) end-spaces,spaces,' '); + bfill((uchar*) end-spaces,spaces,' '); } else decode_bytes(rec,bit_buff,to,end); @@ -876,7 +877,7 @@ static void uf_endspace_selected(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, } if (to+spaces != end) decode_bytes(rec,bit_buff,to,end-spaces); - bfill((byte*) end-spaces,spaces,' '); + bfill((uchar*) end-spaces,spaces,' '); } else decode_bytes(rec,bit_buff,to,end); @@ -887,7 +888,7 @@ static void uf_space_endspace(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, uchar *t { uint spaces; if (get_bit(bit_buff)) - bfill((byte*) to,(end-to),' '); + bfill((uchar*) to,(end-to),' '); else { if ((spaces=get_bits(bit_buff,rec->space_length_bits))+to > end) @@ -897,7 +898,7 @@ static void uf_space_endspace(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, uchar *t } if (to+spaces != end) decode_bytes(rec,bit_buff,to,end-spaces); - bfill((byte*) end-spaces,spaces,' '); + bfill((uchar*) end-spaces,spaces,' '); } } @@ -912,7 +913,7 @@ static void uf_endspace(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, uchar *to, } if (to+spaces != end) decode_bytes(rec,bit_buff,to,end-spaces); - bfill((byte*) end-spaces,spaces,' '); + bfill((uchar*) end-spaces,spaces,' '); } static void uf_space_prespace_selected(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, @@ -920,7 +921,7 @@ static void uf_space_prespace_selected(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, { uint spaces; if (get_bit(bit_buff)) - bfill((byte*) to,(end-to),' '); + bfill((uchar*) to,(end-to),' '); else { if (get_bit(bit_buff)) @@ -930,7 +931,7 @@ static void uf_space_prespace_selected(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, bit_buff->error=1; return; } - bfill((byte*) to,spaces,' '); + bfill((uchar*) to,spaces,' '); if (to+spaces != end) decode_bytes(rec,bit_buff,to+spaces,end); } @@ -951,7 +952,7 @@ static void uf_prespace_selected(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, bit_buff->error=1; return; } - bfill((byte*) to,spaces,' '); + bfill((uchar*) to,spaces,' '); if (to+spaces != end) decode_bytes(rec,bit_buff,to+spaces,end); } @@ -965,7 +966,7 @@ static void uf_space_prespace(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, uchar *t { uint spaces; if (get_bit(bit_buff)) - bfill((byte*) to,(end-to),' '); + bfill((uchar*) to,(end-to),' '); else { if ((spaces=get_bits(bit_buff,rec->space_length_bits))+to > end) @@ -973,7 +974,7 @@ static void uf_space_prespace(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, uchar *t bit_buff->error=1; return; } - bfill((byte*) to,spaces,' '); + bfill((uchar*) to,spaces,' '); if (to+spaces != end) decode_bytes(rec,bit_buff,to+spaces,end); } @@ -988,7 +989,7 @@ static void uf_prespace(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, uchar *to, bit_buff->error=1; return; } - bfill((byte*) to,spaces,' '); + bfill((uchar*) to,spaces,' '); if (to+spaces != end) decode_bytes(rec,bit_buff,to+spaces,end); } @@ -1031,7 +1032,7 @@ static void uf_blob(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, uchar *to, uchar *end) { if (get_bit(bit_buff)) - bzero((byte*) to,(end-to)); + bzero((uchar*) to,(end-to)); else { ulong length=get_bits(bit_buff,rec->space_length_bits); @@ -1039,11 +1040,11 @@ static void uf_blob(MI_COLUMNDEF *rec, MI_BIT_BUFF *bit_buff, if (bit_buff->blob_pos+length > bit_buff->blob_end) { bit_buff->error=1; - bzero((byte*) to,(end-to)); + bzero((uchar*) to,(end-to)); return; } decode_bytes(rec,bit_buff,bit_buff->blob_pos,bit_buff->blob_pos+length); - _my_store_blob_length((byte*) to,pack_length,length); + _my_store_blob_length((uchar*) to,pack_length,length); memcpy_fixed((char*) to+pack_length,(char*) &bit_buff->blob_pos, sizeof(char*)); bit_buff->blob_pos+=length; @@ -1286,7 +1287,7 @@ static uint decode_pos(MI_BIT_BUFF *bit_buff, MI_DECODE_TREE *decode_tree) } -int _mi_read_rnd_pack_record(MI_INFO *info, byte *buf, +int _mi_read_rnd_pack_record(MI_INFO *info, uchar *buf, register my_off_t filepos, my_bool skip_deleted_blocks) { @@ -1303,7 +1304,7 @@ int _mi_read_rnd_pack_record(MI_INFO *info, byte *buf, if (info->opt_flag & READ_CACHE_USED) { - if (_mi_read_cache(&info->rec_cache, (byte*) block_info.header, + if (_mi_read_cache(&info->rec_cache, (uchar*) block_info.header, filepos, share->pack.ref_length, skip_deleted_blocks ? READING_NEXT : 0)) goto err; @@ -1325,14 +1326,14 @@ int _mi_read_rnd_pack_record(MI_INFO *info, byte *buf, if (info->opt_flag & READ_CACHE_USED) { - if (_mi_read_cache(&info->rec_cache, (byte*) info->rec_buff, + if (_mi_read_cache(&info->rec_cache, (uchar*) info->rec_buff, block_info.filepos, block_info.rec_len, skip_deleted_blocks ? READING_NEXT : 0)) goto err; } else { - if (my_read(info->dfile,(byte*) info->rec_buff + block_info.offset, + if (my_read(info->dfile,(uchar*) info->rec_buff + block_info.offset, block_info.rec_len-block_info.offset, MYF(MY_NABP))) goto err; @@ -1352,7 +1353,7 @@ int _mi_read_rnd_pack_record(MI_INFO *info, byte *buf, /* Read and process header from a huff-record-file */ uint _mi_pack_get_block_info(MI_INFO *myisam, MI_BIT_BUFF *bit_buff, - MI_BLOCK_INFO *info, byte **rec_buff_p, + MI_BLOCK_INFO *info, uchar **rec_buff_p, File file, my_off_t filepos) { uchar *header=info->header; @@ -1369,7 +1370,7 @@ uint _mi_pack_get_block_info(MI_INFO *myisam, MI_BIT_BUFF *bit_buff, VOID(my_seek(file,filepos,MY_SEEK_SET,MYF(0))); if (my_read(file,(char*) header,ref_length,MYF(MY_NABP))) return BLOCK_FATAL_ERROR; - DBUG_DUMP("header",(byte*) header,ref_length); + DBUG_DUMP("header",(uchar*) header,ref_length); } head_length= read_pack_length((uint) myisam->s->pack.version, header, &info->rec_len); @@ -1478,8 +1479,8 @@ static uint max_bit(register uint value) #ifdef HAVE_MMAP -static int _mi_read_mempack_record(MI_INFO *info,my_off_t filepos,byte *buf); -static int _mi_read_rnd_mempack_record(MI_INFO*, byte *,my_off_t, my_bool); +static int _mi_read_mempack_record(MI_INFO *info,my_off_t filepos,uchar *buf); +static int _mi_read_rnd_mempack_record(MI_INFO*, uchar *,my_off_t, my_bool); my_bool _mi_memmap_file(MI_INFO *info) { @@ -1512,7 +1513,7 @@ void _mi_unmap_file(MI_INFO *info) static uchar *_mi_mempack_get_block_info(MI_INFO *myisam, MI_BIT_BUFF *bit_buff, - MI_BLOCK_INFO *info, byte **rec_buff_p, + MI_BLOCK_INFO *info, uchar **rec_buff_p, uchar *header) { header+= read_pack_length((uint) myisam->s->pack.version, header, @@ -1532,17 +1533,17 @@ static uchar *_mi_mempack_get_block_info(MI_INFO *myisam, MI_BIT_BUFF *bit_buff, } -static int _mi_read_mempack_record(MI_INFO *info, my_off_t filepos, byte *buf) +static int _mi_read_mempack_record(MI_INFO *info, my_off_t filepos, uchar *buf) { MI_BLOCK_INFO block_info; MYISAM_SHARE *share=info->s; - byte *pos; + uchar *pos; DBUG_ENTER("mi_read_mempack_record"); if (filepos == HA_OFFSET_ERROR) DBUG_RETURN(-1); /* _search() didn't find record */ - if (!(pos= (byte*) _mi_mempack_get_block_info(info, &info->bit_buff, + if (!(pos= (uchar*) _mi_mempack_get_block_info(info, &info->bit_buff, &block_info, &info->rec_buff, (uchar*) share->file_map+ filepos))) @@ -1553,14 +1554,14 @@ static int _mi_read_mempack_record(MI_INFO *info, my_off_t filepos, byte *buf) /*ARGSUSED*/ -static int _mi_read_rnd_mempack_record(MI_INFO *info, byte *buf, +static int _mi_read_rnd_mempack_record(MI_INFO *info, uchar *buf, register my_off_t filepos, my_bool skip_deleted_blocks __attribute__((unused))) { MI_BLOCK_INFO block_info; MYISAM_SHARE *share=info->s; - byte *pos,*start; + uchar *pos,*start; DBUG_ENTER("_mi_read_rnd_mempack_record"); if (filepos >= share->state.state.data_file_length) @@ -1568,7 +1569,7 @@ static int _mi_read_rnd_mempack_record(MI_INFO *info, byte *buf, my_errno=HA_ERR_END_OF_FILE; goto err; } - if (!(pos= (byte*) _mi_mempack_get_block_info(info, &info->bit_buff, + if (!(pos= (uchar*) _mi_mempack_get_block_info(info, &info->bit_buff, &block_info, &info->rec_buff, (uchar*) (start=share->file_map+ @@ -1596,7 +1597,7 @@ static int _mi_read_rnd_mempack_record(MI_INFO *info, byte *buf, /* Save length of row */ -uint save_pack_length(uint version, byte *block_buff, ulong length) +uint save_pack_length(uint version, uchar *block_buff, ulong length) { if (length < 254) { diff --git a/storage/myisam/mi_page.c b/storage/myisam/mi_page.c index da9e19275c9..ede379feea6 100644 --- a/storage/myisam/mi_page.c +++ b/storage/myisam/mi_page.c @@ -29,7 +29,7 @@ uchar *_mi_fetch_keypage(register MI_INFO *info, MI_KEYDEF *keyinfo, DBUG_PRINT("enter",("page: %ld", (long) page)); tmp=(uchar*) key_cache_read(info->s->key_cache, - info->s->kfile, page, level, (byte*) buff, + info->s->kfile, page, level, (uchar*) buff, (uint) keyinfo->block_length, (uint) keyinfo->block_length, return_buffer); @@ -80,7 +80,7 @@ int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo, DBUG_RETURN((-1)); } DBUG_PRINT("page",("write page at: %lu",(long) page)); - DBUG_DUMP("buff",(byte*) buff,mi_getint(buff)); + DBUG_DUMP("buff",(uchar*) buff,mi_getint(buff)); #endif if ((length=keyinfo->block_length) > IO_SIZE*2 && @@ -89,12 +89,12 @@ int _mi_write_keypage(register MI_INFO *info, register MI_KEYDEF *keyinfo, #ifdef HAVE_purify { length=mi_getint(buff); - bzero((byte*) buff+length,keyinfo->block_length-length); + bzero((uchar*) buff+length,keyinfo->block_length-length); length=keyinfo->block_length; } #endif DBUG_RETURN((key_cache_write(info->s->key_cache, - info->s->kfile,page, level, (byte*) buff,length, + info->s->kfile,page, level, (uchar*) buff,length, (uint) keyinfo->block_length, (int) ((info->lock_type != F_UNLCK) || info->s->delay_key_write)))); diff --git a/storage/myisam/mi_preload.c b/storage/myisam/mi_preload.c index 06c66c06bf4..60ab55106cb 100644 --- a/storage/myisam/mi_preload.c +++ b/storage/myisam/mi_preload.c @@ -81,7 +81,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) /* Read the next block of index file into the preload buffer */ if ((my_off_t) length > (key_file_length-pos)) length= (ulong) (key_file_length-pos); - if (my_pread(share->kfile, (byte*) buff, length, pos, MYF(MY_FAE|MY_FNABP))) + if (my_pread(share->kfile, (uchar*) buff, length, pos, MYF(MY_FAE|MY_FNABP))) goto err; if (ignore_leaves) @@ -93,7 +93,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) { if (key_cache_insert(share->key_cache, share->kfile, pos, DFLT_INIT_HITS, - (byte*) buff, block_length)) + (uchar*) buff, block_length)) goto err; } pos+= block_length; @@ -105,7 +105,7 @@ int mi_preload(MI_INFO *info, ulonglong key_map, my_bool ignore_leaves) { if (key_cache_insert(share->key_cache, share->kfile, pos, DFLT_INIT_HITS, - (byte*) buff, length)) + (uchar*) buff, length)) goto err; pos+= length; } diff --git a/storage/myisam/mi_range.c b/storage/myisam/mi_range.c index c7ab6731a2c..932a4abd1b3 100644 --- a/storage/myisam/mi_range.c +++ b/storage/myisam/mi_range.c @@ -21,7 +21,7 @@ #include "myisamdef.h" #include "rt_index.h" -static ha_rows _mi_record_pos(MI_INFO *, const byte *, key_part_map, +static ha_rows _mi_record_pos(MI_INFO *, const uchar *, key_part_map, enum ha_rkey_function); static double _mi_search_pos(MI_INFO *,MI_KEYDEF *,uchar *, uint,uint,my_off_t); static uint _mi_keynr(MI_INFO *info,MI_KEYDEF *,uchar *, uchar *,uint *); @@ -116,7 +116,7 @@ ha_rows mi_records_in_range(MI_INFO *info, int inx, /* Find relative position (in records) for key in index-tree */ -static ha_rows _mi_record_pos(MI_INFO *info, const byte *key, +static ha_rows _mi_record_pos(MI_INFO *info, const uchar *key, key_part_map keypart_map, enum ha_rkey_function search_flag) { diff --git a/storage/myisam/mi_rfirst.c b/storage/myisam/mi_rfirst.c index d23bda46b1a..5a8b27b3e85 100644 --- a/storage/myisam/mi_rfirst.c +++ b/storage/myisam/mi_rfirst.c @@ -17,7 +17,7 @@ /* Read first row through a specfic key */ -int mi_rfirst(MI_INFO *info, byte *buf, int inx) +int mi_rfirst(MI_INFO *info, uchar *buf, int inx) { DBUG_ENTER("mi_rfirst"); info->lastpos= HA_OFFSET_ERROR; diff --git a/storage/myisam/mi_rkey.c b/storage/myisam/mi_rkey.c index a69e276a6d8..3dcaa27d3ca 100644 --- a/storage/myisam/mi_rkey.c +++ b/storage/myisam/mi_rkey.c @@ -21,7 +21,7 @@ /* Read a record using key */ /* Ordinary search_flag is 0 ; Give error if no record with key */ -int mi_rkey(MI_INFO *info, byte *buf, int inx, const byte *key, +int mi_rkey(MI_INFO *info, uchar *buf, int inx, const uchar *key, key_part_map keypart_map, enum ha_rkey_function search_flag) { uchar *key_buff; diff --git a/storage/myisam/mi_rlast.c b/storage/myisam/mi_rlast.c index 7805755ab70..07be619617f 100644 --- a/storage/myisam/mi_rlast.c +++ b/storage/myisam/mi_rlast.c @@ -17,7 +17,7 @@ /* Read last row with the same key as the previous read. */ -int mi_rlast(MI_INFO *info, byte *buf, int inx) +int mi_rlast(MI_INFO *info, uchar *buf, int inx) { DBUG_ENTER("mi_rlast"); info->lastpos= HA_OFFSET_ERROR; diff --git a/storage/myisam/mi_rnext.c b/storage/myisam/mi_rnext.c index f6a0a47413e..7ce66d41e0f 100644 --- a/storage/myisam/mi_rnext.c +++ b/storage/myisam/mi_rnext.c @@ -24,7 +24,7 @@ based on the position of the last used key! */ -int mi_rnext(MI_INFO *info, byte *buf, int inx) +int mi_rnext(MI_INFO *info, uchar *buf, int inx) { int error,changed; uint flag; diff --git a/storage/myisam/mi_rnext_same.c b/storage/myisam/mi_rnext_same.c index 3a7004bf47c..1892fe3e1e0 100644 --- a/storage/myisam/mi_rnext_same.c +++ b/storage/myisam/mi_rnext_same.c @@ -24,7 +24,7 @@ based on the position of the last used key! */ -int mi_rnext_same(MI_INFO *info, byte *buf) +int mi_rnext_same(MI_INFO *info, uchar *buf) { int error; uint inx,not_used[2]; diff --git a/storage/myisam/mi_rprev.c b/storage/myisam/mi_rprev.c index 09802627185..d1407012590 100644 --- a/storage/myisam/mi_rprev.c +++ b/storage/myisam/mi_rprev.c @@ -22,7 +22,7 @@ based on the position of the last used key! */ -int mi_rprev(MI_INFO *info, byte *buf, int inx) +int mi_rprev(MI_INFO *info, uchar *buf, int inx) { int error,changed; register uint flag; diff --git a/storage/myisam/mi_rrnd.c b/storage/myisam/mi_rrnd.c index d31e6c24a37..211e5fa51cc 100644 --- a/storage/myisam/mi_rrnd.c +++ b/storage/myisam/mi_rrnd.c @@ -29,7 +29,7 @@ HA_ERR_END_OF_FILE = EOF. */ -int mi_rrnd(MI_INFO *info, byte *buf, register my_off_t filepos) +int mi_rrnd(MI_INFO *info, uchar *buf, register my_off_t filepos) { my_bool skip_deleted_blocks; DBUG_ENTER("mi_rrnd"); diff --git a/storage/myisam/mi_rsame.c b/storage/myisam/mi_rsame.c index 4831ebb3d7c..8093498483f 100644 --- a/storage/myisam/mi_rsame.c +++ b/storage/myisam/mi_rsame.c @@ -25,7 +25,7 @@ */ -int mi_rsame(MI_INFO *info, byte *record, int inx) +int mi_rsame(MI_INFO *info, uchar *record, int inx) { DBUG_ENTER("mi_rsame"); diff --git a/storage/myisam/mi_rsamepos.c b/storage/myisam/mi_rsamepos.c index 717b9ab52d5..6a1e462b686 100644 --- a/storage/myisam/mi_rsamepos.c +++ b/storage/myisam/mi_rsamepos.c @@ -27,7 +27,7 @@ ** HA_ERR_END_OF_FILE = End of file */ -int mi_rsame_with_pos(MI_INFO *info, byte *record, int inx, my_off_t filepos) +int mi_rsame_with_pos(MI_INFO *info, uchar *record, int inx, my_off_t filepos) { DBUG_ENTER("mi_rsame_with_pos"); DBUG_PRINT("enter",("index: %d filepos: %ld", inx, (long) filepos)); diff --git a/storage/myisam/mi_scan.c b/storage/myisam/mi_scan.c index 87debb67b37..a225b399660 100644 --- a/storage/myisam/mi_scan.c +++ b/storage/myisam/mi_scan.c @@ -36,7 +36,7 @@ int mi_scan_init(register MI_INFO *info) HA_ERR_END_OF_FILE = EOF. */ -int mi_scan(MI_INFO *info, byte *buf) +int mi_scan(MI_INFO *info, uchar *buf) { DBUG_ENTER("mi_scan"); /* Init all but update-flag */ diff --git a/storage/myisam/mi_search.c b/storage/myisam/mi_search.c index d313619e007..acc8c073297 100644 --- a/storage/myisam/mi_search.c +++ b/storage/myisam/mi_search.c @@ -78,7 +78,7 @@ int _mi_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, if (!(buff=_mi_fetch_keypage(info,keyinfo,pos,DFLT_INIT_HITS,info->buff, test(!(nextflag & SEARCH_SAVE_BUFF))))) goto err; - DBUG_DUMP("page",(byte*) buff,mi_getint(buff)); + DBUG_DUMP("page",(uchar*) buff,mi_getint(buff)); flag=(*keyinfo->bin_search)(info,keyinfo,buff,key,key_len,nextflag, &keypos,lastkey, &last_key); @@ -753,7 +753,7 @@ void _mi_dpointer(MI_INFO *info, uchar *buff, my_off_t pos) uint _mi_get_static_key(register MI_KEYDEF *keyinfo, uint nod_flag, register uchar **page, register uchar *key) { - memcpy((byte*) key,(byte*) *page, + memcpy((uchar*) key,(uchar*) *page, (size_t) (keyinfo->keylength+nod_flag)); *page+=keyinfo->keylength+nod_flag; return(keyinfo->keylength); @@ -897,12 +897,12 @@ uint _mi_get_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, else length=keyseg->length; } - memcpy((byte*) key,(byte*) page,(size_t) length); + memcpy((uchar*) key,(uchar*) page,(size_t) length); key+=length; page+=length; } length=keyseg->length+nod_flag; - bmove((byte*) key,(byte*) page,length); + bmove((uchar*) key,(uchar*) page,length); *page_pos= page+length; return ((uint) (key-start_key)+keyseg->length); } /* _mi_get_pack_key */ @@ -1003,7 +1003,7 @@ uint _mi_get_binary_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, } DBUG_PRINT("info",("key: 0x%lx from: 0x%lx length: %u", (long) key, (long) from, length)); - memmove((byte*) key, (byte*) from, (size_t) length); + memmove((uchar*) key, (uchar*) from, (size_t) length); key+=length; from+=length; } @@ -1035,7 +1035,7 @@ uint _mi_get_binary_pack_key(register MI_KEYDEF *keyinfo, uint nod_flag, DBUG_RETURN(0); /* Error */ } /* Copy data pointer and, if appropriate, key block pointer. */ - memcpy((byte*) key,(byte*) from,(size_t) length); + memcpy((uchar*) key,(uchar*) from,(size_t) length); *page_pos= from+length; } DBUG_RETURN((uint) (key-start_key)+keyseg->length); @@ -1054,7 +1054,7 @@ uchar *_mi_get_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, nod_flag=mi_test_if_nod(page); if (! (keyinfo->flag & (HA_VAR_LENGTH_KEY | HA_BINARY_PACK_KEY))) { - bmove((byte*) key,(byte*) keypos,keyinfo->keylength+nod_flag); + bmove((uchar*) key,(uchar*) keypos,keyinfo->keylength+nod_flag); DBUG_RETURN(keypos+keyinfo->keylength+nod_flag); } else @@ -1092,7 +1092,7 @@ static my_bool _mi_get_prev_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, if (! (keyinfo->flag & (HA_VAR_LENGTH_KEY | HA_BINARY_PACK_KEY))) { *return_key_length=keyinfo->keylength; - bmove((byte*) key,(byte*) keypos- *return_key_length-nod_flag, + bmove((uchar*) key,(uchar*) keypos- *return_key_length-nod_flag, *return_key_length); DBUG_RETURN(0); } @@ -1134,7 +1134,7 @@ uchar *_mi_get_last_key(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, lastpos=endpos-keyinfo->keylength-nod_flag; *return_key_length=keyinfo->keylength; if (lastpos > page) - bmove((byte*) lastkey,(byte*) lastpos,keyinfo->keylength+nod_flag); + bmove((uchar*) lastkey,(uchar*) lastpos,keyinfo->keylength+nod_flag); } else { @@ -1225,7 +1225,7 @@ uint _mi_keylength_part(MI_KEYDEF *keyinfo, register uchar *key, uchar *_mi_move_key(MI_KEYDEF *keyinfo, uchar *to, uchar *from) { reg1 uint length; - memcpy((byte*) to, (byte*) from, + memcpy((uchar*) to, (uchar*) from, (size_t) (length=_mi_keylength(keyinfo,from))); return to+length; } @@ -1827,7 +1827,7 @@ void _mi_store_static_key(MI_KEYDEF *keyinfo __attribute__((unused)), register uchar *key_pos, register MI_KEY_PARAM *s_temp) { - memcpy((byte*) key_pos,(byte*) s_temp->key,(size_t) s_temp->totlength); + memcpy((uchar*) key_pos,(uchar*) s_temp->key,(size_t) s_temp->totlength); } @@ -1860,7 +1860,7 @@ void _mi_store_var_pack_key(MI_KEYDEF *keyinfo __attribute__((unused)), /* Not packed against previous key */ store_pack_length(s_temp->pack_marker == 128,key_pos,s_temp->key_length); } - bmove((byte*) key_pos,(byte*) s_temp->key, + bmove((uchar*) key_pos,(uchar*) s_temp->key, (length=s_temp->totlength-(uint) (key_pos-start))); if (!s_temp->next_key_pos) /* No following key */ diff --git a/storage/myisam/mi_static.c b/storage/myisam/mi_static.c index 21a25f66b7c..c92d577b621 100644 --- a/storage/myisam/mi_static.c +++ b/storage/myisam/mi_static.c @@ -27,7 +27,7 @@ uchar NEAR myisam_file_magic[]= { (uchar) 254, (uchar) 254,'\007', '\001', }; uchar NEAR myisam_pack_file_magic[]= { (uchar) 254, (uchar) 254,'\010', '\002', }; -my_string myisam_log_filename=(char*) "myisam.log"; +char * myisam_log_filename=(char*) "myisam.log"; File myisam_log_file= -1; uint myisam_quick_table_bits=9; ulong myisam_block_size= MI_KEY_BLOCK_LENGTH; /* Best by test */ diff --git a/storage/myisam/mi_statrec.c b/storage/myisam/mi_statrec.c index 3f92ec31d4c..93e91fb9e32 100644 --- a/storage/myisam/mi_statrec.c +++ b/storage/myisam/mi_statrec.c @@ -18,7 +18,7 @@ #include "myisamdef.h" -int _mi_write_static_record(MI_INFO *info, const byte *record) +int _mi_write_static_record(MI_INFO *info, const uchar *record) { uchar temp[8]; /* max pointer length */ if (info->s->state.dellink != HA_OFFSET_ERROR && @@ -48,14 +48,14 @@ int _mi_write_static_record(MI_INFO *info, const byte *record) } if (info->opt_flag & WRITE_CACHE_USED) { /* Cash in use */ - if (my_b_write(&info->rec_cache, (byte*) record, + if (my_b_write(&info->rec_cache, (uchar*) record, info->s->base.reclength)) goto err; if (info->s->base.pack_reclength != info->s->base.reclength) { uint length=info->s->base.pack_reclength - info->s->base.reclength; bzero((char*) temp,length); - if (my_b_write(&info->rec_cache, (byte*) temp,length)) + if (my_b_write(&info->rec_cache, (uchar*) temp,length)) goto err; } } @@ -70,7 +70,7 @@ int _mi_write_static_record(MI_INFO *info, const byte *record) { uint length=info->s->base.pack_reclength - info->s->base.reclength; bzero((char*) temp,length); - if (info->s->file_write(info, (byte*) temp,length, + if (info->s->file_write(info, (uchar*) temp,length, info->state->data_file_length+ info->s->base.reclength, info->s->write_flag)) @@ -85,7 +85,7 @@ int _mi_write_static_record(MI_INFO *info, const byte *record) return 1; } -int _mi_update_static_record(MI_INFO *info, my_off_t pos, const byte *record) +int _mi_update_static_record(MI_INFO *info, my_off_t pos, const uchar *record) { info->rec_cache.seek_not_done=1; /* We have done a seek */ return (info->s->file_write(info, @@ -105,12 +105,12 @@ int _mi_delete_static_record(MI_INFO *info) _mi_dpointer(info,temp+1,info->s->state.dellink); info->s->state.dellink = info->lastpos; info->rec_cache.seek_not_done=1; - return (info->s->file_write(info,(byte*) temp, 1+info->s->rec_reflength, + return (info->s->file_write(info,(uchar*) temp, 1+info->s->rec_reflength, info->lastpos, MYF(MY_NABP)) != 0); } -int _mi_cmp_static_record(register MI_INFO *info, register const byte *old) +int _mi_cmp_static_record(register MI_INFO *info, register const uchar *old) { DBUG_ENTER("_mi_cmp_static_record"); @@ -133,7 +133,7 @@ int _mi_cmp_static_record(register MI_INFO *info, register const byte *old) info->lastpos, MYF(MY_NABP))) DBUG_RETURN(-1); - if (memcmp((byte*) info->rec_buff, (byte*) old, + if (memcmp((uchar*) info->rec_buff, (uchar*) old, (uint) info->s->base.reclength)) { DBUG_DUMP("read",old,info->s->base.reclength); @@ -147,7 +147,7 @@ int _mi_cmp_static_record(register MI_INFO *info, register const byte *old) int _mi_cmp_static_unique(MI_INFO *info, MI_UNIQUEDEF *def, - const byte *record, my_off_t pos) + const uchar *record, my_off_t pos) { DBUG_ENTER("_mi_cmp_static_unique"); @@ -166,7 +166,7 @@ int _mi_cmp_static_unique(MI_INFO *info, MI_UNIQUEDEF *def, /* MY_FILE_ERROR on read-error or locking-error */ int _mi_read_static_record(register MI_INFO *info, register my_off_t pos, - register byte *record) + register uchar *record) { int error; @@ -199,7 +199,7 @@ int _mi_read_static_record(register MI_INFO *info, register my_off_t pos, -int _mi_read_rnd_static_record(MI_INFO *info, byte *buf, +int _mi_read_rnd_static_record(MI_INFO *info, uchar *buf, register my_off_t filepos, my_bool skip_deleted_blocks) { @@ -274,11 +274,11 @@ int _mi_read_rnd_static_record(MI_INFO *info, byte *buf, } /* Read record with cacheing */ - error=my_b_read(&info->rec_cache,(byte*) buf,share->base.reclength); + error=my_b_read(&info->rec_cache,(uchar*) buf,share->base.reclength); if (info->s->base.pack_reclength != info->s->base.reclength && !error) { char tmp[8]; /* Skill fill bytes */ - error=my_b_read(&info->rec_cache,(byte*) tmp, + error=my_b_read(&info->rec_cache,(uchar*) tmp, info->s->base.pack_reclength - info->s->base.reclength); } if (locked) diff --git a/storage/myisam/mi_test1.c b/storage/myisam/mi_test1.c index ebb9cdcb2f7..1165ea4bb32 100644 --- a/storage/myisam/mi_test1.c +++ b/storage/myisam/mi_test1.c @@ -109,7 +109,7 @@ static int run_test(const char *filename) } keyinfo[0].flag = (uint8) (pack_keys | unique_key); - bzero((byte*) flags,sizeof(flags)); + bzero((uchar*) flags,sizeof(flags)); if (opt_unique) { uint start; @@ -534,21 +534,21 @@ static struct my_option my_long_options[] = {"debug", '#', "Undocumented", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"delete_rows", 'd', "Undocumented", (gptr*) &remove_count, - (gptr*) &remove_count, 0, GET_UINT, REQUIRED_ARG, 1000, 0, 0, 0, 0, 0}, + {"delete_rows", 'd', "Undocumented", (uchar**) &remove_count, + (uchar**) &remove_count, 0, GET_UINT, REQUIRED_ARG, 1000, 0, 0, 0, 0, 0}, {"help", '?', "Display help and exit", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"insert_rows", 'i', "Undocumented", (gptr*) &insert_count, - (gptr*) &insert_count, 0, GET_UINT, REQUIRED_ARG, 1000, 0, 0, 0, 0, 0}, + {"insert_rows", 'i', "Undocumented", (uchar**) &insert_count, + (uchar**) &insert_count, 0, GET_UINT, REQUIRED_ARG, 1000, 0, 0, 0, 0, 0}, {"key_alpha", 'a', "Use a key of type HA_KEYTYPE_TEXT", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"key_binary_pack", 'B', "Undocumented", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"key_blob", 'b', "Undocumented", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"key_cache", 'K', "Undocumented", (gptr*) &key_cacheing, - (gptr*) &key_cacheing, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"key_length", 'k', "Undocumented", (gptr*) &key_length, (gptr*) &key_length, + {"key_cache", 'K', "Undocumented", (uchar**) &key_cacheing, + (uchar**) &key_cacheing, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"key_length", 'k', "Undocumented", (uchar**) &key_length, (uchar**) &key_length, 0, GET_UINT, REQUIRED_ARG, 6, 0, 0, 0, 0, 0}, {"key_multiple", 'm', "Undocumented", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -559,21 +559,21 @@ static struct my_option my_long_options[] = {"key_varchar", 'w', "Test VARCHAR keys", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"null_fields", 'N', "Define fields with NULL", - (gptr*) &null_fields, (gptr*) &null_fields, 0, GET_BOOL, NO_ARG, + (uchar**) &null_fields, (uchar**) &null_fields, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"row_fixed_size", 'S', "Undocumented", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"row_pointer_size", 'R', "Undocumented", (gptr*) &rec_pointer_size, - (gptr*) &rec_pointer_size, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"row_pointer_size", 'R', "Undocumented", (uchar**) &rec_pointer_size, + (uchar**) &rec_pointer_size, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"silent", 's', "Undocumented", - (gptr*) &silent, (gptr*) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"skip_update", 'U', "Undocumented", (gptr*) &skip_update, - (gptr*) &skip_update, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"unique", 'C', "Undocumented", (gptr*) &opt_unique, (gptr*) &opt_unique, 0, + (uchar**) &silent, (uchar**) &silent, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"skip_update", 'U', "Undocumented", (uchar**) &skip_update, + (uchar**) &skip_update, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"unique", 'C', "Undocumented", (uchar**) &opt_unique, (uchar**) &opt_unique, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"update_rows", 'u', "Undocumented", (gptr*) &update_count, - (gptr*) &update_count, 0, GET_UINT, REQUIRED_ARG, 1000, 0, 0, 0, 0, 0}, - {"verbose", 'v', "Be more verbose", (gptr*) &verbose, (gptr*) &verbose, 0, + {"update_rows", 'u', "Undocumented", (uchar**) &update_count, + (uchar**) &update_count, 0, GET_UINT, REQUIRED_ARG, 1000, 0, 0, 0, 0, 0}, + {"verbose", 'v', "Be more verbose", (uchar**) &verbose, (uchar**) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Print version number and exit", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, diff --git a/storage/myisam/mi_test2.c b/storage/myisam/mi_test2.c index 878bba31ea8..96ee82e023c 100644 --- a/storage/myisam/mi_test2.c +++ b/storage/myisam/mi_test2.c @@ -36,7 +36,7 @@ static void get_options(int argc, char *argv[]); static uint rnd(uint max_value); -static void fix_length(byte *record,uint length); +static void fix_length(uchar *record,uint length); static void put_blob_in_record(char *blob_pos,char **blob_buffer); static void copy_key(struct st_myisam_info *info,uint inx, uchar *record,uchar *key); @@ -455,8 +455,8 @@ int main(int argc, char *argv[]) bcmp(read_record2,read_record3,reclength)) { printf("Can't find last record\n"); - DBUG_DUMP("record2",(byte*) read_record2,reclength); - DBUG_DUMP("record3",(byte*) read_record3,reclength); + DBUG_DUMP("record2",(uchar*) read_record2,reclength); + DBUG_DUMP("record3",(uchar*) read_record3,reclength); goto end; } ant=1; @@ -1001,7 +1001,7 @@ static uint rnd(uint max_value) /* Create a variable length record */ -static void fix_length(byte *rec, uint length) +static void fix_length(uchar *rec, uint length) { bmove(rec+STANDARD_LENGTH, "0123456789012345678901234567890123456789012345678901234567890", diff --git a/storage/myisam/mi_test3.c b/storage/myisam/mi_test3.c index 3987c20ab69..982b999c3a5 100644 --- a/storage/myisam/mi_test3.c +++ b/storage/myisam/mi_test3.c @@ -243,7 +243,7 @@ int test_read(MI_INFO *file,int id) for (i=0 ; i < 100 ; i++) { find=rnd(100000); - if (!mi_rkey(file,record.id,1,(byte*) &find, + if (!mi_rkey(file,record.id,1,(uchar*) &find, sizeof(find),HA_READ_KEY_EXACT)) found++; else @@ -426,7 +426,7 @@ int test_update(MI_INFO *file,int id,int lock_type) { tmp=rnd(100000); int4store(find,tmp); - if (!mi_rkey(file,record.id,1,(byte*) find, + if (!mi_rkey(file,record.id,1,(uchar*) find, sizeof(find),HA_READ_KEY_EXACT)) found++; else diff --git a/storage/myisam/mi_unique.c b/storage/myisam/mi_unique.c index 635f6c18247..e490fb683e4 100644 --- a/storage/myisam/mi_unique.c +++ b/storage/myisam/mi_unique.c @@ -18,7 +18,7 @@ #include "myisamdef.h" #include <m_ctype.h> -my_bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, byte *record, +my_bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, uchar *record, ha_checksum unique_hash, my_off_t disk_pos) { my_off_t lastpos=info->lastpos; @@ -73,9 +73,9 @@ my_bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, byte *record, Add support for bit fields */ -ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const byte *record) +ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const uchar *record) { - const byte *pos, *end; + const uchar *pos, *end; ha_checksum crc= 0; ulong seed1=0, seed2= 4; HA_KEYSEG *keyseg; @@ -111,7 +111,7 @@ ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const byte *record) else if (keyseg->flag & HA_BLOB_PART) { uint tmp_length=_mi_calc_blob_length(keyseg->bit_start,pos); - memcpy_fixed((byte*) &pos,pos+keyseg->bit_start,sizeof(char*)); + memcpy_fixed((uchar*) &pos,pos+keyseg->bit_start,sizeof(char*)); if (!length || length > tmp_length) length=tmp_length; /* The whole blob */ } @@ -145,10 +145,10 @@ ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const byte *record) # Rows are different */ -int mi_unique_comp(MI_UNIQUEDEF *def, const byte *a, const byte *b, +int mi_unique_comp(MI_UNIQUEDEF *def, const uchar *a, const uchar *b, my_bool null_are_equal) { - const byte *pos_a, *pos_b, *end; + const uchar *pos_a, *pos_b, *end; HA_KEYSEG *keyseg; for (keyseg=def->seg ; keyseg < def->end ; keyseg++) @@ -206,8 +206,8 @@ int mi_unique_comp(MI_UNIQUEDEF *def, const byte *a, const byte *b, set_if_smaller(a_length, keyseg->length); set_if_smaller(b_length, keyseg->length); } - memcpy_fixed((byte*) &pos_a,pos_a+keyseg->bit_start,sizeof(char*)); - memcpy_fixed((byte*) &pos_b,pos_b+keyseg->bit_start,sizeof(char*)); + memcpy_fixed((uchar*) &pos_a,pos_a+keyseg->bit_start,sizeof(char*)); + memcpy_fixed((uchar*) &pos_b,pos_b+keyseg->bit_start,sizeof(char*)); } if (type == HA_KEYTYPE_TEXT || type == HA_KEYTYPE_VARTEXT1 || type == HA_KEYTYPE_VARTEXT2) diff --git a/storage/myisam/mi_update.c b/storage/myisam/mi_update.c index bea457d2e9a..924cdfcbc21 100644 --- a/storage/myisam/mi_update.c +++ b/storage/myisam/mi_update.c @@ -18,7 +18,7 @@ #include "fulltext.h" #include "rt_index.h" -int mi_update(register MI_INFO *info, const byte *oldrec, byte *newrec) +int mi_update(register MI_INFO *info, const uchar *oldrec, uchar *newrec) { int flag,key_changed,save_errno; reg3 my_off_t pos; @@ -115,7 +115,7 @@ int mi_update(register MI_INFO *info, const byte *oldrec, byte *newrec) info->update&= ~HA_STATE_RNEXT_SAME; if (new_length != old_length || - memcmp((byte*) old_key,(byte*) new_key,new_length)) + memcmp((uchar*) old_key,(uchar*) new_key,new_length)) { if ((int) i == info->lastinx) key_changed|=HA_STATE_WRITTEN; /* Mark that keyfile changed */ diff --git a/storage/myisam/mi_write.c b/storage/myisam/mi_write.c index 57c054f2de8..8ae979f8bf6 100644 --- a/storage/myisam/mi_write.c +++ b/storage/myisam/mi_write.c @@ -40,7 +40,7 @@ int _mi_ck_write_btree(register MI_INFO *info, uint keynr,uchar *key, /* Write new record to database */ -int mi_write(MI_INFO *info, byte *record) +int mi_write(MI_INFO *info, uchar *record) { MYISAM_SHARE *share=info->s; uint i; @@ -286,7 +286,7 @@ int _mi_ck_write_btree(register MI_INFO *info, uint keynr, uchar *key, if (!error) error= _mi_ft_convert_to_ft2(info, keynr, key); delete_dynamic(info->ft1_to_ft2); - my_free((gptr)info->ft1_to_ft2, MYF(0)); + my_free((uchar*)info->ft1_to_ft2, MYF(0)); info->ft1_to_ft2=0; } DBUG_RETURN(error); @@ -403,14 +403,14 @@ static int w_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, ft_intXstore(keypos, subkeys); if (!error) error=_mi_write_keypage(info,keyinfo,page,DFLT_INIT_HITS,temp_buff); - my_afree((byte*) temp_buff); + my_afree((uchar*) temp_buff); DBUG_RETURN(error); } } else /* not HA_FULLTEXT, normal HA_NOSAME key */ { info->dupp_key_pos= dupp_key_pos; - my_afree((byte*) temp_buff); + my_afree((uchar*) temp_buff); my_errno=HA_ERR_FOUND_DUPP_KEY; DBUG_RETURN(-1); } @@ -429,10 +429,10 @@ static int w_search(register MI_INFO *info, register MI_KEYDEF *keyinfo, if (_mi_write_keypage(info,keyinfo,page,DFLT_INIT_HITS,temp_buff)) goto err; } - my_afree((byte*) temp_buff); + my_afree((uchar*) temp_buff); DBUG_RETURN(error); err: - my_afree((byte*) temp_buff); + my_afree((uchar*) temp_buff); DBUG_PRINT("exit",("Error: %d",my_errno)); DBUG_RETURN (-1); } /* w_search */ @@ -488,7 +488,7 @@ int _mi_insert(register MI_INFO *info, register MI_KEYDEF *keyinfo, if (key_pos != anc_buff+2+nod_flag && (keyinfo->flag & (HA_BINARY_PACK_KEY | HA_PACK_KEY))) { - DBUG_DUMP("prev_key",(byte*) key_buff,_mi_keylength(keyinfo,key_buff)); + DBUG_DUMP("prev_key",(uchar*) key_buff,_mi_keylength(keyinfo,key_buff)); } if (keyinfo->flag & HA_PACK_KEY) { @@ -506,7 +506,7 @@ int _mi_insert(register MI_INFO *info, register MI_KEYDEF *keyinfo, my_errno=HA_ERR_CRASHED; DBUG_RETURN(-1); } - bmove_upp((byte*) endpos+t_length,(byte*) endpos,(uint) (endpos-key_pos)); + bmove_upp((uchar*) endpos+t_length,(uchar*) endpos,(uint) (endpos-key_pos)); } else { @@ -595,7 +595,7 @@ int _mi_split_page(register MI_INFO *info, register MI_KEYDEF *keyinfo, MI_KEY_PARAM s_temp; DBUG_ENTER("mi_split_page"); LINT_INIT(after_key); - DBUG_DUMP("buff",(byte*) buff,mi_getint(buff)); + DBUG_DUMP("buff",(uchar*) buff,mi_getint(buff)); if (info->s->keyinfo+info->lastinx == keyinfo) info->page_changed=1; /* Info->buff is used */ @@ -619,7 +619,7 @@ int _mi_split_page(register MI_INFO *info, register MI_KEYDEF *keyinfo, { DBUG_PRINT("test",("Splitting nod")); pos=key_pos-nod_flag; - memcpy((byte*) info->buff+2,(byte*) pos,(size_t) nod_flag); + memcpy((uchar*) info->buff+2,(uchar*) pos,(size_t) nod_flag); } /* Move middle item to key and pointer to new page */ @@ -635,14 +635,14 @@ int _mi_split_page(register MI_INFO *info, register MI_KEYDEF *keyinfo, (uchar*) 0, (uchar*) 0, key_buff, &s_temp); length=(uint) ((buff+a_length)-key_pos); - memcpy((byte*) info->buff+key_ref_length+t_length,(byte*) key_pos, + memcpy((uchar*) info->buff+key_ref_length+t_length,(uchar*) key_pos, (size_t) length); (*keyinfo->store_key)(keyinfo,info->buff+key_ref_length,&s_temp); mi_putint(info->buff,length+t_length+key_ref_length,nod_flag); if (_mi_write_keypage(info,keyinfo,new_pos,DFLT_INIT_HITS,info->buff)) DBUG_RETURN(-1); - DBUG_DUMP("key",(byte*) key,_mi_keylength(keyinfo,key)); + DBUG_DUMP("key",(uchar*) key,_mi_keylength(keyinfo,key)); DBUG_RETURN(2); /* Middle key up */ } /* _mi_split_page */ @@ -764,7 +764,7 @@ static int _mi_balance_page(register MI_INFO *info, MI_KEYDEF *keyinfo, length,keys; uchar *pos,*buff,*extra_buff; my_off_t next_page,new_pos; - byte tmp_part_key[MI_MAX_KEY_BUFF]; + uchar tmp_part_key[MI_MAX_KEY_BUFF]; DBUG_ENTER("_mi_balance_page"); k_length=keyinfo->keylength; @@ -796,7 +796,7 @@ static int _mi_balance_page(register MI_INFO *info, MI_KEYDEF *keyinfo, if (!_mi_fetch_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,info->buff,0)) goto err; - DBUG_DUMP("next",(byte*) info->buff,mi_getint(info->buff)); + DBUG_DUMP("next",(uchar*) info->buff,mi_getint(info->buff)); /* Test if there is room to share keys */ @@ -815,23 +815,23 @@ static int _mi_balance_page(register MI_INFO *info, MI_KEYDEF *keyinfo, if (left_length < new_left_length) { /* Move keys buff -> leaf */ pos=curr_buff+left_length; - memcpy((byte*) pos,(byte*) father_key_pos, (size_t) k_length); - memcpy((byte*) pos+k_length, (byte*) buff+2, + memcpy((uchar*) pos,(uchar*) father_key_pos, (size_t) k_length); + memcpy((uchar*) pos+k_length, (uchar*) buff+2, (size_t) (length=new_left_length - left_length - k_length)); pos=buff+2+length; - memcpy((byte*) father_key_pos,(byte*) pos,(size_t) k_length); - bmove((byte*) buff+2,(byte*) pos+k_length,new_right_length); + memcpy((uchar*) father_key_pos,(uchar*) pos,(size_t) k_length); + bmove((uchar*) buff+2,(uchar*) pos+k_length,new_right_length); } else { /* Move keys -> buff */ - bmove_upp((byte*) buff+new_right_length,(byte*) buff+right_length, + bmove_upp((uchar*) buff+new_right_length,(uchar*) buff+right_length, right_length-2); length=new_right_length-right_length-k_length; - memcpy((byte*) buff+2+length,father_key_pos,(size_t) k_length); + memcpy((uchar*) buff+2+length,father_key_pos,(size_t) k_length); pos=curr_buff+new_left_length; - memcpy((byte*) father_key_pos,(byte*) pos,(size_t) k_length); - memcpy((byte*) buff+2,(byte*) pos+k_length,(size_t) length); + memcpy((uchar*) father_key_pos,(uchar*) pos,(size_t) k_length); + memcpy((uchar*) buff+2,(uchar*) pos+k_length,(size_t) length); } if (_mi_write_keypage(info,keyinfo,next_page,DFLT_INIT_HITS,info->buff) || @@ -858,22 +858,22 @@ static int _mi_balance_page(register MI_INFO *info, MI_KEYDEF *keyinfo, /* move first largest keys to new page */ pos=buff+right_length-extra_length; - memcpy((byte*) extra_buff+2,pos,(size_t) extra_length); + memcpy((uchar*) extra_buff+2,pos,(size_t) extra_length); /* Save new parting key */ memcpy(tmp_part_key, pos-k_length,k_length); /* Make place for new keys */ - bmove_upp((byte*) buff+new_right_length,(byte*) pos-k_length, + bmove_upp((uchar*) buff+new_right_length,(uchar*) pos-k_length, right_length-extra_length-k_length-2); /* Copy keys from left page */ pos= curr_buff+new_left_length; - memcpy((byte*) buff+2,(byte*) pos+k_length, + memcpy((uchar*) buff+2,(uchar*) pos+k_length, (size_t) (length=left_length-new_left_length-k_length)); /* Copy old parting key */ - memcpy((byte*) buff+2+length,father_key_pos,(size_t) k_length); + memcpy((uchar*) buff+2+length,father_key_pos,(size_t) k_length); /* Move new parting keys up to caller */ - memcpy((byte*) (right ? key : father_key_pos),pos,(size_t) k_length); - memcpy((byte*) (right ? father_key_pos : key),tmp_part_key, k_length); + memcpy((uchar*) (right ? key : father_key_pos),pos,(size_t) k_length); + memcpy((uchar*) (right ? father_key_pos : key),tmp_part_key, k_length); if ((new_pos=_mi_new(info,keyinfo,DFLT_INIT_HITS)) == HA_OFFSET_ERROR) goto err; diff --git a/storage/myisam/myisam_ftdump.c b/storage/myisam/myisam_ftdump.c index 4bc1833cca6..63d954242a0 100644 --- a/storage/myisam/myisam_ftdump.c +++ b/storage/myisam/myisam_ftdump.c @@ -46,7 +46,7 @@ static struct my_option my_long_options[] = {"stats", 's', "Report global stats.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"verbose", 'v', "Be verbose.", - (gptr*) &verbose, (gptr*) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + (uchar**) &verbose, (uchar**) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/myisam/myisamchk.c b/storage/myisam/myisamchk.c index 066e6cdb81b..3700251ab15 100644 --- a/storage/myisam/myisamchk.c +++ b/storage/myisam/myisamchk.c @@ -68,9 +68,9 @@ static void get_options(int *argc,char * * *argv); static void print_version(void); static void usage(void); static int myisamchk(MI_CHECK *param, char *filename); -static void descript(MI_CHECK *param, register MI_INFO *info, my_string name); +static void descript(MI_CHECK *param, register MI_INFO *info, char * name); static int mi_sort_records(MI_CHECK *param, register MI_INFO *info, - my_string name, uint sort_key, + char * name, uint sort_key, my_bool write_info, my_bool update_index); static int sort_record_index(MI_SORT_PARAM *sort_param, MI_INFO *info, MI_KEYDEF *keyinfo, @@ -167,7 +167,7 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR, "Directory where character sets are.", - (gptr*) &charsets_dir, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + (uchar**) &charsets_dir, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"check", 'c', "Check table for errors.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -187,8 +187,8 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"data-file-length", 'D', "Max length of data file (when recreating data-file when it's full).", - (gptr*) &check_param.max_data_file_length, - (gptr*) &check_param.max_data_file_length, + (uchar**) &check_param.max_data_file_length, + (uchar**) &check_param.max_data_file_length, 0, GET_LL, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"extend-check", 'e', "If used when checking a table, ensure that the table is 100 percent consistent, which will take a long time. If used when repairing a table, try to recover every possible row from the data file. Normally this will also find a lot of garbage rows; Don't use this option with repair if you are not totally desperate.", @@ -210,13 +210,13 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"keys-used", 'k', "Tell MyISAM to update only some specific keys. # is a bit mask of which keys to use. This can be used to get faster inserts.", - (gptr*) &check_param.keys_in_use, - (gptr*) &check_param.keys_in_use, + (uchar**) &check_param.keys_in_use, + (uchar**) &check_param.keys_in_use, 0, GET_ULL, REQUIRED_ARG, -1, 0, 0, 0, 0, 0}, {"max-record-length", OPT_MAX_RECORD_LENGTH, "Skip rows bigger than this if myisamchk can't allocate memory to hold it", - (gptr*) &check_param.max_record_length, - (gptr*) &check_param.max_record_length, + (uchar**) &check_param.max_record_length, + (uchar**) &check_param.max_record_length, 0, GET_ULL, REQUIRED_ARG, LONGLONG_MAX, 0, LONGLONG_MAX, 0, 0, 0}, {"medium-check", 'm', "Faster than extend-check, but only finds 99.99% of all errors. Should be good enough for most cases.", @@ -245,12 +245,12 @@ static struct my_option my_long_options[] = #endif {"set-auto-increment", 'A', "Force auto_increment to start at this or higher value. If no value is given, then sets the next auto_increment value to the highest used value for the auto key + 1.", - (gptr*) &check_param.auto_increment_value, - (gptr*) &check_param.auto_increment_value, + (uchar**) &check_param.auto_increment_value, + (uchar**) &check_param.auto_increment_value, 0, GET_ULL, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"set-collation", OPT_SET_COLLATION, "Change the collation used by the index", - (gptr*) &set_collation_name, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + (uchar**) &set_collation_name, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"set-variable", 'O', "Change the value of a variable. Please note that this option is deprecated; you can set variables directly with --variable-name=value.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, @@ -262,12 +262,12 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"sort-records", 'R', "Sort records according to an index. This makes your data much more localized and may speed up things. (It may be VERY slow to do a sort the first time!)", - (gptr*) &check_param.opt_sort_key, - (gptr*) &check_param.opt_sort_key, + (uchar**) &check_param.opt_sort_key, + (uchar**) &check_param.opt_sort_key, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"tmpdir", 't', "Path for temporary files.", - (gptr*) &opt_tmpdir, + (uchar**) &opt_tmpdir, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"update-state", 'U', "Mark tables as crashed if any errors were found.", @@ -285,54 +285,54 @@ static struct my_option my_long_options[] = "Wait if table is locked.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, { "key_buffer_size", OPT_KEY_BUFFER_SIZE, "", - (gptr*) &check_param.use_buffers, (gptr*) &check_param.use_buffers, 0, + (uchar**) &check_param.use_buffers, (uchar**) &check_param.use_buffers, 0, GET_ULONG, REQUIRED_ARG, (long) USE_BUFFER_INIT, (long) MALLOC_OVERHEAD, (long) ~0L, (long) MALLOC_OVERHEAD, (long) IO_SIZE, 0}, { "key_cache_block_size", OPT_KEY_CACHE_BLOCK_SIZE, "", - (gptr*) &opt_key_cache_block_size, - (gptr*) &opt_key_cache_block_size, 0, + (uchar**) &opt_key_cache_block_size, + (uchar**) &opt_key_cache_block_size, 0, GET_LONG, REQUIRED_ARG, MI_KEY_BLOCK_LENGTH, MI_MIN_KEY_BLOCK_LENGTH, MI_MAX_KEY_BLOCK_LENGTH, 0, MI_MIN_KEY_BLOCK_LENGTH, 0}, { "myisam_block_size", OPT_MYISAM_BLOCK_SIZE, "", - (gptr*) &opt_myisam_block_size, (gptr*) &opt_myisam_block_size, 0, + (uchar**) &opt_myisam_block_size, (uchar**) &opt_myisam_block_size, 0, GET_LONG, REQUIRED_ARG, MI_KEY_BLOCK_LENGTH, MI_MIN_KEY_BLOCK_LENGTH, MI_MAX_KEY_BLOCK_LENGTH, 0, MI_MIN_KEY_BLOCK_LENGTH, 0}, { "read_buffer_size", OPT_READ_BUFFER_SIZE, "", - (gptr*) &check_param.read_buffer_length, - (gptr*) &check_param.read_buffer_length, 0, GET_ULONG, REQUIRED_ARG, + (uchar**) &check_param.read_buffer_length, + (uchar**) &check_param.read_buffer_length, 0, GET_ULONG, REQUIRED_ARG, (long) READ_BUFFER_INIT, (long) MALLOC_OVERHEAD, (long) ~0L, (long) MALLOC_OVERHEAD, (long) 1L, 0}, { "write_buffer_size", OPT_WRITE_BUFFER_SIZE, "", - (gptr*) &check_param.write_buffer_length, - (gptr*) &check_param.write_buffer_length, 0, GET_ULONG, REQUIRED_ARG, + (uchar**) &check_param.write_buffer_length, + (uchar**) &check_param.write_buffer_length, 0, GET_ULONG, REQUIRED_ARG, (long) READ_BUFFER_INIT, (long) MALLOC_OVERHEAD, (long) ~0L, (long) MALLOC_OVERHEAD, (long) 1L, 0}, { "sort_buffer_size", OPT_SORT_BUFFER_SIZE, "", - (gptr*) &check_param.sort_buffer_length, - (gptr*) &check_param.sort_buffer_length, 0, GET_ULONG, REQUIRED_ARG, + (uchar**) &check_param.sort_buffer_length, + (uchar**) &check_param.sort_buffer_length, 0, GET_ULONG, REQUIRED_ARG, (long) SORT_BUFFER_INIT, (long) (MIN_SORT_BUFFER + MALLOC_OVERHEAD), (long) ~0L, (long) MALLOC_OVERHEAD, (long) 1L, 0}, { "sort_key_blocks", OPT_SORT_KEY_BLOCKS, "", - (gptr*) &check_param.sort_key_blocks, - (gptr*) &check_param.sort_key_blocks, 0, GET_ULONG, REQUIRED_ARG, + (uchar**) &check_param.sort_key_blocks, + (uchar**) &check_param.sort_key_blocks, 0, GET_ULONG, REQUIRED_ARG, BUFFERS_WHEN_SORTING, 4L, 100L, 0L, 1L, 0}, - { "decode_bits", OPT_DECODE_BITS, "", (gptr*) &decode_bits, - (gptr*) &decode_bits, 0, GET_UINT, REQUIRED_ARG, 9L, 4L, 17L, 0L, 1L, 0}, - { "ft_min_word_len", OPT_FT_MIN_WORD_LEN, "", (gptr*) &ft_min_word_len, - (gptr*) &ft_min_word_len, 0, GET_ULONG, REQUIRED_ARG, 4, 1, HA_FT_MAXCHARLEN, + { "decode_bits", OPT_DECODE_BITS, "", (uchar**) &decode_bits, + (uchar**) &decode_bits, 0, GET_UINT, REQUIRED_ARG, 9L, 4L, 17L, 0L, 1L, 0}, + { "ft_min_word_len", OPT_FT_MIN_WORD_LEN, "", (uchar**) &ft_min_word_len, + (uchar**) &ft_min_word_len, 0, GET_ULONG, REQUIRED_ARG, 4, 1, HA_FT_MAXCHARLEN, 0, 1, 0}, - { "ft_max_word_len", OPT_FT_MAX_WORD_LEN, "", (gptr*) &ft_max_word_len, - (gptr*) &ft_max_word_len, 0, GET_ULONG, REQUIRED_ARG, HA_FT_MAXCHARLEN, 10, + { "ft_max_word_len", OPT_FT_MAX_WORD_LEN, "", (uchar**) &ft_max_word_len, + (uchar**) &ft_max_word_len, 0, GET_ULONG, REQUIRED_ARG, HA_FT_MAXCHARLEN, 10, HA_FT_MAXCHARLEN, 0, 1, 0}, { "ft_stopword_file", OPT_FT_STOPWORD_FILE, "Use stopwords from this file instead of built-in list.", - (gptr*) &ft_stopword_file, (gptr*) &ft_stopword_file, 0, GET_STR, + (uchar**) &ft_stopword_file, (uchar**) &ft_stopword_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"stats_method", OPT_STATS_METHOD, "Specifies how index statistics collection code should threat NULLs. " "Possible values of name are \"nulls_unequal\" (default behavior for 4.1/5.0), " "\"nulls_equal\" (emulate 4.0 behavior), and \"nulls_ignored\".", - (gptr*) &myisam_stats_method_str, (gptr*) &myisam_stats_method_str, 0, + (uchar**) &myisam_stats_method_str, (uchar**) &myisam_stats_method_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -794,7 +794,7 @@ static void get_options(register int *argc,register char ***argv) /* Check table */ -static int myisamchk(MI_CHECK *param, my_string filename) +static int myisamchk(MI_CHECK *param, char * filename) { int error,lock_type,recreate; int rep_quick= param->testflag & (T_QUICK | T_FORCE_UNIQUENESS); @@ -1199,7 +1199,7 @@ end2: /* Write info about table */ -static void descript(MI_CHECK *param, register MI_INFO *info, my_string name) +static void descript(MI_CHECK *param, register MI_INFO *info, char * name) { uint key,keyseg_nr,field,start; reg3 MI_KEYDEF *keyinfo; @@ -1465,7 +1465,7 @@ static void descript(MI_CHECK *param, register MI_INFO *info, my_string name) /* Sort records according to one key */ static int mi_sort_records(MI_CHECK *param, - register MI_INFO *info, my_string name, + register MI_INFO *info, char * name, uint sort_key, my_bool write_info, my_bool update_index) @@ -1536,7 +1536,7 @@ static int mi_sort_records(MI_CHECK *param, mi_check_print_error(param,"Not enough memory for key block"); goto err; } - if (!(sort_param.record=(byte*) my_malloc((uint) share->base.pack_reclength, + if (!(sort_param.record=(uchar*) my_malloc((uint) share->base.pack_reclength, MYF(0)))) { mi_check_print_error(param,"Not enough memory for record"); @@ -1567,7 +1567,7 @@ static int mi_sort_records(MI_CHECK *param, for (key=0 ; key < share->base.keys ; key++) share->keyinfo[key].flag|= HA_SORT_ALLOWS_SAME; - if (my_pread(share->kfile,(byte*) temp_buff, + if (my_pread(share->kfile,(uchar*) temp_buff, (uint) keyinfo->block_length, share->state.key_root[sort_key], MYF(MY_NABP+MY_WME))) @@ -1630,7 +1630,7 @@ err: } if (temp_buff) { - my_afree((gptr) temp_buff); + my_afree((uchar*) temp_buff); } my_free(sort_param.record,MYF(MY_ALLOW_ZERO_PTR)); info->opt_flag&= ~(READ_CACHE_USED | WRITE_CACHE_USED); @@ -1679,7 +1679,7 @@ static int sort_record_index(MI_SORT_PARAM *sort_param,MI_INFO *info, if (nod_flag) { next_page=_mi_kpos(nod_flag,keypos); - if (my_pread(info->s->kfile,(byte*) temp_buff, + if (my_pread(info->s->kfile,(uchar*) temp_buff, (uint) keyinfo->block_length, next_page, MYF(MY_NABP+MY_WME))) { @@ -1718,19 +1718,19 @@ static int sort_record_index(MI_SORT_PARAM *sort_param,MI_INFO *info, goto err; } /* Clear end of block to get better compression if the table is backuped */ - bzero((byte*) buff+used_length,keyinfo->block_length-used_length); - if (my_pwrite(info->s->kfile,(byte*) buff,(uint) keyinfo->block_length, + bzero((uchar*) buff+used_length,keyinfo->block_length-used_length); + if (my_pwrite(info->s->kfile,(uchar*) buff,(uint) keyinfo->block_length, page,param->myf_rw)) { mi_check_print_error(param,"%d when updating keyblock",my_errno); goto err; } if (temp_buff) - my_afree((gptr) temp_buff); + my_afree((uchar*) temp_buff); DBUG_RETURN(0); err: if (temp_buff) - my_afree((gptr) temp_buff); + my_afree((uchar*) temp_buff); DBUG_RETURN(1); } /* sort_record_index */ diff --git a/storage/myisam/myisamdef.h b/storage/myisam/myisamdef.h index a491e6d210c..f68d66d4cbb 100644 --- a/storage/myisam/myisamdef.h +++ b/storage/myisam/myisamdef.h @@ -167,22 +167,22 @@ typedef struct st_mi_isam_share { /* Shared between opens */ char *unique_file_name; /* realpath() of index file */ char *data_file_name, /* Resolved path names from symlinks */ *index_file_name; - byte *file_map; /* mem-map of file if possible */ + uchar *file_map; /* mem-map of file if possible */ KEY_CACHE *key_cache; /* ref to the current key cache */ MI_DECODE_TREE *decode_trees; uint16 *decode_tables; - int (*read_record)(struct st_myisam_info*, my_off_t, byte*); - int (*write_record)(struct st_myisam_info*, const byte*); - int (*update_record)(struct st_myisam_info*, my_off_t, const byte*); + int (*read_record)(struct st_myisam_info*, my_off_t, uchar*); + int (*write_record)(struct st_myisam_info*, const uchar*); + int (*update_record)(struct st_myisam_info*, my_off_t, const uchar*); int (*delete_record)(struct st_myisam_info*); - int (*read_rnd)(struct st_myisam_info*, byte*, my_off_t, my_bool); - int (*compare_record)(struct st_myisam_info*, const byte *); + int (*read_rnd)(struct st_myisam_info*, uchar*, my_off_t, my_bool); + int (*compare_record)(struct st_myisam_info*, const uchar *); /* Function to use for a row checksum. */ - ha_checksum (*calc_checksum)(struct st_myisam_info*, const byte *); + ha_checksum (*calc_checksum)(struct st_myisam_info*, const uchar *); int (*compare_unique)(struct st_myisam_info*, MI_UNIQUEDEF *, - const byte *record, my_off_t pos); - uint (*file_read)(MI_INFO *, byte *, uint, my_off_t, myf); - uint (*file_write)(MI_INFO *, byte *, uint, my_off_t, myf); + const uchar *record, my_off_t pos); + uint (*file_read)(MI_INFO *, uchar *, uint, my_off_t, myf); + uint (*file_write)(MI_INFO *, uchar *, uint, my_off_t, myf); invalidator_by_filename invalidator; /* query cache invalidator */ ulong this_process; /* processid */ ulong last_process; /* For table-change-check */ @@ -245,12 +245,12 @@ struct st_myisam_info { uchar *buff, /* Temp area for key */ *lastkey,*lastkey2; /* Last used search key */ uchar *first_mbr_key; /* Searhed spatial key */ - byte *rec_buff; /* Tempbuff for recordpack */ + uchar *rec_buff; /* Tempbuff for recordpack */ uchar *int_keypos, /* Save position for next/previous */ *int_maxpos; /* -""- */ uint int_nod_flag; /* -""- */ uint32 int_keytree_version; /* -""- */ - int (*read_record)(struct st_myisam_info*, my_off_t, byte*); + int (*read_record)(struct st_myisam_info*, my_off_t, uchar*); invalidator_by_filename invalidator; /* query cache invalidator */ ulong this_unique; /* uniq filenumber or thread */ ulong last_unique; /* last unique number */ @@ -334,10 +334,10 @@ typedef struct st_mi_sort_param HA_KEYSEG *seg; SORT_INFO *sort_info; uchar **sort_keys; - byte *rec_buff; + uchar *rec_buff; void *wordlist, *wordptr; MEM_ROOT wordroot; - char *record; + uchar *record; MY_TMPDIR *tmpdir; int (*key_cmp)(struct st_mi_sort_param *, const void *, const void *); int (*key_read)(struct st_mi_sort_param *,void *); @@ -349,6 +349,7 @@ typedef struct st_mi_sort_param NEAR int (*write_key)(struct st_mi_sort_param *, IO_CACHE *,char *, uint, uint); } MI_SORT_PARAM; + /* Some defines used by isam-funktions */ #define USE_WHOLE_KEY MI_MAX_KEY_BUFF*2 /* Use whole key in _mi_search() */ @@ -497,20 +498,20 @@ typedef struct st_mi_s_param /* Prototypes for intern functions */ -extern int _mi_read_dynamic_record(MI_INFO *info,my_off_t filepos,byte *buf); -extern int _mi_write_dynamic_record(MI_INFO*, const byte*); -extern int _mi_update_dynamic_record(MI_INFO*, my_off_t, const byte*); +extern int _mi_read_dynamic_record(MI_INFO *info,my_off_t filepos,uchar *buf); +extern int _mi_write_dynamic_record(MI_INFO*, const uchar*); +extern int _mi_update_dynamic_record(MI_INFO*, my_off_t, const uchar*); extern int _mi_delete_dynamic_record(MI_INFO *info); -extern int _mi_cmp_dynamic_record(MI_INFO *info,const byte *record); -extern int _mi_read_rnd_dynamic_record(MI_INFO *, byte *,my_off_t, my_bool); -extern int _mi_write_blob_record(MI_INFO*, const byte*); -extern int _mi_update_blob_record(MI_INFO*, my_off_t, const byte*); -extern int _mi_read_static_record(MI_INFO *info, my_off_t filepos,byte *buf); -extern int _mi_write_static_record(MI_INFO*, const byte*); -extern int _mi_update_static_record(MI_INFO*, my_off_t, const byte*); +extern int _mi_cmp_dynamic_record(MI_INFO *info,const uchar *record); +extern int _mi_read_rnd_dynamic_record(MI_INFO *, uchar *,my_off_t, my_bool); +extern int _mi_write_blob_record(MI_INFO*, const uchar*); +extern int _mi_update_blob_record(MI_INFO*, my_off_t, const uchar*); +extern int _mi_read_static_record(MI_INFO *info, my_off_t filepos,uchar *buf); +extern int _mi_write_static_record(MI_INFO*, const uchar*); +extern int _mi_update_static_record(MI_INFO*, my_off_t, const uchar*); extern int _mi_delete_static_record(MI_INFO *info); -extern int _mi_cmp_static_record(MI_INFO *info,const byte *record); -extern int _mi_read_rnd_static_record(MI_INFO*, byte *,my_off_t, my_bool); +extern int _mi_cmp_static_record(MI_INFO *info,const uchar *record); +extern int _mi_read_rnd_static_record(MI_INFO*, uchar *,my_off_t, my_bool); extern int _mi_ck_write(MI_INFO *info,uint keynr,uchar *key,uint length); extern int _mi_ck_real_write_btree(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, uint key_length, @@ -604,39 +605,39 @@ extern int _mi_dispose(MI_INFO *info,MI_KEYDEF *keyinfo,my_off_t pos, int level); extern my_off_t _mi_new(MI_INFO *info,MI_KEYDEF *keyinfo,int level); extern uint _mi_make_key(MI_INFO *info,uint keynr,uchar *key, - const byte *record,my_off_t filepos); + const uchar *record,my_off_t filepos); extern uint _mi_pack_key(register MI_INFO *info, uint keynr, uchar *key, uchar *old, key_part_map keypart_map, HA_KEYSEG **last_used_keyseg); -extern int _mi_read_key_record(MI_INFO *info,my_off_t filepos,byte *buf); -extern int _mi_read_cache(IO_CACHE *info,byte *buff,my_off_t pos, +extern int _mi_read_key_record(MI_INFO *info,my_off_t filepos,uchar *buf); +extern int _mi_read_cache(IO_CACHE *info,uchar *buff,my_off_t pos, uint length,int re_read_if_possibly); -extern ulonglong retrieve_auto_increment(MI_INFO *info,const byte *record); +extern ulonglong retrieve_auto_increment(MI_INFO *info,const uchar *record); -extern byte *mi_alloc_rec_buff(MI_INFO *,ulong, byte**); +extern uchar *mi_alloc_rec_buff(MI_INFO *,ulong, uchar**); #define mi_get_rec_buff_ptr(info,buf) \ ((((info)->s->options & HA_OPTION_PACK_RECORD) && (buf)) ? \ (buf) - MI_REC_BUFF_OFFSET : (buf)) #define mi_get_rec_buff_len(info,buf) \ (*((uint32 *)(mi_get_rec_buff_ptr(info,buf)))) -extern ulong _mi_rec_unpack(MI_INFO *info,byte *to,byte *from, +extern ulong _mi_rec_unpack(MI_INFO *info,uchar *to,uchar *from, ulong reclength); -extern my_bool _mi_rec_check(MI_INFO *info,const char *record, byte *packpos, +extern my_bool _mi_rec_check(MI_INFO *info,const uchar *record, uchar *packpos, ulong packed_length, my_bool with_checkum); extern int _mi_write_part_record(MI_INFO *info,my_off_t filepos,ulong length, - my_off_t next_filepos,byte **record, + my_off_t next_filepos,uchar **record, ulong *reclength,int *flag); extern void _mi_print_key(FILE *stream,HA_KEYSEG *keyseg,const uchar *key, uint length); extern my_bool _mi_read_pack_info(MI_INFO *info,pbool fix_keys); -extern int _mi_read_pack_record(MI_INFO *info,my_off_t filepos,byte *buf); -extern int _mi_read_rnd_pack_record(MI_INFO*, byte *,my_off_t, my_bool); +extern int _mi_read_pack_record(MI_INFO *info,my_off_t filepos,uchar *buf); +extern int _mi_read_rnd_pack_record(MI_INFO*, uchar *,my_off_t, my_bool); extern int _mi_pack_rec_unpack(MI_INFO *info, MI_BIT_BUFF *bit_buff, - byte *to, byte *from, ulong reclength); + uchar *to, uchar *from, ulong reclength); extern ulonglong mi_safe_mul(ulonglong a,ulonglong b); -extern int _mi_ft_update(MI_INFO *info, uint keynr, byte *keybuf, - const byte *oldrec, const byte *newrec, my_off_t pos); +extern int _mi_ft_update(MI_INFO *info, uint keynr, uchar *keybuf, + const uchar *oldrec, const uchar *newrec, my_off_t pos); struct st_sort_info; @@ -697,32 +698,32 @@ extern "C" { #endif extern uint _mi_get_block_info(MI_BLOCK_INFO *,File, my_off_t); -extern uint _mi_rec_pack(MI_INFO *info,byte *to,const byte *from); +extern uint _mi_rec_pack(MI_INFO *info,uchar *to,const uchar *from); extern uint _mi_pack_get_block_info(MI_INFO *myisam, MI_BIT_BUFF *bit_buff, - MI_BLOCK_INFO *info, byte **rec_buff_p, + MI_BLOCK_INFO *info, uchar **rec_buff_p, File file, my_off_t filepos); -extern void _my_store_blob_length(byte *pos,uint pack_length,uint length); +extern void _my_store_blob_length(uchar *pos,uint pack_length,uint length); extern void _myisam_log(enum myisam_log_commands command,MI_INFO *info, - const byte *buffert,uint length); + const uchar *buffert,uint length); extern void _myisam_log_command(enum myisam_log_commands command, - MI_INFO *info, const byte *buffert, + MI_INFO *info, const uchar *buffert, uint length, int result); extern void _myisam_log_record(enum myisam_log_commands command,MI_INFO *info, - const byte *record,my_off_t filepos, + const uchar *record,my_off_t filepos, int result); extern void mi_report_error(int errcode, const char *file_name); extern my_bool _mi_memmap_file(MI_INFO *info); extern void _mi_unmap_file(MI_INFO *info); -extern uint save_pack_length(uint version, byte *block_buff, ulong length); +extern uint save_pack_length(uint version, uchar *block_buff, ulong length); extern uint read_pack_length(uint version, const uchar *buf, ulong *length); extern uint calc_pack_length(uint version, ulong length); -extern uint mi_mmap_pread(MI_INFO *info, byte *Buffer, +extern uint mi_mmap_pread(MI_INFO *info, uchar *Buffer, uint Count, my_off_t offset, myf MyFlags); -extern uint mi_mmap_pwrite(MI_INFO *info, byte *Buffer, +extern uint mi_mmap_pwrite(MI_INFO *info, uchar *Buffer, uint Count, my_off_t offset, myf MyFlags); -extern uint mi_nommap_pread(MI_INFO *info, byte *Buffer, +extern uint mi_nommap_pread(MI_INFO *info, uchar *Buffer, uint Count, my_off_t offset, myf MyFlags); -extern uint mi_nommap_pwrite(MI_INFO *info, byte *Buffer, +extern uint mi_nommap_pwrite(MI_INFO *info, uchar *Buffer, uint Count, my_off_t offset, myf MyFlags); uint mi_state_info_write(File file, MI_STATE_INFO *state, uint pWrite); @@ -741,17 +742,17 @@ char *mi_recinfo_read(char *ptr, MI_COLUMNDEF *recinfo); extern int mi_disable_indexes(MI_INFO *info); extern int mi_enable_indexes(MI_INFO *info); extern int mi_indexes_are_disabled(MI_INFO *info); -ulong _my_calc_total_blob_length(MI_INFO *info, const byte *record); -ha_checksum mi_checksum(MI_INFO *info, const byte *buf); -ha_checksum mi_static_checksum(MI_INFO *info, const byte *buf); -my_bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, byte *record, +ulong _my_calc_total_blob_length(MI_INFO *info, const uchar *record); +ha_checksum mi_checksum(MI_INFO *info, const uchar *buf); +ha_checksum mi_static_checksum(MI_INFO *info, const uchar *buf); +my_bool mi_check_unique(MI_INFO *info, MI_UNIQUEDEF *def, uchar *record, ha_checksum unique_hash, my_off_t pos); -ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const byte *buf); +ha_checksum mi_unique_hash(MI_UNIQUEDEF *def, const uchar *buf); int _mi_cmp_static_unique(MI_INFO *info, MI_UNIQUEDEF *def, - const byte *record, my_off_t pos); + const uchar *record, my_off_t pos); int _mi_cmp_dynamic_unique(MI_INFO *info, MI_UNIQUEDEF *def, - const byte *record, my_off_t pos); -int mi_unique_comp(MI_UNIQUEDEF *def, const byte *a, const byte *b, + const uchar *record, my_off_t pos); +int mi_unique_comp(MI_UNIQUEDEF *def, const uchar *a, const uchar *b, my_bool null_are_equal); void mi_get_status(void* param, int concurrent_insert); void mi_update_status(void* param); diff --git a/storage/myisam/myisamlog.c b/storage/myisam/myisamlog.c index 0bcf74d87a4..1cf4ad730cb 100644 --- a/storage/myisam/myisamlog.c +++ b/storage/myisam/myisamlog.c @@ -32,14 +32,14 @@ struct file_info { long process; int filenr,id; uint rnd; - my_string name,show_name,record; + char *name, *show_name, *record; MI_INFO *isam; bool closed,used; ulong accessed; }; struct test_if_open_param { - my_string name; + char * name; int max_id; }; @@ -53,24 +53,25 @@ struct st_access_param extern int main(int argc,char * *argv); static void get_options(int *argc,char ***argv); -static int examine_log(my_string file_name,char **table_names); -static int read_string(IO_CACHE *file,gptr *to,uint length); +static int examine_log(char * file_name,char **table_names); +static int read_string(IO_CACHE *file,uchar* *to,uint length); static int file_info_compare(void *cmp_arg, void *a,void *b); static int test_if_open(struct file_info *key,element_count count, struct test_if_open_param *param); -static void fix_blob_pointers(MI_INFO *isam,byte *record); +static void fix_blob_pointers(MI_INFO *isam,uchar *record); static int test_when_accessed(struct file_info *key,element_count count, struct st_access_param *access_param); static void file_info_free(struct file_info *info); static int close_some_file(TREE *tree); static int reopen_closed_file(TREE *tree,struct file_info *file_info); -static int find_record_with_key(struct file_info *file_info,byte *record); +static int find_record_with_key(struct file_info *file_info,uchar *record); static void printf_log(const char *str,...); -static bool cmp_filename(struct file_info *file_info,my_string name); +static bool cmp_filename(struct file_info *file_info,char * name); static uint verbose=0,update=0,test_info=0,max_files=0,re_open_count=0, recover=0,prefix_remove=0,opt_processes=0; -static my_string log_filename=0,filepath=0,write_filename=0,record_pos_file=0; +static char *log_filename=0, *filepath=0, *write_filename=0; +static char *record_pos_file= 0; static ulong com_count[10][3],number_of_commands=(ulong) ~0L, isamlog_process; static my_off_t isamlog_filepos,start_offset=0,record_pos= HA_OFFSET_ERROR; @@ -296,7 +297,7 @@ static void get_options(register int *argc, register char ***argv) } -static int examine_log(my_string file_name, char **table_names) +static int examine_log(char * file_name, char **table_names) { uint command,result,files_open; ulong access_time,length; @@ -304,7 +305,7 @@ static int examine_log(my_string file_name, char **table_names) int lock_command,mi_result; char isam_file_name[FN_REFLEN],llbuff[21],llbuff2[21]; uchar head[20]; - gptr buff; + uchar* buff; struct test_if_open_param open_param; IO_CACHE cache; File file; @@ -327,7 +328,7 @@ static int examine_log(my_string file_name, char **table_names) } init_io_cache(&cache,file,0,READ_CACHE,start_offset,0,MYF(0)); - bzero((gptr) com_count,sizeof(com_count)); + bzero((uchar*) com_count,sizeof(com_count)); init_tree(&tree,0,0,sizeof(file_info),(qsort_cmp2) file_info_compare,1, (tree_element_free) file_info_free, NULL); VOID(init_key_cache(dflt_key_cache,KEY_CACHE_BLOCK_SIZE,KEY_CACHE_SIZE, @@ -335,7 +336,7 @@ static int examine_log(my_string file_name, char **table_names) files_open=0; access_time=0; while (access_time++ != number_of_commands && - !my_b_read(&cache,(byte*) head,9)) + !my_b_read(&cache,(uchar*) head,9)) { isamlog_filepos=my_b_tell(&cache)-9L; file_info.filenr= mi_uint2korr(head+1); @@ -375,14 +376,15 @@ static int examine_log(my_string file_name, char **table_names) } if (curr_file_info) - printf("\nWarning: %s is opened with same process and filenumber\nMaybe you should use the -P option ?\n", + printf("\nWarning: %s is opened with same process and filenumber\n" + "Maybe you should use the -P option ?\n", curr_file_info->show_name); - if (my_b_read(&cache,(byte*) head,2)) + if (my_b_read(&cache,(uchar*) head,2)) goto err; file_info.name=0; file_info.show_name=0; file_info.record=0; - if (read_string(&cache,(gptr*) &file_info.name, + if (read_string(&cache,(uchar**) &file_info.name, (uint) mi_uint2korr(head))) goto err; { @@ -455,7 +457,7 @@ static int examine_log(my_string file_name, char **table_names) files_open++; file_info.closed=0; } - VOID(tree_insert(&tree, (gptr) &file_info, 0, tree.custom_arg)); + VOID(tree_insert(&tree, (uchar*) &file_info, 0, tree.custom_arg)); if (file_info.used) { if (verbose && !record_pos_file) @@ -474,11 +476,11 @@ static int examine_log(my_string file_name, char **table_names) { if (!curr_file_info->closed) files_open--; - VOID(tree_delete(&tree, (gptr) curr_file_info, 0, tree.custom_arg)); + VOID(tree_delete(&tree, (uchar*) curr_file_info, 0, tree.custom_arg)); } break; case MI_LOG_EXTRA: - if (my_b_read(&cache,(byte*) head,1)) + if (my_b_read(&cache,(uchar*) head,1)) goto err; extra_command=(enum ha_extra_function) head[0]; if (verbose && !record_pos_file && @@ -499,7 +501,7 @@ static int examine_log(my_string file_name, char **table_names) } break; case MI_LOG_DELETE: - if (my_b_read(&cache,(byte*) head,8)) + if (my_b_read(&cache,(uchar*) head,8)) goto err; filepos=mi_sizekorr(head); if (verbose && (!record_pos_file || @@ -534,7 +536,7 @@ static int examine_log(my_string file_name, char **table_names) break; case MI_LOG_WRITE: case MI_LOG_UPDATE: - if (my_b_read(&cache,(byte*) head,12)) + if (my_b_read(&cache,(uchar*) head,12)) goto err; filepos=mi_sizekorr(head); length=mi_uint4korr(head+8); @@ -616,7 +618,7 @@ static int examine_log(my_string file_name, char **table_names) my_free(buff,MYF(0)); break; case MI_LOG_LOCK: - if (my_b_read(&cache,(byte*) head,sizeof(lock_command))) + if (my_b_read(&cache,(uchar*) head,sizeof(lock_command))) goto err; memcpy_fixed(&lock_command,head,sizeof(lock_command)); if (verbose && !record_pos_file && @@ -675,14 +677,14 @@ static int examine_log(my_string file_name, char **table_names) } -static int read_string(IO_CACHE *file, register gptr *to, register uint length) +static int read_string(IO_CACHE *file, register uchar* *to, register uint length) { DBUG_ENTER("read_string"); if (*to) - my_free((gptr) *to,MYF(0)); - if (!(*to= (gptr) my_malloc(length+1,MYF(MY_WME))) || - my_b_read(file,(byte*) *to,length)) + my_free((uchar*) *to,MYF(0)); + if (!(*to= (uchar*) my_malloc(length+1,MYF(MY_WME))) || + my_b_read(file,(uchar*) *to,length)) { if (*to) my_free(*to,MYF(0)); @@ -717,9 +719,9 @@ static int test_if_open (struct file_info *key, } -static void fix_blob_pointers(MI_INFO *info, byte *record) +static void fix_blob_pointers(MI_INFO *info, uchar *record) { - byte *pos; + uchar *pos; MI_BLOB *blob,*end; pos=record+info->s->base.reclength; @@ -801,7 +803,7 @@ static int reopen_closed_file(TREE *tree, struct file_info *fileinfo) /* Try to find record with uniq key */ -static int find_record_with_key(struct file_info *file_info, byte *record) +static int find_record_with_key(struct file_info *file_info, uchar *record) { uint key; MI_INFO *info=file_info->isam; @@ -836,7 +838,7 @@ static void printf_log(const char *format,...) } -static bool cmp_filename(struct file_info *file_info, my_string name) +static bool cmp_filename(struct file_info *file_info, char * name) { if (!file_info) return 1; diff --git a/storage/myisam/myisampack.c b/storage/myisam/myisampack.c index fb631b5e63e..5f7c4ee8f2e 100644 --- a/storage/myisam/myisampack.c +++ b/storage/myisam/myisampack.c @@ -69,8 +69,8 @@ typedef struct st_huff_counts { my_off_t pre_space[8]; my_off_t tot_end_space,tot_pre_space,zero_fields,empty_fields,bytes_packed; TREE int_tree; /* Tree for detecting distinct column values. */ - byte *tree_buff; /* Column values, 'field_length' each. */ - byte *tree_pos; /* Points to end of column values in 'tree_buff'. */ + uchar *tree_buff; /* Column values, 'field_length' each. */ + uchar *tree_pos; /* Points to end of column values in 'tree_buff'. */ } HUFF_COUNTS; typedef struct st_huff_element HUFF_ELEMENT; @@ -141,8 +141,8 @@ static int test_space_compress(HUFF_COUNTS *huff_counts,my_off_t records, enum en_fieldtype field_type); static HUFF_TREE* make_huff_trees(HUFF_COUNTS *huff_counts,uint trees); static int make_huff_tree(HUFF_TREE *tree,HUFF_COUNTS *huff_counts); -static int compare_huff_elements(void *not_used, byte *a,byte *b); -static int save_counts_in_queue(byte *key,element_count count, +static int compare_huff_elements(void *not_used, uchar *a,uchar *b); +static int save_counts_in_queue(uchar *key,element_count count, HUFF_TREE *tree); static my_off_t calc_packed_length(HUFF_COUNTS *huff_counts,uint flag); static uint join_same_trees(HUFF_COUNTS *huff_counts,uint trees); @@ -171,7 +171,7 @@ static int save_state(MI_INFO *isam_file,PACK_MRG_INFO *mrg,my_off_t new_length, static int save_state_mrg(File file,PACK_MRG_INFO *isam_file,my_off_t new_length, ha_checksum crc); static int mrg_close(PACK_MRG_INFO *mrg); -static int mrg_rrnd(PACK_MRG_INFO *info,byte *buf); +static int mrg_rrnd(PACK_MRG_INFO *info,uchar *buf); static void mrg_reset(PACK_MRG_INFO *mrg); #if !defined(DBUG_OFF) static void fakebigcodes(HUFF_COUNTS *huff_counts, HUFF_COUNTS *end_count); @@ -257,10 +257,10 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #endif {"backup", 'b', "Make a backup of the table as table_name.OLD.", - (gptr*) &backup, (gptr*) &backup, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + (uchar**) &backup, (uchar**) &backup, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, {"character-sets-dir", OPT_CHARSETS_DIR_MP, - "Directory where character sets are.", (gptr*) &charsets_dir, - (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + "Directory where character sets are.", (uchar**) &charsets_dir, + (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"force", 'f', @@ -268,7 +268,7 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"join", 'j', "Join all given tables into 'new_table_name'. All tables MUST have identical layouts.", - (gptr*) &join_table, (gptr*) &join_table, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, + (uchar**) &join_table, (uchar**) &join_table, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, @@ -282,8 +282,8 @@ static struct my_option my_long_options[] = 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"wait", 'w', "Wait and retry if table is in use.", (gptr*) &opt_wait, - (gptr*) &opt_wait, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"wait", 'w', "Wait and retry if table is in use.", (uchar**) &opt_wait, + (uchar**) &opt_wait, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; @@ -478,7 +478,7 @@ static bool open_isam_files(PACK_MRG_INFO *mrg,char **names,uint count) error: while (i--) mi_close(mrg->file[i]); - my_free((gptr) mrg->file,MYF(0)); + my_free((uchar*) mrg->file,MYF(0)); return 1; } @@ -811,11 +811,11 @@ static void free_counts_and_tree_and_queue(HUFF_TREE *huff_trees, uint trees, for (i=0 ; i < trees ; i++) { if (huff_trees[i].element_buffer) - my_free((gptr) huff_trees[i].element_buffer,MYF(0)); + my_free((uchar*) huff_trees[i].element_buffer,MYF(0)); if (huff_trees[i].code) - my_free((gptr) huff_trees[i].code,MYF(0)); + my_free((uchar*) huff_trees[i].code,MYF(0)); } - my_free((gptr) huff_trees,MYF(0)); + my_free((uchar*) huff_trees,MYF(0)); } if (huff_counts) { @@ -823,11 +823,11 @@ static void free_counts_and_tree_and_queue(HUFF_TREE *huff_trees, uint trees, { if (huff_counts[i].tree_buff) { - my_free((gptr) huff_counts[i].tree_buff,MYF(0)); + my_free((uchar*) huff_counts[i].tree_buff,MYF(0)); delete_tree(&huff_counts[i].int_tree); } } - my_free((gptr) huff_counts,MYF(0)); + my_free((uchar*) huff_counts,MYF(0)); } delete_queue(&queue); /* This is safe to free */ return; @@ -840,7 +840,7 @@ static int get_statistic(PACK_MRG_INFO *mrg,HUFF_COUNTS *huff_counts) int error; uint length; ulong reclength,max_blob_length; - byte *record,*pos,*next_pos,*end_pos,*start_pos; + uchar *record,*pos,*next_pos,*end_pos,*start_pos; ha_rows record_count; my_bool static_row_size; HUFF_COUNTS *count,*end_count; @@ -848,7 +848,7 @@ static int get_statistic(PACK_MRG_INFO *mrg,HUFF_COUNTS *huff_counts) DBUG_ENTER("get_statistic"); reclength=mrg->file[0]->s->base.reclength; - record=(byte*) my_alloca(reclength); + record=(uchar*) my_alloca(reclength); end_count=huff_counts+mrg->file[0]->s->base.fields; record_count=0; glob_crc=0; max_blob_length=0; @@ -1032,7 +1032,7 @@ static int get_statistic(PACK_MRG_INFO *mrg,HUFF_COUNTS *huff_counts) { uint i; /* Zero fields are just counted. Go to the next record. */ - if (!memcmp((byte*) start_pos,zero_string,count->field_length)) + if (!memcmp((uchar*) start_pos,zero_string,count->field_length)) { count->zero_fields++; continue; @@ -1141,12 +1141,12 @@ static int get_statistic(PACK_MRG_INFO *mrg,HUFF_COUNTS *huff_counts) mrg->records=record_count; mrg->max_blob_length=max_blob_length; - my_afree((gptr) record); + my_afree((uchar*) record); DBUG_RETURN(error != HA_ERR_END_OF_FILE); } static int compare_huff_elements(void *not_used __attribute__((unused)), - byte *a, byte *b) + uchar *a, uchar *b) { return *((my_off_t*) a) < *((my_off_t*) b) ? -1 : (*((my_off_t*) a) == *((my_off_t*) b) ? 0 : 1); @@ -1162,7 +1162,7 @@ static void check_counts(HUFF_COUNTS *huff_counts, uint trees, my_off_t old_length,new_length,length; DBUG_ENTER("check_counts"); - bzero((gptr) field_count,sizeof(field_count)); + bzero((uchar*) field_count,sizeof(field_count)); space_fields=fill_zero_fields=0; for (; trees-- ; huff_counts++) @@ -1328,12 +1328,12 @@ static void check_counts(HUFF_COUNTS *huff_counts, uint trees, } else { - my_free((gptr) huff_counts->tree_buff,MYF(0)); + my_free((uchar*) huff_counts->tree_buff,MYF(0)); delete_tree(&huff_counts->int_tree); huff_counts->tree_buff=0; } if (tree.element_buffer) - my_free((gptr) tree.element_buffer,MYF(0)); + my_free((uchar*) tree.element_buffer,MYF(0)); } if (huff_counts->pack_type & PACK_TYPE_SPACE_FIELDS) space_fields++; @@ -1450,8 +1450,8 @@ static HUFF_TREE* make_huff_trees(HUFF_COUNTS *huff_counts, uint trees) if (make_huff_tree(huff_tree+tree,huff_counts+tree)) { while (tree--) - my_free((gptr) huff_tree[tree].element_buffer,MYF(0)); - my_free((gptr) huff_tree,MYF(0)); + my_free((uchar*) huff_tree[tree].element_buffer,MYF(0)); + my_free((uchar*) huff_tree,MYF(0)); DBUG_RETURN(0); } } @@ -1526,7 +1526,7 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts) { HUFF_ELEMENT *temp; if (!(temp= - (HUFF_ELEMENT*) my_realloc((gptr) huff_tree->element_buffer, + (HUFF_ELEMENT*) my_realloc((uchar*) huff_tree->element_buffer, found*2*sizeof(HUFF_ELEMENT), MYF(MY_WME)))) return 1; @@ -1561,7 +1561,7 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts) */ tree_walk(&huff_counts->int_tree, (int (*)(void*, element_count,void*)) save_counts_in_queue, - (gptr) huff_tree, left_root_right); + (uchar*) huff_tree, left_root_right); } else { @@ -1587,7 +1587,7 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts) new_huff_el->count=huff_counts->counts[i]; new_huff_el->a.leaf.null=0; new_huff_el->a.leaf.element_nr=i; - queue.root[found]=(byte*) new_huff_el; + queue.root[found]=(uchar*) new_huff_el; } } /* @@ -1604,7 +1604,7 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts) new_huff_el->a.leaf.element_nr=huff_tree->min_chr=last-1; else new_huff_el->a.leaf.element_nr=huff_tree->max_chr=last+1; - queue.root[found]=(byte*) new_huff_el; + queue.root[found]=(uchar*) new_huff_el; } } @@ -1654,7 +1654,7 @@ static int make_huff_tree(HUFF_TREE *huff_tree, HUFF_COUNTS *huff_counts) Replace the copied top element by the new element and re-order the queue. */ - queue.root[1]=(byte*) new_huff_el; + queue.root[1]=(uchar*) new_huff_el; queue_replaced(&queue); } huff_tree->root=(HUFF_ELEMENT*) queue.root[1]; @@ -1693,7 +1693,7 @@ static int compare_tree(void* cmp_arg __attribute__((unused)), 0 */ -static int save_counts_in_queue(byte *key, element_count count, +static int save_counts_in_queue(uchar *key, element_count count, HUFF_TREE *tree) { HUFF_ELEMENT *new_huff_el; @@ -1703,7 +1703,7 @@ static int save_counts_in_queue(byte *key, element_count count, new_huff_el->a.leaf.null=0; new_huff_el->a.leaf.element_nr= (uint) (key- tree->counts->tree_buff) / tree->counts->field_length; - queue.root[tree->elements]=(byte*) new_huff_el; + queue.root[tree->elements]=(uchar*) new_huff_el; return 0; } @@ -1760,7 +1760,7 @@ static my_off_t calc_packed_length(HUFF_COUNTS *huff_counts, first=i; last=i; /* We start with root[1], which is the queues top element. */ - queue.root[found]=(byte*) &huff_counts->counts[i]; + queue.root[found]=(uchar*) &huff_counts->counts[i]; } } if (!found) @@ -1771,7 +1771,7 @@ static my_off_t calc_packed_length(HUFF_COUNTS *huff_counts, the loop, which follows the Huffman algorithm. */ if (found < 2) - queue.root[++found]=(byte*) &huff_counts->counts[last ? 0 : 1]; + queue.root[++found]=(uchar*) &huff_counts->counts[last ? 0 : 1]; /* Make a queue from the queue buffer. */ queue.elements=found; @@ -1826,7 +1826,7 @@ static my_off_t calc_packed_length(HUFF_COUNTS *huff_counts, queue. This successively replaces the references to counts by references to HUFF_ELEMENTs. */ - queue.root[1]=(byte*) new_huff_el; + queue.root[1]=(uchar*) new_huff_el; queue_replaced(&queue); } DBUG_RETURN(bytes_packed+(bits_packed+7)/8); @@ -1859,12 +1859,12 @@ static uint join_same_trees(HUFF_COUNTS *huff_counts, uint trees) i->tree->tree_pack_length+j->tree->tree_pack_length+ ALLOWED_JOIN_DIFF) { - memcpy_fixed((byte*) i->counts,(byte*) count.counts, + memcpy_fixed((uchar*) i->counts,(uchar*) count.counts, sizeof(count.counts[0])*256); - my_free((gptr) j->tree->element_buffer,MYF(0)); + my_free((uchar*) j->tree->element_buffer,MYF(0)); j->tree->element_buffer=0; j->tree=i->tree; - bmove((byte*) i->counts,(byte*) count.counts, + bmove((uchar*) i->counts,(uchar*) count.counts, sizeof(count.counts[0])*256); if (make_huff_tree(i->tree,i)) return (uint) -1; @@ -2007,7 +2007,7 @@ static char *hexdigits(ulonglong value) static int write_header(PACK_MRG_INFO *mrg,uint head_length,uint trees, my_off_t tot_elements,my_off_t filelength) { - byte *buff= (byte*) file_buffer.pos; + uchar *buff= (uchar*) file_buffer.pos; bzero(buff,HEAD_LENGTH); memcpy_fixed(buff,myisam_pack_file_magic,4); @@ -2023,7 +2023,7 @@ static int write_header(PACK_MRG_INFO *mrg,uint head_length,uint trees, if (test_only) return 0; VOID(my_seek(file_buffer.file,0L,MY_SEEK_SET,MYF(0))); - return my_write(file_buffer.file,(const byte *) file_buffer.pos,HEAD_LENGTH, + return my_write(file_buffer.file,(const uchar *) file_buffer.pos,HEAD_LENGTH, MYF(MY_WME | MY_NABP | MY_WAIT_IF_FULL)) != 0; } @@ -2159,7 +2159,7 @@ static my_off_t write_huff_tree(HUFF_TREE *huff_tree, uint trees) { /* This should be impossible */ VOID(fprintf(stderr, "Tree offset got too big: %d, aborted\n", huff_tree->max_offset)); - my_afree((gptr) packed_tree); + my_afree((uchar*) packed_tree); return 0; } @@ -2331,7 +2331,7 @@ static my_off_t write_huff_tree(HUFF_TREE *huff_tree, uint trees) DBUG_PRINT("info", (" ")); if (verbose >= 2) VOID(printf("\n")); - my_afree((gptr) packed_tree); + my_afree((uchar*) packed_tree); if (errors) { VOID(fprintf(stderr, "Error: Generated decode trees are corrupt. Stop.\n")); @@ -2412,7 +2412,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts) my_off_t record_count; char llbuf[32]; ulong length,pack_length; - byte *record,*pos,*end_pos,*record_pos,*start_pos; + uchar *record,*pos,*end_pos,*record_pos,*start_pos; HUFF_COUNTS *count,*end_count; HUFF_TREE *tree; MI_INFO *isam_file=mrg->file[0]; @@ -2420,7 +2420,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts) DBUG_ENTER("compress_isam_file"); /* Allocate a buffer for the records (excluding blobs). */ - if (!(record=(byte*) my_alloca(isam_file->s->base.reclength))) + if (!(record=(uchar*) my_alloca(isam_file->s->base.reclength))) return -1; end_count=huff_counts+isam_file->s->base.fields; @@ -2471,7 +2471,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts) { if (flush_buffer((ulong) max_calc_length + (ulong) max_pack_length)) break; - record_pos= (byte*) file_buffer.pos; + record_pos= (uchar*) file_buffer.pos; file_buffer.pos+=max_pack_length; for (start_pos=record, count= huff_counts; count < end_count ; count++) { @@ -2508,7 +2508,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts) switch (count->field_type) { case FIELD_SKIP_ZERO: - if (!memcmp((byte*) start_pos,zero_string,field_length)) + if (!memcmp((uchar*) start_pos,zero_string,field_length)) { DBUG_PRINT("fields", ("FIELD_SKIP_ZERO zeroes only, bits: 1")); write_bits(1,1); @@ -2637,7 +2637,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts) break; case FIELD_INTERVALL: global_count=count; - pos=(byte*) tree_search(&count->int_tree, start_pos, + pos=(uchar*) tree_search(&count->int_tree, start_pos, count->int_tree.custom_arg); intervall=(uint) (pos - count->tree_buff)/field_length; DBUG_PRINT("fields", ("FIELD_INTERVALL")); @@ -2660,7 +2660,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts) } else { - byte *blob,*blob_end; + uchar *blob,*blob_end; DBUG_PRINT("fields", ("FIELD_BLOB not empty, bits: 1")); write_bits(0,1); /* Write the blob length. */ @@ -2701,7 +2701,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts) } else { - byte *end= start_pos + var_pack_length + col_length; + uchar *end= start_pos + var_pack_length + col_length; DBUG_PRINT("fields", ("FIELD_VARCHAR not empty, bits: 1")); write_bits(0,1); /* Write the varchar length. */ @@ -2733,7 +2733,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts) DBUG_PRINT("fields", ("---")); } flush_bits(); - length=(ulong) ((byte*) file_buffer.pos - record_pos) - max_pack_length; + length=(ulong) ((uchar*) file_buffer.pos - record_pos) - max_pack_length; pack_length= save_pack_length(pack_version, record_pos, length); if (pack_blob_length) pack_length+= save_pack_length(pack_version, record_pos + pack_length, @@ -2773,7 +2773,7 @@ static int compress_isam_file(PACK_MRG_INFO *mrg, HUFF_COUNTS *huff_counts) if (verbose >= 2) VOID(printf("wrote %s records.\n", llstr((longlong) record_count, llbuf))); - my_afree((gptr) record); + my_afree((uchar*) record); mrg->ref_length=max_pack_length; mrg->min_pack_length=max_record_length ? min_record_length : 0; mrg->max_pack_length=max_record_length; @@ -2840,7 +2840,7 @@ static int flush_buffer(ulong neaded_length) if (test_only) return 0; if (error_on_write|| my_write(file_buffer.file, - (const byte*) file_buffer.buffer, + (const uchar*) file_buffer.buffer, length, MYF(MY_WME | MY_NABP | MY_WAIT_IF_FULL))) { @@ -2867,7 +2867,7 @@ static int flush_buffer(ulong neaded_length) static void end_file_buffer(void) { - my_free((gptr) file_buffer.buffer,MYF(0)); + my_free((uchar*) file_buffer.buffer,MYF(0)); } /* output `bits` low bits of `value' */ @@ -3025,7 +3025,7 @@ static void mrg_reset(PACK_MRG_INFO *mrg) } } -static int mrg_rrnd(PACK_MRG_INFO *info,byte *buf) +static int mrg_rrnd(PACK_MRG_INFO *info,uchar *buf) { int error; MI_INFO *isam_info; @@ -3048,7 +3048,7 @@ static int mrg_rrnd(PACK_MRG_INFO *info,byte *buf) for (;;) { isam_info->update&= HA_STATE_CHANGED; - if (!(error=(*isam_info->s->read_rnd)(isam_info,(byte*) buf, + if (!(error=(*isam_info->s->read_rnd)(isam_info,(uchar*) buf, filepos, 1)) || error != HA_ERR_END_OF_FILE) return (error); @@ -3071,7 +3071,7 @@ static int mrg_close(PACK_MRG_INFO *mrg) for (i=0 ; i < mrg->count ; i++) error|=mi_close(mrg->file[i]); if (mrg->free_file) - my_free((gptr) mrg->file,MYF(0)); + my_free((uchar*) mrg->file,MYF(0)); return error; } @@ -3134,7 +3134,7 @@ static void fakebigcodes(HUFF_COUNTS *huff_counts, HUFF_COUNTS *end_count) */ if (huff_counts->tree_buff) { - my_free((gptr) huff_counts->tree_buff, MYF(0)); + my_free((uchar*) huff_counts->tree_buff, MYF(0)); delete_tree(&huff_counts->int_tree); huff_counts->tree_buff= NULL; DBUG_PRINT("fakebigcodes", ("freed distinct column values")); diff --git a/storage/myisam/rt_index.c b/storage/myisam/rt_index.c index cf144839dd1..63ed60586d6 100644 --- a/storage/myisam/rt_index.c +++ b/storage/myisam/rt_index.c @@ -141,11 +141,11 @@ static int rtree_find_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint search_flag, res = 1; ok: - my_afree((byte*)page_buf); + my_afree((uchar*)page_buf); return res; err1: - my_afree((byte*)page_buf); + my_afree((uchar*)page_buf); info->lastpos = HA_OFFSET_ERROR; return -1; } @@ -356,11 +356,11 @@ static int rtree_get_req(MI_INFO *info, MI_KEYDEF *keyinfo, uint key_length, res = 1; ok: - my_afree((byte*)page_buf); + my_afree((uchar*)page_buf); return res; err1: - my_afree((byte*)page_buf); + my_afree((uchar*)page_buf); info->lastpos = HA_OFFSET_ERROR; return -1; } @@ -602,11 +602,11 @@ static int rtree_insert_req(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, } ok: - my_afree((byte*)page_buf); + my_afree((uchar*)page_buf); DBUG_RETURN(res); err1: - my_afree((byte*)page_buf); + my_afree((uchar*)page_buf); DBUG_RETURN(-1); /* purecov: inspected */ } @@ -690,10 +690,10 @@ static int rtree_insert_level(MI_INFO *info, uint keynr, uchar *key, DBUG_PRINT("rtree", ("new root page: %lu level: %d nod_flag: %u", (ulong) new_root, 0, mi_test_if_nod(new_root_buf))); - my_afree((byte*)new_root_buf); + my_afree((uchar*)new_root_buf); break; err1: - my_afree((byte*)new_root_buf); + my_afree((uchar*)new_root_buf); DBUG_RETURN(-1); /* purecov: inspected */ } default: @@ -739,7 +739,7 @@ static int rtree_fill_reinsert_list(stPageList *ReinsertList, my_off_t page, if (ReinsertList->n_pages == ReinsertList->m_pages) { ReinsertList->m_pages += REINSERT_BUFFER_INC; - if (!(ReinsertList->pages = (stPageLevel*)my_realloc((gptr)ReinsertList->pages, + if (!(ReinsertList->pages = (stPageLevel*)my_realloc((uchar*)ReinsertList->pages, ReinsertList->m_pages * sizeof(stPageLevel), MYF(MY_ALLOW_ZERO_PTR)))) goto err1; } @@ -891,11 +891,11 @@ static int rtree_delete_req(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *key, res = 1; ok: - my_afree((byte*)page_buf); + my_afree((uchar*)page_buf); DBUG_RETURN(res); err1: - my_afree((byte*)page_buf); + my_afree((uchar*)page_buf); DBUG_RETURN(-1); /* purecov: inspected */ } @@ -968,7 +968,7 @@ int rtree_delete(MI_INFO *info, uint keynr, uchar *key, uint key_length) if ((res= rtree_insert_level(info, keynr, k, key_length, ReinsertList.pages[i].level)) == -1) { - my_afree((byte*)page_buf); + my_afree((uchar*)page_buf); goto err1; } if (res) @@ -984,13 +984,13 @@ int rtree_delete(MI_INFO *info, uint keynr, uchar *key, uint key_length) } } } - my_afree((byte*)page_buf); + my_afree((uchar*)page_buf); if (_mi_dispose(info, keyinfo, ReinsertList.pages[i].offs, DFLT_INIT_HITS)) goto err1; } if (ReinsertList.pages) - my_free((byte*) ReinsertList.pages, MYF(0)); + my_free((uchar*) ReinsertList.pages, MYF(0)); /* check for redundant root (not leaf, 1 child) and eliminate */ if ((old_root = info->s->state.key_root[keynr]) == HA_OFFSET_ERROR) @@ -1117,11 +1117,11 @@ ha_rows rtree_estimate(MI_INFO *info, uint keynr, uchar *key, res = HA_POS_ERROR; } - my_afree((byte*)page_buf); + my_afree((uchar*)page_buf); return res; err1: - my_afree((byte*)page_buf); + my_afree((uchar*)page_buf); return HA_POS_ERROR; } diff --git a/storage/myisam/rt_split.c b/storage/myisam/rt_split.c index 0f6dc872958..ef988dbd048 100644 --- a/storage/myisam/rt_split.c +++ b/storage/myisam/rt_split.c @@ -345,10 +345,10 @@ int rtree_split_page(MI_INFO *info, MI_KEYDEF *keyinfo, uchar *page, uchar *key, DFLT_INIT_HITS, new_page); DBUG_PRINT("rtree", ("split new block: %lu", (ulong) *new_page_offs)); - my_afree((byte*)new_page); + my_afree((uchar*)new_page); split_err: - my_afree((byte*) coord_buf); + my_afree((uchar*) coord_buf); DBUG_RETURN(err_code); } diff --git a/storage/myisam/sort.c b/storage/myisam/sort.c index 1d4d15c7b25..2abfa749d46 100644 --- a/storage/myisam/sort.c +++ b/storage/myisam/sort.c @@ -84,7 +84,7 @@ static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info, char* key, uint sort_length, uint count); static inline int -my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, byte *bufs); +my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, uchar *bufs); /* Creates a index of sorted keys @@ -163,7 +163,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, if (my_init_dynamic_array(&buffpek, sizeof(BUFFPEK), maxbuffer, maxbuffer/2)) { - my_free((gptr) sort_keys,MYF(0)); + my_free((uchar*) sort_keys,MYF(0)); sort_keys= 0; } else @@ -230,9 +230,9 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, reinit_io_cache(&tempfile_for_exceptions,READ_CACHE,0L,0,0)) goto err; - while (!my_b_read(&tempfile_for_exceptions,(byte*)&key_length, + while (!my_b_read(&tempfile_for_exceptions,(uchar*)&key_length, sizeof(key_length)) - && !my_b_read(&tempfile_for_exceptions,(byte*)sort_keys, + && !my_b_read(&tempfile_for_exceptions,(uchar*)sort_keys, (uint) key_length)) { if (_mi_ck_write(idx,keyno,(uchar*) sort_keys,key_length-ref_length)) @@ -244,7 +244,7 @@ int _create_index_by_sort(MI_SORT_PARAM *info,my_bool no_messages, err: if (sort_keys) - my_free((gptr) sort_keys,MYF(0)); + my_free((uchar*) sort_keys,MYF(0)); delete_dynamic(&buffpek); close_cached_file(&tempfile); close_cached_file(&tempfile_for_exceptions); @@ -383,7 +383,7 @@ pthread_handler_t thr_find_all_keys(void *arg) if (my_init_dynamic_array(&sort_param->buffpek, sizeof(BUFFPEK), maxbuffer, maxbuffer/2)) { - my_free((gptr) sort_keys,MYF(0)); + my_free((uchar*) sort_keys,MYF(0)); sort_keys= (uchar **) NULL; /* for err: label */ } else @@ -453,7 +453,7 @@ err: DBUG_PRINT("error", ("got some error")); sort_param->sort_info->got_error= 1; /* no need to protect with a mutex */ if (sort_keys) - my_free((gptr) sort_keys,MYF(0)); + my_free((uchar*) sort_keys,MYF(0)); sort_param->sort_keys= 0; delete_dynamic(& sort_param->buffpek); close_cached_file(&sort_param->tempfile); @@ -495,7 +495,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param) MI_INFO *info=sort_info->info; MYISAM_SHARE *share=info->s; MI_SORT_PARAM *sinfo; - byte *mergebuf=0; + uchar *mergebuf=0; DBUG_ENTER("thr_write_keys"); LINT_INIT(length); @@ -530,7 +530,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param) sinfo->notnull: NULL, (ulonglong) info->state->records); } - my_free((gptr) sinfo->sort_keys,MYF(0)); + my_free((uchar*) sinfo->sort_keys,MYF(0)); my_free(mi_get_rec_buff_ptr(info, sinfo->rec_buff), MYF(MY_ALLOW_ZERO_PTR)); sinfo->sort_keys=0; @@ -621,12 +621,12 @@ int thr_write_keys(MI_SORT_PARAM *sort_param) } while (!got_error && - !my_b_read(&sinfo->tempfile_for_exceptions,(byte*)&key_length, + !my_b_read(&sinfo->tempfile_for_exceptions,(uchar*)&key_length, sizeof(key_length))) { - byte ft_buf[HA_FT_MAXBYTELEN + HA_FT_WLEN + 10]; + uchar ft_buf[HA_FT_MAXBYTELEN + HA_FT_WLEN + 10]; if (key_length > sizeof(ft_buf) || - my_b_read(&sinfo->tempfile_for_exceptions, (byte*)ft_buf, + my_b_read(&sinfo->tempfile_for_exceptions, (uchar*)ft_buf, (uint)key_length) || _mi_ck_write(info, sinfo->key, (uchar*)ft_buf, key_length - info->s->rec_reflength)) @@ -634,7 +634,7 @@ int thr_write_keys(MI_SORT_PARAM *sort_param) } } } - my_free((gptr) mergebuf,MYF(MY_ALLOW_ZERO_PTR)); + my_free((uchar*) mergebuf,MYF(MY_ALLOW_ZERO_PTR)); DBUG_RETURN(got_error); } #endif /* THREAD */ @@ -648,7 +648,7 @@ static int NEAR_F write_keys(MI_SORT_PARAM *info, register uchar **sort_keys, uint sort_length=info->key_length; DBUG_ENTER("write_keys"); - qsort2((byte*) sort_keys,count,sizeof(byte*),(qsort2_cmp) info->key_cmp, + qsort2((uchar*) sort_keys,count,sizeof(uchar*),(qsort2_cmp) info->key_cmp, info); if (!my_b_inited(tempfile) && open_cached_file(tempfile, my_tmpdir(info->tmpdir), "ST", @@ -660,7 +660,7 @@ static int NEAR_F write_keys(MI_SORT_PARAM *info, register uchar **sort_keys, for (end=sort_keys+count ; sort_keys != end ; sort_keys++) { - if (my_b_write(tempfile,(byte*) *sort_keys,(uint) sort_length)) + if (my_b_write(tempfile,(uchar*) *sort_keys,(uint) sort_length)) DBUG_RETURN(1); /* purecov: inspected */ } DBUG_RETURN(0); @@ -668,13 +668,13 @@ static int NEAR_F write_keys(MI_SORT_PARAM *info, register uchar **sort_keys, static inline int -my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, byte *bufs) +my_var_write(MI_SORT_PARAM *info, IO_CACHE *to_file, uchar *bufs) { int err; uint16 len = _mi_keylength(info->keyinfo, (uchar*) bufs); /* The following is safe as this is a local file */ - if ((err= my_b_write(to_file, (byte*)&len, sizeof(len)))) + if ((err= my_b_write(to_file, (uchar*)&len, sizeof(len)))) return (err); if ((err= my_b_write(to_file,bufs, (uint) len))) return (err); @@ -691,7 +691,7 @@ static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, int err; DBUG_ENTER("write_keys_varlen"); - qsort2((byte*) sort_keys,count,sizeof(byte*),(qsort2_cmp) info->key_cmp, + qsort2((uchar*) sort_keys,count,sizeof(uchar*),(qsort2_cmp) info->key_cmp, info); if (!my_b_inited(tempfile) && open_cached_file(tempfile, my_tmpdir(info->tmpdir), "ST", @@ -702,7 +702,7 @@ static int NEAR_F write_keys_varlen(MI_SORT_PARAM *info, buffpek->count=count; for (end=sort_keys+count ; sort_keys != end ; sort_keys++) { - if ((err= my_var_write(info,tempfile, (byte*) *sort_keys))) + if ((err= my_var_write(info,tempfile, (uchar*) *sort_keys))) DBUG_RETURN(err); } DBUG_RETURN(0); @@ -720,8 +720,8 @@ static int NEAR_F write_key(MI_SORT_PARAM *info, uchar *key, DISK_BUFFER_SIZE, info->sort_info->param->myf_rw)) DBUG_RETURN(1); - if (my_b_write(tempfile,(byte*)&key_length,sizeof(key_length)) || - my_b_write(tempfile,(byte*)key,(uint) key_length)) + if (my_b_write(tempfile,(uchar*)&key_length,sizeof(key_length)) || + my_b_write(tempfile,(uchar*)key,(uint) key_length)) DBUG_RETURN(1); DBUG_RETURN(0); } /* write_key */ @@ -734,7 +734,7 @@ static int NEAR_F write_index(MI_SORT_PARAM *info, register uchar **sort_keys, { DBUG_ENTER("write_index"); - qsort2((gptr) sort_keys,(size_t) count,sizeof(byte*), + qsort2((uchar*) sort_keys,(size_t) count,sizeof(uchar*), (qsort2_cmp) info->key_cmp,info); while (count--) { @@ -813,7 +813,7 @@ static uint NEAR_F read_to_buffer(IO_CACHE *fromfile, BUFFPEK *buffpek, if ((count=(uint) min((ha_rows) buffpek->max_keys,buffpek->count))) { - if (my_pread(fromfile->file,(byte*) buffpek->base, + if (my_pread(fromfile->file,(uchar*) buffpek->base, (length= sort_length*count),buffpek->file_pos,MYF_RW)) return((uint) -1); /* purecov: inspected */ buffpek->key=buffpek->base; @@ -838,11 +838,11 @@ static uint NEAR_F read_to_buffer_varlen(IO_CACHE *fromfile, BUFFPEK *buffpek, for (idx=1;idx<=count;idx++) { - if (my_pread(fromfile->file,(byte*)&length_of_key,sizeof(length_of_key), + if (my_pread(fromfile->file,(uchar*)&length_of_key,sizeof(length_of_key), buffpek->file_pos,MYF_RW)) return((uint) -1); buffpek->file_pos+=sizeof(length_of_key); - if (my_pread(fromfile->file,(byte*) buffp,length_of_key, + if (my_pread(fromfile->file,(uchar*) buffp,length_of_key, buffpek->file_pos,MYF_RW)) return((uint) -1); buffpek->file_pos+=length_of_key; @@ -866,7 +866,7 @@ static int NEAR_F write_merge_key_varlen(MI_SORT_PARAM *info, for (idx=1;idx<=count;idx++) { int err; - if ((err= my_var_write(info,to_file, (byte*) bufs))) + if ((err= my_var_write(info,to_file, (uchar*) bufs))) return (err); bufs=bufs+sort_length; } @@ -878,7 +878,7 @@ static int NEAR_F write_merge_key(MI_SORT_PARAM *info __attribute__((unused)), IO_CACHE *to_file, char* key, uint sort_length, uint count) { - return my_b_write(to_file,(byte*) key,(uint) sort_length*count); + return my_b_write(to_file,(uchar*) key,(uint) sort_length*count); } /* @@ -910,7 +910,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, sort_length=info->key_length; if (init_queue(&queue,(uint) (Tb-Fb)+1,offsetof(BUFFPEK,key),0, - (int (*)(void*, byte *,byte*)) info->key_cmp, + (int (*)(void*, uchar *,uchar*)) info->key_cmp, (void*) info)) DBUG_RETURN(1); /* purecov: inspected */ @@ -937,7 +937,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, buffpek=(BUFFPEK*) queue_top(&queue); if (to_file) { - if (info->write_key(info,to_file,(byte*) buffpek->key, + if (info->write_key(info,to_file,(uchar*) buffpek->key, (uint) sort_length,1)) { error=1; goto err; /* purecov: inspected */ @@ -993,7 +993,7 @@ merge_buffers(MI_SORT_PARAM *info, uint keys, IO_CACHE *from_file, { if (to_file) { - if (info->write_key(info,to_file,(byte*) buffpek->key, + if (info->write_key(info,to_file,(uchar*) buffpek->key, sort_length,buffpek->mem_count)) { error=1; goto err; /* purecov: inspected */ @@ -1046,7 +1046,7 @@ flush_ft_buf(MI_SORT_PARAM *info) if (info->sort_info->ft_buf) { err=sort_ft_buf_flush(info); - my_free((gptr)info->sort_info->ft_buf, MYF(0)); + my_free((uchar*)info->sort_info->ft_buf, MYF(0)); info->sort_info->ft_buf=0; } return err; diff --git a/storage/myisam/sp_defs.h b/storage/myisam/sp_defs.h index 11254d16c97..187ec62b2a3 100644 --- a/storage/myisam/sp_defs.h +++ b/storage/myisam/sp_defs.h @@ -40,7 +40,7 @@ enum wkbByteOrder }; uint sp_make_key(register MI_INFO *info, uint keynr, uchar *key, - const byte *record, my_off_t filepos); + const uchar *record, my_off_t filepos); #endif /*HAVE_SPATIAL*/ #endif /* _SP_DEFS_H */ diff --git a/storage/myisam/sp_key.c b/storage/myisam/sp_key.c index 34c96a219c7..be4021935c4 100644 --- a/storage/myisam/sp_key.c +++ b/storage/myisam/sp_key.c @@ -31,25 +31,25 @@ static int sp_get_geometry_mbr(uchar *(*wkb), uchar *end, uint n_dims, double *mbr, int top); static int sp_mbr_from_wkb(uchar (*wkb), uint size, uint n_dims, double *mbr); -static void get_double(double *d, const byte *pos) +static void get_double(double *d, const uchar *pos) { float8get(*d, pos); } uint sp_make_key(register MI_INFO *info, uint keynr, uchar *key, - const byte *record, my_off_t filepos) + const uchar *record, my_off_t filepos) { HA_KEYSEG *keyseg; MI_KEYDEF *keyinfo = &info->s->keyinfo[keynr]; uint len = 0; - byte *pos; + uchar *pos; uint dlen; uchar *dptr; double mbr[SPDIMS * 2]; uint i; keyseg = &keyinfo->seg[-1]; - pos = (byte*)record + keyseg->start; + pos = (uchar*)record + keyseg->start; dlen = _mi_calc_blob_length(keyseg->bit_start, pos); memcpy_fixed(&dptr, pos + keyseg->bit_start, sizeof(char*)); @@ -64,7 +64,7 @@ uint sp_make_key(register MI_INFO *info, uint keynr, uchar *key, { uint length = keyseg->length; - pos = ((byte*)mbr) + keyseg->start; + pos = ((uchar*)mbr) + keyseg->start; if (keyseg->flag & HA_SWAP_KEY) { #ifdef HAVE_ISNAN @@ -100,7 +100,7 @@ uint sp_make_key(register MI_INFO *info, uint keynr, uchar *key, } else { - memcpy((byte*)key, pos, length); + memcpy((uchar*)key, pos, length); key += keyseg->length; } len += keyseg->length; @@ -141,7 +141,7 @@ static int sp_add_point_to_mbr(uchar *(*wkb), uchar *end, uint n_dims, { if ((*wkb) > end - 8) return -1; - get_double(&ord, (const byte*) *wkb); + get_double(&ord, (const uchar*) *wkb); (*wkb)+= 8; if (ord < *mbr) float8store((char*) mbr, ord); diff --git a/storage/myisammrg/ha_myisammrg.cc b/storage/myisammrg/ha_myisammrg.cc index 5df3e7799d0..d6ea2b4772e 100644 --- a/storage/myisammrg/ha_myisammrg.cc +++ b/storage/myisammrg/ha_myisammrg.cc @@ -120,12 +120,12 @@ int ha_myisammrg::open(const char *name, int mode, uint test_if_locked) u_table->table->s->base.keys, u_table->table->s->base.fields, false)) { - my_free((gptr) recinfo, MYF(0)); + my_free((uchar*) recinfo, MYF(0)); error= HA_ERR_WRONG_MRG_TABLE_DEF; goto err; } } - my_free((gptr) recinfo, MYF(0)); + my_free((uchar*) recinfo, MYF(0)); #if !defined(BIG_TABLES) || SIZEOF_OFF_T == 4 /* Merge table has more than 2G rows */ if (table->s->crashed) @@ -146,7 +146,7 @@ int ha_myisammrg::close(void) return myrg_close(file); } -int ha_myisammrg::write_row(byte * buf) +int ha_myisammrg::write_row(uchar * buf) { ha_statistic_increment(&SSV::ha_write_count); @@ -164,7 +164,7 @@ int ha_myisammrg::write_row(byte * buf) return myrg_write(file,buf); } -int ha_myisammrg::update_row(const byte * old_data, byte * new_data) +int ha_myisammrg::update_row(const uchar * old_data, uchar * new_data) { ha_statistic_increment(&SSV::ha_update_count); if (table->timestamp_field_type & TIMESTAMP_AUTO_SET_ON_UPDATE) @@ -172,13 +172,13 @@ int ha_myisammrg::update_row(const byte * old_data, byte * new_data) return myrg_update(file,old_data,new_data); } -int ha_myisammrg::delete_row(const byte * buf) +int ha_myisammrg::delete_row(const uchar * buf) { ha_statistic_increment(&SSV::ha_delete_count); return myrg_delete(file,buf); } -int ha_myisammrg::index_read(byte * buf, const byte * key, +int ha_myisammrg::index_read(uchar * buf, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag) { @@ -188,7 +188,7 @@ int ha_myisammrg::index_read(byte * buf, const byte * key, return error; } -int ha_myisammrg::index_read_idx(byte * buf, uint index, const byte * key, +int ha_myisammrg::index_read_idx(uchar * buf, uint index, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag) { @@ -198,7 +198,7 @@ int ha_myisammrg::index_read_idx(byte * buf, uint index, const byte * key, return error; } -int ha_myisammrg::index_read_last(byte * buf, const byte * key, +int ha_myisammrg::index_read_last(uchar * buf, const uchar * key, key_part_map keypart_map) { ha_statistic_increment(&SSV::ha_read_key_count); @@ -208,7 +208,7 @@ int ha_myisammrg::index_read_last(byte * buf, const byte * key, return error; } -int ha_myisammrg::index_next(byte * buf) +int ha_myisammrg::index_next(uchar * buf) { ha_statistic_increment(&SSV::ha_read_next_count); int error=myrg_rnext(file,buf,active_index); @@ -216,7 +216,7 @@ int ha_myisammrg::index_next(byte * buf) return error; } -int ha_myisammrg::index_prev(byte * buf) +int ha_myisammrg::index_prev(uchar * buf) { ha_statistic_increment(&SSV::ha_read_prev_count); int error=myrg_rprev(file,buf, active_index); @@ -224,7 +224,7 @@ int ha_myisammrg::index_prev(byte * buf) return error; } -int ha_myisammrg::index_first(byte * buf) +int ha_myisammrg::index_first(uchar * buf) { ha_statistic_increment(&SSV::ha_read_first_count); int error=myrg_rfirst(file, buf, active_index); @@ -232,7 +232,7 @@ int ha_myisammrg::index_first(byte * buf) return error; } -int ha_myisammrg::index_last(byte * buf) +int ha_myisammrg::index_last(uchar * buf) { ha_statistic_increment(&SSV::ha_read_last_count); int error=myrg_rlast(file, buf, active_index); @@ -240,8 +240,8 @@ int ha_myisammrg::index_last(byte * buf) return error; } -int ha_myisammrg::index_next_same(byte * buf, - const byte *key __attribute__((unused)), +int ha_myisammrg::index_next_same(uchar * buf, + const uchar *key __attribute__((unused)), uint length __attribute__((unused))) { ha_statistic_increment(&SSV::ha_read_next_count); @@ -257,7 +257,7 @@ int ha_myisammrg::rnd_init(bool scan) } -int ha_myisammrg::rnd_next(byte *buf) +int ha_myisammrg::rnd_next(uchar *buf) { ha_statistic_increment(&SSV::ha_read_rnd_next_count); int error=myrg_rrnd(file, buf, HA_OFFSET_ERROR); @@ -266,7 +266,7 @@ int ha_myisammrg::rnd_next(byte *buf) } -int ha_myisammrg::rnd_pos(byte * buf, byte *pos) +int ha_myisammrg::rnd_pos(uchar * buf, uchar *pos) { ha_statistic_increment(&SSV::ha_read_rnd_count); int error=myrg_rrnd(file, buf, my_get_ptr(pos,ref_length)); @@ -274,7 +274,7 @@ int ha_myisammrg::rnd_pos(byte * buf, byte *pos) return error; } -void ha_myisammrg::position(const byte *record) +void ha_myisammrg::position(const uchar *record) { ulonglong row_position= myrg_position(file); my_store_ptr(ref, ref_length, (my_off_t) row_position); @@ -464,8 +464,8 @@ void ha_myisammrg::update_create_info(HA_CREATE_INFO *create_info) goto err; create_info->merge_list.elements++; - (*create_info->merge_list.next) = (byte*) ptr; - create_info->merge_list.next= (byte**) &ptr->next_local; + (*create_info->merge_list.next) = (uchar*) ptr; + create_info->merge_list.next= (uchar**) &ptr->next_local; } *create_info->merge_list.next=0; } diff --git a/storage/myisammrg/ha_myisammrg.h b/storage/myisammrg/ha_myisammrg.h index 7bbe659d4b7..88bb5dd2e21 100644 --- a/storage/myisammrg/ha_myisammrg.h +++ b/storage/myisammrg/ha_myisammrg.h @@ -53,23 +53,23 @@ class ha_myisammrg: public handler int open(const char *name, int mode, uint test_if_locked); int close(void); - int write_row(byte * buf); - int update_row(const byte * old_data, byte * new_data); - int delete_row(const byte * buf); - int index_read(byte * buf, const byte * key, key_part_map keypart_map, + int write_row(uchar * buf); + int update_row(const uchar * old_data, uchar * new_data); + int delete_row(const uchar * buf); + int index_read(uchar * buf, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag); - int index_read_idx(byte * buf, uint index, const byte * key, + int index_read_idx(uchar * buf, uint index, const uchar * key, key_part_map keypart_map, enum ha_rkey_function find_flag); - int index_read_last(byte * buf, const byte * key, key_part_map keypart_map); - int index_next(byte * buf); - int index_prev(byte * buf); - int index_first(byte * buf); - int index_last(byte * buf); - int index_next_same(byte *buf, const byte *key, uint keylen); + int index_read_last(uchar * buf, const uchar * key, key_part_map keypart_map); + int index_next(uchar * buf); + int index_prev(uchar * buf); + int index_first(uchar * buf); + int index_last(uchar * buf); + int index_next_same(uchar *buf, const uchar *key, uint keylen); int rnd_init(bool scan); - int rnd_next(byte *buf); - int rnd_pos(byte * buf, byte *pos); - void position(const byte *record); + int rnd_next(uchar *buf); + int rnd_pos(uchar * buf, uchar *pos); + void position(const uchar *record); ha_rows records_in_range(uint inx, key_range *min_key, key_range *max_key); int info(uint); int reset(void); diff --git a/storage/myisammrg/myrg_close.c b/storage/myisammrg/myrg_close.c index 971a83928b1..baae24634b3 100644 --- a/storage/myisammrg/myrg_close.c +++ b/storage/myisammrg/myrg_close.c @@ -30,7 +30,7 @@ int myrg_close(MYRG_INFO *info) pthread_mutex_lock(&THR_LOCK_open); myrg_open_list=list_delete(myrg_open_list,&info->open_list); pthread_mutex_unlock(&THR_LOCK_open); - my_free((gptr) info,MYF(0)); + my_free((uchar*) info,MYF(0)); if (error) { DBUG_RETURN(my_errno=error); diff --git a/storage/myisammrg/myrg_def.h b/storage/myisammrg/myrg_def.h index 344bd4edd3c..ec33d2c0bb4 100644 --- a/storage/myisammrg/myrg_def.h +++ b/storage/myisammrg/myrg_def.h @@ -28,5 +28,5 @@ extern pthread_mutex_t THR_LOCK_open; #endif int _myrg_init_queue(MYRG_INFO *info,int inx,enum ha_rkey_function search_flag); -int _myrg_mi_read_record(MI_INFO *info, byte *buf); +int _myrg_mi_read_record(MI_INFO *info, uchar *buf); diff --git a/storage/myisammrg/myrg_delete.c b/storage/myisammrg/myrg_delete.c index f9604f66885..93d45198b36 100644 --- a/storage/myisammrg/myrg_delete.c +++ b/storage/myisammrg/myrg_delete.c @@ -17,7 +17,7 @@ #include "myrg_def.h" -int myrg_delete(MYRG_INFO *info, const byte *record) +int myrg_delete(MYRG_INFO *info, const uchar *record) { if (!info->current_table) return (my_errno= HA_ERR_NO_ACTIVE_RECORD); diff --git a/storage/myisammrg/myrg_open.c b/storage/myisammrg/myrg_open.c index 3dbb605463e..cca81f0f605 100644 --- a/storage/myisammrg/myrg_open.c +++ b/storage/myisammrg/myrg_open.c @@ -40,6 +40,7 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) IO_CACHE file; MI_INFO *isam=0; uint found_merge_insert_method= 0; + size_t name_buff_length; DBUG_ENTER("myrg_open"); LINT_INIT(key_parts); @@ -48,13 +49,13 @@ MYRG_INFO *myrg_open(const char *name, int mode, int handle_locking) if ((fd=my_open(fn_format(name_buff,name,"",MYRG_NAME_EXT, MY_UNPACK_FILENAME|MY_APPEND_EXT), O_RDONLY | O_SHARE,MYF(0))) < 0) - goto err; - errpos=1; - if (init_io_cache(&file, fd, 4*IO_SIZE, READ_CACHE, 0, 0, + goto err; + errpos=1; + if (init_io_cache(&file, fd, 4*IO_SIZE, READ_CACHE, 0, 0, MYF(MY_WME | MY_NABP))) - goto err; - errpos=2; - dir_length=dirname_part(name_buff,name); + goto err; + errpos=2; + dir_length=dirname_part(name_buff, name, &name_buff_length); while ((length=my_b_gets(&file,buff,FN_REFLEN-1))) { if ((end=buff+length)[-1] == '\n') diff --git a/storage/myisammrg/myrg_queue.c b/storage/myisammrg/myrg_queue.c index 1d252207db1..d2579053784 100644 --- a/storage/myisammrg/myrg_queue.c +++ b/storage/myisammrg/myrg_queue.c @@ -15,7 +15,7 @@ #include "myrg_def.h" -static int queue_key_cmp(void *keyseg, byte *a, byte *b) +static int queue_key_cmp(void *keyseg, uchar *a, uchar *b) { MYRG_TABLE *ma= (MYRG_TABLE *)a; MYRG_TABLE *mb= (MYRG_TABLE *)b; @@ -69,7 +69,7 @@ int _myrg_init_queue(MYRG_INFO *info,int inx,enum ha_rkey_function search_flag) return error; } -int _myrg_mi_read_record(MI_INFO *info, byte *buf) +int _myrg_mi_read_record(MI_INFO *info, uchar *buf) { if (!(*info->read_record)(info,info->lastpos,buf)) { diff --git a/storage/myisammrg/myrg_rfirst.c b/storage/myisammrg/myrg_rfirst.c index 80736537d02..9d7b0f9e83f 100644 --- a/storage/myisammrg/myrg_rfirst.c +++ b/storage/myisammrg/myrg_rfirst.c @@ -17,7 +17,7 @@ /* Read first row according to specific key */ -int myrg_rfirst(MYRG_INFO *info, byte *buf, int inx) +int myrg_rfirst(MYRG_INFO *info, uchar *buf, int inx) { MYRG_TABLE *table; MI_INFO *mi; @@ -35,7 +35,7 @@ int myrg_rfirst(MYRG_INFO *info, byte *buf, int inx) return err; } /* adding to queue */ - queue_insert(&(info->by_key),(byte *)table); + queue_insert(&(info->by_key),(uchar *)table); } /* We have done a read in all tables */ info->last_used_table=table; diff --git a/storage/myisammrg/myrg_rkey.c b/storage/myisammrg/myrg_rkey.c index 2d744ae31ec..8e7886f5a43 100644 --- a/storage/myisammrg/myrg_rkey.c +++ b/storage/myisammrg/myrg_rkey.c @@ -35,10 +35,10 @@ SerG */ -int myrg_rkey(MYRG_INFO *info,byte *buf,int inx, const byte *key, +int myrg_rkey(MYRG_INFO *info,uchar *buf,int inx, const uchar *key, key_part_map keypart_map, enum ha_rkey_function search_flag) { - byte *key_buff; + uchar *key_buff; uint pack_key_length; uint16 last_used_keyseg; MYRG_TABLE *table; @@ -60,7 +60,7 @@ int myrg_rkey(MYRG_INFO *info,byte *buf,int inx, const byte *key, { err=mi_rkey(mi, 0, inx, key, keypart_map, search_flag); /* Get the saved packed key and packed key length. */ - key_buff=(byte*) mi->lastkey+mi->s->base.max_key_length; + key_buff=(uchar*) mi->lastkey+mi->s->base.max_key_length; pack_key_length=mi->pack_key_length; last_used_keyseg= mi->last_used_keyseg; } @@ -80,7 +80,7 @@ int myrg_rkey(MYRG_INFO *info,byte *buf,int inx, const byte *key, DBUG_RETURN(err); } /* adding to queue */ - queue_insert(&(info->by_key),(byte *)table); + queue_insert(&(info->by_key),(uchar *)table); } @@ -92,6 +92,6 @@ int myrg_rkey(MYRG_INFO *info,byte *buf,int inx, const byte *key, mi->once_flags|= RRND_PRESERVE_LASTINX; DBUG_PRINT("info", ("using table no: %d", (int) (info->current_table - info->open_tables + 1))); - DBUG_DUMP("result key", (byte*) mi->lastkey, mi->lastkey_length); + DBUG_DUMP("result key", (uchar*) mi->lastkey, mi->lastkey_length); DBUG_RETURN(_myrg_mi_read_record(mi,buf)); } diff --git a/storage/myisammrg/myrg_rlast.c b/storage/myisammrg/myrg_rlast.c index f364bf9b32f..8086a2f8104 100644 --- a/storage/myisammrg/myrg_rlast.c +++ b/storage/myisammrg/myrg_rlast.c @@ -17,7 +17,7 @@ /* Read last row with the same key as the previous read. */ -int myrg_rlast(MYRG_INFO *info, byte *buf, int inx) +int myrg_rlast(MYRG_INFO *info, uchar *buf, int inx) { MYRG_TABLE *table; MI_INFO *mi; @@ -35,7 +35,7 @@ int myrg_rlast(MYRG_INFO *info, byte *buf, int inx) return err; } /* adding to queue */ - queue_insert(&(info->by_key),(byte *)table); + queue_insert(&(info->by_key),(uchar *)table); } /* We have done a read in all tables */ info->last_used_table=table; diff --git a/storage/myisammrg/myrg_rnext.c b/storage/myisammrg/myrg_rnext.c index de1aa4df4b6..82d5cbf38b1 100644 --- a/storage/myisammrg/myrg_rnext.c +++ b/storage/myisammrg/myrg_rnext.c @@ -19,7 +19,7 @@ Read next row with the same key as previous read */ -int myrg_rnext(MYRG_INFO *info, byte *buf, int inx) +int myrg_rnext(MYRG_INFO *info, uchar *buf, int inx) { int err; MI_INFO *mi; @@ -42,7 +42,7 @@ int myrg_rnext(MYRG_INFO *info, byte *buf, int inx) else { /* Found here, adding to queue */ - queue_top(&(info->by_key))=(byte *)(info->current_table); + queue_top(&(info->by_key))=(uchar *)(info->current_table); queue_replaced(&(info->by_key)); } diff --git a/storage/myisammrg/myrg_rnext_same.c b/storage/myisammrg/myrg_rnext_same.c index 9c6b522ee8a..ad7bbfb0f6e 100644 --- a/storage/myisammrg/myrg_rnext_same.c +++ b/storage/myisammrg/myrg_rnext_same.c @@ -16,7 +16,7 @@ #include "myrg_def.h" -int myrg_rnext_same(MYRG_INFO *info, byte *buf) +int myrg_rnext_same(MYRG_INFO *info, uchar *buf) { int err; MI_INFO *mi; @@ -39,7 +39,7 @@ int myrg_rnext_same(MYRG_INFO *info, byte *buf) else { /* Found here, adding to queue */ - queue_top(&(info->by_key))=(byte *)(info->current_table); + queue_top(&(info->by_key))=(uchar *)(info->current_table); queue_replaced(&(info->by_key)); } diff --git a/storage/myisammrg/myrg_rprev.c b/storage/myisammrg/myrg_rprev.c index b1b86a93fad..66c94974940 100644 --- a/storage/myisammrg/myrg_rprev.c +++ b/storage/myisammrg/myrg_rprev.c @@ -19,7 +19,7 @@ Read previous row with the same key as previous read */ -int myrg_rprev(MYRG_INFO *info, byte *buf, int inx) +int myrg_rprev(MYRG_INFO *info, uchar *buf, int inx) { int err; MI_INFO *mi; @@ -42,7 +42,7 @@ int myrg_rprev(MYRG_INFO *info, byte *buf, int inx) else { /* Found here, adding to queue */ - queue_top(&(info->by_key))=(byte *)(info->current_table); + queue_top(&(info->by_key))=(uchar *)(info->current_table); queue_replaced(&(info->by_key)); } diff --git a/storage/myisammrg/myrg_rrnd.c b/storage/myisammrg/myrg_rrnd.c index 55e72b2170d..b598563680c 100644 --- a/storage/myisammrg/myrg_rrnd.c +++ b/storage/myisammrg/myrg_rrnd.c @@ -30,7 +30,7 @@ static MYRG_TABLE *find_table(MYRG_TABLE *start,MYRG_TABLE *end,ulonglong pos); HA_ERR_END_OF_FILE = EOF. */ -int myrg_rrnd(MYRG_INFO *info,byte *buf,ulonglong filepos) +int myrg_rrnd(MYRG_INFO *info,uchar *buf,ulonglong filepos) { int error; MI_INFO *isam_info; @@ -47,7 +47,7 @@ int myrg_rrnd(MYRG_INFO *info,byte *buf,ulonglong filepos) } isam_info=(info->current_table=info->open_tables)->table; if (info->cache_in_use) - mi_extra(isam_info,HA_EXTRA_CACHE,(byte*) &info->cache_size); + mi_extra(isam_info,HA_EXTRA_CACHE,(uchar*) &info->cache_size); filepos=isam_info->s->pack.header_length; isam_info->lastinx= (uint) -1; /* Can't forward or backward */ } @@ -60,20 +60,20 @@ int myrg_rrnd(MYRG_INFO *info,byte *buf,ulonglong filepos) for (;;) { isam_info->update&= HA_STATE_CHANGED; - if ((error=(*isam_info->s->read_rnd)(isam_info,(byte*) buf, + if ((error=(*isam_info->s->read_rnd)(isam_info,(uchar*) buf, (my_off_t) filepos,1)) != HA_ERR_END_OF_FILE) DBUG_RETURN(error); if (info->cache_in_use) mi_extra(info->current_table->table, HA_EXTRA_NO_CACHE, - (byte*) &info->cache_size); + (uchar*) &info->cache_size); if (info->current_table+1 == info->end_table) DBUG_RETURN(HA_ERR_END_OF_FILE); info->current_table++; info->last_used_table=info->current_table; if (info->cache_in_use) mi_extra(info->current_table->table, HA_EXTRA_CACHE, - (byte*) &info->cache_size); + (uchar*) &info->cache_size); info->current_table->file_offset= info->current_table[-1].file_offset+ info->current_table[-1].table->state->data_file_length; @@ -88,7 +88,7 @@ int myrg_rrnd(MYRG_INFO *info,byte *buf,ulonglong filepos) isam_info=info->current_table->table; isam_info->update&= HA_STATE_CHANGED; DBUG_RETURN((*isam_info->s->read_rnd) - (isam_info, (byte*) buf, + (isam_info, (uchar*) buf, (my_off_t) (filepos - info->current_table->file_offset), 0)); } diff --git a/storage/myisammrg/myrg_rsame.c b/storage/myisammrg/myrg_rsame.c index 56b16c0aa3c..2f7523759dc 100644 --- a/storage/myisammrg/myrg_rsame.c +++ b/storage/myisammrg/myrg_rsame.c @@ -15,7 +15,7 @@ #include "myrg_def.h" -int myrg_rsame(MYRG_INFO *info,byte *record,int inx) +int myrg_rsame(MYRG_INFO *info,uchar *record,int inx) { if (inx) /* not yet used, should be 0 */ return (my_errno=HA_ERR_WRONG_INDEX); diff --git a/storage/myisammrg/myrg_update.c b/storage/myisammrg/myrg_update.c index ba667d69f12..5d883be8484 100644 --- a/storage/myisammrg/myrg_update.c +++ b/storage/myisammrg/myrg_update.c @@ -17,7 +17,7 @@ #include "myrg_def.h" -int myrg_update(register MYRG_INFO *info,const byte *oldrec, byte *newrec) +int myrg_update(register MYRG_INFO *info,const uchar *oldrec, uchar *newrec) { if (!info->current_table) return (my_errno=HA_ERR_NO_ACTIVE_RECORD); diff --git a/storage/myisammrg/myrg_write.c b/storage/myisammrg/myrg_write.c index ed0a4a7996a..27534df2821 100644 --- a/storage/myisammrg/myrg_write.c +++ b/storage/myisammrg/myrg_write.c @@ -17,7 +17,7 @@ #include "myrg_def.h" -int myrg_write(register MYRG_INFO *info, byte *rec) +int myrg_write(register MYRG_INFO *info, uchar *rec) { /* [phi] MERGE_WRITE_DISABLED is handled by the else case */ if (info->merge_insert_method == MERGE_INSERT_TO_FIRST) diff --git a/storage/ndb/include/util/ndb_opts.h b/storage/ndb/include/util/ndb_opts.h index 9cb65d4bc2e..f18bb9646cc 100644 --- a/storage/ndb/include/util/ndb_opts.h +++ b/storage/ndb/include/util/ndb_opts.h @@ -58,40 +58,40 @@ const char *opt_debug= 0; "Set connect string for connecting to ndb_mgmd. " \ "Syntax: \"[nodeid=<id>;][host=]<hostname>[:<port>]\". " \ "Overrides specifying entries in NDB_CONNECTSTRING and my.cnf", \ - (gptr*) &opt_ndb_connectstring, (gptr*) &opt_ndb_connectstring, \ + (uchar**) &opt_ndb_connectstring, (uchar**) &opt_ndb_connectstring, \ 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },\ { "ndb-mgmd-host", OPT_NDB_MGMD, \ "Set host and port for connecting to ndb_mgmd. " \ "Syntax: <hostname>[:<port>].", \ - (gptr*) &opt_ndb_mgmd, (gptr*) &opt_ndb_mgmd, 0, \ + (uchar**) &opt_ndb_mgmd, (uchar**) &opt_ndb_mgmd, 0, \ GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },\ { "ndb-nodeid", OPT_NDB_NODEID, \ "Set node id for this node.", \ - (gptr*) &opt_ndb_nodeid, (gptr*) &opt_ndb_nodeid, 0, \ + (uchar**) &opt_ndb_nodeid, (uchar**) &opt_ndb_nodeid, 0, \ GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },\ { "ndb-shm", OPT_NDB_SHM,\ "Allow optimizing using shared memory connections when available",\ - (gptr*) &opt_ndb_shm, (gptr*) &opt_ndb_shm, 0,\ + (uchar**) &opt_ndb_shm, (uchar**) &opt_ndb_shm, 0,\ GET_BOOL, NO_ARG, OPT_NDB_SHM_DEFAULT, 0, 0, 0, 0, 0 },\ {"ndb-optimized-node-selection", OPT_NDB_OPTIMIZED_NODE_SELECTION,\ "Select nodes for transactions in a more optimal way",\ - (gptr*) &opt_ndb_optimized_node_selection,\ - (gptr*) &opt_ndb_optimized_node_selection, 0,\ + (uchar**) &opt_ndb_optimized_node_selection,\ + (uchar**) &opt_ndb_optimized_node_selection, 0,\ GET_BOOL, OPT_ARG, 1, 0, 0, 0, 0, 0},\ { "connect-string", OPT_NDB_CONNECTSTRING, "same as --ndb-connectstring",\ - (gptr*) &opt_ndb_connectstring, (gptr*) &opt_ndb_connectstring, \ + (uchar**) &opt_ndb_connectstring, (uchar**) &opt_ndb_connectstring, \ 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 },\ { "core-file", OPT_WANT_CORE, "Write core on errors.",\ - (gptr*) &opt_core, (gptr*) &opt_core, 0,\ + (uchar**) &opt_core, (uchar**) &opt_core, 0,\ GET_BOOL, NO_ARG, OPT_WANT_CORE_DEFAULT, 0, 0, 0, 0, 0},\ {"character-sets-dir", OPT_CHARSETS_DIR,\ - "Directory where character sets are.", (gptr*) &charsets_dir,\ - (gptr*) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}\ + "Directory where character sets are.", (uchar**) &charsets_dir,\ + (uchar**) &charsets_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}\ #ifndef DBUG_OFF #define NDB_STD_OPTS(prog_name) \ { "debug", '#', "Output debug log. Often this is 'd:t:o,filename'.", \ - (gptr*) &opt_debug, (gptr*) &opt_debug, \ + (uchar**) &opt_debug, (uchar**) &opt_debug, \ 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0 }, \ NDB_STD_OPTS_COMMON #else diff --git a/storage/ndb/src/cw/cpcd/main.cpp b/storage/ndb/src/cw/cpcd/main.cpp index f23a92b8010..d5c31d610cb 100644 --- a/storage/ndb/src/cw/cpcd/main.cpp +++ b/storage/ndb/src/cw/cpcd/main.cpp @@ -39,22 +39,22 @@ static const char *user = 0; static struct my_option my_long_options[] = { { "work-dir", 'w', "Work directory", - (gptr*) &work_dir, (gptr*) &work_dir, 0, + (uchar**) &work_dir, (uchar**) &work_dir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "port", 'p', "TCP port to listen on", - (gptr*) &port, (gptr*) &port, 0, + (uchar**) &port, (uchar**) &port, 0, GET_INT, REQUIRED_ARG, CPCD_DEFAULT_TCP_PORT, 0, 0, 0, 0, 0 }, { "syslog", 'S', "Log events to syslog", - (gptr*) &use_syslog, (gptr*) &use_syslog, 0, + (uchar**) &use_syslog, (uchar**) &use_syslog, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "logfile", 'L', "File to log events to", - (gptr*) &logfile, (gptr*) &logfile, 0, + (uchar**) &logfile, (uchar**) &logfile, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "debug", 'D', "Enable debug mode", - (gptr*) &debug, (gptr*) &debug, 0, + (uchar**) &debug, (uchar**) &debug, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "user", 'u', "Run as user", - (gptr*) &user, (gptr*) &user, 0, + (uchar**) &user, (uchar**) &user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/src/kernel/vm/Configuration.cpp b/storage/ndb/src/kernel/vm/Configuration.cpp index e0b485eda59..ebdd4c97aab 100644 --- a/storage/ndb/src/kernel/vm/Configuration.cpp +++ b/storage/ndb/src/kernel/vm/Configuration.cpp @@ -74,35 +74,35 @@ static struct my_option my_long_options[] = { "initial", OPT_INITIAL, "Perform initial start of ndbd, including cleaning the file system. " "Consult documentation before using this", - (gptr*) &_initial, (gptr*) &_initial, 0, + (uchar**) &_initial, (uchar**) &_initial, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "nostart", 'n', "Don't start ndbd immediately. Ndbd will await command from ndb_mgmd", - (gptr*) &_no_start, (gptr*) &_no_start, 0, + (uchar**) &_no_start, (uchar**) &_no_start, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "daemon", 'd', "Start ndbd as daemon (default)", - (gptr*) &_daemon, (gptr*) &_daemon, 0, + (uchar**) &_daemon, (uchar**) &_daemon, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 }, { "nodaemon", OPT_NODAEMON, "Do not start ndbd as daemon, provided for testing purposes", - (gptr*) &_no_daemon, (gptr*) &_no_daemon, 0, + (uchar**) &_no_daemon, (uchar**) &_no_daemon, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "foreground", OPT_FOREGROUND, "Run real ndbd in foreground, provided for debugging purposes" " (implies --nodaemon)", - (gptr*) &_foreground, (gptr*) &_foreground, 0, + (uchar**) &_foreground, (uchar**) &_foreground, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "nowait-nodes", OPT_NOWAIT_NODES, "Nodes that will not be waited for during start", - (gptr*) &_nowait_nodes, (gptr*) &_nowait_nodes, 0, + (uchar**) &_nowait_nodes, (uchar**) &_nowait_nodes, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "initial-start", OPT_INITIAL_START, "Perform initial start", - (gptr*) &_initialstart, (gptr*) &_initialstart, 0, + (uchar**) &_initialstart, (uchar**) &_initialstart, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "bind-address", OPT_NOWAIT_NODES, "Local bind address", - (gptr*) &_bind_address, (gptr*) &_bind_address, 0, + (uchar**) &_bind_address, (uchar**) &_bind_address, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/src/mgmclient/main.cpp b/storage/ndb/src/mgmclient/main.cpp index 44408362f09..d0c117f20d3 100644 --- a/storage/ndb/src/mgmclient/main.cpp +++ b/storage/ndb/src/mgmclient/main.cpp @@ -71,11 +71,11 @@ static struct my_option my_long_options[] = NDB_STD_OPTS("ndb_mgm"), { "execute", 'e', "execute command and exit", - (gptr*) &opt_execute_str, (gptr*) &opt_execute_str, 0, + (uchar**) &opt_execute_str, (uchar**) &opt_execute_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "try-reconnect", 't', "Specify number of tries for connecting to ndb_mgmd (0 = infinite)", - (gptr*) &_try_reconnect, (gptr*) &_try_reconnect, 0, + (uchar**) &_try_reconnect, (uchar**) &_try_reconnect, 0, GET_UINT, REQUIRED_ARG, 3, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/src/mgmsrv/InitConfigFileParser.cpp b/storage/ndb/src/mgmsrv/InitConfigFileParser.cpp index c1bfdee9342..569cb1eb654 100644 --- a/storage/ndb/src/mgmsrv/InitConfigFileParser.cpp +++ b/storage/ndb/src/mgmsrv/InitConfigFileParser.cpp @@ -781,19 +781,19 @@ InitConfigFileParser::parse_mycnf() const ConfigInfo::ParamInfo& param = ConfigInfo::m_ParamInfo[i]; switch(param._type){ case ConfigInfo::CI_BOOL: - opt.value = (gptr*)malloc(sizeof(int)); + opt.value = (uchar **)malloc(sizeof(int)); opt.var_type = GET_INT; break; case ConfigInfo::CI_INT: - opt.value = (gptr*)malloc(sizeof(int)); + opt.value = (uchar**)malloc(sizeof(int)); opt.var_type = GET_INT; break; case ConfigInfo::CI_INT64: - opt.value = (gptr*)malloc(sizeof(Int64)); + opt.value = (uchar**)malloc(sizeof(Int64)); opt.var_type = GET_LL; break; case ConfigInfo::CI_STRING: - opt.value = (gptr*)malloc(sizeof(char *)); + opt.value = (uchar**)malloc(sizeof(char *)); opt.var_type = GET_STR; break; default: @@ -819,28 +819,28 @@ InitConfigFileParser::parse_mycnf() bzero(&opt, sizeof(opt)); opt.name = "ndbd"; opt.id = 256; - opt.value = (gptr*)malloc(sizeof(char*)); + opt.value = (uchar**)malloc(sizeof(char*)); opt.var_type = GET_STR; opt.arg_type = REQUIRED_ARG; options.push_back(opt); opt.name = "ndb_mgmd"; opt.id = 256; - opt.value = (gptr*)malloc(sizeof(char*)); + opt.value = (uchar**)malloc(sizeof(char*)); opt.var_type = GET_STR; opt.arg_type = REQUIRED_ARG; options.push_back(opt); opt.name = "mysqld"; opt.id = 256; - opt.value = (gptr*)malloc(sizeof(char*)); + opt.value = (uchar**)malloc(sizeof(char*)); opt.var_type = GET_STR; opt.arg_type = REQUIRED_ARG; options.push_back(opt); opt.name = "ndbapi"; opt.id = 256; - opt.value = (gptr*)malloc(sizeof(char*)); + opt.value = (uchar**)malloc(sizeof(char*)); opt.var_type = GET_STR; opt.arg_type = REQUIRED_ARG; options.push_back(opt); diff --git a/storage/ndb/src/mgmsrv/main.cpp b/storage/ndb/src/mgmsrv/main.cpp index b880657d89b..16c560868ef 100644 --- a/storage/ndb/src/mgmsrv/main.cpp +++ b/storage/ndb/src/mgmsrv/main.cpp @@ -142,29 +142,29 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_mgmd"), { "config-file", 'f', "Specify cluster configuration file", - (gptr*) &opt_config_filename, (gptr*) &opt_config_filename, 0, + (uchar**) &opt_config_filename, (uchar**) &opt_config_filename, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "print-full-config", 'P', "Print full config and exit", - (gptr*) &g_print_full_config, (gptr*) &g_print_full_config, 0, + (uchar**) &g_print_full_config, (uchar**) &g_print_full_config, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "daemon", 'd', "Run ndb_mgmd in daemon mode (default)", - (gptr*) &opt_daemon, (gptr*) &opt_daemon, 0, + (uchar**) &opt_daemon, (uchar**) &opt_daemon, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 }, { "interactive", OPT_INTERACTIVE, "Run interactive. Not supported but provided for testing purposes", - (gptr*) &opt_interactive, (gptr*) &opt_interactive, 0, + (uchar**) &opt_interactive, (uchar**) &opt_interactive, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "no-nodeid-checks", OPT_NO_NODEID_CHECKS, "Do not provide any node id checks", - (gptr*) &g_no_nodeid_checks, (gptr*) &g_no_nodeid_checks, 0, + (uchar**) &g_no_nodeid_checks, (uchar**) &g_no_nodeid_checks, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "nodaemon", OPT_NO_DAEMON, "Don't run as daemon, but don't read from stdin", - (gptr*) &opt_non_interactive, (gptr*) &opt_non_interactive, 0, + (uchar**) &opt_non_interactive, (uchar**) &opt_non_interactive, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "mycnf", 256, "Read cluster config from my.cnf", - (gptr*) &opt_mycnf, (gptr*) &opt_mycnf, 0, + (uchar**) &opt_mycnf, (uchar**) &opt_mycnf, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/src/ndbapi/NdbBlob.cpp b/storage/ndb/src/ndbapi/NdbBlob.cpp index 25dcafdef53..e651a4c70b0 100644 --- a/storage/ndb/src/ndbapi/NdbBlob.cpp +++ b/storage/ndb/src/ndbapi/NdbBlob.cpp @@ -536,7 +536,7 @@ int NdbBlob::setTableKeyValue(NdbOperation* anOp) { DBUG_ENTER("NdbBlob::setTableKeyValue"); - DBUG_DUMP("info", theKeyBuf.data, 4 * theTable->m_keyLenInWords); + DBUG_DUMP("info", (uchar*) theKeyBuf.data, 4 * theTable->m_keyLenInWords); const Uint32* data = (const Uint32*)theKeyBuf.data; const unsigned columns = theTable->m_columns.size(); unsigned pos = 0; @@ -562,7 +562,8 @@ int NdbBlob::setAccessKeyValue(NdbOperation* anOp) { DBUG_ENTER("NdbBlob::setAccessKeyValue"); - DBUG_DUMP("info", theAccessKeyBuf.data, 4 * theAccessTable->m_keyLenInWords); + DBUG_DUMP("info", (uchar*) theAccessKeyBuf.data, + 4 * theAccessTable->m_keyLenInWords); const Uint32* data = (const Uint32*)theAccessKeyBuf.data; const unsigned columns = theAccessTable->m_columns.size(); unsigned pos = 0; @@ -587,7 +588,7 @@ NdbBlob::setPartKeyValue(NdbOperation* anOp, Uint32 part) { DBUG_ENTER("NdbBlob::setPartKeyValue"); DBUG_PRINT("info", ("dist=%u part=%u packkey=", getDistKey(part), part)); - DBUG_DUMP("info", thePackKeyBuf.data, 4 * thePackKeyBuf.size); + DBUG_DUMP("info", (uchar*) thePackKeyBuf.data, 4 * thePackKeyBuf.size); // TODO use attr ids after compatibility with 4.1.7 not needed if (anOp->equal("PK", thePackKeyBuf.data) == -1 || anOp->equal("DIST", getDistKey(part)) == -1 || diff --git a/storage/ndb/src/ndbapi/NdbOperationDefine.cpp b/storage/ndb/src/ndbapi/NdbOperationDefine.cpp index ced9b18bd55..c9459ff911c 100644 --- a/storage/ndb/src/ndbapi/NdbOperationDefine.cpp +++ b/storage/ndb/src/ndbapi/NdbOperationDefine.cpp @@ -608,7 +608,6 @@ NdbOperation::setAnyValue(Uint32 any_value) const NdbColumnImpl* impl = &NdbColumnImpl::getImpl(* NdbDictionary::Column::ANY_VALUE); OperationType tOpType = theOperationType; - OperationStatus tStatus = theStatus; switch(tOpType){ case DeleteRequest:{ diff --git a/storage/ndb/src/ndbapi/NdbOperationInt.cpp b/storage/ndb/src/ndbapi/NdbOperationInt.cpp index 0df1dbfe2c8..f69211cb78b 100644 --- a/storage/ndb/src/ndbapi/NdbOperationInt.cpp +++ b/storage/ndb/src/ndbapi/NdbOperationInt.cpp @@ -1023,7 +1023,7 @@ NdbOperation::branch_col(Uint32 type, DBUG_PRINT("enter", ("type: %u col:%u val: 0x%lx len: %u label: %u", type, ColId, (long) val, len, Label)); if (val != NULL) - DBUG_DUMP("value", (char*)val, len); + DBUG_DUMP("value", (uchar*)val, len); if (initial_interpreterCheck() == -1) DBUG_RETURN(-1); diff --git a/storage/ndb/src/ndbapi/NdbScanOperation.cpp b/storage/ndb/src/ndbapi/NdbScanOperation.cpp index dc9a74ae11c..fa94bf8d836 100644 --- a/storage/ndb/src/ndbapi/NdbScanOperation.cpp +++ b/storage/ndb/src/ndbapi/NdbScanOperation.cpp @@ -1311,7 +1311,7 @@ NdbIndexScanOperation::getKeyFromSCANTABREQ(Uint32* data, Uint32 size) } pos += rem; } - DBUG_DUMP("key", (char*)data, size << 2); + DBUG_DUMP("key", (uchar*) data, size << 2); DBUG_RETURN(size); } diff --git a/storage/ndb/tools/delete_all.cpp b/storage/ndb/tools/delete_all.cpp index 4e3037f1941..1bf89f5a32f 100644 --- a/storage/ndb/tools/delete_all.cpp +++ b/storage/ndb/tools/delete_all.cpp @@ -36,16 +36,16 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_desc"), { "database", 'd', "Name of database table is in", - (gptr*) &_dbname, (gptr*) &_dbname, 0, + (uchar**) &_dbname, (uchar**) &_dbname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "transactional", 't', "Single transaction (may run out of operations)", - (gptr*) &_transactional, (gptr*) &_transactional, 0, + (uchar**) &_transactional, (uchar**) &_transactional, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "tupscan", 999, "Run tupscan", - (gptr*) &_tupscan, (gptr*) &_tupscan, 0, + (uchar**) &_tupscan, (uchar**) &_tupscan, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "diskscan", 999, "Run diskcan", - (gptr*) &_diskscan, (gptr*) &_diskscan, 0, + (uchar**) &_diskscan, (uchar**) &_diskscan, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/tools/desc.cpp b/storage/ndb/tools/desc.cpp index 9eb0cf67ceb..831005139de 100644 --- a/storage/ndb/tools/desc.cpp +++ b/storage/ndb/tools/desc.cpp @@ -39,16 +39,16 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_desc"), { "database", 'd', "Name of database table is in", - (gptr*) &_dbname, (gptr*) &_dbname, 0, + (uchar**) &_dbname, (uchar**) &_dbname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "unqualified", 'u', "Use unqualified table names", - (gptr*) &_unqualified, (gptr*) &_unqualified, 0, + (uchar**) &_unqualified, (uchar**) &_unqualified, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "extra-partition-info", 'p', "Print more info per partition", - (gptr*) &_partinfo, (gptr*) &_partinfo, 0, + (uchar**) &_partinfo, (uchar**) &_partinfo, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "retries", 'r', "Retry every second for # retries", - (gptr*) &_retries, (gptr*) &_retries, 0, + (uchar**) &_retries, (uchar**) &_retries, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/tools/drop_index.cpp b/storage/ndb/tools/drop_index.cpp index 256c40e1924..ec88f331a80 100644 --- a/storage/ndb/tools/drop_index.cpp +++ b/storage/ndb/tools/drop_index.cpp @@ -30,7 +30,7 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_desc"), { "database", 'd', "Name of database table is in", - (gptr*) &_dbname, (gptr*) &_dbname, 0, + (uchar**) &_dbname, (uchar**) &_dbname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/tools/drop_tab.cpp b/storage/ndb/tools/drop_tab.cpp index a7accb904a4..8d07afbbf50 100644 --- a/storage/ndb/tools/drop_tab.cpp +++ b/storage/ndb/tools/drop_tab.cpp @@ -30,7 +30,7 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_desc"), { "database", 'd', "Name of database table is in", - (gptr*) &_dbname, (gptr*) &_dbname, 0, + (uchar**) &_dbname, (uchar**) &_dbname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/tools/listTables.cpp b/storage/ndb/tools/listTables.cpp index 6a73bcc54f5..45129cb34af 100644 --- a/storage/ndb/tools/listTables.cpp +++ b/storage/ndb/tools/listTables.cpp @@ -256,22 +256,22 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_show_tables"), { "database", 'd', "Name of database table is in", - (gptr*) &_dbname, (gptr*) &_dbname, 0, + (uchar**) &_dbname, (uchar**) &_dbname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "loops", 'l', "loops", - (gptr*) &_loops, (gptr*) &_loops, 0, + (uchar**) &_loops, (uchar**) &_loops, 0, GET_INT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0 }, { "type", 't', "type", - (gptr*) &_type, (gptr*) &_type, 0, + (uchar**) &_type, (uchar**) &_type, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "unqualified", 'u', "Use unqualified table names", - (gptr*) &_unqualified, (gptr*) &_unqualified, 0, + (uchar**) &_unqualified, (uchar**) &_unqualified, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "parsable", 'p', "Return output suitable for mysql LOAD DATA INFILE", - (gptr*) &_parsable, (gptr*) &_parsable, 0, + (uchar**) &_parsable, (uchar**) &_parsable, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "show-temp-status", OPT_SHOW_TMP_STATUS, "Show table temporary flag", - (gptr*) &show_temp_status, (gptr*) &show_temp_status, 0, + (uchar**) &show_temp_status, (uchar**) &show_temp_status, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/tools/ndb_config.cpp b/storage/ndb/tools/ndb_config.cpp index 31fc59a8b83..af36103f947 100644 --- a/storage/ndb/tools/ndb_config.cpp +++ b/storage/ndb/tools/ndb_config.cpp @@ -58,37 +58,37 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_config"), { "nodes", 256, "Print nodes", - (gptr*) &g_nodes, (gptr*) &g_nodes, + (uchar**) &g_nodes, (uchar**) &g_nodes, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, { "connections", 256, "Print connections", - (gptr*) &g_connections, (gptr*) &g_connections, + (uchar**) &g_connections, (uchar**) &g_connections, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, { "query", 'q', "Query option(s)", - (gptr*) &g_query, (gptr*) &g_query, + (uchar**) &g_query, (uchar**) &g_query, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "host", 256, "Host", - (gptr*) &g_host, (gptr*) &g_host, + (uchar**) &g_host, (uchar**) &g_host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "type", 258, "Type of node/connection", - (gptr*) &g_type, (gptr*) &g_type, + (uchar**) &g_type, (uchar**) &g_type, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "id", 258, "Nodeid", - (gptr*) &g_nodeid, (gptr*) &g_nodeid, + (uchar**) &g_nodeid, (uchar**) &g_nodeid, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "nodeid", 258, "Nodeid", - (gptr*) &g_nodeid, (gptr*) &g_nodeid, + (uchar**) &g_nodeid, (uchar**) &g_nodeid, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "fields", 'f', "Field separator", - (gptr*) &g_field_delimiter, (gptr*) &g_field_delimiter, + (uchar**) &g_field_delimiter, (uchar**) &g_field_delimiter, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "rows", 'r', "Row separator", - (gptr*) &g_row_delimiter, (gptr*) &g_row_delimiter, + (uchar**) &g_row_delimiter, (uchar**) &g_row_delimiter, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "config-file", 256, "Path to config.ini", - (gptr*) &g_config_file, (gptr*) &g_config_file, + (uchar**) &g_config_file, (uchar**) &g_config_file, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "mycnf", 256, "Read config from my.cnf", - (gptr*) &g_mycnf, (gptr*) &g_mycnf, + (uchar**) &g_mycnf, (uchar**) &g_mycnf, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/tools/restore/consumer_restore.cpp b/storage/ndb/tools/restore/consumer_restore.cpp index b7db8145c56..bb551deb2ba 100644 --- a/storage/ndb/tools/restore/consumer_restore.cpp +++ b/storage/ndb/tools/restore/consumer_restore.cpp @@ -424,13 +424,14 @@ error: bool BackupRestore::translate_frm(NdbDictionary::Table *table) { - const void *pack_data, *data, *new_pack_data; + uchar *pack_data, *data, *new_pack_data; char *new_data; - uint data_len, new_data_len, new_pack_len; + uint new_data_len; + size_t data_len, new_pack_len; uint no_parts, extra_growth; DBUG_ENTER("translate_frm"); - pack_data = table->getFrmData(); + pack_data = (uchar*) table->getFrmData(); no_parts = table->getFragmentCount(); /* Add max 4 characters per partition to handle worst case @@ -442,7 +443,7 @@ bool BackupRestore::translate_frm(NdbDictionary::Table *table) { DBUG_RETURN(TRUE); } - if ((new_data = my_malloc(data_len + extra_growth, MYF(0)))) + if ((new_data = (char*) my_malloc(data_len + extra_growth, MYF(0)))) { DBUG_RETURN(TRUE); } @@ -451,7 +452,7 @@ bool BackupRestore::translate_frm(NdbDictionary::Table *table) my_free(new_data, MYF(0)); DBUG_RETURN(TRUE); } - if (packfrm((const void*)new_data, new_data_len, + if (packfrm((uchar*) new_data, new_data_len, &new_pack_data, &new_pack_len)) { my_free(new_data, MYF(0)); diff --git a/storage/ndb/tools/restore/restore_main.cpp b/storage/ndb/tools/restore/restore_main.cpp index 79aebbaac45..ec2550118d3 100644 --- a/storage/ndb/tools/restore/restore_main.cpp +++ b/storage/ndb/tools/restore/restore_main.cpp @@ -100,99 +100,99 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_restore"), { "connect", 'c', "same as --connect-string", - (gptr*) &opt_connect_str, (gptr*) &opt_connect_str, 0, + (uchar**) &opt_connect_str, (uchar**) &opt_connect_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "nodeid", 'n', "Backup files from node with id", - (gptr*) &ga_nodeId, (gptr*) &ga_nodeId, 0, + (uchar**) &ga_nodeId, (uchar**) &ga_nodeId, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "backupid", 'b', "Backup id", - (gptr*) &ga_backupId, (gptr*) &ga_backupId, 0, + (uchar**) &ga_backupId, (uchar**) &ga_backupId, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "restore_data", 'r', "Restore table data/logs into NDB Cluster using NDBAPI", - (gptr*) &_restore_data, (gptr*) &_restore_data, 0, + (uchar**) &_restore_data, (uchar**) &_restore_data, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "restore_meta", 'm', "Restore meta data into NDB Cluster using NDBAPI", - (gptr*) &_restore_meta, (gptr*) &_restore_meta, 0, + (uchar**) &_restore_meta, (uchar**) &_restore_meta, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "no-upgrade", 'u', "Don't upgrade array type for var attributes, which don't resize VAR data and don't change column attributes", - (gptr*) &ga_no_upgrade, (gptr*) &ga_no_upgrade, 0, + (uchar**) &ga_no_upgrade, (uchar**) &ga_no_upgrade, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "no-restore-disk-objects", 'd', "Dont restore disk objects (tablespace/logfilegroups etc)", - (gptr*) &_no_restore_disk, (gptr*) &_no_restore_disk, 0, + (uchar**) &_no_restore_disk, (uchar**) &_no_restore_disk, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "restore_epoch", 'e', "Restore epoch info into the status table. Convenient on a MySQL Cluster " "replication slave, for starting replication. The row in " NDB_REP_DB "." NDB_APPLY_TABLE " with id 0 will be updated/inserted.", - (gptr*) &ga_restore_epoch, (gptr*) &ga_restore_epoch, 0, + (uchar**) &ga_restore_epoch, (uchar**) &ga_restore_epoch, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "skip-table-check", 's', "Skip table structure check during restore of data", - (gptr*) &ga_skip_table_check, (gptr*) &ga_skip_table_check, 0, + (uchar**) &ga_skip_table_check, (uchar**) &ga_skip_table_check, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "parallelism", 'p', "No of parallel transactions during restore of data." "(parallelism can be 1 to 1024)", - (gptr*) &ga_nParallelism, (gptr*) &ga_nParallelism, 0, + (uchar**) &ga_nParallelism, (uchar**) &ga_nParallelism, 0, GET_INT, REQUIRED_ARG, 128, 1, 1024, 0, 1, 0 }, { "print", OPT_PRINT, "Print data and log to stdout", - (gptr*) &_print, (gptr*) &_print, 0, + (uchar**) &_print, (uchar**) &_print, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "print_data", OPT_PRINT_DATA, "Print data to stdout", - (gptr*) &_print_data, (gptr*) &_print_data, 0, + (uchar**) &_print_data, (uchar**) &_print_data, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "print_meta", OPT_PRINT_META, "Print meta data to stdout", - (gptr*) &_print_meta, (gptr*) &_print_meta, 0, + (uchar**) &_print_meta, (uchar**) &_print_meta, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "print_log", OPT_PRINT_LOG, "Print log to stdout", - (gptr*) &_print_log, (gptr*) &_print_log, 0, + (uchar**) &_print_log, (uchar**) &_print_log, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "backup_path", OPT_BACKUP_PATH, "Path to backup files", - (gptr*) &ga_backupPath, (gptr*) &ga_backupPath, 0, + (uchar**) &ga_backupPath, (uchar**) &ga_backupPath, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "dont_ignore_systab_0", 'f', "Experimental. Do not ignore system table during restore.", - (gptr*) &ga_dont_ignore_systab_0, (gptr*) &ga_dont_ignore_systab_0, 0, + (uchar**) &ga_dont_ignore_systab_0, (uchar**) &ga_dont_ignore_systab_0, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "ndb-nodegroup-map", OPT_NDB_NODEGROUP_MAP, "Nodegroup map for ndbcluster. Syntax: list of (source_ng, dest_ng)", - (gptr*) &opt_nodegroup_map_str, - (gptr*) &opt_nodegroup_map_str, + (uchar**) &opt_nodegroup_map_str, + (uchar**) &opt_nodegroup_map_str, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "fields-enclosed-by", OPT_FIELDS_ENCLOSED_BY, "Fields are enclosed by ...", - (gptr*) &opt_fields_enclosed_by, (gptr*) &opt_fields_enclosed_by, 0, + (uchar**) &opt_fields_enclosed_by, (uchar**) &opt_fields_enclosed_by, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "fields-terminated-by", OPT_FIELDS_TERMINATED_BY, "Fields are terminated by ...", - (gptr*) &opt_fields_terminated_by, - (gptr*) &opt_fields_terminated_by, 0, + (uchar**) &opt_fields_terminated_by, + (uchar**) &opt_fields_terminated_by, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "fields-optionally-enclosed-by", OPT_FIELDS_OPTIONALLY_ENCLOSED_BY, "Fields are optionally enclosed by ...", - (gptr*) &opt_fields_optionally_enclosed_by, - (gptr*) &opt_fields_optionally_enclosed_by, 0, + (uchar**) &opt_fields_optionally_enclosed_by, + (uchar**) &opt_fields_optionally_enclosed_by, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "hex", OPT_HEX_FORMAT, "print binary types in hex format", - (gptr*) &opt_hex_format, (gptr*) &opt_hex_format, 0, + (uchar**) &opt_hex_format, (uchar**) &opt_hex_format, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "tab", 'T', "Creates tab separated textfile for each table to " "given path. (creates .txt files)", - (gptr*) &tab_path, (gptr*) &tab_path, 0, + (uchar**) &tab_path, (uchar**) &tab_path, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, { "append", OPT_APPEND, "for --tab append data to file", - (gptr*) &opt_append, (gptr*) &opt_append, 0, + (uchar**) &opt_append, (uchar**) &opt_append, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "lines-terminated-by", OPT_LINES_TERMINATED_BY, "", - (gptr*) &opt_lines_terminated_by, (gptr*) &opt_lines_terminated_by, 0, + (uchar**) &opt_lines_terminated_by, (uchar**) &opt_lines_terminated_by, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "verbose", OPT_VERBOSE, "verbosity", - (gptr*) &opt_verbose, (gptr*) &opt_verbose, 0, + (uchar**) &opt_verbose, (uchar**) &opt_verbose, 0, GET_INT, REQUIRED_ARG, 1, 0, 255, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/tools/select_all.cpp b/storage/ndb/tools/select_all.cpp index e2072f30edf..23d5f95f3f7 100644 --- a/storage/ndb/tools/select_all.cpp +++ b/storage/ndb/tools/select_all.cpp @@ -54,43 +54,43 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_desc"), { "database", 'd', "Name of database table is in", - (gptr*) &_dbname, (gptr*) &_dbname, 0, + (uchar**) &_dbname, (uchar**) &_dbname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "parallelism", 'p', "parallelism", - (gptr*) &_parallelism, (gptr*) &_parallelism, 0, + (uchar**) &_parallelism, (uchar**) &_parallelism, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "lock", 'l', "Read(0), Read-hold(1), Exclusive(2)", - (gptr*) &_lock, (gptr*) &_lock, 0, + (uchar**) &_lock, (uchar**) &_lock, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "order", 'o', "Sort resultset according to index", - (gptr*) &_order, (gptr*) &_order, 0, + (uchar**) &_order, (uchar**) &_order, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "descending", 'z', "Sort descending (requires order flag)", - (gptr*) &_descending, (gptr*) &_descending, 0, + (uchar**) &_descending, (uchar**) &_descending, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "header", 'h', "Print header", - (gptr*) &_header, (gptr*) &_header, 0, + (uchar**) &_header, (uchar**) &_header, 0, GET_BOOL, NO_ARG, 1, 0, 0, 0, 0, 0 }, { "useHexFormat", 'x', "Output numbers in hexadecimal format", - (gptr*) &_useHexFormat, (gptr*) &_useHexFormat, 0, + (uchar**) &_useHexFormat, (uchar**) &_useHexFormat, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "delimiter", 'D', "Column delimiter", - (gptr*) &_delimiter, (gptr*) &_delimiter, 0, + (uchar**) &_delimiter, (uchar**) &_delimiter, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "disk", 256, "Dump disk ref", - (gptr*) &_dumpDisk, (gptr*) &_dumpDisk, 0, + (uchar**) &_dumpDisk, (uchar**) &_dumpDisk, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "rowid", 256, "Dump rowid", - (gptr*) &use_rowid, (gptr*) &use_rowid, 0, + (uchar**) &use_rowid, (uchar**) &use_rowid, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "gci", 256, "Dump gci", - (gptr*) &use_gci, (gptr*) &use_gci, 0, + (uchar**) &use_gci, (uchar**) &use_gci, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "tupscan", 't', "Scan in tup order", - (gptr*) &_tup, (gptr*) &_tup, 0, + (uchar**) &_tup, (uchar**) &_tup, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "nodata", 256, "Dont print data", - (gptr*) &nodata, (gptr*) &nodata, 0, + (uchar**) &nodata, (uchar**) &nodata, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/tools/select_count.cpp b/storage/ndb/tools/select_count.cpp index 552d156b665..73982e886b5 100644 --- a/storage/ndb/tools/select_count.cpp +++ b/storage/ndb/tools/select_count.cpp @@ -43,13 +43,13 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_desc"), { "database", 'd', "Name of database table is in", - (gptr*) &_dbname, (gptr*) &_dbname, 0, + (uchar**) &_dbname, (uchar**) &_dbname, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { "parallelism", 'p', "parallelism", - (gptr*) &_parallelism, (gptr*) &_parallelism, 0, + (uchar**) &_parallelism, (uchar**) &_parallelism, 0, GET_INT, REQUIRED_ARG, 240, 0, 0, 0, 0, 0 }, { "lock", 'l', "Read(0), Read-hold(1), Exclusive(2)", - (gptr*) &_lock, (gptr*) &_lock, 0, + (uchar**) &_lock, (uchar**) &_lock, 0, GET_INT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/storage/ndb/tools/waiter.cpp b/storage/ndb/tools/waiter.cpp index de8d15ac17a..a292ab9140a 100644 --- a/storage/ndb/tools/waiter.cpp +++ b/storage/ndb/tools/waiter.cpp @@ -46,17 +46,17 @@ static struct my_option my_long_options[] = { NDB_STD_OPTS("ndb_desc"), { "no-contact", 'n', "Wait for cluster no contact", - (gptr*) &_no_contact, (gptr*) &_no_contact, 0, + (uchar**) &_no_contact, (uchar**) &_no_contact, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "not-started", OPT_WAIT_STATUS_NOT_STARTED, "Wait for cluster not started", - (gptr*) &_not_started, (gptr*) &_not_started, 0, + (uchar**) &_not_started, (uchar**) &_not_started, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "single-user", OPT_WAIT_STATUS_SINGLE_USER, "Wait for cluster to enter single user mode", - (gptr*) &_single_user, (gptr*) &_single_user, 0, + (uchar**) &_single_user, (uchar**) &_single_user, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0 }, { "timeout", 't', "Timeout to wait", - (gptr*) &_timeout, (gptr*) &_timeout, 0, + (uchar**) &_timeout, (uchar**) &_timeout, 0, GET_INT, REQUIRED_ARG, 120, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/strings/bchange.c b/strings/bchange.c index f17fb9bea27..0b2c62019b5 100644 --- a/strings/bchange.c +++ b/strings/bchange.c @@ -26,10 +26,10 @@ #include <my_global.h> #include "m_string.h" -void bchange(register char *dst, uint old_length, register const char *src, - uint new_length, uint tot_length) +void bchange(register uchar *dst, size_t old_length, register const uchar *src, + size_t new_length, size_t tot_length) { - uint rest=tot_length-old_length; + size_t rest=tot_length-old_length; if (old_length < new_length) bmove_upp(dst+rest+new_length,dst+tot_length,rest); else diff --git a/strings/bcmp.c b/strings/bcmp.c index fd9ee5c1b96..1b6ed22fc22 100644 --- a/strings/bcmp.c +++ b/strings/bcmp.c @@ -51,9 +51,11 @@ uint len; /* 0 <= len <= 65535 */ #else #ifndef HAVE_purify -int bcmp(register const char *s1,register const char *s2, register uint len) +size_t bcmp(register const uchar *s1,register const uchar *s2, + register size_t len) #else -int my_bcmp(register const char *s1,register const char *s2, register uint len) +size_t my_bcmp(register const uchar *s1,register const uchar *s2, + register size_t len) #endif { while (len-- != 0 && *s1++ == *s2++) ; diff --git a/strings/bmove512.c b/strings/bmove512.c index c3a4b7dfe4e..c3f0446ead6 100644 --- a/strings/bmove512.c +++ b/strings/bmove512.c @@ -36,7 +36,7 @@ #define LONG ulonglong #endif -void bmove512(gptr to, const gptr from, register uint length) +void bmove512(uchar *to, const uchar *from, register size_t length) { reg1 LONG *f,*t,*end= (LONG*) ((char*) from+length); diff --git a/strings/bmove_upp.c b/strings/bmove_upp.c index 02b59bdb703..fb47bda2d1d 100644 --- a/strings/bmove_upp.c +++ b/strings/bmove_upp.c @@ -41,7 +41,8 @@ asm(".L5: "); } #else -void bmove_upp(register char *dst, register const char *src, register uint len) +void bmove_upp(register uchar *dst, register const uchar *src, + register size_t len) { while (len-- != 0) *--dst = *--src; } diff --git a/strings/ctype-big5.c b/strings/ctype-big5.c index dba5064ba0c..a0571ff0b22 100644 --- a/strings/ctype-big5.c +++ b/strings/ctype-big5.c @@ -220,7 +220,7 @@ static uint16 big5strokexfrm(uint16 i) static int my_strnncoll_big5_internal(const uchar **a_res, - const uchar **b_res, uint length) + const uchar **b_res, size_t length) { const uchar *a= *a_res, *b= *b_res; @@ -249,11 +249,11 @@ static int my_strnncoll_big5_internal(const uchar **a_res, /* Compare strings */ static int my_strnncoll_big5(CHARSET_INFO *cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool b_is_prefix) { - uint length= min(a_length, b_length); + size_t length= min(a_length, b_length); int res= my_strnncoll_big5_internal(&a, &b, length); return res ? res : (int)((b_is_prefix ? length : a_length) - b_length); } @@ -262,11 +262,11 @@ static int my_strnncoll_big5(CHARSET_INFO *cs __attribute__((unused)), /* compare strings, ignore end space */ static int my_strnncollsp_big5(CHARSET_INFO * cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool diff_if_only_endspace_difference) { - uint length= min(a_length, b_length); + size_t length= min(a_length, b_length); int res= my_strnncoll_big5_internal(&a, &b, length); #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE @@ -301,12 +301,12 @@ static int my_strnncollsp_big5(CHARSET_INFO * cs __attribute__((unused)), } -static int my_strnxfrm_big5(CHARSET_INFO *cs __attribute__((unused)), - uchar * dest, uint len, - const uchar * src, uint srclen) +static size_t my_strnxfrm_big5(CHARSET_INFO *cs __attribute__((unused)), + uchar *dest, size_t len, + const uchar *src, size_t srclen) { uint16 e; - uint dstlen= len; + size_t dstlen= len; len = srclen; while (len--) @@ -327,7 +327,7 @@ static int my_strnxfrm_big5(CHARSET_INFO *cs __attribute__((unused)), } #if 0 -static int my_strcoll_big5(const uchar * s1, const uchar * s2) +static int my_strcoll_big5(const uchar *s1, const uchar *s2) { while (*s1 && *s2) @@ -346,7 +346,7 @@ static int my_strcoll_big5(const uchar * s1, const uchar * s2) return 0; } -static int my_strxfrm_big5(uchar * dest, const uchar * src, int len) +static int my_strxfrm_big5(uchar *dest, const uchar *src, int len) { uint16 e; uchar *d = dest; @@ -395,15 +395,16 @@ static int my_strxfrm_big5(uchar * dest, const uchar * src, int len) #define max_sort_char ((char) 255) static my_bool my_like_range_big5(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr,uint ptr_length, + const char *ptr,size_t ptr_length, pbool escape, pbool w_one, pbool w_many, - uint res_length, char *min_str,char *max_str, - uint *min_length,uint *max_length) + size_t res_length, + char *min_str, char *max_str, + size_t *min_length, size_t *max_length) { const char *end= ptr + ptr_length; char *min_org=min_str; char *min_end=min_str+res_length; - uint charlen= res_length / cs->mbmaxlen; + size_t charlen= res_length / cs->mbmaxlen; for (; ptr != end && min_str != min_end && charlen > 0; ptr++, charlen--) { @@ -435,7 +436,7 @@ static my_bool my_like_range_big5(CHARSET_INFO *cs __attribute__((unused)), 'a\0\0... is the smallest possible string when we have space expand a\ff\ff... is the biggest possible string */ - *min_length= ((cs->state & MY_CS_BINSORT) ? (uint) (min_str - min_org) : + *min_length= ((cs->state & MY_CS_BINSORT) ? (size_t) (min_str - min_org) : res_length); *max_length= res_length; do { @@ -447,21 +448,21 @@ static my_bool my_like_range_big5(CHARSET_INFO *cs __attribute__((unused)), *min_str++= *max_str++ = *ptr; } - *min_length= *max_length= (uint) (min_str-min_org); + *min_length= *max_length= (size_t) (min_str-min_org); while (min_str != min_end) *min_str++= *max_str++= ' '; return 0; } -static int ismbchar_big5(CHARSET_INFO *cs __attribute__((unused)), - const char* p, const char *e) +static uint ismbchar_big5(CHARSET_INFO *cs __attribute__((unused)), + const char* p, const char *e) { return (isbig5head(*(p)) && (e)-(p)>1 && isbig5tail(*((p)+1))? 2: 0); } -static int mbcharlen_big5(CHARSET_INFO *cs __attribute__((unused)), uint c) +static uint mbcharlen_big5(CHARSET_INFO *cs __attribute__((unused)), uint c) { return (isbig5head(c)? 2 : 1); } @@ -6239,7 +6240,7 @@ static int func_uni_big5_onechar(int code){ static int my_wc_mb_big5(CHARSET_INFO *cs __attribute__((unused)), - my_wc_t wc, unsigned char *s, unsigned char *e) + my_wc_t wc, uchar *s, uchar *e) { int code; @@ -6297,9 +6298,9 @@ my_mb_wc_big5(CHARSET_INFO *cs __attribute__((unused)), CP950 and HKSCS additional characters are also accepted. */ static -uint my_well_formed_len_big5(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e, - uint pos, int *error) +size_t my_well_formed_len_big5(CHARSET_INFO *cs __attribute__((unused)), + const char *b, const char *e, + size_t pos, int *error) { const char *b0= b; const char *emb= e - 1; /* Last possible end of an MB character */ @@ -6324,7 +6325,7 @@ uint my_well_formed_len_big5(CHARSET_INFO *cs __attribute__((unused)), break; } } - return (uint) (b - b0); + return (size_t) (b - b0); } diff --git a/strings/ctype-bin.c b/strings/ctype-bin.c index 69f712c5c44..2c30f5402b5 100644 --- a/strings/ctype-bin.c +++ b/strings/ctype-bin.c @@ -69,26 +69,26 @@ static uchar bin_char_array[] = static my_bool my_coll_init_8bit_bin(CHARSET_INFO *cs, - void *(*alloc)(uint) __attribute__((unused))) + void *(*alloc)(size_t) __attribute__((unused))) { cs->max_sort_char=255; return FALSE; } static int my_strnncoll_binary(CHARSET_INFO * cs __attribute__((unused)), - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { - uint len=min(slen,tlen); + size_t len=min(slen,tlen); int cmp= memcmp(s,t,len); return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen); } -uint my_lengthsp_binary(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr __attribute__((unused)), - uint length) +size_t my_lengthsp_binary(CHARSET_INFO *cs __attribute__((unused)), + const char *ptr __attribute__((unused)), + size_t length) { return length; } @@ -117,8 +117,8 @@ uint my_lengthsp_binary(CHARSET_INFO *cs __attribute__((unused)), */ static int my_strnncollsp_binary(CHARSET_INFO * cs __attribute__((unused)), - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool diff_if_only_endspace_difference __attribute__((unused))) { @@ -127,11 +127,11 @@ static int my_strnncollsp_binary(CHARSET_INFO * cs __attribute__((unused)), static int my_strnncoll_8bit_bin(CHARSET_INFO * cs __attribute__((unused)), - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { - uint len=min(slen,tlen); + size_t len=min(slen,tlen); int cmp= memcmp(s,t,len); return cmp ? cmp : (int)((t_is_prefix ? len : slen) - tlen); } @@ -163,12 +163,12 @@ static int my_strnncoll_8bit_bin(CHARSET_INFO * cs __attribute__((unused)), */ static int my_strnncollsp_8bit_bin(CHARSET_INFO * cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool diff_if_only_endspace_difference) { const uchar *end; - uint length; + size_t length; int res; #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE @@ -211,17 +211,18 @@ static int my_strnncollsp_8bit_bin(CHARSET_INFO * cs __attribute__((unused)), /* This function is used for all conversion functions */ -static uint my_case_str_bin(CHARSET_INFO *cs __attribute__((unused)), - char *str __attribute__((unused))) +static size_t my_case_str_bin(CHARSET_INFO *cs __attribute__((unused)), + char *str __attribute__((unused))) { return 0; } -static uint my_case_bin(CHARSET_INFO *cs __attribute__((unused)), - char *src __attribute__((unused)), - uint srclen, - char *dst __attribute__((unused)), - uint dstlen __attribute__((unused))) + +static size_t my_case_bin(CHARSET_INFO *cs __attribute__((unused)), + char *src __attribute__((unused)), + size_t srclen, + char *dst __attribute__((unused)), + size_t dstlen __attribute__((unused))) { return srclen; } @@ -234,8 +235,8 @@ static int my_strcasecmp_bin(CHARSET_INFO * cs __attribute__((unused)), } -int my_mbcharlen_8bit(CHARSET_INFO *cs __attribute__((unused)), - uint c __attribute__((unused))) +uint my_mbcharlen_8bit(CHARSET_INFO *cs __attribute__((unused)), + uint c __attribute__((unused))) { return 1; } @@ -243,8 +244,8 @@ int my_mbcharlen_8bit(CHARSET_INFO *cs __attribute__((unused)), static int my_mb_wc_bin(CHARSET_INFO *cs __attribute__((unused)), my_wc_t *wc, - const unsigned char *str, - const unsigned char *end __attribute__((unused))) + const uchar *str, + const uchar *end __attribute__((unused))) { if (str >= end) return MY_CS_TOOSMALL; @@ -256,8 +257,8 @@ static int my_mb_wc_bin(CHARSET_INFO *cs __attribute__((unused)), static int my_wc_mb_bin(CHARSET_INFO *cs __attribute__((unused)), my_wc_t wc, - unsigned char *s, - unsigned char *e __attribute__((unused))) + uchar *s, + uchar *e __attribute__((unused))) { if (s >= e) return MY_CS_TOOSMALL; @@ -272,7 +273,7 @@ static int my_wc_mb_bin(CHARSET_INFO *cs __attribute__((unused)), void my_hash_sort_bin(CHARSET_INFO *cs __attribute__((unused)), - const uchar *key, uint len,ulong *nr1, ulong *nr2) + const uchar *key, size_t len,ulong *nr1, ulong *nr2) { const uchar *pos = key; @@ -374,9 +375,9 @@ int my_wildcmp_bin(CHARSET_INFO *cs, } -static int my_strnxfrm_bin(CHARSET_INFO *cs __attribute__((unused)), - uchar * dest, uint dstlen, - const uchar *src, uint srclen) +static size_t my_strnxfrm_bin(CHARSET_INFO *cs __attribute__((unused)), + uchar *dest, size_t dstlen, + const uchar *src, size_t srclen) { if (dest != src) memcpy(dest, src, min(dstlen,srclen)); @@ -387,9 +388,9 @@ static int my_strnxfrm_bin(CHARSET_INFO *cs __attribute__((unused)), static -int my_strnxfrm_8bit_bin(CHARSET_INFO *cs __attribute__((unused)), - uchar * dest, uint dstlen, - const uchar *src, uint srclen) +size_t my_strnxfrm_8bit_bin(CHARSET_INFO *cs __attribute__((unused)), + uchar *dest, size_t dstlen, + const uchar *src, size_t srclen) { if (dest != src) memcpy(dest, src, min(dstlen,srclen)); @@ -401,8 +402,8 @@ int my_strnxfrm_8bit_bin(CHARSET_INFO *cs __attribute__((unused)), static uint my_instr_bin(CHARSET_INFO *cs __attribute__((unused)), - const char *b, uint b_length, - const char *s, uint s_length, + const char *b, size_t b_length, + const char *s, size_t s_length, my_match_t *match, uint nmatch) { register const uchar *str, *search, *end, *search_end; @@ -442,7 +443,7 @@ skip: if (nmatch > 0) { match[0].beg= 0; - match[0].end= (uint) (str- (const uchar*)b-1); + match[0].end= (size_t) (str- (const uchar*)b-1); match[0].mb_len= match[0].end; if (nmatch > 1) @@ -462,65 +463,65 @@ skip: MY_COLLATION_HANDLER my_collation_8bit_bin_handler = { - my_coll_init_8bit_bin, - my_strnncoll_8bit_bin, - my_strnncollsp_8bit_bin, - my_strnxfrm_8bit_bin, - my_strnxfrmlen_simple, - my_like_range_simple, - my_wildcmp_bin, - my_strcasecmp_bin, - my_instr_bin, - my_hash_sort_bin, - my_propagate_simple + my_coll_init_8bit_bin, + my_strnncoll_8bit_bin, + my_strnncollsp_8bit_bin, + my_strnxfrm_8bit_bin, + my_strnxfrmlen_simple, + my_like_range_simple, + my_wildcmp_bin, + my_strcasecmp_bin, + my_instr_bin, + my_hash_sort_bin, + my_propagate_simple }; static MY_COLLATION_HANDLER my_collation_binary_handler = { - NULL, /* init */ - my_strnncoll_binary, - my_strnncollsp_binary, - my_strnxfrm_bin, - my_strnxfrmlen_simple, - my_like_range_simple, - my_wildcmp_bin, - my_strcasecmp_bin, - my_instr_bin, - my_hash_sort_bin, - my_propagate_simple + NULL, /* init */ + my_strnncoll_binary, + my_strnncollsp_binary, + my_strnxfrm_bin, + my_strnxfrmlen_simple, + my_like_range_simple, + my_wildcmp_bin, + my_strcasecmp_bin, + my_instr_bin, + my_hash_sort_bin, + my_propagate_simple }; static MY_CHARSET_HANDLER my_charset_handler= { - NULL, /* init */ - NULL, /* ismbchar */ - my_mbcharlen_8bit, /* mbcharlen */ - my_numchars_8bit, - my_charpos_8bit, - my_well_formed_len_8bit, - my_lengthsp_binary, - my_numcells_8bit, - my_mb_wc_bin, - my_wc_mb_bin, - my_mb_ctype_8bit, - my_case_str_bin, - my_case_str_bin, - my_case_bin, - my_case_bin, - my_snprintf_8bit, - my_long10_to_str_8bit, - my_longlong10_to_str_8bit, - my_fill_8bit, - my_strntol_8bit, - my_strntoul_8bit, - my_strntoll_8bit, - my_strntoull_8bit, - my_strntod_8bit, - my_strtoll10_8bit, - my_strntoull10rnd_8bit, - my_scan_8bit + NULL, /* init */ + NULL, /* ismbchar */ + my_mbcharlen_8bit, /* mbcharlen */ + my_numchars_8bit, + my_charpos_8bit, + my_well_formed_len_8bit, + my_lengthsp_binary, + my_numcells_8bit, + my_mb_wc_bin, + my_wc_mb_bin, + my_mb_ctype_8bit, + my_case_str_bin, + my_case_str_bin, + my_case_bin, + my_case_bin, + my_snprintf_8bit, + my_long10_to_str_8bit, + my_longlong10_to_str_8bit, + my_fill_8bit, + my_strntol_8bit, + my_strntoul_8bit, + my_strntoll_8bit, + my_strntoull_8bit, + my_strntod_8bit, + my_strtoll10_8bit, + my_strntoull10rnd_8bit, + my_scan_8bit }; diff --git a/strings/ctype-cp932.c b/strings/ctype-cp932.c index dc8d1d7cb22..72b00679e1c 100644 --- a/strings/ctype-cp932.c +++ b/strings/ctype-cp932.c @@ -182,13 +182,13 @@ static uchar NEAR sort_order_cp932[]= (0x80<=(c) && (c)<=0xfc)) -static int ismbchar_cp932(CHARSET_INFO *cs __attribute__((unused)), +static uint ismbchar_cp932(CHARSET_INFO *cs __attribute__((unused)), const char* p, const char *e) { return (iscp932head((uchar) *p) && (e-p)>1 && iscp932tail((uchar)p[1]) ? 2: 0); } -static int mbcharlen_cp932(CHARSET_INFO *cs __attribute__((unused)),uint c) +static uint mbcharlen_cp932(CHARSET_INFO *cs __attribute__((unused)),uint c) { return (iscp932head((uchar) c) ? 2 : 1); } @@ -198,8 +198,8 @@ static int mbcharlen_cp932(CHARSET_INFO *cs __attribute__((unused)),uint c) static int my_strnncoll_cp932_internal(CHARSET_INFO *cs, - const uchar **a_res, uint a_length, - const uchar **b_res, uint b_length) + const uchar **a_res, size_t a_length, + const uchar **b_res, size_t b_length) { const uchar *a= *a_res, *b= *b_res; const uchar *a_end= a + a_length; @@ -230,8 +230,8 @@ static int my_strnncoll_cp932_internal(CHARSET_INFO *cs, static int my_strnncoll_cp932(CHARSET_INFO *cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool b_is_prefix) { int res= my_strnncoll_cp932_internal(cs, &a, a_length, &b, b_length); @@ -242,8 +242,8 @@ static int my_strnncoll_cp932(CHARSET_INFO *cs __attribute__((unused)), static int my_strnncollsp_cp932(CHARSET_INFO *cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool diff_if_only_endspace_difference __attribute__((unused))) { @@ -275,9 +275,9 @@ static int my_strnncollsp_cp932(CHARSET_INFO *cs __attribute__((unused)), -static int my_strnxfrm_cp932(CHARSET_INFO *cs __attribute__((unused)), - uchar *dest, uint len, - const uchar *src, uint srclen) +static size_t my_strnxfrm_cp932(CHARSET_INFO *cs __attribute__((unused)), + uchar *dest, size_t len, + const uchar *src, size_t srclen) { uchar *d_end = dest + len; uchar *s_end = (uchar*) src + srclen; @@ -318,10 +318,11 @@ static int my_strnxfrm_cp932(CHARSET_INFO *cs __attribute__((unused)), #define max_sort_char ((char) 255) static my_bool my_like_range_cp932(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr,uint ptr_length, - pbool escape, pbool w_one, pbool w_many, - uint res_length, char *min_str,char *max_str, - uint *min_length,uint *max_length) + const char *ptr,size_t ptr_length, + pbool escape, pbool w_one, pbool w_many, + size_t res_length, + char *min_str,char *max_str, + size_t *min_length, size_t *max_length) { const char *end=ptr+ptr_length; char *min_org=min_str; @@ -350,7 +351,7 @@ static my_bool my_like_range_cp932(CHARSET_INFO *cs __attribute__((unused)), } if (*ptr == w_many) { /* '%' in SQL */ - *min_length = (uint)(min_str - min_org); + *min_length = (size_t)(min_str - min_org); *max_length = res_length; do { @@ -361,7 +362,7 @@ static my_bool my_like_range_cp932(CHARSET_INFO *cs __attribute__((unused)), } *min_str++ = *max_str++ = *ptr++; } - *min_length = *max_length = (uint)(min_str - min_org); + *min_length = *max_length = (size_t) (min_str - min_org); while (min_str < min_end) *min_str++ = *max_str++ = ' '; /* Because if key compression */ return 0; @@ -5378,12 +5379,12 @@ my_mb_wc_cp932(CHARSET_INFO *cs __attribute__((unused)), } static -uint my_numcells_cp932(CHARSET_INFO *cs __attribute__((unused)), +size_t my_numcells_cp932(CHARSET_INFO *cs __attribute__((unused)), const char *str, const char *str_end) { - uint clen= 0; - const unsigned char *b= (const unsigned char *) str; - const unsigned char *e= (const unsigned char *) str_end; + size_t clen= 0; + const uchar *b= (const uchar *) str; + const uchar *e= (const uchar *) str_end; for (clen= 0; b < e; ) { @@ -5410,9 +5411,11 @@ uint my_numcells_cp932(CHARSET_INFO *cs __attribute__((unused)), Returns a well formed length of a cp932 string. cp932 additional characters are also accepted. */ + static -uint my_well_formed_len_cp932(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e, uint pos, int *error) +size_t my_well_formed_len_cp932(CHARSET_INFO *cs __attribute__((unused)), + const char *b, const char *e, + size_t pos, int *error) { const char *b0= b; *error= 0; @@ -5445,7 +5448,7 @@ uint my_well_formed_len_cp932(CHARSET_INFO *cs __attribute__((unused)), break; } } - return (uint) (b - b0); + return (size_t) (b - b0); } diff --git a/strings/ctype-czech.c b/strings/ctype-czech.c index d0104a50f4a..a5df86cc6b3 100644 --- a/strings/ctype-czech.c +++ b/strings/ctype-czech.c @@ -83,7 +83,7 @@ below for what are the "special values" */ -static uchar * CZ_SORT_TABLE[] = { +static uchar *CZ_SORT_TABLE[] = { (uchar*) "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\043\044\045\046\047\050\051\052\053\054\000\000\000\000\000\000\000\003\004\377\007\010\011\012\013\015\016\017\020\022\023\024\025\026\027\031\033\034\035\036\037\040\041\000\000\000\000\000\000\003\004\377\007\010\011\012\013\015\016\017\020\022\023\024\025\026\027\031\033\034\035\036\037\040\041\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\003\000\021\000\020\032\000\000\032\032\033\042\000\042\042\000\003\000\021\000\020\032\000\000\032\032\033\042\000\042\042\027\003\003\003\003\020\006\006\006\010\010\010\010\015\015\007\007\023\023\024\024\024\024\000\030\034\034\034\034\040\033\000\027\003\003\003\003\020\006\006\006\010\010\010\010\015\015\007\007\023\023\024\024\024\024\000\030\034\034\034\034\040\033\000", (uchar*) "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\106\107\110\111\112\113\114\115\116\117\000\000\000\000\000\000\000\003\011\377\016\021\026\027\030\032\035\036\037\043\044\047\054\055\056\061\065\070\075\076\077\100\102\000\000\000\000\000\000\003\011\377\016\021\026\027\030\032\035\036\037\043\044\047\054\055\056\061\065\070\075\076\077\100\102\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\010\000\042\000\041\063\000\000\062\064\066\104\000\103\105\000\010\000\042\000\041\063\000\000\062\064\066\104\000\103\105\057\004\005\007\006\040\014\015\013\022\025\024\023\033\034\017\020\046\045\050\051\053\052\000\060\072\071\074\073\101\067\000\057\004\005\007\006\040\014\015\013\022\025\024\023\033\034\017\020\046\045\050\051\053\052\000\060\072\071\074\073\101\067\000", (uchar*) "\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\002\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\212\213\214\215\216\217\220\221\222\223\000\000\000\000\000\000\000\004\020\377\032\040\052\054\056\063\071\073\075\105\107\115\127\131\133\141\151\157\171\173\175\177\203\000\000\000\000\000\000\003\017\377\031\037\051\053\055\062\070\072\074\104\106\114\126\130\132\140\150\156\170\172\174\176\202\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\016\000\103\000\101\145\000\000\143\147\153\207\000\205\211\000\015\000\102\000\100\144\000\000\142\146\152\206\000\204\210\135\006\010\014\012\077\026\030\024\042\050\046\044\065\067\034\036\113\111\117\121\125\123\000\137\163\161\167\165\201\155\000\134\005\007\013\011\076\025\027\023\041\047\045\043\064\066\033\035\112\110\116\120\124\122\000\136\162\160\166\164\200\154\000", @@ -99,7 +99,7 @@ static uchar * CZ_SORT_TABLE[] = { struct wordvalue { const char * word; - uchar * outvalue; + uchar *outvalue; }; static struct wordvalue doubles[] = { { "ch", (uchar*) "\014\031\057\057" }, @@ -190,8 +190,8 @@ while (1) \ { p++; continue; } /* ignore value */ \ if (value == 2) /* space */ \ { \ - const uchar * tmp; \ - const uchar * runner = ++p; \ + const uchar *tmp; \ + const uchar *runner = ++p; \ while (!(IS_END(runner, src, len)) && (CZ_SORT_TABLE[pass][*runner] == 2)) \ runner++; /* skip all spaces */ \ if (IS_END(runner, src, len) && SKIP_TRAILING_SPACES) \ @@ -240,12 +240,12 @@ while (1) \ */ static int my_strnncoll_czech(CHARSET_INFO *cs __attribute__((unused)), - const uchar * s1, uint len1, - const uchar * s2, uint len2, + const uchar *s1, size_t len1, + const uchar *s2, size_t len2, my_bool s2_is_prefix) { int v1, v2; - const uchar * p1, * p2, * store1, * store2; + const uchar *p1, * p2, * store1, * store2; int pass1 = 0, pass2 = 0; if (s2_is_prefix && len1 > len2) @@ -274,8 +274,8 @@ static int my_strnncoll_czech(CHARSET_INFO *cs __attribute__((unused)), static int my_strnncollsp_czech(CHARSET_INFO * cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool diff_if_only_endspace_difference __attribute__((unused))) { @@ -290,14 +290,14 @@ int my_strnncollsp_czech(CHARSET_INFO * cs, the length of the strings being specified */ -static int my_strnxfrm_czech(CHARSET_INFO *cs __attribute__((unused)), - uchar * dest, uint len, - const uchar * src, uint srclen) +static size_t my_strnxfrm_czech(CHARSET_INFO *cs __attribute__((unused)), + uchar *dest, size_t len, + const uchar *src, size_t srclen) { int value; - const uchar * p, * store; + const uchar *p, * store; int pass = 0; - uint totlen = 0; + size_t totlen = 0; p = src; store = src; do @@ -361,11 +361,11 @@ static int my_strnxfrm_czech(CHARSET_INFO *cs __attribute__((unused)), #define EXAMPLE static my_bool my_like_range_czech(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr,uint ptr_length, + const char *ptr,size_t ptr_length, pbool escape, pbool w_one, pbool w_many, - uint res_length, char *min_str, + size_t res_length, char *min_str, char *max_str, - uint *min_length,uint *max_length) + size_t *min_length,size_t *max_length) { #ifdef EXAMPLE uchar value; @@ -396,7 +396,7 @@ static my_bool my_like_range_czech(CHARSET_INFO *cs __attribute__((unused)), } if (cs->state & MY_CS_BINSORT) - *min_length= (uint) (min_str - min_org); + *min_length= (size_t) (min_str - min_org); else { /* 'a\0\0... is the smallest possible string */ diff --git a/strings/ctype-euc_kr.c b/strings/ctype-euc_kr.c index a90489cf7c6..844d8cc3ff5 100644 --- a/strings/ctype-euc_kr.c +++ b/strings/ctype-euc_kr.c @@ -182,15 +182,15 @@ static uchar NEAR sort_order_euc_kr[]= #define iseuc_kr(c) ((0xa1<=(uchar)(c) && (uchar)(c)<=0xfe)) -static int ismbchar_euc_kr(CHARSET_INFO *cs __attribute__((unused)), - const char* p, const char *e) +static uint ismbchar_euc_kr(CHARSET_INFO *cs __attribute__((unused)), + const char* p, const char *e) { return ((*(uchar*)(p)<0x80)? 0:\ iseuc_kr(*(p)) && (e)-(p)>1 && iseuc_kr(*((p)+1))? 2:\ 0); } -static int mbcharlen_euc_kr(CHARSET_INFO *cs __attribute__((unused)),uint c) +static uint mbcharlen_euc_kr(CHARSET_INFO *cs __attribute__((unused)),uint c) { return (iseuc_kr(c) ? 2 : 1); } @@ -8608,6 +8608,7 @@ my_wc_mb_euc_kr(CHARSET_INFO *cs __attribute__((unused)), return 2; } + static int my_mb_wc_euc_kr(CHARSET_INFO *cs __attribute__((unused)), my_wc_t *pwc, const uchar *s, const uchar *e) @@ -8637,10 +8638,10 @@ my_mb_wc_euc_kr(CHARSET_INFO *cs __attribute__((unused)), /* Returns well formed length of a EUC-KR string. */ -static uint +static size_t my_well_formed_len_euckr(CHARSET_INFO *cs __attribute__((unused)), const char *b, const char *e, - uint pos, int *error) + size_t pos, int *error) { const char *b0= b; const char *emb= e - 1; /* Last possible end of an MB character */ @@ -8665,7 +8666,7 @@ my_well_formed_len_euckr(CHARSET_INFO *cs __attribute__((unused)), break; } } - return (uint) (b - b0); + return (size_t) (b - b0); } diff --git a/strings/ctype-eucjpms.c b/strings/ctype-eucjpms.c index eb1811b19bf..14be5e84d21 100644 --- a/strings/ctype-eucjpms.c +++ b/strings/ctype-eucjpms.c @@ -185,7 +185,7 @@ static uchar NEAR sort_order_eucjpms[]= #define iseucjpms_ss3(c) (((c)&0xff) == 0x8f) -static int ismbchar_eucjpms(CHARSET_INFO *cs __attribute__((unused)), +static uint ismbchar_eucjpms(CHARSET_INFO *cs __attribute__((unused)), const char* p, const char *e) { return ((*(uchar*)(p)<0x80)? 0:\ @@ -195,7 +195,7 @@ static int ismbchar_eucjpms(CHARSET_INFO *cs __attribute__((unused)), 0); } -static int mbcharlen_eucjpms(CHARSET_INFO *cs __attribute__((unused)),uint c) +static uint mbcharlen_eucjpms(CHARSET_INFO *cs __attribute__((unused)),uint c) { return (iseucjpms(c)? 2: iseucjpms_ss2(c)? 2: iseucjpms_ss3(c)? 3: 1); } @@ -8387,8 +8387,9 @@ my_jisx0212_uni_onechar(int code){ */ static -uint my_well_formed_len_eucjpms(CHARSET_INFO *cs __attribute__((unused)), - const char *beg, const char *end, uint pos, int *error) +size_t my_well_formed_len_eucjpms(CHARSET_INFO *cs __attribute__((unused)), + const char *beg, const char *end, size_t pos, + int *error) { const uchar *b= (uchar *) beg; *error=0; @@ -8427,19 +8428,19 @@ uint my_well_formed_len_eucjpms(CHARSET_INFO *cs __attribute__((unused)), *b >= 0xA1 && *b <= 0xFE) /* [xA1-xFE][xA1-xFE] */ continue; *error=1; - return (uint) (chbeg - beg); /* invalid sequence */ + return (size_t) (chbeg - beg); /* invalid sequence */ } - return (uint) (b - (uchar *) beg); + return (size_t) (b - (uchar *) beg); } static -uint my_numcells_eucjp(CHARSET_INFO *cs __attribute__((unused)), - const char *str, const char *str_end) +size_t my_numcells_eucjp(CHARSET_INFO *cs __attribute__((unused)), + const char *str, const char *str_end) { - uint clen= 0; - const unsigned char *b= (const unsigned char *) str; - const unsigned char *e= (const unsigned char *) str_end; + size_t clen; + const uchar *b= (const uchar *) str; + const uchar *e= (const uchar *) str_end; for (clen= 0; b < e; ) { @@ -8555,9 +8556,9 @@ my_mb_wc_euc_jp(CHARSET_INFO *cs,my_wc_t *pwc, const uchar *s, const uchar *e) } static int -my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, unsigned char *s, unsigned char *e) +my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, uchar *s, uchar *e) { - unsigned char c1; + uchar c1; int jp; if (s >= e) diff --git a/strings/ctype-gb2312.c b/strings/ctype-gb2312.c index 6b4238859d5..21aeb8b7990 100644 --- a/strings/ctype-gb2312.c +++ b/strings/ctype-gb2312.c @@ -165,13 +165,13 @@ static uchar NEAR sort_order_gb2312[]= #define isgb2312tail(c) (0xa1<=(uchar)(c) && (uchar)(c)<=0xfe) -static int ismbchar_gb2312(CHARSET_INFO *cs __attribute__((unused)), +static uint ismbchar_gb2312(CHARSET_INFO *cs __attribute__((unused)), const char* p, const char *e) { return (isgb2312head(*(p)) && (e)-(p)>1 && isgb2312tail(*((p)+1))? 2: 0); } -static int mbcharlen_gb2312(CHARSET_INFO *cs __attribute__((unused)),uint c) +static uint mbcharlen_gb2312(CHARSET_INFO *cs __attribute__((unused)),uint c) { return (isgb2312head(c)? 2 : 1); } @@ -5688,10 +5688,10 @@ my_mb_wc_gb2312(CHARSET_INFO *cs __attribute__((unused)), /* Returns well formed length of a EUC-KR string. */ -static uint +static size_t my_well_formed_len_gb2312(CHARSET_INFO *cs __attribute__((unused)), const char *b, const char *e, - uint pos, int *error) + size_t pos, int *error) { const char *b0= b; const char *emb= e - 1; /* Last possible end of an MB character */ @@ -5716,7 +5716,7 @@ my_well_formed_len_gb2312(CHARSET_INFO *cs __attribute__((unused)), break; } } - return (uint) (b - b0); + return (size_t) (b - b0); } diff --git a/strings/ctype-gbk.c b/strings/ctype-gbk.c index d88f4786017..e9a2b7cf832 100644 --- a/strings/ctype-gbk.c +++ b/strings/ctype-gbk.c @@ -2582,7 +2582,7 @@ static uint16 gbksortorder(uint16 i) int my_strnncoll_gbk_internal(const uchar **a_res, const uchar **b_res, - uint length) + size_t length) { const uchar *a= *a_res, *b= *b_res; uint a_char,b_char; @@ -2612,22 +2612,22 @@ int my_strnncoll_gbk_internal(const uchar **a_res, const uchar **b_res, int my_strnncoll_gbk(CHARSET_INFO *cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool b_is_prefix) { - uint length= min(a_length, b_length); + size_t length= min(a_length, b_length); int res= my_strnncoll_gbk_internal(&a, &b, length); return res ? res : (int) ((b_is_prefix ? length : a_length) - b_length); } static int my_strnncollsp_gbk(CHARSET_INFO * cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool diff_if_only_endspace_difference) { - uint length= min(a_length, b_length); + size_t length= min(a_length, b_length); int res= my_strnncoll_gbk_internal(&a, &b, length); #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE @@ -2662,12 +2662,12 @@ static int my_strnncollsp_gbk(CHARSET_INFO * cs __attribute__((unused)), } -static int my_strnxfrm_gbk(CHARSET_INFO *cs __attribute__((unused)), - uchar * dest, uint len, - const uchar * src, uint srclen) +static size_t my_strnxfrm_gbk(CHARSET_INFO *cs __attribute__((unused)), + uchar *dest, size_t len, + const uchar *src, size_t srclen) { uint16 e; - uint dstlen= len; + size_t dstlen= len; len = srclen; while (len--) @@ -2708,15 +2708,16 @@ static int my_strnxfrm_gbk(CHARSET_INFO *cs __attribute__((unused)), #define max_sort_char ((uchar) 255) static my_bool my_like_range_gbk(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr,uint ptr_length, + const char *ptr,size_t ptr_length, pbool escape, pbool w_one, pbool w_many, - uint res_length, char *min_str,char *max_str, - uint *min_length,uint *max_length) + size_t res_length, + char *min_str,char *max_str, + size_t *min_length,size_t *max_length) { const char *end= ptr + ptr_length; char *min_org=min_str; char *min_end=min_str+res_length; - uint charlen= res_length / cs->mbmaxlen; + size_t charlen= res_length / cs->mbmaxlen; for (; ptr != end && min_str != min_end && charlen > 0; ptr++, charlen--) { @@ -2748,7 +2749,7 @@ static my_bool my_like_range_gbk(CHARSET_INFO *cs __attribute__((unused)), 'a\0\0... is the smallest possible string when we have space expand a\ff\ff... is the biggest possible string */ - *min_length= ((cs->state & MY_CS_BINSORT) ? (uint) (min_str - min_org) : + *min_length= ((cs->state & MY_CS_BINSORT) ? (size_t) (min_str - min_org) : res_length); *max_length= res_length; do { @@ -2760,20 +2761,20 @@ static my_bool my_like_range_gbk(CHARSET_INFO *cs __attribute__((unused)), *min_str++= *max_str++ = *ptr; } - *min_length= *max_length = (uint) (min_str - min_org); + *min_length= *max_length = (size_t) (min_str - min_org); while (min_str != min_end) *min_str++= *max_str++= ' '; /* Because if key compression */ return 0; } -static int ismbchar_gbk(CHARSET_INFO *cs __attribute__((unused)), +static uint ismbchar_gbk(CHARSET_INFO *cs __attribute__((unused)), const char* p, const char *e) { return (isgbkhead(*(p)) && (e)-(p)>1 && isgbktail(*((p)+1))? 2: 0); } -static int mbcharlen_gbk(CHARSET_INFO *cs __attribute__((unused)),uint c) +static uint mbcharlen_gbk(CHARSET_INFO *cs __attribute__((unused)),uint c) { return (isgbkhead(c)? 2 : 1); } @@ -9940,9 +9941,9 @@ my_mb_wc_gbk(CHARSET_INFO *cs __attribute__((unused)), Returns well formed length of a GBK string. */ static -uint my_well_formed_len_gbk(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e, - uint pos, int *error) +size_t my_well_formed_len_gbk(CHARSET_INFO *cs __attribute__((unused)), + const char *b, const char *e, + size_t pos, int *error) { const char *b0= b; const char *emb= e - 1; /* Last possible end of an MB character */ @@ -9967,7 +9968,7 @@ uint my_well_formed_len_gbk(CHARSET_INFO *cs __attribute__((unused)), break; } } - return (uint) (b - b0); + return (size_t) (b - b0); } diff --git a/strings/ctype-latin1.c b/strings/ctype-latin1.c index 30e0abb35d5..e5333c4101b 100644 --- a/strings/ctype-latin1.c +++ b/strings/ctype-latin1.c @@ -150,7 +150,7 @@ unsigned short cs_to_uni[256]={ 0x00F0,0x00F1,0x00F2,0x00F3,0x00F4,0x00F5,0x00F6,0x00F7, 0x00F8,0x00F9,0x00FA,0x00FB,0x00FC,0x00FD,0x00FE,0x00FF }; -unsigned char pl00[256]={ +uchar pl00[256]={ 0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07, 0x08,0x09,0x0A,0x0B,0x0C,0x0D,0x0E,0x0F, 0x10,0x11,0x12,0x13,0x14,0x15,0x16,0x17, @@ -184,7 +184,7 @@ unsigned char pl00[256]={ 0xF0,0xF1,0xF2,0xF3,0xF4,0xF5,0xF6,0xF7, 0xF8,0xF9,0xFA,0xFB,0xFC,0xFD,0xFE,0xFF }; -unsigned char pl01[256]={ +uchar pl01[256]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, @@ -218,7 +218,7 @@ unsigned char pl01[256]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; -unsigned char pl02[256]={ +uchar pl02[256]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, @@ -252,7 +252,7 @@ unsigned char pl02[256]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; -unsigned char pl20[256]={ +uchar pl20[256]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x96,0x97,0x00,0x00,0x00, @@ -286,7 +286,7 @@ unsigned char pl20[256]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; -unsigned char pl21[256]={ +uchar pl21[256]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, @@ -320,7 +320,7 @@ unsigned char pl21[256]={ 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00, 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00 }; -unsigned char *uni_to_cs[256]={ +uchar *uni_to_cs[256]={ pl00,pl01,pl02,NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, @@ -358,8 +358,8 @@ NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL static int my_mb_wc_latin1(CHARSET_INFO *cs __attribute__((unused)), my_wc_t *wc, - const unsigned char *str, - const unsigned char *end __attribute__((unused))) + const uchar *str, + const uchar *end __attribute__((unused))) { if (str >= end) return MY_CS_TOOSMALL; @@ -371,10 +371,10 @@ int my_mb_wc_latin1(CHARSET_INFO *cs __attribute__((unused)), static int my_wc_mb_latin1(CHARSET_INFO *cs __attribute__((unused)), my_wc_t wc, - unsigned char *str, - unsigned char *end __attribute__((unused))) + uchar *str, + uchar *end __attribute__((unused))) { - unsigned char *pl; + uchar *pl; if (str >= end) return MY_CS_TOOSMALL; @@ -543,8 +543,8 @@ uchar combo2map[]={ static int my_strnncoll_latin1_de(CHARSET_INFO *cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool b_is_prefix) { const uchar *a_end= a + a_length; @@ -584,8 +584,8 @@ static int my_strnncoll_latin1_de(CHARSET_INFO *cs __attribute__((unused)), static int my_strnncollsp_latin1_de(CHARSET_INFO *cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool diff_if_only_endspace_difference) { const uchar *a_end= a + a_length, *b_end= b + b_length; @@ -655,9 +655,9 @@ static int my_strnncollsp_latin1_de(CHARSET_INFO *cs __attribute__((unused)), } -static int my_strnxfrm_latin1_de(CHARSET_INFO *cs __attribute__((unused)), - uchar * dest, uint len, - const uchar * src, uint srclen) +static size_t my_strnxfrm_latin1_de(CHARSET_INFO *cs __attribute__((unused)), + uchar *dest, size_t len, + const uchar *src, size_t srclen) { const uchar *de = dest + len; const uchar *se = src + srclen; @@ -675,7 +675,7 @@ static int my_strnxfrm_latin1_de(CHARSET_INFO *cs __attribute__((unused)), void my_hash_sort_latin1_de(CHARSET_INFO *cs __attribute__((unused)), - const uchar *key, uint len, + const uchar *key, size_t len, ulong *nr1, ulong *nr2) { const uchar *end= key+len; diff --git a/strings/ctype-mb.c b/strings/ctype-mb.c index 4234ac091cd..bcdb23096f3 100644 --- a/strings/ctype-mb.c +++ b/strings/ctype-mb.c @@ -20,7 +20,7 @@ #ifdef USE_MB -uint my_caseup_str_mb(CHARSET_INFO * cs, char *str) +size_t my_caseup_str_mb(CHARSET_INFO * cs, char *str) { register uint32 l; register uchar *map= cs->to_upper; @@ -37,10 +37,11 @@ uint my_caseup_str_mb(CHARSET_INFO * cs, char *str) str++; } } - return str - str_orig; + return (size_t) (str - str_orig); } -uint my_casedn_str_mb(CHARSET_INFO * cs, char *str) + +size_t my_casedn_str_mb(CHARSET_INFO * cs, char *str) { register uint32 l; register uchar *map= cs->to_lower; @@ -57,12 +58,13 @@ uint my_casedn_str_mb(CHARSET_INFO * cs, char *str) str++; } } - return str - str_orig; + return (size_t) (str - str_orig); } -uint my_caseup_mb(CHARSET_INFO * cs, char *src, uint srclen, - char *dst __attribute__((unused)), - uint dstlen __attribute__((unused))) + +size_t my_caseup_mb(CHARSET_INFO * cs, char *src, size_t srclen, + char *dst __attribute__((unused)), + size_t dstlen __attribute__((unused))) { register uint32 l; register char *srcend= src + srclen; @@ -82,9 +84,10 @@ uint my_caseup_mb(CHARSET_INFO * cs, char *src, uint srclen, return srclen; } -uint my_casedn_mb(CHARSET_INFO * cs, char *src, uint srclen, - char *dst __attribute__((unused)), - uint dstlen __attribute__((unused))) + +size_t my_casedn_mb(CHARSET_INFO * cs, char *src, size_t srclen, + char *dst __attribute__((unused)), + size_t dstlen __attribute__((unused))) { register uint32 l; register char *srcend= src + srclen; @@ -104,9 +107,11 @@ uint my_casedn_mb(CHARSET_INFO * cs, char *src, uint srclen, return srclen; } + /* my_strcasecmp_mb() returns 0 if strings are equal, non-zero otherwise. */ + int my_strcasecmp_mb(CHARSET_INFO * cs,const char *s, const char *t) { register uint32 l; @@ -250,10 +255,10 @@ int my_wildcmp_mb(CHARSET_INFO *cs, } -uint my_numchars_mb(CHARSET_INFO *cs __attribute__((unused)), +size_t my_numchars_mb(CHARSET_INFO *cs __attribute__((unused)), const char *pos, const char *end) { - register uint32 count=0; + register size_t count= 0; while (pos < end) { uint mb_len; @@ -264,8 +269,8 @@ uint my_numchars_mb(CHARSET_INFO *cs __attribute__((unused)), } -uint my_charpos_mb(CHARSET_INFO *cs __attribute__((unused)), - const char *pos, const char *end, uint length) +size_t my_charpos_mb(CHARSET_INFO *cs __attribute__((unused)), + const char *pos, const char *end, size_t length) { const char *start= pos; @@ -275,12 +280,12 @@ uint my_charpos_mb(CHARSET_INFO *cs __attribute__((unused)), pos+= (mb_len= my_ismbchar(cs, pos, end)) ? mb_len : 1; length--; } - return (uint) (length ? end+2-start : pos-start); + return (size_t) (length ? end+2-start : pos-start); } -uint my_well_formed_len_mb(CHARSET_INFO *cs, const char *b, const char *e, - uint pos, int *error) +size_t my_well_formed_len_mb(CHARSET_INFO *cs, const char *b, const char *e, + size_t pos, int *error) { const char *b_start= b; *error= 0; @@ -297,14 +302,13 @@ uint my_well_formed_len_mb(CHARSET_INFO *cs, const char *b, const char *e, b+= mb_len; pos--; } - return (uint) (b - b_start); + return (size_t) (b - b_start); } - uint my_instr_mb(CHARSET_INFO *cs, - const char *b, uint b_length, - const char *s, uint s_length, + const char *b, size_t b_length, + const char *s, size_t s_length, my_match_t *match, uint nmatch) { register const char *end, *b0; @@ -330,13 +334,13 @@ uint my_instr_mb(CHARSET_INFO *cs, { int mb_len; - if (!cs->coll->strnncoll(cs, (unsigned char*) b, s_length, - (unsigned char*) s, s_length, 0)) + if (!cs->coll->strnncoll(cs, (uchar*) b, s_length, + (uchar*) s, s_length, 0)) { if (nmatch) { match[0].beg= 0; - match[0].end= (uint) (b-b0); + match[0].end= (size_t) (b-b0); match[0].mb_len= res; if (nmatch > 1) { @@ -360,11 +364,11 @@ uint my_instr_mb(CHARSET_INFO *cs, /* BINARY collations handlers for MB charsets */ static int my_strnncoll_mb_bin(CHARSET_INFO * cs __attribute__((unused)), - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { - uint len=min(slen,tlen); + size_t len=min(slen,tlen); int cmp= memcmp(s,t,len); return cmp ? cmp : (int) ((t_is_prefix ? len : slen) - tlen); } @@ -396,12 +400,12 @@ static int my_strnncoll_mb_bin(CHARSET_INFO * cs __attribute__((unused)), */ static int my_strnncollsp_mb_bin(CHARSET_INFO * cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool diff_if_only_endspace_difference) { const uchar *end; - uint length; + size_t length; int res; #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE @@ -442,9 +446,9 @@ static int my_strnncollsp_mb_bin(CHARSET_INFO * cs __attribute__((unused)), } -static int my_strnxfrm_mb_bin(CHARSET_INFO *cs __attribute__((unused)), - uchar * dest, uint dstlen, - const uchar *src, uint srclen) +static size_t my_strnxfrm_mb_bin(CHARSET_INFO *cs __attribute__((unused)), + uchar *dest, size_t dstlen, + const uchar *src, size_t srclen) { if (dest != src) memcpy(dest, src, min(dstlen, srclen)); @@ -461,7 +465,7 @@ static int my_strcasecmp_mb_bin(CHARSET_INFO * cs __attribute__((unused)), } static void my_hash_sort_mb_bin(CHARSET_INFO *cs __attribute__((unused)), - const uchar *key, uint len,ulong *nr1, ulong *nr2) + const uchar *key, size_t len,ulong *nr1, ulong *nr2) { const uchar *pos = key; @@ -544,18 +548,18 @@ static void pad_max_char(CHARSET_INFO *cs, char *str, char *end) */ my_bool my_like_range_mb(CHARSET_INFO *cs, - const char *ptr,uint ptr_length, + const char *ptr,size_t ptr_length, pbool escape, pbool w_one, pbool w_many, - uint res_length, + size_t res_length, char *min_str,char *max_str, - uint *min_length,uint *max_length) + size_t *min_length,size_t *max_length) { uint mb_len; const char *end= ptr + ptr_length; char *min_org= min_str; char *min_end= min_str + res_length; char *max_end= max_str + res_length; - uint maxcharlen= res_length / cs->mbmaxlen; + size_t maxcharlen= res_length / cs->mbmaxlen; for (; ptr != end && min_str != min_end && maxcharlen ; maxcharlen--) { @@ -569,7 +573,7 @@ my_bool my_like_range_mb(CHARSET_INFO *cs, 'a\0\0... is the smallest possible string when we have space expand a\ff\ff... is the biggest possible string */ - *min_length= ((cs->state & MY_CS_BINSORT) ? (uint) (min_str - min_org) : + *min_length= ((cs->state & MY_CS_BINSORT) ? (size_t) (min_str - min_org) : res_length); *max_length= res_length; /* Create min key */ @@ -599,7 +603,7 @@ my_bool my_like_range_mb(CHARSET_INFO *cs, } - *min_length= *max_length = (uint) (min_str - min_org); + *min_length= *max_length = (size_t) (min_str - min_org); while (min_str != min_end) *min_str++= *max_str++= ' '; /* Because if key compression */ return 0; @@ -919,10 +923,11 @@ static struct {int page; char *p;} utr11_data[256]= {0,NULL},{1,NULL},{0,pgFA},{0,NULL},{0,NULL},{0,NULL},{0,pgFE},{0,pgFF} }; -uint my_numcells_mb(CHARSET_INFO *cs, const char *b, const char *e) + +size_t my_numcells_mb(CHARSET_INFO *cs, const char *b, const char *e) { my_wc_t wc; - int clen= 0; + size_t clen= 0; while (b < e) { @@ -944,7 +949,7 @@ uint my_numcells_mb(CHARSET_INFO *cs, const char *b, const char *e) int my_mb_ctype_mb(CHARSET_INFO *cs, int *ctype, - const unsigned char *s, const unsigned char *e) + const uchar *s, const uchar *e) { my_wc_t wc; int res= cs->cset->mb_wc(cs, &wc, s, e); @@ -958,7 +963,6 @@ int my_mb_ctype_mb(CHARSET_INFO *cs, int *ctype, } - MY_COLLATION_HANDLER my_collation_mb_bin_handler = { NULL, /* init */ diff --git a/strings/ctype-simple.c b/strings/ctype-simple.c index c129f117744..99e41611eaa 100644 --- a/strings/ctype-simple.c +++ b/strings/ctype-simple.c @@ -24,7 +24,8 @@ /* Returns the number of bytes required for strnxfrm(). */ -uint my_strnxfrmlen_simple(CHARSET_INFO *cs, uint len) + +size_t my_strnxfrmlen_simple(CHARSET_INFO *cs, size_t len) { return len * (cs->strxfrm_multiply ? cs->strxfrm_multiply : 1); } @@ -70,12 +71,12 @@ uint my_strnxfrmlen_simple(CHARSET_INFO *cs, uint len) */ -int my_strnxfrm_simple(CHARSET_INFO * cs, - uchar *dest, uint len, - const uchar *src, uint srclen) +size_t my_strnxfrm_simple(CHARSET_INFO * cs, + uchar *dest, size_t len, + const uchar *src, size_t srclen) { uchar *map= cs->sort_order; - uint dstlen= len; + size_t dstlen= len; set_if_smaller(len, srclen); if (dest != src) { @@ -94,11 +95,12 @@ int my_strnxfrm_simple(CHARSET_INFO * cs, return dstlen; } -int my_strnncoll_simple(CHARSET_INFO * cs, const uchar *s, uint slen, - const uchar *t, uint tlen, + +int my_strnncoll_simple(CHARSET_INFO * cs, const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { - int len = ( slen > tlen ) ? tlen : slen; + size_t len = ( slen > tlen ) ? tlen : slen; uchar *map= cs->sort_order; if (t_is_prefix && slen > tlen) slen=tlen; @@ -107,7 +109,11 @@ int my_strnncoll_simple(CHARSET_INFO * cs, const uchar *s, uint slen, if (map[*s++] != map[*t++]) return ((int) map[s[-1]] - (int) map[t[-1]]); } - return (int) (slen - tlen); + /* + We can't use (slen - tlen) here as the result may be outside of the + precision of a signed int + */ + return slen > tlen ? 1 : slen < tlen ? -1 : 0 ; } @@ -141,12 +147,12 @@ int my_strnncoll_simple(CHARSET_INFO * cs, const uchar *s, uint slen, > 0 a > b */ -int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *a, uint a_length, - const uchar *b, uint b_length, +int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool diff_if_only_endspace_difference) { const uchar *map= cs->sort_order, *end; - uint length; + size_t length; int res; #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE @@ -187,48 +193,49 @@ int my_strnncollsp_simple(CHARSET_INFO * cs, const uchar *a, uint a_length, } -uint my_caseup_str_8bit(CHARSET_INFO * cs,char *str) +size_t my_caseup_str_8bit(CHARSET_INFO * cs,char *str) { register uchar *map= cs->to_upper; char *str_orig= str; while ((*str= (char) map[(uchar) *str]) != 0) str++; - return str - str_orig; + return (size_t) (str - str_orig); } -uint my_casedn_str_8bit(CHARSET_INFO * cs,char *str) +size_t my_casedn_str_8bit(CHARSET_INFO * cs,char *str) { register uchar *map= cs->to_lower; char *str_orig= str; while ((*str= (char) map[(uchar) *str]) != 0) str++; - return str - str_orig; + return (size_t) (str - str_orig); } -uint my_caseup_8bit(CHARSET_INFO * cs, char *src, uint srclen, - char *dst __attribute__((unused)), - uint dstlen __attribute__((unused))) +size_t my_caseup_8bit(CHARSET_INFO * cs, char *src, size_t srclen, + char *dst __attribute__((unused)), + size_t dstlen __attribute__((unused))) { - uint srclen0= srclen; + char *end= src + srclen; register uchar *map= cs->to_upper; DBUG_ASSERT(src == dst && srclen == dstlen); - for ( ; srclen > 0 ; srclen--, src++) + for ( ; src != end ; src++) *src= (char) map[(uchar) *src]; - return srclen0; + return srclen; } -uint my_casedn_8bit(CHARSET_INFO * cs, char *src, uint srclen, - char *dst __attribute__((unused)), - uint dstlen __attribute__((unused))) + +size_t my_casedn_8bit(CHARSET_INFO * cs, char *src, size_t srclen, + char *dst __attribute__((unused)), + size_t dstlen __attribute__((unused))) { - uint srclen0= srclen; + char *end= src + srclen; register uchar *map=cs->to_lower; DBUG_ASSERT(src == dst && srclen == dstlen); - for ( ; srclen > 0 ; srclen--, src++) + for ( ; src != end ; src++) *src= (char) map[(uchar) *src]; - return srclen0; + return srclen; } int my_strcasecmp_8bit(CHARSET_INFO * cs,const char *s, const char *t) @@ -241,8 +248,8 @@ int my_strcasecmp_8bit(CHARSET_INFO * cs,const char *s, const char *t) int my_mb_wc_8bit(CHARSET_INFO *cs,my_wc_t *wc, - const unsigned char *str, - const unsigned char *end __attribute__((unused))) + const uchar *str, + const uchar *end __attribute__((unused))) { if (str >= end) return MY_CS_TOOSMALL; @@ -252,8 +259,8 @@ int my_mb_wc_8bit(CHARSET_INFO *cs,my_wc_t *wc, } int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc, - unsigned char *str, - unsigned char *end __attribute__((unused))) + uchar *str, + uchar *end) { MY_UNI_IDX *idx; @@ -279,8 +286,8 @@ int my_wc_mb_8bit(CHARSET_INFO *cs,my_wc_t wc, end buffer must be checked. */ -int my_snprintf_8bit(CHARSET_INFO *cs __attribute__((unused)), - char* to, uint n __attribute__((unused)), +size_t my_snprintf_8bit(CHARSET_INFO *cs __attribute__((unused)), + char* to, size_t n __attribute__((unused)), const char* fmt, ...) { va_list args; @@ -293,7 +300,7 @@ int my_snprintf_8bit(CHARSET_INFO *cs __attribute__((unused)), void my_hash_sort_simple(CHARSET_INFO *cs, - const uchar *key, uint len, + const uchar *key, size_t len, ulong *nr1, ulong *nr2) { register uchar *sort_order=cs->sort_order; @@ -316,15 +323,15 @@ void my_hash_sort_simple(CHARSET_INFO *cs, long my_strntol_8bit(CHARSET_INFO *cs, - const char *nptr, uint l, int base, + const char *nptr, size_t l, int base, char **endptr, int *err) { int negative; register uint32 cutoff; - register unsigned int cutlim; + register uint cutlim; register uint32 i; register const char *s; - register unsigned char c; + register uchar c; const char *save, *e; int overflow; @@ -439,15 +446,15 @@ noconv: ulong my_strntoul_8bit(CHARSET_INFO *cs, - const char *nptr, uint l, int base, + const char *nptr, size_t l, int base, char **endptr, int *err) { int negative; register uint32 cutoff; - register unsigned int cutlim; + register uint cutlim; register uint32 i; register const char *s; - register unsigned char c; + register uchar c; const char *save, *e; int overflow; @@ -553,12 +560,12 @@ noconv: longlong my_strntoll_8bit(CHARSET_INFO *cs __attribute__((unused)), - const char *nptr, uint l, int base, + const char *nptr, size_t l, int base, char **endptr,int *err) { int negative; register ulonglong cutoff; - register unsigned int cutlim; + register uint cutlim; register ulonglong i; register const char *s, *e; const char *save; @@ -625,7 +632,7 @@ longlong my_strntoll_8bit(CHARSET_INFO *cs __attribute__((unused)), i = 0; for ( ; s != e; s++) { - register unsigned char c= *s; + register uchar c= *s; if (c>='0' && c<='9') c -= '0'; else if (c>='A' && c<='Z') @@ -676,12 +683,12 @@ noconv: ulonglong my_strntoull_8bit(CHARSET_INFO *cs, - const char *nptr, uint l, int base, + const char *nptr, size_t l, int base, char **endptr, int *err) { int negative; register ulonglong cutoff; - register unsigned int cutlim; + register uint cutlim; register ulonglong i; register const char *s, *e; const char *save; @@ -748,7 +755,7 @@ ulonglong my_strntoull_8bit(CHARSET_INFO *cs, i = 0; for ( ; s != e; s++) { - register unsigned char c= *s; + register uchar c= *s; if (c>='0' && c<='9') c -= '0'; @@ -790,6 +797,7 @@ noconv: return 0L; } + /* Read double from string @@ -814,7 +822,7 @@ noconv: double my_strntod_8bit(CHARSET_INFO *cs __attribute__((unused)), - char *str, uint length, + char *str, size_t length, char **end, int *err) { if (length == INT_MAX32) @@ -830,8 +838,8 @@ double my_strntod_8bit(CHARSET_INFO *cs __attribute__((unused)), Assume len >= 1 */ -int my_long10_to_str_8bit(CHARSET_INFO *cs __attribute__((unused)), - char *dst, uint len, int radix, long int val) +size_t my_long10_to_str_8bit(CHARSET_INFO *cs __attribute__((unused)), + char *dst, size_t len, int radix, long int val) { char buffer[66]; register char *p, *e; @@ -863,14 +871,15 @@ int my_long10_to_str_8bit(CHARSET_INFO *cs __attribute__((unused)), val= new_val; } - len= min(len, (uint) (e-p)); + len= min(len, (size_t) (e-p)); memcpy(dst, p, len); - return (int) len+sign; + return len+sign; } -int my_longlong10_to_str_8bit(CHARSET_INFO *cs __attribute__((unused)), - char *dst, uint len, int radix, longlong val) +size_t my_longlong10_to_str_8bit(CHARSET_INFO *cs __attribute__((unused)), + char *dst, size_t len, int radix, + longlong val) { char buffer[65]; register char *p, *e; @@ -914,7 +923,7 @@ int my_longlong10_to_str_8bit(CHARSET_INFO *cs __attribute__((unused)), long_val= quo; } - len= min(len, (uint) (e-p)); + len= min(len, (size_t) (e-p)); cnv: memcpy(dst, p, len); return len+sign; @@ -1034,16 +1043,16 @@ int my_wildcmp_8bit(CHARSET_INFO *cs, */ my_bool my_like_range_simple(CHARSET_INFO *cs, - const char *ptr,uint ptr_length, + const char *ptr, size_t ptr_length, pbool escape, pbool w_one, pbool w_many, - uint res_length, + size_t res_length, char *min_str,char *max_str, - uint *min_length,uint *max_length) + size_t *min_length, size_t *max_length) { const char *end= ptr + ptr_length; char *min_org=min_str; char *min_end=min_str+res_length; - uint charlen= res_length / cs->mbmaxlen; + size_t charlen= res_length / cs->mbmaxlen; for (; ptr != end && min_str != min_end && charlen > 0 ; ptr++, charlen--) { @@ -1062,7 +1071,8 @@ my_bool my_like_range_simple(CHARSET_INFO *cs, if (*ptr == w_many) /* '%' in SQL */ { /* Calculate length of keys */ - *min_length= ((cs->state & MY_CS_BINSORT) ? (uint) (min_str - min_org) : + *min_length= ((cs->state & MY_CS_BINSORT) ? + (size_t) (min_str - min_org) : res_length); *max_length= res_length; do @@ -1075,14 +1085,14 @@ my_bool my_like_range_simple(CHARSET_INFO *cs, *min_str++= *max_str++ = *ptr; } - *min_length= *max_length = (uint) (min_str - min_org); + *min_length= *max_length = (size_t) (min_str - min_org); while (min_str != min_end) *min_str++= *max_str++ = ' '; /* Because if key compression */ return 0; } -ulong my_scan_8bit(CHARSET_INFO *cs, const char *str, const char *end, int sq) +size_t my_scan_8bit(CHARSET_INFO *cs, const char *str, const char *end, int sq) { const char *str0= str; switch (sq) @@ -1091,7 +1101,7 @@ ulong my_scan_8bit(CHARSET_INFO *cs, const char *str, const char *end, int sq) if (*str == '.') { for(str++ ; str != end && *str == '0' ; str++); - return (ulong) (str - str0); + return (size_t) (str - str0); } return 0; @@ -1101,7 +1111,7 @@ ulong my_scan_8bit(CHARSET_INFO *cs, const char *str, const char *end, int sq) if (!my_isspace(cs,*str)) break; } - return (ulong) (str - str0); + return (size_t) (str - str0); default: return 0; } @@ -1109,59 +1119,59 @@ ulong my_scan_8bit(CHARSET_INFO *cs, const char *str, const char *end, int sq) void my_fill_8bit(CHARSET_INFO *cs __attribute__((unused)), - char *s, uint l, int fill) + char *s, size_t l, int fill) { - bfill(s,l,fill); + bfill((uchar*) s,l,fill); } -uint my_numchars_8bit(CHARSET_INFO *cs __attribute__((unused)), +size_t my_numchars_8bit(CHARSET_INFO *cs __attribute__((unused)), const char *b, const char *e) { - return (uint) (e - b); + return (size_t) (e - b); } -uint my_numcells_8bit(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e) +size_t my_numcells_8bit(CHARSET_INFO *cs __attribute__((unused)), + const char *b, const char *e) { - return (uint) (e - b); + return (size_t) (e - b); } -uint my_charpos_8bit(CHARSET_INFO *cs __attribute__((unused)), - const char *b __attribute__((unused)), - const char *e __attribute__((unused)), - uint pos) +size_t my_charpos_8bit(CHARSET_INFO *cs __attribute__((unused)), + const char *b __attribute__((unused)), + const char *e __attribute__((unused)), + size_t pos) { return pos; } -uint my_well_formed_len_8bit(CHARSET_INFO *cs __attribute__((unused)), - const char *start, const char *end, - uint nchars, int *error) +size_t my_well_formed_len_8bit(CHARSET_INFO *cs __attribute__((unused)), + const char *start, const char *end, + size_t nchars, int *error) { - uint nbytes= (uint) (end-start); + size_t nbytes= (size_t) (end-start); *error= 0; return min(nbytes, nchars); } -uint my_lengthsp_8bit(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr, uint length) +size_t my_lengthsp_8bit(CHARSET_INFO *cs __attribute__((unused)), + const char *ptr, size_t length) { const char *end= ptr+length; while (end > ptr && end[-1] == ' ') end--; - return (uint) (end-ptr); + return (size_t) (end-ptr); } uint my_instr_simple(CHARSET_INFO *cs, - const char *b, uint b_length, - const char *s, uint s_length, - my_match_t *match, uint nmatch) + const char *b, size_t b_length, + const char *s, size_t s_length, + my_match_t *match, uint nmatch) { register const uchar *str, *search, *end, *search_end; @@ -1200,7 +1210,7 @@ skip: if (nmatch > 0) { match[0].beg= 0; - match[0].end= (uint) (str- (const uchar*)b-1); + match[0].end= (size_t) (str- (const uchar*)b-1); match[0].mb_len= match[0].end; if (nmatch > 1) @@ -1239,7 +1249,7 @@ static int pcmp(const void * f, const void * s) return res; } -static my_bool create_fromuni(CHARSET_INFO *cs, void *(*alloc)(uint)) +static my_bool create_fromuni(CHARSET_INFO *cs, void *(*alloc)(size_t)) { uni_idx idx[PLANE_NUM]; int i,n; @@ -1318,7 +1328,7 @@ static my_bool create_fromuni(CHARSET_INFO *cs, void *(*alloc)(uint)) return FALSE; } -static my_bool my_cset_init_8bit(CHARSET_INFO *cs, void *(*alloc)(uint)) +static my_bool my_cset_init_8bit(CHARSET_INFO *cs, void *(*alloc)(size_t)) { cs->caseup_multiply= 1; cs->casedn_multiply= 1; @@ -1346,7 +1356,7 @@ static void set_max_sort_char(CHARSET_INFO *cs) } static my_bool my_coll_init_simple(CHARSET_INFO *cs, - void *(*alloc)(uint) __attribute__((unused))) + void *(*alloc)(size_t) __attribute__((unused))) { set_max_sort_char(cs); return FALSE; @@ -1361,7 +1371,7 @@ longlong my_strtoll10_8bit(CHARSET_INFO *cs __attribute__((unused)), int my_mb_ctype_8bit(CHARSET_INFO *cs, int *ctype, - const unsigned char *s, const unsigned char *e) + const uchar *s, const uchar *e) { if (s >= e) { @@ -1473,13 +1483,13 @@ static ulonglong d10[DIGITS_IN_ULONGLONG]= ulonglong my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)), - const char *str, uint length, int unsigned_flag, + const char *str, size_t length, int unsigned_flag, char **endptr, int *error) { const char *dot, *end9, *beg, *end= str + length; ulonglong ull; ulong ul; - unsigned char ch; + uchar ch; int shift= 0, digits= 0, negative, addon; /* Skip leading spaces and tabs */ @@ -1497,7 +1507,7 @@ my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)), beg= str; end9= (str + 9) > end ? end : (str + 9); /* Accumulate small number into ulong, for performance purposes */ - for (ul= 0 ; str < end9 && (ch= (unsigned char) (*str - '0')) < 10; str++) + for (ul= 0 ; str < end9 && (ch= (uchar) (*str - '0')) < 10; str++) { ul= ul * 10 + ch; } @@ -1530,7 +1540,7 @@ my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)), /* Continue to accumulate into ulonglong */ for (dot= NULL, ull= ul; str < end; str++) { - if ((ch= (unsigned char) (*str - '0')) < 10) + if ((ch= (uchar) (*str - '0')) < 10) { if (ull < CUTOFF || (ull == CUTOFF && ch <= CUTLIM)) { @@ -1551,7 +1561,7 @@ my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)), } else addon= (*str >= '5'); - for ( ; str < end && (ch= (unsigned char) (*str - '0')) < 10; str++) + for ( ; str < end && (ch= (uchar) (*str - '0')) < 10; str++) { if (!dot) shift++; @@ -1559,7 +1569,7 @@ my_strntoull10rnd_8bit(CHARSET_INFO *cs __attribute__((unused)), if (str < end && *str == '.' && !dot) { str++; - for ( ; str < end && (ch= (unsigned char) (*str - '0')) < 10; str++); + for ( ; str < end && (ch= (uchar) (*str - '0')) < 10; str++); } goto exp; } @@ -1605,7 +1615,7 @@ exp: /* [ E [ <sign> ] <unsigned integer> ] */ goto ret_sign; } for (exponent= 0 ; - str < end && (ch= (unsigned char) (*str - '0')) < 10; + str < end && (ch= (uchar) (*str - '0')) < 10; str++) { exponent= exponent * 10 + ch; @@ -1748,7 +1758,7 @@ ret_too_big: my_bool my_propagate_simple(CHARSET_INFO *cs __attribute__((unused)), const uchar *str __attribute__((unused)), - uint length __attribute__((unused))) + size_t length __attribute__((unused))) { return 1; } @@ -1756,7 +1766,7 @@ my_bool my_propagate_simple(CHARSET_INFO *cs __attribute__((unused)), my_bool my_propagate_complex(CHARSET_INFO *cs __attribute__((unused)), const uchar *str __attribute__((unused)), - uint length __attribute__((unused))) + size_t length __attribute__((unused))) { return 0; } diff --git a/strings/ctype-sjis.c b/strings/ctype-sjis.c index 8f7158cc9c9..dfa8819a4db 100644 --- a/strings/ctype-sjis.c +++ b/strings/ctype-sjis.c @@ -182,13 +182,13 @@ static uchar NEAR sort_order_sjis[]= (0x80<=(c) && (c)<=0xfc)) -static int ismbchar_sjis(CHARSET_INFO *cs __attribute__((unused)), +static uint ismbchar_sjis(CHARSET_INFO *cs __attribute__((unused)), const char* p, const char *e) { return (issjishead((uchar) *p) && (e-p)>1 && issjistail((uchar)p[1]) ? 2: 0); } -static int mbcharlen_sjis(CHARSET_INFO *cs __attribute__((unused)),uint c) +static uint mbcharlen_sjis(CHARSET_INFO *cs __attribute__((unused)),uint c) { return (issjishead((uchar) c) ? 2 : 1); } @@ -198,8 +198,8 @@ static int mbcharlen_sjis(CHARSET_INFO *cs __attribute__((unused)),uint c) static int my_strnncoll_sjis_internal(CHARSET_INFO *cs, - const uchar **a_res, uint a_length, - const uchar **b_res, uint b_length) + const uchar **a_res, size_t a_length, + const uchar **b_res, size_t b_length) { const uchar *a= *a_res, *b= *b_res; const uchar *a_end= a + a_length; @@ -230,9 +230,9 @@ static int my_strnncoll_sjis_internal(CHARSET_INFO *cs, static int my_strnncoll_sjis(CHARSET_INFO *cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, - my_bool b_is_prefix) + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, + my_bool b_is_prefix) { int res= my_strnncoll_sjis_internal(cs, &a, a_length, &b, b_length); if (b_is_prefix && a_length > b_length) @@ -242,8 +242,8 @@ static int my_strnncoll_sjis(CHARSET_INFO *cs __attribute__((unused)), static int my_strnncollsp_sjis(CHARSET_INFO *cs __attribute__((unused)), - const uchar *a, uint a_length, - const uchar *b, uint b_length, + const uchar *a, size_t a_length, + const uchar *b, size_t b_length, my_bool diff_if_only_endspace_difference) { const uchar *a_end= a + a_length, *b_end= b + b_length; @@ -281,9 +281,9 @@ static int my_strnncollsp_sjis(CHARSET_INFO *cs __attribute__((unused)), -static int my_strnxfrm_sjis(CHARSET_INFO *cs __attribute__((unused)), - uchar *dest, uint len, - const uchar *src, uint srclen) +static size_t my_strnxfrm_sjis(CHARSET_INFO *cs __attribute__((unused)), + uchar *dest, size_t len, + const uchar *src, size_t srclen) { uchar *d_end = dest + len; uchar *s_end = (uchar*) src + srclen; @@ -324,15 +324,16 @@ static int my_strnxfrm_sjis(CHARSET_INFO *cs __attribute__((unused)), #define max_sort_char ((char) 255) static my_bool my_like_range_sjis(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr,uint ptr_length, + const char *ptr,size_t ptr_length, pbool escape, pbool w_one, pbool w_many, - uint res_length, char *min_str,char *max_str, - uint *min_length,uint *max_length) + size_t res_length, + char *min_str,char *max_str, + size_t *min_length,size_t *max_length) { const char *end= ptr + ptr_length; char *min_org=min_str; char *min_end=min_str+res_length; - uint charlen= res_length / cs->mbmaxlen; + size_t charlen= res_length / cs->mbmaxlen; for ( ; ptr < end && min_str < min_end && charlen > 0 ; charlen--) { @@ -363,7 +364,7 @@ static my_bool my_like_range_sjis(CHARSET_INFO *cs __attribute__((unused)), 'a\0\0... is the smallest possible string when we have space expand a\ff\ff... is the biggest possible string */ - *min_length= ((cs->state & MY_CS_BINSORT) ? (uint) (min_str - min_org) : + *min_length= ((cs->state & MY_CS_BINSORT) ? (size_t) (min_str - min_org) : res_length); *max_length= res_length; do @@ -376,7 +377,7 @@ static my_bool my_like_range_sjis(CHARSET_INFO *cs __attribute__((unused)), *min_str++ = *max_str++ = *ptr++; } - *min_length= *max_length= (uint) (min_str - min_org); + *min_length= *max_length= (size_t) (min_str - min_org); while (min_str != min_end) *min_str++= *max_str++= ' '; /* Because if key compression */ return 0; @@ -4553,12 +4554,12 @@ my_mb_wc_sjis(CHARSET_INFO *cs __attribute__((unused)), } static -uint my_numcells_sjis(CHARSET_INFO *cs __attribute__((unused)), +size_t my_numcells_sjis(CHARSET_INFO *cs __attribute__((unused)), const char *str, const char *str_end) { - uint clen= 0; - const unsigned char *b= (const unsigned char *) str; - const unsigned char *e= (const unsigned char *) str_end; + size_t clen; + const uchar *b= (const uchar *) str; + const uchar *e= (const uchar *) str_end; for (clen= 0; b < e; ) { @@ -4586,9 +4587,9 @@ uint my_numcells_sjis(CHARSET_INFO *cs __attribute__((unused)), CP932 additional characters are also accepted. */ static -uint my_well_formed_len_sjis(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e, - uint pos, int *error) +size_t my_well_formed_len_sjis(CHARSET_INFO *cs __attribute__((unused)), + const char *b, const char *e, + size_t pos, int *error) { const char *b0= b; *error= 0; @@ -4616,7 +4617,7 @@ uint my_well_formed_len_sjis(CHARSET_INFO *cs __attribute__((unused)), break; } } - return (uint) (b - b0); + return (size_t) (b - b0); } diff --git a/strings/ctype-tis620.c b/strings/ctype-tis620.c index 4babe9917dc..a8c05dc4fd0 100644 --- a/strings/ctype-tis620.c +++ b/strings/ctype-tis620.c @@ -462,7 +462,7 @@ static uchar NEAR sort_order_tis620[]= len Length of tstr */ -static uint thai2sortable(uchar *tstr, uint len) +static size_t thai2sortable(uchar *tstr, size_t len) { uchar *p; int tlen; @@ -527,8 +527,8 @@ static uint thai2sortable(uchar *tstr, uint len) static int my_strnncoll_tis620(CHARSET_INFO *cs __attribute__((unused)), - const uchar * s1, uint len1, - const uchar * s2, uint len2, + const uchar *s1, size_t len1, + const uchar *s2, size_t len2, my_bool s2_is_prefix) { uchar buf[80] ; @@ -557,12 +557,12 @@ int my_strnncoll_tis620(CHARSET_INFO *cs __attribute__((unused)), static int my_strnncollsp_tis620(CHARSET_INFO * cs __attribute__((unused)), - const uchar *a0, uint a_length, - const uchar *b0, uint b_length, + const uchar *a0, size_t a_length, + const uchar *b0, size_t b_length, my_bool diff_if_only_endspace_difference) { uchar buf[80], *end, *a, *b, *alloced= NULL; - uint length; + size_t length; int res= 0; #ifndef VARCHAR_WITH_DIFF_ENDSPACE_ARE_DIFFERENT_FOR_UNIQUE @@ -633,13 +633,13 @@ ret: */ static -int my_strnxfrm_tis620(CHARSET_INFO *cs __attribute__((unused)), - uchar * dest, uint len, - const uchar * src, uint srclen) +size_t my_strnxfrm_tis620(CHARSET_INFO *cs __attribute__((unused)), + uchar *dest, size_t len, + const uchar *src, size_t srclen) { - uint dstlen= len; - len= (uint) (strmake((char*) dest, (char*) src, min(len, srclen)) - - (char*) dest); + size_t dstlen= len; + len= (size_t) (strmake((char*) dest, (char*) src, min(len, srclen)) - + (char*) dest); len= thai2sortable(dest, len); if (dstlen > len) bfill(dest + len, dstlen - len, ' '); @@ -681,7 +681,7 @@ static unsigned short cs_to_uni[256]={ 0x0E50,0x0E51,0x0E52,0x0E53,0x0E54,0x0E55,0x0E56,0x0E57, 0x0E58,0x0E59,0x0E5A,0x0E5B,0xFFFD,0xFFFD,0xFFFD,0xFFFD }; -static unsigned char pl00[256]={ +static uchar pl00[256]={ 0x0000,0x0001,0x0002,0x0003,0x0004,0x0005,0x0006,0x0007, 0x0008,0x0009,0x000A,0x000B,0x000C,0x000D,0x000E,0x000F, 0x0010,0x0011,0x0012,0x0013,0x0014,0x0015,0x0016,0x0017, @@ -715,7 +715,7 @@ static unsigned char pl00[256]={ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 }; -static unsigned char pl0E[256]={ +static uchar pl0E[256]={ 0x0000,0x00A1,0x00A2,0x00A3,0x00A4,0x00A5,0x00A6,0x00A7, 0x00A8,0x00A9,0x00AA,0x00AB,0x00AC,0x00AD,0x00AE,0x00AF, 0x00B0,0x00B1,0x00B2,0x00B3,0x00B4,0x00B5,0x00B6,0x00B7, @@ -749,7 +749,7 @@ static unsigned char pl0E[256]={ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000 }; -static unsigned char plFF[256]={ +static uchar plFF[256]={ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, @@ -783,7 +783,7 @@ static unsigned char plFF[256]={ 0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000, 0x0000,0x0000,0x0000,0x0000,0x0000,0x00FF,0x0000,0x0000 }; -static unsigned char *uni_to_cs[256]={ +static uchar *uni_to_cs[256]={ pl00,NULL,NULL,NULL,NULL,NULL,NULL,NULL, NULL,NULL,NULL,NULL,NULL,NULL,pl0E,NULL, NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL, @@ -822,8 +822,8 @@ NULL,NULL,NULL,NULL,NULL,NULL,NULL,plFF static int my_mb_wc_tis620(CHARSET_INFO *cs __attribute__((unused)), my_wc_t *wc, - const unsigned char *str, - const unsigned char *end __attribute__((unused))) + const uchar *str, + const uchar *end __attribute__((unused))) { if (str >= end) return MY_CS_TOOSMALL; @@ -835,10 +835,10 @@ int my_mb_wc_tis620(CHARSET_INFO *cs __attribute__((unused)), static int my_wc_mb_tis620(CHARSET_INFO *cs __attribute__((unused)), my_wc_t wc, - unsigned char *str, - unsigned char *end __attribute__((unused))) + uchar *str, + uchar *end __attribute__((unused))) { - unsigned char *pl; + uchar *pl; if (str >= end) return MY_CS_TOOSMALL; diff --git a/strings/ctype-uca.c b/strings/ctype-uca.c index 1263882846d..ea0d5a1436a 100644 --- a/strings/ctype-uca.c +++ b/strings/ctype-uca.c @@ -6740,7 +6740,7 @@ typedef struct my_uca_scanner_st typedef struct my_uca_scanner_handler_st { void (*init)(my_uca_scanner *scanner, CHARSET_INFO *cs, - const uchar *str, uint length); + const uchar *str, size_t length); int (*next)(my_uca_scanner *scanner); } my_uca_scanner_handler; @@ -6767,7 +6767,7 @@ static uint16 nochar[]= {0,0}; static void my_uca_scanner_init_ucs2(my_uca_scanner *scanner, CHARSET_INFO *cs __attribute__((unused)), - const uchar *str, uint length) + const uchar *str, size_t length) { scanner->wbeg= nochar; if (length) @@ -6859,8 +6859,8 @@ static int my_uca_scanner_next_ucs2(my_uca_scanner *scanner) if (scanner->sbeg > scanner->send) return -1; - scanner->page= (unsigned char)scanner->sbeg[0]; - scanner->code= (unsigned char)scanner->sbeg[1]; + scanner->page= (uchar)scanner->sbeg[0]; + scanner->code= (uchar)scanner->sbeg[1]; scanner->sbeg+= 2; if (scanner->contractions && (scanner->sbeg <= scanner->send)) @@ -6919,7 +6919,7 @@ static my_uca_scanner_handler my_ucs2_uca_scanner_handler= */ static void my_uca_scanner_init_any(my_uca_scanner *scanner, CHARSET_INFO *cs __attribute__((unused)), - const uchar *str, uint length) + const uchar *str, size_t length) { /* Note, no needs to initialize scanner->wbeg */ scanner->sbeg= str; @@ -7055,8 +7055,8 @@ static my_uca_scanner_handler my_any_uca_scanner_handler= static int my_strnncoll_uca(CHARSET_INFO *cs, my_uca_scanner_handler *scanner_handler, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { my_uca_scanner sscanner; @@ -7126,8 +7126,8 @@ static int my_strnncoll_uca(CHARSET_INFO *cs, static int my_strnncollsp_uca(CHARSET_INFO *cs, my_uca_scanner_handler *scanner_handler, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool diff_if_only_endspace_difference) { my_uca_scanner sscanner, tscanner; @@ -7204,7 +7204,7 @@ static int my_strnncollsp_uca(CHARSET_INFO *cs, static void my_hash_sort_uca(CHARSET_INFO *cs, my_uca_scanner_handler *scanner_handler, - const uchar *s, uint slen, + const uchar *s, size_t slen, ulong *n1, ulong *n2) { int s_res; @@ -7254,12 +7254,12 @@ static void my_hash_sort_uca(CHARSET_INFO *cs, Number of bytes that have been written into the binary image. */ -static int my_strnxfrm_uca(CHARSET_INFO *cs, - my_uca_scanner_handler *scanner_handler, - uchar *dst, uint dstlen, - const uchar *src, uint srclen) +static size_t my_strnxfrm_uca(CHARSET_INFO *cs, + my_uca_scanner_handler *scanner_handler, + uchar *dst, size_t dstlen, + const uchar *src, size_t srclen) { - uchar *de = dst + (dstlen & (uint) ~1); /* add even length for easier code */ + uchar *de= dst + (dstlen & (size_t) ~1); /* add even length for easier code */ int s_res; my_uca_scanner scanner; scanner_handler->init(&scanner, cs, src, srclen); @@ -7292,6 +7292,7 @@ static int my_strnxfrm_uca(CHARSET_INFO *cs, This fact allows us to use memcmp() safely, on both little-endian and big-endian machines. */ + static int my_uca_charcmp(CHARSET_INFO *cs, my_wc_t wc1, my_wc_t wc2) { size_t page1= wc1 >> MY_UCA_PSHIFT; @@ -7334,7 +7335,7 @@ int my_wildcmp_uca(CHARSET_INFO *cs, my_wc_t s_wc, w_wc; int scan; int (*mb_wc)(struct charset_info_st *, my_wc_t *, - const unsigned char *, const unsigned char *); + const uchar *, const uchar *); mb_wc= cs->cset->mb_wc; while (wildstr != wildend) @@ -7566,7 +7567,7 @@ static void my_coll_lexem_print_error(MY_COLL_LEXEM *lexem, { char tail[30]; size_t len= lexem->end - lexem->prev; - strmake (tail, lexem->prev, (uint) min(len, sizeof(tail)-1)); + strmake (tail, lexem->prev, (size_t) min(len, sizeof(tail)-1)); errstr[errsize-1]= '\0'; my_snprintf(errstr,errsize-1,"%s at '%s'", txt, tail); } @@ -7830,7 +7831,7 @@ static int my_coll_rule_parse(MY_COLL_RULE *rule, size_t mitems, default weights. */ -static my_bool create_tailoring(CHARSET_INFO *cs, void *(*alloc)(uint)) +static my_bool create_tailoring(CHARSET_INFO *cs, void *(*alloc)(size_t)) { MY_COLL_RULE rule[MY_MAX_COLL_RULE]; char errstr[128]; @@ -7979,15 +7980,15 @@ static my_bool create_tailoring(CHARSET_INFO *cs, void *(*alloc)(uint)) Should work for any character set. */ -static my_bool my_coll_init_uca(CHARSET_INFO *cs, void *(*alloc)(uint)) +static my_bool my_coll_init_uca(CHARSET_INFO *cs, void *(*alloc)(size_t)) { cs->pad_char= ' '; return create_tailoring(cs, alloc); } static int my_strnncoll_any_uca(CHARSET_INFO *cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { return my_strnncoll_uca(cs, &my_any_uca_scanner_handler, @@ -7995,8 +7996,8 @@ static int my_strnncoll_any_uca(CHARSET_INFO *cs, } static int my_strnncollsp_any_uca(CHARSET_INFO *cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool diff_if_only_endspace_difference) { return my_strnncollsp_uca(cs, &my_any_uca_scanner_handler, @@ -8005,15 +8006,15 @@ static int my_strnncollsp_any_uca(CHARSET_INFO *cs, } static void my_hash_sort_any_uca(CHARSET_INFO *cs, - const uchar *s, uint slen, + const uchar *s, size_t slen, ulong *n1, ulong *n2) { my_hash_sort_uca(cs, &my_any_uca_scanner_handler, s, slen, n1, n2); } -static int my_strnxfrm_any_uca(CHARSET_INFO *cs, - uchar *dst, uint dstlen, - const uchar *src, uint srclen) +static size_t my_strnxfrm_any_uca(CHARSET_INFO *cs, + uchar *dst, size_t dstlen, + const uchar *src, size_t srclen) { return my_strnxfrm_uca(cs, &my_any_uca_scanner_handler, dst, dstlen, src, srclen); @@ -8025,8 +8026,8 @@ static int my_strnxfrm_any_uca(CHARSET_INFO *cs, UCS2 optimized CHARSET_INFO compatible wrappers. */ static int my_strnncoll_ucs2_uca(CHARSET_INFO *cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { return my_strnncoll_uca(cs, &my_ucs2_uca_scanner_handler, @@ -8034,8 +8035,8 @@ static int my_strnncoll_ucs2_uca(CHARSET_INFO *cs, } static int my_strnncollsp_ucs2_uca(CHARSET_INFO *cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool diff_if_only_endspace_difference) { return my_strnncollsp_uca(cs, &my_ucs2_uca_scanner_handler, @@ -8044,15 +8045,15 @@ static int my_strnncollsp_ucs2_uca(CHARSET_INFO *cs, } static void my_hash_sort_ucs2_uca(CHARSET_INFO *cs, - const uchar *s, uint slen, + const uchar *s, size_t slen, ulong *n1, ulong *n2) { my_hash_sort_uca(cs, &my_ucs2_uca_scanner_handler, s, slen, n1, n2); } -static int my_strnxfrm_ucs2_uca(CHARSET_INFO *cs, - uchar *dst, uint dstlen, - const uchar *src, uint srclen) +static size_t my_strnxfrm_ucs2_uca(CHARSET_INFO *cs, + uchar *dst, size_t dstlen, + const uchar *src, size_t srclen) { return my_strnxfrm_uca(cs, &my_ucs2_uca_scanner_handler, dst, dstlen, src, srclen); @@ -8060,17 +8061,17 @@ static int my_strnxfrm_ucs2_uca(CHARSET_INFO *cs, MY_COLLATION_HANDLER my_collation_ucs2_uca_handler = { - my_coll_init_uca, /* init */ - my_strnncoll_ucs2_uca, - my_strnncollsp_ucs2_uca, - my_strnxfrm_ucs2_uca, - my_strnxfrmlen_simple, - my_like_range_ucs2, - my_wildcmp_uca, - NULL, - my_instr_mb, - my_hash_sort_ucs2_uca, - my_propagate_complex + my_coll_init_uca, /* init */ + my_strnncoll_ucs2_uca, + my_strnncollsp_ucs2_uca, + my_strnxfrm_ucs2_uca, + my_strnxfrmlen_simple, + my_like_range_ucs2, + my_wildcmp_uca, + NULL, + my_instr_mb, + my_hash_sort_ucs2_uca, + my_propagate_complex }; CHARSET_INFO my_charset_ucs2_general_uca= diff --git a/strings/ctype-ucs2.c b/strings/ctype-ucs2.c index d3b65aa1643..38b2789c545 100644 --- a/strings/ctype-ucs2.c +++ b/strings/ctype-ucs2.c @@ -22,6 +22,7 @@ #include "m_string.h" #include "m_ctype.h" #include <errno.h> +#include <stdarg.h> #ifdef HAVE_CHARSET_ucs2 @@ -96,7 +97,7 @@ static int my_ucs2_uni(CHARSET_INFO *cs __attribute__((unused)), if (s+2 > e) /* Need 2 characters */ return MY_CS_TOOSMALL2; - *pwc= ((unsigned char)s[0]) * 256 + ((unsigned char)s[1]); + *pwc= ((uchar)s[0]) * 256 + ((uchar)s[1]); return 2; } @@ -112,9 +113,9 @@ static int my_uni_ucs2(CHARSET_INFO *cs __attribute__((unused)) , } -static uint my_caseup_ucs2(CHARSET_INFO *cs, char *src, uint srclen, +static size_t my_caseup_ucs2(CHARSET_INFO *cs, char *src, size_t srclen, char *dst __attribute__((unused)), - uint dstlen __attribute__((unused))) + size_t dstlen __attribute__((unused))) { my_wc_t wc; int res; @@ -135,7 +136,7 @@ static uint my_caseup_ucs2(CHARSET_INFO *cs, char *src, uint srclen, } -static void my_hash_sort_ucs2(CHARSET_INFO *cs, const uchar *s, uint slen, +static void my_hash_sort_ucs2(CHARSET_INFO *cs, const uchar *s, size_t slen, ulong *n1, ulong *n2) { my_wc_t wc; @@ -159,16 +160,16 @@ static void my_hash_sort_ucs2(CHARSET_INFO *cs, const uchar *s, uint slen, } -static uint my_caseup_str_ucs2(CHARSET_INFO * cs __attribute__((unused)), +static size_t my_caseup_str_ucs2(CHARSET_INFO * cs __attribute__((unused)), char * s __attribute__((unused))) { return 0; } -static uint my_casedn_ucs2(CHARSET_INFO *cs, char *src, uint srclen, +static size_t my_casedn_ucs2(CHARSET_INFO *cs, char *src, size_t srclen, char *dst __attribute__((unused)), - uint dstlen __attribute__((unused))) + size_t dstlen __attribute__((unused))) { my_wc_t wc; int res; @@ -189,7 +190,7 @@ static uint my_casedn_ucs2(CHARSET_INFO *cs, char *src, uint srclen, } -static uint my_casedn_str_ucs2(CHARSET_INFO *cs __attribute__((unused)), +static size_t my_casedn_str_ucs2(CHARSET_INFO *cs __attribute__((unused)), char * s __attribute__((unused))) { return 0; @@ -197,8 +198,8 @@ static uint my_casedn_str_ucs2(CHARSET_INFO *cs __attribute__((unused)), static int my_strnncoll_ucs2(CHARSET_INFO *cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { int s_res,t_res; @@ -263,13 +264,13 @@ static int my_strnncoll_ucs2(CHARSET_INFO *cs, */ static int my_strnncollsp_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool diff_if_only_endspace_difference __attribute__((unused))) { const uchar *se, *te; - uint minlen; + size_t minlen; MY_UNICASE_INFO **uni_plane= cs->caseinfo; /* extra safety to make sure the lengths are even numbers */ @@ -314,7 +315,7 @@ static int my_strnncollsp_ucs2(CHARSET_INFO *cs __attribute__((unused)), static int my_strncasecmp_ucs2(CHARSET_INFO *cs, - const char *s, const char *t, uint len) + const char *s, const char *t, size_t len) { int s_res,t_res; my_wc_t s_wc,t_wc; @@ -355,15 +356,16 @@ static int my_strncasecmp_ucs2(CHARSET_INFO *cs, static int my_strcasecmp_ucs2(CHARSET_INFO *cs, const char *s, const char *t) { - uint s_len= (uint) strlen(s); - uint t_len= (uint) strlen(t); - uint len = (s_len > t_len) ? s_len : t_len; - return my_strncasecmp_ucs2(cs, s, t, len); + size_t s_len= strlen(s); + size_t t_len= strlen(t); + size_t len = (s_len > t_len) ? s_len : t_len; + return my_strncasecmp_ucs2(cs, s, t, len); } -static int my_strnxfrm_ucs2(CHARSET_INFO *cs, - uchar *dst, uint dstlen, const uchar *src, uint srclen) +static size_t my_strnxfrm_ucs2(CHARSET_INFO *cs, + uchar *dst, size_t dstlen, const uchar *src, + size_t srclen) { my_wc_t wc; int res; @@ -391,30 +393,27 @@ static int my_strnxfrm_ucs2(CHARSET_INFO *cs, dst+=res; } if (dst < de) - cs->cset->fill(cs, (char*) dst, (uint) (de - dst), ' '); + cs->cset->fill(cs, (char*) dst, (size_t) (de - dst), ' '); return dstlen; } -static int my_ismbchar_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *b __attribute__((unused)), - const char *e __attribute__((unused))) +static uint my_ismbchar_ucs2(CHARSET_INFO *cs __attribute__((unused)), + const char *b __attribute__((unused)), + const char *e __attribute__((unused))) { return 2; } -static int my_mbcharlen_ucs2(CHARSET_INFO *cs __attribute__((unused)) , - uint c __attribute__((unused))) +static uint my_mbcharlen_ucs2(CHARSET_INFO *cs __attribute__((unused)) , + uint c __attribute__((unused))) { return 2; } -#include <m_string.h> -#include <stdarg.h> - -static int my_vsnprintf_ucs2(char *dst, uint n, const char* fmt, va_list ap) +static int my_vsnprintf_ucs2(char *dst, size_t n, const char* fmt, va_list ap) { char *start=dst, *end=dst+n-1; for (; *fmt ; fmt++) @@ -440,10 +439,10 @@ static int my_vsnprintf_ucs2(char *dst, uint n, const char* fmt, va_list ap) if (*fmt == 's') /* String parameter */ { reg2 char *par = va_arg(ap, char *); - uint plen; - uint left_len = (uint)(end-dst); + size_t plen; + size_t left_len = (size_t)(end-dst); if (!par) par = (char*)"(null)"; - plen = (uint) strlen(par); + plen= strlen(par); if (left_len <= plen*2) plen = left_len/2 - 1; @@ -460,7 +459,7 @@ static int my_vsnprintf_ucs2(char *dst, uint n, const char* fmt, va_list ap) char nbuf[16]; char *pbuf=nbuf; - if ((uint) (end-dst) < 32) + if ((size_t) (end-dst) < 32) break; iarg = va_arg(ap, int); if (*fmt == 'd') @@ -485,11 +484,11 @@ static int my_vsnprintf_ucs2(char *dst, uint n, const char* fmt, va_list ap) DBUG_ASSERT(dst <= end); *dst='\0'; /* End of errmessage */ - return (uint) (dst - start); + return (size_t) (dst - start); } -static int my_snprintf_ucs2(CHARSET_INFO *cs __attribute__((unused)), - char* to, uint n, const char* fmt, ...) +static size_t my_snprintf_ucs2(CHARSET_INFO *cs __attribute__((unused)), + char* to, size_t n, const char* fmt, ...) { va_list args; va_start(args,fmt); @@ -498,7 +497,7 @@ static int my_snprintf_ucs2(CHARSET_INFO *cs __attribute__((unused)), long my_strntol_ucs2(CHARSET_INFO *cs, - const char *nptr, uint l, int base, + const char *nptr, size_t l, int base, char **endptr, int *err) { int negative=0; @@ -613,7 +612,7 @@ bs: ulong my_strntoul_ucs2(CHARSET_INFO *cs, - const char *nptr, uint l, int base, + const char *nptr, size_t l, int base, char **endptr, int *err) { int negative=0; @@ -722,7 +721,7 @@ bs: longlong my_strntoll_ucs2(CHARSET_INFO *cs, - const char *nptr, uint l, int base, + const char *nptr, size_t l, int base, char **endptr, int *err) { int negative=0; @@ -839,7 +838,7 @@ bs: ulonglong my_strntoull_ucs2(CHARSET_INFO *cs, - const char *nptr, uint l, int base, + const char *nptr, size_t l, int base, char **endptr, int *err) { int negative=0; @@ -947,7 +946,7 @@ bs: double my_strntod_ucs2(CHARSET_INFO *cs __attribute__((unused)), - char *nptr, uint length, + char *nptr, size_t length, char **endptr, int *err) { char buf[256]; @@ -974,13 +973,14 @@ double my_strntod_ucs2(CHARSET_INFO *cs __attribute__((unused)), *endptr= b; res= my_strtod(buf, endptr, err); - *endptr= nptr + (uint) (*endptr- buf); + *endptr= nptr + (size_t) (*endptr- buf); return res; } ulonglong my_strntoull10rnd_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *nptr, uint length, int unsign_fl, + const char *nptr, size_t length, + int unsign_fl, char **endptr, int *err) { char buf[256], *b= buf; @@ -1003,7 +1003,7 @@ ulonglong my_strntoull10rnd_ucs2(CHARSET_INFO *cs __attribute__((unused)), } res= my_strntoull10rnd_8bit(cs, buf, b - buf, unsign_fl, endptr, err); - *endptr= (char*) nptr + 2 * (uint) (*endptr- buf); + *endptr= (char*) nptr + 2 * (size_t) (*endptr- buf); return res; } @@ -1012,8 +1012,8 @@ ulonglong my_strntoull10rnd_ucs2(CHARSET_INFO *cs __attribute__((unused)), This is a fast version optimized for the case of radix 10 / -10 */ -int my_l10tostr_ucs2(CHARSET_INFO *cs, - char *dst, uint len, int radix, long int val) +size_t my_l10tostr_ucs2(CHARSET_INFO *cs, + char *dst, size_t len, int radix, long int val) { char buffer[66]; register char *p, *db, *de; @@ -1059,8 +1059,9 @@ int my_l10tostr_ucs2(CHARSET_INFO *cs, return (int) (dst-db); } -int my_ll10tostr_ucs2(CHARSET_INFO *cs __attribute__((unused)), - char *dst, uint len, int radix, longlong val) + +size_t my_ll10tostr_ucs2(CHARSET_INFO *cs __attribute__((unused)), + char *dst, size_t len, int radix, longlong val) { char buffer[65]; register char *p, *db, *de; @@ -1087,7 +1088,7 @@ int my_ll10tostr_ucs2(CHARSET_INFO *cs __attribute__((unused)), while ((ulonglong) val > (ulonglong) LONG_MAX) { - ulonglong quo=(ulonglong) val/(uint) 10; + ulonglong quo=(ulonglong) val/(size_t) 10; uint rem= (uint) (val- quo* (uint) 10); *--p = '0' + rem; val= quo; @@ -1137,7 +1138,7 @@ longlong my_strtoll10_ucs2(CHARSET_INFO *cs __attribute__((unused)), const char *nptr, char **endptr, int *error) { const char *s, *end, *start, *n_end, *true_end; - unsigned char c; + uchar c; unsigned long i, j, k; ulonglong li; int negative; @@ -1273,7 +1274,7 @@ end_i: return (negative ? ((longlong) -(long) i) : (longlong) i); end_i_and_j: - li= (ulonglong) i * lfactor[(uint) (s-start) / 2] + j; + li= (ulonglong) i * lfactor[(size_t) (s-start) / 2] + j; *endptr= (char*) s; return (negative ? -((longlong) li) : (longlong) li); @@ -1302,31 +1303,31 @@ no_conv: static -uint my_numchars_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e) +size_t my_numchars_ucs2(CHARSET_INFO *cs __attribute__((unused)), + const char *b, const char *e) { - return (uint) (e-b)/2; + return (size_t) (e-b)/2; } static -uint my_charpos_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *b __attribute__((unused)), - const char *e __attribute__((unused)), - uint pos) +size_t my_charpos_ucs2(CHARSET_INFO *cs __attribute__((unused)), + const char *b __attribute__((unused)), + const char *e __attribute__((unused)), + size_t pos) { - uint string_length= (uint) (e - b); + size_t string_length= (size_t) (e - b); return pos > string_length ? string_length + 2 : pos * 2; } static -uint my_well_formed_len_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *b, const char *e, - uint nchars, int *error) +size_t my_well_formed_len_ucs2(CHARSET_INFO *cs __attribute__((unused)), + const char *b, const char *e, + size_t nchars, int *error) { /* Ensure string length is dividable with 2 */ - uint nbytes= ((uint) (e-b)) & ~(uint) 1; + size_t nbytes= ((size_t) (e-b)) & ~(size_t) 1; *error= 0; nchars*= 2; return min(nbytes, nchars); @@ -1335,20 +1336,20 @@ uint my_well_formed_len_ucs2(CHARSET_INFO *cs __attribute__((unused)), static void my_fill_ucs2(CHARSET_INFO *cs __attribute__((unused)), - char *s, uint l, int fill) + char *s, size_t l, int fill) { for ( ; l >= 2; s[0]= 0, s[1]= fill, s+=2, l-=2); } static -uint my_lengthsp_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr, uint length) +size_t my_lengthsp_ucs2(CHARSET_INFO *cs __attribute__((unused)), + const char *ptr, size_t length) { const char *end= ptr+length; while (end > ptr+1 && end[-1] == ' ' && end[-2] == '\0') end-=2; - return (uint) (end-ptr); + return (size_t) (end-ptr); } @@ -1377,8 +1378,8 @@ int my_wildcmp_ucs2_bin(CHARSET_INFO *cs, static int my_strnncoll_ucs2_bin(CHARSET_INFO *cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { int s_res,t_res; @@ -1410,13 +1411,13 @@ int my_strnncoll_ucs2_bin(CHARSET_INFO *cs, } static int my_strnncollsp_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool diff_if_only_endspace_difference __attribute__((unused))) { const uchar *se, *te; - uint minlen; + size_t minlen; /* extra safety to make sure the lengths are even numbers */ slen= (slen >> 1) << 1; @@ -1459,17 +1460,17 @@ static int my_strnncollsp_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), static int my_strcasecmp_ucs2_bin(CHARSET_INFO *cs, const char *s, const char *t) { - uint s_len= (uint) strlen(s); - uint t_len= (uint) strlen(t); - uint len = (s_len > t_len) ? s_len : t_len; + size_t s_len= strlen(s); + size_t t_len= strlen(t); + size_t len = (s_len > t_len) ? s_len : t_len; return my_strncasecmp_ucs2(cs, s, t, len); } static -int my_strnxfrm_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), - uchar *dst, uint dstlen, - const uchar *src, uint srclen) +size_t my_strnxfrm_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), + uchar *dst, size_t dstlen, + const uchar *src, size_t srclen) { if (dst != src) memcpy(dst,src,srclen= min(dstlen,srclen)); @@ -1481,7 +1482,7 @@ int my_strnxfrm_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), static void my_hash_sort_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), - const uchar *key, uint len,ulong *nr1, ulong *nr2) + const uchar *key, size_t len,ulong *nr1, ulong *nr2) { const uchar *pos = key; @@ -1513,16 +1514,16 @@ void my_hash_sort_ucs2_bin(CHARSET_INFO *cs __attribute__((unused)), */ my_bool my_like_range_ucs2(CHARSET_INFO *cs, - const char *ptr,uint ptr_length, + const char *ptr, size_t ptr_length, pbool escape, pbool w_one, pbool w_many, - uint res_length, + size_t res_length, char *min_str,char *max_str, - uint *min_length,uint *max_length) + size_t *min_length,size_t *max_length) { const char *end=ptr+ptr_length; char *min_org=min_str; char *min_end=min_str+res_length; - uint charlen= res_length / cs->mbmaxlen; + size_t charlen= res_length / cs->mbmaxlen; for ( ; ptr + 1 < end && min_str + 1 < min_end && charlen > 0 ; ptr+=2, charlen--) @@ -1549,7 +1550,7 @@ my_bool my_like_range_ucs2(CHARSET_INFO *cs, 'a\0\0... is the smallest possible string when we have space expand a\ff\ff... is the biggest possible string */ - *min_length= ((cs->state & MY_CS_BINSORT) ? (uint) (min_str - min_org) : + *min_length= ((cs->state & MY_CS_BINSORT) ? (size_t) (min_str - min_org) : res_length); *max_length= res_length; do { @@ -1574,7 +1575,7 @@ my_bool my_like_range_ucs2(CHARSET_INFO *cs, } } - *min_length= *max_length = (uint) (min_str - min_org); + *min_length= *max_length = (size_t) (min_str - min_org); while (min_str + 1 < min_end) { *min_str++ = *max_str++ = '\0'; @@ -1585,8 +1586,8 @@ my_bool my_like_range_ucs2(CHARSET_INFO *cs, -ulong my_scan_ucs2(CHARSET_INFO *cs __attribute__((unused)), - const char *str, const char *end, int sequence_type) +size_t my_scan_ucs2(CHARSET_INFO *cs __attribute__((unused)), + const char *str, const char *end, int sequence_type) { const char *str0= str; end--; /* for easier loop condition, because of two bytes per character */ @@ -1599,7 +1600,7 @@ ulong my_scan_ucs2(CHARSET_INFO *cs __attribute__((unused)), if (str[0] != '\0' || str[1] != ' ') break; } - return (ulong) (str - str0); + return (size_t) (str - str0); default: return 0; } diff --git a/strings/ctype-ujis.c b/strings/ctype-ujis.c index d1e11071886..12d14667b28 100644 --- a/strings/ctype-ujis.c +++ b/strings/ctype-ujis.c @@ -184,7 +184,7 @@ static uchar NEAR sort_order_ujis[]= #define isujis_ss3(c) (((c)&0xff) == 0x8f) -static int ismbchar_ujis(CHARSET_INFO *cs __attribute__((unused)), +static uint ismbchar_ujis(CHARSET_INFO *cs __attribute__((unused)), const char* p, const char *e) { return ((*(uchar*)(p)<0x80)? 0:\ @@ -194,7 +194,7 @@ static int ismbchar_ujis(CHARSET_INFO *cs __attribute__((unused)), 0); } -static int mbcharlen_ujis(CHARSET_INFO *cs __attribute__((unused)),uint c) +static uint mbcharlen_ujis(CHARSET_INFO *cs __attribute__((unused)),uint c) { return (isujis(c)? 2: isujis_ss2(c)? 2: isujis_ss3(c)? 3: 1); } @@ -8252,9 +8252,9 @@ my_jisx0212_uni_onechar(int code){ */ static -uint my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)), - const char *beg, const char *end, - uint pos, int *error) +size_t my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)), + const char *beg, const char *end, + size_t pos, int *error) { const uchar *b= (uchar *) beg; @@ -8270,7 +8270,7 @@ uint my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)), if (b >= (uchar *) end) /* need more bytes */ { *error= 1; - return (uint) (chbeg - beg); /* unexpected EOL */ + return (size_t) (chbeg - beg); /* unexpected EOL */ } if (ch == 0x8E) /* [x8E][xA0-xDF] */ @@ -8278,7 +8278,7 @@ uint my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)), if (*b >= 0xA0 && *b <= 0xDF) continue; *error= 1; - return (uint) (chbeg - beg); /* invalid sequence */ + return (size_t) (chbeg - beg); /* invalid sequence */ } if (ch == 0x8F) /* [x8F][xA1-xFE][xA1-xFE] */ @@ -8287,7 +8287,7 @@ uint my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)), if (b >= (uchar*) end) { *error= 1; - return (uint) (chbeg - beg); /* unexpected EOL */ + return (size_t) (chbeg - beg); /* unexpected EOL */ } } @@ -8295,19 +8295,19 @@ uint my_well_formed_len_ujis(CHARSET_INFO *cs __attribute__((unused)), *b >= 0xA1 && *b <= 0xFE) /* [xA1-xFE][xA1-xFE] */ continue; *error= 1; - return (uint) (chbeg - beg); /* invalid sequence */ + return (size_t) (chbeg - beg); /* invalid sequence */ } - return (uint) (b - (uchar *) beg); + return (size_t) (b - (uchar *) beg); } static -uint my_numcells_eucjp(CHARSET_INFO *cs __attribute__((unused)), +size_t my_numcells_eucjp(CHARSET_INFO *cs __attribute__((unused)), const char *str, const char *str_end) { - uint clen= 0; - const unsigned char *b= (const unsigned char *) str; - const unsigned char *e= (const unsigned char *) str_end; + size_t clen; + const uchar *b= (const uchar *) str; + const uchar *e= (const uchar *) str_end; for (clen= 0; b < e; ) { @@ -8335,6 +8335,7 @@ uint my_numcells_eucjp(CHARSET_INFO *cs __attribute__((unused)), return clen; } + static int my_mb_wc_euc_jp(CHARSET_INFO *cs,my_wc_t *pwc, const uchar *s, const uchar *e) { @@ -8422,10 +8423,11 @@ my_mb_wc_euc_jp(CHARSET_INFO *cs,my_wc_t *pwc, const uchar *s, const uchar *e) return MY_CS_ILSEQ; } + static int -my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, unsigned char *s, unsigned char *e) +my_wc_mb_euc_jp(CHARSET_INFO *c,my_wc_t wc, uchar *s, uchar *e) { - unsigned char c1; + uchar c1; int jp; if (s >= e) diff --git a/strings/ctype-utf8.c b/strings/ctype-utf8.c index 16882e9b25d..851cef54b5b 100644 --- a/strings/ctype-utf8.c +++ b/strings/ctype-utf8.c @@ -1722,7 +1722,7 @@ int my_wildcmp_unicode(CHARSET_INFO *cs, my_wc_t s_wc, w_wc; int scan, plane; int (*mb_wc)(struct charset_info_st *, my_wc_t *, - const unsigned char *, const unsigned char *); + const uchar *, const uchar *); mb_wc= cs->cset->mb_wc; while (wildstr != wildend) @@ -1946,7 +1946,7 @@ static inline int bincmp(const uchar *s, const uchar *se, static int my_utf8_uni(CHARSET_INFO *cs __attribute__((unused)), my_wc_t * pwc, const uchar *s, const uchar *e) { - unsigned char c; + uchar c; if (s >= e) return MY_CS_TOOSMALL; @@ -1975,7 +1975,8 @@ static int my_utf8_uni(CHARSET_INFO *cs __attribute__((unused)), if (s+3 > e) /* We need 3 characters */ return MY_CS_TOOSMALL3; - if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 && (c >= 0xe1 || s[1] >= 0xa0))) + if (!((s[1] ^ 0x80) < 0x40 && (s[2] ^ 0x80) < 0x40 && + (c >= 0xe1 || s[1] >= 0xa0))) return MY_CS_ILSEQ; *pwc = ((my_wc_t) (c & 0x0f) << 12) | @@ -2055,7 +2056,7 @@ static int my_utf8_uni(CHARSET_INFO *cs __attribute__((unused)), static int my_utf8_uni_no_range(CHARSET_INFO *cs __attribute__((unused)), my_wc_t * pwc, const uchar *s) { - unsigned char c; + uchar c; c= s[0]; if (c < 0x80) @@ -2093,8 +2094,8 @@ static int my_utf8_uni_no_range(CHARSET_INFO *cs __attribute__((unused)), } -static int my_uni_utf8 (CHARSET_INFO *cs __attribute__((unused)) , - my_wc_t wc, uchar *r, uchar *e) +static int my_uni_utf8 (CHARSET_INFO *cs __attribute__((unused)), + my_wc_t wc, uchar *r, uchar *e) { int count; @@ -2167,8 +2168,8 @@ static int my_uni_utf8_no_range(CHARSET_INFO *cs __attribute__((unused)), } -static uint my_caseup_utf8(CHARSET_INFO *cs, char *src, uint srclen, - char *dst, uint dstlen) +static size_t my_caseup_utf8(CHARSET_INFO *cs, char *src, size_t srclen, + char *dst, size_t dstlen) { my_wc_t wc; int srcres, dstres; @@ -2186,10 +2187,11 @@ static uint my_caseup_utf8(CHARSET_INFO *cs, char *src, uint srclen, src+= srcres; dst+= dstres; } - return (uint) (dst - dst0); + return (size_t) (dst - dst0); } -static void my_hash_sort_utf8(CHARSET_INFO *cs, const uchar *s, uint slen, + +static void my_hash_sort_utf8(CHARSET_INFO *cs, const uchar *s, size_t slen, ulong *n1, ulong *n2) { my_wc_t wc; @@ -2217,7 +2219,7 @@ static void my_hash_sort_utf8(CHARSET_INFO *cs, const uchar *s, uint slen, } -static uint my_caseup_str_utf8(CHARSET_INFO *cs, char *src) +static size_t my_caseup_str_utf8(CHARSET_INFO *cs, char *src) { my_wc_t wc; int srcres, dstres; @@ -2236,12 +2238,12 @@ static uint my_caseup_str_utf8(CHARSET_INFO *cs, char *src) dst+= dstres; } *dst= '\0'; - return (uint) (dst - dst0); + return (size_t) (dst - dst0); } -static uint my_casedn_utf8(CHARSET_INFO *cs, char *src, uint srclen, - char *dst, uint dstlen) +static size_t my_casedn_utf8(CHARSET_INFO *cs, char *src, size_t srclen, + char *dst, size_t dstlen) { my_wc_t wc; int srcres, dstres; @@ -2259,11 +2261,11 @@ static uint my_casedn_utf8(CHARSET_INFO *cs, char *src, uint srclen, src+= srcres; dst+= dstres; } - return (uint) (dst - dst0); + return (size_t) (dst - dst0); } -static uint my_casedn_str_utf8(CHARSET_INFO *cs, char *src) +static size_t my_casedn_str_utf8(CHARSET_INFO *cs, char *src) { my_wc_t wc; int srcres, dstres; @@ -2298,13 +2300,13 @@ static uint my_casedn_str_utf8(CHARSET_INFO *cs, char *src) */ *dst= '\0'; - return (uint) (dst - dst0); + return (size_t) (dst - dst0); } static int my_strnncoll_utf8(CHARSET_INFO *cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { int s_res,t_res; @@ -2375,8 +2377,8 @@ static int my_strnncoll_utf8(CHARSET_INFO *cs, */ static int my_strnncollsp_utf8(CHARSET_INFO *cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool diff_if_only_endspace_difference) { int s_res, t_res, res; @@ -2415,8 +2417,8 @@ static int my_strnncollsp_utf8(CHARSET_INFO *cs, t+=t_res; } - slen= (uint) (se-s); - tlen= (uint) (te-t); + slen= (size_t) (se-s); + tlen= (size_t) (te-t); res= 0; if (slen != tlen) @@ -2564,14 +2566,16 @@ int my_wildcmp_utf8(CHARSET_INFO *cs, static -uint my_strnxfrmlen_utf8(CHARSET_INFO *cs __attribute__((unused)), uint len) +size_t my_strnxfrmlen_utf8(CHARSET_INFO *cs __attribute__((unused)), + size_t len) { return (len * 2 + 2) / 3; } -static int my_strnxfrm_utf8(CHARSET_INFO *cs, - uchar *dst, uint dstlen, - const uchar *src, uint srclen) + +static size_t my_strnxfrm_utf8(CHARSET_INFO *cs, + uchar *dst, size_t dstlen, + const uchar *src, size_t srclen) { my_wc_t wc; int res; @@ -2607,14 +2611,15 @@ static int my_strnxfrm_utf8(CHARSET_INFO *cs, return dstlen; } -static int my_ismbchar_utf8(CHARSET_INFO *cs,const char *b, const char *e) +static uint my_ismbchar_utf8(CHARSET_INFO *cs,const char *b, const char *e) { my_wc_t wc; - int res=my_utf8_uni(cs,&wc, (const uchar*)b, (const uchar*)e); + int res= my_utf8_uni(cs,&wc, (const uchar*)b, (const uchar*)e); return (res>1) ? res : 0; } -static int my_mbcharlen_utf8(CHARSET_INFO *cs __attribute__((unused)) , uint c) +static uint my_mbcharlen_utf8(CHARSET_INFO *cs __attribute__((unused)), + uint c) { if (c < 0x80) return 1; @@ -2759,8 +2764,8 @@ CHARSET_INFO my_charset_utf8_bin= */ static int my_strnncoll_utf8_cs(CHARSET_INFO *cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool t_is_prefix) { int s_res,t_res; @@ -2805,8 +2810,8 @@ static int my_strnncoll_utf8_cs(CHARSET_INFO *cs, } static int my_strnncollsp_utf8_cs(CHARSET_INFO *cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool diff_if_only_endspace_difference __attribute__((unused))) { @@ -4104,7 +4109,7 @@ my_mb_wc_filename(CHARSET_INFO *cs __attribute__((unused)), static int my_wc_mb_filename(CHARSET_INFO *cs __attribute__((unused)), - my_wc_t wc, unsigned char *s, unsigned char *e) + my_wc_t wc, uchar *s, uchar *e) { int code; char hex[]= "0123456789abcdef"; @@ -4230,7 +4235,7 @@ static void test_mb(CHARSET_INFO *cs, uchar *s) { if (my_ismbhead_utf8(cs,*s)) { - int len=my_mbcharlen_utf8(cs,*s); + uint len=my_mbcharlen_utf8(cs,*s); while(len--) { printf("%c",*s); diff --git a/strings/ctype-win1250ch.c b/strings/ctype-win1250ch.c index d5be20f7b1b..b22b4364e8a 100644 --- a/strings/ctype-win1250ch.c +++ b/strings/ctype-win1250ch.c @@ -400,7 +400,7 @@ static uchar NEAR _sort_order_win1250ch2[] = { }; struct wordvalue { - const uchar * word; + const uchar *word; uchar pass1; uchar pass2; }; @@ -423,8 +423,8 @@ static struct wordvalue doubles[] = { if (value == 0xff) { \ int i; \ for (i = 0; i < (int) sizeof(doubles); i++) { \ - const uchar * patt = doubles[i].word; \ - const uchar * q = (const uchar *) p; \ + const uchar *patt = doubles[i].word; \ + const uchar *q = (const uchar *) p; \ while (*patt \ && !(IS_END(q, src, len)) \ && (*patt == *q)) { \ @@ -446,12 +446,12 @@ static struct wordvalue doubles[] = { #define IS_END(p, src, len) (((char *)p - (char *)src) >= (len)) static int my_strnncoll_win1250ch(CHARSET_INFO *cs __attribute__((unused)), - const uchar * s1, uint len1, - const uchar * s2, uint len2, + const uchar *s1, size_t len1, + const uchar *s2, size_t len2, my_bool s2_is_prefix) { int v1, v2; - const uchar * p1, * p2; + const uchar *p1, * p2; int pass1 = 0, pass2 = 0; int diff; @@ -477,8 +477,8 @@ static int my_strnncoll_win1250ch(CHARSET_INFO *cs __attribute__((unused)), static int my_strnncollsp_win1250ch(CHARSET_INFO * cs, - const uchar *s, uint slen, - const uchar *t, uint tlen, + const uchar *s, size_t slen, + const uchar *t, size_t tlen, my_bool diff_if_only_endspace_difference __attribute__((unused))) { @@ -488,14 +488,14 @@ int my_strnncollsp_win1250ch(CHARSET_INFO * cs, } -static int my_strnxfrm_win1250ch(CHARSET_INFO * cs __attribute__((unused)), - uchar * dest, uint len, - const uchar * src, uint srclen) +static size_t my_strnxfrm_win1250ch(CHARSET_INFO * cs __attribute__((unused)), + uchar *dest, size_t len, + const uchar *src, size_t srclen) { int value; - const uchar * p; + const uchar *p; int pass = 0; - uint totlen = 0; + size_t totlen = 0; p = src; do { @@ -615,11 +615,11 @@ static uchar NEAR like_range_prefix_max_win1250ch[]= static my_bool my_like_range_win1250ch(CHARSET_INFO *cs __attribute__((unused)), - const char *ptr, uint ptr_length, + const char *ptr, size_t ptr_length, pbool escape, pbool w_one, pbool w_many, - uint res_length, + size_t res_length, char *min_str, char *max_str, - uint *min_length, uint *max_length) + size_t *min_length, size_t *max_length) { int only_min_found= 1; @@ -643,7 +643,7 @@ my_like_range_win1250ch(CHARSET_INFO *cs __attribute__((unused)), } if (cs->state & MY_CS_BINSORT) - *min_length= (uint) (min_str - min_org); + *min_length= (size_t) (min_str - min_org); else { /* 'a\0\0... is the smallest possible string */ diff --git a/strings/ctype.c b/strings/ctype.c index 8cb6b23c58e..de5625ef074 100644 --- a/strings/ctype.c +++ b/strings/ctype.c @@ -111,7 +111,7 @@ static struct my_cs_file_section_st sec[] = {0, NULL} }; -static struct my_cs_file_section_st * cs_file_sec(const char *attr, uint len) +static struct my_cs_file_section_st * cs_file_sec(const char *attr, size_t len) { struct my_cs_file_section_st *s; for (s=sec; s->str; s++) @@ -160,7 +160,7 @@ static int fill_uchar(uchar *a,uint size,const char *str, uint len) return 0; } -static int fill_uint16(uint16 *a,uint size,const char *str, uint len) +static int fill_uint16(uint16 *a,uint size,const char *str, size_t len) { uint i= 0; @@ -178,7 +178,7 @@ static int fill_uint16(uint16 *a,uint size,const char *str, uint len) } -static int cs_enter(MY_XML_PARSER *st,const char *attr, uint len) +static int cs_enter(MY_XML_PARSER *st,const char *attr, size_t len) { struct my_cs_file_info *i= (struct my_cs_file_info *)st->user_data; struct my_cs_file_section_st *s= cs_file_sec(attr,len); @@ -193,7 +193,7 @@ static int cs_enter(MY_XML_PARSER *st,const char *attr, uint len) } -static int cs_leave(MY_XML_PARSER *st,const char *attr, uint len) +static int cs_leave(MY_XML_PARSER *st,const char *attr, size_t len) { struct my_cs_file_info *i= (struct my_cs_file_info *)st->user_data; struct my_cs_file_section_st *s= cs_file_sec(attr,len); @@ -211,11 +211,12 @@ static int cs_leave(MY_XML_PARSER *st,const char *attr, uint len) } -static int cs_value(MY_XML_PARSER *st,const char *attr, uint len) +static int cs_value(MY_XML_PARSER *st,const char *attr, size_t len) { struct my_cs_file_info *i= (struct my_cs_file_info *)st->user_data; struct my_cs_file_section_st *s; - int state= (int)((s=cs_file_sec(st->attr, (int) strlen(st->attr))) ? s->state : 0); + int state= (int)((s=cs_file_sec(st->attr, strlen(st->attr))) ? s->state : + 0); switch (state) { case _CS_ID: @@ -289,8 +290,8 @@ static int cs_value(MY_XML_PARSER *st,const char *attr, uint len) } -my_bool my_parse_charset_xml(const char *buf, uint len, - int (*add_collation)(CHARSET_INFO *cs)) +my_bool my_parse_charset_xml(const char *buf, size_t len, + int (*add_collation)(CHARSET_INFO *cs)) { MY_XML_PARSER p; struct my_cs_file_info i; diff --git a/strings/decimal.c b/strings/decimal.c index 0768c8cd4ca..ac82e7b16d6 100644 --- a/strings/decimal.c +++ b/strings/decimal.c @@ -1190,7 +1190,7 @@ int decimal2longlong(decimal_t *from, longlong *to) 7E F2 04 37 2D FB 2D */ -int decimal2bin(decimal_t *from, char *to, int precision, int frac) +int decimal2bin(decimal_t *from, uchar *to, int precision, int frac) { dec1 mask=from->sign ? -1 : 0, *buf1=from->buf, *stop1; int error=E_DEC_OK, intg=precision-frac, @@ -1206,7 +1206,7 @@ int decimal2bin(decimal_t *from, char *to, int precision, int frac) fsize1=frac1*sizeof(dec1)+dig2bytes[frac1x]; const int orig_isize0= isize0; const int orig_fsize0= fsize0; - char *orig_to= to; + uchar *orig_to= to; buf1= remove_leading_zeroes(from, &from_intg); @@ -1296,10 +1296,10 @@ int decimal2bin(decimal_t *from, char *to, int precision, int frac) } if (fsize0 > fsize1) { - char *to_end= orig_to + orig_fsize0 + orig_isize0; + uchar *to_end= orig_to + orig_fsize0 + orig_isize0; while (fsize0-- > fsize1 && to < to_end) - *to++=(uchar)mask; + *to++= (uchar)mask; } orig_to[0]^= 0x80; @@ -1325,19 +1325,19 @@ int decimal2bin(decimal_t *from, char *to, int precision, int frac) E_DEC_OK/E_DEC_TRUNCATED/E_DEC_OVERFLOW */ -int bin2decimal(char *from, decimal_t *to, int precision, int scale) +int bin2decimal(const uchar *from, decimal_t *to, int precision, int scale) { int error=E_DEC_OK, intg=precision-scale, intg0=intg/DIG_PER_DEC1, frac0=scale/DIG_PER_DEC1, intg0x=intg-intg0*DIG_PER_DEC1, frac0x=scale-frac0*DIG_PER_DEC1, intg1=intg0+(intg0x>0), frac1=frac0+(frac0x>0); dec1 *buf=to->buf, mask=(*from & 0x80) ? 0 : -1; - char *stop; - char *d_copy; + const uchar *stop; + uchar *d_copy; int bin_size= decimal_bin_size(precision, scale); sanity(to); - d_copy= (char *)my_alloca(bin_size); + d_copy= (uchar*) my_alloca(bin_size); memcpy(d_copy, from, bin_size); d_copy[0]^= 0x80; from= d_copy; diff --git a/strings/do_ctype.c b/strings/do_ctype.c index b8eca68debf..f33ddc5eb81 100644 --- a/strings/do_ctype.c +++ b/strings/do_ctype.c @@ -141,22 +141,22 @@ void init_case_convert() #endif #ifdef MSDOS - higher_pos= (uchar * ) "\217\216\231\232\220"; /* Extra chars to konv. */ - lower_pos= (uchar * ) "\206\204\224\201\202"; + higher_pos= (uchar *) "\217\216\231\232\220"; /* Extra chars to konv. */ + lower_pos= (uchar *) "\206\204\224\201\202"; #else #if defined(HPUX10) && ASCII_BITS_USED == 8 - higher_pos= (uchar * ) "\xd0\xd8\xda\xdb\xdc\xd3"; - lower_pos= (uchar * ) "\xd4\xcc\xce\xdf\xc9\xd7"; + higher_pos= (uchar *) "\xd0\xd8\xda\xdb\xdc\xd3"; + lower_pos= (uchar *) "\xd4\xcc\xce\xdf\xc9\xd7"; #else #ifdef USE_INTERNAL_CTYPE higher_pos=lower_pos= (uchar* ) ""; /* System converts chars */ #else #if defined(DEC_MULTINATIONAL_CHAR) || defined(HP_MULTINATIONAL_CHAR) - higher_pos= (uchar * ) "\305\304\326\311\334"; - lower_pos= (uchar * ) "\345\344\366\351\374"; + higher_pos= (uchar *) "\305\304\326\311\334"; + lower_pos= (uchar *) "\345\344\366\351\374"; #else - higher_pos= (uchar * ) "[]\\@^"; - lower_pos= (uchar * ) "{}|`~"; + higher_pos= (uchar *) "[]\\@^"; + lower_pos= (uchar *) "{}|`~"; #endif #endif /* USE_INTERNAL_CTYPE */ #endif /* HPUX10 */ diff --git a/strings/my_strtoll10.c b/strings/my_strtoll10.c index 165d3e38095..4f73b1f8e71 100644 --- a/strings/my_strtoll10.c +++ b/strings/my_strtoll10.c @@ -86,7 +86,7 @@ longlong my_strtoll10(const char *nptr, char **endptr, int *error) { const char *s, *end, *start, *n_end, *true_end; char *dummy; - unsigned char c; + uchar c; unsigned long i, j, k; ulonglong li; int negative; diff --git a/strings/my_vsnprintf.c b/strings/my_vsnprintf.c index befdb1a81c2..a57cc5b5ebe 100644 --- a/strings/my_vsnprintf.c +++ b/strings/my_vsnprintf.c @@ -40,10 +40,11 @@ length of result string */ -int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) +size_t my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) { char *start=to, *end=to+n-1; - uint length, width, pre_zero, have_long; + size_t length, width; + uint pre_zero, have_long; for (; *fmt ; fmt++) { @@ -58,7 +59,8 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) /* Read max fill size (only used with %d and %u) */ if (*fmt == '-') fmt++; - length= width= pre_zero= have_long= 0; + length= width= 0; + pre_zero= have_long= 0; if (*fmt == '*') { fmt++; @@ -93,7 +95,7 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) if (*fmt == 's') /* String parameter */ { reg2 char *par = va_arg(ap, char *); - uint plen,left_len = (uint)(end-to)+1; + size_t plen,left_len = (size_t) (end - to) + 1; if (!par) par = (char*)"(null)"; plen= (uint) strnlen(par, width); if (left_len <= plen) @@ -114,11 +116,11 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) else if (*fmt == 'd' || *fmt == 'u'|| *fmt== 'x') /* Integer parameter */ { register long larg; - uint res_length, to_length; + size_t res_length, to_length; char *store_start= to, *store_end; char buff[32]; - if ((to_length= (uint) (end-to)) < 16 || length) + if ((to_length= (size_t) (end-to)) < 16 || length) store_start= buff; if (have_long) larg = va_arg(ap, long); @@ -134,7 +136,7 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) store_end= int10_to_str(larg, store_start, 10); else store_end= int2str(larg, store_start, 16, 0); - if ((res_length= (uint) (store_end - store_start)) > to_length) + if ((res_length= (size_t) (store_end - store_start)) > to_length) break; /* num doesn't fit in output */ /* If %#d syntax was used, we have to pre-zero/pre-space the string */ if (store_start == buff) @@ -142,7 +144,7 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) length= min(length, to_length); if (res_length < length) { - uint diff= (length- res_length); + size_t diff= (length- res_length); bfill(to, diff, pre_zero ? '0' : ' '); to+= diff; } @@ -168,10 +170,11 @@ int my_vsnprintf(char *to, size_t n, const char* fmt, va_list ap) } DBUG_ASSERT(to <= end); *to='\0'; /* End of errmessage */ - return (uint) (to - start); + return (size_t) (to - start); } -int my_snprintf(char* to, size_t n, const char* fmt, ...) + +size_t my_snprintf(char* to, size_t n, const char* fmt, ...) { int result; va_list args; diff --git a/strings/r_strinstr.c b/strings/r_strinstr.c index 98118015456..fb1e0c5a090 100644 --- a/strings/r_strinstr.c +++ b/strings/r_strinstr.c @@ -25,14 +25,14 @@ #include <my_global.h> #include "m_string.h" -uint r_strinstr(reg1 my_string str,int from, reg4 my_string search) +size_t r_strinstr(reg1 const char * str, size_t from, reg4 const char * search) { - reg2 my_string i, j; - uint len = (uint) strlen(search); + reg2 const char *i, *j; + size_t len = strlen(search); /* pointer to the last char of buff */ - my_string start = str + from - 1; + const char * start = str + from - 1; /* pointer to the last char of search */ - my_string search_end = search + len - 1; + const char * search_end = search + len - 1; skip: while (start >= str) /* Cant be != because the first char */ @@ -43,7 +43,7 @@ uint r_strinstr(reg1 my_string str,int from, reg4 my_string search) while (j >= search && start > str) if (*i-- != *j--) goto skip; - return (uint) ((start - len) - str + 3); + return (size_t) ((start - len) - str + 3); } } return (0); diff --git a/strings/str_test.c b/strings/str_test.c index 7863dce8688..3ddfca39419 100644 --- a/strings/str_test.c +++ b/strings/str_test.c @@ -29,12 +29,12 @@ #define T_PREFILL '1' static char from_buff[100],to_buff[100]; -static my_string from,to; +static char * from, *to; static int errors,tests; static int test_strarg(const char *name,...); static void init_strings (void); /* Init from and to */ void test_arg (const char *message,long func_value,long value); -int compare_buff(const char *message,my_string b1,my_string b2,int length, +int compare_buff(const char *message,char * b1,char * b2,int length, pchar fill, pchar prefill); static int my_test(int a) @@ -228,7 +228,7 @@ static int test_strarg(const char *message,...) /* test if function made right value */ -int compare_buff(const char *message, my_string b1, my_string b2, int length, +int compare_buff(const char *message, char * b1, char * b2, int length, pchar fill, pchar prefill) { int i,error=0; diff --git a/strings/strappend.c b/strings/strappend.c index 3a5da658709..bb926f74665 100644 --- a/strings/strappend.c +++ b/strings/strappend.c @@ -27,7 +27,7 @@ #include "m_string.h" -void strappend(register char *s, uint len, pchar fill) +void strappend(register char *s, size_t len, pchar fill) { register char *endpos; diff --git a/strings/strcont.c b/strings/strcont.c index d57af77804d..5a518a3550f 100644 --- a/strings/strcont.c +++ b/strings/strcont.c @@ -27,9 +27,9 @@ #include <my_global.h> #include "m_string.h" -my_string strcont(reg1 const char *str,reg2 const char *set) +char * strcont(reg1 const char *str,reg2 const char *set) { - reg3 my_string start = (my_string) set; + reg3 char * start = (char *) set; while (*str) { diff --git a/strings/strfill.c b/strings/strfill.c index 7d3f25e3ff4..4b1fe67b206 100644 --- a/strings/strfill.c +++ b/strings/strfill.c @@ -26,7 +26,7 @@ #include <my_global.h> #include "m_string.h" -my_string strfill(my_string s,uint len,pchar fill) +char * strfill(char *s, size_t len, pchar fill) { while (len--) *s++ = fill; *(s) = '\0'; diff --git a/strings/strinstr.c b/strings/strinstr.c index 10f83a54c29..dce498d61e8 100644 --- a/strings/strinstr.c +++ b/strings/strinstr.c @@ -28,20 +28,20 @@ #include <my_global.h> #include "m_string.h" -uint strinstr(reg1 const char *str,reg4 const char *search) +size_t strinstr(reg1 const char *str,reg4 const char *search) { - reg2 my_string i,j; - my_string start = (my_string) str; + reg2 const char *i, *j; + const char *start= str; skip: while (*str != '\0') { if (*str++ == *search) { - i=(my_string) str; j= (my_string) search+1; + i= str; j= search+1; while (*j) if (*i++ != *j++) goto skip; - return ((uint) (str - start)); + return ((size_t) (str - start)); } } return (0); diff --git a/strings/strlen.c b/strings/strlen.c index b3c901739b1..1469dd096ee 100644 --- a/strings/strlen.c +++ b/strings/strlen.c @@ -31,7 +31,7 @@ #if VaxAsm -size_s strlen(char *s) +size_t strlen(char *s) { asm("locc $0,$65535,*4(ap)"); asm("subl3 r0,$65535,r0"); @@ -40,7 +40,7 @@ size_s strlen(char *s) #else #if defined(MC68000) && defined(DS90) -size_s strlen(char *s) +size_t strlen(char *s) { asm(" movl 4(a7),a0 "); asm(" movl a0,a1 "); @@ -52,13 +52,13 @@ asm(" subql #1,d0 "); } #else -size_s strlen(register char *s) +size_t strlen(register char *s) { register char *startpos; startpos = s; while (*s++); - return ((size_s) (s-startpos-1)); + return ((size_t) (s-startpos-1)); } #endif diff --git a/strings/strmake.c b/strings/strmake.c index 5ca4688de46..0d26e1b61a9 100644 --- a/strings/strmake.c +++ b/strings/strmake.c @@ -42,7 +42,7 @@ char *strmake(char *dst,const char *src,uint length) #define strmake strmake_overlapp /* Use orginal for overlapping str */ #endif -char *strmake(register char *dst, register const char *src, uint length) +char *strmake(register char *dst, register const char *src, size_t length) { while (length--) if (! (*dst++ = *src++)) diff --git a/strings/strnlen.c b/strings/strnlen.c index 11ecf718746..826cd5ae5dd 100644 --- a/strings/strnlen.c +++ b/strings/strnlen.c @@ -25,10 +25,10 @@ #ifndef HAVE_STRNLEN -uint strnlen(register const char *s, register uint maxlen) +size_t strnlen(register const char *s, register size_t maxlen) { const char *end= (const char *)memchr(s, '\0', maxlen); - return end ? (uint) (end - s) : maxlen; + return end ? (size_t) (end - s) : maxlen; } #endif diff --git a/strings/strnmov.c b/strings/strnmov.c index b2099452d98..7e26877637b 100644 --- a/strings/strnmov.c +++ b/strings/strnmov.c @@ -23,7 +23,7 @@ #include <my_global.h> #include "m_string.h" -char *strnmov(register char *dst, register const char *src, uint n) +char *strnmov(register char *dst, register const char *src, size_t n) { while (n-- != 0) { if (!(*dst++ = *src++)) { diff --git a/strings/strto.c b/strings/strto.c index 934b5d88e90..fcb0d800b81 100644 --- a/strings/strto.c +++ b/strings/strto.c @@ -88,7 +88,7 @@ function (const char *nptr,char **endptr,int base) register unsigned int cutlim; register ulongtype i; register const char *s; - register unsigned char c; + register uchar c; const char *save; int overflow; diff --git a/strings/strtod.c b/strings/strtod.c index 7196cafb2c9..868fddd9eb4 100644 --- a/strings/strtod.c +++ b/strings/strtod.c @@ -56,7 +56,8 @@ static double scaler1[] = { double my_strtod(const char *str, char **end_ptr, int *error) { double result= 0.0; - uint negative= 0, ndigits, dec_digits= 0, neg_exp= 0; + uint negative= 0, neg_exp= 0; + size_t ndigits, dec_digits= 0; int exponent= 0, digits_after_dec_point= 0, tmp_exp; const char *old_str, *end= *end_ptr, *start_of_number; char next_char; @@ -100,7 +101,7 @@ double my_strtod(const char *str, char **end_ptr, int *error) } start_of_number= 0; /* Found digit */ } - ndigits= (uint) (str-old_str); + ndigits= (size_t) (str-old_str); if (next_char == '.' && str < end-1) { @@ -124,7 +125,7 @@ double my_strtod(const char *str, char **end_ptr, int *error) } } /* If we found just '+.' or '.' then point at first character */ - if (!(dec_digits= (uint) (str-old_str)) && start_of_number) + if (!(dec_digits= (size_t) (str-old_str)) && start_of_number) str= start_of_number; /* Point at '+' or '.' */ } if ((next_char == 'e' || next_char == 'E') && diff --git a/strings/strxnmov.c b/strings/strxnmov.c index 377133de69e..16469be6e45 100644 --- a/strings/strxnmov.c +++ b/strings/strxnmov.c @@ -39,7 +39,7 @@ #include "m_string.h" #include <stdarg.h> -char *strxnmov(char *dst,uint len, const char *src, ...) +char *strxnmov(char *dst, size_t len, const char *src, ...) { va_list pvar; char *end_of_dst=dst+len; diff --git a/strings/xml.c b/strings/xml.c index fc6c61c8a3c..5c62a8e8603 100644 --- a/strings/xml.c +++ b/strings/xml.c @@ -110,7 +110,7 @@ static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a) { int lex; - for( ; ( p->cur < p->end) && my_xml_is_space(p->cur[0]) ; p->cur++); + for (; ( p->cur < p->end) && my_xml_is_space(p->cur[0]) ; p->cur++); if (p->cur >= p->end) { @@ -125,7 +125,7 @@ static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a) if ((p->end - p->cur > 3) && !bcmp(p->cur,"<!--",4)) { - for( ; (p->cur < p->end) && bcmp(p->cur, "-->", 3); p->cur++) + for (; (p->cur < p->end) && bcmp(p->cur, "-->", 3); p->cur++) {} if (!bcmp(p->cur, "-->", 3)) p->cur+=3; @@ -155,7 +155,7 @@ static int my_xml_scan(MY_XML_PARSER *p,MY_XML_ATTR *a) else if ( (p->cur[0] == '"') || (p->cur[0] == '\'') ) { p->cur++; - for( ; ( p->cur < p->end ) && (p->cur[0] != a->beg[0]); p->cur++) + for (; ( p->cur < p->end ) && (p->cur[0] != a->beg[0]); p->cur++) {} a->end=p->cur; if (a->beg[0] == p->cur[0])p->cur++; @@ -185,15 +185,15 @@ ret: } -static int my_xml_value(MY_XML_PARSER *st, const char *str, uint len) +static int my_xml_value(MY_XML_PARSER *st, const char *str, size_t len) { return (st->value) ? (st->value)(st,str,len) : MY_XML_OK; } -static int my_xml_enter(MY_XML_PARSER *st, const char *str, uint len) +static int my_xml_enter(MY_XML_PARSER *st, const char *str, size_t len) { - if ((uint) (st->attrend-st->attr+len+1) > sizeof(st->attr)) + if ((size_t) (st->attrend-st->attr+len+1) > sizeof(st->attr)) { sprintf(st->errstr,"To deep XML"); return MY_XML_ERROR; @@ -213,7 +213,7 @@ static int my_xml_enter(MY_XML_PARSER *st, const char *str, uint len) } -static void mstr(char *s,const char *src,uint l1, uint l2) +static void mstr(char *s,const char *src,size_t l1, size_t l2) { l1 = l1<l2 ? l1 : l2; memcpy(s,src,l1); @@ -221,17 +221,17 @@ static void mstr(char *s,const char *src,uint l1, uint l2) } -static int my_xml_leave(MY_XML_PARSER *p, const char *str, uint slen) +static int my_xml_leave(MY_XML_PARSER *p, const char *str, size_t slen) { char *e; - uint glen; + size_t glen; char s[32]; char g[32]; int rc; /* Find previous '/' or beginning */ - for( e=p->attrend; (e>p->attr) && (e[0] != '/') ; e--); - glen = (uint) ((e[0] == '/') ? (p->attrend-e-1) : p->attrend-e); + for (e=p->attrend; (e>p->attr) && (e[0] != '/') ; e--); + glen = (size_t) ((e[0] == '/') ? (p->attrend-e-1) : p->attrend-e); if (str && (slen != glen)) { @@ -249,7 +249,8 @@ static int my_xml_leave(MY_XML_PARSER *p, const char *str, uint slen) if (p->flags & MY_XML_FLAG_RELATIVE_NAMES) rc= p->leave_xml ? p->leave_xml(p, str, slen) : MY_XML_OK; else - rc = p->leave_xml ? p->leave_xml(p,p->attr,p->attrend-p->attr) : MY_XML_OK; + rc= (p->leave_xml ? p->leave_xml(p,p->attr,p->attrend-p->attr) : + MY_XML_OK); *e='\0'; p->attrend=e; @@ -258,7 +259,7 @@ static int my_xml_leave(MY_XML_PARSER *p, const char *str, uint slen) } -int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len) +int my_xml_parse(MY_XML_PARSER *p,const char *str, size_t len) { p->attrend=p->attr; p->beg=str; @@ -283,7 +284,7 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len) { a.beg+= 9; a.end-= 3; - my_xml_value(p, a.beg, (uint) (a.end-a.beg)); + my_xml_value(p, a.beg, (size_t) (a.end-a.beg)); continue; } @@ -296,7 +297,7 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len) sprintf(p->errstr,"%s unexpected (ident wanted)",lex2str(lex)); return MY_XML_ERROR; } - if (MY_XML_OK != my_xml_leave(p,a.beg,(uint) (a.end-a.beg))) + if (MY_XML_OK != my_xml_leave(p,a.beg,(size_t) (a.end-a.beg))) return MY_XML_ERROR; lex=my_xml_scan(p,&a); goto gt; @@ -316,7 +317,7 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len) if (MY_XML_IDENT == lex) { p->current_node_type= MY_XML_NODE_TAG; - if (MY_XML_OK != my_xml_enter(p,a.beg,(uint) (a.end-a.beg))) + if (MY_XML_OK != my_xml_enter(p,a.beg,(size_t) (a.end-a.beg))) return MY_XML_ERROR; } else @@ -336,9 +337,9 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len) if ( (lex == MY_XML_IDENT) || (lex == MY_XML_STRING) ) { p->current_node_type= MY_XML_NODE_ATTR; - if ((MY_XML_OK != my_xml_enter(p,a.beg,(uint) (a.end-a.beg))) || - (MY_XML_OK != my_xml_value(p,b.beg,(uint) (b.end-b.beg))) || - (MY_XML_OK != my_xml_leave(p,a.beg,(uint) (a.end-a.beg)))) + if ((MY_XML_OK != my_xml_enter(p,a.beg,(size_t) (a.end-a.beg))) || + (MY_XML_OK != my_xml_value(p,b.beg,(size_t) (b.end-b.beg))) || + (MY_XML_OK != my_xml_leave(p,a.beg,(size_t) (a.end-a.beg)))) return MY_XML_ERROR; } else @@ -351,8 +352,8 @@ int my_xml_parse(MY_XML_PARSER *p,const char *str, uint len) else if ((MY_XML_STRING == lex) || (MY_XML_IDENT == lex)) { p->current_node_type= MY_XML_NODE_ATTR; - if ((MY_XML_OK != my_xml_enter(p,a.beg,(uint) (a.end-a.beg))) || - (MY_XML_OK != my_xml_leave(p,a.beg,(uint) (a.end-a.beg)))) + if ((MY_XML_OK != my_xml_enter(p,a.beg,(size_t) (a.end-a.beg))) || + (MY_XML_OK != my_xml_leave(p,a.beg,(size_t) (a.end-a.beg)))) return MY_XML_ERROR; } else @@ -401,7 +402,7 @@ gt: my_xml_norm_text(&a); if (a.beg != a.end) { - my_xml_value(p,a.beg,(uint) (a.end-a.beg)); + my_xml_value(p,a.beg,(size_t) (a.end-a.beg)); } } } @@ -428,14 +429,14 @@ void my_xml_parser_free(MY_XML_PARSER *p __attribute__((unused))) void my_xml_set_value_handler(MY_XML_PARSER *p, int (*action)(MY_XML_PARSER *p, const char *s, - uint l)) + size_t l)) { p->value=action; } void my_xml_set_enter_handler(MY_XML_PARSER *p, int (*action)(MY_XML_PARSER *p, const char *s, - uint l)) + size_t l)) { p->enter=action; } @@ -443,7 +444,7 @@ void my_xml_set_enter_handler(MY_XML_PARSER *p, void my_xml_set_leave_handler(MY_XML_PARSER *p, int (*action)(MY_XML_PARSER *p, const char *s, - uint l)) + size_t l)) { p->leave_xml=action; } @@ -461,7 +462,7 @@ const char *my_xml_error_string(MY_XML_PARSER *p) } -uint my_xml_error_pos(MY_XML_PARSER *p) +size_t my_xml_error_pos(MY_XML_PARSER *p) { const char *beg=p->beg; const char *s; @@ -470,7 +471,7 @@ uint my_xml_error_pos(MY_XML_PARSER *p) if (s[0] == '\n') beg=s; } - return (uint) (p->cur-beg); + return (size_t) (p->cur-beg); } uint my_xml_error_lineno(MY_XML_PARSER *p) diff --git a/support-files/compiler_warnings.supp b/support-files/compiler_warnings.supp index 04f5a30bafa..0a2c720b81b 100644 --- a/support-files/compiler_warnings.supp +++ b/support-files/compiler_warnings.supp @@ -51,6 +51,11 @@ db_vrfy.c : .*comparison is always false due to limited range of data type.* .* : conversion from '.*size_t' to 'uint32'.* .* : conversion from '.*size_t' to 'off_t'.* .* : conversion from '.*size_t' to 'size_s'.* +.* : conversion from '.*size_t' to 'DWORD'.* +.* : conversion from '.*size_t' to 'uLongf'.* +.* : conversion from '.*size_t' to 'UINT'.* +.* : conversion from '.*size_t' to 'uInt'.* +.* : conversion from '.*size_t' to 'uint16'.* # # The following should be fixed by the ndb team @@ -64,7 +69,9 @@ db_vrfy.c : .*comparison is always false due to limited range of data type.* # listener.cc : .*conversion from 'SOCKET' to 'int'.* net_serv.cc : .*conversion from 'SOCKET' to 'int'.* -mi_packrec.c : .*result of 32-bit shift implicitly converted to 64 bits.* : 567 + +# allow a little moving space for the warning below +mi_packrec.c : .*result of 32-bit shift implicitly converted to 64 bits.* : 560-600 # # Wrong compiler warnings diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index ceb7e59a97b..a093456427f 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -13717,7 +13717,7 @@ static void test_bug11111() for (i=0; i < 2; i++) { my_bind[i].buffer_type= MYSQL_TYPE_STRING; - my_bind[i].buffer= (gptr *)&buf[i]; + my_bind[i].buffer= (uchar* *)&buf[i]; my_bind[i].buffer_length= 20; my_bind[i].length= &len[i]; } @@ -14102,7 +14102,7 @@ static void test_bug11656() for (i=0; i < 2; i++) { my_bind[i].buffer_type= MYSQL_TYPE_STRING; - my_bind[i].buffer= (gptr *)&buf[i]; + my_bind[i].buffer= (uchar* *)&buf[i]; my_bind[i].buffer_length= strlen(buf[i]); } mysql_stmt_bind_param(stmt, my_bind); @@ -16170,23 +16170,23 @@ static char **defaults_argv; static struct my_option client_test_long_options[] = { - {"basedir", 'b', "Basedir for tests.", (gptr*) &opt_basedir, - (gptr*) &opt_basedir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"count", 't', "Number of times test to be executed", (char **) &opt_count, - (char **) &opt_count, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0}, - {"database", 'D', "Database to use", (char **) &opt_db, (char **) &opt_db, + {"basedir", 'b', "Basedir for tests.", (uchar**) &opt_basedir, + (uchar**) &opt_basedir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"count", 't', "Number of times test to be executed", (uchar **) &opt_count, + (uchar **) &opt_count, 0, GET_UINT, REQUIRED_ARG, 1, 0, 0, 0, 0, 0}, + {"database", 'D', "Database to use", (uchar **) &opt_db, (uchar **) &opt_db, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"debug", '#', "Output debug log", (gptr*) &default_dbug_option, - (gptr*) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, + {"debug", '#', "Output debug log", (uchar**) &default_dbug_option, + (uchar**) &default_dbug_option, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, {"help", '?', "Display this help and exit", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"host", 'h', "Connect to host", (char **) &opt_host, (char **) &opt_host, + {"host", 'h', "Connect to host", (uchar **) &opt_host, (uchar **) &opt_host, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server. If password is not given it's asked from the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Port number to use for connection", (char **) &opt_port, - (char **) &opt_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"port", 'P', "Port number to use for connection", (uchar **) &opt_port, + (uchar **) &opt_port, 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"server-arg", 'A', "Send embedded server this as a parameter.", 0, 0, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"show-tests", 'T', "Show all tests' names", 0, 0, 0, GET_NO_ARG, NO_ARG, @@ -16194,19 +16194,19 @@ static struct my_option client_test_long_options[] = {"silent", 's', "Be more silent", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, {"socket", 'S', "Socket file to use for connection", - (char **) &opt_unix_socket, (char **) &opt_unix_socket, 0, GET_STR, + (uchar **) &opt_unix_socket, (uchar **) &opt_unix_socket, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"testcase", 'c', "May disable some code when runs as mysql-test-run testcase.", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, #ifndef DONT_ALLOW_USER_CHANGE - {"user", 'u', "User for login if not current user", (char **) &opt_user, - (char **) &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"user", 'u', "User for login if not current user", (uchar **) &opt_user, + (uchar **) &opt_user, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #endif - {"vardir", 'v', "Data dir for tests.", (gptr*) &opt_vardir, - (gptr*) &opt_vardir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"vardir", 'v', "Data dir for tests.", (uchar**) &opt_vardir, + (uchar**) &opt_vardir, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"getopt-ll-test", 'g', "Option for testing bug in getopt library", - (char **) &opt_getopt_ll_test, (char **) &opt_getopt_ll_test, 0, + (uchar **) &opt_getopt_ll_test, (uchar **) &opt_getopt_ll_test, 0, GET_LL, REQUIRED_ARG, 0, 0, LONGLONG_MAX, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/tests/thread_test.c b/tests/thread_test.c index 0ad446282c2..b3a34447271 100644 --- a/tests/thread_test.c +++ b/tests/thread_test.c @@ -88,30 +88,30 @@ static struct my_option my_long_options[] = { {"help", '?', "Display this help and exit", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"database", 'D', "Database to use", (gptr*) &database, (gptr*) &database, + {"database", 'D', "Database to use", (uchar**) &database, (uchar**) &database, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"host", 'h', "Connect to host", (gptr*) &host, (gptr*) &host, 0, GET_STR, + {"host", 'h', "Connect to host", (uchar**) &host, (uchar**) &host, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"password", 'p', "Password to use when connecting to server. If password is not given it's asked from the tty.", 0, 0, 0, GET_STR, OPT_ARG, 0, 0, 0, 0, 0, 0}, - {"user", 'u', "User for login if not current user", (gptr*) &user, - (gptr*) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"user", 'u', "User for login if not current user", (uchar**) &user, + (uchar**) &user, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"version", 'V', "Output version information and exit", 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"verbose", 'v', "Write some progress indicators", (gptr*) &verbose, - (gptr*) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, - {"query", 'Q', "Query to execute in each threads", (gptr*) &query, - (gptr*) &query, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, - {"port", 'P', "Port number to use for connection", (gptr*) &tcp_port, - (gptr*) &tcp_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0}, - {"socket", 'S', "Socket file to use for connection", (gptr*) &unix_socket, - (gptr*) &unix_socket, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"verbose", 'v', "Write some progress indicators", (uchar**) &verbose, + (uchar**) &verbose, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0}, + {"query", 'Q', "Query to execute in each threads", (uchar**) &query, + (uchar**) &query, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"port", 'P', "Port number to use for connection", (uchar**) &tcp_port, + (uchar**) &tcp_port, 0, GET_UINT, REQUIRED_ARG, MYSQL_PORT, 0, 0, 0, 0, 0}, + {"socket", 'S', "Socket file to use for connection", (uchar**) &unix_socket, + (uchar**) &unix_socket, 0, GET_STR_ALLOC, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"test-count", 'c', "Run test count times (default %d)", - (gptr*) &number_of_tests, (gptr*) &number_of_tests, 0, GET_UINT, + (uchar**) &number_of_tests, (uchar**) &number_of_tests, 0, GET_UINT, REQUIRED_ARG, 1000, 0, 0, 0, 0, 0}, {"thread-count", 't', "Number of threads to start", - (gptr*) &number_of_threads, (gptr*) &number_of_threads, 0, GET_UINT, + (uchar**) &number_of_threads, (uchar**) &number_of_threads, 0, GET_UINT, REQUIRED_ARG, 2, 0, 0, 0, 0, 0}, { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; diff --git a/vio/test-ssl.c b/vio/test-ssl.c index 76833e25949..855dc5fbb3e 100644 --- a/vio/test-ssl.c +++ b/vio/test-ssl.c @@ -106,8 +106,8 @@ main(int argc, char** argv) child_pid = fork(); if (child_pid==-1) { - my_free((gptr)ssl_acceptor,MYF(0)); - my_free((gptr)ssl_connector,MYF(0)); + my_free((uchar*)ssl_acceptor,MYF(0)); + my_free((uchar*)ssl_connector,MYF(0)); fatal_error("fork"); } if (child_pid==0) @@ -116,28 +116,28 @@ main(int argc, char** argv) char xbuf[100]; int r = vio_read(client_vio,xbuf, sizeof(xbuf)); if (r<=0) { - my_free((gptr)ssl_acceptor,MYF(0)); - my_free((gptr)ssl_connector,MYF(0)); + my_free((uchar*)ssl_acceptor,MYF(0)); + my_free((uchar*)ssl_connector,MYF(0)); fatal_error("client:SSL_read"); } xbuf[r] = 0; printf("client:got %s\n", xbuf); - my_free((gptr)client_vio,MYF(0)); - my_free((gptr)ssl_acceptor,MYF(0)); - my_free((gptr)ssl_connector,MYF(0)); + my_free((uchar*)client_vio,MYF(0)); + my_free((uchar*)ssl_acceptor,MYF(0)); + my_free((uchar*)ssl_connector,MYF(0)); } else { const char* s = "Huhuhuh"; - int r = vio_write(server_vio,(gptr)s, strlen(s)); + int r = vio_write(server_vio,(uchar*)s, strlen(s)); if (r<=0) { - my_free((gptr)ssl_acceptor,MYF(0)); - my_free((gptr)ssl_connector,MYF(0)); + my_free((uchar*)ssl_acceptor,MYF(0)); + my_free((uchar*)ssl_connector,MYF(0)); fatal_error("server:SSL_write"); } - my_free((gptr)server_vio,MYF(0)); - my_free((gptr)ssl_acceptor,MYF(0)); - my_free((gptr)ssl_connector,MYF(0)); + my_free((uchar*)server_vio,MYF(0)); + my_free((uchar*)ssl_acceptor,MYF(0)); + my_free((uchar*)ssl_connector,MYF(0)); } return 0; } diff --git a/vio/test-sslclient.c b/vio/test-sslclient.c index c8e14721375..e1b8461397b 100644 --- a/vio/test-sslclient.c +++ b/vio/test-sslclient.c @@ -84,13 +84,13 @@ main( int argc __attribute__((unused)), sslconnect(ssl_connector,client_vio,60L); err = vio_read(client_vio,xbuf, sizeof(xbuf)); if (err<=0) { - my_free((gptr)ssl_connector,MYF(0)); + my_free((uchar*)ssl_connector,MYF(0)); fatal_error("client:SSL_read"); } xbuf[err] = 0; printf("client:got %s\n", xbuf); - my_free((gptr)client_vio,MYF(0)); - my_free((gptr)ssl_connector,MYF(0)); + my_free((uchar*)client_vio,MYF(0)); + my_free((uchar*)ssl_connector,MYF(0)); return 0; } #else /* HAVE_OPENSSL */ diff --git a/vio/test-sslserver.c b/vio/test-sslserver.c index 59456db1fd4..f55b5bae53a 100644 --- a/vio/test-sslserver.c +++ b/vio/test-sslserver.c @@ -59,9 +59,9 @@ do_ssl_stuff( TH_ARGS* args) /* ----------------------------------------------- */ /* TCP connection is ready. Do server side SSL. */ - err = write(server_vio->sd,(gptr)s, strlen(s)); + err = write(server_vio->sd,(uchar*)s, strlen(s)); sslaccept(args->ssl_acceptor,server_vio,60L); - err = server_vio->write(server_vio,(gptr)s, strlen(s)); + err = server_vio->write(server_vio,(uchar*)s, strlen(s)); DBUG_VOID_RETURN; } @@ -139,12 +139,12 @@ main(int argc __attribute__((unused)), char** argv) #if 0 if (err<=0) { - my_free((gptr)ssl_acceptor,MYF(0)); + my_free((uchar*)ssl_acceptor,MYF(0)); fatal_error("server:SSL_write"); } #endif /* 0 */ - my_free((gptr)ssl_acceptor,MYF(0)); + my_free((uchar*)ssl_acceptor,MYF(0)); return 0; } #else /* HAVE_OPENSSL */ diff --git a/vio/vio.c b/vio/vio.c index 5db54d58a79..e088687098b 100644 --- a/vio/vio.c +++ b/vio/vio.c @@ -228,8 +228,8 @@ void vio_delete(Vio* vio) if (vio->type != VIO_CLOSED) vio->vioclose(vio); - my_free((gptr) vio->read_buffer, MYF(MY_ALLOW_ZERO_PTR)); - my_free((gptr) vio,MYF(0)); + my_free((uchar*) vio->read_buffer, MYF(MY_ALLOW_ZERO_PTR)); + my_free((uchar*) vio,MYF(0)); } diff --git a/vio/vio_priv.h b/vio/vio_priv.h index 4a272e519a3..0a91c134666 100644 --- a/vio/vio_priv.h +++ b/vio/vio_priv.h @@ -27,8 +27,8 @@ void vio_ignore_timeout(Vio *vio, uint which, uint timeout); #ifdef HAVE_OPENSSL #include "my_net.h" /* needed because of struct in_addr */ -int vio_ssl_read(Vio *vio,gptr buf, int size); -int vio_ssl_write(Vio *vio,const gptr buf,int size); +size_t vio_ssl_read(Vio *vio,uchar* buf, size_t size); +size_t vio_ssl_write(Vio *vio,const uchar* buf, size_t size); /* When the workday is over... */ int vio_ssl_close(Vio *vio); diff --git a/vio/viosocket.c b/vio/viosocket.c index d3a479edac3..9afb1ec4bbf 100644 --- a/vio/viosocket.c +++ b/vio/viosocket.c @@ -28,12 +28,12 @@ int vio_errno(Vio *vio __attribute__((unused))) } -int vio_read(Vio * vio, gptr buf, int size) +size_t vio_read(Vio * vio, uchar* buf, size_t size) { - int r; + size_t r; DBUG_ENTER("vio_read"); - DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %d", vio->sd, (long) buf, - size)); + DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %u", vio->sd, (long) buf, + (uint) size)); /* Ensure nobody uses vio_read_buff and vio_read simultaneously */ DBUG_ASSERT(vio->read_end == vio->read_pos); @@ -44,12 +44,12 @@ int vio_read(Vio * vio, gptr buf, int size) r = read(vio->sd, buf, size); #endif /* __WIN__ */ #ifndef DBUG_OFF - if (r < 0) + if (r == (size_t) -1) { DBUG_PRINT("vio_error", ("Got error %d during read",errno)); } #endif /* DBUG_OFF */ - DBUG_PRINT("exit", ("%d", r)); + DBUG_PRINT("exit", ("%ld", (long) r)); DBUG_RETURN(r); } @@ -59,17 +59,17 @@ int vio_read(Vio * vio, gptr buf, int size) reduce number of syscalls. */ -int vio_read_buff(Vio *vio, gptr buf, int size) +size_t vio_read_buff(Vio *vio, uchar* buf, size_t size) { - int rc; + size_t rc; #define VIO_UNBUFFERED_READ_MIN_SIZE 2048 DBUG_ENTER("vio_read_buff"); - DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %d", vio->sd, (long) buf, - size)); + DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %u", vio->sd, (long) buf, + (uint) size)); if (vio->read_pos < vio->read_end) { - rc= min(vio->read_end - vio->read_pos, size); + rc= min((size_t) (vio->read_end - vio->read_pos), size); memcpy(buf, vio->read_pos, rc); vio->read_pos+= rc; /* @@ -81,7 +81,7 @@ int vio_read_buff(Vio *vio, gptr buf, int size) else if (size < VIO_UNBUFFERED_READ_MIN_SIZE) { rc= vio_read(vio, vio->read_buffer, VIO_READ_BUFFER_SIZE); - if (rc > 0) + if (rc != 0 && rc != (size_t) -1) { if (rc > size) { @@ -99,24 +99,24 @@ int vio_read_buff(Vio *vio, gptr buf, int size) } -int vio_write(Vio * vio, const gptr buf, int size) +size_t vio_write(Vio * vio, const uchar* buf, size_t size) { - int r; + size_t r; DBUG_ENTER("vio_write"); - DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %d", vio->sd, (long) buf, - size)); + DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %u", vio->sd, (long) buf, + (uint) size)); #ifdef __WIN__ r = send(vio->sd, buf, size,0); #else r = write(vio->sd, buf, size); #endif /* __WIN__ */ #ifndef DBUG_OFF - if (r < 0) + if (r == (size_t) -1) { DBUG_PRINT("vio_error", ("Got error on write: %d",socket_errno)); } #endif /* DBUG_OFF */ - DBUG_PRINT("exit", ("%d", r)); + DBUG_PRINT("exit", ("%u", (uint) r)); DBUG_RETURN(r); } @@ -405,33 +405,33 @@ void vio_timeout(Vio *vio, uint which, uint timeout) #ifdef __WIN__ -int vio_read_pipe(Vio * vio, gptr buf, int size) +size_t vio_read_pipe(Vio * vio, uchar* buf, size_t size) { DWORD length; DBUG_ENTER("vio_read_pipe"); - DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %d", vio->sd, (long) buf, - size)); + DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %u", vio->sd, (long) buf, + (uint) size)); if (!ReadFile(vio->hPipe, buf, size, &length, NULL)) DBUG_RETURN(-1); DBUG_PRINT("exit", ("%d", length)); - DBUG_RETURN(length); + DBUG_RETURN((size_t) length); } -int vio_write_pipe(Vio * vio, const gptr buf, int size) +size_t vio_write_pipe(Vio * vio, const uchar* buf, size_t size) { DWORD length; DBUG_ENTER("vio_write_pipe"); - DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %d", vio->sd, (long) buf, - size)); + DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %u", vio->sd, (long) buf, + (uint) size)); if (!WriteFile(vio->hPipe, (char*) buf, size, &length, NULL)) DBUG_RETURN(-1); DBUG_PRINT("exit", ("%d", length)); - DBUG_RETURN(length); + DBUG_RETURN((size_t) length); } int vio_close_pipe(Vio * vio) @@ -463,12 +463,11 @@ void vio_ignore_timeout(Vio *vio __attribute__((unused)), #ifdef HAVE_SMEM -int vio_read_shared_memory(Vio * vio, gptr buf, int size) +size_t vio_read_shared_memory(Vio * vio, uchar* buf, size_t size) { - int length; - int remain_local; + size_t length; + size_t remain_local; char *current_postion; - DBUG_ENTER("vio_read_shared_memory"); DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %d", vio->sd, (long) buf, size)); @@ -485,7 +484,8 @@ int vio_read_shared_memory(Vio * vio, gptr buf, int size) /* WaitForMultipleObjects can return next values: WAIT_OBJECT_0+0 - event from vio->event_server_wrote - WAIT_OBJECT_0+1 - event from vio->event_conn_closed. We can't read anything + WAIT_OBJECT_0+1 - event from vio->event_conn_closed. We can't read + anything WAIT_ABANDONED_0 and WAIT_TIMEOUT - fail. We can't read anything */ if (WaitForMultipleObjects(2, (HANDLE*)&events,FALSE, @@ -514,23 +514,23 @@ int vio_read_shared_memory(Vio * vio, gptr buf, int size) remain_local-=length; if (!vio->shared_memory_remain) - if (!SetEvent(vio->event_client_read)) DBUG_RETURN(-1); + { + if (!SetEvent(vio->event_client_read)) + DBUG_RETURN(-1); + } } while (remain_local); length = size; - DBUG_PRINT("exit", ("%d", length)); + DBUG_PRINT("exit", ("%lu", (ulong) length)); DBUG_RETURN(length); } -int vio_write_shared_memory(Vio * vio, const gptr buf, int size) +size_t vio_write_shared_memory(Vio * vio, const uchar* buf, size_t size) { - int length; - uint remain; + size_t length, remain, sz; HANDLE pos; - int sz; - char *current_postion; - + const uchar *current_postion; DBUG_ENTER("vio_write_shared_memory"); DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %d", vio->sd, (long) buf, size)); @@ -539,24 +539,27 @@ int vio_write_shared_memory(Vio * vio, const gptr buf, int size) current_postion = buf; while (remain != 0) { - if (WaitForSingleObject(vio->event_server_read, vio->net->write_timeout*1000) - != WAIT_OBJECT_0) + if (WaitForSingleObject(vio->event_server_read, + vio->net->write_timeout*1000) != + WAIT_OBJECT_0) { - DBUG_RETURN(-1); - }; + DBUG_RETURN((size_t) -1); + } - sz = remain > shared_memory_buffer_length ? shared_memory_buffer_length: remain; + sz= (remain > shared_memory_buffer_length ? shared_memory_buffer_length : + remain); int4store(vio->handle_map,sz); pos = vio->handle_map + 4; memcpy(pos,current_postion,sz); remain-=sz; current_postion+=sz; - if (!SetEvent(vio->event_client_wrote)) DBUG_RETURN(-1); + if (!SetEvent(vio->event_client_wrote)) + DBUG_RETURN((size_t) -1); } length = size; - DBUG_PRINT("exit", ("%d", length)); + DBUG_PRINT("exit", ("%lu", (ulong) length)); DBUG_RETURN(length); } diff --git a/vio/viossl.c b/vio/viossl.c index 5e4203a3fb5..32cfecdb9c8 100644 --- a/vio/viossl.c +++ b/vio/viossl.c @@ -82,35 +82,36 @@ report_errors(SSL* ssl) } -int vio_ssl_read(Vio *vio, gptr buf, int size) +size_t vio_ssl_read(Vio *vio, uchar* buf, size_t size) { - int r; + size_t r; DBUG_ENTER("vio_ssl_read"); - DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %d ssl: 0x%lx", - vio->sd, (long) buf, size, (long) vio->ssl_arg)); + DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %u ssl: 0x%lx", + vio->sd, (long) buf, (uint) size, (long) vio->ssl_arg)); r= SSL_read((SSL*) vio->ssl_arg, buf, size); #ifndef DBUG_OFF - if (r < 0) + if (r == (size_t) -1) report_errors((SSL*) vio->ssl_arg); #endif - DBUG_PRINT("exit", ("%d", r)); + DBUG_PRINT("exit", ("%u", (uint) r)); DBUG_RETURN(r); } -int vio_ssl_write(Vio *vio, const gptr buf, int size) +size_t vio_ssl_write(Vio *vio, const uchar* buf, size_t size) { - int r; + size_t r; DBUG_ENTER("vio_ssl_write"); - DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %d", vio->sd, (long) buf, size)); + DBUG_PRINT("enter", ("sd: %d buf: 0x%lx size: %u", vio->sd, + (long) buf, (uint) size)); r= SSL_write((SSL*) vio->ssl_arg, buf, size); #ifndef DBUG_OFF - if (r < 0) + if (r == (size_t) -1) report_errors((SSL*) vio->ssl_arg); #endif - DBUG_PRINT("exit", ("%d", r)); + DBUG_PRINT("exit", ("%u", (uint) r)); DBUG_RETURN(r); } @@ -123,8 +124,7 @@ int vio_ssl_close(Vio *vio) if (ssl) { - switch ((r= SSL_shutdown(ssl))) - { + switch ((r= SSL_shutdown(ssl))) { case 1: /* Shutdown successful */ break; diff --git a/vio/viosslfactories.c b/vio/viosslfactories.c index d26d4147c9f..d7e4f380bc1 100644 --- a/vio/viosslfactories.c +++ b/vio/viosslfactories.c @@ -378,6 +378,6 @@ new_VioSSLAcceptorFd(const char *key_file, const char *cert_file, void free_vio_ssl_acceptor_fd(struct st_VioSSLFd *fd) { SSL_CTX_free(fd->ssl_context); - my_free((gptr) fd, MYF(0)); + my_free((uchar*) fd, MYF(0)); } #endif /* HAVE_OPENSSL */ diff --git a/vio/viotest-ssl.c b/vio/viotest-ssl.c index 81d119ff207..b8abbac4ed6 100644 --- a/vio/viotest-ssl.c +++ b/vio/viotest-ssl.c @@ -106,8 +106,8 @@ int main(int argc, char **argv) child_pid = fork(); if (child_pid==-1) { - my_free((gptr)ssl_acceptor,MYF(0)); - my_free((gptr)ssl_connector,MYF(0)); + my_free((uchar*)ssl_acceptor,MYF(0)); + my_free((uchar*)ssl_connector,MYF(0)); fatal_error("fork"); } if (child_pid==0) @@ -116,29 +116,29 @@ int main(int argc, char **argv) char xbuf[100]; int r = vio_ssl_read(client_vio,xbuf, sizeof(xbuf)); if (r<=0) { - my_free((gptr)ssl_acceptor,MYF(0)); - my_free((gptr)ssl_connector,MYF(0)); + my_free((uchar*)ssl_acceptor,MYF(0)); + my_free((uchar*)ssl_connector,MYF(0)); fatal_error("client:SSL_read"); } xbuf[r] = 0; printf("client:got %s\n", xbuf); - my_free((gptr)client_vio,MYF(0)); - my_free((gptr)ssl_acceptor,MYF(0)); - my_free((gptr)ssl_connector,MYF(0)); + my_free((uchar*)client_vio,MYF(0)); + my_free((uchar*)ssl_acceptor,MYF(0)); + my_free((uchar*)ssl_connector,MYF(0)); sleep(1); } else { const char* s = "Huhuhuh"; - int r = vio_ssl_write(server_vio,(gptr)s, strlen(s)); + int r = vio_ssl_write(server_vio,(uchar*)s, strlen(s)); if (r<=0) { - my_free((gptr)ssl_acceptor,MYF(0)); - my_free((gptr)ssl_connector,MYF(0)); + my_free((uchar*)ssl_acceptor,MYF(0)); + my_free((uchar*)ssl_connector,MYF(0)); fatal_error("server:SSL_write"); } - my_free((gptr)server_vio,MYF(0)); - my_free((gptr)ssl_acceptor,MYF(0)); - my_free((gptr)ssl_connector,MYF(0)); + my_free((uchar*)server_vio,MYF(0)); + my_free((uchar*)ssl_acceptor,MYF(0)); + my_free((uchar*)ssl_connector,MYF(0)); sleep(1); } return 0; diff --git a/win/README b/win/README index 1e45b92abb2..fbcdfd068b8 100644 --- a/win/README +++ b/win/README @@ -35,7 +35,7 @@ the link named "Complete package, excluding sources". This includes an installer that will install bison. After the installer finishes, modify your path so that you can execute bison. -(Alternative you, can take the sql_yacc.yy and sql_yacc.h files from a +(As an alternative you can take the sql_yacc.yy and sql_yacc.h files from a matching mysql tar distribution and drop them into the sql directory just before you start the build) @@ -45,8 +45,11 @@ Clone your bk tree to any location you like. Step 5 ------ -From the root of your bk clone, execute the command: win\configure <options>. -The options right now are +From the root of your installation directory, execute the command: + +win\configure <options> + +The options right now are: WITH_INNOBASE_STORAGE_ENGINE Enable particular storage engines WITH_PARTITION_STORAGE_ENGINE @@ -68,8 +71,9 @@ win\configure WITH_INNOBASE_STORAGE_ENGINE WITH_PARTITION_STORAGE_ENGINE MYSQL_S Step 6 ------ -From the root of your bk clone, execute one of the batch files to generate the type -of project files you desire. + +From the root of your installation directory/bk clone, execute one of +the batch files to generate the type of project files you desire. For Visual Studio 8 (or Visual C++ 2005 express edition), do win\build-vs8. For Visual Studio 7.1, do win\build-vs71. @@ -80,8 +84,8 @@ Step 7 ------ From the root of your bk clone, start your build. -For Visual Studio, simply execute mysql.sln. This will start the IDE and you can -click the build solution menu option. +For Visual Studio, execute mysql.sln. This will start the IDE +and you can click the build solution menu option. Current issues -------------- |