| 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: # |
| 22 |
# http://dev.mysql.com/doc/refman/5.1/en/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 FLOOR(@@timestamp) = UNIX_TIMESTAMP(); |
| 47 |
|
| 48 |
--echo '#---------------------FN_DYNVARS_001_02-------------------------#' |
| 49 |
############################################################## |
| 50 |
# see if accessable using global scope # |
| 51 |
############################################################## |
| 52 |
|
| 53 |
--Error ER_LOCAL_VARIABLE |
| 54 |
SET @@global.timestamp = "1000"; |
| 55 |
|
| 56 |
--echo '#--------------------FN_DYNVARS_001_03------------------------#' |
| 57 |
######################################################################## |
| 58 |
# Change the value of timestamp to a valid value # |
| 59 |
######################################################################## |
| 60 |
|
| 61 |
SET @@timestamp = 0; |
| 62 |
SELECT FLOOR(@@timestamp) = UNIX_TIMESTAMP(); |
| 63 |
|
| 64 |
--echo 'Setting 0 resets timestamp to session default timestamp' |
| 65 |
|
| 66 |
SET @@timestamp = -1000000000; |
| 67 |
SELECT FLOOR(@@timestamp) = UNIX_TIMESTAMP(); |
| 68 |
|
| 69 |
SET @temp_ts = @@timestamp - @@timestamp; |
| 70 |
SELECT @temp_ts; |
| 71 |
|
| 72 |
--echo '#--------------------FN_DYNVARS_001_04-------------------------#' |
| 73 |
########################################################################### |
| 74 |
# Change the value of timestamp to invalid value # |
| 75 |
########################################################################### |
| 76 |
|
| 77 |
# for session scope |
| 78 |
--Error ER_WRONG_TYPE_FOR_VAR |
| 79 |
SET @@timestamp = "100"; |
| 80 |
|
| 81 |
--Error ER_WRONG_TYPE_FOR_VAR |
| 82 |
SET @@timestamp = " "; |
| 83 |
|
| 84 |
--Error ER_WRONG_VALUE_FOR_VAR |
| 85 |
SET @@timestamp = 9999999999999999999999; |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
--echo '#----------------------FN_DYNVARS_001_06------------------------#' |
| 90 |
######################################################################### |
| 91 |
# Check if the value in SESSION Table matches value in variable # |
| 92 |
######################################################################### |
| 93 |
|
| 94 |
# disabled due to bug#41584 |
| 95 |
#SELECT @@timestamp = VARIABLE_VALUE |
| 96 |
#FROM performance_schema.session_variables |
| 97 |
#WHERE VARIABLE_NAME='timestamp'; |
| 98 |
|
| 99 |
--echo '#---------------------FN_DYNVARS_001_08-------------------------#' |
| 100 |
############################################################################# |
| 101 |
# Check if ON, OFF, TRUE and FALSE values can be used on variable # |
| 102 |
############################################################################# |
| 103 |
--Error ER_WRONG_TYPE_FOR_VAR |
| 104 |
SET @@timestamp = OFF; |
| 105 |
|
| 106 |
--Error ER_WRONG_TYPE_FOR_VAR |
| 107 |
SET @@timestamp = ON; |
| 108 |
|
| 109 |
SET @@timestamp = TRUE; |
| 110 |
SELECT @@timestamp; |
| 111 |
|
| 112 |
SET @@timestamp = FALSE; |
| 113 |
#SELECT @@timestamp; |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
--echo '#---------------------FN_DYNVARS_001_10----------------------#' |
| 118 |
############################################################################# |
| 119 |
# Check if accessing variable with SESSION,LOCAL and without SCOPE points |
| 120 |
# to same session variable |
| 121 |
############################################################################# |
| 122 |
|
| 123 |
SET @@timestamp = 123456; |
| 124 |
SELECT @@timestamp = @@local.timestamp and @@timestamp = @@session.timestamp; |
| 125 |
SET @@timestamp = 654321; |
| 126 |
SELECT @@timestamp = @@local.timestamp and @@timestamp = @@session.timestamp; |
| 127 |
|
| 128 |
|
| 129 |
--echo '#---------------------FN_DYNVARS_001_11----------------------#' |
| 130 |
##################################################################### |
| 131 |
# Check if timestamp can be accessed with and without @@ sign # |
| 132 |
##################################################################### |
| 133 |
|
| 134 |
SET timestamp = 1; |
| 135 |
SELECT @@timestamp; |
| 136 |
--Error ER_UNKNOWN_TABLE |
| 137 |
SELECT local.timestamp; |
| 138 |
--Error ER_UNKNOWN_TABLE |
| 139 |
SELECT session.timestamp; |
| 140 |
--Error ER_BAD_FIELD_ERROR |
| 141 |
SELECT timestamp = @@session.timestamp; |
| 142 |
|
| 143 |
############################## |
| 144 |
# Restore initial value # |
| 145 |
############################## |
| 146 |
|
| 147 |
SET @@timestamp = @session_start_value; |
| 148 |
|
| 149 |
####################################################################### |
| 150 |
# END OF timestamp TESTS # |
| 151 |
####################################################################### |
| 152 |
|