1
################## mysql-test\t\timestamp_basic.test ##########################
3
# Variable Name: timestamp #
5
# Access Type: Dynamic #
11
# Creation Date: 2008-02-07 #
14
# Description: Test Cases of Dynamic System Variable timestamp #
15
# that checks the behavior of this variable in the following ways#
17
# * Valid & Invalid values #
18
# * Scope & Access method #
21
# Reference: http://dev.mysql.com/doc/refman/5.1/en/ #
22
# server-system-variables.html #
24
###############################################################################
26
--source include/load_sysvars.inc
28
#######################################################################
29
# START OF timestamp TESTS #
30
#######################################################################
33
#######################################################################
34
# Saving initial value of timestamp in a temporary variable #
35
#######################################################################
37
SET @session_start_value = @@session.timestamp;
39
--echo '#--------------------FN_DYNVARS_001_01------------------------#'
40
########################################################################
41
# Display the DEFAULT value of timestamp #
42
########################################################################
45
SET @@timestamp = DEFAULT;
48
--echo 'timestamp does not have any DEFAULT value'
50
--echo '#---------------------FN_DYNVARS_001_02-------------------------#'
51
##############################################################
52
# see if accessable using global scope #
53
##############################################################
55
--Error ER_LOCAL_VARIABLE
56
SET @@global.timestamp = "1000";
59
--echo '#--------------------FN_DYNVARS_001_03------------------------#'
60
########################################################################
61
# Change the value of timestamp to a valid value #
62
########################################################################
67
--echo 'Setting 0 resets timestamp to session default timestamp'
69
SET @@timestamp = 123456789123456;
71
SET @@timestamp = 60*60*60*60*365;
73
SET @@timestamp = -1000000000;
76
SET @temp_ts = @@timestamp - @@timestamp;
79
--echo '#--------------------FN_DYNVARS_001_04-------------------------#'
80
###########################################################################
81
# Change the value of timestamp to invalid value #
82
###########################################################################
85
--Error ER_WRONG_TYPE_FOR_VAR
86
SET @@timestamp = "100";
87
--echo 'Bug# 34836: Documentation says its a string variable but infact its numeric'
89
--Error ER_WRONG_TYPE_FOR_VAR
90
SET @@timestamp = " ";
92
--Error ER_WRONG_TYPE_FOR_VAR
93
SET @@timestamp = 1.1;
95
--Error ER_WRONG_TYPE_FOR_VAR
96
SET @@timestamp = 9999999999999999999999;
100
--echo '#----------------------FN_DYNVARS_001_06------------------------#'
101
#########################################################################
102
# Check if the value in SESSION Table matches value in variable #
103
#########################################################################
105
SELECT @@timestamp = VARIABLE_VALUE
106
FROM INFORMATION_SCHEMA.SESSION_VARIABLES
107
WHERE VARIABLE_NAME='timestamp';
109
--echo '#---------------------FN_DYNVARS_001_08-------------------------#'
110
#############################################################################
111
# Check if ON, OFF, TRUE and FALSE values can be used on variable #
112
#############################################################################
113
--Error ER_WRONG_TYPE_FOR_VAR
114
SET @@timestamp = OFF;
116
--Error ER_WRONG_TYPE_FOR_VAR
117
SET @@timestamp = ON;
119
SET @@timestamp = TRUE;
122
SET @@timestamp = FALSE;
127
--echo '#---------------------FN_DYNVARS_001_10----------------------#'
128
#############################################################################
129
# Check if accessing variable with SESSION,LOCAL and without SCOPE points
130
# to same session variable
131
#############################################################################
133
SET @@timestamp = 123456;
134
SELECT @@timestamp = @@local.timestamp and @@timestamp = @@session.timestamp;
135
SET @@timestamp = 654321;
136
SELECT @@timestamp = @@local.timestamp and @@timestamp = @@session.timestamp;
139
--echo '#---------------------FN_DYNVARS_001_11----------------------#'
140
#####################################################################
141
# Check if timestamp can be accessed with and without @@ sign #
142
#####################################################################
146
--Error ER_UNKNOWN_TABLE
147
SELECT local.timestamp;
148
--Error ER_UNKNOWN_TABLE
149
SELECT session.timestamp;
150
--Error ER_BAD_FIELD_ERROR
151
SELECT timestamp = @@session.timestamp;
153
##############################
154
# Restore initial value #
155
##############################
157
SET @@timestamp = @session_start_value;
159
#######################################################################
160
# END OF timestamp TESTS #
161
#######################################################################