403Webshell
Server IP : 104.21.38.3  /  Your IP : 172.70.92.204
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/t/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/server/mysql/src/mysql-test/suite/ndb/t/ndb_fk_alter.test
-- source include/have_ndb.inc

###
### PK vs PK
###
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;

# Parent pk
# child pk, uk, oi
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;

alter table child algorithm=inplace, drop foreign key fk1;

show create table child;

alter table child algorithm=inplace, drop foreign key fk2;

show create table child;

alter table child algorithm=inplace, drop foreign key fk3;

show create table child;

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);
--error ER_NO_REFERENCED_ROW_2
INSERT INTO bug46599b VALUES ('');

--sorted_result
SELECT * FROM bug46599a;
--sorted_result
SELECT * FROM bug46599b;

--error ER_FK_COLUMN_CANNOT_CHANGE
ALTER TABLE bug46599b MODIFY COLUMN b VARCHAR(2) NOT NULL DEFAULT '';

--sorted_result
SELECT * FROM bug46599b;

DROP TABLE bug46599b,bug46599a;

#
# bug#16912989 - part I
#
#   copy_fk_for_offline_alter must use column name (not column number)
#   in determining columns for newly created FK's
#   This as column number change with DROP COLUMN
#
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;

#
# bug#16912989 - part II
#
#   When offline altering a parent table, the on the child recreated FK's
#     can't be verified since the copying of data to the new parent
#     is done later
#
let $i=2;
while ($i)
{
	eval set @i=$i;
	let $engine=`select if(@i=1,'ndb','innodb')`;

	eval create table t1(
	  col1 int not null primary key,
	  col2 int not null unique,
	  col3 varchar(35)
	) engine=$engine;

	eval create table t2(
	  col1 int not null unique,
	  col2 int not null,
	  col3 varchar(35),
	  constraint fk1 foreign key (col2) references t1(col1)
	) engine=$engine;

	insert into t1(col1,col2,col3) values (2, 3, 'abcdefghijkl');
	insert into t2(col1,col2,col3) values (1, 2, 'abcdefghijkl');

	--echo # Attempt to drop col1, should give error
	--error 1829
	ALTER TABLE t1 DROP COLUMN col1;

	--echo # Attempt to modify col1, should give error
	--error 1833
	ALTER TABLE t1 MODIFY COLUMN col1 bigint;

	--echo # Drop the column t1.col3
	ALTER TABLE t1 DROP COLUMN col3;

	--echo # Drop t2.col2
        --error 1553, 1828
        ALTER TABLE t2 DROP COLUMN col2;

	drop table t2, t1;
	dec $i;
}

--echo #
--echo # Test non-auto partitioning
--echo #
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;
SHOW CREATE TABLE t2;
ALTER TABLE t1 PARTITION BY KEY ();
SHOW CREATE TABLE t1;
ALTER TABLE t1 PARTITION BY KEY (col1);
SHOW CREATE TABLE t1;
ALTER TABLE t1 REMOVE PARTITIONING;
SHOW CREATE TABLE t1;

ALTER TABLE t2 PARTITION BY KEY ();
SHOW CREATE TABLE t2;
ALTER TABLE t2 PARTITION BY KEY (col1);
SHOW CREATE TABLE t2;
ALTER TABLE t2 REMOVE PARTITIONING;
SHOW CREATE TABLE t2;

DROP TABLE t2, t1;


Youez - 2016 - github.com/yon3zu
LinuXploit