summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorunknown <konstantin@mysql.com>2004-10-16 00:12:59 +0400
committerunknown <konstantin@mysql.com>2004-10-16 00:12:59 +0400
commit9aefc403f9f707edf0f84ce401d32929067aea30 (patch)
tree49c6d8401938fd8137914328918f5f64de298327 /tests
parentf125849dd1fa2b7eaca3aea5f84d7d79fb201ec2 (diff)
downloadmariadb-git-9aefc403f9f707edf0f84ce401d32929067aea30.tar.gz
A fix and test case for Bug#6049 "Loss of sign when using prepared
statements and negative time/date values". The bug was in wrong sprintf format used in the client library. The fix moves TIME -> string conversion functions to sql-common and utilized them in the client library. include/my_time.h: Declarations for new functions shared between the client and server. libmysql/libmysql.c: Fix for Bug#6049 "Loss of sign when using prepared statements and negative time/date values": use the same function as the server to convert date/time/datetime values to strings. sql-common/my_time.c: Implementation of my_{time,datetime,date,TIME}_to_str: it's needed by the client library, so it should be shared. sql/field.cc: Don't create String object if it's not needed. sql/item.cc: Don't create String object if it's not needed: TIME_to_string was moved to my_TIME_to_str, with different arguments. sql/item_timefunc.cc: Don't create String object if it's not needed. sql/mysql_priv.h: TIME_to_string and MAX_DATE_REP_LENGTH moved to the client library. MAX_DATE_REP_LENGTH was renamed to MAX_DATE_STRING_REP_LENGTH to not conflict with the same name in libmysql.c sql/protocol.cc: Don't create String object if it's not needed. sql/time.cc: Implementation of my_{time,date,datetime,TIME}_to_str moved to my_time.c shared between the client and the server. tests/client_test.c: A test case for Bug#6049.
Diffstat (limited to 'tests')
-rw-r--r--tests/client_test.c47
1 files changed, 47 insertions, 0 deletions
diff --git a/tests/client_test.c b/tests/client_test.c
index 0b30cc3386d..5cafd2e033e 100644
--- a/tests/client_test.c
+++ b/tests/client_test.c
@@ -10541,6 +10541,52 @@ static void test_bug5315()
}
+static void test_bug6049()
+{
+ MYSQL_STMT *stmt;
+ MYSQL_BIND bind[1];
+ MYSQL_RES *res;
+ MYSQL_ROW row;
+ const char *stmt_text;
+ char *buffer[30];
+ ulong length;
+ int rc;
+
+ myheader("test_bug6049");
+
+ stmt_text= "SELECT MAKETIME(-25, 12, 12)";
+
+ rc= mysql_real_query(mysql, stmt_text, strlen(stmt_text));
+ myquery(rc);
+ res= mysql_store_result(mysql);
+ row= mysql_fetch_row(res);
+
+ stmt= mysql_stmt_init(mysql);
+ rc= mysql_stmt_prepare(stmt, stmt_text, strlen(stmt_text));
+ check_execute(stmt, rc);
+ rc= mysql_stmt_execute(stmt);
+ check_execute(stmt, rc);
+
+ bzero(bind, sizeof(bind));
+ bind[0].buffer_type = MYSQL_TYPE_STRING;
+ bind[0].buffer = &buffer;
+ bind[0].buffer_length = sizeof(buffer);
+ bind[0].length = &length;
+
+ mysql_stmt_bind_result(stmt, bind);
+ 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);
+
+ DIE_UNLESS(strcmp(row[0], buffer) == 0);
+
+ mysql_free_result(res);
+ mysql_stmt_close(stmt);
+}
+
+
/*
Read and parse arguments and MySQL options from my.cnf
*/
@@ -10851,6 +10897,7 @@ int main(int argc, char **argv)
test_bug5194(); /* bulk inserts in prepared mode */
test_bug5315(); /* check that mysql_change_user closes all
prepared statements */
+ test_bug6049(); /* check support for negative TIME values */
/*
XXX: PLEASE RUN THIS PROGRAM UNDER VALGRIND AND VERIFY THAT YOUR TEST
DOESN'T CONTAIN WARNINGS/ERRORS BEFORE YOU PUSH.