403Webshell
Server IP : 172.67.216.182  /  Your IP : 172.70.143.180
Web Server : Apache
System : Linux krdc-ubuntu-s-2vcpu-4gb-amd-blr1-01.localdomain 5.15.0-142-generic #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025 x86_64
User : www ( 1000)
PHP Version : 7.4.33
Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /www/server/mysql/src/mysql-test/suite/innodb/t/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/server/mysql/src/mysql-test/suite/innodb/t/innodb-wl6445-2.test
######## suite/innodb/t/innodb-wl6445-2                     ##########
#                                                                    #
# Testcase for worklog WL#6445: InnoDB should be able to work with   #
# read-only tables
# All sub-test in this file focus on changinf file permission and    #
# restarting server in read only. It verifies necessary operations   #
# are blocked                                                        #
#                                                                    #
#                                                                    #
# Creation:                                                          #
# 2011-09-06 Implemented this test as part of WL#6445                #
#                                                                    #
######################################################################

# Not supported in embedded
--source include/not_embedded.inc
--source include/no_valgrind_without_big.inc

-- source include/have_innodb.inc
# *nix specific command to remove write permission
# wanted to use perl to save original permission of file and restore back after
# chnage but could not find way to do.(with perl we could run test on windows too)
-- source include/not_windows.inc

let MYSQLD_DATADIR =`SELECT @@datadir`;
let $innodb_file_per_table = `SELECT @@innodb_file_per_table`;

SET GLOBAL innodb_file_per_table = 1;
SELECT @@innodb_file_per_table;

let $MYSQLD_DATADIR = `SELECT @@datadir`;


--disable_warnings
DROP DATABASE IF EXISTS testdb_wl6445;
--enable_warnings
CREATE DATABASE testdb_wl6445;


#------------------------------------------------------------------------------
# Testcase covers
# a) Create table/data ,
# b) remove write permission of ibdata , ib_logfile0
# c) restart server in --innodb-read-only mode and verfiy DDL/DML/DCL in read only mode
#------------------------------------------------------------------------------
--echo case # 1

SET GLOBAL innodb_file_per_table = 1;
USE testdb_wl6445;
CREATE TABLE t1 ( i int PRIMARY KEY , j blob) ENGINE = InnoDB;
INSERT INTO t1 VALUES (1,repeat('a',200)),(2,repeat('b',200)),(3,repeat('c',200));
SELECT i,LEFT(j,20) FROM t1 ORDER BY i;

# remove write permissions
--exec chmod a-w $MYSQLD_DATADIR/ibdata1
--exec chmod a-w $MYSQLD_DATADIR/testdb_wl6445/t1.ibd
--exec chmod a-w $MYSQLD_DATADIR/ib_logfile0
#

let $restart_parameters = restart: --innodb-read-only;
--source include/restart_mysqld.inc

USE testdb_wl6445;
SELECT i FROM t1 ORDER BY i;
--ERROR ER_CANT_LOCK
INSERT INTO t1 VALUES (11,repeat('a',200)),(12,repeat('b',200)),(13,repeat('c',200));
SELECT i,LEFT(j,20) FROM t1 ORDER BY i;

--ERROR ER_CANT_LOCK
INSERT INTO t1 VALUES (11,repeat('a',200)),(12,repeat('b',200)),(13,repeat('c',200));
SELECT i,LEFT(j,20) FROM t1 ORDER BY i;
--ERROR ER_INNODB_READ_ONLY
CREATE TABLE t2 ( i int , j blob) ENGINE = Innodb;
--ERROR ER_CANT_LOCK
UPDATE t1 SET i = i+1;

# Fix in next revision - known ( no data returned)
# SHOW ENGINE INNODB STATUS;
FLUSH STATUS;
FLUSH LOGS;
FLUSH TABLES t1;
FLUSH TABLES WITH READ LOCK;
UNLOCK TABLES;


#------------------------------------------------------------------------------
#cleanup
#------------------------------------------------------------------------------
#
--source include/shutdown_mysqld.inc
# Do something while server is down
--exec chmod 0644 $MYSQLD_DATADIR/ibdata1
--exec chmod 0644 $MYSQLD_DATADIR/ib_logfile0
--exec chmod 0660 $MYSQLD_DATADIR/testdb_wl6445/t1.ibd
let $restart_parameters = restart;
--source include/start_mysqld.inc
DROP DATABASE testdb_wl6445;


#------------------------------------------------------------------------------
# Testcase covers
# a) Create table/data ,
# b) remove write permission of ibdata , ib_logfile0 when server is running
# c) restart server in --innodb-read-only mode and verfiy DDL/DML/DCL in read only mode
#------------------------------------------------------------------------------
--echo case # 2
CREATE DATABASE testdb_wl6445;

USE testdb_wl6445;
CREATE TABLE t1 ( i int PRIMARY KEY , j blob) ENGINE = InnoDB;
INSERT INTO t1 VALUES (1,repeat('a',200)),(2,repeat('b',200)),(3,repeat('c',200));
SELECT i,LEFT(j,20) FROM t1 ORDER BY i;

# remove write permissions
--exec chmod a-w $MYSQLD_DATADIR/ibdata1
--exec chmod a-w $MYSQLD_DATADIR/testdb_wl6445/t1.ibd
--exec chmod a-w $MYSQLD_DATADIR/ib_logfile0
#
# check dml/ddl after removing write permission
CREATE TABLE t2 ( i int PRIMARY KEY , j blob) ENGINE = InnoDB;
INSERT INTO t2 VALUES (1,repeat('a',200)),(2,repeat('b',200)),(3,repeat('c',200));
SELECT i,LEFT(j,20) FROM t2 ORDER BY i;
SELECT i,LEFT(j,20) FROM t1 ORDER BY i;
UPDATE t2 SET i = i + 10;
SELECT i,LEFT(j,20) FROM t2 ORDER BY i;
DELETE FROM t2;
SELECT i,LEFT(j,20) FROM t2 ORDER BY i;

let $restart_parameters = restart: --innodb-read-only;
--source include/restart_mysqld.inc

USE testdb_wl6445;
SELECT i FROM t1 ORDER BY i;
SELECT i FROM t2 ORDER BY i;
--ERROR ER_CANT_LOCK
INSERT INTO t1 VALUES (11,repeat('a',200)),(12,repeat('b',200)),(13,repeat('c',200));
SELECT i,LEFT(j,20) FROM t1 ORDER BY i;

--ERROR ER_CANT_LOCK
INSERT INTO t1 VALUES (11,repeat('a',200)),(12,repeat('b',200)),(13,repeat('c',200));
SELECT i,LEFT(j,20) FROM t1 ORDER BY i;
--ERROR ER_TABLE_EXISTS_ERROR
CREATE TABLE t2 ( i int , j blob) ENGINE = Innodb;
--ERROR ER_INNODB_READ_ONLY
CREATE TABLE t3 ( i int , j blob) ENGINE = Innodb;
--ERROR ER_CANT_LOCK
UPDATE t1 SET i = i+1;

# Fix in next revision - known ( no data returned)
# SHOW ENGINE INNODB STATUS;
FLUSH STATUS;
FLUSH LOGS;
FLUSH TABLES t1,t2;
FLUSH TABLES WITH READ LOCK;
UNLOCK TABLES;


#------------------------------------------------------------------------------
# Testcase covers
# a) Create table/data ,
# b) remove write permission of ibdata , ib_logfile0
# c) try to restart server without --innodb-read-only mode
#------------------------------------------------------------------------------
#  Note : write permission is already removed in previous case so we just
#         start server without --innodb-read-only option

--echo case # 3

# We let our server restart attempts write to the file $error_log.
let $error_log= $MYSQLTEST_VARDIR/log/my_restart.err;
# $error_log has to be processed by include/search_pattern_in_file.inc which
# contains Perl code requiring that the environment variable SEARCH_FILE points
# to this file.
let SEARCH_FILE= $error_log;

--source include/shutdown_mysqld.inc

--echo #    Try to restart the server without --innodb-read-only after removing
--echo #    write permissions of system tablespace. Server should not start.
--echo #    This confirms server is not automatically started in read-only mode.
#----------------------------------------------------------------------------------
# Detailed explanations of what happens are placed nearby the checks.
--error 1,42
--exec $MYSQLD_CMD --core-file --loose-console > $error_log 2>&1

# We get depending on the platform either "./ibdata1" or ".\ibdata1".
let SEARCH_PATTERN=InnoDB: The innodb_system data file 'ibdata1' must be writable;
--source include/search_pattern_in_file.inc


#------------------------------------------------------------------------------
# Cleanup
#------------------------------------------------------------------------------
#
# Do something while server is down
--exec chmod 0644 $MYSQLD_DATADIR/ibdata1
--exec chmod 0644 $MYSQLD_DATADIR/ib_logfile0
--exec chmod 0660 $MYSQLD_DATADIR/testdb_wl6445/t1.ibd
--remove_file $error_log

let $restart_parameters = restart;
--source include/start_mysqld.inc
DROP DATABASE testdb_wl6445;

Youez - 2016 - github.com/yon3zu
LinuXploit