diff options
author | unknown <konstantin@mysql.com> | 2004-10-20 16:45:09 +0400 |
---|---|---|
committer | unknown <konstantin@mysql.com> | 2004-10-20 16:45:09 +0400 |
commit | 7c20b1328866061273617ec7e8ae7b4e00c8674c (patch) | |
tree | b63f30c547d9c739a72eccdd5b8817f371e31a6d /tests | |
parent | 6875cf36d1625449f539c9eaefb8171158231ee2 (diff) | |
parent | 8fe8912f4c1d01b9bb8c5c1aefe4ac6405a87976 (diff) | |
download | mariadb-git-7c20b1328866061273617ec7e8ae7b4e00c8674c.tar.gz |
Merge bk-internal.mysql.com:/home/bk/mysql-4.1
into mysql.com:/home/kostja/work/mysql-4.1-6049
libmysql/libmysql.c:
Auto merged
sql/field.cc:
Auto merged
sql/item.cc:
Auto merged
sql/mysql_priv.h:
Auto merged
tests/client_test.c:
Auto merged
Diffstat (limited to 'tests')
-rw-r--r-- | tests/client_test.c | 101 |
1 files changed, 98 insertions, 3 deletions
diff --git a/tests/client_test.c b/tests/client_test.c index eb97c0ce949..8721285ec3f 100644 --- a/tests/client_test.c +++ b/tests/client_test.c @@ -3431,7 +3431,7 @@ static void test_fetch_date() MYSQL_STMT *stmt; uint i; int rc, year; - char date[25], time[25], ts[25], ts_4[15], ts_6[20], dt[20]; + char date[25], time[25], ts[25], ts_4[25], ts_6[20], dt[20]; ulong d_length, t_length, ts_length, ts4_length, ts6_length, dt_length, y_length; MYSQL_BIND bind[8]; @@ -3541,8 +3541,8 @@ static void test_fetch_date() DIE_UNLESS(strcmp(dt, "2010-07-10 00:00:00") == 0); DIE_UNLESS(dt_length == 19); - DIE_UNLESS(ts_4[0] == '\0'); - DIE_UNLESS(ts4_length == 0); + DIE_UNLESS(strcmp(ts_4, "0000-00-00 00:00:00") == 0); + DIE_UNLESS(ts4_length == strlen("0000-00-00 00:00:00")); DIE_UNLESS(strcmp(ts_6, "1999-12-29 00:00:00") == 0); DIE_UNLESS(ts6_length == 19); @@ -10533,6 +10533,99 @@ 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", (char*) buffer); + + DIE_UNLESS(strcmp(row[0], (char*) buffer) == 0); + + mysql_free_result(res); + mysql_stmt_close(stmt); +} + + +static void test_bug6058() +{ + 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_bug6058"); + + stmt_text= "SELECT CAST('0000-00-00' AS DATE)"; + + 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 */ @@ -10843,6 +10936,8 @@ 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 */ + test_bug6058(); /* check support for 0000-00-00 dates */ /* XXX: PLEASE RUN THIS PROGRAM UNDER VALGRIND AND VERIFY THAT YOUR TEST DOESN'T CONTAIN WARNINGS/ERRORS BEFORE YOU PUSH. |