From 8b6a8cc5615f4df62e70ff54e8a90498a8a393a5 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 7 Sep 2005 16:39:16 +0200 Subject: [PATCH 01/11] BUG#12984 mysqltest.test: different output from "exec NonExistsinfComamdn" - Improved solution mysql-test/r/mysqltest.result: Update test results mysql-test/t/mysqltest.test: Fix test for failing "exec" and "system", by using the false command --- mysql-test/r/mysqltest.result | 2 ++ mysql-test/t/mysqltest.test | 10 ++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index ae44233aab6..2277fe1b5ed 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -179,6 +179,7 @@ source database echo message echo message mysqltest: At line 1: Empty variable +mysqltest: At line 1: command "false" failed mysqltest: At line 1: Missing argument in exec MySQL "MySQL" @@ -300,6 +301,7 @@ mysqltest: At line 1: First argument to dec must be a variable (start with $) mysqltest: At line 1: End of line junk detected: "1000" mysqltest: At line 1: Missing arguments to system, nothing to do! mysqltest: At line 1: Missing arguments to system, nothing to do! +mysqltest: At line 1: system command 'false' failed test test2 test3 diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index 4d3bcc037d1..fc9f621f7cd 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -426,9 +426,8 @@ echo ; # ---------------------------------------------------------------------------- # Illegal use of exec -# Disabled, some shells prints the failed command regardless of pipes -#--error 1 -#--exec echo "--exec ';' 2> /dev/null" | $MYSQL_TEST 2>&1 +--error 1 +--exec echo "--exec false" | $MYSQL_TEST 2>&1 --error 1 --exec echo "--exec " | $MYSQL_TEST 2>&1 @@ -675,9 +674,8 @@ system echo "hej" > /dev/null; --exec echo "system;" | $MYSQL_TEST 2>&1 --error 1 --exec echo "system $NONEXISTSINFVAREABLI;" | $MYSQL_TEST 2>&1 -# Disabled, some shells prints the failed command regardless of pipes -#--error 1 -#--exec echo "system NonExistsinfComamdn 2> /dev/null;" | $MYSQL_TEST 2>&1 +--error 1 +--exec echo "system false;" | $MYSQL_TEST 2>&1 --disable_abort_on_error system NonExistsinfComamdn; From 56f457b67f01a87c2828920040767d302f7b79cb Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 19 Sep 2005 12:24:59 +0200 Subject: [PATCH 02/11] Clean up printout of line numbers client/mysqltest.c: Only print line no if start_lineno > 0 Remove lineno in calls to verbose_msg and die, this is handled by the function. --- client/mysqltest.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 3e2cde92aa9..19c74629a55 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -610,7 +610,9 @@ static void verbose_msg(const char *fmt, ...) va_start(args, fmt); - fprintf(stderr, "mysqltest: At line %u: ", start_lineno); + fprintf(stderr, "mysqltest: "); + if (start_lineno > 0) + fprintf(stderr, "At line %u: ", start_lineno); vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); va_end(args); @@ -1345,9 +1347,7 @@ int do_sync_with_master2(long offset) int rpl_parse; if (!master_pos.file[0]) - { - die("Line %u: Calling 'sync_with_master' without calling 'save_master_pos'", start_lineno); - } + die("Calling 'sync_with_master' without calling 'save_master_pos'"); rpl_parse= mysql_rpl_parse_enabled(mysql); mysql_disable_rpl_parse(mysql); @@ -1357,14 +1357,13 @@ int do_sync_with_master2(long offset) wait_for_position: if (mysql_query(mysql, query_buf)) - die("line %u: failed in %s: %d: %s", start_lineno, query_buf, - mysql_errno(mysql), mysql_error(mysql)); + die("failed in %s: %d: %s", query_buf, mysql_errno(mysql), + mysql_error(mysql)); if (!(last_result= res= mysql_store_result(mysql))) - die("line %u: mysql_store_result() returned NULL for '%s'", start_lineno, - query_buf); + die("mysql_store_result() returned NULL for '%s'", query_buf); if (!(row= mysql_fetch_row(res))) - die("line %u: empty result in %s", start_lineno, query_buf); + die("empty result in %s", query_buf); if (!row[0]) { /* @@ -1372,10 +1371,7 @@ wait_for_position: SLAVE has been issued ? */ if (tries++ == 3) - { - die("line %u: could not sync with master ('%s' returned NULL)", - start_lineno, query_buf); - } + die("could not sync with master ('%s' returned NULL)", query_buf); sleep(1); /* So at most we will wait 3 seconds and make 4 tries */ mysql_free_result(res); goto wait_for_position; @@ -1421,10 +1417,9 @@ int do_save_master_pos() mysql_errno(mysql), mysql_error(mysql)); if (!(last_result =res = mysql_store_result(mysql))) - die("line %u: mysql_store_result() retuned NULL for '%s'", start_lineno, - query); + die("mysql_store_result() retuned NULL for '%s'", query); if (!(row = mysql_fetch_row(res))) - die("line %u: empty result in show master status", start_lineno); + die("empty result in show master status"); strnmov(master_pos.file, row[0], sizeof(master_pos.file)-1); master_pos.pos = strtoul(row[1], (char**) 0, 10); mysql_free_result(res); last_result=0; From 6bec4bc605961b7c8066a8d8e594dc60aabd5e75 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Sep 2005 12:13:17 +0200 Subject: [PATCH 03/11] Improved output client/mysqltest.c: Don't print "At line: 0" --- client/mysqltest.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 19c74629a55..1e04b41f35c 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -577,7 +577,8 @@ static void die(const char *fmt, ...) if (cur_file && cur_file != file_stack) fprintf(stderr, "In included file \"%s\": ", cur_file->file_name); - fprintf(stderr, "At line %u: ", start_lineno); + if (start_lineno != 0) + fprintf(stderr, "At line %u: ", start_lineno); vfprintf(stderr, fmt, args); fprintf(stderr, "\n"); fflush(stderr); From 0aee9b2c19b52be26e9a0dc67ae178ccfa70db35 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 20 Sep 2005 14:11:58 +0200 Subject: [PATCH 04/11] BUG#12959 mysqltest crashes if testcase passed with -x option - Enable testcases after help from Serg client/mysqltest.c: Dump output to stdout if no result file is specified Don't print verbose_msg when command fails whith expected error mysql-test/mysql-test-run.pl: Don't add all args to the MYSQL_TEST environment variable. mysql-test/r/mysqltest.result: Add test for mysqltest -x mysql-test/t/mysqltest.test: Add test for mysqltest -x --- client/mysqltest.c | 24 ++++++++++++++++-------- mysql-test/mysql-test-run.pl | 19 ++++++++++++------- mysql-test/r/mysqltest.result | 4 ++++ mysql-test/t/mysqltest.test | 10 +++++----- 4 files changed, 37 insertions(+), 20 deletions(-) diff --git a/client/mysqltest.c b/client/mysqltest.c index 1e04b41f35c..6963ff2f99e 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -1062,8 +1062,8 @@ static void do_exec(struct st_query *query) (query->expected_errno[i].code.errnum == status)) { ok= 1; - verbose_msg("command \"%s\" failed with expected error: %d", - cmd, status); + DBUG_PRINT("info", ("command \"%s\" failed with expected error: %d", + cmd, status)); } } if (!ok) @@ -2557,7 +2557,7 @@ get_one_option(int optid, const struct my_option *opt __attribute__((unused)), fn_format(buff, argument, "", "", 4); DBUG_ASSERT(cur_file == file_stack && cur_file->file == 0); if (!(cur_file->file= - my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(MY_WME)))) + my_fopen(buff, O_RDONLY | FILE_BINARY, MYF(0)))) die("Could not open %s: errno = %d", buff, errno); cur_file->file_name= my_strdup(buff, MYF(MY_FAE)); break; @@ -2663,7 +2663,7 @@ void str_to_file(const char *fname, char *str, int size) fname=buff; } fn_format(buff,fname,"","",4); - + if ((fd = my_open(buff, O_WRONLY | O_CREAT | O_TRUNC, MYF(MY_WME | MY_FFNF))) < 0) die("Could not open %s: errno = %d", buff, errno); @@ -4043,12 +4043,20 @@ int main(int argc, char **argv) parser.current_line += current_line_inc; } - if (result_file && ds_res.length && !error) + if (ds_res.length && !error) { - if (!record) - error |= check_result(&ds_res, result_file, q->require_file); + if (result_file) + { + if (!record) + error |= check_result(&ds_res, result_file, q->require_file); + else + str_to_file(result_file, ds_res.str, ds_res.length); + } else - str_to_file(result_file, ds_res.str, ds_res.length); + { + // Print the result to stdout + printf("%s", ds_res.str); + } } dynstr_free(&ds_res); diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl index 013b8d49967..eed80b1e339 100755 --- a/mysql-test/mysql-test-run.pl +++ b/mysql-test/mysql-test-run.pl @@ -2155,11 +2155,6 @@ sub run_mysqltest ($) { mtr_add_arg($args, "--big-test"); } - if ( $opt_record ) - { - mtr_add_arg($args, "--record"); - } - if ( $opt_compress ) { mtr_add_arg($args, "--compress"); @@ -2185,8 +2180,6 @@ sub run_mysqltest ($) { $glob_mysql_test_dir); } - mtr_add_arg($args, "-R"); - mtr_add_arg($args, $tinfo->{'result_file'}); # ---------------------------------------------------------------------- # If embedded server, we create server args to give mysqltest to pass on @@ -2202,6 +2195,18 @@ sub run_mysqltest ($) { # ---------------------------------------------------------------------- $ENV{'MYSQL_TEST'}= "$exe_mysqltest " . join(" ", @$args); + # ---------------------------------------------------------------------- + # Add arguments that should not go into the MYSQL_TEST env var + # ---------------------------------------------------------------------- + + mtr_add_arg($args, "-R"); + mtr_add_arg($args, $tinfo->{'result_file'}); + + if ( $opt_record ) + { + mtr_add_arg($args, "--record"); + } + return mtr_run_test($exe,$args,$tinfo->{'path'},"",$path_timefile,""); } diff --git a/mysql-test/r/mysqltest.result b/mysql-test/r/mysqltest.result index 2277fe1b5ed..0e3d3812781 100644 --- a/mysql-test/r/mysqltest.result +++ b/mysql-test/r/mysqltest.result @@ -345,6 +345,10 @@ mysqltest: At line 1: Wrong column number to replace_column in 'replace_column 1 mysqltest: At line 1: Invalid integer argument "10!" mysqltest: At line 1: End of line junk detected: "!" mysqltest: At line 1: Invalid integer argument "a" +Output from mysqltest-x.inc +Output from mysqltest-x.inc +Output from mysqltest-x.inc +mysqltest: Could not open ./non_existing_file.inc: errno = 2 failing_statement; ERROR 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'failing_statement' at line 1 failing_statement; diff --git a/mysql-test/t/mysqltest.test b/mysql-test/t/mysqltest.test index fc9f621f7cd..7ed204fc6d3 100644 --- a/mysql-test/t/mysqltest.test +++ b/mysql-test/t/mysqltest.test @@ -810,11 +810,11 @@ select "a" as col1, "c" as col2; # ---------------------------------------------------------------------------- # -x , use the file specified after -x as the test file -#--exec $MYSQL_TEST < $MYSQL_TEST_DIR/include/mysqltest-x.inc 2>&1 -#--exec $MYSQL_TEST -x $MYSQL_TEST_DIR/include/mysqltest-x.inc 2>&1 -#--exec $MYSQL_TEST --result_file=$MYSQL_TEST_DIR/include/mysqltest-x.inc 2>&1 -#--error 1 -#--exec $MYSQL_TEST -x non_existing_file.inc 2>&1 +--exec $MYSQL_TEST < $MYSQL_TEST_DIR/include/mysqltest-x.inc +--exec $MYSQL_TEST -x $MYSQL_TEST_DIR/include/mysqltest-x.inc +--exec $MYSQL_TEST --test_file=$MYSQL_TEST_DIR/include/mysqltest-x.inc +--error 1 +--exec $MYSQL_TEST -x non_existing_file.inc 2>&1 # ---------------------------------------------------------------------------- From 1d16fa5d866c3875bb8fab818115b15c3cda93f5 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 21 Sep 2005 17:28:25 +0300 Subject: [PATCH 05/11] Ensure that hex strings are used as integers in cast(... signed/unsigned) This fixes the new report for bug #7036 mysql-test/t/cast.test: Added test for cast(hex-value to signed/unsigned) sql/item.h: Ensure that hex strings are used as integers in cast(... signed/unsigned) --- mysql-test/t/cast.test | 4 ++++ sql/item.h | 1 + 2 files changed, 5 insertions(+) diff --git a/mysql-test/t/cast.test b/mysql-test/t/cast.test index 394971f9648..bb01e8cea83 100644 --- a/mysql-test/t/cast.test +++ b/mysql-test/t/cast.test @@ -20,6 +20,10 @@ select CONVERT(DATE "2004-01-22 21:45:33",CHAR); select CONVERT(DATE "2004-01-22 21:45:33",CHAR(4)); select CONVERT(DATE "2004-01-22 21:45:33",BINARY(4)); select CAST(DATE "2004-01-22 21:45:33" AS BINARY(4)); +select CAST(0xb3 as signed); +select CAST(0x8fffffffffffffff as signed); +select CAST(0xffffffffffffffff as unsigned); +select CAST(0xfffffffffffffffe as signed); # out-of-range cases select cast('18446744073709551616' as unsigned); diff --git a/sql/item.h b/sql/item.h index e683cda5786..b1aed733101 100644 --- a/sql/item.h +++ b/sql/item.h @@ -842,6 +842,7 @@ public: String *val_str(String*) { DBUG_ASSERT(fixed == 1); return &str_value; } int save_in_field(Field *field, bool no_conversions); enum Item_result result_type () const { return STRING_RESULT; } + enum Item_result cast_to_int_type() const { return INT_RESULT; } enum_field_types field_type() const { return MYSQL_TYPE_STRING; } // to prevent drop fixed flag (no need parent cleanup call) void cleanup() {} From ea5d6776b0ddc753c543da378c461f1cd69b6e95 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 23 Sep 2005 09:47:41 +0200 Subject: [PATCH 06/11] BUG#7037 MySQL Bugs: #7037: Test "mysql_protocols" fails on Solaris 8 + 9 /x86 mysys/my_init.c: Changed implementation slightly to use a local variable for keeping track of wheter we should print to the info_file even if the flag is not set in infoflag Explicitly turn off print_info if there is no DBUG_FILE --- mysys/my_init.c | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/mysys/my_init.c b/mysys/my_init.c index bee485c3bed..c50c00c1e5c 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -127,11 +127,18 @@ my_bool my_init(void) void my_end(int infoflag) { - FILE *info_file; - if (!(info_file=DBUG_FILE)) - info_file=stderr; - DBUG_PRINT("info",("Shutting down")); - if (infoflag & MY_CHECK_ERROR || info_file != stderr) + DBUG_ENTER("my_end"); + FILE *info_file= DBUG_FILE; + bool print_info= (info_file != stderr); + if (!info_file) + { + info_file= stderr; + print_info= 0; + } + + DBUG_PRINT("info",("Shutting down: print_info: %d", print_info)); + if ((infoflag & MY_CHECK_ERROR) || print_info) + { /* Test if some file is left open */ if (my_file_opened | my_stream_opened) { @@ -141,7 +148,8 @@ void my_end(int infoflag) } } my_once_free(); - if (infoflag & MY_GIVE_INFO || info_file != stderr) + + if ((infoflag & MY_GIVE_INFO) || print_info) { #ifdef HAVE_GETRUSAGE struct rusage rus; From b9ace625400f3b5c13c23236d13f93a2f886b326 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 23 Sep 2005 14:07:31 +0200 Subject: [PATCH 07/11] Bug #7037 Test "mysql_protocols" fails on Solaris 8 + 9 /x86 mysys/my_init.c: Updated after review --- mysys/my_init.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/mysys/my_init.c b/mysys/my_init.c index c50c00c1e5c..3e5130ec670 100644 --- a/mysys/my_init.c +++ b/mysys/my_init.c @@ -127,9 +127,14 @@ my_bool my_init(void) void my_end(int infoflag) { - DBUG_ENTER("my_end"); + /* + this code is suboptimal to workaround a bug in + Sun CC: Sun C++ 5.6 2004/06/02 for x86, and should not be + optimized until this compiler is not in use anymore + */ FILE *info_file= DBUG_FILE; - bool print_info= (info_file != stderr); + my_bool print_info= (info_file != stderr); + DBUG_ENTER("my_end"); if (!info_file) { info_file= stderr; From 3614cff71cc79b197863a968d385cb2cce1680fd Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 24 Sep 2005 02:42:38 +0200 Subject: [PATCH 08/11] Makefile.am: Revert to shell test script for test targets mysqltest.c: Windows pclose() returns error code in low byte mysql_config.sh: Remove -Xa -xstrconst from --cflags for Sun C++ scripts/mysql_config.sh: Remove -Xa -xstrconst from --cflags for Sun C++ client/mysqltest.c: Windows pclose() returns error code in low byte Makefile.am: Revert to shell test script for test targets --- Makefile.am | 15 +++++++++++++-- client/mysqltest.c | 6 +++++- scripts/mysql_config.sh | 13 ++++++++----- 3 files changed, 26 insertions(+), 8 deletions(-) diff --git a/Makefile.am b/Makefile.am index ae0d56ba9fd..9025251ff2a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -106,12 +106,12 @@ MYSQL_TEST_NDB_PORT = 9350 test: cd mysql-test ; \ - ./mysql-test-run.pl \ + ./mysql-test-run \ --manager-port=$(MYSQL_TEST_MANAGER_PORT) \ --master_port=$(MYSQL_TEST_MASTER_PORT) \ --slave_port=$(MYSQL_TEST_SLAVE_PORT) \ --ndbcluster_port=$(MYSQL_TEST_NDB_PORT) && \ - ./mysql-test-run.pl --ps-protocol \ + ./mysql-test-run --ps-protocol \ --manager-port=$(MYSQL_TEST_MANAGER_PORT) \ --master_port=$(MYSQL_TEST_MASTER_PORT) \ --slave_port=$(MYSQL_TEST_SLAVE_PORT) \ @@ -121,3 +121,14 @@ test-force: cd mysql-test; \ ./mysql-test-run --force ;\ ./mysql-test-run --ps-protocol --force + +# We are testing a new Perl version of the test script +test-pl: + cd mysql-test; \ + ./mysql-test-run.pl && \ + ./mysql-test-run.pl --ps-protocol + +test-force-pl: + cd mysql-test; \ + ./mysql-test-run.pl --force ; \ + ./mysql-test-run.pl --ps-protocol --force diff --git a/client/mysqltest.c b/client/mysqltest.c index 1b8a0658cc7..a4fec7eb28c 100644 --- a/client/mysqltest.c +++ b/client/mysqltest.c @@ -64,7 +64,11 @@ #include #endif #ifndef WEXITSTATUS -# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) +# ifdef __WIN__ +# define WEXITSTATUS(stat_val) (stat_val) +# else +# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) +# endif #endif #define MAX_QUERY 131072 #define MAX_VAR_NAME 256 diff --git a/scripts/mysql_config.sh b/scripts/mysql_config.sh index 16e50c044ca..15b45391ef8 100644 --- a/scripts/mysql_config.sh +++ b/scripts/mysql_config.sh @@ -105,9 +105,12 @@ embedded_libs="$ldflags -L$pkglibdir -lmysqld @LIBS@ @WRAPLIBS@ @innodb_system_l embedded_libs=`echo "$embedded_libs" | sed -e 's; \+; ;g' | sed -e 's;^ *;;' | sed -e 's; *\$;;'` # Remove some options that a client doesn't have to care about +# FIXME until we have a --cxxflags, we need to remove -Xa +# and -xstrconst to make --cflags usable for Sun Forte C++ for remove in DDBUG_OFF DSAFEMALLOC USAFEMALLOC DSAFE_MUTEX \ DPEDANTIC_SAFEMALLOC DUNIV_MUST_NOT_INLINE DFORCE_INIT_OF_VARS \ - DEXTRA_DEBUG DHAVE_purify 'O[0-9]' 'W[-A-Za-z]*' + DEXTRA_DEBUG DHAVE_purify 'O[0-9]' 'W[-A-Za-z]*' \ + Xa xstrconst do # The first option we might strip will always have a space before it because # we set -I$pkgincludedir as the first option @@ -120,13 +123,13 @@ usage () { Usage: $0 [OPTIONS] Options: --cflags [$cflags] - --include [$include] + --include [$include] --libs [$libs] --libs_r [$libs_r] --socket [$socket] --port [$port] --version [$version] - --libmysqld-libs [$embedded_libs] + --libmysqld-libs [$embedded_libs] EOF exit 1 } @@ -136,13 +139,13 @@ if test $# -le 0; then usage; fi while test $# -gt 0; do case $1 in --cflags) echo "$cflags" ;; - --include) echo "$include" ;; + --include) echo "$include" ;; --libs) echo "$libs" ;; --libs_r) echo "$libs_r" ;; --socket) echo "$socket" ;; --port) echo "$port" ;; --version) echo "$version" ;; - --embedded-libs | --embedded | --libmysqld-libs) echo "$embedded_libs" ;; + --embedded-libs | --embedded | --libmysqld-libs) echo "$embedded_libs" ;; *) usage ;; esac From 466b46a66af37310b7d050448ab08913cb09671e Mon Sep 17 00:00:00 2001 From: unknown Date: Sun, 25 Sep 2005 21:22:23 +0300 Subject: [PATCH 09/11] Fixed error found during review of new pushed code client/mysql.cc: Don't use c_ptr() for cgets() and ensure buffer is not overwritten mysql-test/r/cast.result: More test for CAST(0x.... as signed) sql/opt_sum.cc: Fix bugs found during review - Changed code to be able to remove one if - Ensure that count == 0 only if is_exact_count == TRUE sql/sql_delete.cc: Ensure 'allow_sum_func' is reset before call to setup_conds sql/sql_lex.cc: allow_sum_func doesn't have to be reset for each query (It's to be reset in setup_fields() or before call to setup_conds() sql/sql_load.cc: Move set of auto_increment_field_not_null so that it's not set if field value is NULL sql/sql_prepare.cc: allow_sum_func doesn't have to be reset for each query (It's to be reset in setup_fields() or before call to setup_conds() sql/sql_update.cc: Ensure 'allow_sum_func' is reset before call to setup_conds --- client/mysql.cc | 4 ++-- mysql-test/r/cast.result | 12 ++++++++++++ sql/opt_sum.cc | 14 +++++++------- sql/sql_delete.cc | 5 +++-- sql/sql_lex.cc | 1 - sql/sql_load.cc | 10 +++++----- sql/sql_prepare.cc | 1 - sql/sql_update.cc | 1 + 8 files changed, 30 insertions(+), 18 deletions(-) diff --git a/client/mysql.cc b/client/mysql.cc index be1541faaf5..e73d627d67a 100644 --- a/client/mysql.cc +++ b/client/mysql.cc @@ -993,13 +993,13 @@ static int read_lines(bool execute_commands) unsigned long clen; do { - line= my_cgets(tmpbuf.c_ptr(), tmpbuf.alloced_length(), &clen); + line= my_cgets(tmpbuf.ptr(), tmpbuf.alloced_length()-1, &clen); buffer.append(line, clen); /* if we got buffer fully filled than there is a chance that something else is still in console input buffer */ - } while (tmpbuf.alloced_length() <= clen + 1); + } while (tmpbuf.alloced_length() <= clen); line= buffer.c_ptr(); #else /* OS2 */ buffer.length(0); diff --git a/mysql-test/r/cast.result b/mysql-test/r/cast.result index 7cd0934f7a3..1b681941a1d 100644 --- a/mysql-test/r/cast.result +++ b/mysql-test/r/cast.result @@ -54,6 +54,18 @@ CONVERT(DATE "2004-01-22 21:45:33",BINARY(4)) select CAST(DATE "2004-01-22 21:45:33" AS BINARY(4)); CAST(DATE "2004-01-22 21:45:33" AS BINARY(4)) 2004 +select CAST(0xb3 as signed); +CAST(0xb3 as signed) +179 +select CAST(0x8fffffffffffffff as signed); +CAST(0x8fffffffffffffff as signed) +-8070450532247928833 +select CAST(0xffffffffffffffff as unsigned); +CAST(0xffffffffffffffff as unsigned) +18446744073709551615 +select CAST(0xfffffffffffffffe as signed); +CAST(0xfffffffffffffffe as signed) +-2 select cast('18446744073709551616' as unsigned); cast('18446744073709551616' as unsigned) 18446744073709551615 diff --git a/sql/opt_sum.cc b/sql/opt_sum.cc index 3ac72e5a6f9..cfb5b3695a3 100644 --- a/sql/opt_sum.cc +++ b/sql/opt_sum.cc @@ -108,7 +108,7 @@ int opt_sum_query(TABLE_LIST *tables, List &all_fields,COND *conds) WHERE t2.field IS NULL; */ if (tl->table->map & where_tables) - const_result= 0; + return 0; } else used_tables|= tl->table->map; @@ -119,7 +119,10 @@ int opt_sum_query(TABLE_LIST *tables, List &all_fields,COND *conds) may be used as the real count. */ if (tl->table->file->table_flags() & HA_NOT_EXACT_COUNT) + { is_exact_count= FALSE; + count= 1; // ensure count != 0 + } else { tl->table->file->info(HA_STATUS_VARIABLE | HA_STATUS_NO_LOCK); @@ -127,9 +130,6 @@ int opt_sum_query(TABLE_LIST *tables, List &all_fields,COND *conds) } } - if (!const_result) - return 0; - /* Iterate through all items in the SELECT clause and replace COUNT(), MIN() and MAX() with constants (if possible). @@ -150,8 +150,8 @@ int opt_sum_query(TABLE_LIST *tables, List &all_fields,COND *conds) if (!conds && !((Item_sum_count*) item)->args[0]->maybe_null && !outer_tables && is_exact_count) { - ((Item_sum_count*) item)->make_const(count); - recalc_const_item= 1; + ((Item_sum_count*) item)->make_const(count); + recalc_const_item= 1; } else const_result= 0; @@ -234,7 +234,7 @@ int opt_sum_query(TABLE_LIST *tables, List &all_fields,COND *conds) } if (!count) { - /* If count != 1, then we know that is_exact_count == TRUE. */ + /* If count == 0, then we know that is_exact_count == TRUE. */ ((Item_sum_min*) item_sum)->clear(); /* Set to NULL. */ } else diff --git a/sql/sql_delete.cc b/sql/sql_delete.cc index 7248adf6993..1dd52a2ba74 100644 --- a/sql/sql_delete.cc +++ b/sql/sql_delete.cc @@ -27,8 +27,8 @@ #include "ha_innodb.h" #include "sql_select.h" -int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, SQL_LIST *order, - ha_rows limit, ulong options) +int mysql_delete(THD *thd, TABLE_LIST *table_list, COND *conds, + SQL_LIST *order, ha_rows limit, ulong options) { int error; TABLE *table; @@ -266,6 +266,7 @@ int mysql_prepare_delete(THD *thd, TABLE_LIST *table_list, Item **conds) select_lex.table_list.first); DBUG_ENTER("mysql_prepare_delete"); + thd->allow_sum_func= 0; if (setup_conds(thd, delete_table_list, conds) || setup_ftfuncs(&thd->lex->select_lex)) DBUG_RETURN(-1); diff --git a/sql/sql_lex.cc b/sql/sql_lex.cc index 07017451bad..8636b6542fc 100644 --- a/sql/sql_lex.cc +++ b/sql/sql_lex.cc @@ -160,7 +160,6 @@ void lex_start(THD *thd, uchar *buf,uint length) lex->duplicates= DUP_ERROR; lex->ignore= 0; lex->proc_list.first= 0; - thd->allow_sum_func= 0; } void lex_end(LEX *lex) diff --git a/sql/sql_load.cc b/sql/sql_load.cc index f590038f899..4d09da70ef7 100644 --- a/sql/sql_load.cc +++ b/sql/sql_load.cc @@ -429,8 +429,6 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List &fields, while ((sql_field= (Item_field*) it++)) { Field *field= sql_field->field; - if (field == table->next_number_field) - table->auto_increment_field_not_null= TRUE; if (pos == read_info.row_end) { thd->cuted_fields++; /* Not enough fields */ @@ -443,11 +441,13 @@ read_fixed_length(THD *thd,COPY_INFO &info,TABLE *table,List &fields, { uint length; byte save_chr; + if (field == table->next_number_field) + table->auto_increment_field_not_null= TRUE; if ((length=(uint) (read_info.row_end-pos)) > field->field_length) length=field->field_length; save_chr=pos[length]; pos[length]='\0'; // Safeguard aganst malloc - field->store((char*) pos,length,read_info.read_charset); + field->store((char*) pos,length,read_info.read_charset); pos[length]=save_chr; if ((pos+=length) > read_info.row_end) pos= read_info.row_end; /* Fills rest with space */ @@ -522,8 +522,6 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table, length=(uint) (read_info.row_end-pos); Field *field=sql_field->field; - if (field == table->next_number_field) - table->auto_increment_field_not_null= TRUE; if (!read_info.enclosed && (enclosed_length && length == 4 && !memcmp(pos,"NULL",4)) || (length == 1 && read_info.found_null)) @@ -540,6 +538,8 @@ read_sep_field(THD *thd,COPY_INFO &info,TABLE *table, } continue; } + if (field == table->next_number_field) + table->auto_increment_field_not_null= TRUE; field->set_notnull(); read_info.row_end[0]=0; // Safe to change end marker field->store((char*) read_info.row_start,length,read_info.read_charset); diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index c8f417c9b9b..8a50d0bd50e 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1738,7 +1738,6 @@ static void reset_stmt_for_execute(Prepared_statement *stmt) lex->current_select= &lex->select_lex; if (lex->result) lex->result->cleanup(); - thd->allow_sum_func= 0; } diff --git a/sql/sql_update.cc b/sql/sql_update.cc index 6c12381b4bd..2857bce09ed 100644 --- a/sql/sql_update.cc +++ b/sql/sql_update.cc @@ -426,6 +426,7 @@ int mysql_prepare_update(THD *thd, TABLE_LIST *table_list, bzero((char*) &tables,sizeof(tables)); // For ORDER BY tables.table= table; tables.alias= table_list->alias; + thd->allow_sum_func= 0; if (setup_tables(update_table_list) || setup_conds(thd, update_table_list, conds) || From 31b01d13efca6a766470319cfe973b24d8f7ffd8 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Sep 2005 10:26:38 +0200 Subject: [PATCH 10/11] added make target for printSchemaFile --- ndb/src/kernel/blocks/dbdict/Makefile.am | 12 ++++++++++-- ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp | 11 +---------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/ndb/src/kernel/blocks/dbdict/Makefile.am b/ndb/src/kernel/blocks/dbdict/Makefile.am index 9a0d68f8148..3c1cf6735d9 100644 --- a/ndb/src/kernel/blocks/dbdict/Makefile.am +++ b/ndb/src/kernel/blocks/dbdict/Makefile.am @@ -1,12 +1,20 @@ -#SUBDIRS = printSchemafile - noinst_LIBRARIES = libdbdict.a +EXTRA_PROGRAMS = printSchemaFile libdbdict_a_SOURCES = Dbdict.cpp +printSchemaFile_SOURCES = printSchemaFile.cpp + include $(top_srcdir)/ndb/config/common.mk.am include $(top_srcdir)/ndb/config/type_kernel.mk.am +LDADD += \ + $(top_builddir)/ndb/src/common/util/libgeneral.la \ + $(top_builddir)/ndb/src/common/portlib/libportlib.la \ + $(top_builddir)/dbug/libdbug.a \ + $(top_builddir)/mysys/libmysys.a \ + $(top_builddir)/strings/libmystrings.a + # Don't update the files from bitkeeper %::SCCS/s.% diff --git a/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp b/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp index 3e944485e1c..a8b84298ebe 100644 --- a/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp +++ b/ndb/src/kernel/blocks/dbdict/printSchemaFile.cpp @@ -1,11 +1,3 @@ -#if 0 -make -f Makefile -f - printSchemaFile <<'_eof_' -printSchemaFile: printSchemaFile.cpp - $(CXXCOMPILE) -o $@ $@.cpp -L../../../common/util/.libs -lgeneral -_eof_ -exit $? -#endif - /* Copyright (C) 2003 MySQL AB This program is free software; you can redistribute it and/or modify @@ -58,8 +50,7 @@ print(const char * filename, const SchemaFile * file){ SchemaFile::TableEntry te = file->TableEntries[i]; if(te.m_tableState != SchemaFile::INIT){ ndbout << "Table " << i << ": State = " << te.m_tableState - << " version = " << table_version_major(te.m_tableVersion) << - << "(" << table_version_minor(te.m_tableVersion) << ")" + << " version = " << te.m_tableVersion << " type = " << te.m_tableType << " noOfPages = " << te.m_noOfPages << " gcp: " << te.m_gcp << endl; From e7c905c4fdfdb2cb40c1d776f80805eb0711c312 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 26 Sep 2005 16:49:18 +0200 Subject: [PATCH 11/11] Fixed gcc error on AMD64: cast from 'char*' to 'unsigned int' loses precision --- sql/ha_ndbcluster.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sql/ha_ndbcluster.cc b/sql/ha_ndbcluster.cc index cc60c807bc9..c478e565220 100644 --- a/sql/ha_ndbcluster.cc +++ b/sql/ha_ndbcluster.cc @@ -598,8 +598,8 @@ int ha_ndbcluster::set_ndb_value(NdbOperation *ndb_op, Field *field, blob_ptr= (char*)""; } - DBUG_PRINT("value", ("set blob ptr=%x len=%u", - (unsigned)blob_ptr, blob_len)); + DBUG_PRINT("value", ("set blob ptr=%p len=%u", + blob_ptr, blob_len)); DBUG_DUMP("value", (char*)blob_ptr, min(blob_len, 26)); if (set_blob_value)