summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <monty@mishka.local>2005-07-18 15:33:18 +0300
committerunknown <monty@mishka.local>2005-07-18 15:33:18 +0300
commit68b4d7b74d80062b09edfdaeb7137c74b3071346 (patch)
tree1505fc52926154e1f91d7d822237aa1b9352cb3f
parenta1da992f4f3da5a5c84a819c80dd5d09db9c66d8 (diff)
downloadmariadb-git-68b4d7b74d80062b09edfdaeb7137c74b3071346.tar.gz
Cleanups during review
Changed defaults option --instance to --defaults-group-suffix Changed option handling to allow --defaults-file, --defaults-extra-file and --defaults-group-suffix to be given in any order Changed MYSQL_INSTANCE to MYSQL_GROUP_SUFFIX mysql_print_defaults now understands --defaults-group-suffix Remove usage of my_tempnam() (not safe function) if( -> if ( and while( to while ( BitKeeper/deleted/.del-my_tempnam.c~a8562f15dad3012f: Delete: mysys/my_tempnam.c VC++Files/client/mysqlclient.dsp: Remove not used file my_tempnam.c VC++Files/client/mysqlclient_ia64.dsp: Remove not used file my_tempnam.c VC++Files/libmysql/libmysql.dsp: Remove not used file my_tempnam.c VC++Files/libmysql/libmysql_ia64.dsp: Remove not used file my_tempnam.c VC++Files/mysys/mysys.dsp: Remove not used file my_tempnam.c VC++Files/mysys/mysys_ia64.dsp: Remove not used file my_tempnam.c client/mysql.cc: Change to use get_defaults_options() Remove compiler warnings client/mysqldump.c: Indentation fixes Use quoted table name for 'primary_key_fields' extra/my_print_defaults.c: Add support for --defaults-group-suffix change to use get_default_options() extra/replace.c: Replace my_tempnam() with create_tmp_file() to allow us to remove my_tempnam.c include/config-win.h: Added DEFAULT_GROUP_SUFFIX_ENV include/my_sys.h: Change defaults_instance -> defaults_group_suffix Change get_defaults_files -> get_defaults_options libmysql/Makefile.shared: Added DEFAULT_GROUP_SUFFIX_ENV mysys/Makefile.am: Added DEFAULT_GROUP_SUFFIX_ENV Remove my_tempnam.c mysys/default.c: Changed --instance to --defaults-group-suffix Changed MYSQL_INSTANCE to MYSQL_GROUP_SUFFIX and moved the name to Makefile.am (mysys shouldn't by MySQL independent) Changed option handling to allow --defaults-file, --defaults-extra-file and --defaults-group-suffix to be given in any order mysys/default_modify.c: Optimized code to use allocated space more efficently Reduce code size Ensure that realloc() works independent of argument size mysys/my_bitmap.c: Added missing return sql/ha_innodb.cc: Change if( -> if ( sql/ha_ndbcluster.cc: Change while( -> while ( sql/item_cmpfunc.cc: Break loop early (simple optimization) sql/item_strfunc.cc: Change if( -> if ( sql/log.cc: Fixed comment sql/mysqld.cc: Change if( -> if ( sql/opt_range.cc: while( -> while ( if( -> if ( sql/parse_file.cc: Change if( -> if ( sql/sql_cache.cc: while( -> while ( sql/sql_parse.cc: Change if( -> if ( sql/sql_prepare.cc: Added comment sql/sql_select.cc: while( -> while ( Removed index variable by incrementing pointer sql/sql_show.cc: Change if( -> if ( sql/sql_yacc.yy: Change if( -> if ( tests/mysql_client_test.c: Added cast to first argument to bzero()
-rw-r--r--VC++Files/client/mysqlclient.dsp4
-rw-r--r--VC++Files/client/mysqlclient_ia64.dsp4
-rw-r--r--VC++Files/libmysql/libmysql.dsp4
-rw-r--r--VC++Files/libmysql/libmysql_ia64.dsp4
-rw-r--r--VC++Files/mysys/mysys.dsp4
-rw-r--r--VC++Files/mysys/mysys_ia64.dsp4
-rw-r--r--client/mysql.cc26
-rw-r--r--client/mysqldump.c13
-rw-r--r--extra/my_print_defaults.c46
-rw-r--r--extra/replace.c21
-rw-r--r--include/config-win.h3
-rw-r--r--include/my_sys.h7
-rw-r--r--libmysql/Makefile.shared1
-rw-r--r--mysys/Makefile.am3
-rw-r--r--mysys/default.c190
-rw-r--r--mysys/default_modify.c65
-rw-r--r--mysys/my_bitmap.c1
-rw-r--r--mysys/my_tempnam.c173
-rw-r--r--sql/ha_innodb.cc6
-rw-r--r--sql/ha_ndbcluster.cc4
-rw-r--r--sql/item_cmpfunc.cc8
-rw-r--r--sql/item_strfunc.cc2
-rw-r--r--sql/log.cc2
-rw-r--r--sql/mysqld.cc2
-rw-r--r--sql/opt_range.cc18
-rw-r--r--sql/parse_file.cc2
-rw-r--r--sql/sql_cache.cc2
-rw-r--r--sql/sql_parse.cc2
-rw-r--r--sql/sql_prepare.cc6
-rw-r--r--sql/sql_select.cc11
-rw-r--r--sql/sql_show.cc2
-rw-r--r--sql/sql_yacc.yy2
-rw-r--r--tests/mysql_client_test.c142
33 files changed, 315 insertions, 469 deletions
diff --git a/VC++Files/client/mysqlclient.dsp b/VC++Files/client/mysqlclient.dsp
index c0d891b1c9a..5499379be8d 100644
--- a/VC++Files/client/mysqlclient.dsp
+++ b/VC++Files/client/mysqlclient.dsp
@@ -451,10 +451,6 @@ SOURCE=..\mysys\my_symlink2.c
# End Source File
# Begin Source File
-SOURCE=..\mysys\my_tempnam.c
-# End Source File
-# Begin Source File
-
SOURCE=..\libmysql\my_time.c
# End Source File
# Begin Source File
diff --git a/VC++Files/client/mysqlclient_ia64.dsp b/VC++Files/client/mysqlclient_ia64.dsp
index e38f37d61e6..b982b3b281c 100644
--- a/VC++Files/client/mysqlclient_ia64.dsp
+++ b/VC++Files/client/mysqlclient_ia64.dsp
@@ -436,10 +436,6 @@ SOURCE=..\mysys\my_symlink2.c
# End Source File
# Begin Source File
-SOURCE=..\mysys\my_tempnam.c
-# End Source File
-# Begin Source File
-
SOURCE=..\mysys\my_thr_init.c
# End Source File
# Begin Source File
diff --git a/VC++Files/libmysql/libmysql.dsp b/VC++Files/libmysql/libmysql.dsp
index 356aac3563f..883557e7b63 100644
--- a/VC++Files/libmysql/libmysql.dsp
+++ b/VC++Files/libmysql/libmysql.dsp
@@ -419,10 +419,6 @@ SOURCE=..\mysys\my_symlink2.c
# End Source File
# Begin Source File
-SOURCE=..\mysys\my_tempnam.c
-# End Source File
-# Begin Source File
-
SOURCE=..\mysys\my_thr_init.c
# End Source File
# Begin Source File
diff --git a/VC++Files/libmysql/libmysql_ia64.dsp b/VC++Files/libmysql/libmysql_ia64.dsp
index 75586ef2cf6..717125d5497 100644
--- a/VC++Files/libmysql/libmysql_ia64.dsp
+++ b/VC++Files/libmysql/libmysql_ia64.dsp
@@ -406,10 +406,6 @@ SOURCE=..\mysys\my_symlink2.c
# End Source File
# Begin Source File
-SOURCE=..\mysys\my_tempnam.c
-# End Source File
-# Begin Source File
-
SOURCE=..\mysys\my_thr_init.c
# End Source File
# Begin Source File
diff --git a/VC++Files/mysys/mysys.dsp b/VC++Files/mysys/mysys.dsp
index ab5077810b2..e239318d54d 100644
--- a/VC++Files/mysys/mysys.dsp
+++ b/VC++Files/mysys/mysys.dsp
@@ -533,10 +533,6 @@ SOURCE=.\my_sync.c
# End Source File
# Begin Source File
-SOURCE=.\my_tempnam.c
-# End Source File
-# Begin Source File
-
SOURCE=.\my_thr_init.c
# End Source File
# Begin Source File
diff --git a/VC++Files/mysys/mysys_ia64.dsp b/VC++Files/mysys/mysys_ia64.dsp
index a0877457286..b0ce2b4c579 100644
--- a/VC++Files/mysys/mysys_ia64.dsp
+++ b/VC++Files/mysys/mysys_ia64.dsp
@@ -526,10 +526,6 @@ SOURCE=.\my_sync.c
# End Source File
# Begin Source File
-SOURCE=.\my_tempnam.c
-# End Source File
-# Begin Source File
-
SOURCE=.\my_thr_init.c
# End Source File
# Begin Source File
diff --git a/client/mysql.cc b/client/mysql.cc
index f98bf467588..871936d7800 100644
--- a/client/mysql.cc
+++ b/client/mysql.cc
@@ -44,7 +44,7 @@
#include <locale.h>
#endif
-const char *VER= "14.11";
+const char *VER= "14.12";
/* Don't try to make a nice table if the data is too big */
#define MAX_COLUMN_LENGTH 1024
@@ -340,16 +340,15 @@ static sig_handler mysql_end(int sig);
int main(int argc,char *argv[])
{
char buff[80];
- char *defaults, *extra_defaults;
- char *emb_argv[3];
- int emb_argc= 1;
+ char *defaults, *extra_defaults, *group_suffix;
+ char *emb_argv[4];
+ int emb_argc;
- emb_argv[0]= argv[0];
- get_defaults_files(argc, argv, &defaults, &extra_defaults);
- if (defaults)
- emb_argv[emb_argc++]= defaults;
- if (extra_defaults)
- emb_argv[emb_argc++]= extra_defaults;
+ /* Get --defaults-xxx args for mysql_server_init() */
+ emb_argc= get_defaults_options(argc, argv, &defaults, &extra_defaults,
+ &group_suffix)+1;
+ memcpy((char*) emb_argv, (char*) argv, emb_argc * sizeof(*argv));
+ emb_argv[emb_argc]= 0;
MY_INIT(argv[0]);
DBUG_ENTER("main");
@@ -2060,6 +2059,7 @@ static void end_tee()
return;
}
+
static int
com_ego(String *buffer,char *line)
{
@@ -2071,8 +2071,10 @@ com_ego(String *buffer,char *line)
return result;
}
-static char *fieldtype2str(enum enum_field_types type) {
- switch(type) {
+
+static const char *fieldtype2str(enum enum_field_types type)
+{
+ switch (type) {
case FIELD_TYPE_BIT: return "BIT";
case FIELD_TYPE_BLOB: return "BLOB";
case FIELD_TYPE_DATE: return "DATE";
diff --git a/client/mysqldump.c b/client/mysqldump.c
index b2bf23c3e3a..28da11f5f9a 100644
--- a/client/mysqldump.c
+++ b/client/mysqldump.c
@@ -1212,7 +1212,7 @@ static uint get_table_structure(char *table, char *db)
opt_quoted_table= quote_name(table, table_buff2, 0);
if (opt_order_by_primary)
- order_by = primary_key_fields(opt_quoted_table);
+ order_by = primary_key_fields(result_table);
if (!opt_xml && !mysql_query_with_error_report(sock, 0, query_buff))
{
@@ -1272,7 +1272,7 @@ static uint get_table_structure(char *table, char *db)
/* Create temp table by selecting from the view */
my_snprintf(query_buff, sizeof(query_buff),
- "CREATE TEMPORARY TABLE %s SELECT * FROM %s WHERE 0",
+ "CREATE TEMPORARY TABLE %s SELECT * FROM %s WHERE 0",
result_table, result_table);
if (mysql_query_with_error_report(sock, 0, query_buff))
{
@@ -1391,7 +1391,7 @@ static uint get_table_structure(char *table, char *db)
fprintf(sql_file, "\n--\n-- Table structure for table %s\n--\n\n",
result_table);
if (opt_drop)
- fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n",result_table);
+ fprintf(sql_file, "DROP TABLE IF EXISTS %s;\n", result_table);
if (!opt_xml)
fprintf(sql_file, "CREATE TABLE %s (\n", result_table);
else
@@ -2773,6 +2773,7 @@ static const char *check_if_ignore_table(const char *table_name)
or if there is some failure. It is better to continue to dump
the table unsorted, rather than exit without dumping the data.
*/
+
static char *primary_key_fields(const char *table_name)
{
MYSQL_RES *res = NULL;
@@ -2809,11 +2810,13 @@ static char *primary_key_fields(const char *table_name)
}
/* Build the ORDER BY clause result */
- if (result_length) {
+ if (result_length)
+ {
char *end;
/* result (terminating \0 is already in result_length) */
result = my_malloc(result_length + 10, MYF(MY_WME));
- if (!result) {
+ if (!result)
+ {
fprintf(stderr, "Error: Not enough memory to store ORDER BY clause\n");
goto cleanup;
}
diff --git a/extra/my_print_defaults.c b/extra/my_print_defaults.c
index 946ac219e1a..916203bc7d7 100644
--- a/extra/my_print_defaults.c
+++ b/extra/my_print_defaults.c
@@ -1,3 +1,4 @@
+
/* Copyright (C) 2000 MySQL AB
This program is free software; you can redistribute it and/or modify
@@ -23,8 +24,10 @@
#include <my_global.h>
#include <my_sys.h>
+#include <m_string.h>
#include <my_getopt.h>
+
const char *config_file="my"; /* Default config file */
uint verbose= 0, opt_defaults_file_used= 0;
const char *default_dbug_option="d:t:o,/tmp/my_print_defaults.trace";
@@ -48,6 +51,10 @@ static struct my_option my_long_options[] =
"Read this file after the global /etc config file and before the config file in the users home directory.",
(gptr*) &defaults_extra_file, (gptr*) &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*) &defaults_group_suffix, (gptr*) &defaults_group_suffix,
+ 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0},
{"extra-file", 'e',
"Synonym for --defaults-extra-file.",
(gptr*) &defaults_extra_file, (gptr*) &defaults_extra_file, 0, GET_STR,
@@ -127,37 +134,32 @@ static int get_options(int *argc,char ***argv)
return 0;
}
+
int main(int argc, char **argv)
{
- int count, error;
- char **load_default_groups, *tmp_arguments[3],
- **argument, **arguments;
- char *defaults, *extra_defaults;
+ int count, error, args_used;
+ char **load_default_groups, *tmp_arguments[6];
+ char **argument, **arguments, **org_argv;
+ char *defaults, *extra_defaults, *group_suffix;
MY_INIT(argv[0]);
- get_defaults_files(argc, argv, &defaults, &extra_defaults);
+ org_argv= argv;
+ args_used= get_defaults_options(argc, argv, &defaults, &extra_defaults,
+ &group_suffix);
- /*
- ** Check out the args
- */
- if (!(load_default_groups=(char**) my_malloc((argc+2)*sizeof(char*),
+ /* Copy defaults-xxx arguments & program name */
+ count=args_used+1;
+ arguments= tmp_arguments;
+ memcpy((char*) arguments, (char*) org_argv, count * sizeof(*org_argv));
+ arguments[count]= 0;
+
+ /* Check out the args */
+ if (!(load_default_groups=(char**) my_malloc((argc+1)*sizeof(char*),
MYF(MY_WME))))
exit(1);
if (get_options(&argc,&argv))
exit(1);
-
- for (count=0; *argv ; argv++,count++)
- load_default_groups[count]= *argv;
- load_default_groups[count]=0;
-
- count=0;
- arguments=tmp_arguments;
- arguments[count++]=my_progname;
- if (extra_defaults)
- arguments[count++]= extra_defaults;
- if (defaults)
- arguments[count++]= defaults;
- arguments[count]= 0;
+ memcpy((char*) load_default_groups, (char*) argv, (argc + 1) * sizeof(*argv));
if ((error= load_defaults(config_file, (const char **) load_default_groups,
&count, &arguments)))
diff --git a/extra/replace.c b/extra/replace.c
index d92355359d3..0b7d9600232 100644
--- a/extra/replace.c
+++ b/extra/replace.c
@@ -175,7 +175,7 @@ register char **argv[];
case 'I':
case '?':
help=1; /* Help text written */
- printf("%s Ver 1.3 for %s at %s\n",my_progname,SYSTEM_TYPE,
+ printf("%s Ver 1.4 for %s at %s\n",my_progname,SYSTEM_TYPE,
MACHINE_TYPE);
if (version)
break;
@@ -1048,23 +1048,25 @@ FILE *in,*out;
}
-static int convert_file(rep,name)
-REPLACE *rep;
-my_string name;
+static int convert_file(REPLACE *rep, my_string name)
{
int error;
FILE *in,*out;
- char dir_buff[FN_REFLEN],*tempname;
+ char dir_buff[FN_REFLEN], tempname[FN_REFLEN];
+ File temp_file;
DBUG_ENTER("convert_file");
if (!(in=my_fopen(name,O_RDONLY,MYF(MY_WME))))
DBUG_RETURN(1);
dirname_part(dir_buff,name);
- tempname=my_tempnam(dir_buff,"PR",MYF(MY_WME));
- if (!(out=my_fopen(tempname,(int) (O_WRONLY | O_CREAT),
- MYF(MY_WME))))
+ if ((temp_file= create_temp_file(tempname, dir_buff, "PR", O_WRONLY,
+ MYF(MY_WME))) < 0)
+ {
+ my_fclose(in,MYF(0));
+ DBUG_RETURN(1);
+ }
+ if (!(out= my_fdopen(temp_file, tempname, O_WRONLY, MYF(MY_WME))))
{
- (*free)(tempname);
my_fclose(in,MYF(0));
DBUG_RETURN(1);
}
@@ -1076,7 +1078,6 @@ my_string name;
my_redel(name,tempname,MYF(MY_WME | MY_LINK_WARNING));
else
my_delete(tempname,MYF(MY_WME));
- (*free)(tempname);
if (!silent && ! error)
{
if (updated)
diff --git a/include/config-win.h b/include/config-win.h
index 2559b3b74fd..6e0740497b0 100644
--- a/include/config-win.h
+++ b/include/config-win.h
@@ -353,6 +353,9 @@ inline double ulonglong2double(ulonglong value)
#ifndef DEFAULT_HOME_ENV
#define DEFAULT_HOME_ENV MYSQL_HOME
#endif
+#ifndef DEFAULT_GROUP_SUFFIX_ENV
+#define DEFAULT_GROUP_SUFFIX_ENV MYSQL_GROUP_SUFFIX
+#endif
/* File name handling */
diff --git a/include/my_sys.h b/include/my_sys.h
index a3d6f6827d3..a7304b8c952 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -263,7 +263,7 @@ extern my_bool NEAR my_disable_locking,NEAR my_disable_async_io,
extern char wild_many,wild_one,wild_prefix;
extern const char *charsets_dir;
extern char *defaults_extra_file;
-extern const char *defaults_instance;
+extern const char *defaults_group_suffix;
extern my_bool timed_mutexes;
@@ -785,8 +785,9 @@ extern void reset_root_defaults(MEM_ROOT *mem_root, uint block_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 void get_defaults_files(int argc, char **argv,
- char **defaults, char **extra_defaults);
+extern int get_defaults_options(int argc, char **argv,
+ char **defaults, char **extra_defaults,
+ char **group_suffix);
extern int load_defaults(const char *conf_file, const char **groups,
int *argc, char ***argv);
extern int modify_defaults_file(const char *file_location, const char *option,
diff --git a/libmysql/Makefile.shared b/libmysql/Makefile.shared
index a2bfa616f6b..fab1a402c1e 100644
--- a/libmysql/Makefile.shared
+++ b/libmysql/Makefile.shared
@@ -84,6 +84,7 @@ CLEANFILES = $(target_libadd) $(SHLIBOBJS) \
DEFS = -DDEFAULT_CHARSET_HOME="\"$(MYSQLBASEdir)\"" \
-DDATADIR="\"$(MYSQLDATAdir)\"" \
-DDEFAULT_HOME_ENV=MYSQL_HOME \
+ -DDEFAULT_GROUP_SUFFIX_ENV=MYSQL_GROUP_SUFFIX \
-DSHAREDIR="\"$(MYSQLSHAREdir)\"" $(target_defs)
# The automatic dependencies miss this
diff --git a/mysys/Makefile.am b/mysys/Makefile.am
index 03ee692645f..0007a8808bd 100644
--- a/mysys/Makefile.am
+++ b/mysys/Makefile.am
@@ -44,7 +44,7 @@ libmysys_a_SOURCES = my_init.c my_getwd.c mf_getdate.c my_mmap.c \
ptr_cmp.c mf_radix.c queues.c \
tree.c list.c hash.c array.c string.c typelib.c \
my_copy.c my_append.c my_lib.c \
- my_delete.c my_rename.c my_redel.c my_tempnam.c \
+ my_delete.c my_rename.c my_redel.c \
my_chsize.c my_lread.c my_lwrite.c my_clock.c \
my_quick.c my_lockmem.c my_static.c \
my_sync.c my_getopt.c my_mkdir.c \
@@ -68,6 +68,7 @@ DEFS = -DDEFAULT_BASEDIR=\"$(prefix)\" \
-DDEFAULT_CHARSET_HOME="\"$(MYSQLBASEdir)\"" \
-DSHAREDIR="\"$(MYSQLSHAREdir)\"" \
-DDEFAULT_HOME_ENV=MYSQL_HOME \
+ -DDEFAULT_GROUP_SUFFIX_ENV=MYSQL_GROUP_SUFFIX \
@DEFS@
libmysys_a_DEPENDENCIES= @THREAD_LOBJECTS@
diff --git a/mysys/default.c b/mysys/default.c
index 1fa8deaa65c..994749f1c54 100644
--- a/mysys/default.c
+++ b/mysys/default.c
@@ -30,8 +30,8 @@
--no-defaults ; no options are read.
--defaults-file=full-path-to-default-file ; Only this file will be read.
--defaults-extra-file=full-path-to-default-file ; Read this file before ~/
- --print-defaults ; Print the modified command line and exit
- --instance ; also read groups with concat(group, instance)
+ --defaults-group-suffix ; Also read groups with concat(group, suffix)
+ --print-defaults ; Print the modified command line and exit
****************************************************************************/
#include "mysys_priv.h"
@@ -42,8 +42,7 @@
#include <winbase.h>
#endif
-const char *defaults_instance=0;
-static const char instance_option[] = "--instance=";
+const char *defaults_group_suffix=0;
char *defaults_extra_file=0;
/* Which directories are searched for options (and in which order) */
@@ -60,6 +59,9 @@ static const char *f_extensions[]= { ".cnf", 0 };
#define NEWLINE "\n"
#endif
+static int handle_default_option(void *in_ctx, const char *group_name,
+ const char *option);
+
/*
This structure defines the context that we pass to callback
function 'handle_default_option' used in search_default_file
@@ -100,35 +102,81 @@ static char *remove_end_comment(char *ptr);
func_ctx It's context. Usually it is the structure to
store additional options.
DESCRIPTION
+ Process the default options from argc & argv
+ Read through each found config file looks and calls 'func' to process
+ each option.
+
+ NOTES
+ --defaults-group-suffix is only processed if we are called from
+ load_defaults().
- This function looks for config files in default directories. Then it
- travesrses each of the files and calls func to process each option.
RETURN
0 ok
1 given cinf_file doesn't exist
+
+ The global variable 'defaults_group_suffix' is updated with value for
+ --defaults_group_suffix
*/
int my_search_option_files(const char *conf_file, int *argc, char ***argv,
- uint *args_used, Process_option_func func,
- void *func_ctx)
+ uint *args_used, Process_option_func func,
+ void *func_ctx)
{
const char **dirs, *forced_default_file, *forced_extra_defaults;
int error= 0;
DBUG_ENTER("my_search_option_files");
/* Check if we want to force the use a specific default file */
- get_defaults_files(*argc - *args_used, *argv + *args_used,
- (char **)&forced_default_file,
- (char **)&forced_extra_defaults);
- if (forced_default_file)
- forced_default_file= strchr(forced_default_file,'=')+1;
- if (forced_extra_defaults)
- defaults_extra_file= strchr(forced_extra_defaults,'=')+1;
+ *args_used+= get_defaults_options(*argc - *args_used, *argv + *args_used,
+ (char **) &forced_default_file,
+ (char **) &forced_extra_defaults,
+ (char **) &defaults_group_suffix);
- (*args_used)+= (forced_default_file ? 1 : 0) +
- (forced_extra_defaults ? 1 : 0);
+ if (! defaults_group_suffix)
+ defaults_group_suffix= getenv(STRINGIFY_ARG(DEFAULT_GROUP_SUFFIX_ENV));
+
+ /*
+ We can only handle 'defaults-group-suffix' if we are called from
+ load_defaults() as otherwise we can't know the type of 'func_ctx'
+ */
+ if (defaults_group_suffix && func == handle_default_option)
+ {
+ /* Handle --defaults-group-suffix= */
+ uint i;
+ const char **extra_groups;
+ const uint instance_len= strlen(defaults_group_suffix);
+ struct handle_option_ctx *ctx= (struct handle_option_ctx*) func_ctx;
+ char *ptr;
+ TYPELIB *group= ctx->group;
+
+ if (!(extra_groups=
+ (const char**)alloc_root(ctx->alloc,
+ (2*group->count+1)*sizeof(char*))))
+ goto err;
+
+ for (i= 0; i < group->count; i++)
+ {
+ uint len;
+ extra_groups[i]= group->type_names[i]; /** copy group */
+
+ len= strlen(extra_groups[i]);
+ if (!(ptr= alloc_root(ctx->alloc, len+instance_len+1)))
+ goto err;
+
+ extra_groups[i+group->count]= ptr;
+
+ /** Construct new group */
+ memcpy(ptr, extra_groups[i], len);
+ memcpy(ptr+len, defaults_group_suffix, instance_len+1);
+ }
+
+ group->count*= 2;
+ group->type_names= extra_groups;
+ group->type_names[group->count]= 0;
+ }
+
if (forced_default_file)
{
if ((error= search_default_file_with_ext(func, func_ctx, "", "",
@@ -221,32 +269,54 @@ static int handle_default_option(void *in_ctx, const char *group_name,
/*
- Gets --defaults-file and --defaults-extra-file options from command line.
+ Gets options from the command line
SYNOPSIS
- get_defaults_files()
+ get_defaults_options()
argc Pointer to argc of original program
argv Pointer to argv of original program
defaults --defaults-file option
extra_defaults --defaults-extra-file option
RETURN
- defaults and extra_defaults will be set to appropriate items
- of argv array, or to NULL if there are no such options
+ # Number of arguments used from *argv
+ defaults and extra_defaults will be set to option of the appropriate
+ items of argv array, or to NULL if there are no such options
*/
-void get_defaults_files(int argc, char **argv,
- char **defaults, char **extra_defaults)
+int get_defaults_options(int argc, char **argv,
+ char **defaults,
+ char **extra_defaults,
+ char **group_suffix)
{
- *defaults=0;
- *extra_defaults=0;
- if (argc >= 2)
+ int org_argc= argc, prev_argc= 0;
+ *defaults= *extra_defaults= *group_suffix= 0;
+
+ while (argc >= 2 && argc != prev_argc)
{
- if (is_prefix(argv[1],"--defaults-file="))
- *defaults= argv[1];
- else if (is_prefix(argv[1],"--defaults-extra-file="))
- *extra_defaults= argv[1];
+ /* Skip program name or previously handled argument */
+ argv++;
+ prev_argc= argc; /* To check if we found */
+ if (!*defaults && is_prefix(*argv,"--defaults-file="))
+ {
+ *defaults= *argv + sizeof("--defaults-file=")-1;
+ argc--;
+ continue;
+ }
+ if (!*extra_defaults && is_prefix(*argv,"--defaults-extra-file="))
+ {
+ *extra_defaults= *argv + sizeof("--defaults-extra-file=")-1;
+ argc--;
+ continue;
+ }
+ if (!*group_suffix && is_prefix(*argv, "--defaults-group-suffix="))
+ {
+ *group_suffix= *argv + sizeof("--defaults-group-suffix=")-1;
+ argc--;
+ continue;
+ }
}
+ return org_argc - argc;
}
@@ -296,6 +366,10 @@ int load_defaults(const char *conf_file, const char **groups,
init_default_directories();
init_alloc_root(&alloc,512,0);
+ /*
+ Check if the user doesn't want any default option processing
+ --no-defaults is always the first option
+ */
if (*argc >= 2 && !strcmp(argv[0][1],"--no-defaults"))
{
/* remove the --no-defaults argument and return only the other arguments */
@@ -328,51 +402,8 @@ int load_defaults(const char *conf_file, const char **groups,
ctx.args= &args;
ctx.group= &group;
- if (*argc >= 2 + args_used &&
- is_prefix(argv[0][1+args_used], instance_option))
- {
- args_used++;
- defaults_instance= argv[0][args_used]+sizeof(instance_option)-1;
- }
- else
- {
- defaults_instance= getenv("MYSQL_INSTANCE");
- }
-
- if (defaults_instance)
- {
- /** Handle --instance= */
- uint i, len;
- const char **extra_groups;
- const uint instance_len= strlen(defaults_instance);
-
- if (!(extra_groups=
- (const char**)alloc_root(&alloc, (2*group.count+1)*sizeof(char*))))
- goto err;
-
- for (i= 0; i<group.count; i++)
- {
- extra_groups[i]= group.type_names[i]; /** copy group */
-
- len= strlen(extra_groups[i]);
- if (!(ptr= alloc_root(&alloc, len+instance_len+1)))
- goto err;
-
- extra_groups[i+group.count]= ptr;
-
- /** Construct new group */
- memcpy(ptr, extra_groups[i], len);
- ptr+= len;
- memcpy(ptr, defaults_instance, instance_len+1);
- }
-
- group.count*= 2;
- group.type_names= extra_groups;
- group.type_names[group.count]= 0;
- }
-
error= my_search_option_files(conf_file, argc, argv, &args_used,
- handle_default_option, (void *) &ctx);
+ handle_default_option, (void *) &ctx);
/*
Here error contains <> 0 only if we have a fully specified conf_file
or a forced default file
@@ -385,11 +416,14 @@ 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*));
- /* Skip --defaults-file and --defaults-extra-file */
+ /* Skip --defaults-xxx options */
(*argc)-= args_used;
(*argv)+= args_used;
- /* Check if we wan't to see the new argument list */
+ /*
+ Check if we wan't to see the new argument list
+ This options must always be the last of the default options
+ */
if (*argc >= 2 && !strcmp(argv[0][1],"--print-defaults"))
{
found_print_defaults=1;
@@ -850,14 +884,14 @@ void print_defaults(const char *conf_file, const char **groups)
fputs(*groups,stdout);
}
- if (defaults_instance)
+ if (defaults_group_suffix)
{
groups= groups_save;
for ( ; *groups ; groups++)
{
fputc(' ',stdout);
fputs(*groups,stdout);
- fputs(defaults_instance,stdout);
+ fputs(defaults_group_suffix,stdout);
}
}
puts("\nThe following options may be given as the first argument:\n\
diff --git a/mysys/default_modify.c b/mysys/default_modify.c
index ea384f9f27a..de03d783c68 100644
--- a/mysys/default_modify.c
+++ b/mysys/default_modify.c
@@ -20,8 +20,7 @@
#include <my_dir.h>
#define BUFF_SIZE 1024
-/* should be big enough to handle at least one line */
-#define RESERVE 1024
+#define RESERVE 1024 /* Extend buffer with this extent */
#ifdef __WIN__
#define NEWLINE "\r\n"
@@ -70,7 +69,7 @@ int modify_defaults_file(const char *file_location, const char *option,
char linebuff[BUFF_SIZE], *src_ptr, *dst_ptr, *file_buffer;
uint opt_len, optval_len, sect_len, nr_newlines= 0, buffer_size;
my_bool in_section= FALSE, opt_applied= 0;
- uint reserve_extended= 1, old_opt_len= 0;
+ uint reserve_extended;
uint new_opt_len;
int reserve_occupied= 0;
DBUG_ENTER("modify_defaults_file");
@@ -88,25 +87,21 @@ int modify_defaults_file(const char *file_location, const char *option,
new_opt_len= opt_len + 1 + optval_len + NEWLINE_LEN;
/* calculate the size of the buffer we need */
- buffer_size= sizeof(char) * (file_stat.st_size +
- /* option name len */
- opt_len +
- /* reserve for '=' char */
- 1 +
- /* option value len */
- optval_len +
- /* reserve space for newline */
- NEWLINE_LEN +
- /* The ending zero */
- 1 +
- /* reserve some additional space */
- RESERVE);
+ reserve_extended= (opt_len +
+ 1 + /* For '=' char */
+ optval_len + /* Option value len */
+ NEWLINE_LEN + /* Space for newline */
+ RESERVE); /* Some additional space */
+
+ buffer_size= (file_stat.st_size +
+ 1); /* The ending zero */
/*
Reserve space to read the contents of the file and some more
for the option we want to add.
*/
- if (!(file_buffer= (char*) my_malloc(buffer_size, MYF(MY_WME))))
+ if (!(file_buffer= (char*) my_malloc(buffer_size + reserve_extended,
+ MYF(MY_WME))))
goto malloc_err;
sect_len= (uint) strlen(section_name);
@@ -130,31 +125,20 @@ int modify_defaults_file(const char *file_location, const char *option,
my_isspace(&my_charset_latin1, *(src_ptr + opt_len)) ||
*(src_ptr + opt_len) == '\0'))
{
- /*
- we should change all options. If opt_applied is set, we are running
- into reserved memory area. Hence we should check for overruns.
- */
- if (opt_applied)
+ char *old_src_ptr= src_ptr;
+ src_ptr= strend(src_ptr+ opt_len); /* Find the end of the line */
+
+ /* could be negative */
+ reserve_occupied+= (int) new_opt_len - (int) (src_ptr - old_src_ptr);
+ if (reserve_occupied >= (int) reserve_extended)
{
- src_ptr+= opt_len; /* If we correct an option, we know it's name */
- old_opt_len= opt_len;
-
- while (*src_ptr++) /* Find the end of the line */
- old_opt_len++;
-
- /* could be negative */
- reserve_occupied+= (int) new_opt_len - (int) old_opt_len;
- if ((int) reserve_occupied > (int) (RESERVE*reserve_extended))
- {
- if (!(file_buffer= (char*) my_realloc(file_buffer, buffer_size +
- RESERVE*reserve_extended,
- MYF(MY_WME|MY_FREE_ON_ERROR))))
- goto malloc_err;
- reserve_extended++;
- }
+ reserve_extended= (uint) reserve_occupied + RESERVE;
+ if (!(file_buffer= (char*) my_realloc(file_buffer, buffer_size +
+ reserve_extended,
+ MYF(MY_WME|MY_FREE_ON_ERROR))))
+ goto malloc_err;
}
- else
- opt_applied= 1;
+ opt_applied= 1;
dst_ptr= add_option(dst_ptr, option_value, option, remove_option);
}
else
@@ -164,6 +148,7 @@ int modify_defaults_file(const char *file_location, const char *option,
{
dst_ptr= add_option(dst_ptr, option_value, option, remove_option);
opt_applied= 1; /* set the flag to do write() later */
+ reserve_occupied= new_opt_len+ opt_len + 1 + NEWLINE_LEN;
}
for (; nr_newlines; nr_newlines--)
diff --git a/mysys/my_bitmap.c b/mysys/my_bitmap.c
index ba958b234d2..c70c0fa0754 100644
--- a/mysys/my_bitmap.c
+++ b/mysys/my_bitmap.c
@@ -152,6 +152,7 @@ my_bool bitmap_test_and_set(MY_BITMAP *map, uint bitmap_bit)
bitmap_lock(map);
res= bitmap_fast_test_and_set(map, bitmap_bit);
bitmap_unlock(map);
+ return res;
}
uint bitmap_set_next(MY_BITMAP *map)
diff --git a/mysys/my_tempnam.c b/mysys/my_tempnam.c
deleted file mode 100644
index 9f765298fb6..00000000000
--- a/mysys/my_tempnam.c
+++ /dev/null
@@ -1,173 +0,0 @@
-/* Copyright (C) 2000 MySQL AB
-
- This program is free software; you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- You should have received a copy of the GNU General Public License
- along with this program; if not, write to the Free Software
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */
-
-/*
- This function is only used by some old ISAM code.
- When we remove ISAM support from MySQL, we should also delete this file
-
- One should instead use the functions in mf_tempfile.c
-*/
-
-#include "mysys_priv.h"
-#include <m_string.h>
-
-/* HPUX 11.0 doesn't allow us to change the environ pointer */
-#ifdef HPUX11
-#undef HAVE_TEMPNAM
-#endif
-
-#include "my_static.h"
-#include "mysys_err.h"
-
-#define TMP_EXT ".tmp" /* Extension of tempfile */
-#if ! defined(P_tmpdir)
-#define P_tmpdir ""
-#endif
-
-#ifdef HAVE_TEMPNAM
-#if !defined( MSDOS) && !defined(OS2) && !defined(__NETWARE__)
-extern char **environ;
-#endif
-#endif
-
-/* Make a uniq temp file name by using dir and adding something after
- pfx to make name uniq. Name is made by adding a uniq 8 length-string and
- TMP_EXT after pfx.
- Returns pointer to malloced area for filename. Should be freed by
- free().
- The name should be uniq, but it isn't checked if it file allready exists.
- Uses tempnam() if function exist on system.
- This function fixes that if dir is given it's used. For example
- MSDOS tempnam() uses always TMP environment-variable if it exists.
-*/
- /* ARGSUSED */
-
-my_string my_tempnam(const char *dir, const char *pfx,
- myf MyFlags __attribute__((unused)))
-{
-#ifdef _MSC_VER
- char temp[FN_REFLEN],*end,*res,**old_env,*temp_env[1];
- old_env=environ;
- if (dir)
- {
- end=strend(dir)-1;
- if (!dir[0])
- { /* Change empty string to current dir */
- temp[0]= FN_CURLIB;
- temp[1]= 0;
- dir=temp;
- }
- else if (*end == FN_DEVCHAR)
- { /* Get current dir for drive */
- _fullpath(temp,dir,FN_REFLEN);
- dir=temp;
- }
- else if (*end == FN_LIBCHAR && dir < end && end[-1] != FN_DEVCHAR)
- {
- strmake(temp,dir,(uint) (end-dir)); /* Copy and remove last '\' */
- dir=temp;
- }
- environ=temp_env; /* Force use of dir (dir not checked) */
- temp_env[0]=0;
- }
- res=tempnam((char*) dir,(my_string) pfx);
- environ=old_env;
- return res;
-#else
-#ifdef __ZTC__
- if (!dir)
- { /* If empty test first if TMP can be used */
- dir=getenv("TMP");
- }
- return tempnam((char*) dir,(my_string) pfx); /* Use stand. dir with prefix */
-#else
-#ifdef HAVE_TEMPNAM
- char temp[2],*res,**old_env,*temp_env[1];
-
- if (dir && !dir[0])
- { /* Change empty string to current dir */
- temp[0]= FN_CURLIB;
- temp[1]= 0;
- dir=temp;
- }
-#ifdef OS2
- /* changing environ variable doesn't work with VACPP */
- char buffer[256], *end;
- buffer[sizeof[buffer)-1]= 0;
- end= strxnmov(buffer, sizeof(buffer)-1, (char*) "TMP=", dir, NullS);
- /* remove ending backslash */
- if (end[-1] == '\\')
- end[-1]= 0;
- putenv(buffer);
-#elif !defined(__NETWARE__)
- old_env=(char**)environ;
- if (dir)
- { /* Don't use TMPDIR if dir is given */
- /*
- The following strange cast is required because the IBM compiler on AIX
- doesn't allow us to cast the value of environ.
- The cast of environ is needed as some systems doesn't allow us to
- update environ with a char ** pointer. (const mismatch)
- */
- (*(char***) &environ)=(char**) temp_env;
- temp_env[0]=0;
- }
-#endif
- res=tempnam((char*) dir,(my_string) pfx); /* Use stand. dir with prefix */
-#if !defined(OS2) && !defined(__NETWARE__)
- (*(char***) &environ)=(char**) old_env;
-#endif
- if (!res)
- DBUG_PRINT("error",("Got error: %d from tempnam",errno));
- return res;
-#else
- register long uniq;
- register int length;
- my_string pos,end_pos;
- DBUG_ENTER("my_tempnam");
- /* Make a uniq nummber */
- pthread_mutex_lock(&THR_LOCK_open);
- uniq= ((long) getpid() << 20) + (long) _my_tempnam_used++ ;
- pthread_mutex_unlock(&THR_LOCK_open);
- if (!dir && !(dir=getenv("TMPDIR"))) /* Use this if possibly */
- dir=P_tmpdir; /* Use system default */
- length=strlen(dir)+strlen(pfx)+1;
-
- DBUG_PRINT("test",("mallocing %d byte",length+8+sizeof(TMP_EXT)+1));
- if (!(pos=(char*) malloc(length+8+sizeof(TMP_EXT)+1)))
- {
- if (MyFlags & MY_FAE+MY_WME)
- my_error(EE_OUTOFMEMORY, MYF(ME_BELL+ME_WAITTANG),
- length+8+sizeof(TMP_EXT)+1);
- DBUG_RETURN(NullS);
- }
- end_pos=strmov(pos,dir);
- if (end_pos != pos && end_pos[-1] != FN_LIBCHAR)
- *end_pos++=FN_LIBCHAR;
- end_pos=strmov(end_pos,pfx);
-
- for (length=0 ; length < 8 && uniq ; length++)
- {
- *end_pos++= _dig_vec_upper[(int) (uniq & 31)];
- uniq >>= 5;
- }
- VOID(strmov(end_pos,TMP_EXT));
- DBUG_PRINT("exit",("tempnam: '%s'",pos));
- DBUG_RETURN(pos);
-#endif /* HAVE_TEMPNAM */
-#endif /* __ZTC__ */
-#endif /* _MSC_VER */
-} /* my_tempnam */
diff --git a/sql/ha_innodb.cc b/sql/ha_innodb.cc
index 8218e4fecc0..d49387ca4e5 100644
--- a/sql/ha_innodb.cc
+++ b/sql/ha_innodb.cc
@@ -5484,7 +5484,7 @@ ha_innobase::update_table_comment(
external_lock(). To be safe, update the thd of the current table
handle. */
- if(length > 64000 - 3) {
+ if (length > 64000 - 3) {
return((char*)comment); /* string too long */
}
@@ -5522,7 +5522,7 @@ ha_innobase::update_table_comment(
if (str) {
char* pos = str + length;
- if(length) {
+ if (length) {
memcpy(str, comment, length);
*pos++ = ';';
*pos++ = ' ';
@@ -5580,7 +5580,7 @@ ha_innobase::get_foreign_key_create_info(void)
flen = ftell(file);
if (flen < 0) {
flen = 0;
- } else if(flen > 64000 - 1) {
+ } else if (flen > 64000 - 1) {
flen = 64000 - 1;
}
diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc
index def99b51f95..4ff0951d89b 100644
--- a/sql/ha_ndbcluster.cc
+++ b/sql/ha_ndbcluster.cc
@@ -5464,7 +5464,7 @@ ndb_get_table_statistics(Ndb* ndb, const char * table,
Uint64 sum_commits= 0;
Uint64 sum_row_size= 0;
Uint64 sum_mem= 0;
- while((check= pOp->nextResult(TRUE, TRUE)) == 0)
+ while ((check= pOp->nextResult(TRUE, TRUE)) == 0)
{
sum_rows+= rows;
sum_commits+= commits;
@@ -5492,7 +5492,7 @@ ndb_get_table_statistics(Ndb* ndb, const char * table,
sum_mem, count));
DBUG_RETURN(0);
- } while(0);
+ } while (0);
if (pTrans)
ndb->closeTransaction(pTrans);
diff --git a/sql/item_cmpfunc.cc b/sql/item_cmpfunc.cc
index 5ed857319be..12342f707c3 100644
--- a/sql/item_cmpfunc.cc
+++ b/sql/item_cmpfunc.cc
@@ -2180,7 +2180,13 @@ void Item_func_in::fix_length_and_dec()
return;
for (arg=args+1, arg_end=args+arg_count; arg != arg_end ; arg++)
- const_itm&= arg[0]->const_item();
+ {
+ if (!arg[0]->const_item())
+ {
+ const_itm= 0;
+ break;
+ }
+ }
/*
Row item with NULLs inside can return NULL or FALSE =>
diff --git a/sql/item_strfunc.cc b/sql/item_strfunc.cc
index 1ad65fb6208..44d78f28052 100644
--- a/sql/item_strfunc.cc
+++ b/sql/item_strfunc.cc
@@ -2093,7 +2093,7 @@ String *Item_func_rpad::val_str(String *str)
func_name(), current_thd->variables.max_allowed_packet);
goto err;
}
- if(args[2]->null_value || !pad_char_length)
+ if (args[2]->null_value || !pad_char_length)
goto err;
res_byte_length= res->length(); /* Must be done before alloc_buffer */
if (!(res= alloc_buffer(res,str,&tmp_value,byte_count)))
diff --git a/sql/log.cc b/sql/log.cc
index e69c0af15bd..6369699378b 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -2647,7 +2647,7 @@ int TC_LOG_MMAP::log(THD *thd, my_xid xid)
{ // somebody's syncing. let's wait
p->waiters++;
/*
- note - it must be while(), not do ... while() here
+ note - it must be while (), not do ... while () here
as p->state may be not DIRTY when we come here
*/
while (p->state == DIRTY && syncing)
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 78d9af387da..035f098c88c 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -882,7 +882,7 @@ static void __cdecl kill_server(int sig_ptr)
unireg_end();
#ifdef __NETWARE__
- if(!event_flag)
+ if (!event_flag)
pthread_join(select_thread, NULL); // wait for main thread
#endif /* __NETWARE__ */
diff --git a/sql/opt_range.cc b/sql/opt_range.cc
index c2760b08b6e..9965766af19 100644
--- a/sql/opt_range.cc
+++ b/sql/opt_range.cc
@@ -630,7 +630,7 @@ int imerge_list_or_tree(PARAM *param,
{
SEL_IMERGE *imerge;
List_iterator<SEL_IMERGE> it(*im1);
- while((imerge= it++))
+ while ((imerge= it++))
{
if (imerge->or_sel_tree_with_checks(param, tree))
it.remove();
@@ -990,7 +990,7 @@ int QUICK_ROR_INTERSECT_SELECT::init_ror_merged_scan(bool reuse_handler)
DBUG_RETURN(1);
quick->file->extra(HA_EXTRA_KEYREAD_PRESERVE_FIELDS);
}
- while((quick= quick_it++))
+ while ((quick= quick_it++))
{
if (quick->init_ror_merged_scan(FALSE))
DBUG_RETURN(1);
@@ -6942,7 +6942,7 @@ get_best_group_min_max(PARAM *param, SEL_TREE *tree)
List_iterator<Item> select_items_it(join->fields_list);
/* Check (SA1,SA4) and store the only MIN/MAX argument - the C attribute.*/
- if(join->make_sum_func_list(join->all_fields, join->fields_list, 1))
+ if (join->make_sum_func_list(join->all_fields, join->fields_list, 1))
DBUG_RETURN(NULL);
if (join->sum_funcs[0])
{
@@ -7268,7 +7268,7 @@ check_group_min_max_predicates(COND *cond, Item_field *min_max_arg_item,
Item *and_or_arg;
while ((and_or_arg= li++))
{
- if(!check_group_min_max_predicates(and_or_arg, min_max_arg_item,
+ if (!check_group_min_max_predicates(and_or_arg, min_max_arg_item,
image_type))
DBUG_RETURN(FALSE);
}
@@ -7350,7 +7350,7 @@ check_group_min_max_predicates(COND *cond, Item_field *min_max_arg_item,
}
else if (cur_arg->type() == Item::FUNC_ITEM)
{
- if(!check_group_min_max_predicates(cur_arg, min_max_arg_item,
+ if (!check_group_min_max_predicates(cur_arg, min_max_arg_item,
image_type))
DBUG_RETURN(FALSE);
}
@@ -7881,19 +7881,19 @@ int QUICK_GROUP_MIN_MAX_SELECT::init()
if (min_max_arg_part)
{
- if(my_init_dynamic_array(&min_max_ranges, sizeof(QUICK_RANGE*), 16, 16))
+ if (my_init_dynamic_array(&min_max_ranges, sizeof(QUICK_RANGE*), 16, 16))
return 1;
if (have_min)
{
- if(!(min_functions= new List<Item_sum>))
+ if (!(min_functions= new List<Item_sum>))
return 1;
}
else
min_functions= NULL;
if (have_max)
{
- if(!(max_functions= new List<Item_sum>))
+ if (!(max_functions= new List<Item_sum>))
return 1;
}
else
@@ -7967,7 +7967,7 @@ bool QUICK_GROUP_MIN_MAX_SELECT::add_range(SEL_ARG *sel_range)
uint range_flag= sel_range->min_flag | sel_range->max_flag;
/* Skip (-inf,+inf) ranges, e.g. (x < 5 or x > 4). */
- if((range_flag & NO_MIN_RANGE) && (range_flag & NO_MAX_RANGE))
+ if ((range_flag & NO_MIN_RANGE) && (range_flag & NO_MAX_RANGE))
return FALSE;
if (!(sel_range->min_flag & NO_MIN_RANGE) &&
diff --git a/sql/parse_file.cc b/sql/parse_file.cc
index 7cc563901d2..abca8736916 100644
--- a/sql/parse_file.cc
+++ b/sql/parse_file.cc
@@ -728,7 +728,7 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root,
sizeof(LEX_STRING))) ||
list->push_back(str, mem_root))
goto list_err;
- if(!(ptr= parse_quoted_escaped_string(ptr, end, mem_root, str)))
+ if (!(ptr= parse_quoted_escaped_string(ptr, end, mem_root, str)))
goto list_err_w_message;
switch (*ptr) {
case '\n':
diff --git a/sql/sql_cache.cc b/sql/sql_cache.cc
index 430e0fbcabf..2cfe30004c0 100644
--- a/sql/sql_cache.cc
+++ b/sql/sql_cache.cc
@@ -2052,7 +2052,7 @@ my_bool Query_cache::allocate_data_chain(Query_cache_block **result_block,
*/
data_len= len - new_block->length;
prev_block= new_block;
- } while(1);
+ } while (1);
DBUG_RETURN(TRUE);
}
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index a57ad84da5b..e78b2b94199 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -2151,7 +2151,7 @@ int prepare_schema_table(THD *thd, LEX *lex, Table_ident *table_ident,
TABLE_LIST **query_tables_last= lex->query_tables_last;
sel= new SELECT_LEX();
sel->init_query();
- if(!sel->add_table_to_list(thd, table_ident, 0, 0, TL_READ,
+ if (!sel->add_table_to_list(thd, table_ident, 0, 0, TL_READ,
(List<String> *) 0, (List<String> *) 0))
DBUG_RETURN(1);
lex->query_tables_last= query_tables_last;
diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc
index 53f706bd0f6..b5f6d39cbe6 100644
--- a/sql/sql_prepare.cc
+++ b/sql/sql_prepare.cc
@@ -1752,6 +1752,10 @@ bool mysql_stmt_prepare(THD *thd, char *packet, uint packet_length,
DBUG_RETURN(TRUE);
}
+ /*
+ alloc_query() uses thd->memroot && thd->query, so we have to call
+ both of backup_statement() and backup_item_area() here.
+ */
thd->set_n_backup_statement(stmt, &stmt_backup);
thd->set_n_backup_item_arena(stmt, &stmt_backup);
@@ -2239,7 +2243,7 @@ void mysql_stmt_fetch(THD *thd, char *packet, uint packet_length)
cleanup_stmt_and_thd_after_use(stmt, thd);
reset_stmt_params(stmt);
/*
- Must be the last, as some momory is still needed for
+ Must be the last, as some memory is still needed for
the previous calls.
*/
free_root(cursor->mem_root, MYF(0));
diff --git a/sql/sql_select.cc b/sql/sql_select.cc
index 66e783a2103..26b00559b1b 100644
--- a/sql/sql_select.cc
+++ b/sql/sql_select.cc
@@ -6697,7 +6697,7 @@ static COND *build_equal_items_for_cond(COND *cond,
of the condition expression.
*/
li.rewind();
- while((item= li++))
+ while ((item= li++))
{
Item *new_item;
if ((new_item = build_equal_items_for_cond(item, inherited))!= item)
@@ -7506,7 +7506,7 @@ simplify_joins(JOIN *join, List<TABLE_LIST> *join_list, COND *conds, bool top)
/* Flatten nested joins that can be flattened. */
li.rewind();
- while((table= li++))
+ while ((table= li++))
{
nested_join= table->nested_join;
if (nested_join && !table->on_expr)
@@ -12102,7 +12102,6 @@ create_distinct_group(THD *thd, Item **ref_pointer_array,
List_iterator<Item> li(fields);
Item *item;
ORDER *order,*group,**prev;
- uint index= 0;
*all_order_by_fields_used= 1;
while ((item=li++))
@@ -12139,12 +12138,12 @@ create_distinct_group(THD *thd, Item **ref_pointer_array,
simple indexing of ref_pointer_array (order in the array and in the
list are same)
*/
- ord->item= ref_pointer_array + index;
+ ord->item= ref_pointer_array;
ord->asc=1;
*prev=ord;
prev= &ord->next;
}
- index++;
+ ref_pointer_array++;
}
*prev=0;
return group;
@@ -12973,7 +12972,7 @@ static bool change_group_ref(THD *thd, Item_func *expr, ORDER *group_list,
if (item->eq(*group_tmp->item,0))
{
Item *new_item;
- if(!(new_item= new Item_ref(context, group_tmp->item, 0,
+ if (!(new_item= new Item_ref(context, group_tmp->item, 0,
item->name)))
return 1; // fatal_error is set
thd->change_item_tree(arg, new_item);
diff --git a/sql/sql_show.cc b/sql/sql_show.cc
index 72092db400d..197e939162a 100644
--- a/sql/sql_show.cc
+++ b/sql/sql_show.cc
@@ -1709,7 +1709,7 @@ int make_table_list(THD *thd, SELECT_LEX *sel,
ident_table.length= strlen(table);
table_ident= new Table_ident(thd, ident_db, ident_table, 1);
sel->init_query();
- if(!sel->add_table_to_list(thd, table_ident, 0, 0, TL_READ,
+ if (!sel->add_table_to_list(thd, table_ident, 0, 0, TL_READ,
(List<String> *) 0, (List<String> *) 0))
return 1;
return 0;
diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy
index 4fc9819d0e1..71efd9b727c 100644
--- a/sql/sql_yacc.yy
+++ b/sql/sql_yacc.yy
@@ -45,7 +45,7 @@ int yylex(void *yylval, void *yythd);
const LEX_STRING null_lex_str={0,0};
-#define yyoverflow(A,B,C,D,E,F) {ulong val= *(F); if(my_yyoverflow((B), (D), &val)) { yyerror((char*) (A)); return 2; } else { *(F)= (YYSIZE_T)val; }}
+#define yyoverflow(A,B,C,D,E,F) {ulong val= *(F); if (my_yyoverflow((B), (D), &val)) { yyerror((char*) (A)); return 2; } else { *(F)= (YYSIZE_T)val; }}
#define WARN_DEPRECATED(A,B) \
push_warning_printf(((THD *)yythd), MYSQL_ERROR::WARN_LEVEL_WARN, \
diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c
index a80d5e1d1be..1eceb58f6f6 100644
--- a/tests/mysql_client_test.c
+++ b/tests/mysql_client_test.c
@@ -1960,7 +1960,7 @@ static void test_fetch_null()
myquery(rc);
/* fetch */
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
for (i= 0; i < (int) array_elements(bind); i++)
{
bind[i].buffer_type= MYSQL_TYPE_LONG;
@@ -3401,7 +3401,7 @@ static void test_bind_result()
/* fetch */
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_LONG;
bind[0].buffer= (void *) &nData; /* integer data */
bind[0].is_null= &is_null[0];
@@ -3494,7 +3494,7 @@ static void test_bind_result_ext()
rc= mysql_commit(mysql);
myquery(rc);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
for (i= 0; i < (int) array_elements(bind); i++)
{
bind[i].length= &length[i];
@@ -3613,7 +3613,7 @@ static void test_bind_result_ext1()
rc= mysql_commit(mysql);
myquery(rc);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_STRING;
bind[0].buffer= (void *) t_data;
bind[0].buffer_length= sizeof(t_data);
@@ -3906,7 +3906,7 @@ static void test_fetch_date()
rc= mysql_commit(mysql);
myquery(rc);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
for (i= 0; i < array_elements(bind); i++)
{
bind[i].is_null= &is_null[i];
@@ -5623,7 +5623,7 @@ static void test_store_result()
myquery(rc);
/* fetch */
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_LONG;
bind[0].buffer= (void *) &nData; /* integer data */
bind[0].length= &length;
@@ -6337,7 +6337,7 @@ static void test_buffers()
bzero(buffer, sizeof(buffer)); /* Avoid overruns in printf() */
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].length= &length;
bind[0].is_null= &is_null;
bind[0].buffer_length= 1;
@@ -6526,7 +6526,7 @@ static void test_fetch_nobuffs()
fprintf(stdout, "\n total rows : %d", rc);
DIE_UNLESS(rc == 1);
- bzero(bind, sizeof(MYSQL_BIND));
+ bzero((char*) bind, sizeof(MYSQL_BIND));
bind[0].buffer_type= MYSQL_TYPE_STRING;
bind[0].buffer= (void *)str[0];
bind[0].buffer_length= sizeof(str[0]);
@@ -6596,7 +6596,7 @@ static void test_ushort_bug()
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_SHORT;
bind[0].buffer= (void *)&short_value;
bind[0].is_unsigned= TRUE;
@@ -6684,7 +6684,7 @@ static void test_sshort_bug()
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_SHORT;
bind[0].buffer= (void *)&short_value;
bind[0].length= &s_length;
@@ -6771,7 +6771,7 @@ static void test_stiny_bug()
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_SHORT;
bind[0].buffer= (void *)&short_value;
bind[0].length= &s_length;
@@ -6879,7 +6879,7 @@ static void test_field_misc()
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_STRING;
bind[0].buffer= table_type;
bind[0].length= &type_length;
@@ -7190,7 +7190,7 @@ static void test_frm_bug()
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_STRING;
bind[0].buffer= data_dir;
bind[0].buffer_length= FN_REFLEN;
@@ -7928,7 +7928,7 @@ static void test_fetch_seek()
stmt= mysql_simple_prepare(mysql, "select * from t1");
check_stmt(stmt);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_LONG;
bind[0].buffer= (void *)&c1;
@@ -8024,7 +8024,7 @@ static void test_fetch_offset()
stmt= mysql_simple_prepare(mysql, "select * from t1");
check_stmt(stmt);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_STRING;
bind[0].buffer= (void *)data;
bind[0].buffer_length= 11;
@@ -8111,7 +8111,7 @@ static void test_fetch_column()
stmt= mysql_simple_prepare(mysql, "select * from t1 order by c2 desc");
check_stmt(stmt);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_LONG;
bind[0].buffer= (void *)&bc1;
bind[0].buffer_length= 0;
@@ -8359,7 +8359,7 @@ static void test_free_result()
stmt= mysql_simple_prepare(mysql, "select * from test_free_result");
check_stmt(stmt);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_LONG;
bind[0].buffer= (void *)&bc1;
bind[0].length= &bl1;
@@ -8439,7 +8439,7 @@ static void test_free_store_result()
stmt= mysql_simple_prepare(mysql, "select * from test_free_result");
check_stmt(stmt);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_LONG;
bind[0].buffer= (void *)&bc1;
bind[0].buffer_length= 0;
@@ -9900,7 +9900,7 @@ static void test_bug3035()
rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
myquery(rc);
- bzero(bind_array, sizeof(bind_array));
+ bzero((char*) bind_array, sizeof(bind_array));
for (bind= bind_array; bind < bind_end; bind++)
bind->error= &bind->error_value;
@@ -10107,7 +10107,7 @@ static void test_bug1664()
verify_param_count(stmt, 2);
- bzero(&bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_STRING;
bind[0].buffer= (void *)str_data;
@@ -10347,7 +10347,7 @@ static void test_ps_i18n()
rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
myquery(rc);
- bzero(bind_array, sizeof(bind_array));
+ bzero((char*) bind_array, sizeof(bind_array));
bind_array[0].buffer_type= MYSQL_TYPE_STRING;
bind_array[0].buffer= (void *) koi8;
@@ -10531,7 +10531,7 @@ static void test_bug3796()
check_execute(stmt, rc);
/* Bind input buffers */
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_STRING;
bind[0].buffer= (void *) concat_arg0;
@@ -10598,11 +10598,11 @@ static void test_bug4026()
check_execute(stmt, rc);
/* Bind input buffers */
- bzero(bind, sizeof(bind));
- bzero(&time_in, sizeof(time_in));
- bzero(&time_out, sizeof(time_out));
- bzero(&datetime_in, sizeof(datetime_in));
- bzero(&datetime_out, sizeof(datetime_out));
+ bzero((char*) bind, sizeof(bind));
+ bzero((char*) &time_in, sizeof(time_in));
+ bzero((char*) &time_out, sizeof(time_out));
+ bzero((char*) &datetime_in, sizeof(datetime_in));
+ bzero((char*) &datetime_out, sizeof(datetime_out));
bind[0].buffer_type= MYSQL_TYPE_TIME;
bind[0].buffer= (void *) &time_in;
@@ -10680,7 +10680,7 @@ static void test_bug4079()
check_execute(stmt, rc);
/* Bind input buffers */
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_LONG;
bind[0].buffer= (void *) &res;
@@ -10749,13 +10749,13 @@ static void test_bug4030()
check_execute(stmt, rc);
/* Bind output buffers */
- bzero(bind, sizeof(bind));
- bzero(&time_canonical, sizeof(time_canonical));
- bzero(&time_out, sizeof(time_out));
- bzero(&date_canonical, sizeof(date_canonical));
- bzero(&date_out, sizeof(date_out));
- bzero(&datetime_canonical, sizeof(datetime_canonical));
- bzero(&datetime_out, sizeof(datetime_out));
+ bzero((char*) bind, sizeof(bind));
+ bzero((char*) &time_canonical, sizeof(time_canonical));
+ bzero((char*) &time_out, sizeof(time_out));
+ bzero((char*) &date_canonical, sizeof(date_canonical));
+ bzero((char*) &date_out, sizeof(date_out));
+ bzero((char*) &datetime_canonical, sizeof(datetime_canonical));
+ bzero((char*) &datetime_out, sizeof(datetime_out));
bind[0].buffer_type= MYSQL_TYPE_TIME;
bind[0].buffer= (void *) &time_out;
@@ -10858,7 +10858,7 @@ static void test_view()
check_execute(stmt, rc);
strmov(str_data, "TEST");
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= FIELD_TYPE_STRING;
bind[0].buffer= (char *)&str_data;
bind[0].buffer_length= 50;
@@ -10977,7 +10977,7 @@ static void test_view_2where()
" AENAME,T0001.DEPENDVARS AS DEPENDVARS,T0001.INACTIVE AS "
" INACTIVE from LTDX T0001 where (T0001.SRTF2 = 0)");
myquery(rc);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
for (i=0; i < 8; i++) {
strmov(parms[i], "1");
bind[i].buffer_type = MYSQL_TYPE_VAR_STRING;
@@ -11026,7 +11026,7 @@ static void test_view_star()
myquery(rc);
rc= mysql_query(mysql, "CREATE VIEW vt1 AS SELECT a FROM t1");
myquery(rc);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
for (i= 0; i < 2; i++) {
sprintf((char *)&parms[i], "%d", i);
bind[i].buffer_type = MYSQL_TYPE_VAR_STRING;
@@ -11092,7 +11092,7 @@ static void test_view_insert()
rc= mysql_stmt_prepare(select_stmt, query, strlen(query));
check_execute(select_stmt, rc);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type = FIELD_TYPE_LONG;
bind[0].buffer = (char *)&my_val;
bind[0].length = &my_length;
@@ -11196,7 +11196,7 @@ static void test_view_insert_fields()
" F7F8 AS F7F8, F6N4 AS F6N4, F5C8 AS F5C8, F9D8 AS F9D8"
" from t1 T0001");
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
for (i= 0; i < 11; i++)
{
l[i]= 20;
@@ -11264,7 +11264,7 @@ static void test_bug5126()
check_execute(stmt, rc);
/* Bind output buffers */
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_LONG;
bind[0].buffer= &c1;
@@ -11310,8 +11310,8 @@ static void test_bug4231()
check_execute(stmt, rc);
/* Bind input buffers */
- bzero(bind, sizeof(bind));
- bzero(tm, sizeof(tm));
+ bzero((char*) bind, sizeof(bind));
+ bzero((char*) tm, sizeof(tm));
bind[0].buffer_type= MYSQL_TYPE_DATE;
bind[0].buffer= &tm[0];
@@ -11371,7 +11371,7 @@ static void test_bug5399()
myheader("test_bug5399");
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_LONG;
bind[0].buffer= &no;
@@ -11531,7 +11531,7 @@ static void test_bug5194()
param_str_length= strlen(param_str);
/* setup bind array */
- bzero(bind, MAX_PARAM_COUNT * sizeof(MYSQL_BIND));
+ bzero((char*) bind, MAX_PARAM_COUNT * sizeof(MYSQL_BIND));
for (i= 0; i < MAX_PARAM_COUNT; ++i)
{
bind[i].buffer_type= MYSQL_TYPE_FLOAT;
@@ -11649,7 +11649,7 @@ static void test_bug6049()
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type = MYSQL_TYPE_STRING;
bind[0].buffer = &buffer;
bind[0].buffer_length = sizeof(buffer);
@@ -11698,7 +11698,7 @@ static void test_bug6058()
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type = MYSQL_TYPE_STRING;
bind[0].buffer = &buffer;
bind[0].buffer_length = sizeof(buffer);
@@ -11766,7 +11766,7 @@ static void test_bug6046()
check_execute(stmt, rc);
b= 1;
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer= &b;
bind[0].buffer_type= MYSQL_TYPE_SHORT;
@@ -11945,7 +11945,7 @@ static void test_bug6096()
/* Bind and fetch the data */
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
for (i= 0; i < stmt_field_count; ++i)
{
bind[i].buffer_type= MYSQL_TYPE_STRING;
@@ -12000,7 +12000,7 @@ static void test_datetime_ranges()
check_stmt(stmt);
verify_param_count(stmt, 6);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
for (i= 0; i < 6; i++)
{
bind[i].buffer_type= MYSQL_TYPE_DATETIME;
@@ -12131,7 +12131,7 @@ static void test_bug4172()
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_STRING;
bind[0].buffer= f;
bind[0].buffer_length= sizeof(f);
@@ -12198,7 +12198,7 @@ static void test_conversion()
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
check_execute(stmt, rc);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer= buff;
bind[0].length= &length;
bind[0].buffer_type= MYSQL_TYPE_STRING;
@@ -12261,7 +12261,7 @@ static void test_rewind(void)
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
check_execute(stmt, rc);
- bzero(&bind,sizeof(MYSQL_BIND));
+ bzero((char*) &bind, sizeof(MYSQL_BIND));
bind.buffer_type= MYSQL_TYPE_LONG;
bind.buffer= (void *)&Data; /* this buffer won't be altered */
bind.length= &length;
@@ -12357,7 +12357,7 @@ static void test_truncation()
/*************** Fill in the bind structure and bind it **************/
bind_array= malloc(sizeof(MYSQL_BIND) * bind_count);
- bzero(bind_array, sizeof(MYSQL_BIND) * bind_count);
+ bzero((char*) bind_array, sizeof(MYSQL_BIND) * bind_count);
for (bind= bind_array; bind < bind_array + bind_count; bind++)
bind->error= &bind->error_value;
bind= bind_array;
@@ -12562,7 +12562,7 @@ static void test_truncation_option()
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
- bzero(&bind, sizeof(MYSQL_BIND));
+ bzero((char*) &bind, sizeof(MYSQL_BIND));
bind.buffer= (void*) &buf;
bind.buffer_type= MYSQL_TYPE_TINY;
@@ -12637,7 +12637,7 @@ static void test_bug8330()
rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
myquery(rc);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
for (i=0; i < 2; i++)
{
stmt[i]= mysql_stmt_init(mysql);
@@ -12911,7 +12911,7 @@ static void test_bug9520()
rc= mysql_stmt_execute(stmt);
check_execute(stmt, rc);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_STRING;
bind[0].buffer= (char*) a;
bind[0].buffer_length= sizeof(a);
@@ -12960,7 +12960,7 @@ static void test_bug9478()
stmt= open_cursor("select name from t1 where id=2");
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_STRING;
bind[0].buffer= (char*) a;
bind[0].buffer_length= sizeof(a);
@@ -13138,7 +13138,7 @@ static void test_bug9643()
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
check_execute(stmt, rc);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_LONG;
bind[0].buffer= (void*) &a;
bind[0].buffer_length= sizeof(a);
@@ -13194,7 +13194,7 @@ static void test_bug11111()
mysql_stmt_prepare(stmt, query, strlen(query));
mysql_stmt_execute(stmt);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
for (i=0; i < 2; i++)
{
bind[i].buffer_type= MYSQL_TYPE_STRING;
@@ -13231,7 +13231,7 @@ static void test_bug10729()
int rc;
const char *stmt_text;
int i= 0;
- char *name_array[3]= { "aaa", "bbb", "ccc" };
+ const char *name_array[3]= { "aaa", "bbb", "ccc" };
ulong type;
myheader("test_bug10729");
@@ -13252,7 +13252,7 @@ static void test_bug10729()
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
check_execute(stmt, rc);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_STRING;
bind[0].buffer= (void*) a;
bind[0].buffer_length= sizeof(a);
@@ -13363,7 +13363,7 @@ static void test_bug10736()
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
check_execute(stmt, rc);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_STRING;
bind[0].buffer= (void*) a;
bind[0].buffer_length= sizeof(a);
@@ -13412,7 +13412,7 @@ static void test_bug10794()
stmt_text= "insert into t1 (id, name) values (?, ?)";
rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
check_execute(stmt, rc);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_LONG;
bind[0].buffer= (void*) &id_val;
bind[1].buffer_type= MYSQL_TYPE_STRING;
@@ -13434,7 +13434,7 @@ static void test_bug10794()
mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void*) &type);
stmt1= mysql_stmt_init(mysql);
mysql_stmt_attr_set(stmt1, STMT_ATTR_CURSOR_TYPE, (const void*) &type);
- bzero(bind, sizeof(bind));
+ bzero((char*) bind, sizeof(bind));
bind[0].buffer_type= MYSQL_TYPE_STRING;
bind[0].buffer= (void*) a;
bind[0].buffer_length= sizeof(a);
@@ -13507,9 +13507,9 @@ static void test_bug11172()
type= (ulong) CURSOR_TYPE_READ_ONLY;
mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void*) &type);
- bzero(bind_in, sizeof(bind_in));
- bzero(bind_out, sizeof(bind_out));
- bzero(&hired, sizeof(hired));
+ bzero((char*) bind_in, sizeof(bind_in));
+ bzero((char*) bind_out, sizeof(bind_out));
+ bzero((char*) &hired, sizeof(hired));
hired.year= 1965;
hired.month= 1;
hired.day= 1;
@@ -13577,9 +13577,9 @@ static void test_bug11656()
type= (ulong) CURSOR_TYPE_READ_ONLY;
mysql_stmt_attr_set(stmt, STMT_ATTR_CURSOR_TYPE, (const void*) &type);
- bzero(bind, sizeof(bind));
- strcpy(buf[0], "pcint502_MY2");
- strcpy(buf[1], "*");
+ bzero((char*) bind, sizeof(bind));
+ strmov(buf[0], "pcint502_MY2");
+ strmov(buf[1], "*");
for (i=0; i < 2; i++)
{
bind[i].buffer_type= MYSQL_TYPE_STRING;