From 71e0ff64f070b7ebcf9c25d7c9e75a0aa4970163 Mon Sep 17 00:00:00 2001 From: Davi Arnaut Date: Thu, 7 Jul 2011 08:22:43 -0300 Subject: Bug#12727287: Maintainer mode compilation fails with gcc 4.6 GCC 4.6 has new -Wunused-but-set-variable flag, which is enabled by -Wall, that causes GCC to emit a warning whenever a local variable is assigned to, but otherwise unused (aside from its declaration). Since the maintainer mode uses -Wall and -Werror, source code which triggers these warnings will be rejected. That is, these warnings become hard errors. The solution is to fix the code which triggers these specific warnings. In most of the cases, this is a welcome cleanup as code which triggers this warning is probably dead anyway. dbug/dbug.c: Unused but set. libmysqld/lib_sql.cc: Length is not necessary as the converted error message is always null-terminated. sql/item_func.cc: Make get_var_with_binlog private to this compilation unit. If a error was raised, do not attempt to evaluate the user variable as the statement execution will be interrupted anyway. sql/mysqld.cc: Use a void expression to silence the warning. Avoids the use of macros that would make the code more unreadable than it already is. sql/protocol.cc: Length is not necessary as the converted error message is always null-terminated. Remove unnecessary casts and assignment. sql/sql_class.h: Function is only used in a single compilation unit. sql/sql_load.cc: Only use the variable outside of EMBEDDED_LIBRARY. storage/innobase/btr/btr0cur.c: Do not retrieve field, only the record length is being used. storage/perfschema/pfs.cc: Use a void expression to silence the warning. tests/mysql_client_test.c: Unused but set. unittest/mysys/lf-t.c: Unused but set. --- tests/mysql_client_test.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'tests/mysql_client_test.c') diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 5401e360f33..b3da65485dd 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -18596,11 +18596,8 @@ static void test_bug38486(void) static void test_bug33831(void) { MYSQL *l_mysql; - my_bool error; DBUG_ENTER("test_bug33831"); - - error= 0; if (!(l_mysql= mysql_client_init(NULL))) { @@ -18623,9 +18620,8 @@ static void test_bug33831(void) DIE_UNLESS(0); } - mysql_close(l_mysql); - + DBUG_VOID_RETURN; } -- cgit v1.2.1 From 22c2d06d3dcf8ec958b771f4a7a49ef368d79b17 Mon Sep 17 00:00:00 2001 From: Gleb Shchepa Date: Wed, 3 Aug 2011 17:53:44 +0400 Subject: backport from mysql-trunk BUG #11754979 - 46675: ON DUPLICATE KEY UPDATE AND UPDATECOUNT() POSSIBLY WRONG The mysql_affected_rows() client call returns 3 instead of 2 on INSERT ... ON DUPLICATE KEY UPDATE query with a duplicated key value. The fix for the old bug #29692 was incomplete: unnecessary double increment of "touched" rows still happened. This bugfix removes: 1) unneeded increment of "touched" rows and 2) useless double resetting of auto-increment value. sql/sql_insert.cc: write_record() function: Unneeded increment of "touched" rows and useless double resetting of auto-increment value has been removed. tests/mysql_client_test.c: New test case. --- tests/mysql_client_test.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'tests/mysql_client_test.c') diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index b3da65485dd..14a60f0e857 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -19660,6 +19660,34 @@ static void test_bug12337762() DBUG_VOID_RETURN; } + +/* + BUG 11754979 - 46675: ON DUPLICATE KEY UPDATE AND UPDATECOUNT() POSSIBLY WRONG +*/ + +static void test_bug11754979() +{ + MYSQL* conn; + DBUG_ENTER("test_bug11754979"); + + myheader("test_bug11754979"); + DIE_UNLESS((conn= mysql_client_init(NULL))); + DIE_UNLESS(mysql_real_connect(conn, opt_host, opt_user, + opt_password, opt_db ? opt_db:"test", opt_port, + opt_unix_socket, CLIENT_FOUND_ROWS)); + myquery(mysql_query(conn, "DROP TABLE IF EXISTS t1")); + myquery(mysql_query(conn, "CREATE TABLE t1(id INT, label CHAR(1), PRIMARY KEY(id))")); + myquery(mysql_query(conn, "INSERT INTO t1(id, label) VALUES (1, 'a')")); + myquery(mysql_query(conn, "INSERT INTO t1(id, label) VALUES (1, 'a') " + "ON DUPLICATE KEY UPDATE id = 4")); + DIE_UNLESS(mysql_affected_rows(conn) == 2); + myquery(mysql_query(conn, "DROP TABLE t1")); + mysql_close(conn); + + DBUG_VOID_RETURN; +} + + /* Read and parse arguments and MySQL options from my.cnf */ @@ -20005,6 +20033,7 @@ static struct my_tests_st my_tests[]= { { "test_bug56976", test_bug56976 }, { "test_bug11766854", test_bug11766854 }, { "test_bug12337762", test_bug12337762 }, + { "test_bug11754979", test_bug11754979 }, { 0, 0 } }; -- cgit v1.2.1 From 681476255147dacac7e3674b6cd2ae770fee2208 Mon Sep 17 00:00:00 2001 From: Magne Mahre Date: Thu, 6 Oct 2011 14:13:23 +0200 Subject: Bug#12912112 MYSQL_CLIENT_TEST FAILS ON TEST_TRUNCATION Sun Studio 12 has an error when calculating the compile-time length of a constant character string. The error is only present when building an optimized 32-bits version, using the -xbuiltin=(%all) compiler flag. During compilation, the compiler recognizes the use of the strlen() function used on a constant string. It optimizes the strlen and replaces it with the actual length of the string. This optimization seems to calculate the length wrongly in this particular case. Replacing the "const char *" with a "const char []" solves the problem. --- tests/mysql_client_test.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'tests/mysql_client_test.c') diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index 14a60f0e857..4050f18c674 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -13445,7 +13445,10 @@ static void test_truncation() ")"; rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); myquery(rc); - stmt_text= "insert into t1 VALUES (" + + { + const char insert_text[]= + "insert into t1 VALUES (" "-10, " /* i8 */ "200, " /* ui8 */ "32000, " /* i16 */ @@ -13461,8 +13464,9 @@ static void test_truncation() "'12345.67 ', " /* tx_1 */ "'12345.67abc'" /* ch_2 */ ")"; - rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text)); - myquery(rc); + rc= mysql_real_query(mysql, insert_text, strlen(insert_text)); + myquery(rc); + } stmt_text= "select i8 c1, i8 c2, ui8 c3, i16_1 c4, ui16 c5, " " i16 c6, ui16 c7, i32 c8, i32_1 c9, i32_1 c10, " -- cgit v1.2.1