diff options
54 files changed, 1211 insertions, 668 deletions
diff --git a/BitKeeper/etc/logging_ok b/BitKeeper/etc/logging_ok index 953ddf7b564..ac02fa84bbc 100644 --- a/BitKeeper/etc/logging_ok +++ b/BitKeeper/etc/logging_ok @@ -95,6 +95,7 @@ kaj@work.mysql.com kent@mysql.com konstantin@mysql.com kostja@oak.local +lars@mysql.com lenz@kallisto.mysql.com lenz@mysql.com magnus@neptunus.(none) diff --git a/Docs/Support/texi2html b/Docs/Support/texi2html index 8067d8f72ce..f13c006c7dc 100755 --- a/Docs/Support/texi2html +++ b/Docs/Support/texi2html @@ -1,4 +1,4 @@ -#!PATH_TO_PERL -*- perl -*- +#!/usr/bin/perl # Add path to perl on the previous line and make this executable # if you want to use this as a normal script. 'di '; @@ -12,7 +12,7 @@ #-############################################################################## # @(#)texi2html 1.52 971230 Written (mainly) by Lionel Cons, Lionel.Cons@cern.ch -# Enhanced by David Axmark, david@detron.se +# Enhanced by David Axmark # The man page for this program is included at the end of this file and can be # viewed using the command 'nroff -man texi2html'. @@ -40,8 +40,7 @@ $NODESRE = '[^@{}:\'`"]+'; # RE for a list of node names $XREFRE = '[^@{}]+'; # RE for a xref (should use NODERE) $ERROR = "***"; # prefix for errors and warnings -$THISPROG = "texi2html 1.52 (hacked by david\@detron.se)"; # program name and version -$HOMEPAGE = "http://www.mathematik.uni-kl.de/~obachman/Texi2html/"; # program home page +$THISPROG = "texi2html 1.52 (with additions by MySQL AB)"; # program name and version $TODAY = &pretty_date; # like "20 September 1993" $SPLITTAG = "<!-- SPLIT HERE -->\n"; # tag to know where to split $PROTECTTAG = "_ThisIsProtected_"; # tag to recognize protected sections @@ -114,10 +113,12 @@ $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 2//E # %accent_map = ( '"', 'uml', + '\'', 'acute', + ',{', 'cedil', '~', 'tilde', '^', 'circ', '`', 'grave', - '\'', 'acute', + 'ringaccent{', 'ring', ); # @@ -125,7 +126,7 @@ $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 2//E # %simple_map = ( # cf. makeinfo.c - "*", "<BR>", # HTML+ + "*", "<br />", # HTML+ " ", " ", "\n", "\n", "|", "", @@ -134,6 +135,8 @@ $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 2//E "!", "!", "?", "?", ".", ".", + # @- means "allow word break", not — + "-", "", ); # @@ -141,9 +144,10 @@ $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 2//E # %things_map = ( 'TeX', 'TeX', - 'br', '<P>', # paragraph break + 'br', '<p>', # paragraph break 'bullet', '*', 'copyright', '(C)', + 'registeredsymbol', '(R)', 'dots', '...', 'equiv', '==', 'error', 'error-->', @@ -161,27 +165,28 @@ $html2_doctype = '<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0 Strict Level 2//E %style_map = ( 'asis', '', 'b', 'B', - 'cite', 'CITE', - 'code', 'CODE', + 'cite', 'cite', + 'code', 'code', + 'command', 'code', 'ctrl', '&do_ctrl', # special case - 'dfn', 'STRONG', # DFN tag is illegal in the standard + 'dfn', 'strong', # DFN tag is illegal in the standard 'dmn', '', # useless 'email', '&fix_email', # special - 'emph', 'EM', - 'file', '"TT', # will put quotes, cf. &apply_style - 'i', 'I', - 'kbd', 'KBD', - 'key', 'KBD', + 'emph', 'em', + 'file', '"tt', # will put quotes, cf. &apply_style + 'i', 'i', + 'kbd', 'kbd', + 'key', 'kbd', 'r', '', # unsupported - 'samp', '"SAMP', # will put quotes, cf. &apply_style + 'samp', '"samp', # will put quotes, cf. &apply_style 'sc', '&do_sc', # special case - 'strong', 'STRONG', - 't', 'TT', + 'strong', 'strong', + 't', 'tt', 'titlefont', '', # useless 'image', '&fix_image', # Image 'url', '&fix_url', # URL 'uref', '&fix_uref', # URL Reference - 'var', 'VAR', + 'var', 'var', 'w', '', # unsupported ); @@ -317,6 +322,7 @@ $usage = <<EOT; This is $THISPROG To convert a Texinfo file to HMTL: $0 [options] file where options can be: +-acc : convert @"-like accents to &entities; -expandinfo : use \@ifinfo sections, not \@iftex -glossary : handle a glossary -invisible name: use 'name' as an invisible anchor @@ -445,11 +451,15 @@ $html_num = 0; if ($use_iso) { $things_map{'bullet'} = "•"; $things_map{'copyright'} = "©"; + $things_map{'registeredsymbol'} = "®"; $things_map{'dots'} = "…"; $things_map{'equiv'} = "≡"; $things_map{'expansion'} = "→"; $things_map{'point'} = "∗"; $things_map{'result'} = "⇒"; + $things_map{'ss'} = "ß"; + $things_map{'o'} = "ø"; + $things_map{'O'} = "Ø"; } # @@ -505,23 +515,27 @@ $html_element = ''; # current HTML element # watch out for regexps, / and escaped characters! $subst_code = ''; foreach (keys(%simple_map)) { - ($re = $_) =~ s/(\W)/\\$1/g; # protect regexp chars - $subst_code .= "s/\\\@$re/$simple_map{$_}/g;\n"; + $re = quotemeta $_; # protect regexp chars + $sub = quotemeta $simple_map{$_}; + $subst_code .= "s/\\\@$re/$sub/g;\n"; } foreach (keys(%things_map)) { - $subst_code .= "s/\\\@$_\\{\\}/$things_map{$_}/g;\n"; + $re = quotemeta $_; # protect regexp chars + $sub = quotemeta $things_map{$_}; + $subst_code .= "s/\\\@$re\\{\\}/$sub/g;\n"; } if ($use_acc) { # accentuated characters foreach (keys(%accent_map)) { + my $brace = /{$/ ? '}' : ''; if ($_ eq "`") { $subst_code .= "s/$;3"; } elsif ($_ eq "'") { $subst_code .= "s/$;4"; } else { - $subst_code .= "s/\\\@\\$_"; + $subst_code .= "s/\\\@\\Q$_\\E"; } - $subst_code .= "([aeiou])/&\${1}$accent_map{$_};/gi;\n"; + $subst_code .= "(\\w)$brace/&\${1}$accent_map{$_};/gi;\n"; } } eval("sub simple_substitutions { $subst_code }"); @@ -703,7 +717,7 @@ READ_LINE: while ($_ = &next_line) s/{[^{}]+}//g); print "# Multitable with $multitable_cols columns\n" if $debug and $DEBUG_USER; - push(@lines, &debug("<TABLE BORDER WIDTH=\"100%\">\n", __LINE__)); + push(@lines, &debug("<TABLE BORDER>\n", __LINE__)); } else { warn "$ERROR Bad table line: $_"; } @@ -873,7 +887,7 @@ READ_LINE: while ($_ = &next_line) &simple_substitutions; s/\@value{($VARRE)}/$value{$1}/eg; s/\@footnote\{/\@footnote$docu_doc\{/g; # mark footnotes, cf. pass 4 - s|\s+\@tab\s*| </TD><TD> |g if ($in_multitable); + s/(^|\s+)\@tab\s*/ <\/TD><TD> /g if ($in_multitable); # # analyze the tag again @@ -885,7 +899,7 @@ READ_LINE: while ($_ = &next_line) $name =~ s/\s+$//; $level = $sec2level{$tag}; $name = &update_sec_num($tag, $level) . " $name" - if $number_sections && $tag !~ /^unnumbered/; + if $number_sections && $tag !~ /^unnumbered/ && $tag ne 'subsubheading'; if ($tag =~ /heading$/) { push(@lines, &html_debug("\n", __LINE__)); if ($html_element ne 'body') { @@ -1079,7 +1093,7 @@ EOC push(@lines, &debug("</TD></TR>\n", __LINE__)) unless $html_element eq 'TABLE'; &html_pop_if('TR'); - $what =~ s|\s+\@tab\s*| </TD><TD> |g; + $what =~ s/(^|\s+)\@tab\s*/ <\/TD><TD> /g; push(@lines, &debug("<TR><TD>$what\n", __LINE__)); &html_push('TR'); if ($deferred_ref) @@ -1463,11 +1477,7 @@ print "# end of pass 4\n" if $verbose; # # #---############################################################################ -$header = <<EOT; -<!-- This HTML file has been created by $THISPROG - from $docu on $TODAY --> -EOT - + $header = ''; $full_title = $value{'_title'} || $value{'_settitle'} || "Untitled Document"; $title = $value{'_settitle'} || $full_title; $_ = &substitute_style($full_title); @@ -1815,8 +1825,10 @@ sub fix_image die "error in image: '$text'" unless defined($1); $arg1 = $1; $arg1 =~ s/@@/@/g; - $ext = "jpg" if -f "$arg1.jpg"; - $ext = "gif" if -f "$arg1.gif"; + foreach (@include_dirs) { + $ext = "jpg" if -f "$_/$arg1.jpg"; + $ext = "gif" if -f "$_/$arg1.gif"; + } if (defined($ext)) { "<IMG SRC=\"$arg1.$ext\">"; @@ -2010,7 +2022,7 @@ sub print_toplevel_header { local($_); - &print_header; # pass given arg... + &print_header unless $opt_empty_headers; # pass given arg... print FILE $full_title; if ($value{'_subtitle'}) { $value{'_subtitle'} =~ s/\n+$//; @@ -2042,13 +2054,7 @@ EOT sub print_toplevel_footer { - &print_ruler; - print FILE <<EOT; -This document was generated on $TODAY using the -<A HREF=\"$HOMEPAGE\">texi2html</A> -translator version 1.52 (extended by davida\@detron.se).</P> -EOT - &print_footer; + &print_footer unless $opt_empty_headers; } sub protect_texi @@ -2065,8 +2071,10 @@ sub protect_html { local($what) = @_; # protect & < > - # Avoid loop in & replacement. This instead bugs out for &# in text.. - $what =~ s/\&([^#]|$)/\&\#38;$1/g; + # hack for the two entity-like variable reference in existing examples + $what =~ s/\&(length|ts);/\&\#38;$1;/g; + # this leaves alone entities, but encodes standalone ampersands + $what =~ s/\&(?!([a-z0-9]+|#\d+);)/\&\#38;/ig; $what =~ s/\</\&\#60;/g; $what =~ s/\>/\&\#62;/g; # but recognize some HTML things diff --git a/client/mysqltest.c b/client/mysqltest.c index 21f93b1fc6a..aef36823dfc 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -42,7 +42,7 @@ **********************************************************************/ -#define MTEST_VERSION "2.3" +#define MTEST_VERSION "2.4" #include <my_global.h> #include <mysql_embed.h> @@ -243,8 +243,7 @@ VAR var_reg[10]; HASH var_hash; my_bool disable_query_log=0, disable_result_log=0, disable_warnings=0; my_bool disable_info= 1; /* By default off */ -/* default for disable_abort_on_error: false = abort on unmasked error */ -my_bool disable_abort_on_error= 0; +my_bool abort_on_error= 1; struct connection cons[MAX_CONS]; struct connection* cur_con, *next_con, *cons_end; @@ -370,7 +369,7 @@ const char *command_names[]= }; TYPELIB command_typelib= {array_elements(command_names),"", - command_names}; + command_names, 0}; DYNAMIC_STRING ds_res; static void die(const char *fmt, ...); @@ -744,7 +743,7 @@ err: DBUG_RETURN(0); } -static VAR* var_obtain(char* name, int len) +static VAR *var_obtain(const char* name, int len) { VAR* v; if ((v = (VAR*)hash_search(&var_hash, name, len))) @@ -754,28 +753,33 @@ static VAR* var_obtain(char* name, int len) return v; } -int var_set(char* var_name, char* var_name_end, char* var_val, - char* var_val_end) +int var_set(const char *var_name, const char *var_name_end, + const char *var_val, const char *var_val_end) { int digit; VAR* v; + DBUG_ENTER("var_set"); + DBUG_PRINT("enter", ("var_name: '%.*s' = '%.*s' (length: %d)", + (int) (var_name_end - var_name), var_name, + (int) (var_val_end - var_val), var_val, + (int) (var_val_end - var_val))); + if (*var_name++ != '$') - { - --var_name; - *var_name_end = 0; - die("Variable name in %s does not start with '$'", var_name); - } + { + var_name--; + die("Variable name in %s does not start with '$'", var_name); + } digit = *var_name - '0'; if (!(digit < 10 && digit >= 0)) - { - v = var_obtain(var_name, var_name_end - var_name); - } + { + v = var_obtain(var_name, (uint) (var_name_end - var_name)); + } else - v = var_reg + digit; - + v = var_reg + digit; return eval_expr(v, var_val, (const char**)&var_val_end); } + int open_file(const char* name) { char buff[FN_REFLEN]; @@ -1244,18 +1248,22 @@ int do_let(struct st_query* q) return var_set(var_name, var_name_end, var_val_start, q->end); } -/* Store an integer (typically the returncode of the last SQL) */ -/* statement in the mysqltest builtin variable $mysql_errno, by */ -/* simulating of a user statement "let $mysql_errno= <integer>" */ -int var_set_errno(int sql_errno ) + +/* + Store an integer (typically the returncode of the last SQL) + statement in the mysqltest builtin variable $mysql_errno, by + simulating of a user statement "let $mysql_errno= <integer>" +*/ + +int var_set_errno(int sql_errno) { - char var_name[] = "$mysql_errno", var_val[30]; - sprintf(var_val, "%d", sql_errno); - /* On some odd systems, the return value from sprintf() isn't */ - /* always the length of the string, so we use strlen() */ - return var_set(var_name, var_name + 12, var_val, var_val + strlen(var_val)); + const char *var_name= "$mysql_errno"; + char var_val[21]; + uint length= my_sprintf(var_val, (var_val, "%d", sql_errno)); + return var_set(var_name, var_name + 12, var_val, var_val + length); } + int do_rpl_probe(struct st_query* q __attribute__((unused))) { DBUG_ENTER("do_rpl_probe"); @@ -1264,12 +1272,14 @@ int do_rpl_probe(struct st_query* q __attribute__((unused))) DBUG_RETURN(0); } + int do_enable_rpl_parse(struct st_query* q __attribute__((unused))) { mysql_enable_rpl_parse(&cur_con->mysql); return 0; } + int do_disable_rpl_parse(struct st_query* q __attribute__((unused))) { mysql_disable_rpl_parse(&cur_con->mysql); @@ -2013,7 +2023,7 @@ int read_query(struct st_query** q_ptr) memcpy((gptr) q->expected_errno, (gptr) global_expected_errno, sizeof(global_expected_errno)); q->expected_errors= global_expected_errors; - q->abort_on_error= (global_expected_errors == 0 && !disable_abort_on_error); + q->abort_on_error= (global_expected_errors == 0 && abort_on_error); bzero((gptr) global_expected_errno, sizeof(global_expected_errno)); global_expected_errors=0; if (p[0] == '-' && p[1] == '-') @@ -2422,7 +2432,7 @@ static int run_query(MYSQL *mysql, struct st_query *q, int flags) if (ps_protocol_enabled && disable_info && (flags & QUERY_SEND) && (flags & QUERY_REAP) && ps_match_re(q->query)) - return run_query_stmt (mysql, q, flags); + return run_query_stmt(mysql, q, flags); return run_query_normal(mysql, q, flags); } @@ -2659,9 +2669,12 @@ end: dynstr_free(&ds_tmp); if (q->type == Q_EVAL) dynstr_free(&eval_query); - /* We save the return code (mysql_errno(mysql)) from the last call sent */ - /* to the server into the mysqltest builtin variable $mysql_errno. This */ - /* variable then can be used from the test case itself. */ + + /* + We save the return code (mysql_errno(mysql)) from the last call sent + to the server into the mysqltest builtin variable $mysql_errno. This + variable then can be used from the test case itself. + */ var_set_errno(mysql_errno(mysql)); DBUG_RETURN(error); } @@ -3012,6 +3025,7 @@ end: dynstr_free(&ds_tmp); if (q->type == Q_EVAL) dynstr_free(&eval_query); + var_set_errno(mysql_stmt_errno(stmt)); mysql_stmt_close(stmt); DBUG_RETURN(error); } @@ -3319,7 +3333,7 @@ static VAR* var_from_env(const char *name, const char *def_val) if (!(tmp = getenv(name))) tmp = def_val; - v = var_init(0, name, 0, tmp, 0); + v = var_init(0, name, strlen(name), tmp, strlen(tmp)); my_hash_insert(&var_hash, (byte*)v); return v; } @@ -3416,9 +3430,11 @@ int main(int argc, char **argv) init_var_hash(&cur_con->mysql); - /* Initialize $mysql_errno with -1, so we can */ - /* - distinguish it from valid values ( >= 0 ) and */ - /* - detect if there was never a command sent to the server */ + /* + Initialize $mysql_errno with -1, so we can + - distinguish it from valid values ( >= 0 ) and + - detect if there was never a command sent to the server + */ var_set_errno(-1); while (!read_query(&q)) @@ -3440,8 +3456,8 @@ int main(int argc, char **argv) case Q_DISABLE_RPL_PARSE: do_disable_rpl_parse(q); break; case Q_ENABLE_QUERY_LOG: disable_query_log=0; break; case Q_DISABLE_QUERY_LOG: disable_query_log=1; break; - case Q_ENABLE_ABORT_ON_ERROR: disable_abort_on_error=0; break; - case Q_DISABLE_ABORT_ON_ERROR: disable_abort_on_error=1; break; + case Q_ENABLE_ABORT_ON_ERROR: abort_on_error=1; break; + case Q_DISABLE_ABORT_ON_ERROR: abort_on_error=0; break; case Q_ENABLE_RESULT_LOG: disable_result_log=0; break; case Q_DISABLE_RESULT_LOG: disable_result_log=1; break; case Q_ENABLE_WARNINGS: disable_warnings=0; break; diff --git a/configure.in b/configure.in index d63859720a3..71adaa747f5 100644 --- a/configure.in +++ b/configure.in @@ -1039,8 +1039,8 @@ case $SYSTEM_TYPE in ;; *hpux11.*) echo "Enabling workarounds for hpux 11" - CFLAGS="$CFLAGS -DHPUX11 -DHAVE_BROKEN_PREAD -DDONT_USE_FINITE -DHAVE_BROKEN_GETPASS -DNO_FCNTL_NONBLOCK -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT" - CXXFLAGS="$CXXFLAGS -DHPUX11 -DHAVE_BROKEN_PREAD -DDONT_USE_FINITE -D_INCLUDE_LONGLONG -DNO_FCNTL_NONBLOCK -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT" + CFLAGS="$CFLAGS -DHPUX11 -DSNPRINTF_RETURN_TRUNC -DHAVE_BROKEN_PREAD -DDONT_USE_FINITE -DHAVE_BROKEN_GETPASS -DNO_FCNTL_NONBLOCK -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT" + CXXFLAGS="$CXXFLAGS -DHPUX11 -DSNPRINTF_RETURN_TRUNC -DHAVE_BROKEN_PREAD -DDONT_USE_FINITE -D_INCLUDE_LONGLONG -DNO_FCNTL_NONBLOCK -DDO_NOT_REMOVE_THREAD_WRAPPERS -DHAVE_BROKEN_PTHREAD_COND_TIMEDWAIT" if test "$with_named_thread" = "no" then echo "Using --with-named-thread=-lpthread" diff --git a/include/my_list.h b/include/my_list.h index 789bbb50f97..f786621e311 100644 --- a/include/my_list.h +++ b/include/my_list.h @@ -33,8 +33,8 @@ extern LIST *list_delete(LIST *root,LIST *element); 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 *list); -extern int list_walk(LIST *list,list_walk_action action,gptr argument); +extern unsigned int list_length(LIST *); +extern int list_walk(LIST *,list_walk_action action,gptr argument); #define rest(a) ((a)->next) #define list_push(a,b) (a)=list_cons((b),(a)) diff --git a/include/mysql_com.h b/include/mysql_com.h index 4686acc098f..6a6136bd974 100644 --- a/include/mysql_com.h +++ b/include/mysql_com.h @@ -282,13 +282,7 @@ void my_net_local_init(NET *net); void net_end(NET *net); void net_clear(NET *net); my_bool net_realloc(NET *net, unsigned long length); - -#ifndef EMBEDDED_LIBRARY /* To be removed by HF */ my_bool net_flush(NET *net); -#else -#define net_flush(A) -#endif - my_bool my_net_write(NET *net,const char *packet,unsigned long len); my_bool net_write_command(NET *net,unsigned char command, const char *header, unsigned long head_len, diff --git a/innobase/dict/dict0crea.c b/innobase/dict/dict0crea.c index 137964b26c1..cbdc0aab53c 100644 --- a/innobase/dict/dict0crea.c +++ b/innobase/dict/dict0crea.c @@ -1067,6 +1067,12 @@ dict_create_or_check_foreign_constraint_tables(void) there are 2 secondary indexes on SYS_FOREIGN, and they are defined just like below */ + /* NOTE: when designing InnoDB's foreign key support in 2001, we made + an error and made the table names and the foreign key id of type + 'CHAR' (internally, really a VARCHAR). We should have made the type + VARBINARY, like in other InnoDB system tables, to get a clean + design. */ + str = "PROCEDURE CREATE_FOREIGN_SYS_TABLES_PROC () IS\n" "BEGIN\n" @@ -1284,9 +1290,17 @@ loop: fputs(".\nA foreign key constraint of name ", ef); ut_print_name(ef, trx, foreign->id); fputs("\nalready exists." - " (Note that internally InnoDB adds 'databasename/'\n" + " (Note that internally InnoDB adds 'databasename/'\n" "in front of the user-defined constraint name).\n", ef); + fputs("Note that InnoDB's FOREIGN KEY system tables store\n" + "constraint names as case-insensitive, with the\n" + "MySQL standard latin1_swedish_ci collation. If you\n" + "create tables or databases whose names differ only in\n" + "the character case, then collisions in constraint\n" + "names can occur. Workaround: name your constraints\n" + "explicitly with unique names.\n", + ef); mutex_exit(&dict_foreign_err_mutex); diff --git a/innobase/dict/dict0dict.c b/innobase/dict/dict0dict.c index c3d0d8d9ac1..bc08fc2437e 100644 --- a/innobase/dict/dict0dict.c +++ b/innobase/dict/dict0dict.c @@ -156,7 +156,7 @@ dict_index_build_internal_non_clust( dict_index_t* index); /* in: user representation of a non-clustered index */ /************************************************************************** -Removes a foreign constraint struct from the dictionet cache. */ +Removes a foreign constraint struct from the dictionary cache. */ static void dict_foreign_remove_from_cache( @@ -606,7 +606,7 @@ dict_table_get_on_id( dict_table_t* table; if (ut_dulint_cmp(table_id, DICT_FIELDS_ID) <= 0 - || trx->dict_operation) { + || trx->dict_operation_lock_mode == RW_X_LATCH) { /* It is a system table which will always exist in the table cache: we avoid acquiring the dictionary mutex, because if we are doing a rollback to handle an error in TABLE diff --git a/innobase/dict/dict0load.c b/innobase/dict/dict0load.c index c2b778f77c3..8fc6eb9141e 100644 --- a/innobase/dict/dict0load.c +++ b/innobase/dict/dict0load.c @@ -19,6 +19,7 @@ Created 4/24/1996 Heikki Tuuri #include "mach0data.h" #include "dict0dict.h" #include "dict0boot.h" +#include "rem0cmp.h" #include "srv0start.h" #include "srv0srv.h" @@ -1256,12 +1257,26 @@ loop: rec = btr_pcur_get_rec(&pcur); field = rec_get_nth_field(rec, 0, &len); - /* Check if the table name in record is the one searched for */ - if (len != ut_strlen(table_name) - || 0 != ut_memcmp(field, table_name, len)) { + /* Check if the table name in the record is the one searched for; the + following call does the comparison in the latin1_swedish_ci + charset-collation, in a case-insensitive way. */ + if (0 != cmp_data_data(dfield_get_type(dfield), + dfield_get_data(dfield), dfield_get_len(dfield), + field, len)) { + goto load_next_index; } + + /* Since table names in SYS_FOREIGN are stored in a case-insensitive + order, we have to check that the table name matches also in a binary + string comparison. On Unix, MySQL allows table names that only differ + in character case. */ + + if (0 != ut_memcmp(field, table_name, len)) { + + goto next_rec; + } if (rec_get_deleted_flag(rec)) { diff --git a/innobase/eval/eval0eval.c b/innobase/eval/eval0eval.c index ebb6cb1b7d9..5b2d1f857b1 100644 --- a/innobase/eval/eval0eval.c +++ b/innobase/eval/eval0eval.c @@ -627,7 +627,11 @@ eval_concat( } /********************************************************************* -Evaluates a predefined function node. */ +Evaluates a predefined function node. If the first argument is an integer, +this function looks at the second argument which is the integer length in +bytes, and converts the integer to a VARCHAR. +If the first argument is of some other type, this function converts it to +BINARY. */ UNIV_INLINE void eval_to_binary( @@ -638,12 +642,24 @@ eval_to_binary( que_node_t* arg2; dfield_t* dfield; byte* str1; + ulint len; ulint len1; arg1 = func_node->args; str1 = dfield_get_data(que_node_get_val(arg1)); + if (dtype_get_mtype(que_node_get_data_type(arg1)) != DATA_INT) { + + len = dfield_get_len(que_node_get_val(arg1)); + + dfield = que_node_get_val(func_node); + + dfield_set_data(dfield, str1, len); + + return; + } + arg2 = que_node_get_next(arg1); len1 = (ulint)eval_node_get_int_val(arg2); diff --git a/innobase/ibuf/ibuf0ibuf.c b/innobase/ibuf/ibuf0ibuf.c index b3c8ade2414..2191cdc0ee6 100644 --- a/innobase/ibuf/ibuf0ibuf.c +++ b/innobase/ibuf/ibuf0ibuf.c @@ -2866,6 +2866,8 @@ ibuf_delete_rec( #ifdef UNIV_IBUF_DEBUG ibuf_count_set(space, page_no, ibuf_count_get(space, page_no) - 1); +#else + UT_NOT_USED(space); #endif ibuf_data_sizes_update(ibuf_data, root, mtr); @@ -3267,11 +3269,11 @@ leave_loop: ibuf_data->n_merged_recs += n_inserts; mutex_exit(&ibuf_mutex); - + /* fprintf(stderr, "InnoDB: Discarded %lu ibuf entries for space %lu\n", (ulong) n_inserts, (ulong) space); - + */ ibuf_exit(); mem_heap_free(heap); diff --git a/innobase/pars/pars0pars.c b/innobase/pars/pars0pars.c index 846cb060a7e..16d630dd318 100644 --- a/innobase/pars/pars0pars.c +++ b/innobase/pars/pars0pars.c @@ -259,9 +259,13 @@ pars_resolve_func_data_type( dtype_set(que_node_get_data_type(node), DATA_VARCHAR, DATA_ENGLISH, 0, 0); } else if (func == PARS_TO_BINARY_TOKEN) { - ut_a(dtype_get_mtype(que_node_get_data_type(arg)) == DATA_INT); - dtype_set(que_node_get_data_type(node), DATA_VARCHAR, + if (dtype_get_mtype(que_node_get_data_type(arg)) == DATA_INT) { + dtype_set(que_node_get_data_type(node), DATA_VARCHAR, DATA_ENGLISH, 0, 0); + } else { + dtype_set(que_node_get_data_type(node), DATA_BINARY, + 0, 0, 0); + } } else if (func == PARS_TO_NUMBER_TOKEN) { ut_a(dtype_get_mtype(que_node_get_data_type(arg)) == DATA_VARCHAR); diff --git a/innobase/row/row0mysql.c b/innobase/row/row0mysql.c index 241ddc310e8..f356ef8081e 100644 --- a/innobase/row/row0mysql.c +++ b/innobase/row/row0mysql.c @@ -2314,7 +2314,8 @@ row_drop_table_for_mysql( "WHILE found = 1 LOOP\n" " SELECT ID INTO foreign_id\n" " FROM SYS_FOREIGN\n" - " WHERE FOR_NAME = table_name;\n" + " WHERE FOR_NAME = table_name\n" + " AND TO_BINARY(FOR_NAME) = TO_BINARY(table_name);\n" " IF (SQL % NOTFOUND) THEN\n" " found := 0;\n" " ELSE" @@ -2769,7 +2770,8 @@ row_rename_table_for_mysql( "WHILE found = 1 LOOP\n" " SELECT ID INTO foreign_id\n" " FROM SYS_FOREIGN\n" - " WHERE FOR_NAME = old_table_name;\n" + " WHERE FOR_NAME = old_table_name\n" + " AND TO_BINARY(FOR_NAME) = TO_BINARY(old_table_name);\n" " IF (SQL % NOTFOUND) THEN\n" " found := 0;\n" " ELSE\n" @@ -2802,7 +2804,8 @@ row_rename_table_for_mysql( " END IF;\n" "END LOOP;\n" "UPDATE SYS_FOREIGN SET REF_NAME = new_table_name\n" - "WHERE REF_NAME = old_table_name;\n"; + "WHERE REF_NAME = old_table_name\n" + " AND TO_BINARY(REF_NAME) = TO_BINARY(old_table_name);\n"; static const char str5[] = "END;\n"; @@ -3012,7 +3015,11 @@ row_rename_table_for_mysql( if (err != DB_SUCCESS) { if (err == DB_DUPLICATE_KEY) { ut_print_timestamp(stderr); - fputs(" InnoDB: Error: table ", stderr); + fputs( + " InnoDB: Error; possible reasons:\n" + "InnoDB: 1) Table rename would cause two FOREIGN KEY constraints\n" + "InnoDB: to have the same internal name in case-insensitive comparison.\n" + "InnoDB: 2) table ", stderr); ut_print_name(stderr, trx, new_name); fputs(" exists in the InnoDB internal data\n" "InnoDB: dictionary though MySQL is trying rename table ", stderr); diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index 5dc9ede1ca6..d75dbd5d00c 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -7,11 +7,6 @@ otto select otto from (select 1 as otto) as t1; otto 1 -select otto from (select 1 as otto) as t1; -otto -1 -select friedrich from (select 1 as otto) as t1; -ERROR 42S22: Unknown column 'friedrich' in 'field list' select friedrich from (select 1 as otto) as t1; ERROR 42S22: Unknown column 'friedrich' in 'field list' select otto from (select 1 as otto) as t1; @@ -147,5 +142,3 @@ after_--enable_abort_on_error 1064 select 3 from t1 ; ERROR 42S02: Table 'test.t1' doesn't exist -select 3 from t1 ; -ERROR 42S02: Table 'test.t1' doesn't exist diff --git a/mysql-test/r/ndb_blob.result b/mysql-test/r/ndb_blob.result index 1f2cf33f57d..156c2d570a4 100644 --- a/mysql-test/r/ndb_blob.result +++ b/mysql-test/r/ndb_blob.result @@ -414,6 +414,7 @@ a b c d 9 b9 999 dd9 drop table t1; drop database test2; +set autocommit=0; create table t1 ( a int not null primary key, b tinytext @@ -422,9 +423,13 @@ insert into t1 values(1, 'x'); update t1 set b = 'y'; select * from t1; a b -1 x +1 y delete from t1; +select * from t1; +a b +commit; drop table t1; +set autocommit=0; create table t1 ( a int not null primary key, b text not null @@ -433,6 +438,7 @@ insert into t1 values(1, ''); select * from t1; a b 1 +commit; drop table t1; set autocommit=1; use test; @@ -454,6 +460,7 @@ select * from t1 order by a; a b 1 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA 2 BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB +set autocommit=1; alter table t1 engine=myisam; select * from t1 order by a; a b diff --git a/mysql-test/r/ps_10nestset.result b/mysql-test/r/ps_10nestset.result index 68f58a03674..ff63485a5f9 100644 --- a/mysql-test/r/ps_10nestset.result +++ b/mysql-test/r/ps_10nestset.result @@ -62,4 +62,15 @@ id emp salary l r 4 Donna 1064.80 5 6 5 Eddie 931.70 7 8 6 Fred 798.60 9 10 +prepare st_round from 'update t1 set salary = salary + ? - ( salary MOD ? )'; +set @arg_round= 50; +execute st_round using @arg_round, @arg_round; +select * from t1; +id emp salary l r +1 Jerry 1350.00 1 12 +2 Bert 1200.00 2 3 +3 Chuck 1250.00 4 11 +4 Donna 1100.00 5 6 +5 Eddie 950.00 7 8 +6 Fred 800.00 9 10 drop table t1; diff --git a/mysql-test/r/range.result b/mysql-test/r/range.result index 4ca96316800..17ed9513653 100644 --- a/mysql-test/r/range.result +++ b/mysql-test/r/range.result @@ -561,3 +561,19 @@ select count(*) from t1 where x = 18446744073709551601; count(*) 1 drop table t1; +set names latin1; +create table t1 (a char(10), b text, key (a)) character set latin1; +INSERT INTO t1 (a) VALUES +('111'),('222'),('222'),('222'),('222'),('444'),('aaa'),('AAA'),('bbb'); +explain select * from t1 where a='aaa'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ref a a 11 const 2 Using where +explain select * from t1 where a=binary 'aaa'; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 11 NULL 2 Using where +explain select * from t1 where a='aaa' collate latin1_bin; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 range a a 11 NULL 2 Using where +explain select * from t1 where a='aaa' collate latin1_german1_ci; +id select_type table type possible_keys key key_len ref rows Extra +1 SIMPLE t1 ALL a NULL NULL NULL 9 Using where diff --git a/mysql-test/r/rpl_failed_optimize.result b/mysql-test/r/rpl_failed_optimize.result new file mode 100644 index 00000000000..1576ec60500 --- /dev/null +++ b/mysql-test/r/rpl_failed_optimize.result @@ -0,0 +1,15 @@ +stop slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +reset master; +reset slave; +drop table if exists t1,t2,t3,t4,t5,t6,t7,t8,t9; +start slave; +CREATE TABLE t1 ( a int ) ENGINE=InnoDB; +BEGIN; +INSERT INTO t1 VALUES (1); +OPTIMIZE TABLE t1; +Table Op Msg_type Msg_text +test.t1 optimize status Operation failed +OPTIMIZE TABLE non_existing; +Table Op Msg_type Msg_text +test.non_existing optimize error Table 'test.non_existing' doesn't exist diff --git a/mysql-test/r/sql_mode.result b/mysql-test/r/sql_mode.result index e54dd217f8c..c18be2df403 100644 --- a/mysql-test/r/sql_mode.result +++ b/mysql-test/r/sql_mode.result @@ -85,6 +85,36 @@ t1 CREATE TABLE "t1" ( UNIQUE KEY "email" ("email") ) drop table t1; +CREATE TABLE t1 ( +a char(10), +b char(10) collate latin1_bin, +c binary(10) +) character set latin1; +set @@sql_mode=""; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(10) default NULL, + `b` char(10) character set latin1 collate latin1_bin default NULL, + `c` binary(10) default NULL +) ENGINE=MyISAM DEFAULT CHARSET=latin1 +set @@sql_mode="mysql323"; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(10) default NULL, + `b` char(10) binary default NULL, + `c` binary(10) default NULL +) TYPE=MyISAM +set @@sql_mode="mysql40"; +show create table t1; +Table Create Table +t1 CREATE TABLE `t1` ( + `a` char(10) default NULL, + `b` char(10) binary default NULL, + `c` binary(10) default NULL +) TYPE=MyISAM +drop table t1; set session sql_mode = ''; create table t1 ( min_num dec(6,6) default .000001); show create table t1; diff --git a/mysql-test/t/client_test.test b/mysql-test/t/client_test.test index b56e8038d9b..830c5f1b8a2 100644 --- a/mysql-test/t/client_test.test +++ b/mysql-test/t/client_test.test @@ -1,2 +1,2 @@ --disable_result_log ---exec $TESTS_BINDIR/client_test --testcase --user=root --socket=$MASTER_MYSOCK --port=$MYSQL_TCP_PORT +--exec $TESTS_BINDIR/client_test --testcase --user=root --socket=$MASTER_MYSOCK --port=$MYSQL_TCP_PORT --silent diff --git a/mysql-test/t/comments.test b/mysql-test/t/comments.test index 2fc6237907c..087df60f3f5 100644 --- a/mysql-test/t/comments.test +++ b/mysql-test/t/comments.test @@ -5,7 +5,8 @@ select 1+2/*hello*/+3; select 1 /* long multi line comment */; -!$1065 ; +--error 1065 + ; select 1 /*!32301 +1 */; select 1 /*!52301 +1 */; select 1--1; diff --git a/mysql-test/t/join_outer.test b/mysql-test/t/join_outer.test index 0c4c9614d88..bc96318ae2e 100644 --- a/mysql-test/t/join_outer.test +++ b/mysql-test/t/join_outer.test @@ -34,11 +34,14 @@ explain select t1.*,t2.* from t1 left join t2 on t1.a=t2.a where isnull(t2.a)=1; select t1.*,t2.*,t3.a from t1 left join t2 on (t1.a=t2.a) left join t1 as t3 on (t2.a=t3.a); # The next query should rearange the left joins to get this to work -!$1120 explain select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); -!$1120 select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); +--error 1120 +explain select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); +--error 1120 +select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t1.a=t3.a); # The next query should give an error in MySQL -!$1120 select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t2.a=t3.a); +--error 1120 +select t1.*,t2.*,t3.a from t1 left join t2 on (t3.a=t2.a) left join t1 as t3 on (t2.a=t3.a); # Test of inner join select t1.*,t2.* from t1 inner join t2 using (a); @@ -94,7 +97,8 @@ WHERE t1.uniq_id = 4 ORDER BY t2.c_amount; INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); -!$1062 INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); +--error 1062 +INSERT INTO t2 VALUES (2,3,3000,6000,0,0,746584,837484,'yes'); INSERT INTO t2 VALUES (7,3,1000,2000,0,0,746294,937484,'yes'); #3rd select should show that one record is returned with null entries for the @@ -288,7 +292,8 @@ insert into t3 values (1); insert into t4 values (1,1); insert into t5 values (1,1); -!$1120 explain select * from t3 left join t4 on t4.seq_1_id = t2.t2_id left join t1 on t1.t1_id = t4.seq_0_id left join t5 on t5.seq_0_id = t1.t1_id left join t2 on t2.t2_id = t5.seq_1_id where t3.t3_id = 23; +--error 1120 +explain select * from t3 left join t4 on t4.seq_1_id = t2.t2_id left join t1 on t1.t1_id = t4.seq_0_id left join t5 on t5.seq_0_id = t1.t1_id left join t2 on t2.t2_id = t5.seq_1_id where t3.t3_id = 23; drop table t1,t2,t3,t4,t5; diff --git a/mysql-test/t/key.test b/mysql-test/t/key.test index 4be34cac30e..5ee2f68ab83 100644 --- a/mysql-test/t/key.test +++ b/mysql-test/t/key.test @@ -146,7 +146,8 @@ create table t1 ); INSERT INTO t1 VALUES (1, 1, 1, 1, 'a'); INSERT INTO t1 VALUES (1, 1, 1, 1, 'b'); -!$1062 INSERT INTO t1 VALUES (1, 1, 1, 1, 'a'); +--error 1062 +INSERT INTO t1 VALUES (1, 1, 1, 1, 'a'); drop table t1; # diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index b7007e1a519..0802c18ed6c 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -20,12 +20,10 @@ eval select $mysql_errno as "before_use_test" ; select otto from (select 1 as otto) as t1; # expectation = response -!$0 select otto from (select 1 as otto) as t1; --error 0 select otto from (select 1 as otto) as t1; # expectation <> response --- // !$1054 select otto from (select 1 as otto) as t1; -- // --error 1054 -- // select otto from (select 1 as otto) as t1; @@ -38,12 +36,10 @@ select otto from (select 1 as otto) as t1; # ---------------------------------------------------------------------------- # expectation <> response -#!$0 select friedrich from (select 1 as otto) as t1; #--error 0 #select friedrich from (select 1 as otto) as t1; # expectation = response -!$1054 select friedrich from (select 1 as otto) as t1; --error 1054 select friedrich from (select 1 as otto) as t1; @@ -94,130 +90,130 @@ select friedrich from (select 1 as otto) as t1; # # The following test cases often initialize $mysql_errno to 1064 by # a command with wrong syntax. -# Example: !$1064 To prevent the abort after the error. +# Example: --error 1064 To prevent the abort after the error. # garbage ; # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# 1. check mysql_errno = 0 after successful statement +# check mysql_errno = 0 after successful statement # ---------------------------------------------------------------------------- select otto from (select 1 as otto) as t1; eval select $mysql_errno as "after_successful_stmt_errno" ; #---------------------------------------------------------------------------- -# 2. check mysql_errno = 1064 after statement with wrong syntax +# check mysql_errno = 1064 after statement with wrong syntax # ---------------------------------------------------------------------------- -!$1064 +--error 1064 garbage ; eval select $mysql_errno as "after_wrong_syntax_errno" ; # ---------------------------------------------------------------------------- -# 3. check if let $my_var= 'abc' ; affects $mysql_errno +# check if let $my_var= 'abc' ; affects $mysql_errno # ---------------------------------------------------------------------------- -!$1064 +--error 1064 garbage ; let $my_var= 'abc' ; eval select $mysql_errno as "after_let_var_equal_value" ; # ---------------------------------------------------------------------------- -# 4. check if set @my_var= 'abc' ; affects $mysql_errno +# check if set @my_var= 'abc' ; affects $mysql_errno # ---------------------------------------------------------------------------- -!$1064 +--error 1064 garbage ; set @my_var= 'abc' ; eval select $mysql_errno as "after_set_var_equal_value" ; # ---------------------------------------------------------------------------- -# 5. check if the setting of --disable-warnings itself affects $mysql_errno -# (May be --<whatever> modifies $mysql_errno.) +# check if the setting of --disable-warnings itself affects $mysql_errno +# (May be --<whatever> modifies $mysql_errno.) # ---------------------------------------------------------------------------- -!$1064 +--error 1064 garbage ; --disable_warnings eval select $mysql_errno as "after_disable_warnings_command" ; # ---------------------------------------------------------------------------- -# 6. check if --disable-warnings + command with warning affects the errno -# stored within $mysql_errno -# (May be disabled warnings affect $mysql_errno.) +# check if --disable-warnings + command with warning affects the errno +# stored within $mysql_errno +# (May be disabled warnings affect $mysql_errno.) # ---------------------------------------------------------------------------- drop table if exists t1 ; -!$1064 +--error 1064 garbage ; drop table if exists t1 ; eval select $mysql_errno as "after_disable_warnings" ; --enable_warnings # ---------------------------------------------------------------------------- -# 7. check if masked errors affect $mysql_errno +# check if masked errors affect $mysql_errno # ---------------------------------------------------------------------------- -!$1064 +--error 1064 garbage ; --error 1146 select 3 from t1 ; eval select $mysql_errno as "after_minus_masked" ; -!$1064 +--error 1064 garbage ; -!$1146 +--error 1146 select 3 from t1 ; eval select $mysql_errno as "after_!_masked" ; # ---------------------------------------------------------------------------- -# 8. Will manipulations of $mysql_errno be possible and visible ? +# Will manipulations of $mysql_errno be possible and visible ? # ---------------------------------------------------------------------------- -!$1064 +--error 1064 garbage ; let $mysql_errno= -1; eval select $mysql_errno as "after_let_errno_equal_value" ; # ---------------------------------------------------------------------------- -# 9. How affect actions on prepared statements $mysql_errno ? +# How affect actions on prepared statements $mysql_errno ? # ---------------------------------------------------------------------------- # failing prepare -!$1064 +--error 1064 garbage ; -!$1146 +--error 1146 prepare stmt from "select 3 from t1" ; eval select $mysql_errno as "after_failing_prepare" ; create table t1 ( f1 char(10)); # successful prepare -!$1064 +--error 1064 garbage ; prepare stmt from "select 3 from t1" ; eval select $mysql_errno as "after_successful_prepare" ; # successful execute -!$1064 +--error 1064 garbage ; execute stmt; eval select $mysql_errno as "after_successful_execute" ; # failing execute (table dropped) drop table t1; -!$1064 +--error 1064 garbage ; -!$1146 +--error 1146 execute stmt; eval select $mysql_errno as "after_failing_execute" ; # failing execute (unknown statement) -!$1064 +--error 1064 garbage ; -!$1243 +--error 1243 execute __stmt_; eval select $mysql_errno as "after_failing_execute" ; # successful deallocate -!$1064 +--error 1064 garbage ; deallocate prepare stmt; eval select $mysql_errno as "after_successful_deallocate" ; # failing deallocate ( statement handle does not exist ) -!$1064 +--error 1064 garbage ; -!$1243 +--error 1243 deallocate prepare __stmt_; eval select $mysql_errno as "after_failing_deallocate" ; @@ -231,7 +227,7 @@ eval select $mysql_errno as "after_failing_deallocate" ; # The default is "--enable_abort_on_error". # # "Maskings" are -# !$<error number> and --error <error number> +# --error <error number> and --error <error number> # in the line before the failing statement. # # There are some additional test case for $mysql_errno @@ -240,58 +236,53 @@ eval select $mysql_errno as "after_failing_deallocate" ; # ---------------------------------------------------------------------------- # ---------------------------------------------------------------------------- -# 1. Switch the abort on error off and check the effect on $mysql_errno +# Switch the abort on error off and check the effect on $mysql_errno # ---------------------------------------------------------------------------- -!$1064 +--error 1064 garbage ; --disable_abort_on_error eval select $mysql_errno as "after_--disable_abort_on_error" ; # ---------------------------------------------------------------------------- -# 2. "unmasked" failing statement should not cause an abort +# "unmasked" failing statement should not cause an abort # ---------------------------------------------------------------------------- select 3 from t1 ; # ---------------------------------------------------------------------------- -# 3. masked failing statements +# masked failing statements # ---------------------------------------------------------------------------- # expected error = response --error 1146 select 3 from t1 ; -!$1146 +--error 1146 select 3 from t1 ; eval select $mysql_errno as "after_!errno_masked_error" ; # expected error <> response # --error 1000 # select 3 from t1 ; -# !$1000 +# --error 1000 # select 3 from t1 ; # ---------------------------------------------------------------------------- -# 4. Switch the abort on error on and check the effect on $mysql_errno +# Switch the abort on error on and check the effect on $mysql_errno # ---------------------------------------------------------------------------- -!$1064 +--error 1064 garbage ; --enable_abort_on_error eval select $mysql_errno as "after_--enable_abort_on_error" ; # ---------------------------------------------------------------------------- -# 5. masked failing statements +# masked failing statements # ---------------------------------------------------------------------------- # expected error = response --error 1146 select 3 from t1 ; -!$1146 -select 3 from t1 ; # ---------------------------------------------------------------------------- -# 6. check that the old default behaviour is not changed +# check that the old default behaviour is not changed # Please remove the '#' to get the abort on error # ---------------------------------------------------------------------------- #--error 1064 #select 3 from t1 ; # -#!$1064 -#select 3 from t1 ; -# #select 3 from t1 ; diff --git a/mysql-test/t/ndb_blob.test b/mysql-test/t/ndb_blob.test index ba5f089b17b..06ecbc66d97 100644 --- a/mysql-test/t/ndb_blob.test +++ b/mysql-test/t/ndb_blob.test @@ -337,8 +337,9 @@ select * from t1 order by a; drop table t1; drop database test2; -# -- bug-5252 tinytext crashes -- +# -- bug-5252 tinytext crashes plus no-commit result -- +set autocommit=0; create table t1 ( a int not null primary key, b tinytext @@ -348,10 +349,13 @@ insert into t1 values(1, 'x'); update t1 set b = 'y'; select * from t1; delete from t1; +select * from t1; +commit; drop table t1; # -- bug-5013 insert empty string to text -- +set autocommit=0; create table t1 ( a int not null primary key, b text not null @@ -359,6 +363,7 @@ create table t1 ( insert into t1 values(1, ''); select * from t1; +commit; drop table t1; # -- bug #5349 -- @@ -380,6 +385,7 @@ alter table t1 engine=ndb; select * from t1 order by a; # -- bug #5872 -- +set autocommit=1; alter table t1 engine=myisam; select * from t1 order by a; drop table t1; diff --git a/mysql-test/t/ps_10nestset.test b/mysql-test/t/ps_10nestset.test index d2adaca689e..53e84f7a47d 100644 --- a/mysql-test/t/ps_10nestset.test +++ b/mysql-test/t/ps_10nestset.test @@ -61,12 +61,11 @@ while ($1) select * from t1; -# Waiting for the resolution of bug#6138 -# # Now, increase salary to a multiple of 50 -# prepare st_round from 'update t1 set salary = salary + ? - ( salary MOD ? )'; -# set @arg_round= 50; -# execute st_round using @arg_round, @arg_round; -# -# select * from t1; +# Now, increase salary to a multiple of 50 (checks for bug#6138) +prepare st_round from 'update t1 set salary = salary + ? - ( salary MOD ? )'; +set @arg_round= 50; +execute st_round using @arg_round, @arg_round; + +select * from t1; drop table t1; diff --git a/mysql-test/t/range.test b/mysql-test/t/range.test index cd6620f7126..44f55da5722 100644 --- a/mysql-test/t/range.test +++ b/mysql-test/t/range.test @@ -431,3 +431,17 @@ select count(*) from t1 where x = 18446744073709551601; drop table t1; +# +# Bug #6045: Binary Comparison regression in MySQL 4.1 +# Binary searches didn't use a case insensitive index. +# +set names latin1; +create table t1 (a char(10), b text, key (a)) character set latin1; +INSERT INTO t1 (a) VALUES +('111'),('222'),('222'),('222'),('222'),('444'),('aaa'),('AAA'),('bbb'); +# all these three can be optimized +explain select * from t1 where a='aaa'; +explain select * from t1 where a=binary 'aaa'; +explain select * from t1 where a='aaa' collate latin1_bin; +# this one cannot: +explain select * from t1 where a='aaa' collate latin1_german1_ci; diff --git a/mysql-test/t/rpl_failed_optimize-master.opt b/mysql-test/t/rpl_failed_optimize-master.opt new file mode 100644 index 00000000000..a6ef074a120 --- /dev/null +++ b/mysql-test/t/rpl_failed_optimize-master.opt @@ -0,0 +1 @@ +--innodb-lock-wait-timeout=1 diff --git a/mysql-test/t/rpl_failed_optimize.test b/mysql-test/t/rpl_failed_optimize.test new file mode 100644 index 00000000000..d245d1bacbb --- /dev/null +++ b/mysql-test/t/rpl_failed_optimize.test @@ -0,0 +1,18 @@ +source include/have_innodb.inc; +source include/master-slave.inc; + +# +# BUG#5551 "Failed OPTIMIZE TABLE is logged to binary log" +# Replication should work when OPTIMIZE TABLE timeouts, and +# when OPTIMIZE TABLE is executed on a non-existing table +# + +CREATE TABLE t1 ( a int ) ENGINE=InnoDB; +BEGIN; +INSERT INTO t1 VALUES (1); + +connection master1; +OPTIMIZE TABLE t1; + +OPTIMIZE TABLE non_existing; +sync_slave_with_master; diff --git a/mysql-test/t/show_check.test b/mysql-test/t/show_check.test index 681127eab5e..efbe2e9371d 100644 --- a/mysql-test/t/show_check.test +++ b/mysql-test/t/show_check.test @@ -21,7 +21,8 @@ check table t1 changed; check table t1 medium; check table t1 extended; show index from t1; -!$1062 insert into t1 values (5,5,5); +--error 1062 +insert into t1 values (5,5,5); optimize table t1; optimize table t1; drop table t1; diff --git a/mysql-test/t/sql_mode.test b/mysql-test/t/sql_mode.test index 63a5d6d3671..f841d36e837 100644 --- a/mysql-test/t/sql_mode.test +++ b/mysql-test/t/sql_mode.test @@ -30,6 +30,37 @@ show create table t1; drop table t1; # +# Check that a binary collation adds 'binary' +# suffix into a char() column definition in +# mysql40 and mysql2323 modes. This allows +# not to lose the column's case sensitivity +# when loading the dump in pre-4.1 servers. +# +# Thus, in 4.0 and 3.23 modes we dump: +# +# 'char(10) collate xxx_bin' as 'char(10) binary' +# 'binary(10)' as 'binary(10)' +# +# In mysql-4.1 these types are different, and they will +# be recreated differently. +# +# In mysqld-4.0 the the above two types were the same, +# so it will create a 'char(10) binary' column for both definitions. +# +CREATE TABLE t1 ( + a char(10), + b char(10) collate latin1_bin, + c binary(10) +) character set latin1; +set @@sql_mode=""; +show create table t1; +set @@sql_mode="mysql323"; +show create table t1; +set @@sql_mode="mysql40"; +show create table t1; +drop table t1; + +# # BUG#5318 - failure: 'IGNORE_SPACE' affects numeric values after DEFAULT # # Force the usage of the default diff --git a/mysql-test/t/temp_table.test b/mysql-test/t/temp_table.test index 2181d3eb74c..74276c7668c 100644 --- a/mysql-test/t/temp_table.test +++ b/mysql-test/t/temp_table.test @@ -20,8 +20,10 @@ create TEMPORARY TABLE t2 engine=heap select * from t1; create TEMPORARY TABLE IF NOT EXISTS t2 (a int) engine=heap; # This should give errors -!$1050 CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null); -!$1050 ALTER TABLE t1 RENAME t2; +--error 1050 +CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null); +--error 1050 +ALTER TABLE t1 RENAME t2; select * from t2; alter table t2 add primary key (a,b); diff --git a/mysql-test/t/type_ranges.test b/mysql-test/t/type_ranges.test index 09b5867e7a8..572dc0af313 100644 --- a/mysql-test/t/type_ranges.test +++ b/mysql-test/t/type_ranges.test @@ -135,7 +135,8 @@ drop table t1,t2; create table t1 (c int); insert into t1 values(1),(2); create table t2 select * from t1; -!$1060 create table t3 select * from t1, t2; # Should give an error +--error 1060 +create table t3 select * from t1, t2; # Should give an error create table t3 select t1.c AS c1, t2.c AS c2,1 as "const" from t1, t2; show full columns from t3; drop table t1,t2,t3; diff --git a/ndb/src/common/editline/sysunix.c b/ndb/src/common/editline/sysunix.c index 1339e5769e2..d7437f6a9c7 100644 --- a/ndb/src/common/editline/sysunix.c +++ b/ndb/src/common/editline/sysunix.c @@ -139,7 +139,7 @@ rl_add_slash(char *path, char *p, size_t p_len) struct stat Sb; if (stat(path, &Sb) >= 0) { - int len= strlen(p); + size_t len= strlen(p); if (len+1 < p_len) { p[len]= S_ISDIR(Sb.st_mode) ? '/' : ' '; p[len+1]= 0; diff --git a/ndb/src/common/util/basestring_vsnprintf.c b/ndb/src/common/util/basestring_vsnprintf.c index c96d1a300e1..7307279f345 100644 --- a/ndb/src/common/util/basestring_vsnprintf.c +++ b/ndb/src/common/util/basestring_vsnprintf.c @@ -35,7 +35,11 @@ basestring_snprintf(char *str, size_t size, const char *format, ...) #define BASESTRING_VSNPRINTF_FUNC(a,b,c,d) vsnprintf(a,b,c,d) #else #define SNPRINTF_RETURN_TRUNC - #define BASESTRING_VSNPRINTF_FUNC(a,b,c,d) my_vsnprintf(a,b,c,d) + /* #define BASESTRING_VSNPRINTF_FUNC(a,b,c,d) my_vsnprintf(a,b,c,d) + * we would like to use my_vsnprintf but it does not have enough features + * Let's hope vsnprintf works anyways + */ + #define BASESTRING_VSNPRINTF_FUNC(a,b,c,d) vsnprintf(a,b,c,d) extern int my_vsnprintf(char *str, size_t size, const char *format, va_list ap); #endif #ifdef SNPRINTF_RETURN_TRUNC @@ -46,7 +50,7 @@ basestring_vsnprintf(char *str, size_t size, const char *format, va_list ap) { int ret= BASESTRING_VSNPRINTF_FUNC(str, size, format, ap); #ifdef SNPRINTF_RETURN_TRUNC - if (ret == size-1) { + if (ret == size-1 || ret == -1) { ret= BASESTRING_VSNPRINTF_FUNC(basestring_vsnprintf_buf, sizeof(basestring_vsnprintf_buf), format, ap); diff --git a/ndb/src/kernel/vm/Emulator.hpp b/ndb/src/kernel/vm/Emulator.hpp index bd240f8679b..b3c64830802 100644 --- a/ndb/src/kernel/vm/Emulator.hpp +++ b/ndb/src/kernel/vm/Emulator.hpp @@ -25,6 +25,7 @@ // //=========================================================================== #include <kernel_types.h> +#include <TransporterRegistry.hpp> extern class JobTable globalJobTable; extern class TimeQueue globalTimeQueue; diff --git a/ndb/src/mgmsrv/Services.cpp b/ndb/src/mgmsrv/Services.cpp index 5b552836955..2672d8c9d4b 100644 --- a/ndb/src/mgmsrv/Services.cpp +++ b/ndb/src/mgmsrv/Services.cpp @@ -773,8 +773,10 @@ MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &, /* XXX should use constants for this value */ if(level > 15) { - errorString.assign("Invalied loglevel"); - goto error; + m_output->println("set cluster loglevel reply"); + m_output->println("result: Invalid loglevel"); + m_output->println(""); + return; } EventSubscribeReq req; @@ -786,11 +788,6 @@ MgmApiSession::setClusterLogLevel(Parser<MgmApiSession>::Context &, m_output->println("set cluster loglevel reply"); m_output->println("result: Ok"); m_output->println(""); - return; -error: - m_output->println("set cluster loglevel reply"); - m_output->println("result: %s", errorString.c_str()); - m_output->println(""); } void @@ -807,8 +804,10 @@ MgmApiSession::setLogLevel(Parser<MgmApiSession>::Context &, /* XXX should use constants for this value */ if(level > 15) { - errorString.assign("Invalied loglevel"); - goto error; + m_output->println("set loglevel reply"); + m_output->println("result: Invalid loglevel", errorString.c_str()); + m_output->println(""); + return; } EventSubscribeReq req; @@ -820,11 +819,6 @@ MgmApiSession::setLogLevel(Parser<MgmApiSession>::Context &, m_output->println("set loglevel reply"); m_output->println("result: Ok"); m_output->println(""); - return; - error: - m_output->println("set loglevel reply"); - m_output->println("result: %s", errorString.c_str()); - m_output->println(""); } void diff --git a/ndb/src/ndbapi/NdbBlob.cpp b/ndb/src/ndbapi/NdbBlob.cpp index 9d21304939a..53c0a0e07f9 100644 --- a/ndb/src/ndbapi/NdbBlob.cpp +++ b/ndb/src/ndbapi/NdbBlob.cpp @@ -1428,6 +1428,18 @@ NdbBlob::postExecute(ExecType anExecType) if (invokeActiveHook() == -1) return -1; } + if (anExecType == NoCommit && theHeadInlineUpdateFlag) { + NdbOperation* tOp = theNdbCon->getNdbOperation(theTable); + if (tOp == NULL || + tOp->updateTuple() == -1 || + setTableKeyValue(tOp) == -1 || + setHeadInlineValue(tOp) == -1) { + setErrorCode(ErrAbort); + return -1; + } + tOp->m_abortOption = AbortOnError; + DBG("added op to update head+inline"); + } DBG("postExecute [out]"); return 0; } diff --git a/ndb/src/ndbapi/NdbConnection.cpp b/ndb/src/ndbapi/NdbConnection.cpp index c21a85fd24d..4f6468eb4ae 100644 --- a/ndb/src/ndbapi/NdbConnection.cpp +++ b/ndb/src/ndbapi/NdbConnection.cpp @@ -340,7 +340,12 @@ NdbConnection::execute(ExecType aTypeOfExec, if (executeNoBlobs(tExecType, abortOption, forceSend) == -1) ret = -1; +#ifndef VM_TRACE + // can happen in complex abort cases + theFirstOpInList = theLastOpInList = NULL; +#else assert(theFirstOpInList == NULL && theLastOpInList == NULL); +#endif { NdbOperation* tOp = theCompletedFirstOp; diff --git a/ndb/src/ndbapi/NdbDictionaryImpl.cpp b/ndb/src/ndbapi/NdbDictionaryImpl.cpp index 76854cabcd7..304d1b904d4 100644 --- a/ndb/src/ndbapi/NdbDictionaryImpl.cpp +++ b/ndb/src/ndbapi/NdbDictionaryImpl.cpp @@ -47,15 +47,13 @@ * Column */ NdbColumnImpl::NdbColumnImpl() - : NdbDictionary::Column(* this), m_facade(this), - m_attrId(-1) + : NdbDictionary::Column(* this), m_attrId(-1), m_facade(this) { init(); } NdbColumnImpl::NdbColumnImpl(NdbDictionary::Column & f) - : NdbDictionary::Column(* this), m_facade(&f), - m_attrId(-1) + : NdbDictionary::Column(* this), m_attrId(-1), m_facade(&f) { init(); } diff --git a/ndb/src/ndbapi/NdbOperationExec.cpp b/ndb/src/ndbapi/NdbOperationExec.cpp index 6d7a3817e04..13664794dcd 100644 --- a/ndb/src/ndbapi/NdbOperationExec.cpp +++ b/ndb/src/ndbapi/NdbOperationExec.cpp @@ -552,7 +552,7 @@ NdbOperation::receiveTCKEYREF( NdbApiSignal* aSignal) theNdbCon->theReturnStatus = NdbConnection::ReturnFailure; theError.code = aSignal->readData(4); - theNdbCon->setOperationErrorCodeAbort(aSignal->readData(4), ao); + theNdbCon->setOperationErrorCodeAbort(aSignal->readData(4), m_abortOption); if(theOperationType != ReadRequest || !theSimpleIndicator) // not simple read return theNdbCon->OpCompleteFailure(ao, m_abortOption != IgnoreError); diff --git a/ndb/src/ndbapi/ndberror.c b/ndb/src/ndbapi/ndberror.c index 20661b89517..17a80082023 100644 --- a/ndb/src/ndbapi/ndberror.c +++ b/ndb/src/ndbapi/ndberror.c @@ -150,7 +150,7 @@ ErrorBundle ErrorCodes[] = { { 623, IS, "623" }, { 624, IS, "624" }, { 625, IS, "Out of memory in Ndb Kernel, index part" }, - { 826, IS, "826" }, + { 826, IS, "Too many tables and attributes (increase MaxNoOfAttributes)" }, { 827, IS, "Out of memory in Ndb Kernel, data part" }, { 832, IS, "832" }, diff --git a/ndb/test/ndbapi/testBlobs.cpp b/ndb/test/ndbapi/testBlobs.cpp index 08bf8a2fd4b..efa0811aa39 100644 --- a/ndb/test/ndbapi/testBlobs.cpp +++ b/ndb/test/ndbapi/testBlobs.cpp @@ -42,6 +42,7 @@ struct Opt { bool m_core; bool m_dbg; bool m_dbgall; + const char* m_dbug; bool m_full; unsigned m_loop; unsigned m_parts; @@ -66,6 +67,7 @@ struct Opt { m_core(false), m_dbg(false), m_dbgall(false), + m_dbug(0), m_full(false), m_loop(1), m_parts(10), @@ -100,6 +102,7 @@ printusage() << " -core dump core on error" << endl << " -dbg print debug" << endl << " -dbgall print also NDB API debug (if compiled in)" << endl + << " -dbug opt dbug options" << endl << " -full read/write only full blob values" << endl << " -loop N loop N times 0=forever [" << d.m_loop << "]" << endl << " -parts N max parts in blob value [" << d.m_parts << "]" << endl @@ -1046,8 +1049,12 @@ writeIdx(int style) if (style == 0) { CHK(setBlobValue(tup) == 0); } else if (style == 1) { + // non-nullable must be set + CHK(g_bh1->setValue("", 0) == 0); CHK(setBlobWriteHook(tup) == 0); } else { + // non-nullable must be set + CHK(g_bh1->setValue("", 0) == 0); CHK(g_con->execute(NoCommit) == 0); CHK(writeBlobData(tup) == 0); } @@ -1463,6 +1470,12 @@ NDB_COMMAND(testOdbcDriver, "testBlobs", "testBlobs", "testBlobs", 65535) putenv(strdup("NDB_BLOB_DEBUG=1")); continue; } + if (strcmp(arg, "-dbug") == 0) { + if (++argv, --argc > 0) { + g_opt.m_dbug = strdup(argv[0]); + continue; + } + } if (strcmp(arg, "-full") == 0) { g_opt.m_full = true; continue; @@ -1533,6 +1546,9 @@ NDB_COMMAND(testOdbcDriver, "testBlobs", "testBlobs", "testBlobs", 65535) printusage(); return NDBT_ProgramExit(NDBT_WRONGARGS); } + if (g_opt.m_dbug != 0) { + DBUG_PUSH(g_opt.m_dbug); + } if (g_opt.m_pk2len == 0) { char b[100]; b[0] = 0; diff --git a/sql/field.cc b/sql/field.cc index 4b833874221..24bd0c48c92 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -4417,6 +4417,7 @@ void Field_string::sort_string(char *to,uint length) void Field_string::sql_type(String &res) const { + THD *thd= table->in_use; CHARSET_INFO *cs=res.charset(); ulong length= cs->cset->snprintf(cs,(char*) res.ptr(), res.alloced_length(), "%s(%d)", @@ -4427,6 +4428,9 @@ void Field_string::sql_type(String &res) const (has_charset() ? "char" : "binary")), (int) field_length / charset()->mbmaxlen); res.length(length); + if ((thd->variables.sql_mode & (MODE_MYSQL323 | MODE_MYSQL40)) && + has_charset() && (charset()->state & MY_CS_BINSORT)) + res.append(" binary"); } char *Field_string::pack(char *to, const char *from, uint max_length) diff --git a/sql/mysqld.cc b/sql/mysqld.cc index 7062334edbb..af6f25c1400 100644 --- a/sql/mysqld.cc +++ b/sql/mysqld.cc @@ -2918,11 +2918,10 @@ we force server id to 2, but this MySQL server will not act as a slave."); exit(1); #ifdef __WIN__ -#define MYSQL_ERR_FILE "mysql.err" if (!opt_console) { - freopen(MYSQL_ERR_FILE,"a+",stdout); - freopen(MYSQL_ERR_FILE,"a+",stderr); + freopen(log_error_file,"a+",stdout); + freopen(log_error_file,"a+",stderr); FreeConsole(); // Remove window } #endif @@ -5026,12 +5025,12 @@ The minimum value for this variable is 4096.", "Persistent buffer for query parsing and execution", (gptr*) &global_system_variables.query_prealloc_size, (gptr*) &max_system_variables.query_prealloc_size, 0, GET_ULONG, - REQUIRED_ARG, QUERY_ALLOC_PREALLOC_SIZE, 1024, ~0L, 0, 1024, 0}, + REQUIRED_ARG, QUERY_ALLOC_PREALLOC_SIZE, 16384, ~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, - REQUIRED_ARG, RANGE_ALLOC_BLOCK_SIZE, 1024, ~0L, 0, 1024, 0}, + 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, diff --git a/sql/net_serv.cc b/sql/net_serv.cc index 457b2052a45..5985cf63ed6 100644 --- a/sql/net_serv.cc +++ b/sql/net_serv.cc @@ -53,19 +53,9 @@ #include <errno.h> #ifdef EMBEDDED_LIBRARY - #undef MYSQL_SERVER - -#ifndef MYSQL_CLIENT +#undef MYSQL_CLIENT #define MYSQL_CLIENT -#endif - -#undef net_flush - -extern "C" { -my_bool net_flush(NET *net); -} - #endif /*EMBEDDED_LIBRARY */ diff --git a/sql/opt_range.cc b/sql/opt_range.cc index 541acc69ec7..c9528af7d98 100644 --- a/sql/opt_range.cc +++ b/sql/opt_range.cc @@ -1013,13 +1013,22 @@ get_mm_leaf(PARAM *param, COND *conf_func, Field *field, KEY_PART *key_part, } /* - We can't use an index when comparing strings of - different collations + 1. Usually we can't use an index if the column collation + differ from the operation collation. + + 2. However, we can reuse a case insensitive index for + the binary searches: + + WHERE latin1_swedish_ci_column = 'a' COLLATE lati1_bin; + + WHERE latin1_swedish_ci_colimn = BINARY 'a ' + */ if (field->result_type() == STRING_RESULT && value->result_type() == STRING_RESULT && key_part->image_type == Field::itRAW && - ((Field_str*)field)->charset() != conf_func->compare_collation()) + ((Field_str*)field)->charset() != conf_func->compare_collation() && + !(conf_func->compare_collation()->state & MY_CS_BINSORT)) DBUG_RETURN(0); if (type == Item_func::LIKE_FUNC) diff --git a/sql/protocol.cc b/sql/protocol.cc index 598d102ec29..eaa0fd55b25 100644 --- a/sql/protocol.cc +++ b/sql/protocol.cc @@ -470,6 +470,15 @@ void Protocol::init(THD *thd_arg) } +bool Protocol::flush() +{ +#ifndef EMBEDDED_LIBRARY + return net_flush(&thd->net); +#else + return 0; +#endif +} + /* Send name and type of result to client. diff --git a/sql/protocol.h b/sql/protocol.h index d7ce5425ad1..a3b6da55da3 100644 --- a/sql/protocol.h +++ b/sql/protocol.h @@ -75,6 +75,7 @@ public: field_count=item_list->elements; return 0; } + virtual bool flush(); virtual void prepare_for_resend()=0; virtual bool store_null()=0; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index dce32720184..f5b9bc0638f 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -2610,6 +2610,7 @@ unsent_create_error: mysql_update_log.write(thd, thd->query, thd->query_length); if (mysql_bin_log.is_open()) { + thd->clear_error(); // No binlog error generated Query_log_event qinfo(thd, thd->query, thd->query_length, 0); mysql_bin_log.write(&qinfo); } @@ -2638,6 +2639,7 @@ unsent_create_error: mysql_update_log.write(thd, thd->query, thd->query_length); if (mysql_bin_log.is_open()) { + thd->clear_error(); // No binlog error generated Query_log_event qinfo(thd, thd->query, thd->query_length, 0); mysql_bin_log.write(&qinfo); } @@ -2660,6 +2662,7 @@ unsent_create_error: mysql_update_log.write(thd, thd->query, thd->query_length); if (mysql_bin_log.is_open()) { + thd->clear_error(); // No binlog error generated Query_log_event qinfo(thd, thd->query, thd->query_length, 0); mysql_bin_log.write(&qinfo); } diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index b5e12c4d208..4ae69e40342 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -153,6 +153,8 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns) { NET *net= &stmt->thd->net; char buff[9]; + DBUG_ENTER("send_prep_stmt"); + buff[0]= 0; /* OK packet indicator */ int4store(buff+1, stmt->id); int2store(buff+5, columns); @@ -161,12 +163,11 @@ static bool send_prep_stmt(Prepared_statement *stmt, uint columns) Send types and names of placeholders to the client XXX: fix this nasty upcast from List<Item_param> to List<Item> */ - return my_net_write(net, buff, sizeof(buff)) || - (stmt->param_count && - stmt->thd->protocol_simple.send_fields((List<Item> *) - &stmt->lex->param_list, 0)) || - net_flush(net); - return 0; + DBUG_RETURN(my_net_write(net, buff, sizeof(buff)) || + (stmt->param_count && + stmt->thd->protocol_simple.send_fields((List<Item> *) + &stmt->lex->param_list, + 0))); } #else static bool send_prep_stmt(Prepared_statement *stmt, @@ -1088,7 +1089,7 @@ static int mysql_test_select(Prepared_statement *stmt, { if (lex->describe) { - if (send_prep_stmt(stmt, 0)) + if (send_prep_stmt(stmt, 0) || thd->protocol->flush()) goto err_prep; } else @@ -1106,11 +1107,8 @@ static int mysql_test_select(Prepared_statement *stmt, prepared in unit->prepare call above. */ if (send_prep_stmt(stmt, lex->result->field_count(fields)) || - lex->result->send_fields(fields, 0) -#ifndef EMBEDDED_LIBRARY - || net_flush(&thd->net) -#endif - ) + lex->result->send_fields(fields, 0) || + thd->protocol->flush()) goto err_prep; } } @@ -1389,7 +1387,6 @@ static int send_prepare_results(Prepared_statement *stmt, bool text_protocol) enum enum_sql_command sql_command= lex->sql_command; int res= 0; DBUG_ENTER("send_prepare_results"); - DBUG_PRINT("enter",("command: %d, param_count: %ld", sql_command, stmt->param_count)); @@ -1475,7 +1472,8 @@ static int send_prepare_results(Prepared_statement *stmt, bool text_protocol) goto error; } if (res == 0) - DBUG_RETURN(text_protocol? 0 : send_prep_stmt(stmt, 0)); + DBUG_RETURN(text_protocol? 0 : (send_prep_stmt(stmt, 0) || + thd->protocol->flush())); error: if (res < 0) send_error(thd, thd->killed ? ER_SERVER_SHUTDOWN : 0); diff --git a/sql/sql_show.cc b/sql/sql_show.cc index 2af4cb3fc23..bda490e2916 100644 --- a/sql/sql_show.cc +++ b/sql/sql_show.cc @@ -1081,7 +1081,7 @@ mysqld_list_fields(THD *thd, TABLE_LIST *table_list, const char *wild) restore_record(table,default_values); // Get empty record if (thd->protocol->send_fields(&field_list,2)) DBUG_VOID_RETURN; - net_flush(&thd->net); + thd->protocol->flush(); DBUG_VOID_RETURN; } @@ -1098,13 +1098,11 @@ mysqld_dump_create_info(THD *thd, TABLE *table, int fd) if (store_create_info(thd, table, packet)) DBUG_RETURN(-1); - //if (protocol->convert) - // protocol->convert->convert((char*) packet->ptr(), packet->length()); if (fd < 0) { if (protocol->write()) DBUG_RETURN(-1); - net_flush(&thd->net); + protocol->flush(); } else { diff --git a/sql/sql_table.cc b/sql/sql_table.cc index 79cec85927e..c69235a5647 100644 --- a/sql/sql_table.cc +++ b/sql/sql_table.cc @@ -1734,6 +1734,12 @@ end: } +/* + RETURN VALUES + 0 Message sent to net (admin operation went ok) + -1 Message should be sent by caller + (admin operation or network communication failed) +*/ static int mysql_admin_table(THD* thd, TABLE_LIST* tables, HA_CHECK_OPT* check_opt, const char *operator_name, @@ -1780,9 +1786,13 @@ static int mysql_admin_table(THD* thd, TABLE_LIST* tables, if (prepare_func) { switch ((*prepare_func)(thd, table, check_opt)) { - case 1: continue; // error, message written to net - case -1: goto err; // error, message could be written to net - default: ; // should be 0 otherwise + case 1: // error, message written to net + close_thread_tables(thd); + continue; + case -1: // error, message could be written to net + goto err; + default: // should be 0 otherwise + ; } } diff --git a/tests/client_test.c b/tests/client_test.c index 48676ae7e12..227f7e29ef2 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -1,4 +1,4 @@ -/* Copyright (C) 2003 MySQL AB +/* Copyright (C) 2003-2004 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 @@ -27,6 +27,7 @@ #include <my_getopt.h> #include <m_string.h> +#define VER "2.0" #define MAX_TEST_QUERY_LENGTH 300 /* MAX QUERY BUFFER LENGTH */ /* set default options */ @@ -37,7 +38,7 @@ static char *opt_password= 0; static char *opt_host= 0; static char *opt_unix_socket= 0; static unsigned int opt_port; -static my_bool tty_password= 0; +static my_bool tty_password= 0, opt_silent= 0; static MYSQL *mysql= 0; static char query[MAX_TEST_QUERY_LENGTH]; @@ -52,6 +53,7 @@ static double total_time; const char *default_dbug_option= "d:t:o,/tmp/client_test.trace"; #define myheader(str) \ +if (opt_silent < 2) \ { \ fprintf(stdout, "\n\n#####################################\n"); \ fprintf(stdout, "%d of (%d/%d): %s", test_count++, iter_count, \ @@ -59,6 +61,7 @@ const char *default_dbug_option= "d:t:o,/tmp/client_test.trace"; fprintf(stdout, " \n#####################################\n"); \ } #define myheader_r(str) \ +if (!opt_silent) \ { \ fprintf(stdout, "\n\n#####################################\n"); \ fprintf(stdout, "%s", str); \ @@ -144,32 +147,39 @@ DIE_UNLESS(stmt == 0);\ static void print_error(const char *msg) { - if (mysql && mysql_errno(mysql)) + if (!opt_silent) { - if (mysql->server_version) - fprintf(stdout, "\n [MySQL-%s]", mysql->server_version); - else - fprintf(stdout, "\n [MySQL]"); - fprintf(stdout, "[%d] %s\n", mysql_errno(mysql), mysql_error(mysql)); + if (mysql && mysql_errno(mysql)) + { + if (mysql->server_version) + fprintf(stdout, "\n [MySQL-%s]", mysql->server_version); + else + fprintf(stdout, "\n [MySQL]"); + fprintf(stdout, "[%d] %s\n", mysql_errno(mysql), mysql_error(mysql)); + } + else if (msg) + fprintf(stderr, " [MySQL] %s\n", msg); } - else if (msg) fprintf(stderr, " [MySQL] %s\n", msg); } static void print_st_error(MYSQL_STMT *stmt, const char *msg) { - if (stmt && mysql_stmt_errno(stmt)) + if (!opt_silent) { - if (stmt->mysql && stmt->mysql->server_version) - fprintf(stdout, "\n [MySQL-%s]", stmt->mysql->server_version); - else - fprintf(stdout, "\n [MySQL]"); + if (stmt && mysql_stmt_errno(stmt)) + { + if (stmt->mysql && stmt->mysql->server_version) + fprintf(stdout, "\n [MySQL-%s]", stmt->mysql->server_version); + else + fprintf(stdout, "\n [MySQL]"); - fprintf(stdout, "[%d] %s\n", mysql_stmt_errno(stmt), - mysql_stmt_error(stmt)); + fprintf(stdout, "[%d] %s\n", mysql_stmt_errno(stmt), + mysql_stmt_error(stmt)); + } + else if (msg) + fprintf(stderr, " [MySQL] %s\n", msg); } - else if (msg) - fprintf(stderr, " [MySQL] %s\n", msg); } @@ -198,8 +208,9 @@ static void client_connect() int rc; myheader_r("client_connect"); - fprintf(stdout, "\n Establishing a connection to '%s' ...", - opt_host ? opt_host : ""); + if (!opt_silent) + fprintf(stdout, "\n Establishing a connection to '%s' ...", + opt_host ? opt_host : ""); if (!(mysql= mysql_init(NULL))) { @@ -217,12 +228,14 @@ static void client_connect() exit(1); } - fprintf(stdout, " OK"); + if (!opt_silent) + fprintf(stdout, " OK"); /* set AUTOCOMMIT to ON*/ mysql_autocommit(mysql, TRUE); - fprintf(stdout, "\n Creating a test database '%s' ...", current_db); + if (!opt_silent) + fprintf(stdout, "\n Creating a test database '%s' ...", current_db); strxmov(query, "CREATE DATABASE IF NOT EXISTS ", current_db, NullS); rc= mysql_query(mysql, query); @@ -232,7 +245,8 @@ static void client_connect() rc= mysql_query(mysql, query); myquery(rc); - fprintf(stdout, " OK"); + if (!opt_silent) + fprintf(stdout, " OK"); } @@ -244,13 +258,16 @@ static void client_disconnect() if (mysql) { - fprintf(stdout, "\n dropping the test database '%s' ...", current_db); + if (!opt_silent) + fprintf(stdout, "\n dropping the test database '%s' ...", current_db); strxmov(query, "DROP DATABASE IF EXISTS ", current_db, NullS); mysql_query(mysql, query); - fprintf(stdout, " OK"); + if (!opt_silent) + fprintf(stdout, " OK"); - fprintf(stdout, "\n closing the connection ..."); + if (!opt_silent) + fprintf(stdout, "\n closing the connection ..."); mysql_close(mysql); fprintf(stdout, " OK\n"); } @@ -331,8 +348,11 @@ static void my_print_result_metadata(MYSQL_RES *result) unsigned int field_count; mysql_field_seek(result, 0); - fputc('\n', stdout); - fputc('\n', stdout); + if (!opt_silent) + { + fputc('\n', stdout); + fputc('\n', stdout); + } field_count= mysql_num_fields(result); for(i= 0; i< field_count; i++) @@ -345,18 +365,25 @@ static void my_print_result_metadata(MYSQL_RES *result) j= 4; field->max_length= j; } - my_print_dashes(result); - fputc('\t', stdout); - fputc('|', stdout); + if (!opt_silent) + { + my_print_dashes(result); + fputc('\t', stdout); + fputc('|', stdout); + } mysql_field_seek(result, 0); for(i= 0; i< field_count; i++) { field= mysql_fetch_field(result); - fprintf(stdout, " %-*s |", (int) field->max_length, field->name); + if (!opt_silent) + fprintf(stdout, " %-*s |", (int) field->max_length, field->name); + } + if (!opt_silent) + { + fputc('\n', stdout); + my_print_dashes(result); } - fputc('\n', stdout); - my_print_dashes(result); } @@ -377,31 +404,43 @@ int my_process_result_set(MYSQL_RES *result) while ((row= mysql_fetch_row(result)) != NULL) { mysql_field_seek(result, 0); - fputc('\t', stdout); - fputc('|', stdout); + if (!opt_silent) + { + fputc('\t', stdout); + fputc('|', stdout); + } for(i= 0; i< mysql_num_fields(result); i++) { field= mysql_fetch_field(result); - if (row[i] == NULL) - fprintf(stdout, " %-*s |", (int) field->max_length, "NULL"); - else if (IS_NUM(field->type)) - fprintf(stdout, " %*s |", (int) field->max_length, row[i]); - else - fprintf(stdout, " %-*s |", (int) field->max_length, row[i]); + if (!opt_silent) + { + if (row[i] == NULL) + fprintf(stdout, " %-*s |", (int) field->max_length, "NULL"); + else if (IS_NUM(field->type)) + fprintf(stdout, " %*s |", (int) field->max_length, row[i]); + else + fprintf(stdout, " %-*s |", (int) field->max_length, row[i]); + } + } + if (!opt_silent) + { + fputc('\t', stdout); + fputc('\n', stdout); } - fputc('\t', stdout); - fputc('\n', stdout); row_count++; } - if (row_count) - my_print_dashes(result); + if (!opt_silent) + { + if (row_count) + my_print_dashes(result); - if (mysql_errno(mysql) != 0) - fprintf(stderr, "\n\tmysql_fetch_row() failed\n"); - else - fprintf(stdout, "\n\t%d %s returned\n", row_count, - row_count == 1 ? "row" : "rows"); + if (mysql_errno(mysql) != 0) + fprintf(stderr, "\n\tmysql_fetch_row() failed\n"); + else + fprintf(stdout, "\n\t%d %s returned\n", row_count, + row_count == 1 ? "row" : "rows"); + } return row_count; } @@ -470,34 +509,44 @@ int my_process_stmt_result(MYSQL_STMT *stmt) mysql_field_seek(result, 0); while (mysql_stmt_fetch(stmt) == 0) { - fputc('\t', stdout); - fputc('|', stdout); - + if (!opt_silent) + { + fputc('\t', stdout); + fputc('|', stdout); + } mysql_field_seek(result, 0); for (i= 0; i < field_count; i++) { field= mysql_fetch_field(result); - if (is_null[i]) - fprintf(stdout, " %-*s |", (int) field->max_length, "NULL"); - else if (length[i] == 0) + if (!opt_silent) { - data[i][0]= '\0'; /* unmodified buffer */ - fprintf(stdout, " %*s |", (int) field->max_length, data[i]); + if (is_null[i]) + fprintf(stdout, " %-*s |", (int) field->max_length, "NULL"); + else if (length[i] == 0) + { + data[i][0]= '\0'; /* unmodified buffer */ + fprintf(stdout, " %*s |", (int) field->max_length, data[i]); + } + else if (IS_NUM(field->type)) + fprintf(stdout, " %*s |", (int) field->max_length, data[i]); + else + fprintf(stdout, " %-*s |", (int) field->max_length, data[i]); } - else if (IS_NUM(field->type)) - fprintf(stdout, " %*s |", (int) field->max_length, data[i]); - else - fprintf(stdout, " %-*s |", (int) field->max_length, data[i]); } - fputc('\t', stdout); - fputc('\n', stdout); + if (!opt_silent) + { + fputc('\t', stdout); + fputc('\n', stdout); + } row_count++; } - if (row_count) - my_print_dashes(result); - - fprintf(stdout, "\n\t%d %s returned\n", row_count, - row_count == 1 ? "row" : "rows"); + if (!opt_silent) + { + if (row_count) + my_print_dashes(result); + fprintf(stdout, "\n\t%d %s returned\n", row_count, + row_count == 1 ? "row" : "rows"); + } mysql_free_result(result); return row_count; } @@ -511,7 +560,8 @@ int my_stmt_result(const char *buff) int row_count; int rc; - fprintf(stdout, "\n\n %s", buff); + if (!opt_silent) + fprintf(stdout, "\n\n %s", buff); stmt= mysql_simple_prepare(mysql, buff); check_stmt(stmt); @@ -537,7 +587,8 @@ static void verify_col_data(const char *table, const char *col, if (table && col) { strxmov(query, "SELECT ", col, " FROM ", table, " LIMIT 1", NullS); - fprintf(stdout, "\n %s", query); + if (!opt_silent) + fprintf(stdout, "\n %s", query); rc= mysql_query(mysql, query); myquery(rc); @@ -565,10 +616,12 @@ static void verify_col_data(const char *table, const char *col, /* Utility function to verify the field members */ static void verify_prepare_field(MYSQL_RES *result, - unsigned int no, const char *name, const char *org_name, - enum enum_field_types type, const char *table, - const char *org_table, const char *db, - unsigned long length, const char *def) + unsigned int no, const char *name, + const char *org_name, + enum enum_field_types type, + const char *table, + const char *org_table, const char *db, + unsigned long length, const char *def) { MYSQL_FIELD *field; @@ -577,23 +630,26 @@ static void verify_prepare_field(MYSQL_RES *result, fprintf(stdout, "\n *** ERROR: FAILED TO GET THE RESULT ***"); exit(1); } - fprintf(stdout, "\n field[%d]:", no); - fprintf(stdout, "\n name :`%s`\t(expected: `%s`)", field->name, name); - fprintf(stdout, "\n org_name :`%s`\t(expected: `%s`)", - field->org_name, org_name); - fprintf(stdout, "\n type :`%d`\t(expected: `%d`)", field->type, type); - fprintf(stdout, "\n table :`%s`\t(expected: `%s`)", - field->table, table); - fprintf(stdout, "\n org_table:`%s`\t(expected: `%s`)", - field->org_table, org_table); - fprintf(stdout, "\n database :`%s`\t(expected: `%s`)", field->db, db); - fprintf(stdout, "\n length :`%ld`\t(expected: `%ld`)", - field->length, length); - fprintf(stdout, "\n maxlength:`%ld`", field->max_length); - fprintf(stdout, "\n charsetnr:`%d`", field->charsetnr); - fprintf(stdout, "\n default :`%s`\t(expected: `%s`)", - field->def ? field->def : "(null)", def ? def: "(null)"); - fprintf(stdout, "\n"); + if (!opt_silent) + { + fprintf(stdout, "\n field[%d]:", no); + fprintf(stdout, "\n name :`%s`\t(expected: `%s`)", field->name, name); + fprintf(stdout, "\n org_name :`%s`\t(expected: `%s`)", + field->org_name, org_name); + fprintf(stdout, "\n type :`%d`\t(expected: `%d`)", field->type, type); + fprintf(stdout, "\n table :`%s`\t(expected: `%s`)", + field->table, table); + fprintf(stdout, "\n org_table:`%s`\t(expected: `%s`)", + field->org_table, org_table); + fprintf(stdout, "\n database :`%s`\t(expected: `%s`)", field->db, db); + fprintf(stdout, "\n length :`%ld`\t(expected: `%ld`)", + field->length, length); + fprintf(stdout, "\n maxlength:`%ld`", field->max_length); + fprintf(stdout, "\n charsetnr:`%d`", field->charsetnr); + fprintf(stdout, "\n default :`%s`\t(expected: `%s`)", + field->def ? field->def : "(null)", def ? def: "(null)"); + fprintf(stdout, "\n"); + } DIE_UNLESS(strcmp(field->name, name) == 0); DIE_UNLESS(strcmp(field->org_name, org_name) == 0); DIE_UNLESS(field->type == type); @@ -611,8 +667,9 @@ static void verify_prepare_field(MYSQL_RES *result, static void verify_param_count(MYSQL_STMT *stmt, long exp_count) { long param_count= mysql_stmt_param_count(stmt); - fprintf(stdout, "\n total parameters in stmt: `%ld` (expected: `%ld`)", - param_count, exp_count); + if (!opt_silent) + fprintf(stdout, "\n total parameters in stmt: `%ld` (expected: `%ld`)", + param_count, exp_count); DIE_UNLESS(param_count == exp_count); } @@ -622,8 +679,9 @@ static void verify_param_count(MYSQL_STMT *stmt, long exp_count) static void verify_st_affected_rows(MYSQL_STMT *stmt, ulonglong exp_count) { ulonglong affected_rows= mysql_stmt_affected_rows(stmt); - fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)", - affected_rows, exp_count); + if (!opt_silent) + fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)", + affected_rows, exp_count); DIE_UNLESS(affected_rows == exp_count); } @@ -633,7 +691,8 @@ static void verify_st_affected_rows(MYSQL_STMT *stmt, ulonglong exp_count) static void verify_affected_rows(ulonglong exp_count) { ulonglong affected_rows= mysql_affected_rows(mysql); - fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)", + if (!opt_silent) + fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)", affected_rows, exp_count); DIE_UNLESS(affected_rows == exp_count); } @@ -644,8 +703,9 @@ static void verify_affected_rows(ulonglong exp_count) static void verify_field_count(MYSQL_RES *result, uint exp_count) { uint field_count= mysql_num_fields(result); - fprintf(stdout, "\n total fields in the result set: `%d` (expected: `%d`)", - field_count, exp_count); + if (!opt_silent) + fprintf(stdout, "\n total fields in the result set: `%d` (expected: `%d`)", + field_count, exp_count); DIE_UNLESS(field_count == exp_count); } @@ -665,8 +725,9 @@ static void execute_prepare_query(const char *query, ulonglong exp_count) myquery(rc); affected_rows= mysql_stmt_affected_rows(stmt); - fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)", - affected_rows, exp_count); + if (!opt_silent) + fprintf(stdout, "\n total affected rows: `%lld` (expected: `%lld`)", + affected_rows, exp_count); DIE_UNLESS(affected_rows == exp_count); mysql_stmt_close(stmt); @@ -722,7 +783,8 @@ static my_bool thread_query(char *query) my_bool error; error= 0; - fprintf(stdout, "\n in thread_query(%s)", query); + if (!opt_silent) + fprintf(stdout, "\n in thread_query(%s)", query); if (!(l_mysql= mysql_init(NULL))) { myerror("mysql_init() failed"); @@ -1033,7 +1095,8 @@ static void test_prepare_field_result() my_print_result_metadata(result); - fprintf(stdout, "\n\n field attributes:\n"); + if (!opt_silent) + fprintf(stdout, "\n\n field attributes:\n"); verify_prepare_field(result, 0, "int_c", "int_c", MYSQL_TYPE_LONG, "t1", "test_prepare_field_result", current_db, 11, 0); verify_prepare_field(result, 1, "var_c", "var_c", MYSQL_TYPE_VAR_STRING, @@ -1207,17 +1270,20 @@ static void test_prepare() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n"); + if (!opt_silent) + { + fprintf(stdout, "\n"); - fprintf(stdout, "\n\t tiny : %d (%lu)", tiny_data, length[0]); - fprintf(stdout, "\n\t short : %d (%lu)", small_data, length[3]); - fprintf(stdout, "\n\t int : %d (%lu)", int_data, length[2]); - fprintf(stdout, "\n\t big : %lld (%lu)", big_data, length[4]); + fprintf(stdout, "\n\t tiny : %d (%lu)", tiny_data, length[0]); + fprintf(stdout, "\n\t short : %d (%lu)", small_data, length[3]); + fprintf(stdout, "\n\t int : %d (%lu)", int_data, length[2]); + fprintf(stdout, "\n\t big : %lld (%lu)", big_data, length[4]); - fprintf(stdout, "\n\t float : %f (%lu)", real_data, length[5]); - fprintf(stdout, "\n\t double : %f (%lu)", double_data, length[6]); + fprintf(stdout, "\n\t float : %f (%lu)", real_data, length[5]); + fprintf(stdout, "\n\t double : %f (%lu)", double_data, length[6]); - fprintf(stdout, "\n\t str : %s (%lu)", str_data, length[1]); + fprintf(stdout, "\n\t str : %s (%lu)", str_data, length[1]); + } DIE_UNLESS(tiny_data == o_tiny_data); DIE_UNLESS(is_null[0] == 0); @@ -1578,11 +1644,13 @@ static void test_fetch_null() rc++; for (i= 0; i < 10; i++) { - fprintf(stdout, "\n data[%d] : %s", i, - is_null[i] ? "NULL" : "NOT NULL"); + if (!opt_silent) + fprintf(stdout, "\n data[%d] : %s", i, + is_null[i] ? "NULL" : "NOT NULL"); DIE_UNLESS(is_null[i]); } - fprintf(stdout, "\n data[%d]: %d", i, nData); + if (!opt_silent) + fprintf(stdout, "\n data[%d]: %d", i, nData); DIE_UNLESS(nData == 1000 || nData == 88 || nData == 389789); DIE_UNLESS(is_null[i] == 0); DIE_UNLESS(length[i] == 4); @@ -2367,7 +2435,8 @@ static void test_long_data() /* execute */ rc= mysql_stmt_execute(stmt); - fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc); + if (!opt_silent) + fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc); check_execute(stmt, rc); rc= mysql_commit(mysql); @@ -2450,7 +2519,8 @@ static void test_long_data_str() } /* execute */ rc= mysql_stmt_execute(stmt); - fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc); + if (!opt_silent) + fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc); check_execute(stmt, rc); mysql_stmt_close(stmt); @@ -2541,7 +2611,8 @@ static void test_long_data_str1() /* execute */ rc= mysql_stmt_execute(stmt); - fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc); + if (!opt_silent) + fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc); check_execute(stmt, rc); mysql_stmt_close(stmt); @@ -2692,7 +2763,8 @@ static void test_long_data_bin() } /* execute */ rc= mysql_stmt_execute(stmt); - fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc); + if (!opt_silent) + fprintf(stdout, " mysql_stmt_execute() returned %d\n", rc); check_execute(stmt, rc); mysql_stmt_close(stmt); @@ -2999,7 +3071,8 @@ static void test_bind_result() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 1: %d, %s(%lu)", nData, szData, length1); + if (!opt_silent) + fprintf(stdout, "\n row 1: %d, %s(%lu)", nData, szData, length1); DIE_UNLESS(nData == 10); DIE_UNLESS(strcmp(szData, "venu") == 0); DIE_UNLESS(length1 == 4); @@ -3007,7 +3080,8 @@ static void test_bind_result() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 2: %d, %s(%lu)", nData, szData, length1); + if (!opt_silent) + fprintf(stdout, "\n row 2: %d, %s(%lu)", nData, szData, length1); DIE_UNLESS(nData == 20); DIE_UNLESS(strcmp(szData, "MySQL") == 0); DIE_UNLESS(length1 == 5); @@ -3016,7 +3090,7 @@ static void test_bind_result() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - if (is_null[0]) + if (!opt_silent && is_null[0]) fprintf(stdout, "\n row 3: NULL, %s(%lu)", szData, length1); DIE_UNLESS(is_null[0]); DIE_UNLESS(strcmp(szData, "monty") == 0); @@ -3114,19 +3188,21 @@ static void test_bind_result_ext() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n data (tiny) : %d", t_data); - fprintf(stdout, "\n data (short) : %d", s_data); - fprintf(stdout, "\n data (int) : %d", i_data); - fprintf(stdout, "\n data (big) : %lld", b_data); - - fprintf(stdout, "\n data (float) : %f", f_data); - fprintf(stdout, "\n data (double) : %f", d_data); + if (!opt_silent) + { + fprintf(stdout, "\n data (tiny) : %d", t_data); + fprintf(stdout, "\n data (short) : %d", s_data); + fprintf(stdout, "\n data (int) : %d", i_data); + fprintf(stdout, "\n data (big) : %lld", b_data); - fprintf(stdout, "\n data (str) : %s(%lu)", szData, szLength); + fprintf(stdout, "\n data (float) : %f", f_data); + fprintf(stdout, "\n data (double) : %f", d_data); - bData[bLength]= '\0'; /* bData is binary */ - fprintf(stdout, "\n data (bin) : %s(%lu)", bData, bLength); + fprintf(stdout, "\n data (str) : %s(%lu)", szData, szLength); + bData[bLength]= '\0'; /* bData is binary */ + fprintf(stdout, "\n data (bin) : %s(%lu)", bData, bLength); + } DIE_UNLESS(t_data == 19); DIE_UNLESS(s_data == 2999); @@ -3234,16 +3310,19 @@ static void test_bind_result_ext1() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n data (tiny) : %s(%lu)", t_data, length[0]); - fprintf(stdout, "\n data (short) : %f(%lu)", s_data, length[1]); - fprintf(stdout, "\n data (int) : %d(%lu)", i_data, length[2]); - fprintf(stdout, "\n data (big) : %d(%lu)", b_data, length[3]); + if (!opt_silent) + { + fprintf(stdout, "\n data (tiny) : %s(%lu)", t_data, length[0]); + fprintf(stdout, "\n data (short) : %f(%lu)", s_data, length[1]); + fprintf(stdout, "\n data (int) : %d(%lu)", i_data, length[2]); + fprintf(stdout, "\n data (big) : %d(%lu)", b_data, length[3]); - fprintf(stdout, "\n data (float) : %d(%lu)", f_data, length[4]); - fprintf(stdout, "\n data (double) : %s(%lu)", d_data, length[5]); + fprintf(stdout, "\n data (float) : %d(%lu)", f_data, length[4]); + fprintf(stdout, "\n data (double) : %s(%lu)", d_data, length[5]); - fprintf(stdout, "\n data (bin) : %ld(%lu)", bData, length[6]); - fprintf(stdout, "\n data (str) : %g(%lu)", szData, length[7]); + fprintf(stdout, "\n data (bin) : %ld(%lu)", bData, length[6]); + fprintf(stdout, "\n data (str) : %g(%lu)", szData, length[7]); + } DIE_UNLESS(strcmp(t_data, "120") == 0); DIE_UNLESS(i_data == 3999); @@ -3368,15 +3447,17 @@ static void bind_fetch(int row_count) rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n"); - fprintf(stdout, "\n tiny : %ld(%lu)", (ulong) i8_data, length[0]); - fprintf(stdout, "\n short : %ld(%lu)", (ulong) i16_data, length[1]); - fprintf(stdout, "\n int : %ld(%lu)", (ulong) i32_data, length[2]); - fprintf(stdout, "\n longlong : %ld(%lu)", (ulong) i64_data, length[3]); - fprintf(stdout, "\n float : %f(%lu)", f_data, length[4]); - fprintf(stdout, "\n double : %g(%lu)", d_data, length[5]); - fprintf(stdout, "\n char : %s(%lu)", s_data, length[6]); - + if (!opt_silent) + { + fprintf(stdout, "\n"); + fprintf(stdout, "\n tiny : %ld(%lu)", (ulong) i8_data, length[0]); + fprintf(stdout, "\n short : %ld(%lu)", (ulong) i16_data, length[1]); + fprintf(stdout, "\n int : %ld(%lu)", (ulong) i32_data, length[2]); + fprintf(stdout, "\n longlong : %ld(%lu)", (ulong) i64_data, length[3]); + fprintf(stdout, "\n float : %f(%lu)", f_data, length[4]); + fprintf(stdout, "\n double : %g(%lu)", d_data, length[5]); + fprintf(stdout, "\n char : %s(%lu)", s_data, length[6]); + } rc= 10+row_count; /* TINY */ @@ -3518,13 +3599,16 @@ static void test_fetch_date() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n date : %s(%lu)", date, d_length); - fprintf(stdout, "\n time : %s(%lu)", time, t_length); - fprintf(stdout, "\n ts : %s(%lu)", ts, ts_length); - fprintf(stdout, "\n year : %d(%lu)", year, y_length); - fprintf(stdout, "\n dt : %s(%lu)", dt, dt_length); - fprintf(stdout, "\n ts(4) : %s(%lu)", ts_4, ts4_length); - fprintf(stdout, "\n ts(6) : %s(%lu)", ts_6, ts6_length); + if (!opt_silent) + { + fprintf(stdout, "\n date : %s(%lu)", date, d_length); + fprintf(stdout, "\n time : %s(%lu)", time, t_length); + fprintf(stdout, "\n ts : %s(%lu)", ts, ts_length); + fprintf(stdout, "\n year : %d(%lu)", year, y_length); + fprintf(stdout, "\n dt : %s(%lu)", dt, dt_length); + fprintf(stdout, "\n ts(4) : %s(%lu)", ts_4, ts4_length); + fprintf(stdout, "\n ts(6) : %s(%lu)", ts_6, ts6_length); + } DIE_UNLESS(strcmp(date, "2002-01-02") == 0); DIE_UNLESS(d_length == 10); @@ -3851,7 +3935,8 @@ static void test_field_names() myheader("test_field_names"); - fprintf(stdout, "\n %d, %d, %d", MYSQL_TYPE_DECIMAL, MYSQL_TYPE_NEWDATE, MYSQL_TYPE_ENUM); + if (!opt_silent) + fprintf(stdout, "\n %d, %d, %d", MYSQL_TYPE_DECIMAL, MYSQL_TYPE_NEWDATE, MYSQL_TYPE_ENUM); rc= mysql_query(mysql, "DROP TABLE IF EXISTS test_field_names1"); myquery(rc); @@ -3902,7 +3987,8 @@ static void test_warnings() rc= mysql_query(mysql, "DROP TABLE if exists test_non_exists"); myquery(rc); - fprintf(stdout, "\n total warnings: %d", mysql_warning_count(mysql)); + if (!opt_silent) + fprintf(stdout, "\n total warnings: %d", mysql_warning_count(mysql)); rc= mysql_query(mysql, "SHOW WARNINGS"); myquery(rc); @@ -4084,23 +4170,27 @@ static void test_field_flags() mytest(result); mysql_field_seek(result, 0); - fputc('\n', stdout); + if (!opt_silent) + fputc('\n', stdout); for(i= 0; i< mysql_num_fields(result); i++) { field= mysql_fetch_field(result); - fprintf(stdout, "\n field:%d", i); - if (field->flags & NOT_NULL_FLAG) - fprintf(stdout, "\n NOT_NULL_FLAG"); - if (field->flags & PRI_KEY_FLAG) - fprintf(stdout, "\n PRI_KEY_FLAG"); - if (field->flags & UNIQUE_KEY_FLAG) - fprintf(stdout, "\n UNIQUE_KEY_FLAG"); - if (field->flags & MULTIPLE_KEY_FLAG) - fprintf(stdout, "\n MULTIPLE_KEY_FLAG"); - if (field->flags & AUTO_INCREMENT_FLAG) - fprintf(stdout, "\n AUTO_INCREMENT_FLAG"); + if (!opt_silent) + { + fprintf(stdout, "\n field:%d", i); + if (field->flags & NOT_NULL_FLAG) + fprintf(stdout, "\n NOT_NULL_FLAG"); + if (field->flags & PRI_KEY_FLAG) + fprintf(stdout, "\n PRI_KEY_FLAG"); + if (field->flags & UNIQUE_KEY_FLAG) + fprintf(stdout, "\n UNIQUE_KEY_FLAG"); + if (field->flags & MULTIPLE_KEY_FLAG) + fprintf(stdout, "\n MULTIPLE_KEY_FLAG"); + if (field->flags & AUTO_INCREMENT_FLAG) + fprintf(stdout, "\n AUTO_INCREMENT_FLAG"); + } } mysql_free_result(result); } @@ -4119,7 +4209,8 @@ static void test_stmt_close() myheader("test_stmt_close"); - fprintf(stdout, "\n Establishing a test connection ..."); + if (!opt_silent) + fprintf(stdout, "\n Establishing a test connection ..."); if (!(lmysql= mysql_init(NULL))) { myerror("mysql_init() failed"); @@ -4132,7 +4223,8 @@ static void test_stmt_close() myerror("connection failed"); exit(1); } - fprintf(stdout, " OK"); + if (!opt_silent) + fprintf(stdout, " OK"); /* set AUTOCOMMIT to ON*/ @@ -4169,7 +4261,8 @@ static void test_stmt_close() verify_param_count(stmt2, 1); rc= mysql_stmt_close(stmt1); - fprintf(stdout, "\n mysql_close_stmt(1) returned: %d", rc); + if (!opt_silent) + fprintf(stdout, "\n mysql_close_stmt(1) returned: %d", rc); DIE_UNLESS(rc == 0); /* @@ -4203,7 +4296,8 @@ static void test_stmt_close() verify_st_affected_rows(stmt_x, 1); rc= mysql_stmt_close(stmt_x); - fprintf(stdout, "\n mysql_close_stmt(x) returned: %d", rc); + if (!opt_silent) + fprintf(stdout, "\n mysql_close_stmt(x) returned: %d", rc); DIE_UNLESS( rc == 0); rc= mysql_query(mysql, "SELECT id FROM test_stmt_close"); @@ -4262,7 +4356,8 @@ static void test_set_variable() rc= mysql_stmt_fetch(stmt1); check_execute(stmt1, rc); - fprintf(stdout, "\n max_error_count(default): %d", get_count); + if (!opt_silent) + fprintf(stdout, "\n max_error_count(default): %d", get_count); def_count= get_count; DIE_UNLESS(strcmp(var, "max_error_count") == 0); @@ -4292,7 +4387,8 @@ static void test_set_variable() rc= mysql_stmt_fetch(stmt1); check_execute(stmt1, rc); - fprintf(stdout, "\n max_error_count : %d", get_count); + if (!opt_silent) + fprintf(stdout, "\n max_error_count : %d", get_count); DIE_UNLESS(get_count == set_count); rc= mysql_stmt_fetch(stmt1); @@ -4309,7 +4405,8 @@ static void test_set_variable() rc= mysql_stmt_fetch(stmt1); check_execute(stmt1, rc); - fprintf(stdout, "\n max_error_count(default): %d", get_count); + if (!opt_silent) + fprintf(stdout, "\n max_error_count(default): %d", get_count); DIE_UNLESS(get_count == set_count); rc= mysql_stmt_fetch(stmt1); @@ -4367,12 +4464,14 @@ static void test_insert_meta() mysql_field_seek(result, 0); field= mysql_fetch_field(result); mytest(field); - fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col1"); + if (!opt_silent) + fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col1"); DIE_UNLESS(strcmp(field->name, "col1") == 0); field= mysql_fetch_field(result); mytest(field); - fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col3"); + if (!opt_silent) + fprintf(stdout, "\n obtained: `%s` (expected: `%s`)", field->name, "col3"); DIE_UNLESS(strcmp(field->name, "col3") == 0); field= mysql_fetch_field(result); @@ -4429,15 +4528,21 @@ static void test_update_meta() mysql_field_seek(result, 0); field= mysql_fetch_field(result); mytest(field); - fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); - fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); + if (!opt_silent) + { + fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); + fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); + } DIE_UNLESS(strcmp(field->name, "col1") == 0); DIE_UNLESS(strcmp(field->table, "test_prep_update") == 0); field= mysql_fetch_field(result); mytest(field); - fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col3"); - fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); + if (!opt_silent) + { + fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col3"); + fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_update"); + } DIE_UNLESS(strcmp(field->name, "col3") == 0); DIE_UNLESS(strcmp(field->table, "test_prep_update") == 0); @@ -4493,15 +4598,21 @@ static void test_select_meta() mysql_field_seek(result, 0); field= mysql_fetch_field(result); mytest(field); - fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); - fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); + if (!opt_silent) + { + fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col1"); + fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); + } DIE_UNLESS(strcmp(field->name, "col1") == 0); DIE_UNLESS(strcmp(field->table, "test_prep_select") == 0); field= mysql_fetch_field(result); mytest(field); - fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col2"); - fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); + if (!opt_silent) + { + fprintf(stdout, "\n col obtained: `%s` (expected: `%s`)", field->name, "col2"); + fprintf(stdout, "\n tab obtained: `%s` (expected: `%s`)", field->table, "test_prep_select"); + } DIE_UNLESS(strcmp(field->name, "col2") == 0); DIE_UNLESS(strcmp(field->table, "test_prep_select") == 0); @@ -4545,8 +4656,9 @@ static void test_func_fields() field= mysql_fetch_field(result); mytest(field); - fprintf(stdout, "\n table name: `%s` (expected: `%s`)", field->table, - "test_dateformat"); + if (!opt_silent) + fprintf(stdout, "\n table name: `%s` (expected: `%s`)", field->table, + "test_dateformat"); DIE_UNLESS(strcmp(field->table, "test_dateformat") == 0); field= mysql_fetch_field(result); @@ -4563,7 +4675,8 @@ static void test_func_fields() field= mysql_fetch_field(result); mytest(field); - fprintf(stdout, "\n table name: `%s` (expected: `%s`)", field->table, ""); + if (!opt_silent) + fprintf(stdout, "\n table name: `%s` (expected: `%s`)", field->table, ""); DIE_UNLESS(field->table[0] == '\0'); field= mysql_fetch_field(result); @@ -4580,8 +4693,11 @@ static void test_func_fields() field= mysql_fetch_field(result); mytest(field); - fprintf(stdout, "\n field name: `%s` (expected: `%s`)", field->name, "YEAR"); - fprintf(stdout, "\n field org name: `%s` (expected: `%s`)", field->org_name, ""); + if (!opt_silent) + { + printf("\n field name: `%s` (expected: `%s`)", field->name, "YEAR"); + printf("\n field org name: `%s` (expected: `%s`)", field->org_name, ""); + } DIE_UNLESS(strcmp(field->name, "YEAR") == 0); DIE_UNLESS(field->org_name[0] == '\0'); @@ -4658,8 +4774,11 @@ static void test_multi_stmt() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n int_data: %lu(%lu)", (ulong) id, length[0]); - fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]); + if (!opt_silent) + { + fprintf(stdout, "\n int_data: %lu(%lu)", (ulong) id, length[0]); + fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]); + } DIE_UNLESS(id == 10); DIE_UNLESS(strcmp(name, "mysql") == 0); @@ -4687,8 +4806,11 @@ static void test_multi_stmt() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n int_data: %lu(%lu)", (ulong) id, length[0]); - fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]); + if (!opt_silent) + { + fprintf(stdout, "\n int_data: %lu(%lu)", (ulong) id, length[0]); + fprintf(stdout, "\n str_data: %s(%lu)", name, length[1]); + } DIE_UNLESS(id == 10); DIE_UNLESS(strcmp(name, "updated") == 0); @@ -4762,12 +4884,14 @@ static void test_manual_sample() fprintf(stderr, "\n %s", mysql_error(mysql)); exit(1); } - fprintf(stdout, "\n prepare, insert successful"); + if (!opt_silent) + fprintf(stdout, "\n prepare, insert successful"); /* Get the parameter count from the statement */ param_count= mysql_stmt_param_count(stmt); - fprintf(stdout, "\n total parameters in insert: %d", param_count); + if (!opt_silent) + fprintf(stdout, "\n total parameters in insert: %d", param_count); if (param_count != 3) /* validate parameter count */ { fprintf(stderr, "\n invalid parameter count returned by MySQL"); @@ -4823,7 +4947,8 @@ static void test_manual_sample() /* Get the total rows affected */ affected_rows= mysql_stmt_affected_rows(stmt); - fprintf(stdout, "\n total affected rows: %lld", affected_rows); + if (!opt_silent) + fprintf(stdout, "\n total affected rows: %lld", affected_rows); if (affected_rows != 1) /* validate affected rows */ { fprintf(stderr, "\n invalid affected rows by MySQL"); @@ -4847,7 +4972,8 @@ static void test_manual_sample() /* Get the total rows affected */ affected_rows= mysql_stmt_affected_rows(stmt); - fprintf(stdout, "\n total affected rows: %lld", affected_rows); + if (!opt_silent) + fprintf(stdout, "\n total affected rows: %lld", affected_rows); if (affected_rows != 1) /* validate affected rows */ { fprintf(stderr, "\n invalid affected rows by MySQL"); @@ -4871,7 +4997,8 @@ static void test_manual_sample() fprintf(stderr, "\n %s", mysql_error(mysql)); exit(1); } - fprintf(stdout, "Success !!!"); + if (!opt_silent) + fprintf(stdout, "Success !!!"); } @@ -4993,13 +5120,14 @@ DROP TABLE IF EXISTS test_multi_tab"; for (count= 0 ; count < array_elements(rows) ; count++) { - fprintf(stdout, "\n Query %d: ", count); + if (!opt_silent) + fprintf(stdout, "\n Query %d: ", count); if ((result= mysql_store_result(mysql_local))) { (void) my_process_result_set(result); mysql_free_result(result); } - else + else if (!opt_silent) fprintf(stdout, "OK, %lld row(s) affected, %d warning(s)\n", mysql_affected_rows(mysql_local), mysql_warning_count(mysql_local)); @@ -5007,7 +5135,7 @@ DROP TABLE IF EXISTS test_multi_tab"; exp_value= (uint) mysql_affected_rows(mysql_local); if (rows[count] != exp_value) { - fprintf(stdout, "row %d had affected rows: %d, should be %d\n", + fprintf(stderr, "row %d had affected rows: %d, should be %d\n", count, exp_value, rows[count]); exit(1); } @@ -5083,7 +5211,7 @@ static void test_prepare_multi_statements() if (!(mysql_local= mysql_init(NULL))) { - fprintf(stdout, "\n mysql_init() failed"); + fprintf(stderr, "\n mysql_init() failed"); exit(1); } @@ -5091,7 +5219,7 @@ static void test_prepare_multi_statements() opt_password, current_db, opt_port, opt_unix_socket, CLIENT_MULTI_STATEMENTS))) { - fprintf(stdout, "\n connection failed(%s)", mysql_error(mysql_local)); + fprintf(stderr, "\n connection failed(%s)", mysql_error(mysql_local)); exit(1); } strmov(query, "select 1; select 'another value'"); @@ -5159,7 +5287,8 @@ static void test_store_result() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 1: %ld, %s(%lu)", (long) nData, szData, length1); + if (!opt_silent) + fprintf(stdout, "\n row 1: %ld, %s(%lu)", (long) nData, szData, length1); DIE_UNLESS(nData == 10); DIE_UNLESS(strcmp(szData, "venu") == 0); DIE_UNLESS(length1 == 4); @@ -5167,7 +5296,8 @@ static void test_store_result() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 2: %ld, %s(%lu)", (long) nData, szData, length1); + if (!opt_silent) + fprintf(stdout, "\n row 2: %ld, %s(%lu)", (long) nData, szData, length1); DIE_UNLESS(nData == 20); DIE_UNLESS(strcmp(szData, "mysql") == 0); DIE_UNLESS(length1 == 5); @@ -5176,7 +5306,7 @@ static void test_store_result() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - if (is_null[0]) + if (!opt_silent && is_null[0]) fprintf(stdout, "\n row 3: NULL, %s(%lu)", szData, length1); DIE_UNLESS(is_null[0]); DIE_UNLESS(strcmp(szData, "monty") == 0); @@ -5194,7 +5324,8 @@ static void test_store_result() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 1: %ld, %s(%lu)", (long) nData, szData, length1); + if (!opt_silent) + fprintf(stdout, "\n row 1: %ld, %s(%lu)", (long) nData, szData, length1); DIE_UNLESS(nData == 10); DIE_UNLESS(strcmp(szData, "venu") == 0); DIE_UNLESS(length1 == 4); @@ -5202,7 +5333,8 @@ static void test_store_result() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 2: %ld, %s(%lu)", (long) nData, szData, length1); + if (!opt_silent) + fprintf(stdout, "\n row 2: %ld, %s(%lu)", (long) nData, szData, length1); DIE_UNLESS(nData == 20); DIE_UNLESS(strcmp(szData, "mysql") == 0); DIE_UNLESS(length1 == 5); @@ -5211,7 +5343,7 @@ static void test_store_result() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - if (is_null[0]) + if (!opt_silent && is_null[0]) fprintf(stdout, "\n row 3: NULL, %s(%lu)", szData, length1); DIE_UNLESS(is_null[0]); DIE_UNLESS(strcmp(szData, "monty") == 0); @@ -5260,7 +5392,8 @@ static void test_store_result1() rc= 0; while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA) rc++; - fprintf(stdout, "\n total rows: %d", rc); + if (!opt_silent) + fprintf(stdout, "\n total rows: %d", rc); DIE_UNLESS(rc == 3); rc= mysql_stmt_execute(stmt); @@ -5272,7 +5405,8 @@ static void test_store_result1() rc= 0; while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA) rc++; - fprintf(stdout, "\n total rows: %d", rc); + if (!opt_silent) + fprintf(stdout, "\n total rows: %d", rc); DIE_UNLESS(rc == 3); mysql_stmt_close(stmt); @@ -5338,7 +5472,8 @@ static void test_store_result2() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 1: %d", nData); + if (!opt_silent) + fprintf(stdout, "\n row 1: %d", nData); DIE_UNLESS(nData == 10); rc= mysql_stmt_fetch(stmt); @@ -5355,7 +5490,8 @@ static void test_store_result2() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 1: %d", nData); + if (!opt_silent) + fprintf(stdout, "\n row 1: %d", nData); DIE_UNLESS(nData == 20); rc= mysql_stmt_fetch(stmt); @@ -5458,7 +5594,8 @@ static void test_subselect() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 1: %d", id); + if (!opt_silent) + fprintf(stdout, "\n row 1: %d", id); DIE_UNLESS(id == 1); rc= mysql_stmt_fetch(stmt); @@ -5471,7 +5608,8 @@ static void test_subselect() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 1: %d", id); + if (!opt_silent) + fprintf(stdout, "\n row 1: %d", id); DIE_UNLESS(id == 0); rc= mysql_stmt_fetch(stmt); @@ -5587,21 +5725,21 @@ static void test_bind_date_conv(uint row_count) rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n"); + if (!opt_silent) + fprintf(stdout, "\n"); for (i= 0; i < array_elements(bind); i++) { - fprintf(stdout, "\n"); - fprintf(stdout, " time[%d]: %02d-%02d-%02d %02d:%02d:%02d.%02lu", - i, tm[i].year, tm[i].month, tm[i].day, - tm[i].hour, tm[i].minute, tm[i].second, - tm[i].second_part); - + if (!opt_silent) + fprintf(stdout, "\ntime[%d]: %02d-%02d-%02d %02d:%02d:%02d.%02lu", + i, tm[i].year, tm[i].month, tm[i].day, + tm[i].hour, tm[i].minute, tm[i].second, + tm[i].second_part); DIE_UNLESS(tm[i].year == 0 || tm[i].year == year+count); DIE_UNLESS(tm[i].month == 0 || tm[i].month == month+count); DIE_UNLESS(tm[i].day == 0 || tm[i].day == day+count); DIE_UNLESS(tm[i].hour == 0 || tm[i].hour == hour+count); -#if 0 +#ifdef NOT_USED /* minute causes problems from date<->time, don't assert, instead validate separatly in another routine @@ -5856,7 +5994,8 @@ static void test_buffers() buffer[1]= 'X'; rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n data: %s (%lu)", buffer, length); + if (!opt_silent) + fprintf(stdout, "\n data: %s (%lu)", buffer, length); DIE_UNLESS(buffer[0] == 'M'); DIE_UNLESS(buffer[1] == 'X'); DIE_UNLESS(length == 5); @@ -5867,7 +6006,8 @@ static void test_buffers() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n data: %s (%lu)", buffer, length); + if (!opt_silent) + fprintf(stdout, "\n data: %s (%lu)", buffer, length); DIE_UNLESS(strncmp(buffer, "Database", 8) == 0); DIE_UNLESS(length == 8); @@ -5877,7 +6017,8 @@ static void test_buffers() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n data: %s (%lu)", buffer, length); + if (!opt_silent) + fprintf(stdout, "\n data: %s (%lu)", buffer, length); DIE_UNLESS(strcmp(buffer, "Open-Source") == 0); DIE_UNLESS(length == 11); @@ -5887,7 +6028,8 @@ static void test_buffers() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n data: %s (%lu)", buffer, length); + if (!opt_silent) + fprintf(stdout, "\n data: %s (%lu)", buffer, length); DIE_UNLESS(strncmp(buffer, "Popula", 6) == 0); DIE_UNLESS(length == 7); @@ -6018,7 +6160,8 @@ static void test_fetch_nobuffs() while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA) rc++; - fprintf(stdout, "\n total rows : %d", rc); + if (!opt_silent) + fprintf(stdout, "\n total rows : %d", rc); DIE_UNLESS(rc == 1); bind[0].buffer_type= MYSQL_TYPE_STRING; @@ -6041,12 +6184,16 @@ static void test_fetch_nobuffs() while (mysql_stmt_fetch(stmt) != MYSQL_NO_DATA) { rc++; - fprintf(stdout, "\n CURRENT_DATABASE(): %s", str[0]); - fprintf(stdout, "\n CURRENT_USER() : %s", str[1]); - fprintf(stdout, "\n CURRENT_DATE() : %s", str[2]); - fprintf(stdout, "\n CURRENT_TIME() : %s", str[3]); + if (!opt_silent) + { + fprintf(stdout, "\n CURRENT_DATABASE(): %s", str[0]); + fprintf(stdout, "\n CURRENT_USER() : %s", str[1]); + fprintf(stdout, "\n CURRENT_DATE() : %s", str[2]); + fprintf(stdout, "\n CURRENT_TIME() : %s", str[3]); + } } - fprintf(stdout, "\n total rows : %d", rc); + if (!opt_silent) + fprintf(stdout, "\n total rows : %d", rc); DIE_UNLESS(rc == 1); mysql_stmt_close(stmt); @@ -6113,10 +6260,13 @@ static void test_ushort_bug() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n ushort : %d (%ld)", short_value, s_length); - fprintf(stdout, "\n ulong : %lu (%ld)", (ulong) long_value, l_length); - fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length); - fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length); + if (!opt_silent) + { + fprintf(stdout, "\n ushort : %d (%ld)", short_value, s_length); + fprintf(stdout, "\n ulong : %lu (%ld)", (ulong) long_value, l_length); + fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length); + fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length); + } DIE_UNLESS(short_value == 35999); DIE_UNLESS(s_length == 2); @@ -6197,10 +6347,13 @@ static void test_sshort_bug() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n sshort : %d (%ld)", short_value, s_length); - fprintf(stdout, "\n slong : %ld (%ld)", (long) long_value, l_length); - fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length); - fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length); + if (!opt_silent) + { + fprintf(stdout, "\n sshort : %d (%ld)", short_value, s_length); + fprintf(stdout, "\n slong : %ld (%ld)", (long) long_value, l_length); + fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length); + fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length); + } DIE_UNLESS(short_value == -5999); DIE_UNLESS(s_length == 2); @@ -6281,10 +6434,13 @@ static void test_stiny_bug() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n sshort : %d (%ld)", short_value, s_length); - fprintf(stdout, "\n slong : %ld (%ld)", (long) long_value, l_length); - fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length); - fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length); + if (!opt_silent) + { + fprintf(stdout, "\n sshort : %d (%ld)", short_value, s_length); + fprintf(stdout, "\n slong : %ld (%ld)", (long) long_value, l_length); + fprintf(stdout, "\n longlong : %lld (%ld)", longlong_value, ll_length); + fprintf(stdout, "\n tinyint : %d (%ld)", tiny_value, t_length); + } DIE_UNLESS(short_value == -128); DIE_UNLESS(s_length == 2); @@ -6373,7 +6529,8 @@ static void test_field_misc() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n default table type: %s(%ld)", table_type, type_length); + if (!opt_silent) + fprintf(stdout, "\n default table type: %s(%ld)", table_type, type_length); rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == MYSQL_NO_DATA); @@ -6493,7 +6650,8 @@ static void test_set_option() rc= mysql_query(mysql, "INSERT INTO test_limit VALUES(10), (20), (30), (40)"); myquery(rc); - fprintf(stdout, "\n with SQL_SELECT_LIMIT= 2 (direct)"); + if (!opt_silent) + fprintf(stdout, "\n with SQL_SELECT_LIMIT= 2 (direct)"); rc= mysql_query(mysql, "SELECT * FROM test_limit"); myquery(rc); @@ -6505,7 +6663,8 @@ static void test_set_option() mysql_free_result(result); - fprintf(stdout, "\n with SQL_SELECT_LIMIT=2 (prepare)"); + if (!opt_silent) + fprintf(stdout, "\n with SQL_SELECT_LIMIT=2 (prepare)"); stmt= mysql_simple_prepare(mysql, "SELECT * FROM test_limit"); check_stmt(stmt); @@ -6518,7 +6677,8 @@ static void test_set_option() mysql_stmt_close(stmt); /* RESET the LIMIT the rows count to 0 */ - fprintf(stdout, "\n with SQL_SELECT_LIMIT=DEFAULT (prepare)"); + if (!opt_silent) + fprintf(stdout, "\n with SQL_SELECT_LIMIT=DEFAULT (prepare)"); rc= mysql_query(mysql, "SET OPTION SQL_SELECT_LIMIT=DEFAULT"); myquery(rc); @@ -6576,7 +6736,8 @@ static void test_prepare_grant() MYSQL *org_mysql= mysql, *lmysql; MYSQL_STMT *stmt; - fprintf(stdout, "\n Establishing a test connection ..."); + if (!opt_silent) + fprintf(stdout, "\n Establishing a test connection ..."); if (!(lmysql= mysql_init(NULL))) { myerror("mysql_init() failed"); @@ -6590,7 +6751,8 @@ static void test_prepare_grant() mysql_close(lmysql); exit(1); } - fprintf(stdout, " OK"); + if (!opt_silent) + fprintf(stdout, " OK"); mysql= lmysql; rc= mysql_query(mysql, "INSERT INTO test_grant VALUES(NULL)"); @@ -6677,14 +6839,16 @@ static void test_frm_bug() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n data directory: %s", data_dir); + if (!opt_silent) + fprintf(stdout, "\n data directory: %s", data_dir); rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == MYSQL_NO_DATA); strxmov(test_frm, data_dir, "/", current_db, "/", "test_frm_bug.frm", NullS); - fprintf(stdout, "\n test_frm: %s", test_frm); + if (!opt_silent) + fprintf(stdout, "\n test_frm: %s", test_frm); if (!(test_file= my_fopen(test_frm, (int) (O_RDWR | O_CREAT), MYF(MY_WME)))) { @@ -6692,7 +6856,8 @@ static void test_frm_bug() fprintf(stdout, "\n test cancelled"); exit(1); } - fprintf(test_file, "this is a junk file for test"); + if (!opt_silent) + fprintf(test_file, "this is a junk file for test"); rc= mysql_query(mysql, "SHOW TABLE STATUS like 'test_frm_bug'"); myquery(rc); @@ -6708,7 +6873,8 @@ static void test_frm_bug() row= mysql_fetch_row(result); mytest(row); - fprintf(stdout, "\n Comment: %s", row[17]); + if (!opt_silent) + fprintf(stdout, "\n Comment: %s", row[17]); DIE_UNLESS(row[17] != 0); mysql_free_result(result); @@ -6771,7 +6937,8 @@ static void test_decimal_bug() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n data: %s", data); + if (!opt_silent) + fprintf(stdout, "\n data: %s", data); DIE_UNLESS(strcmp(data, "8.00") == 0); rc= mysql_stmt_fetch(stmt); @@ -6788,7 +6955,8 @@ static void test_decimal_bug() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n data: %s", data); + if (!opt_silent) + fprintf(stdout, "\n data: %s", data); DIE_UNLESS(strcmp(data, "5.61") == 0); rc= mysql_stmt_fetch(stmt); @@ -6812,7 +6980,8 @@ static void test_decimal_bug() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n data: %s", data); + if (!opt_silent) + fprintf(stdout, "\n data: %s", data); DIE_UNLESS(strcmp(data, "10.22") == 0); rc= mysql_stmt_fetch(stmt); @@ -6852,8 +7021,9 @@ static void test_explain_bug() result= mysql_stmt_result_metadata(stmt); mytest(result); - fprintf(stdout, "\n total fields in the result: %d", - mysql_num_fields(result)); + if (!opt_silent) + fprintf(stdout, "\n total fields in the result: %d", + mysql_num_fields(result)); DIE_UNLESS(6 == mysql_num_fields(result)); verify_prepare_field(result, 0, "Field", "", MYSQL_TYPE_VAR_STRING, @@ -6889,8 +7059,9 @@ static void test_explain_bug() result= mysql_stmt_result_metadata(stmt); mytest(result); - fprintf(stdout, "\n total fields in the result: %d", - mysql_num_fields(result)); + if (!opt_silent) + fprintf(stdout, "\n total fields in the result: %d", + mysql_num_fields(result)); DIE_UNLESS(10 == mysql_num_fields(result)); verify_prepare_field(result, 0, "id", "", MYSQL_TYPE_LONGLONG, @@ -6911,8 +7082,12 @@ static void test_explain_bug() verify_prepare_field(result, 5, "key", "", MYSQL_TYPE_VAR_STRING, "", "", "", NAME_LEN, 0); - verify_prepare_field(result, 6, "key_len", "", MYSQL_TYPE_LONGLONG, - "", "", "", 3, 0); + verify_prepare_field(result, 6, "key_len", "", + (mysql_get_server_version(mysql) <= 50000 ? + MYSQL_TYPE_LONGLONG : MYSQL_TYPE_VAR_STRING), + "", "", "", + (mysql_get_server_version(mysql) <= 50000 ? 3 : 4096), + 0); verify_prepare_field(result, 7, "ref", "", MYSQL_TYPE_VAR_STRING, "", "", "", NAME_LEN*16, 0); @@ -6938,11 +7113,14 @@ static void test_explain_bug() static void check_errcode(const unsigned int err) { - if (mysql->server_version) - fprintf(stdout, "\n [MySQL-%s]", mysql->server_version); - else - fprintf(stdout, "\n [MySQL]"); - fprintf(stdout, "[%d] %s\n", mysql_errno(mysql), mysql_error(mysql)); + if (!opt_silent || mysql_errno(mysql) != err) + { + if (mysql->server_version) + fprintf(stdout, "\n [MySQL-%s]", mysql->server_version); + else + fprintf(stdout, "\n [MySQL]"); + fprintf(stdout, "[%d] %s\n", mysql_errno(mysql), mysql_error(mysql)); + } DIE_UNLESS(mysql_errno(mysql) == err); } @@ -6988,7 +7166,8 @@ static void test_drop_temp() { MYSQL *org_mysql= mysql, *lmysql; - fprintf(stdout, "\n Establishing a test connection ..."); + if (!opt_silent) + fprintf(stdout, "\n Establishing a test connection ..."); if (!(lmysql= mysql_init(NULL))) { myerror("mysql_init() failed"); @@ -7007,7 +7186,8 @@ static void test_drop_temp() mysql_close(lmysql); exit(1); } - fprintf(stdout, " OK"); + if (!opt_silent) + fprintf(stdout, " OK"); mysql= lmysql; rc= mysql_query(mysql, "INSERT INTO t1 VALUES(10, 'C')"); @@ -7076,14 +7256,16 @@ static void test_cuted_rows() myquery(rc); count= mysql_warning_count(mysql); - fprintf(stdout, "\n total warnings: %d", count); + if (!opt_silent) + fprintf(stdout, "\n total warnings: %d", count); DIE_UNLESS(count == 0); rc= mysql_query(mysql, "INSERT INTO t2 SELECT * FROM t1"); myquery(rc); count= mysql_warning_count(mysql); - fprintf(stdout, "\n total warnings: %d", count); + if (!opt_silent) + fprintf(stdout, "\n total warnings: %d", count); DIE_UNLESS(count == 2); rc= mysql_query(mysql, "SHOW WARNINGS"); @@ -7100,7 +7282,8 @@ static void test_cuted_rows() myquery(rc); count= mysql_warning_count(mysql); - fprintf(stdout, "\n total warnings: %d", count); + if (!opt_silent) + fprintf(stdout, "\n total warnings: %d", count); DIE_UNLESS(count == 2); rc= mysql_query(mysql, "SHOW WARNINGS"); @@ -7213,8 +7396,11 @@ static void test_logs() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n id : %d", id); - fprintf(stdout, "\n name : %s(%ld)", data, length); + if (!opt_silent) + { + fprintf(stdout, "\n id : %d", id); + fprintf(stdout, "\n name : %s(%ld)", data, length); + } DIE_UNLESS(id == 9876); DIE_UNLESS(length == 19); /* Due to VARCHAR(20) */ @@ -7223,7 +7409,8 @@ static void test_logs() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n name : %s(%ld)", data, length); + if (!opt_silent) + fprintf(stdout, "\n name : %s(%ld)", data, length); DIE_UNLESS(length == 1); DIE_UNLESS(strcmp(data, "'") == 0); @@ -7231,7 +7418,8 @@ static void test_logs() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n name : %s(%ld)", data, length); + if (!opt_silent) + fprintf(stdout, "\n name : %s(%ld)", data, length); DIE_UNLESS(length == 1); DIE_UNLESS(strcmp(data, "\"") == 0); @@ -7239,7 +7427,8 @@ static void test_logs() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n name : %s(%ld)", data, length); + if (!opt_silent) + fprintf(stdout, "\n name : %s(%ld)", data, length); DIE_UNLESS(length == 7); DIE_UNLESS(strcmp(data, "my\'sql\'") == 0); @@ -7247,7 +7436,8 @@ static void test_logs() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n name : %s(%ld)", data, length); + if (!opt_silent) + fprintf(stdout, "\n name : %s(%ld)", data, length); DIE_UNLESS(length == 7); /*DIE_UNLESS(strcmp(data, "my\"sql\"") == 0); */ @@ -7293,7 +7483,8 @@ static void test_nstmts() for (i= 0; i < total_stmts; i++) { - fprintf(stdout, "\r stmt: %d", i); + if (!opt_silent) + fprintf(stdout, "\r stmt: %d", i); strmov(query, "insert into test_nstmts values(?)"); stmt= mysql_simple_prepare(mysql, query); @@ -7320,7 +7511,8 @@ static void test_nstmts() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n total rows: %d", i); + if (!opt_silent) + fprintf(stdout, "\n total rows: %d", i); DIE_UNLESS( i == total_stmts); rc= mysql_stmt_fetch(stmt); @@ -7386,7 +7578,8 @@ static void test_fetch_seek() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 0: %ld, %s, %s", (long) c1, c2, c3); + if (!opt_silent) + fprintf(stdout, "\n row 0: %ld, %s, %s", (long) c1, c2, c3); row= mysql_stmt_row_tell(stmt); @@ -7395,21 +7588,24 @@ static void test_fetch_seek() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 2: %ld, %s, %s", (long) c1, c2, c3); + if (!opt_silent) + fprintf(stdout, "\n row 2: %ld, %s, %s", (long) c1, c2, c3); row= mysql_stmt_row_seek(stmt, row); rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 2: %ld, %s, %s", (long) c1, c2, c3); + if (!opt_silent) + fprintf(stdout, "\n row 2: %ld, %s, %s", (long) c1, c2, c3); mysql_stmt_data_seek(stmt, 0); rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 0: %ld, %s, %s", (long) c1, c2, c3); + if (!opt_silent) + fprintf(stdout, "\n row 0: %ld, %s, %s", (long) c1, c2, c3); rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); @@ -7477,17 +7673,20 @@ static void test_fetch_offset() data[0]= '\0'; rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 1: %s (%ld)", data, length); + if (!opt_silent) + fprintf(stdout, "\n col 1: %s (%ld)", data, length); DIE_UNLESS(strncmp(data, "abcd", 4) == 0 && length == 10); rc= mysql_stmt_fetch_column(stmt, bind, 0, 5); check_execute(stmt, rc); - fprintf(stdout, "\n col 1: %s (%ld)", data, length); + if (!opt_silent) + fprintf(stdout, "\n col 1: %s (%ld)", data, length); DIE_UNLESS(strncmp(data, "fg", 2) == 0 && length == 10); rc= mysql_stmt_fetch_column(stmt, bind, 0, 9); check_execute(stmt, rc); - fprintf(stdout, "\n col 0: %s (%ld)", data, length); + if (!opt_silent) + fprintf(stdout, "\n col 0: %s (%ld)", data, length); DIE_UNLESS(strncmp(data, "j", 1) == 0 && length == 10); rc= mysql_stmt_fetch(stmt); @@ -7560,7 +7759,8 @@ static void test_fetch_column() rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 0: %d, %s", bc1, bc2); + if (!opt_silent) + fprintf(stdout, "\n row 0: %d, %s", bc1, bc2); c2[0]= '\0'; l2= 0; bind[0].buffer_type= MYSQL_TYPE_STRING; @@ -7571,13 +7771,15 @@ static void test_fetch_column() rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); + if (!opt_silent) + fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); DIE_UNLESS(strncmp(c2, "venu", 4) == 0 && l2 == 4); c2[0]= '\0'; l2= 0; rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); + if (!opt_silent) + fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); DIE_UNLESS(strcmp(c2, "venu") == 0 && l2 == 4); c1= 0; @@ -7589,13 +7791,15 @@ static void test_fetch_column() rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); + if (!opt_silent) + fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); DIE_UNLESS(c1 == 1 && l1 == 4); rc= mysql_stmt_fetch(stmt); check_execute(stmt, rc); - fprintf(stdout, "\n row 1: %d, %s", bc1, bc2); + if (!opt_silent) + fprintf(stdout, "\n row 1: %d, %s", bc1, bc2); c2[0]= '\0'; l2= 0; bind[0].buffer_type= MYSQL_TYPE_STRING; @@ -7606,13 +7810,15 @@ static void test_fetch_column() rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); + if (!opt_silent) + fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); DIE_UNLESS(strncmp(c2, "mysq", 4) == 0 && l2 == 5); c2[0]= '\0'; l2= 0; rc= mysql_stmt_fetch_column(stmt, bind, 1, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 1: %si(%ld)", c2, l2); + if (!opt_silent) + fprintf(stdout, "\n col 1: %si(%ld)", c2, l2); DIE_UNLESS(strcmp(c2, "mysql") == 0 && l2 == 5); c1= 0; @@ -7624,7 +7830,8 @@ static void test_fetch_column() rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); + if (!opt_silent) + fprintf(stdout, "\n col 0: %d(%ld)", c1, l1); DIE_UNLESS(c1 == 2 && l1 == 4); rc= mysql_stmt_fetch(stmt); @@ -7678,7 +7885,6 @@ static void test_mem_overun() MYSQL_RES *field_res; int rc, i, length; - myheader("test_mem_overun"); /* @@ -7728,7 +7934,8 @@ static void test_mem_overun() field_res= mysql_stmt_result_metadata(stmt); mytest(field_res); - fprintf(stdout, "\n total fields : %d", mysql_num_fields(field_res)); + if (!opt_silent) + fprintf(stdout, "\n total fields : %d", mysql_num_fields(field_res)); DIE_UNLESS( 1000 == mysql_num_fields(field_res)); rc= mysql_stmt_store_result(stmt); @@ -7795,7 +8002,8 @@ static void test_free_result() rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 0: %s(%ld)", c2, l2); + if (!opt_silent) + fprintf(stdout, "\n col 0: %s(%ld)", c2, l2); DIE_UNLESS(strncmp(c2, "1", 1) == 0 && l2 == 1); rc= mysql_stmt_fetch(stmt); @@ -7810,7 +8018,8 @@ static void test_free_result() rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); + if (!opt_silent) + fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); DIE_UNLESS(c1 == 2 && l2 == 4); rc= mysql_query(mysql, "drop table test_free_result"); @@ -7877,7 +8086,8 @@ static void test_free_store_result() rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); + if (!opt_silent) + fprintf(stdout, "\n col 1: %s(%ld)", c2, l2); DIE_UNLESS(strncmp(c2, "1", 1) == 0 && l2 == 1); rc= mysql_stmt_fetch(stmt); @@ -7892,7 +8102,8 @@ static void test_free_store_result() rc= mysql_stmt_fetch_column(stmt, bind, 0, 0); check_execute(stmt, rc); - fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); + if (!opt_silent) + fprintf(stdout, "\n col 0: %d(%ld)", c1, l2); DIE_UNLESS(c1 == 2 && l2 == 4); rc= mysql_stmt_free_result(stmt); @@ -7924,16 +8135,19 @@ static void test_sqlmode() /* PIPES_AS_CONCAT */ strcpy(query, "SET SQL_MODE= \"PIPES_AS_CONCAT\""); - fprintf(stdout, "\n With %s", query); + if (!opt_silent) + fprintf(stdout, "\n With %s", query); rc= mysql_query(mysql, query); myquery(rc); strcpy(query, "INSERT INTO test_piping VALUES(?||?)"); - fprintf(stdout, "\n query: %s", query); + if (!opt_silent) + fprintf(stdout, "\n query: %s", query); stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - fprintf(stdout, "\n total parameters: %ld", mysql_stmt_param_count(stmt)); + if (!opt_silent) + fprintf(stdout, "\n total parameters: %ld", mysql_stmt_param_count(stmt)); /* We need to bzero bind structure because mysql_stmt_bind_param checks all @@ -7963,21 +8177,25 @@ static void test_sqlmode() myquery(rc); strcpy(query, "SELECT connection_id ()"); - fprintf(stdout, "\n query: %s", query); + if (!opt_silent) + fprintf(stdout, "\n query: %s", query); stmt= mysql_simple_prepare(mysql, query); check_stmt_r(stmt); /* ANSI */ strcpy(query, "SET SQL_MODE= \"ANSI\""); - fprintf(stdout, "\n With %s", query); + if (!opt_silent) + fprintf(stdout, "\n With %s", query); rc= mysql_query(mysql, query); myquery(rc); strcpy(query, "INSERT INTO test_piping VALUES(?||?)"); - fprintf(stdout, "\n query: %s", query); + if (!opt_silent) + fprintf(stdout, "\n query: %s", query); stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); - fprintf(stdout, "\n total parameters: %ld", mysql_stmt_param_count(stmt)); + if (!opt_silent) + fprintf(stdout, "\n total parameters: %ld", mysql_stmt_param_count(stmt)); rc= mysql_stmt_bind_param(stmt, bind); check_execute(stmt, rc); @@ -7991,7 +8209,8 @@ static void test_sqlmode() /* ANSI mode spaces ... */ strcpy(query, "SELECT connection_id ()"); - fprintf(stdout, "\n query: %s", query); + if (!opt_silent) + fprintf(stdout, "\n query: %s", query); stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); @@ -8003,18 +8222,21 @@ static void test_sqlmode() rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == MYSQL_NO_DATA); - fprintf(stdout, "\n returned 1 row\n"); + if (!opt_silent) + fprintf(stdout, "\n returned 1 row\n"); mysql_stmt_close(stmt); /* IGNORE SPACE MODE */ strcpy(query, "SET SQL_MODE= \"IGNORE_SPACE\""); - fprintf(stdout, "\n With %s", query); + if (!opt_silent) + fprintf(stdout, "\n With %s", query); rc= mysql_query(mysql, query); myquery(rc); strcpy(query, "SELECT connection_id ()"); - fprintf(stdout, "\n query: %s", query); + if (!opt_silent) + fprintf(stdout, "\n query: %s", query); stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); @@ -8026,7 +8248,8 @@ static void test_sqlmode() rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == MYSQL_NO_DATA); - fprintf(stdout, "\n returned 1 row"); + if (!opt_silent) + fprintf(stdout, "\n returned 1 row"); mysql_stmt_close(stmt); } @@ -8118,7 +8341,8 @@ static void test_ts() sprintf(query, "SELECT a, b, c FROM test_ts WHERE %c=?", name); - fprintf(stdout, "\n %s", query); + if (!opt_silent) + fprintf(stdout, "\n %s", query); stmt= mysql_simple_prepare(mysql, query); check_stmt(stmt); @@ -8131,7 +8355,8 @@ static void test_ts() while (mysql_stmt_fetch(stmt) == 0) row_count++; - fprintf(stdout, "\n returned '%d' rows", row_count); + if (!opt_silent) + fprintf(stdout, "\n returned '%d' rows", row_count); DIE_UNLESS(row_count == 2); mysql_stmt_close(stmt); } @@ -8273,7 +8498,8 @@ static void test_bug1946() check_stmt(stmt); rc= mysql_real_query(mysql, query, strlen(query)); DIE_UNLESS(rc != 0); - fprintf(stdout, "Got error (as expected):\n"); + if (!opt_silent) + fprintf(stdout, "Got error (as expected):\n"); myerror(NULL); mysql_stmt_close(stmt); @@ -8291,19 +8517,23 @@ static void test_parse_error_and_bad_length() rc= mysql_query(mysql, "SHOW DATABAAAA"); DIE_UNLESS(rc); - fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql)); + if (!opt_silent) + fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql)); rc= mysql_real_query(mysql, "SHOW DATABASES", 100); DIE_UNLESS(rc); - fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql)); + if (!opt_silent) + fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql)); stmt= mysql_simple_prepare(mysql, "SHOW DATABAAAA"); DIE_UNLESS(!stmt); - fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql)); + if (!opt_silent) + fprintf(stdout, "Got error (as expected): '%s'\n", mysql_error(mysql)); stmt= mysql_stmt_init(mysql); DIE_UNLESS(stmt); rc= mysql_stmt_prepare(stmt, "SHOW DATABASES", 100); DIE_UNLESS(rc != 0); - fprintf(stdout, "Got error (as expected): '%s'\n", mysql_stmt_error(stmt)); + if (!opt_silent) + fprintf(stdout, "Got error (as expected): '%s'\n", mysql_stmt_error(stmt)); mysql_stmt_close(stmt); } @@ -8324,7 +8554,8 @@ static void test_bug2247() myheader("test_bug2247"); - fprintf(stdout, "\nChecking if stmt_affected_rows is not affected by\n" + if (!opt_silent) + fprintf(stdout, "\nChecking if stmt_affected_rows is not affected by\n" "mysql_query ... "); /* create table and insert few rows */ rc= mysql_query(mysql, drop); @@ -8381,7 +8612,8 @@ static void test_bug2247() DIE_UNLESS(mysql_stmt_affected_rows(stmt) == exp_count); mysql_stmt_close(stmt); - fprintf(stdout, "OK"); + if (!opt_silent) + fprintf(stdout, "OK"); } @@ -8659,7 +8891,8 @@ static void test_bug3117() check_execute(stmt, rc); DIE_UNLESS(is_null == 0 && lii == 1); - fprintf(stdout, "\n\tLAST_INSERT_ID()= 1 ok\n"); + if (!opt_silent) + fprintf(stdout, "\n\tLAST_INSERT_ID()= 1 ok\n"); rc= mysql_query(mysql, "INSERT INTO t1 VALUES (NULL)"); myquery(rc); @@ -8671,7 +8904,8 @@ static void test_bug3117() check_execute(stmt, rc); DIE_UNLESS(is_null == 0 && lii == 2); - fprintf(stdout, "\tLAST_INSERT_ID()= 2 ok\n"); + if (!opt_silent) + fprintf(stdout, "\tLAST_INSERT_ID()= 2 ok\n"); mysql_stmt_close(stmt); @@ -8821,7 +9055,8 @@ static void test_create_drop() { rc= mysql_stmt_execute(stmt_create); check_execute(stmt_create, rc); - fprintf(stdout, "created %i\n", i); + if (!opt_silent) + fprintf(stdout, "created %i\n", i); rc= mysql_stmt_execute(stmt_select); check_execute(stmt_select, rc); @@ -8830,11 +9065,13 @@ static void test_create_drop() rc= mysql_stmt_execute(stmt_drop); check_execute(stmt_drop, rc); - fprintf(stdout, "droped %i\n", i); + if (!opt_silent) + fprintf(stdout, "droped %i\n", i); rc= mysql_stmt_execute(stmt_create_select); check_execute(stmt_create, rc); - fprintf(stdout, "created select %i\n", i); + if (!opt_silent) + fprintf(stdout, "created select %i\n", i); rc= mysql_stmt_execute(stmt_select); check_execute(stmt_select, rc); @@ -8843,7 +9080,8 @@ static void test_create_drop() rc= mysql_stmt_execute(stmt_drop); check_execute(stmt_drop, rc); - fprintf(stdout, "droped %i\n", i); + if (!opt_silent) + fprintf(stdout, "droped %i\n", i); } mysql_stmt_close(stmt_create); @@ -8874,25 +9112,29 @@ static void test_rename() rc= mysql_stmt_execute(stmt); check_execute_r(stmt, rc); - fprintf(stdout, "rename without t3\n"); + if (!opt_silent) + fprintf(stdout, "rename without t3\n"); rc= mysql_query(mysql, "create table t3 (a int)"); myquery(rc); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - fprintf(stdout, "rename with t3\n"); + if (!opt_silent) + fprintf(stdout, "rename with t3\n"); rc= mysql_stmt_execute(stmt); check_execute_r(stmt, rc); - fprintf(stdout, "rename renamed\n"); + if (!opt_silent) + fprintf(stdout, "rename renamed\n"); rc= mysql_query(mysql, "rename table t2 to t1, t4 to t3"); myquery(rc); rc= mysql_stmt_execute(stmt); check_execute(stmt, rc); - fprintf(stdout, "rename reverted\n"); + if (!opt_silent) + fprintf(stdout, "rename reverted\n"); mysql_stmt_close(stmt); @@ -8926,10 +9168,12 @@ static void test_do_set() { rc= mysql_stmt_execute(stmt_do); check_execute(stmt_do, rc); - fprintf(stdout, "do %i\n", i); + if (!opt_silent) + fprintf(stdout, "do %i\n", i); rc= mysql_stmt_execute(stmt_set); check_execute(stmt_set, rc); - fprintf(stdout, "set %i\n", i); + if (!opt_silent) + fprintf(stdout, "set %i\n", i); } mysql_stmt_close(stmt_do); @@ -8995,11 +9239,13 @@ static void test_multi() rc= mysql_stmt_execute(stmt_update); check_execute(stmt_update, rc); - fprintf(stdout, "update %ld\n", (long) param); + if (!opt_silent) + fprintf(stdout, "update %ld\n", (long) param); rc= mysql_stmt_execute(stmt_delete); check_execute(stmt_delete, rc); - fprintf(stdout, "delete %ld\n", (long) param); + if (!opt_silent) + fprintf(stdout, "delete %ld\n", (long) param); rc= mysql_stmt_execute(stmt_select1); check_execute(stmt_select1, rc); @@ -9055,7 +9301,8 @@ static void test_insert_select() { rc= mysql_stmt_execute(stmt_insert); check_execute(stmt_insert, rc); - fprintf(stdout, "insert %u\n", i); + if (!opt_silent) + fprintf(stdout, "insert %u\n", i); rc= mysql_stmt_execute(stmt_select); check_execute(stmt_select, rc); @@ -9915,7 +10162,8 @@ static void test_bug3796() mysql_stmt_bind_result(stmt, bind); rc= mysql_stmt_fetch(stmt); - printf("Concat result: '%s'\n", out_buff); + if (!opt_silent) + printf("Concat result: '%s'\n", out_buff); check_execute(stmt, rc); strcpy(canonical_buff, concat_arg0); strcat(canonical_buff, "ONE"); @@ -9927,7 +10175,8 @@ static void test_bug3796() strcpy(canonical_buff + strlen(concat_arg0), "TWO"); DIE_UNLESS(strlen(canonical_buff) == out_length && strncmp(out_buff, canonical_buff, out_length) == 0); - printf("Concat result: '%s'\n", out_buff); + if (!opt_silent) + printf("Concat result: '%s'\n", out_buff); rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == MYSQL_NO_DATA); @@ -10001,12 +10250,15 @@ static void test_bug4026() rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == 0); - printf("%d:%d:%d.%lu\n", time_out.hour, time_out.minute, time_out.second, - time_out.second_part); - printf("%d-%d-%d %d:%d:%d.%lu\n", datetime_out.year, datetime_out.month, - datetime_out.day, datetime_out.hour, - datetime_out.minute, datetime_out.second, - datetime_out.second_part); + if (!opt_silent) + { + printf("%d:%d:%d.%lu\n", time_out.hour, time_out.minute, time_out.second, + time_out.second_part); + printf("%d-%d-%d %d:%d:%d.%lu\n", datetime_out.year, datetime_out.month, + datetime_out.day, datetime_out.hour, + datetime_out.minute, datetime_out.second, + datetime_out.second_part); + } DIE_UNLESS(memcmp(&time_in, &time_out, sizeof(time_in)) == 0); DIE_UNLESS(memcmp(&datetime_in, &datetime_out, sizeof(datetime_in)) == 0); mysql_stmt_close(stmt); @@ -10049,8 +10301,9 @@ static void test_bug4079() rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc != 0 && rc != MYSQL_NO_DATA); - printf("Got error from mysql_stmt_fetch (as expected):\n%s\n", - mysql_stmt_error(stmt)); + if (!opt_silent) + printf("Got error from mysql_stmt_fetch (as expected):\n%s\n", + mysql_stmt_error(stmt)); /* buggy version of libmysql hanged up here */ mysql_stmt_close(stmt); } @@ -10144,13 +10397,16 @@ static void test_bug4030() rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == 0); - printf("%d:%d:%d.%lu\n", time_out.hour, time_out.minute, time_out.second, - time_out.second_part); - printf("%d-%d-%d\n", date_out.year, date_out.month, date_out.day); - printf("%d-%d-%d %d:%d:%d.%lu\n", datetime_out.year, datetime_out.month, - datetime_out.day, datetime_out.hour, - datetime_out.minute, datetime_out.second, - datetime_out.second_part); + if (!opt_silent) + { + printf("%d:%d:%d.%lu\n", time_out.hour, time_out.minute, time_out.second, + time_out.second_part); + printf("%d-%d-%d\n", date_out.year, date_out.month, date_out.day); + printf("%d-%d-%d %d:%d:%d.%lu\n", datetime_out.year, datetime_out.month, + datetime_out.day, datetime_out.hour, + datetime_out.minute, datetime_out.second, + datetime_out.second_part); + } DIE_UNLESS(memcmp(&time_canonical, &time_out, sizeof(time_out)) == 0); DIE_UNLESS(memcmp(&date_canonical, &date_out, sizeof(date_out)) == 0); DIE_UNLESS(memcmp(&datetime_canonical, &datetime_out, sizeof(datetime_out)) == 0); @@ -10200,7 +10456,8 @@ static void test_bug5126() rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == 0); DIE_UNLESS(c1 == 8386608 && c2 == 1); - printf("%ld, %ld\n", (long) c1, (long) c2); + if (!opt_silent) + printf("%ld, %ld\n", (long) c1, (long) c2); mysql_stmt_close(stmt); } @@ -10306,7 +10563,8 @@ static void test_bug5399() check_execute(*stmt, rc); mysql_stmt_bind_result(*stmt, bind); } - printf("%d statements prepared.\n", NUM_OF_USED_STMT); + if (!opt_silent) + printf("%d statements prepared.\n", NUM_OF_USED_STMT); for (stmt= stmt_list; stmt != stmt_list + NUM_OF_USED_STMT; ++stmt) { @@ -10478,15 +10736,17 @@ static void test_bug5194() rc= mysql_stmt_prepare(stmt, query, query_ptr - query); if (rc && nrows * COLUMN_COUNT > uint16_max) { - printf("Failed to prepare a statement with %d placeholders " - "(as expected).\n", nrows * COLUMN_COUNT); + if (!opt_silent) + printf("Failed to prepare a statement with %d placeholders " + "(as expected).\n", nrows * COLUMN_COUNT); break; } else check_execute(stmt, rc); - printf("Insert: query length= %d, row count= %d, param count= %lu\n", - strlen(query), nrows, mysql_stmt_param_count(stmt)); + if (!opt_silent) + printf("Insert: query length= %d, row count= %d, param count= %lu\n", + strlen(query), nrows, mysql_stmt_param_count(stmt)); /* bind the parameter array and execute the query */ rc= mysql_stmt_bind_param(stmt, bind); @@ -10522,7 +10782,10 @@ static void test_bug5315() rc= mysql_stmt_execute(stmt); DIE_UNLESS(rc != 0); if (rc) - printf("Got error (as expected):\n%s", mysql_stmt_error(stmt)); + { + if (!opt_silent) + printf("Got error (as expected):\n%s", mysql_stmt_error(stmt)); + } /* check that connection is OK */ mysql_stmt_close(stmt); stmt= mysql_stmt_init(mysql); @@ -10570,8 +10833,11 @@ static void test_bug6049() rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == 0); - printf("Result from query: %s\n", row[0]); - printf("Result from prepared statement: %s\n", (char*) buffer); + if (!opt_silent) + { + printf("Result from query: %s\n", row[0]); + printf("Result from prepared statement: %s\n", (char*) buffer); + } DIE_UNLESS(strcmp(row[0], (char*) buffer) == 0); @@ -10616,8 +10882,11 @@ static void test_bug6058() rc= mysql_stmt_fetch(stmt); DIE_UNLESS(rc == 0); - printf("Result from query: %s\n", row[0]); - printf("Result from prepared statement: %s\n", buffer); + if (!opt_silent) + { + printf("Result from query: %s\n", row[0]); + printf("Result from prepared statement: %s\n", buffer); + } DIE_UNLESS(strcmp(row[0], buffer) == 0); @@ -10656,17 +10925,17 @@ static void test_bug6046() stmt_text= "DROP TABLE IF EXISTS t1"; rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); myquery(rc); - stmt_text= "CREATE TABLE a1 (a int, b int)"; + stmt_text= "CREATE TABLE t1 (a int, b int)"; rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); myquery(rc); - stmt_text= "INSERT INTO a1 VALUES (1,1),(2,2),(3,1),(4,2)"; + stmt_text= "INSERT INTO t1 VALUES (1,1),(2,2),(3,1),(4,2)"; rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); myquery(rc); stmt= mysql_stmt_init(mysql); - stmt_text= "SELECT a1.a FROM a1 NATURAL JOIN a1 as X1 " - "WHERE a1.b > ? ORDER BY a1.a"; + stmt_text= "SELECT t1.a FROM t1 NATURAL JOIN t1 as X1 " + "WHERE t1.b > ? ORDER BY t1.a"; rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text)); check_execute(stmt, rc); @@ -10772,22 +11041,25 @@ static void test_bug6096() /* Print out and check the metadata */ - printf(" ---------------------------------------------------------------\n"); - printf(" | Metadata \n"); - printf(" ---------------------------------------------------------------\n"); - printf(" | Query | Prepared statement \n"); - printf(" ---------------------------------------------------------------\n"); - printf(" field name | length | max_length | length | max_length \n"); - printf(" ---------------------------------------------------------------\n"); - - for (i= 0; i < query_field_count; ++i) + if (!opt_silent) { - MYSQL_FIELD *f1= &query_field_list[i], *f2= &stmt_field_list[i]; - printf(" %-11s | %9lu | %10lu | %9lu | %10lu \n", - f1->name, f1->length, f1->max_length, f2->length, f2->max_length); - DIE_UNLESS(f1->length == f2->length); + printf(" ------------------------------------------------------------\n"); + printf(" | Metadata \n"); + printf(" ------------------------------------------------------------\n"); + printf(" | Query | Prepared statement \n"); + printf(" ------------------------------------------------------------\n"); + printf(" field name | length | max_length | length | max_length\n"); + printf(" ------------------------------------------------------------\n"); + + for (i= 0; i < query_field_count; ++i) + { + MYSQL_FIELD *f1= &query_field_list[i], *f2= &stmt_field_list[i]; + printf(" %-11s | %9lu | %10lu | %9lu | %10lu \n", + f1->name, f1->length, f1->max_length, f2->length, f2->max_length); + DIE_UNLESS(f1->length == f2->length); + } + printf(" ---------------------------------------------------------------\n"); } - printf(" ---------------------------------------------------------------\n"); /* Bind and fetch the data */ @@ -10842,6 +11114,8 @@ static struct my_option client_test_long_options[] = #endif {"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}, + {"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, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, {"testcase", 'c', "May disable some code when runs as mysql-test-run testcase.", @@ -10851,36 +11125,25 @@ static struct my_option client_test_long_options[] = { 0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0} }; -static void client_test_print_version(void) -{ - fprintf(stdout, "%s Distrib %s, for %s (%s)\n\n", - my_progname, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE); -} - static void usage(void) { - /* - * show the usage string when the user asks for this - */ + /* show the usage string when the user asks for this */ putc('\n', stdout); - puts("***********************************************************************\n"); - puts(" Test for client-server protocol 4.1"); - puts(" By Monty & Venu \n"); - puts("This software comes with ABSOLUTELY NO WARRANTY. This is free software, "); - puts("and you are welcome to modify and redistribute it under the GPL license\n"); - puts(" Copyright (C) 1995-2003 MySQL AB "); - puts("-----------------------------------------------------------------------\n"); - client_test_print_version(); - fprintf(stdout, "Usage: %s [OPTIONS]\n\n", my_progname); - + printf("%s Ver %s Distrib %s, for %s (%s)\n", + my_progname, VER, MYSQL_SERVER_VERSION, SYSTEM_TYPE, MACHINE_TYPE); + puts("By Monty, Venu, Kent and others\n"); + printf("\ +Copyright (C) 2002-2004 MySQL AB\n\ +This software comes with ABSOLUTELY NO WARRANTY. This is free software,\n\ +and you are welcome to modify and redistribute it under the GPL license\n"); + printf("Usage: %s [OPTIONS]\n", my_progname); my_print_help(client_test_long_options); print_defaults("my", client_test_load_default_groups); my_print_variables(client_test_long_options); - - puts("***********************************************************************\n"); } + static my_bool get_one_option(int optid, const struct my_option *opt __attribute__((unused)), char *argument) @@ -10905,6 +11168,12 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), else tty_password= 1; break; + case 's': + if (argument == disabled_my_option) + opt_silent= 0; + else + opt_silent++; + break; case '?': case 'I': /* Info */ usage(); @@ -10933,14 +11202,17 @@ static void get_options(int argc, char **argv) static void print_test_output() { - fprintf(stdout, "\n\n"); - fprintf(stdout, "All '%d' tests were successful (in '%d' iterations)", - test_count-1, opt_count); - fprintf(stdout, "\n Total execution time: %g SECS", total_time); - if (opt_count > 1) - fprintf(stdout, " (Avg: %g SECS)", total_time/opt_count); - - fprintf(stdout, "\n\n!!! SUCCESS !!!\n"); + if (opt_silent < 3) + { + fprintf(stdout, "\n\n"); + fprintf(stdout, "All '%d' tests were successful (in '%d' iterations)", + test_count-1, opt_count); + fprintf(stdout, "\n Total execution time: %g SECS", total_time); + if (opt_count > 1) + fprintf(stdout, " (Avg: %g SECS)", total_time/opt_count); + + fprintf(stdout, "\n\n!!! SUCCESS !!!\n"); + } } |