| 1 |
################# mysql-test\t\general_log_func.test ########################### |
| 2 |
# # |
| 3 |
# Variable Name: general_log # |
| 4 |
# Scope: GLOBAL # |
| 5 |
# Access Type: Dynamic # |
| 6 |
# Data Type: Boolean # |
| 7 |
# Default Value: OFF # |
| 8 |
# Valid Values: ON, OFF # |
| 9 |
# # |
| 10 |
# # |
| 11 |
# Creation Date: 2008-03-17 # |
| 12 |
# Author: Salman Rawala # |
| 13 |
# # |
| 14 |
# Description: Test Cases of Dynamic System Variable "general_log" # |
| 15 |
# that checks functionality of this variable # |
| 16 |
# # |
| 17 |
# Reference: http://dev.mysql.com/doc/refman/5.1/en/ # |
| 18 |
# server-system-variables.html#option_mysqld_general_log # |
| 19 |
# # |
| 20 |
################################################################################ |
| 21 |
|
| 22 |
|
| 23 |
--disable_warnings |
| 24 |
drop table if exists t1; |
| 25 |
--enable_warnings |
| 26 |
|
| 27 |
######################### |
| 28 |
# Creating new table # |
| 29 |
######################### |
| 30 |
|
| 31 |
--echo ## Creating new table ## |
| 32 |
CREATE TABLE t1 |
| 33 |
( |
| 34 |
id INT NOT NULL auto_increment, |
| 35 |
PRIMARY KEY (id), |
| 36 |
name VARCHAR(30) |
| 37 |
); |
| 38 |
|
| 39 |
--echo '#--------------------FN_DYNVARS_018_01-------------------------#' |
| 40 |
#################################################################### |
| 41 |
# Setting initial value of general_log to OFF and verifying |
| 42 |
# its behavior |
| 43 |
#################################################################### |
| 44 |
|
| 45 |
--echo ## Setting initial value of variable to OFF ## |
| 46 |
SET @@global.general_log = OFF; |
| 47 |
SELECT @@general_log; |
| 48 |
|
| 49 |
let $MYSQLD_LOGFILE= `select @@global.general_log_file`; |
| 50 |
|
| 51 |
# |
| 52 |
# truncate the existing log - it could be larger than max_allowed_packet |
| 53 |
# and that would cause load_file() below to fail |
| 54 |
# |
| 55 |
--remove_file $MYSQLD_LOGFILE |
| 56 |
flush logs; |
| 57 |
SET @@global.general_log = ON; |
| 58 |
flush logs; |
| 59 |
SET @@global.general_log = OFF; |
| 60 |
|
| 61 |
--copy_file $MYSQLD_LOGFILE $MYSQLD_LOGFILE.copy |
| 62 |
|
| 63 |
--echo ## Inserting some Records & Verifying output in log ## |
| 64 |
INSERT into t1(name) values('Record_1'); |
| 65 |
INSERT into t1(name) values('Record_2'); |
| 66 |
|
| 67 |
--echo ## There should be no difference, case should pass ## |
| 68 |
--diff_files $MYSQLD_LOGFILE $MYSQLD_LOGFILE.copy |
| 69 |
--remove_file $MYSQLD_LOGFILE.copy |
| 70 |
|
| 71 |
--echo '#--------------------FN_DYNVARS_018_01-------------------------#' |
| 72 |
#################################################################### |
| 73 |
# Setting initial value of general_log to ON and verifying |
| 74 |
# its behavior |
| 75 |
#################################################################### |
| 76 |
|
| 77 |
--echo ## Setting initial value of variable to OFF ## |
| 78 |
SET @@global.general_log = ON; |
| 79 |
SELECT @@general_log; |
| 80 |
|
| 81 |
--copy_file $MYSQLD_LOGFILE $MYSQLD_LOGFILE.copy |
| 82 |
--chmod 0777 $MYSQLD_LOGFILE.copy |
| 83 |
|
| 84 |
--echo ## Inserting some Records & Verifying output in log ## |
| 85 |
INSERT into t1(name) values('Record_3'); |
| 86 |
INSERT into t1(name) values('Record_4'); |
| 87 |
|
| 88 |
--copy_file $MYSQLD_LOGFILE $MYSQLD_LOGFILE.orig |
| 89 |
--chmod 0777 $MYSQLD_LOGFILE.orig |
| 90 |
|
| 91 |
--echo ## old log is a proper prefix of the new log ## |
| 92 |
--replace_result $MYSQLD_LOGFILE MYSQLD_LOGFILE |
| 93 |
eval SET @orig_file= load_file('$MYSQLD_LOGFILE.orig'); |
| 94 |
--replace_result $MYSQLD_LOGFILE MYSQLD_LOGFILE |
| 95 |
eval SET @copy_file= load_file('$MYSQLD_LOGFILE.copy'); |
| 96 |
SELECT @orig_file > @copy_file, left(@orig_file, length(@copy_file)) = @copy_file; |
| 97 |
--remove_file $MYSQLD_LOGFILE.copy |
| 98 |
--remove_file $MYSQLD_LOGFILE.orig |
| 99 |
|
| 100 |
--echo ## Dropping tables ## |
| 101 |
DROP TABLE t1; |
| 102 |
|