403Webshell
Server IP : 104.21.38.3  /  Your IP : 162.158.108.47
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/ndb/r/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/server/mysql/src/mysql-test/suite/ndb/r/ndb_fk_alter.result
create table parent (
a int primary key auto_increment,
b int not null,
c int not null,
unique(b) using hash,
index(c)) engine = ndb;
create table child (
a int primary key auto_increment,
b int not null,
c int not null,
unique(b) using hash,
index(c)) engine = ndb;
alter table child algorithm=inplace, add constraint fk1 foreign key (a) references parent(a);
alter table child algorithm=inplace, add constraint fk2 foreign key (b) references parent(a);
alter table child algorithm=inplace, add constraint fk3 foreign key (c) references parent(a);
show create table child;
Table	Create Table
child	CREATE TABLE `child` (
  `a` int(11) NOT NULL AUTO_INCREMENT,
  `b` int(11) NOT NULL,
  `c` int(11) NOT NULL,
  PRIMARY KEY (`a`),
  UNIQUE KEY `b` (`b`) USING HASH,
  KEY `c` (`c`),
  CONSTRAINT `fk1` FOREIGN KEY (`a`) REFERENCES `parent` (`a`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk2` FOREIGN KEY (`b`) REFERENCES `parent` (`a`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk3` FOREIGN KEY (`c`) REFERENCES `parent` (`a`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
alter table child algorithm=inplace, drop foreign key fk1;
show create table child;
Table	Create Table
child	CREATE TABLE `child` (
  `a` int(11) NOT NULL AUTO_INCREMENT,
  `b` int(11) NOT NULL,
  `c` int(11) NOT NULL,
  PRIMARY KEY (`a`),
  UNIQUE KEY `b` (`b`) USING HASH,
  KEY `c` (`c`),
  CONSTRAINT `fk2` FOREIGN KEY (`b`) REFERENCES `parent` (`a`) ON DELETE NO ACTION ON UPDATE NO ACTION,
  CONSTRAINT `fk3` FOREIGN KEY (`c`) REFERENCES `parent` (`a`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
alter table child algorithm=inplace, drop foreign key fk2;
show create table child;
Table	Create Table
child	CREATE TABLE `child` (
  `a` int(11) NOT NULL AUTO_INCREMENT,
  `b` int(11) NOT NULL,
  `c` int(11) NOT NULL,
  PRIMARY KEY (`a`),
  UNIQUE KEY `b` (`b`) USING HASH,
  KEY `c` (`c`),
  CONSTRAINT `fk3` FOREIGN KEY (`c`) REFERENCES `parent` (`a`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
alter table child algorithm=inplace, drop foreign key fk3;
show create table child;
Table	Create Table
child	CREATE TABLE `child` (
  `a` int(11) NOT NULL AUTO_INCREMENT,
  `b` int(11) NOT NULL,
  `c` int(11) NOT NULL,
  PRIMARY KEY (`a`),
  UNIQUE KEY `b` (`b`) USING HASH,
  KEY `c` (`c`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
drop table parent, child;
CREATE TABLE bug46599a (
b VARCHAR(2), PRIMARY KEY(b)) ENGINE=ndb;
CREATE TABLE bug46599b (b VARCHAR(2),
CONSTRAINT fk1 FOREIGN KEY (b) REFERENCES bug46599a (b)) ENGINE=Ndb;
INSERT INTO bug46599a VALUES ('b');
INSERT INTO bug46599b VALUES ('b'), (NULL);
INSERT INTO bug46599b VALUES ('');
ERROR 23000: Cannot add or update a child row: a foreign key constraint fails (Unknown error code)
SELECT * FROM bug46599a;
b
b
SELECT * FROM bug46599b;
b
NULL
b
ALTER TABLE bug46599b MODIFY COLUMN b VARCHAR(2) NOT NULL DEFAULT '';
ERROR HY000: Cannot change column 'b': used in a foreign key constraint 'fk1'
SELECT * FROM bug46599b;
b
NULL
b
DROP TABLE bug46599b,bug46599a;
create table t1(
col1 int not null primary key,
col2 int not null,
col3 varchar(35) not null,
unique name0 (col2),
unique name1 (col3)
) engine=ndb;
create table t2(
col1 int not null unique,
col2 int not null,
col3 varchar(35),
constraint fk1 foreign key (col3) references t1(col3)
) engine=ndb;
ALTER TABLE t1 DROP COLUMN col2;
drop table t2, t1;
set @i=2;
create table t1(
col1 int not null primary key,
col2 int not null unique,
col3 varchar(35)
) engine=innodb;
create table t2(
col1 int not null unique,
col2 int not null,
col3 varchar(35),
constraint fk1 foreign key (col2) references t1(col1)
) engine=innodb;
insert into t1(col1,col2,col3) values (2, 3, 'abcdefghijkl');
insert into t2(col1,col2,col3) values (1, 2, 'abcdefghijkl');
# Attempt to drop col1, should give error
ALTER TABLE t1 DROP COLUMN col1;
ERROR HY000: Cannot drop column 'col1': needed in a foreign key constraint 'fk1' of table 'test.t2'
# Attempt to modify col1, should give error
ALTER TABLE t1 MODIFY COLUMN col1 bigint;
ERROR HY000: Cannot change column 'col1': used in a foreign key constraint 'fk1' of table 'test.t2'
# Drop the column t1.col3
ALTER TABLE t1 DROP COLUMN col3;
# Drop t2.col2
ALTER TABLE t2 DROP COLUMN col2;
Got one of the listed errors
drop table t2, t1;
set @i=1;
create table t1(
col1 int not null primary key,
col2 int not null unique,
col3 varchar(35)
) engine=ndb;
create table t2(
col1 int not null unique,
col2 int not null,
col3 varchar(35),
constraint fk1 foreign key (col2) references t1(col1)
) engine=ndb;
insert into t1(col1,col2,col3) values (2, 3, 'abcdefghijkl');
insert into t2(col1,col2,col3) values (1, 2, 'abcdefghijkl');
# Attempt to drop col1, should give error
ALTER TABLE t1 DROP COLUMN col1;
ERROR HY000: Cannot drop column 'col1': needed in a foreign key constraint 'fk1' of table 'test.t2'
# Attempt to modify col1, should give error
ALTER TABLE t1 MODIFY COLUMN col1 bigint;
ERROR HY000: Cannot change column 'col1': used in a foreign key constraint 'fk1' of table 'test.t2'
# Drop the column t1.col3
ALTER TABLE t1 DROP COLUMN col3;
# Drop t2.col2
ALTER TABLE t2 DROP COLUMN col2;
Got one of the listed errors
drop table t2, t1;
#
# Test non-auto partitioning
#
CREATE TABLE t1
(col1 int NOT NULL PRIMARY KEY,
col2 int NOT NULL,
col3 varchar(35) NOT NULL,
UNIQUE KEY name0 (col2),
UNIQUE KEY name1 (col3)
)
ENGINE = NDB;
CREATE TABLE t2
(col1 int NOT NULL UNIQUE,
col2 int NOT NULL,
col3 varchar(35),
CONSTRAINT fk1 FOREIGN KEY (col3) REFERENCES t1 (col3)
)
ENGINE = NDB;
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `col1` int(11) NOT NULL,
  `col2` int(11) NOT NULL,
  `col3` varchar(35) NOT NULL,
  PRIMARY KEY (`col1`),
  UNIQUE KEY `name0` (`col2`),
  UNIQUE KEY `name1` (`col3`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `col1` int(11) NOT NULL,
  `col2` int(11) NOT NULL,
  `col3` varchar(35) DEFAULT NULL,
  UNIQUE KEY `col1` (`col1`),
  KEY `fk1` (`col3`),
  CONSTRAINT `fk1` FOREIGN KEY (`col3`) REFERENCES `t1` (`col3`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
ALTER TABLE t1 PARTITION BY KEY ();
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `col1` int(11) NOT NULL,
  `col2` int(11) NOT NULL,
  `col3` varchar(35) NOT NULL,
  PRIMARY KEY (`col1`),
  UNIQUE KEY `name0` (`col2`),
  UNIQUE KEY `name1` (`col3`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
/*!50100 PARTITION BY KEY () */
ALTER TABLE t1 PARTITION BY KEY (col1);
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `col1` int(11) NOT NULL,
  `col2` int(11) NOT NULL,
  `col3` varchar(35) NOT NULL,
  PRIMARY KEY (`col1`),
  UNIQUE KEY `name0` (`col2`),
  UNIQUE KEY `name1` (`col3`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
/*!50100 PARTITION BY KEY (col1) */
ALTER TABLE t1 REMOVE PARTITIONING;
SHOW CREATE TABLE t1;
Table	Create Table
t1	CREATE TABLE `t1` (
  `col1` int(11) NOT NULL,
  `col2` int(11) NOT NULL,
  `col3` varchar(35) NOT NULL,
  PRIMARY KEY (`col1`),
  UNIQUE KEY `name0` (`col2`),
  UNIQUE KEY `name1` (`col3`)
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
ALTER TABLE t2 PARTITION BY KEY ();
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `col1` int(11) NOT NULL,
  `col2` int(11) NOT NULL,
  `col3` varchar(35) DEFAULT NULL,
  UNIQUE KEY `col1` (`col1`),
  KEY `fk1` (`col3`),
  CONSTRAINT `fk1` FOREIGN KEY (`col3`) REFERENCES `t1` (`col3`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
/*!50100 PARTITION BY KEY () */
ALTER TABLE t2 PARTITION BY KEY (col1);
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `col1` int(11) NOT NULL,
  `col2` int(11) NOT NULL,
  `col3` varchar(35) DEFAULT NULL,
  UNIQUE KEY `col1` (`col1`),
  KEY `fk1` (`col3`),
  CONSTRAINT `fk1` FOREIGN KEY (`col3`) REFERENCES `t1` (`col3`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
/*!50100 PARTITION BY KEY (col1) */
ALTER TABLE t2 REMOVE PARTITIONING;
SHOW CREATE TABLE t2;
Table	Create Table
t2	CREATE TABLE `t2` (
  `col1` int(11) NOT NULL,
  `col2` int(11) NOT NULL,
  `col3` varchar(35) DEFAULT NULL,
  UNIQUE KEY `col1` (`col1`),
  KEY `fk1` (`col3`),
  CONSTRAINT `fk1` FOREIGN KEY (`col3`) REFERENCES `t1` (`col3`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=ndbcluster DEFAULT CHARSET=latin1
DROP TABLE t2, t1;

Youez - 2016 - github.com/yon3zu
LinuXploit