403Webshell
Server IP : 172.67.216.182  /  Your IP : 172.69.176.86
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/sys_vars/t/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/server/mysql/src/mysql-test/suite/sys_vars/t/foreign_key_checks_func.test
############## mysql-test\t\foreign_key_checks_func.test  #####################
#                                                                             #
# Variable Name: foreign_key_checks                                           #
# Scope: SESSION                                                              # 
# Access Type: Dynamic                                                        #
# Data Type: boolean                                                          #
# Default Value: NA                                                           #
# Range: NA                                                                   #
#                                                                             #
#                                                                             #
# Creation Date: 2008-03-08                                                   #
# Author:  Rizwan                                                             #
#                                                                             #
# Description: Test Cases of Dynamic System Variable foreign_key_checks       #
#              that checks the behavior of this variable                      #
#                                                                             #
# Reference: http://dev.mysql.com/doc/refman/5.1/en/                          #
#  server-system-variables.html                                               #
#                                                                             #
###############################################################################

--source include/have_innodb.inc

--echo '#--------------------FN_DYNVARS_032_01-------------------------#'
####################################################################
# Check if setting foreign_key_checks is changed in new connection # 
####################################################################

SET @@session.foreign_key_checks = 0;
# con1 will be default connection from now on
--echo 'connect (con1,localhost,root,,,,)'
connect (con1,localhost,root,,,,);
--echo 'connection con1'
connection con1;
SELECT @@session.foreign_key_checks;
SET @@session.foreign_key_checks = 1;
--echo 'connect (con2,localhost,root,,,,)'
connect (con2,localhost,root,,,,);
--echo 'connection con2'
connection con2;
SELECT @@session.foreign_key_checks;
disconnect con2;

--echo '#--------------------FN_DYNVARS_032_02-------------------------#'
#################################################################
# Begin the functionality Testing of foreign_key_checks         #
#################################################################

--echo 'connection con1'
connection con1;

--disable_warnings
DROP TABLE IF EXISTS t1,t2;
--enable_warnings

CREATE TABLE t1(a INT PRIMARY KEY)ENGINE = INNODB;
CREATE TABLE t2(a INT PRIMARY KEY,b INT)ENGINE = INNODB;

ALTER TABLE t2
ADD CONSTRAINT fk FOREIGN KEY (b) REFERENCES t1 (a);

#===========================================================
--echo '---Check when foreign_key_checks is enabled---'
#===========================================================


SET @@session.foreign_key_checks = 1;

INSERT INTO t1 values (1),(2),(3);

INSERT INTO t2 values (10,1);
--Error ER_NO_REFERENCED_ROW_2
INSERT INTO t2 values (20,22);

#===========================================================
--echo '---Check when foreign_key_checks is disabled---'
#===========================================================

--Error ER_TRUNCATE_ILLEGAL_FK
TRUNCATE t1;

SET @@session.foreign_key_checks = 0;

TRUNCATE t1;
TRUNCATE t2;

INSERT INTO t1 values (1),(2),(3);

INSERT INTO t2 values (10,1);
INSERT INTO t2 values (20,4);

--echo 'try enabling foreign_key_checks again';
SET @@session.foreign_key_checks = 1;

UPDATE t2 SET b=4 where a=20;

#==============================================================================
--echo 'Check when foreign_key_checks is enabled and FK constraint is re-created'
#==============================================================================

SET @@session.foreign_key_checks = 0;
TRUNCATE t2;
TRUNCATE t1;

INSERT INTO t1 values (1),(2),(3);
INSERT INTO t2 values (10,1),(20,4);

ALTER TABLE t2 DROP FOREIGN KEY fk;

SET @@session.foreign_key_checks = 1;

# Test disabled as error description is different. The resulting description has
# difference in code #sql-xxx_2 where xxx is different for each run.
#--Error ER_NO_REFERENCED_ROW_2
#ALTER TABLE t2
#ADD CONSTRAINT fk FOREIGN KEY (b) REFERENCES t1 (a);

# delete all rows with incorrect reference
DELETE FROM t2 WHERE b not in (SELECT a from t1);

ALTER TABLE t2
ADD CONSTRAINT fk FOREIGN KEY (b) REFERENCES t1 (a);

INSERT INTO t2 values (20,2);

SELECT * from t2;

--disable_warnings
DROP TABLE IF EXISTS t2;
DROP TABLE IF EXISTS t1;
--enable_warnings

##########################################################
# End of functionality Testing for foreign_key_checks    #
##########################################################


Youez - 2016 - github.com/yon3zu
LinuXploit