diff --git a/mysql-test/r/timestamp_func.result b/mysql-test/r/timestamp_func.result index ed51cec422719538cba350f109a5e023aad44eff..1b49331c069f9ac1bb30da8f1c93ea178be6be37 100644 --- a/mysql-test/r/timestamp_func.result +++ b/mysql-test/r/timestamp_func.result @@ -1,33 +1,25 @@ -** Setup ** - -** Connecting con0 using root ** ** Connecting con1 using root ** -'#-----------------------------FN_DYNVARS_179_01------------------#' -** Connection con0 ** -SET @ts_old = @@SESSION.timestamp; -waiting 1 sec -SET @ts_new = @@SESSION.timestamp; -SELECT @ts_new - @ts_old >= 1 AS 'Timestamp Difference'; -Timestamp Difference +SELECT date(now()) = date(sysdate()); +date(now()) = date(sysdate()) +1 +SET @@session.timestamp = 1100000000; +SELECT date(now()) != date(sysdate()); +date(now()) != date(sysdate()) +1 +** Connecting con0 using root ** +SELECT @@session.timestamp != 1100000000; +@@session.timestamp != 1100000000 +1 +SET @@session.timestamp = 1000000000; +SELECT date(now()) != date(sysdate()); +date(now()) != date(sysdate()) 1 -1 means >=1 expected is true ** Connection con1 ** -SET @ts_old = @@SESSION.timestamp; -waiting 4 sec -SET @ts_new = @@SESSION.timestamp; -SELECT @ts_new - @ts_old >= 4 AS 'Timestamp Difference'; -Timestamp Difference +SELECT @@session.timestamp != 1000000000; +@@session.timestamp != 1000000000 1 -1 means >=4 expected is true -'#-----------------------------FN_DYNVARS_179_02---------------------#' -SET @ts_old = @@SESSION.timestamp; -Changing time zone -SET time_zone = 'MET'; -SET @ts_new = @@SESSION.timestamp; -SELECT @ts_new - @ts_old >= 1 AS 'Timestamp Difference'; -Timestamp Difference +SELECT @@session.timestamp = 1100000000; +@@session.timestamp = 1100000000 1 -1 means >=1 expected is true -** Cleanup ** ** Connection default ** Disconnecting Connections con0, con1 diff --git a/mysql-test/r/timestamp_sysdate_is_now_func.result b/mysql-test/r/timestamp_sysdate_is_now_func.result new file mode 100644 index 0000000000000000000000000000000000000000..e24ff2e962ab98b26f4f9b6913b29e0973df8fa4 --- /dev/null +++ b/mysql-test/r/timestamp_sysdate_is_now_func.result @@ -0,0 +1,25 @@ +** Connecting con1 using root ** +SELECT date(now()) = date(sysdate()); +date(now()) = date(sysdate()) +1 +SET @@session.timestamp = 1100000000; +SELECT date(now()) != date(sysdate()); +date(now()) != date(sysdate()) +0 +** Connecting con0 using root ** +SELECT @@session.timestamp != 1100000000; +@@session.timestamp != 1100000000 +1 +SET @@session.timestamp = 1000000000; +SELECT date(now()) != date(sysdate()); +date(now()) != date(sysdate()) +0 +** Connection con1 ** +SELECT @@session.timestamp != 1000000000; +@@session.timestamp != 1000000000 +1 +SELECT @@session.timestamp = 1100000000; +@@session.timestamp = 1100000000 +1 +** Connection default ** +Disconnecting Connections con0, con1 diff --git a/mysql-test/t/timestamp_func.test b/mysql-test/t/timestamp_func.test index ecca3c7daeb9771f5e02efcfe425a4c79e02b548..e119f1b6253b96047f58786fa876eca19644cf63 100644 --- a/mysql-test/t/timestamp_func.test +++ b/mysql-test/t/timestamp_func.test @@ -9,6 +9,8 @@ # Creation Date: 2008-02-25 # # Author: Sharique Abdullah # # # +# Modified: HHunger 2008-08-28 Reimplemented the test completely. # +# # # Description: Test Cases of Dynamic System Variable "timestamp" # # that checks behavior of this variable in the following ways # # * Functionality based on different values # @@ -17,63 +19,32 @@ # # ############################################################################ ---echo ** Setup ** ---echo -# -# Setup -# ---echo ** Connecting con0 using root ** -connect (con0,localhost,root,,); ---echo ** Connecting con1 using root ** -connect (con1, localhost, root,,); - ---echo '#-----------------------------FN_DYNVARS_179_01------------------#' -# -# Checking for connection 1 -# +# Change timestamp which must have an effect on now(), but not on sysdate(). +# Use Unix epoch timestamp +# All comparisons must deliver true(1) +# Exception: --sysdate-is-now switches off this behaviour and must not be set. ---echo ** Connection con0 ** -connection con0; -SET @ts_old = @@SESSION.timestamp; ---echo waiting 1 sec ---sleep 1 -SET @ts_new = @@SESSION.timestamp; -SELECT @ts_new - @ts_old >= 1 AS 'Timestamp Difference'; ---echo 1 means >=1 expected is true +--echo ** Connecting con1 using root ** +connect (con1,localhost,root,,); +SELECT date(now()) = date(sysdate()); +SET @@session.timestamp = 1100000000; +SELECT date(now()) != date(sysdate()); +# Assure that setting of the variable has no effect on other session. +--echo ** Connecting con0 using root ** +connect (con0,localhost,root,,); +SELECT @@session.timestamp != 1100000000; +SET @@session.timestamp = 1000000000; +SELECT date(now()) != date(sysdate()); -# -# Checking for connection 2 -# --echo ** Connection con1 ** connection con1; -SET @ts_old = @@SESSION.timestamp; ---echo waiting 4 sec ---sleep 4 -SET @ts_new = @@SESSION.timestamp; -SELECT @ts_new - @ts_old >= 4 AS 'Timestamp Difference'; ---echo 1 means >=4 expected is true - ---echo '#-----------------------------FN_DYNVARS_179_02---------------------#' -# -# Testing timezone change effect -# - -SET @ts_old = @@SESSION.timestamp; ---sleep 1 ---echo Changing time zone -SET time_zone = 'MET'; -SET @ts_new = @@SESSION.timestamp; -SELECT @ts_new - @ts_old >= 1 AS 'Timestamp Difference'; ---echo 1 means >=1 expected is true - -# -# Cleanup -# ---echo ** Cleanup ** +SELECT @@session.timestamp != 1000000000; +SELECT @@session.timestamp = 1100000000; --echo ** Connection default ** connection default; --echo Disconnecting Connections con0, con1 disconnect con0; disconnect con1; + diff --git a/mysql-test/t/timestamp_sysdate_is_now_func-master.opt b/mysql-test/t/timestamp_sysdate_is_now_func-master.opt new file mode 100644 index 0000000000000000000000000000000000000000..97a58d2803287e0cfb25f3472ca34f4864b075c7 --- /dev/null +++ b/mysql-test/t/timestamp_sysdate_is_now_func-master.opt @@ -0,0 +1 @@ +--sysdate-is-now diff --git a/mysql-test/t/timestamp_sysdate_is_now_func.test b/mysql-test/t/timestamp_sysdate_is_now_func.test new file mode 100644 index 0000000000000000000000000000000000000000..7ca3b4cddac7674d5630286951a6bce446feff6d --- /dev/null +++ b/mysql-test/t/timestamp_sysdate_is_now_func.test @@ -0,0 +1,47 @@ +############################################################################ +# # +# Variable Name: timestamp with sysdate-is-now # +# Scope: GLOBAL # +# Access Type: Dynamic # +# Data Type: INTEGER # +# # +# # +# Creation Date: 2008-11-25 # +# Author: Horst Hunger # +# # +# Description: Test Cases of Dynamic System Variable "timestamp" # +# that checks behavior of this variable in the following ways # +# * Like timstamp_func, but with set "sysdate-is-now". # +# # +# Reference: http://dev.mysql.com/doc/refman/5.1/en/set-option.html # +# # +############################################################################ + +# Use Unix epoch timestamp +# Due to "--sysdate-is-now" timestamp must have an effect on both. +# See also timestamp_func.test. + +--echo ** Connecting con1 using root ** +connect (con1,localhost,root,,); +SELECT date(now()) = date(sysdate()); +SET @@session.timestamp = 1100000000; +SELECT date(now()) != date(sysdate()); + +# Assure that setting of the variable has no effect on other session. +--echo ** Connecting con0 using root ** +connect (con0,localhost,root,,); +SELECT @@session.timestamp != 1100000000; +SET @@session.timestamp = 1000000000; +SELECT date(now()) != date(sysdate()); + +--echo ** Connection con1 ** +connection con1; +SELECT @@session.timestamp != 1000000000; +SELECT @@session.timestamp = 1100000000; + +--echo ** Connection default ** +connection default; +--echo Disconnecting Connections con0, con1 +disconnect con0; +disconnect con1; +