diff options
author | Sergey Glukhov <Sergey.Glukhov@sun.com> | 2008-11-27 17:05:38 +0400 |
---|---|---|
committer | Sergey Glukhov <Sergey.Glukhov@sun.com> | 2008-11-27 17:05:38 +0400 |
commit | 910d41725dcbf6e54a1d07370949e6da2b9535ca (patch) | |
tree | c61e6a14ef5de640a505489c42a67f76446e6ec7 | |
parent | 12758f9d6e5162a251c6e80840653c53afd1cb8c (diff) | |
parent | 73960af037a68dd96ae636ff84b39007f825ab0e (diff) | |
download | mariadb-git-910d41725dcbf6e54a1d07370949e6da2b9535ca.tar.gz |
5.0-bugteam->5.1-bugteam merge
-rw-r--r-- | extra/perror.c | 40 | ||||
-rw-r--r-- | mysql-test/r/perror-win.result | 5 | ||||
-rw-r--r-- | mysql-test/t/perror-win.test | 11 | ||||
-rw-r--r-- | sql/field.cc | 2 | ||||
-rw-r--r-- | tests/mysql_client_test.c | 82 |
5 files changed, 138 insertions, 2 deletions
diff --git a/extra/perror.c b/extra/perror.c index 237b2582d43..80eb2af2dae 100644 --- a/extra/perror.c +++ b/extra/perror.c @@ -185,11 +185,36 @@ static const char *get_ha_error_msg(int code) } +#if defined(__WIN__) +static my_bool print_win_error_msg(DWORD error, my_bool verbose) +{ + LPTSTR s; + if (FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | + FORMAT_MESSAGE_FROM_SYSTEM, + NULL, error, 0, (LPTSTR)&s, 0, + NULL)) + { + if (verbose) + printf("Win32 error code %d: %s", error, s); + else + puts(s); + LocalFree(s); + return 0; + } + return 1; +} +#endif + + + int main(int argc,char *argv[]) { int error,code,found; const char *msg; char *unknown_error = 0; +#if defined(__WIN__) + my_bool skip_win_message= 0; +#endif MY_INIT(argv[0]); if (get_options(&argc,&argv)) @@ -293,9 +318,20 @@ int main(int argc,char *argv[]) } if (!found) { - fprintf(stderr,"Illegal error code: %d\n", code); - error= 1; +#if defined(__WIN__) + if (!(skip_win_message= !print_win_error_msg((DWORD)code, verbose))) + { +#endif + fprintf(stderr,"Illegal error code: %d\n",code); + error=1; +#if defined(__WIN__) + } +#endif } +#if defined(__WIN__) + if (!skip_win_message) + print_win_error_msg((DWORD)code, verbose); +#endif } } diff --git a/mysql-test/r/perror-win.result b/mysql-test/r/perror-win.result new file mode 100644 index 00000000000..61e6fcaab4e --- /dev/null +++ b/mysql-test/r/perror-win.result @@ -0,0 +1,5 @@ +MySQL error code 150: Foreign key constraint is incorrectly formed +Win32 error code 150: System trace information was not specified in your CONFIG.SYS file, or tracing is disallowed. +OS error code 23: Too many open files in system +Win32 error code 23: Data error (cyclic redundancy check). +Win32 error code 15000: The specified channel path is invalid. diff --git a/mysql-test/t/perror-win.test b/mysql-test/t/perror-win.test new file mode 100644 index 00000000000..56615e72a5a --- /dev/null +++ b/mysql-test/t/perror-win.test @@ -0,0 +1,11 @@ +# Windows-specific tests +--source include/windows.inc +--require r/have_perror.require +disable_query_log; +eval select LENGTH("$MY_PERROR") > 0 as "have_perror"; +enable_query_log; + + +--exec $MY_PERROR 150 +--exec $MY_PERROR 23 +--exec $MY_PERROR 15000 diff --git a/sql/field.cc b/sql/field.cc index a03beb4e8af..e815320bc9e 100644 --- a/sql/field.cc +++ b/sql/field.cc @@ -5814,6 +5814,7 @@ int Field_newdate::store_time(MYSQL_TIME *ltime,timestamp_type time_type) { char buff[MAX_DATE_STRING_REP_LENGTH]; String str(buff, sizeof(buff), &my_charset_latin1); + tmp= 0; make_date((DATE_TIME_FORMAT *) 0, ltime, &str); set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, str.ptr(), str.length(), MYSQL_TIMESTAMP_DATE, 1); @@ -6056,6 +6057,7 @@ int Field_datetime::store_time(MYSQL_TIME *ltime,timestamp_type time_type) { char buff[MAX_DATE_STRING_REP_LENGTH]; String str(buff, sizeof(buff), &my_charset_latin1); + tmp= 0; make_datetime((DATE_TIME_FORMAT *) 0, ltime, &str); set_datetime_warning(MYSQL_ERROR::WARN_LEVEL_WARN, WARN_DATA_TRUNCATED, str.ptr(), str.length(), MYSQL_TIMESTAMP_DATETIME,1); diff --git a/tests/mysql_client_test.c b/tests/mysql_client_test.c index a50b009303a..d0a60d4df9a 100644 --- a/tests/mysql_client_test.c +++ b/tests/mysql_client_test.c @@ -17576,6 +17576,87 @@ static void test_bug38486(void) DBUG_VOID_RETURN; } +static void test_bug40365(void) +{ + uint rc, i, count= 1; + MYSQL_STMT *stmt= 0; + MYSQL_BIND my_bind[2]; + my_bool is_null[2]= {0}; + MYSQL_TIME tm[2]; + + DBUG_ENTER("test_bug40365"); + + rc= mysql_query(mysql, "DROP TABLE IF EXISTS t1"); + myquery(rc); + rc= mysql_query(mysql, "CREATE TABLE t1(c1 DATETIME, \ + c2 DATE)"); + myquery(rc); + + stmt= mysql_simple_prepare(mysql, "INSERT INTO t1 VALUES(?, ?)"); + check_stmt(stmt); + verify_param_count(stmt, 2); + + bzero((char*) my_bind, sizeof(my_bind)); + my_bind[0].buffer_type= MYSQL_TYPE_DATETIME; + my_bind[1].buffer_type= MYSQL_TYPE_DATE; + for (i= 0; i < (int) array_elements(my_bind); i++) + { + my_bind[i].buffer= (void *) &tm[i]; + my_bind[i].is_null= &is_null[i]; + } + + rc= mysql_stmt_bind_param(stmt, my_bind); + check_execute(stmt, rc); + + for (i= 0; i < (int) array_elements(my_bind); i++) + { + tm[i].neg= 0; + tm[i].second_part= 0; + tm[i].year= 2009; + tm[i].month= 2; + tm[i].day= 29; + tm[i].hour= 0; + tm[i].minute= 0; + tm[i].second= 0; + } + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + rc= mysql_commit(mysql); + myquery(rc); + mysql_stmt_close(stmt); + + stmt= mysql_simple_prepare(mysql, "SELECT * FROM t1"); + check_stmt(stmt); + + rc= mysql_stmt_bind_result(stmt, my_bind); + check_execute(stmt, rc); + + rc= mysql_stmt_execute(stmt); + check_execute(stmt, rc); + + rc= mysql_stmt_store_result(stmt); + check_execute(stmt, rc); + + rc= mysql_stmt_fetch(stmt); + check_execute(stmt, rc); + + if (!opt_silent) + fprintf(stdout, "\n"); + + for (i= 0; i < array_elements(my_bind); i++) + { + if (!opt_silent) + fprintf(stdout, "\ntime[%d]: %02d-%02d-%02d ", + i, tm[i].year, tm[i].month, tm[i].day); + DIE_UNLESS(tm[i].year == 0); + DIE_UNLESS(tm[i].month == 0); + DIE_UNLESS(tm[i].day == 0); + } + mysql_stmt_close(stmt); + + DBUG_VOID_RETURN; +} /* Read and parse arguments and MySQL options from my.cnf */ @@ -17885,6 +17966,7 @@ static struct my_tests_st my_tests[]= { { "test_wl4166_1", test_wl4166_1 }, { "test_wl4166_2", test_wl4166_2 }, { "test_bug38486", test_bug38486 }, + { "test_bug40365", test_bug40365 }, { 0, 0 } }; |