List:Commits« Previous MessageNext Message »
From:Andrei Elkin Date:March 10 2006 2:48pm
Subject:bk commit into 5.0 tree (aelkin:1.2084) BUG#12562
View as plain text  
Below is the list of changes that have just been committed into a local
5.0 repository of elkin. When elkin does a push these changes will
be propagated to the main repository and, within 24 hours after the
push, to the public repository.
For information on how to access the public repository
see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html

ChangeSet
  1.2084 06/03/10 16:47:56 aelkin@stripped +6 -0
  BUG#15101 SYSDATE() disregards SET TIMESTAMP. 
  
     After the ChangeSet 1.1892.20.1 2005/08/24 (Bug #12562) SYSDATE() is not an alias
     of NOW() and is unsafe for replication.
     `SYSDATE()' backward compatible aliasing clashes with the idea #12562 
     fix. To make it safe-replicatable we have to either use RBR or to restore
     the pre-5.0 style.
     --sysdate-is-now command line flag was introduced to provide backward compatibility.

  mysql-test/t/sysdate_is_now.test
    1.1 06/03/10 16:47:45 aelkin@stripped +11 -0
    New BitKeeper file ``mysql-test/t/sysdate_is_now.test''

  mysql-test/t/sysdate_is_now.test
    1.0 06/03/10 16:47:45 aelkin@stripped +0 -0
    BitKeeper file /usr_rh9/home/elkin.rh9/MySQL/FIXES/5.0.20-bug15101-sysdate/mysql-test/t/sysdate_is_now.test

  mysql-test/t/sysdate_is_now-master.opt
    1.1 06/03/10 16:47:44 aelkin@stripped +1 -0
    New BitKeeper file ``mysql-test/t/sysdate_is_now-master.opt''

  mysql-test/r/sysdate_is_now.result
    1.1 06/03/10 16:47:44 aelkin@stripped +4 -0
    New BitKeeper file ``mysql-test/r/sysdate_is_now.result''

  mysql-test/t/sysdate_is_now-master.opt
    1.0 06/03/10 16:47:44 aelkin@stripped +0 -0
    BitKeeper file /usr_rh9/home/elkin.rh9/MySQL/FIXES/5.0.20-bug15101-sysdate/mysql-test/t/sysdate_is_now-master.opt

  mysql-test/r/sysdate_is_now.result
    1.0 06/03/10 16:47:44 aelkin@stripped +0 -0
    BitKeeper file /usr_rh9/home/elkin.rh9/MySQL/FIXES/5.0.20-bug15101-sysdate/mysql-test/r/sysdate_is_now.result

  sql/sql_yacc.yy
    1.461 06/03/10 16:47:43 aelkin@stripped +12 -2
    calling NOW's branches when --sysdate-is-now

  sql/sql_class.h
    1.283 06/03/10 16:47:43 aelkin@stripped +1 -0
    new slot to fill at init time and check at parse

  sql/mysqld.cc
    1.538 06/03/10 16:47:43 aelkin@stripped +5 -0
    New option to force SYSDATE's backward compatible with 4.1 aliasing to NOW (not default)

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# User:	aelkin
# Host:	dsl-hkigw8-feb0de00-199.dhcp.inet.fi
# Root:	/usr_rh9/home/elkin.rh9/MySQL/FIXES/5.0.20-bug15101-sysdate

--- 1.537/sql/mysqld.cc	2006-03-10 02:44:01 +02:00
+++ 1.538/sql/mysqld.cc	2006-03-10 16:47:43 +02:00
@@ -4578,6 +4578,7 @@
   OPT_DATETIME_FORMAT,
   OPT_LOG_QUERIES_NOT_USING_INDEXES,
   OPT_DEFAULT_TIME_ZONE,
+  OPT_SYSDATE_IS_NOW,
   OPT_OPTIMIZER_SEARCH_DEPTH,
   OPT_OPTIMIZER_PRUNE_LEVEL,
   OPT_UPDATABLE_VIEWS_WITH_LIMIT,
@@ -5935,6 +5936,10 @@
    (gptr*) &max_system_variables.net_wait_timeout, 0, GET_ULONG,
    REQUIRED_ARG, NET_WAIT_TIMEOUT, 1, IF_WIN(INT_MAX32/1000, LONG_TIMEOUT),
    0, 1, 0},
+  {"sysdate-is-now", OPT_SYSDATE_IS_NOW,
+   "Non-default flag to alias SYSDATE() to NOW() to be safe-replicatable. Since 5.0 SYSDATE returns a `dynamic' value different for different invocation even within a query",
+   (gptr*) &global_system_variables.sysdate_is_now,
+   0, 0, GET_BOOL, NO_ARG, 0, 0, 1, 0, 1, 0},
   {0, 0, 0, 0, 0, 0, GET_NO_ARG, NO_ARG, 0, 0, 0, 0, 0, 0}
 };
 

--- 1.282/sql/sql_class.h	2006-02-25 17:46:26 +02:00
+++ 1.283/sql/sql_class.h	2006-03-10 16:47:43 +02:00
@@ -585,6 +585,7 @@
   DATE_TIME_FORMAT *date_format;
   DATE_TIME_FORMAT *datetime_format;
   DATE_TIME_FORMAT *time_format;
+  my_bool sysdate_is_now;
 };
 
 

--- 1.460/sql/sql_yacc.yy	2006-03-07 13:24:18 +02:00
+++ 1.461/sql/sql_yacc.yy	2006-03-10 16:47:43 +02:00
@@ -4671,9 +4671,19 @@
 	| SUBSTRING_INDEX '(' expr ',' expr ',' expr ')'
 	  { $$= new Item_func_substr_index($3,$5,$7); }
 	| SYSDATE optional_braces
-	  { $$= new Item_func_sysdate_local(); Lex->safe_to_cache_query=0;}
+          {
+            if (global_system_variables.sysdate_is_now == 0)
+              $$= new Item_func_sysdate_local();
+            else $$= new Item_func_now_local();
+            Lex->safe_to_cache_query=0;
+          }
 	| SYSDATE '(' expr ')'
-	  { $$= new Item_func_sysdate_local($3); Lex->safe_to_cache_query=0;}
+          {
+            if (global_system_variables.sysdate_is_now == 0)
+              $$= new Item_func_sysdate_local($3);
+            else $$= new Item_func_now_local($3);
+            Lex->safe_to_cache_query=0;
+          }
 	| TIME_SYM '(' expr ')'
 	  { $$= new Item_time_typecast($3); }
 	| TIMESTAMP '(' expr ')'
--- New file ---
+++ mysql-test/r/sysdate_is_now.result	06/03/10 16:47:44
set timestamp=1;
SELECT sleep(1),NOW()-SYSDATE() as zero;
sleep(1)	zero
0	0

--- New file ---
+++ mysql-test/t/sysdate_is_now-master.opt	06/03/10 16:47:44
--sysdate-is-now

--- New file ---
+++ mysql-test/t/sysdate_is_now.test	06/03/10 16:47:45
#
# BUG#15101 restore aliasing of SYSDATE to NOW in 5.0
# this feature is activated via --sysdate-is-now mysqld init opt
#
# To test here
# 1. SYSDATE() does not distiguish from NOW()
# 2. SYSDATE() obeys set timestamp

set timestamp=1;
SELECT sleep(1),NOW()-SYSDATE() as zero;
# End of 5.0 tests

Thread
bk commit into 5.0 tree (aelkin:1.2084) BUG#12562Andrei Elkin10 Mar