~jlukas79/+junk/mysql-server

« back to all changes in this revision

Viewing changes to mysql-test/include/timestamp_basic.inc

manual merge 6.0-main --> 6.0-bka-review

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
################## mysql-test\t\timestamp_basic.test ##########################
 
2
#                                                                             #
 
3
# Variable Name: timestamp                                                    #
 
4
# Scope: SESSION                                                              #
 
5
# Access Type: Dynamic                                                        #
 
6
# Data Type: string                                                           #
 
7
# Default Value:                                                              #
 
8
# Range:                                                                      #
 
9
#                                                                             #
 
10
#                                                                             #
 
11
# Creation Date: 2008-02-07                                                   #
 
12
# Author:  Rizwan                                                             #
 
13
#                                                                             #
 
14
# Description: Test Cases of Dynamic System Variable timestamp                #
 
15
#              that checks the behavior of this variable in the following ways#
 
16
#              * Default Value                                                #
 
17
#              * Valid & Invalid values                                       #
 
18
#              * Scope & Access method                                        #
 
19
#              * Data Integrity                                               #
 
20
#                                                                             #
 
21
# Reference: http://dev.mysql.com/doc/refman/5.1/en/                          #
 
22
#  server-system-variables.html                                               #
 
23
#                                                                             #
 
24
###############################################################################
 
25
 
 
26
--source include/load_sysvars.inc
 
27
 
 
28
#######################################################################
 
29
#                    START OF timestamp TESTS                         #
 
30
#######################################################################
 
31
 
 
32
 
 
33
#######################################################################
 
34
#      Saving initial value of timestamp in a temporary variable      #
 
35
#######################################################################
 
36
 
 
37
SET @session_start_value = @@session.timestamp;
 
38
 
 
39
--echo '#--------------------FN_DYNVARS_001_01------------------------#'
 
40
########################################################################
 
41
#                    Display the DEFAULT value of timestamp            #
 
42
########################################################################
 
43
 
 
44
 
 
45
SET @@timestamp = DEFAULT;
 
46
#SELECT @@timestamp;
 
47
 
 
48
--echo 'timestamp does not have any DEFAULT value'
 
49
 
 
50
--echo '#---------------------FN_DYNVARS_001_02-------------------------#'
 
51
##############################################################
 
52
#     see if accessable using global scope                   #
 
53
##############################################################
 
54
 
 
55
--Error ER_LOCAL_VARIABLE
 
56
SET @@global.timestamp = "1000";
 
57
 
 
58
 
 
59
--echo '#--------------------FN_DYNVARS_001_03------------------------#'
 
60
######################################################################## 
 
61
#              Change the value of timestamp to a valid value          #
 
62
######################################################################## 
 
63
 
 
64
SET @@timestamp = 0;
 
65
#SELECT @@timestamp;
 
66
 
 
67
--echo 'Setting 0 resets timestamp to session default timestamp'
 
68
 
 
69
SET @@timestamp = 123456789123456;
 
70
SELECT @@timestamp;
 
71
SET @@timestamp = 60*60*60*60*365;
 
72
SELECT @@timestamp;
 
73
SET @@timestamp = -1000000000;
 
74
SELECT @@timestamp;
 
75
 
 
76
SET @temp_ts = @@timestamp - @@timestamp;
 
77
SELECT @temp_ts;
 
78
 
 
79
--echo '#--------------------FN_DYNVARS_001_04-------------------------#'
 
80
########################################################################### 
 
81
#               Change the value of timestamp to invalid value            #
 
82
########################################################################### 
 
83
 
 
84
# for session scope
 
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'
 
88
 
 
89
--Error ER_WRONG_TYPE_FOR_VAR
 
90
SET @@timestamp = " ";
 
91
 
 
92
--Error ER_WRONG_TYPE_FOR_VAR
 
93
SET @@timestamp = 1.1;
 
94
 
 
95
--Error ER_WRONG_TYPE_FOR_VAR
 
96
SET @@timestamp = 9999999999999999999999;
 
97
 
 
98
 
 
99
 
 
100
--echo '#----------------------FN_DYNVARS_001_06------------------------#'
 
101
######################################################################### 
 
102
#     Check if the value in SESSION Table matches value in variable     #
 
103
#########################################################################
 
104
 
 
105
SELECT @@timestamp = VARIABLE_VALUE 
 
106
FROM INFORMATION_SCHEMA.SESSION_VARIABLES 
 
107
WHERE VARIABLE_NAME='timestamp';
 
108
 
 
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;
 
115
 
 
116
--Error ER_WRONG_TYPE_FOR_VAR
 
117
SET @@timestamp = ON;
 
118
 
 
119
SET @@timestamp = TRUE;
 
120
SELECT @@timestamp;
 
121
 
 
122
SET @@timestamp = FALSE;
 
123
#SELECT @@timestamp;
 
124
 
 
125
 
 
126
 
 
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
#############################################################################
 
132
 
 
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;
 
137
 
 
138
 
 
139
--echo '#---------------------FN_DYNVARS_001_11----------------------#'
 
140
#####################################################################  
 
141
#   Check if timestamp can be accessed with and without @@ sign    #
 
142
#####################################################################
 
143
 
 
144
SET timestamp = 1;
 
145
SELECT @@timestamp;
 
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;
 
152
 
 
153
##############################  
 
154
#   Restore initial value    #
 
155
##############################
 
156
 
 
157
SET @@timestamp = @session_start_value;
 
158
 
 
159
#######################################################################
 
160
#                    END OF timestamp TESTS                           #
 
161
#######################################################################
 
162