#At file:///home/malff/BZR_TREE/mysql-5.5-bugfixing-56528/ based on revid:marc.alff@stripped
3204 Marc Alff 2010-09-09 [merge]
local merge
modified:
client/mysqltest.cc
cmake/dtrace.cmake
libmysqld/lib_sql.cc
mysql-test/r/func_time.result
mysql-test/r/parser.result
mysql-test/r/select.result
mysql-test/r/strict.result
mysql-test/r/type_datetime.result
mysql-test/suite/rpl/t/disabled.def
mysql-test/t/disabled.def
mysql-test/t/strict.test
mysql-test/t/type_datetime.test
mysys/my_gethwaddr.c
mysys/my_sync.c
sql/derror.cc
sql/item_timefunc.cc
sql/item_timefunc.h
sql/mysqld.cc
sql/set_var.cc
sql/set_var.h
sql/sys_vars.h
=== modified file 'client/mysqltest.cc'
--- a/client/mysqltest.cc 2010-08-27 11:33:32 +0000
+++ b/client/mysqltest.cc 2010-09-08 08:53:03 +0000
@@ -248,10 +248,14 @@ struct st_connection
my_bool pending;
#ifdef EMBEDDED_LIBRARY
+ pthread_t tid;
const char *cur_query;
int cur_query_len;
- pthread_mutex_t mutex;
- pthread_cond_t cond;
+ int command, result;
+ pthread_mutex_t query_mutex;
+ pthread_cond_t query_cond;
+ pthread_mutex_t result_mutex;
+ pthread_cond_t result_cond;
int query_done;
#endif /*EMBEDDED_LIBRARY*/
};
@@ -703,67 +707,148 @@ void handle_no_error(struct st_command*)
#ifdef EMBEDDED_LIBRARY
+#define EMB_SEND_QUERY 1
+#define EMB_READ_QUERY_RESULT 2
+#define EMB_END_CONNECTION 3
+
/* attributes of the query thread */
pthread_attr_t cn_thd_attrib;
+
/*
- send_one_query executes query in separate thread, which is
- necessary in embedded library to run 'send' in proper way.
- This implementation doesn't handle errors returned
- by mysql_send_query. It's technically possible, though
- I don't see where it is needed.
+ This procedure represents the connection and actually
+ runs queries when in the EMBEDDED-SERVER mode.
+ The run_query_normal() just sends request for running
+ mysql_send_query and mysql_read_query_result() here.
*/
-pthread_handler_t send_one_query(void *arg)
+
+pthread_handler_t connection_thread(void *arg)
{
struct st_connection *cn= (struct st_connection*)arg;
mysql_thread_init();
- (void) mysql_send_query(&cn->mysql, cn->cur_query, cn->cur_query_len);
+ while (cn->command != EMB_END_CONNECTION)
+ {
+ if (!cn->command)
+ {
+ pthread_mutex_lock(&cn->query_mutex);
+ while (!cn->command)
+ pthread_cond_wait(&cn->query_cond, &cn->query_mutex);
+ pthread_mutex_unlock(&cn->query_mutex);
+ }
+ switch (cn->command)
+ {
+ case EMB_END_CONNECTION:
+ goto end_thread;
+ case EMB_SEND_QUERY:
+ cn->result= mysql_send_query(&cn->mysql, cn->cur_query, cn->cur_query_len);
+ break;
+ case EMB_READ_QUERY_RESULT:
+ cn->result= mysql_read_query_result(&cn->mysql);
+ break;
+ default:
+ DBUG_ASSERT(0);
+ }
+ cn->command= 0;
+ pthread_mutex_lock(&cn->result_mutex);
+ cn->query_done= 1;
+ pthread_cond_signal(&cn->result_cond);
+ pthread_mutex_unlock(&cn->result_mutex);
+ }
- mysql_thread_end();
- pthread_mutex_lock(&cn->mutex);
+end_thread:
cn->query_done= 1;
- pthread_cond_signal(&cn->cond);
- pthread_mutex_unlock(&cn->mutex);
+ mysql_thread_end();
pthread_exit(0);
return 0;
}
-static int do_send_query(struct st_connection *cn, const char *q, int q_len,
- int flags)
+
+static void wait_query_thread_done(struct st_connection *con)
+{
+ DBUG_ASSERT(con->tid);
+ if (!con->query_done)
+ {
+ pthread_mutex_lock(&con->result_mutex);
+ while (!con->query_done)
+ pthread_cond_wait(&con->result_cond, &con->result_mutex);
+ pthread_mutex_unlock(&con->result_mutex);
+ }
+}
+
+
+static void signal_connection_thd(struct st_connection *cn, int command)
{
- pthread_t tid;
+ DBUG_ASSERT(cn->tid);
+ cn->query_done= 0;
+ cn->command= command;
+ pthread_mutex_lock(&cn->query_mutex);
+ pthread_cond_signal(&cn->query_cond);
+ pthread_mutex_unlock(&cn->query_mutex);
+}
- if (flags & QUERY_REAP_FLAG)
- return mysql_send_query(&cn->mysql, q, q_len);
- if (pthread_mutex_init(&cn->mutex, NULL) ||
- pthread_cond_init(&cn->cond, NULL))
- die("Error in the thread library");
+/*
+ Sometimes we try to execute queries when the connection is closed.
+ It's done to make sure it was closed completely.
+ So that if our connection is closed (cn->tid == 0), we just return
+ the mysql_send_query() result which is an error in this case.
+*/
+static int do_send_query(struct st_connection *cn, const char *q, int q_len)
+{
+ if (!cn->tid)
+ return mysql_send_query(&cn->mysql, q, q_len);
cn->cur_query= q;
cn->cur_query_len= q_len;
- cn->query_done= 0;
- if (pthread_create(&tid, &cn_thd_attrib, send_one_query, (void*)cn))
- die("Cannot start new thread for query");
-
+ signal_connection_thd(cn, EMB_SEND_QUERY);
return 0;
}
-static void wait_query_thread_end(struct st_connection *con)
+
+static int do_read_query_result(struct st_connection *cn)
{
- if (!con->query_done)
- {
- pthread_mutex_lock(&con->mutex);
- while (!con->query_done)
- pthread_cond_wait(&con->cond, &con->mutex);
- pthread_mutex_unlock(&con->mutex);
- }
+ DBUG_ASSERT(cn->tid);
+ wait_query_thread_done(cn);
+ signal_connection_thd(cn, EMB_READ_QUERY_RESULT);
+ wait_query_thread_done(cn);
+
+ return cn->result;
+}
+
+
+static void emb_close_connection(struct st_connection *cn)
+{
+ if (!cn->tid)
+ return;
+ wait_query_thread_done(cn);
+ signal_connection_thd(cn, EMB_END_CONNECTION);
+ pthread_join(cn->tid, NULL);
+ cn->tid= 0;
+ pthread_mutex_destroy(&cn->query_mutex);
+ pthread_cond_destroy(&cn->query_cond);
+ pthread_mutex_destroy(&cn->result_mutex);
+ pthread_cond_destroy(&cn->result_cond);
}
+
+static void init_connection_thd(struct st_connection *cn)
+{
+ cn->query_done= 1;
+ cn->command= 0;
+ if (pthread_mutex_init(&cn->query_mutex, NULL) ||
+ pthread_cond_init(&cn->query_cond, NULL) ||
+ pthread_mutex_init(&cn->result_mutex, NULL) ||
+ pthread_cond_init(&cn->result_cond, NULL) ||
+ pthread_create(&cn->tid, &cn_thd_attrib, connection_thread, (void*)cn))
+ die("Error in the thread library");
+}
+
+
#else /*EMBEDDED_LIBRARY*/
-#define do_send_query(cn,q,q_len,flags) mysql_send_query(&cn->mysql, q, q_len)
+#define do_send_query(cn,q,q_len) mysql_send_query(&cn->mysql, q, q_len)
+#define do_read_query_result(cn) mysql_read_query_result(&cn->mysql)
#endif /*EMBEDDED_LIBRARY*/
@@ -1106,6 +1191,9 @@ void close_connections()
DBUG_ENTER("close_connections");
for (--next_con; next_con >= connections; --next_con)
{
+#ifdef EMBEDDED_LIBRARY
+ emb_close_connection(next_con);
+#endif
if (next_con->stmt)
mysql_stmt_close(next_con->stmt);
next_con->stmt= 0;
@@ -4866,7 +4954,7 @@ void do_close_connection(struct st_comma
we need to check if the query's thread was finished and probably wait
(embedded-server specific)
*/
- wait_query_thread_end(con);
+ emb_close_connection(con);
#endif /*EMBEDDED_LIBRARY*/
if (con->stmt)
mysql_stmt_close(con->stmt);
@@ -5216,8 +5304,9 @@ void do_connect(struct st_command *comma
}
#ifdef EMBEDDED_LIBRARY
- con_slot->query_done= 1;
-#endif
+ init_connection_thd(con_slot);
+#endif /*EMBEDDED_LIBRARY*/
+
if (!mysql_init(&con_slot->mysql))
die("Failed on mysql_init()");
@@ -6768,21 +6857,13 @@ void run_query_normal(struct st_connecti
/*
Send the query
*/
- if (do_send_query(cn, query, query_len, flags))
+ if (do_send_query(cn, query, query_len))
{
handle_error(command, mysql_errno(mysql), mysql_error(mysql),
mysql_sqlstate(mysql), ds);
goto end;
}
}
-#ifdef EMBEDDED_LIBRARY
- /*
- Here we handle 'reap' command, so we need to check if the
- query's thread was finished and probably wait
- */
- else if (flags & QUERY_REAP_FLAG)
- wait_query_thread_end(cn);
-#endif /*EMBEDDED_LIBRARY*/
if (!(flags & QUERY_REAP_FLAG))
{
cn->pending= TRUE;
@@ -6795,7 +6876,7 @@ void run_query_normal(struct st_connecti
When on first result set, call mysql_read_query_result to retrieve
answer to the query sent earlier
*/
- if ((counter==0) && mysql_read_query_result(mysql))
+ if ((counter==0) && do_read_query_result(cn))
{
handle_error(command, mysql_errno(mysql), mysql_error(mysql),
mysql_sqlstate(mysql), ds);
@@ -7970,6 +8051,9 @@ int main(int argc, char **argv)
ps_protocol_enabled= 1;
st_connection *con= connections;
+#ifdef EMBEDDED_LIBRARY
+ init_connection_thd(con);
+#endif /*EMBEDDED_LIBRARY*/
if (!( mysql_init(&con->mysql)))
die("Failed in mysql_init()");
if (opt_connect_timeout)
=== modified file 'cmake/dtrace.cmake'
--- a/cmake/dtrace.cmake 2010-02-25 16:31:31 +0000
+++ b/cmake/dtrace.cmake 2010-09-06 12:45:12 +0000
@@ -13,13 +13,30 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+IF(CMAKE_SYSTEM_NAME MATCHES "SunOS" AND CMAKE_COMPILER_IS_GNUCXX
+ AND CMAKE_SIZEOF_VOID_P EQUAL 4)
+ IF(NOT DEFINED BUGGY_GCC_NO_DTRACE_MODULES)
+ EXECUTE_PROCESS(
+ COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1} --version
+ OUTPUT_VARIABLE out)
+ IF(out MATCHES "3.4.6")
+ # This gcc causes crashes in dlopen() for dtraced shared libs,
+ # while standard shipped with Solaris10 3.4.3 is ok
+ SET(BUGGY_GCC_NO_DTRACE_MODULES 1 CACHE INTERNAL "")
+ ELSE()
+ SET(BUGGY_GCC_NO_DTRACE_MODULES 0 CACHE INTERNAL "")
+ ENDIF()
+ ENDIF()
+ENDIF()
+
# Check if OS supports DTrace
MACRO(CHECK_DTRACE)
FIND_PROGRAM(DTRACE dtrace)
MARK_AS_ADVANCED(DTRACE)
# On FreeBSD, dtrace does not handle userland tracing yet
- IF(DTRACE AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ IF(DTRACE AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD"
+ AND NOT BUGGY_GCC_NO_DTRACE_MODULES)
SET(ENABLE_DTRACE ON CACHE BOOL "Enable dtrace")
ENDIF()
SET(HAVE_DTRACE ${ENABLE_DTRACE})
@@ -72,22 +89,6 @@ IF(ENABLE_DTRACE)
)
ENDIF()
-IF(CMAKE_SYSTEM_NAME MATCHES "SunOS" AND CMAKE_COMPILER_IS_GNUCXX
- AND CMAKE_SIZEOF_VOID_P EQUAL 4)
- IF(NOT DEFINED BUGGY_GCC_NO_DTRACE_MODULES)
- EXECUTE_PROCESS(
- COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1} --version
- OUTPUT_VARIABLE out)
- IF(out MATCHES "3.4.6")
- # This gcc causes crashes in dlopen() for dtraced shared libs,
- # while standard shipped with Solaris10 3.4.3 is ok
- SET(BUGGY_GCC_NO_DTRACE_MODULES 1 CACHE INTERNAL "")
- ELSE()
- SET(BUGGY_GCC_NO_DTRACE_MODULES 0 CACHE INTERNAL "")
- ENDIF()
- ENDIF()
-ENDIF()
-
FUNCTION(DTRACE_INSTRUMENT target)
IF(BUGGY_GCC_NO_DTRACE_MODULES)
GET_TARGET_PROPERTY(target_type ${target} TYPE)
=== modified file 'libmysqld/lib_sql.cc'
--- a/libmysqld/lib_sql.cc 2010-07-15 11:33:27 +0000
+++ b/libmysqld/lib_sql.cc 2010-09-02 18:37:04 +0000
@@ -481,6 +481,10 @@ int init_embedded_server(int argc, char
char *fake_argv[] = { (char *)"", 0 };
const char *fake_groups[] = { "server", "embedded", 0 };
my_bool acl_error;
+
+ if (my_thread_init())
+ return 1;
+
if (argc)
{
argcp= &argc;
=== modified file 'mysql-test/r/func_time.result'
--- a/mysql-test/r/func_time.result 2010-08-16 07:11:57 +0000
+++ b/mysql-test/r/func_time.result 2010-09-09 12:02:02 +0000
@@ -1200,6 +1200,8 @@ set time_zone= @@global.time_zone;
select str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE;
str_to_date('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE
NULL
+Warnings:
+Warning 1411 Incorrect datetime value: '10:00 PM' for function str_to_date
create table t1 (field DATE);
insert into t1 values ('2006-11-06');
select * from t1 where field < '2006-11-06 04:08:36.0';
=== modified file 'mysql-test/r/parser.result'
--- a/mysql-test/r/parser.result 2010-06-09 08:46:24 +0000
+++ b/mysql-test/r/parser.result 2010-09-07 06:45:00 +0000
@@ -556,9 +556,13 @@ DROP TABLE IF EXISTS t1;
SELECT STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE;
STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL 10 MINUTE
NULL
+Warnings:
+Warning 1411 Incorrect datetime value: '10:00 PM' for function str_to_date
SELECT STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL (INTERVAL(1,2,3) + 1) MINUTE;
STR_TO_DATE('10:00 PM', '%h:%i %p') + INTERVAL (INTERVAL(1,2,3) + 1) MINUTE
NULL
+Warnings:
+Warning 1411 Incorrect datetime value: '10:00 PM' for function str_to_date
SELECT "1997-12-31 23:59:59" + INTERVAL 1 SECOND;
"1997-12-31 23:59:59" + INTERVAL 1 SECOND
1998-01-01 00:00:00
=== modified file 'mysql-test/r/select.result'
--- a/mysql-test/r/select.result 2010-08-25 19:00:38 +0000
+++ b/mysql-test/r/select.result 2010-09-07 06:45:00 +0000
@@ -4171,9 +4171,10 @@ str_to_date('2007-10-00','%Y-%m-%d') bet
set SQL_MODE=TRADITIONAL;
select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';
str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'
-0
+NULL
Warnings:
Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34'
+Warning 1411 Incorrect datetime value: '2007-10-00 12:34' for function str_to_date
select str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34';
str_to_date('2007-10-01 12:34','%Y-%m-%d %H:%i') = '2007-10-00 12:34'
0
@@ -4181,17 +4182,16 @@ Warnings:
Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34'
select str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34';
str_to_date('2007-10-00 12:34','%Y-%m-%d %H:%i') = '2007-10-01 12:34'
-0
+NULL
Warnings:
-Warning 1292 Truncated incorrect datetime value: '2007-10-00 12:34:00'
+Warning 1411 Incorrect datetime value: '2007-10-00 12:34' for function str_to_date
select str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01'
and '2007/10/20';
str_to_date('2007-10-00','%Y-%m-%d') between '2007/09/01'
and '2007/10/20'
-0
+NULL
Warnings:
-Warning 1292 Incorrect datetime value: '2007-10-00' for column '2007/09/01' at row 1
-Warning 1292 Incorrect datetime value: '2007-10-00' for column '2007/10/20' at row 1
+Warning 1411 Incorrect datetime value: '2007-10-00' for function str_to_date
set SQL_MODE=DEFAULT;
select str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20';
str_to_date('2007-10-00','%Y-%m-%d') between '' and '2007/10/20'
=== modified file 'mysql-test/r/strict.result'
--- a/mysql-test/r/strict.result 2010-07-30 15:28:36 +0000
+++ b/mysql-test/r/strict.result 2010-09-07 06:45:00 +0000
@@ -206,12 +206,11 @@ INSERT INTO t1 (col1) VALUES (STR_TO_DAT
INSERT INTO t1 (col2) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i'));
INSERT INTO t1 (col3) VALUES (STR_TO_DATE('15.10.2004 10.15','%d.%m.%Y %H.%i'));
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
-Warnings:
-Note 1265 Data truncated for column 'col1' at row 1
+ERROR HY000: Incorrect datetime value: '31.10.0000 15.30' for function str_to_date
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
-ERROR 22007: Incorrect date value: '2004-00-31 15:30:00' for column 'col1' at row 1
+ERROR HY000: Incorrect datetime value: '31.0.2004 15.30' for function str_to_date
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
-ERROR 22007: Incorrect date value: '2004-10-00 15:30:00' for column 'col1' at row 1
+ERROR HY000: Incorrect datetime value: '0.10.2004 15.30' for function str_to_date
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
ERROR 22007: Incorrect date value: '2004-09-31 15:30:00' for column 'col1' at row 1
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
@@ -221,12 +220,13 @@ ERROR 22007: Incorrect date value: '2003
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
ERROR HY000: Incorrect datetime value: '15.13.2004 15.30' for function str_to_date
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
-ERROR 22007: Incorrect date value: '0000-00-00' for column 'col1' at row 1
+ERROR HY000: Incorrect datetime value: '00.00.0000' for function str_to_date
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
+ERROR HY000: Incorrect datetime value: '31.10.0000 15.30' for function str_to_date
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
-ERROR 22007: Incorrect datetime value: '2004-00-31 15:30:00' for column 'col2' at row 1
+ERROR HY000: Incorrect datetime value: '31.0.2004 15.30' for function str_to_date
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
-ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col2' at row 1
+ERROR HY000: Incorrect datetime value: '0.10.2004 15.30' for function str_to_date
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
ERROR 22007: Incorrect datetime value: '2004-09-31 15:30:00' for column 'col2' at row 1
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
@@ -236,13 +236,13 @@ ERROR 22007: Incorrect datetime value: '
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
ERROR HY000: Incorrect datetime value: '15.13.2004 15.30' for function str_to_date
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
-ERROR 22007: Incorrect datetime value: '0000-00-00' for column 'col2' at row 1
+ERROR HY000: Incorrect datetime value: '00.00.0000' for function str_to_date
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
-ERROR 22007: Incorrect datetime value: '0000-10-31 15:30:00' for column 'col3' at row 1
+ERROR HY000: Incorrect datetime value: '31.10.0000 15.30' for function str_to_date
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
-ERROR 22007: Incorrect datetime value: '2004-00-31 15:30:00' for column 'col3' at row 1
+ERROR HY000: Incorrect datetime value: '31.0.2004 15.30' for function str_to_date
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
-ERROR 22007: Incorrect datetime value: '2004-10-00 15:30:00' for column 'col3' at row 1
+ERROR HY000: Incorrect datetime value: '0.10.2004 15.30' for function str_to_date
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
ERROR 22007: Incorrect datetime value: '2004-09-31 15:30:00' for column 'col3' at row 1
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('32.10.2004 15.30','%d.%m.%Y %H.%i'));
@@ -252,7 +252,7 @@ ERROR 22007: Incorrect datetime value: '
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
ERROR HY000: Incorrect datetime value: '15.13.2004 15.30' for function str_to_date
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
-ERROR 22007: Incorrect datetime value: '0000-00-00' for column 'col3' at row 1
+ERROR HY000: Incorrect datetime value: '00.00.0000' for function str_to_date
drop table t1;
CREATE TABLE t1 (col1 date, col2 datetime, col3 timestamp);
INSERT INTO t1 (col1) VALUES (CAST('2004-10-15' AS DATE));
@@ -1108,6 +1108,9 @@ Warnings:
Warning 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
Warning 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
Warning 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
+Warning 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
+Warning 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
+Warning 1411 Incorrect datetime value: '2004.12.12 10:22:61' for function str_to_date
drop table t1;
create table t1 (col1 char(3), col2 integer);
insert into t1 (col1) values (cast(1000 as char(3)));
=== modified file 'mysql-test/r/type_datetime.result'
--- a/mysql-test/r/type_datetime.result 2010-05-05 09:28:37 +0000
+++ b/mysql-test/r/type_datetime.result 2010-09-07 06:45:00 +0000
@@ -655,5 +655,30 @@ Note 1003 select `test`.`t1`.`Id` AS `Id
DROP TABLE t1;
SET NAMES latin1;
#
+# Bug#56271: Wrong comparison result with STR_TO_DATE function
+#
+CREATE TABLE t1 (
+`year` int(4) NOT NULL,
+`month` int(2) NOT NULL
+);
+INSERT INTO t1 VALUES (2010,3),(2010,4),(2009,8),(2008,9);
+SELECT *
+FROM t1
+WHERE STR_TO_DATE(CONCAT_WS('/01/',`month`,`year`), '%m/%d/%Y') >=
+STR_TO_DATE('1/1/2010', '%m/%d/%Y');
+year month
+2010 3
+2010 4
+create table t2(f1 datetime primary key);
+insert into t2 select STR_TO_DATE(CONCAT_WS('/01/',`month`,`year`), '%m/%d/%Y') from t1;
+select * from t2 where f1=STR_TO_DATE('4/1/2010', '%m/%d/%Y');
+f1
+2010-04-01 00:00:00
+t2 should be const
+explain select * from t2 where f1=STR_TO_DATE('4/1/2010', '%m/%d/%Y');
+id select_type table type possible_keys key key_len ref rows Extra
+1 SIMPLE t2 const PRIMARY PRIMARY 8 const 1 Using index
+DROP TABLE t1,t2;
+#
# End of 5.5 tests
#
=== modified file 'mysql-test/suite/rpl/t/disabled.def'
--- a/mysql-test/suite/rpl/t/disabled.def 2010-08-13 10:07:27 +0000
+++ b/mysql-test/suite/rpl/t/disabled.def 2010-09-06 12:45:12 +0000
@@ -11,7 +11,6 @@
##############################################################################
rpl_failed_optimize : WL#4284: Can't optimize table used by a pending transaction (there is metadata lock on the table).
-rpl_plugin_load : Bug#55966 2010-08-13 alik "plugin" tests fail in 5.5
rpl_read_only : WL#4284: Setting Read only won't succeed until all metadata locks are released.
rpl_row_create_table : Bug#51574 2010-02-27 andrei failed different way than earlier with bug#45576
rpl_spec_variables : BUG#47661 2009-10-27 jasonh rpl_spec_variables fails on PB2 hpux
=== modified file 'mysql-test/t/disabled.def'
--- a/mysql-test/t/disabled.def 2010-09-01 13:12:42 +0000
+++ b/mysql-test/t/disabled.def 2010-09-06 12:45:12 +0000
@@ -14,9 +14,6 @@ lowercase_table3 : Bug#54845 201
mysqlhotcopy_myisam : Bug#54129 2010-08-31 alik mysqlhotcopy* fails
mysqlhotcopy_archive : Bug#54129 2010-08-31 alik mysqlhotcopy* fails
partition_innodb_plugin : Bug#53307 2010-04-30 VasilDimov valgrind warnings
-plugin : Bug#55966 2010-08-13 alik "plugin" tests fail in 5.5
-plugin_load : Bug#55966 2010-08-13 alik "plugin" tests fail in 5.5
-plugin_not_embedded : Bug#55966 2010-08-13 alik "plugin" tests fail in 5.5
query_cache_28249 : Bug#43861 2009-03-25 main.query_cache_28249 fails sporadically
sp_sync : Bug#48157 2010-02-06 5.5-m3 demands a differnt solution
ctype_utf8mb4_ndb : Bug#55799, Bug#51907, disabled by Konstantin 2010-08-06
=== modified file 'mysql-test/t/strict.test'
--- a/mysql-test/t/strict.test 2010-03-18 10:38:29 +0000
+++ b/mysql-test/t/strict.test 2010-09-07 06:45:00 +0000
@@ -192,11 +192,11 @@ INSERT INTO t1 (col3) VALUES (STR_TO_DAT
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid date value>
+--error 1411
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
-
---error 1292
+--error 1411
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
---error 1292
+--error 1411
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
--error 1292
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
@@ -206,18 +206,18 @@ INSERT INTO t1 (col1) VALUES(STR_TO_DATE
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
--error 1411
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
---error 1292
+--error 1411
INSERT INTO t1 (col1) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
## Test INSERT with STR_TO_DATE into DATETIME
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid datetime value>
+--error 1411
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
-
---error 1292
+--error 1411
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
---error 1292
+--error 1411
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
--error 1292
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
@@ -227,18 +227,18 @@ INSERT INTO t1 (col2) VALUES(STR_TO_DATE
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
--error 1411
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
---error 1292
+--error 1411
INSERT INTO t1 (col2) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
## Test INSERT with STR_TO_DATE into TIMESTAMP
# All test cases expected to fail should return
# SQLSTATE 22007 <invalid datetime value>
---error 1292
+--error 1411
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.10.0000 15.30','%d.%m.%Y %H.%i'));
---error 1292
+--error 1411
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.0.2004 15.30','%d.%m.%Y %H.%i'));
---error 1292
+--error 1411
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('0.10.2004 15.30','%d.%m.%Y %H.%i'));
--error 1292
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('31.9.2004 15.30','%d.%m.%Y %H.%i'));
@@ -248,7 +248,7 @@ INSERT INTO t1 (col3) VALUES(STR_TO_DATE
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('29.02.2003 15.30','%d.%m.%Y %H.%i'));
--error 1411
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('15.13.2004 15.30','%d.%m.%Y %H.%i'));
---error 1292
+--error 1411
INSERT INTO t1 (col3) VALUES(STR_TO_DATE('00.00.0000','%d.%m.%Y'));
drop table t1;
=== modified file 'mysql-test/t/type_datetime.test'
--- a/mysql-test/t/type_datetime.test 2010-05-05 09:28:37 +0000
+++ b/mysql-test/t/type_datetime.test 2010-09-07 06:45:00 +0000
@@ -462,5 +462,28 @@ DROP TABLE t1;
SET NAMES latin1;
--echo #
+--echo # Bug#56271: Wrong comparison result with STR_TO_DATE function
+--echo #
+CREATE TABLE t1 (
+ `year` int(4) NOT NULL,
+ `month` int(2) NOT NULL
+);
+
+INSERT INTO t1 VALUES (2010,3),(2010,4),(2009,8),(2008,9);
+
+SELECT *
+FROM t1
+WHERE STR_TO_DATE(CONCAT_WS('/01/',`month`,`year`), '%m/%d/%Y') >=
+STR_TO_DATE('1/1/2010', '%m/%d/%Y');
+
+create table t2(f1 datetime primary key);
+insert into t2 select STR_TO_DATE(CONCAT_WS('/01/',`month`,`year`), '%m/%d/%Y') from t1;
+select * from t2 where f1=STR_TO_DATE('4/1/2010', '%m/%d/%Y');
+--echo t2 should be const
+explain select * from t2 where f1=STR_TO_DATE('4/1/2010', '%m/%d/%Y');
+
+DROP TABLE t1,t2;
+
+--echo #
--echo # End of 5.5 tests
--echo #
=== modified file 'mysys/my_gethwaddr.c'
--- a/mysys/my_gethwaddr.c 2010-07-15 13:47:50 +0000
+++ b/mysys/my_gethwaddr.c 2010-09-09 12:51:50 +0000
@@ -64,7 +64,7 @@ my_bool my_gethwaddr(uchar *to)
if (ifm->ifm_type == RTM_IFINFO)
{
sdl = (struct sockaddr_dl *)(ifm + 1);
- addr=LLADDR(sdl);
+ addr=(uchar *)LLADDR(sdl);
res=memcpy_and_test(to, addr, ETHER_ADDR_LEN);
}
}
=== modified file 'mysys/my_sync.c'
--- a/mysys/my_sync.c 2009-12-11 09:39:38 +0000
+++ b/mysys/my_sync.c 2010-09-09 13:55:37 +0000
@@ -100,9 +100,9 @@ static const char cur_dir_name[]= {FN_CU
RETURN
0 if ok, !=0 if error
*/
+#ifdef NEED_EXPLICIT_SYNC_DIR
int my_sync_dir(const char *dir_name, myf my_flags)
{
-#ifdef NEED_EXPLICIT_SYNC_DIR
File dir_fd;
int res= 0;
const char *correct_dir_name;
@@ -124,10 +124,14 @@ int my_sync_dir(const char *dir_name, my
else
res= 1;
DBUG_RETURN(res);
-#else
+}
+#else /* NEED_EXPLICIT_SYNC_DIR */
+int my_sync_dir(const char *dir_name __attribute__((unused)),
+ myf my_flags __attribute__((unused)))
+{
return 0;
-#endif
}
+#endif /* NEED_EXPLICIT_SYNC_DIR */
/*
@@ -141,15 +145,18 @@ int my_sync_dir(const char *dir_name, my
RETURN
0 if ok, !=0 if error
*/
+#ifdef NEED_EXPLICIT_SYNC_DIR
int my_sync_dir_by_file(const char *file_name, myf my_flags)
{
-#ifdef NEED_EXPLICIT_SYNC_DIR
char dir_name[FN_REFLEN];
size_t dir_name_length;
dirname_part(dir_name, file_name, &dir_name_length);
return my_sync_dir(dir_name, my_flags);
-#else
+}
+#else /* NEED_EXPLICIT_SYNC_DIR */
+int my_sync_dir_by_file(const char *file_name __attribute__((unused)),
+ myf my_flags __attribute__((unused)))
+{
return 0;
-#endif
}
-
+#endif /* NEED_EXPLICIT_SYNC_DIR */
=== modified file 'sql/derror.cc'
--- a/sql/derror.cc 2010-07-08 21:20:08 +0000
+++ b/sql/derror.cc 2010-09-02 18:37:04 +0000
@@ -35,6 +35,8 @@ static void init_myfunc_errs(void);
C_MODE_START
static const char **get_server_errmsgs()
{
+ if (!current_thd)
+ return DEFAULT_ERRMSGS;
return CURRENT_THD_ERRMSGS;
}
C_MODE_END
=== modified file 'sql/item_timefunc.cc'
--- a/sql/item_timefunc.cc 2010-07-09 12:28:51 +0000
+++ b/sql/item_timefunc.cc 2010-09-07 06:45:00 +0000
@@ -3368,6 +3368,8 @@ void Item_func_str_to_date::fix_length_a
cached_field_type= MYSQL_TYPE_DATETIME;
max_length= MAX_DATETIME_FULL_WIDTH*MY_CHARSET_BIN_MB_MAXLEN;
cached_timestamp_type= MYSQL_TIMESTAMP_NONE;
+ sql_mode= (current_thd->variables.sql_mode &
+ (MODE_NO_ZERO_IN_DATE | MODE_NO_ZERO_DATE));
if ((const_item= args[1]->const_item()))
{
char format_buff[64];
@@ -3433,6 +3435,14 @@ bool Item_func_str_to_date::get_date(MYS
return 0;
null_date:
+ if (fuzzy_date & TIME_NO_ZERO_DATE)
+ {
+ char buff[128];
+ strmake(buff, val->ptr(), min(val->length(), sizeof(buff)-1));
+ push_warning_printf(current_thd, MYSQL_ERROR::WARN_LEVEL_WARN,
+ ER_WRONG_VALUE_FOR_TYPE, ER(ER_WRONG_VALUE_FOR_TYPE),
+ "datetime", buff, "str_to_date");
+ }
return (null_value=1);
}
@@ -3442,7 +3452,7 @@ String *Item_func_str_to_date::val_str(S
DBUG_ASSERT(fixed == 1);
MYSQL_TIME ltime;
- if (Item_func_str_to_date::get_date(<ime, TIME_FUZZY_DATE))
+ if (Item_func_str_to_date::get_date(<ime, TIME_FUZZY_DATE | sql_mode))
return 0;
if (!make_datetime((const_item ? cached_format_type :
@@ -3453,6 +3463,29 @@ String *Item_func_str_to_date::val_str(S
}
+longlong Item_func_str_to_date::val_int()
+{
+ DBUG_ASSERT(fixed == 1);
+ MYSQL_TIME ltime;
+
+ if (Item_func_str_to_date::get_date(<ime, TIME_FUZZY_DATE | sql_mode))
+ return 0;
+
+ if (const_item)
+ {
+ switch (cached_field_type) {
+ case MYSQL_TYPE_DATE:
+ return TIME_to_ulonglong_date(<ime);
+ case MYSQL_TYPE_TIME:
+ return TIME_to_ulonglong_time(<ime);
+ default:
+ return TIME_to_ulonglong_datetime(<ime);
+ }
+ }
+ return TIME_to_ulonglong_datetime(<ime);
+}
+
+
bool Item_func_last_day::get_date(MYSQL_TIME *ltime, uint fuzzy_date)
{
if (get_arg0_date(ltime, fuzzy_date & ~TIME_FUZZY_DATE) ||
=== modified file 'sql/item_timefunc.h'
--- a/sql/item_timefunc.h 2010-08-16 07:11:57 +0000
+++ b/sql/item_timefunc.h 2010-09-09 12:02:02 +0000
@@ -1039,6 +1039,7 @@ class Item_func_str_to_date :public Item
date_time_format_types cached_format_type;
timestamp_type cached_timestamp_type;
bool const_item;
+ ulonglong sql_mode;
public:
Item_func_str_to_date(Item *a, Item *b)
:Item_str_func(a, b), const_item(false)
@@ -1052,6 +1053,8 @@ public:
{
return tmp_table_field_from_field_type(table, 1);
}
+ longlong val_int();
+ bool result_as_longlong() { return TRUE; }
};
=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc 2010-08-30 14:07:40 +0000
+++ b/sql/mysqld.cc 2010-09-02 18:37:04 +0000
@@ -1486,6 +1486,7 @@ void clean_up(bool print_message)
cleanup_errmsgs();
MYSQL_CALLBACK(thread_scheduler, end, ());
finish_client_errs();
+ (void) my_error_unregister(ER_ERROR_FIRST, ER_ERROR_LAST); // finish server errs
DBUG_PRINT("quit", ("Error messages freed"));
/* Tell main we are ready */
logger.cleanup_end();
=== modified file 'sql/set_var.cc'
--- a/sql/set_var.cc 2010-08-26 00:59:28 +0000
+++ b/sql/set_var.cc 2010-09-02 18:37:04 +0000
@@ -108,7 +108,7 @@ void sys_var_end()
my_hash_free(&system_variable_hash);
for (sys_var *var=all_sys_vars.first; var; var= var->next)
- var->~sys_var();
+ var->cleanup();
DBUG_VOID_RETURN;
}
=== modified file 'sql/set_var.h'
--- a/sql/set_var.h 2010-07-23 20:13:36 +0000
+++ b/sql/set_var.h 2010-09-09 12:37:09 +0000
@@ -91,11 +91,13 @@ public:
longlong def_val, PolyLock *lock, enum binlog_status_enum binlog_status_arg,
on_check_function on_check_func, on_update_function on_update_func,
uint deprecated_version, const char *substitute, int parse_flag);
+
+ virtual ~sys_var() {}
+
/**
- The instance should only be destroyed on shutdown, as it doesn't unlink
- itself from the chain.
+ All the cleanup procedures should be performed here
*/
- virtual ~sys_var() {}
+ virtual void cleanup() {}
/**
downcast for sys_var_pluginvar. Returns this if it's an instance
of sys_var_pluginvar, and 0 otherwise.
=== modified file 'sql/sys_vars.h'
--- a/sql/sys_vars.h 2010-08-05 12:34:19 +0000
+++ b/sql/sys_vars.h 2010-09-02 18:37:04 +0000
@@ -385,7 +385,7 @@ public:
DBUG_ASSERT(scope() == GLOBAL);
DBUG_ASSERT(size == sizeof(char *));
}
- ~Sys_var_charptr()
+ void cleanup()
{
if (flags & ALLOCATED)
my_free(global_var(char*));
Attachment: [text/bzr-bundle] bzr/marc.alff@oracle.com-20100909152655-sfg9zyasx41oq9b1.bundle
| Thread |
|---|
| • bzr commit into mysql-5.5-bugfixing branch (marc.alff:3204) | Marc Alff | 9 Sep |