1
0
mirror of https://github.com/MariaDB/server.git synced 2025-09-03 20:43:11 +03:00
Files
mariadb/mysql-test/suite/sys_vars/t/read_only_basic.test
Staale Smedseng 5eb71aca21 This is a backport of the two patches for Bug #28299:
To-number conversion warnings work differenly with CHAR 
and VARCHAR sp variables.

The original revision-IDs are:
  staale.smedseng@sun.com-20081124095339-2qdvzkp0rn1ljs30
  staale.smedseng@sun.com-20081125104611-rtxic5d12e83ag2o
                                                
The patch provides ER_TRUNCATED_WRONG_VALUE warning messages
for conversion of VARCHAR to numberic values, in line with
messages provided for CHAR conversions. Conversions are
checked for success, and the message is emitted in case
failure.
                                                
The tests are amended to accept the added warning messages,
and explicit conversion of ON/OFF values is added for
statements checking system variables. In test
rpl.rpl_switch_stm_row_mixed checking for warnings is
temporarily disabled for one statement, as this generates
warning messages for strings that vary between executions.
2009-10-09 15:34:07 +02:00

174 lines
6.9 KiB
Plaintext

############## mysql-test\t\read_only_basic.test ###############
# #
# Variable Name: read_only #
# Scope: GLOBAL #
# Access Type: Dynamic #
# Data Type: numeric #
# Default Value: 0 #
# Range: - #
# #
# #
# Creation Date: 2008-02-07 #
# Author: Salman #
# #
# Description: Test Cases of Dynamic System Variable read_only #
# that checks the behavior of this variable in the following ways#
# * Default Value #
# * Valid & Invalid values #
# * Scope & Access method #
# * Data Integrity #
# #
# Reference: http://dev.mysql.com/doc/refman/5.1/en/ #
# server-system-variables.html #
# #
###############################################################################
--source include/load_sysvars.inc
################################################################
# START OF read_only TESTS #
################################################################
################################################################
# Saving initial value of read_only in a temporary variable #
################################################################
SET @start_value = @@global.read_only;
SELECT @start_value;
--echo '#--------------------FN_DYNVARS_139_01------------------------#'
################################################################
# Display the DEFAULT value of read_only #
################################################################
SET @@global.read_only = 1;
SET @@global.read_only = DEFAULT;
SELECT @@global.read_only;
--echo '#---------------------FN_DYNVARS_139_02-------------------------#'
###############################################
# Verify default value of variable #
###############################################
SET @@global.read_only = @start_value;
SELECT @@global.read_only = 0;
--echo '#--------------------FN_DYNVARS_139_03------------------------#'
#################################################################
# Change the value of read_only to a valid value #
#################################################################
SET @@global.read_only = 0;
SELECT @@global.read_only;
SET @@global.read_only = 1;
SELECT @@global.read_only;
SET @@global.read_only = TRUE;
SELECT @@global.read_only;
SET @@global.read_only = FALSE;
SELECT @@global.read_only;
SET @@global.read_only = ON;
SELECT @@global.read_only;
SET @@global.read_only = OFF;
SELECT @@global.read_only;
--echo '#--------------------FN_DYNVARS_139_04-------------------------#'
####################################################################
# Change the value of read_only to invalid value #
####################################################################
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.read_only = -1;
SELECT @@global.read_only;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.read_only = 4294967296;
SELECT @@global.read_only;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.read_only = 10240022115;
SELECT @@global.read_only;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.read_only = 10000.01;
SELECT @@global.read_only;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.read_only = -1024;
SELECT @@global.read_only;
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.read_only = 42949672950;
SELECT @@global.read_only;
--echo 'Bug # 34837: Errors are not coming on assigning invalid values to variable';
--Error ER_WRONG_VALUE_FOR_VAR
SET @@global.read_only = 'test';
SELECT @@global.read_only;
--echo '#-------------------FN_DYNVARS_139_05----------------------------#'
####################################################################
# Test if accessing session read_only gives error #
####################################################################
--Error ER_GLOBAL_VARIABLE
SET @@session.read_only = 0;
SELECT @@read_only;
--echo '#----------------------FN_DYNVARS_139_06------------------------#'
##############################################################################
# Check if the value in GLOBAL & SESSION Tables matches values in variable #
##############################################################################
SELECT IF(@@global.read_only, "ON", "OFF") = VARIABLE_VALUE
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='read_only';
SELECT IF(@@read_only, "ON", "OFF") = VARIABLE_VALUE
FROM INFORMATION_SCHEMA.SESSION_VARIABLES
WHERE VARIABLE_NAME='read_only';
--echo '#---------------------FN_DYNVARS_139_07----------------------#'
########################################################################################################
# Check if accessing variable with SESSION,LOCAL and without SCOPE points to same session variable #
########################################################################################################
SET @@global.read_only = 1;
SELECT @@read_only = @@global.read_only;
--echo '#---------------------FN_DYNVARS_139_08----------------------#'
###################################################################
# Check if read_only can be accessed with and without @@ sign #
###################################################################
--Error ER_GLOBAL_VARIABLE
SET read_only = 1;
SELECT @@read_only;
--Error ER_PARSE_ERROR
SET local.read_only = 1;
--Error ER_UNKNOWN_TABLE
SELECT local.read_only;
--Error ER_PARSE_ERROR
SET global.read_only = 1;
--Error ER_UNKNOWN_TABLE
SELECT global.read_only;
--Error ER_BAD_FIELD_ERROR
SELECT read_only = @@session.read_only;
##############################
# Restore initial value #
##############################
SET @@global.read_only = @start_value;
SELECT @@global.read_only;
#################################################################
# END OF read_only TESTS #
#################################################################