mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
merge
ndb/include/ndbapi/NdbScanOperation.hpp: Auto merged ndb/src/common/util/version.c: Auto merged ndb/src/kernel/blocks/dbdih/DbdihMain.cpp: Auto merged ndb/src/kernel/blocks/dblqh/Dblqh.hpp: Auto merged ndb/src/kernel/blocks/dblqh/DblqhMain.cpp: Auto merged ndb/src/kernel/blocks/dbtc/DbtcMain.cpp: Auto merged ndb/src/ndbapi/NdbConnection.cpp: Auto merged ndb/test/ndbapi/testReadPerf.cpp: Auto merged ndb/test/ndbapi/testScanPerf.cpp: Auto merged
This commit is contained in:
@ -19,6 +19,9 @@ select 'a ' = 'a\t', 'a ' < 'a\t', 'a ' > 'a\t';
|
||||
select 'a a' > 'a', 'a \t' < 'a';
|
||||
'a a' > 'a' 'a \t' < 'a'
|
||||
1 1
|
||||
select 'c' like '\_' as want0;
|
||||
want0
|
||||
0
|
||||
CREATE TABLE t (
|
||||
c char(20) NOT NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
|
||||
|
@ -814,3 +814,6 @@ t2 CREATE TABLE `t2` (
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
select 'c' like '\_' as want0;
|
||||
want0
|
||||
0
|
||||
|
@ -399,3 +399,9 @@ select count(*) from t1;
|
||||
count(*)
|
||||
1
|
||||
drop table t1;
|
||||
create table t1 (a int primary key, b text, fulltext(b));
|
||||
create table t2 (a int, b text);
|
||||
insert t1 values (1, "aaaa"), (2, "bbbb");
|
||||
insert t2 values (10, "aaaa"), (2, "cccc");
|
||||
replace t1 select * from t2;
|
||||
drop table t1, t2;
|
||||
|
@ -363,40 +363,17 @@ NULL test PRIMARY NULL test t1 a 1 NULL NULL NULL
|
||||
NULL test constraint_1 NULL test t1 a 1 NULL NULL NULL
|
||||
NULL test key_1 NULL test t1 a 1 NULL NULL NULL
|
||||
NULL test key_2 NULL test t1 a 1 NULL NULL NULL
|
||||
drop table t1;
|
||||
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
|
||||
CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id),
|
||||
FOREIGN KEY (t1_id) REFERENCES t1(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (t1_id) REFERENCES t1(id) ON UPDATE CASCADE) ENGINE=INNODB;
|
||||
select * from information_schema.TABLE_CONSTRAINTS where
|
||||
TABLE_SCHEMA= "test";
|
||||
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE CONSTRAINT_METHOD
|
||||
NULL test PRIMARY test t1 PRIMARY KEY NULL
|
||||
NULL test PRIMARY test t2 PRIMARY KEY NULL
|
||||
NULL test t2_ibfk_1 test t2 FOREIGN KEY ON DELETE CASCADE
|
||||
NULL test t2_ibfk_2 test t2 FOREIGN KEY ON UPDATE CASCADE
|
||||
select * from information_schema.KEY_COLUMN_USAGE where
|
||||
TABLE_SCHEMA= "test";
|
||||
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
|
||||
NULL test PRIMARY NULL test t1 id 1 NULL NULL NULL
|
||||
NULL test PRIMARY NULL test t2 id 1 NULL NULL NULL
|
||||
NULL test t2_ibfk_1 NULL test t2 t1_id 1 NULL id
|
||||
NULL test t2_ibfk_2 NULL test t2 t1_id 1 NULL id
|
||||
select table_name from information_schema.TABLES where table_schema like "test%";
|
||||
table_name
|
||||
t1
|
||||
t2
|
||||
select table_name,column_name from information_schema.COLUMNS where table_schema like "test%";
|
||||
table_name column_name
|
||||
t1 id
|
||||
t2 id
|
||||
t2 t1_id
|
||||
t1 a
|
||||
select ROUTINE_NAME from information_schema.ROUTINES;
|
||||
ROUTINE_NAME
|
||||
sel2
|
||||
sub1
|
||||
delete from mysql.user where user='mysqltest_1';
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
drop procedure sel2;
|
||||
drop function sub1;
|
||||
|
19
mysql-test/r/information_schema_inno.result
Normal file
19
mysql-test/r/information_schema_inno.result
Normal file
@ -0,0 +1,19 @@
|
||||
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
|
||||
CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id),
|
||||
FOREIGN KEY (t1_id) REFERENCES t1(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (t1_id) REFERENCES t1(id) ON UPDATE CASCADE) ENGINE=INNODB;
|
||||
select * from information_schema.TABLE_CONSTRAINTS where
|
||||
TABLE_SCHEMA= "test";
|
||||
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_SCHEMA TABLE_NAME CONSTRAINT_TYPE CONSTRAINT_METHOD
|
||||
NULL test PRIMARY test t1 PRIMARY KEY NULL
|
||||
NULL test PRIMARY test t2 PRIMARY KEY NULL
|
||||
NULL test t2_ibfk_1 test t2 FOREIGN KEY ON DELETE CASCADE
|
||||
NULL test t2_ibfk_2 test t2 FOREIGN KEY ON UPDATE CASCADE
|
||||
select * from information_schema.KEY_COLUMN_USAGE where
|
||||
TABLE_SCHEMA= "test";
|
||||
CONSTRAINT_CATALOG CONSTRAINT_SCHEMA CONSTRAINT_NAME TABLE_CATALOG TABLE_SCHEMA TABLE_NAME COLUMN_NAME ORDINAL_POSITION REFERENCED_TABLE_SCHEMA REFERENCED_TABLE_NAME REFERENCED_COLUMN_NAME
|
||||
NULL test PRIMARY NULL test t1 id 1 NULL NULL NULL
|
||||
NULL test PRIMARY NULL test t2 id 1 NULL NULL NULL
|
||||
NULL test t2_ibfk_1 NULL test t2 t1_id 1 NULL id
|
||||
NULL test t2_ibfk_2 NULL test t2 t1_id 1 NULL id
|
||||
drop table t2, t1;
|
@ -6,5 +6,5 @@ drop table t1;
|
||||
flush tables;
|
||||
CREATE TABLE t1 (a int) ENGINE=INNODB;
|
||||
SELECT * from T1;
|
||||
ERROR HY000: Can't open file: 'T1.InnoDB' (errno: 1)
|
||||
ERROR HY000: Can't open file: 'T1.ibd' (errno: 1)
|
||||
drop table t1;
|
||||
|
@ -22,3 +22,19 @@ insert into v2aA values ((select max(col1) from v1aA));
|
||||
ERROR HY000: You can't specify target table 'v2aa' for update in FROM clause
|
||||
drop view v2Aa,v1Aa;
|
||||
drop table t1Aa,t2Aa;
|
||||
create table t1Aa (col1 int);
|
||||
create view v1Aa as select col1 from t1Aa as AaA;
|
||||
show create view v1AA;
|
||||
View Create View
|
||||
v1aa CREATE ALGORITHM=UNDEFINED VIEW `test`.`v1aa` AS select `aaa`.`col1` AS `col1` from `test`.`t1aa` `AaA`
|
||||
drop view v1AA;
|
||||
select Aaa.col1 from t1Aa as AaA;
|
||||
col1
|
||||
create view v1Aa as select Aaa.col1 from t1Aa as AaA;
|
||||
drop view v1AA;
|
||||
create view v1Aa as select AaA.col1 from t1Aa as AaA;
|
||||
show create view v1AA;
|
||||
View Create View
|
||||
v1aa CREATE ALGORITHM=UNDEFINED VIEW `test`.`v1aa` AS select `aaa`.`col1` AS `col1` from `test`.`t1aa` `AaA`
|
||||
drop view v1AA;
|
||||
drop table t1Aa;
|
||||
|
@ -887,7 +887,7 @@ insert into t1 values (1), (2), (3), (200);
|
||||
create view v1 (x) as select a from t1 where a > 1;
|
||||
create view v2 (y) as select x from v1 where x < 100;
|
||||
select * from v2;
|
||||
x
|
||||
y
|
||||
2
|
||||
3
|
||||
drop table t1;
|
||||
@ -1661,3 +1661,171 @@ check table v1;
|
||||
Table Op Msg_type Msg_text
|
||||
test.v1 check error View 'test.v1' references invalid table(s) or column(s)
|
||||
drop view v1;
|
||||
create table t1 (a int);
|
||||
create table t2 (a int);
|
||||
create table t3 (a int);
|
||||
insert into t1 values (1), (2), (3);
|
||||
insert into t2 values (1), (3);
|
||||
insert into t3 values (1), (2), (4);
|
||||
create view v3 (a,b) as select t1.a as a, t2.a as b from t1 left join t2 on (t1.a=t2.a);
|
||||
select * from t3 left join v3 on (t3.a = v3.a);
|
||||
a a b
|
||||
1 1 1
|
||||
2 2 NULL
|
||||
4 NULL NULL
|
||||
explain extended select * from t3 left join v3 on (t3.a = v3.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `b` from `test`.`t3` left join (`test`.`t1` left join `test`.`t2` on((`test`.`t1`.`a` = `test`.`t2`.`a`))) on((`test`.`t3`.`a` = `test`.`t1`.`a`)) where 1
|
||||
create view v1 (a) as select a from t1;
|
||||
create view v2 (a) as select a from t2;
|
||||
create view v4 (a,b) as select v1.a as a, v2.a as b from v1 left join v2 on (v1.a=v2.a);
|
||||
select * from t3 left join v4 on (t3.a = v4.a);
|
||||
a a b
|
||||
1 1 1
|
||||
2 2 NULL
|
||||
4 NULL NULL
|
||||
explain extended select * from t3 left join v4 on (t3.a = v4.a);
|
||||
id select_type table type possible_keys key key_len ref rows Extra
|
||||
1 PRIMARY t3 ALL NULL NULL NULL NULL 3
|
||||
1 PRIMARY t1 ALL NULL NULL NULL NULL 3
|
||||
1 PRIMARY t2 ALL NULL NULL NULL NULL 2
|
||||
Warnings:
|
||||
Note 1003 select `test`.`t3`.`a` AS `a`,`test`.`t1`.`a` AS `a`,`test`.`t2`.`a` AS `b` from `test`.`t3` left join (`test`.`v1` left join `test`.`v2` on((`test`.`t1`.`a` = `test`.`t2`.`a`))) on((`test`.`t3`.`a` = `test`.`t1`.`a`)) where 1
|
||||
prepare stmt1 from "select * from t3 left join v4 on (t3.a = v4.a);";
|
||||
execute stmt1;
|
||||
a a b
|
||||
1 1 1
|
||||
2 2 NULL
|
||||
4 NULL NULL
|
||||
execute stmt1;
|
||||
a a b
|
||||
1 1 1
|
||||
2 2 NULL
|
||||
4 NULL NULL
|
||||
deallocate prepare stmt1;
|
||||
drop view v4,v3,v2,v1;
|
||||
drop tables t1,t2,t3;
|
||||
create table t1 (a int, primary key (a), b int);
|
||||
create table t2 (a int, primary key (a));
|
||||
insert into t1 values (1,100), (2,200);
|
||||
insert into t2 values (1), (3);
|
||||
create view v3 (a,b) as select t1.a as a, t2.a as b from t1, t2;
|
||||
update v3 set a= 10 where a=1;
|
||||
select * from t1;
|
||||
a b
|
||||
10 100
|
||||
2 200
|
||||
select * from t2;
|
||||
a
|
||||
1
|
||||
3
|
||||
create view v2 (a,b) as select t1.b as a, t2.a as b from t1, t2;
|
||||
set updatable_views_with_limit=NO;
|
||||
update v2 set a= 10 where a=200 limit 1;
|
||||
ERROR HY000: The target table t1 of the UPDATE is not updatable
|
||||
set updatable_views_with_limit=DEFAULT;
|
||||
select * from v3;
|
||||
a b
|
||||
2 1
|
||||
10 1
|
||||
2 3
|
||||
10 3
|
||||
select * from v2;
|
||||
a b
|
||||
100 1
|
||||
200 1
|
||||
100 3
|
||||
200 3
|
||||
set @a= 10;
|
||||
set @b= 100;
|
||||
prepare stmt1 from "update v3 set a= ? where a=?";
|
||||
execute stmt1 using @a,@b;
|
||||
select * from v3;
|
||||
a b
|
||||
2 1
|
||||
10 1
|
||||
2 3
|
||||
10 3
|
||||
set @a= 300;
|
||||
set @b= 10;
|
||||
execute stmt1 using @a,@b;
|
||||
select * from v3;
|
||||
a b
|
||||
2 1
|
||||
300 1
|
||||
2 3
|
||||
300 3
|
||||
deallocate prepare stmt1;
|
||||
drop view v3,v2;
|
||||
drop tables t1,t2;
|
||||
create table t1 (a int, primary key (a), b int);
|
||||
create table t2 (a int, primary key (a), b int);
|
||||
insert into t2 values (1000, 2000);
|
||||
create view v3 (a,b) as select t1.a as a, t2.a as b from t1, t2;
|
||||
insert into v3 values (1,2);
|
||||
ERROR HY000: Can not insert into join view 'test.v3' without fields list
|
||||
insert into v3 select * from t2;
|
||||
ERROR HY000: Can not insert into join view 'test.v3' without fields list
|
||||
insert into v3(a,b) values (1,2);
|
||||
ERROR HY000: Can not modify more than one base table through a join view 'test.v3'
|
||||
insert into v3(a,b) select * from t2;
|
||||
ERROR HY000: Can not modify more than one base table through a join view 'test.v3'
|
||||
insert into v3(a) values (1);
|
||||
insert into v3(b) values (10);
|
||||
insert into v3(a) select a from t2;
|
||||
insert into v3(b) select b from t2;
|
||||
Warnings:
|
||||
Warning 1263 Column set to default value; NULL supplied to NOT NULL column 'a' at row 2
|
||||
insert into v3(a) values (1) on duplicate key update a=a+10000+VALUES(a);
|
||||
select * from t1;
|
||||
a b
|
||||
10002 NULL
|
||||
10 NULL
|
||||
1000 NULL
|
||||
select * from t2;
|
||||
a b
|
||||
1000 2000
|
||||
10 NULL
|
||||
2000 NULL
|
||||
0 NULL
|
||||
delete from v3;
|
||||
ERROR HY000: Can not delete from join view 'test.v3'
|
||||
delete v3,t1 from v3,t1;
|
||||
ERROR HY000: Can not delete from join view 'test.v3'
|
||||
delete from t1;
|
||||
prepare stmt1 from "insert into v3(a) values (?);";
|
||||
set @a= 100;
|
||||
execute stmt1 using @a;
|
||||
set @a= 300;
|
||||
execute stmt1 using @a;
|
||||
deallocate prepare stmt1;
|
||||
prepare stmt1 from "insert into v3(a) select ?;";
|
||||
set @a= 101;
|
||||
execute stmt1 using @a;
|
||||
set @a= 301;
|
||||
execute stmt1 using @a;
|
||||
deallocate prepare stmt1;
|
||||
select * from v3;
|
||||
a b
|
||||
100 1000
|
||||
101 1000
|
||||
300 1000
|
||||
301 1000
|
||||
100 10
|
||||
101 10
|
||||
300 10
|
||||
301 10
|
||||
100 2000
|
||||
101 2000
|
||||
300 2000
|
||||
301 2000
|
||||
100 0
|
||||
101 0
|
||||
300 0
|
||||
301 0
|
||||
drop view v3;
|
||||
drop tables t1,t2;
|
||||
|
@ -24,6 +24,11 @@ select 'a ' = 'a\t', 'a ' < 'a\t', 'a ' > 'a\t';
|
||||
|
||||
select 'a a' > 'a', 'a \t' < 'a';
|
||||
|
||||
#
|
||||
# Bug #6787 LIKE not working properly with _ and utf8 data
|
||||
#
|
||||
select 'c' like '\_' as want0;
|
||||
|
||||
#
|
||||
# Bug #5679 utf8_unicode_ci LIKE--trailing % doesn't equal zero characters
|
||||
#
|
||||
|
@ -660,3 +660,9 @@ create table t2 select concat(a,_utf8'') as a, concat(b,_utf8'')as b from t1;
|
||||
show create table t2;
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# Bug #6787 LIKE not working properly with _ and utf8 data
|
||||
#
|
||||
select 'c' like '\_' as want0;
|
||||
|
||||
|
@ -308,3 +308,16 @@ REPAIR TABLE t1;
|
||||
select count(*) from t1;
|
||||
drop table t1;
|
||||
|
||||
#
|
||||
# bug#6784
|
||||
# mi_flush_bulk_insert (on dup key error in mi_write)
|
||||
# was mangling info->dupp_key_pos
|
||||
#
|
||||
|
||||
create table t1 (a int primary key, b text, fulltext(b));
|
||||
create table t2 (a int, b text);
|
||||
insert t1 values (1, "aaaa"), (2, "bbbb");
|
||||
insert t2 values (10, "aaaa"), (2, "cccc");
|
||||
replace t1 select * from t2;
|
||||
drop table t1, t2;
|
||||
|
||||
|
@ -162,16 +162,7 @@ select * from information_schema.TABLE_CONSTRAINTS where
|
||||
TABLE_SCHEMA= "test";
|
||||
select * from information_schema.KEY_COLUMN_USAGE where
|
||||
TABLE_SCHEMA= "test";
|
||||
drop table t1;
|
||||
|
||||
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
|
||||
CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id),
|
||||
FOREIGN KEY (t1_id) REFERENCES t1(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (t1_id) REFERENCES t1(id) ON UPDATE CASCADE) ENGINE=INNODB;
|
||||
select * from information_schema.TABLE_CONSTRAINTS where
|
||||
TABLE_SCHEMA= "test";
|
||||
select * from information_schema.KEY_COLUMN_USAGE where
|
||||
TABLE_SCHEMA= "test";
|
||||
|
||||
connect (user1,localhost,mysqltest_1,,);
|
||||
connection user1;
|
||||
@ -181,7 +172,6 @@ select ROUTINE_NAME from information_schema.ROUTINES;
|
||||
disconnect user1;
|
||||
connection default;
|
||||
delete from mysql.user where user='mysqltest_1';
|
||||
drop table t2;
|
||||
drop table t1;
|
||||
drop procedure sel2;
|
||||
drop function sub1;
|
||||
|
16
mysql-test/t/information_schema_inno.test
Normal file
16
mysql-test/t/information_schema_inno.test
Normal file
@ -0,0 +1,16 @@
|
||||
-- source include/have_innodb.inc
|
||||
|
||||
#
|
||||
# Test for KEY_COLUMN_USAGE & TABLE_CONSTRAINTS tables
|
||||
#
|
||||
|
||||
CREATE TABLE t1 (id INT NOT NULL, PRIMARY KEY (id)) ENGINE=INNODB;
|
||||
CREATE TABLE t2 (id INT PRIMARY KEY, t1_id INT, INDEX par_ind (t1_id),
|
||||
FOREIGN KEY (t1_id) REFERENCES t1(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (t1_id) REFERENCES t1(id) ON UPDATE CASCADE) ENGINE=INNODB;
|
||||
select * from information_schema.TABLE_CONSTRAINTS where
|
||||
TABLE_SCHEMA= "test";
|
||||
select * from information_schema.KEY_COLUMN_USAGE where
|
||||
TABLE_SCHEMA= "test";
|
||||
|
||||
drop table t2, t1;
|
@ -32,3 +32,18 @@ delete from v2aA where col1 = (select max(col1) from v1aA);
|
||||
insert into v2aA values ((select max(col1) from v1aA));
|
||||
drop view v2Aa,v1Aa;
|
||||
drop table t1Aa,t2Aa;
|
||||
|
||||
#
|
||||
# aliases in VIEWs
|
||||
#
|
||||
create table t1Aa (col1 int);
|
||||
create view v1Aa as select col1 from t1Aa as AaA;
|
||||
show create view v1AA;
|
||||
drop view v1AA;
|
||||
select Aaa.col1 from t1Aa as AaA;
|
||||
create view v1Aa as select Aaa.col1 from t1Aa as AaA;
|
||||
drop view v1AA;
|
||||
create view v1Aa as select AaA.col1 from t1Aa as AaA;
|
||||
show create view v1AA;
|
||||
drop view v1AA;
|
||||
drop table t1Aa;
|
||||
|
@ -1599,3 +1599,115 @@ check table v1,t1;
|
||||
drop table t1;
|
||||
check table v1;
|
||||
drop view v1;
|
||||
|
||||
#
|
||||
# merge of VIEW with several tables
|
||||
#
|
||||
create table t1 (a int);
|
||||
create table t2 (a int);
|
||||
create table t3 (a int);
|
||||
insert into t1 values (1), (2), (3);
|
||||
insert into t2 values (1), (3);
|
||||
insert into t3 values (1), (2), (4);
|
||||
# view over tables
|
||||
create view v3 (a,b) as select t1.a as a, t2.a as b from t1 left join t2 on (t1.a=t2.a);
|
||||
select * from t3 left join v3 on (t3.a = v3.a);
|
||||
explain extended select * from t3 left join v3 on (t3.a = v3.a);
|
||||
# view over views
|
||||
create view v1 (a) as select a from t1;
|
||||
create view v2 (a) as select a from t2;
|
||||
create view v4 (a,b) as select v1.a as a, v2.a as b from v1 left join v2 on (v1.a=v2.a);
|
||||
select * from t3 left join v4 on (t3.a = v4.a);
|
||||
explain extended select * from t3 left join v4 on (t3.a = v4.a);
|
||||
# PS with view over views
|
||||
prepare stmt1 from "select * from t3 left join v4 on (t3.a = v4.a);";
|
||||
execute stmt1;
|
||||
execute stmt1;
|
||||
deallocate prepare stmt1;
|
||||
drop view v4,v3,v2,v1;
|
||||
drop tables t1,t2,t3;
|
||||
|
||||
#
|
||||
# updating of join view
|
||||
#
|
||||
create table t1 (a int, primary key (a), b int);
|
||||
create table t2 (a int, primary key (a));
|
||||
insert into t1 values (1,100), (2,200);
|
||||
insert into t2 values (1), (3);
|
||||
# legal view for update
|
||||
create view v3 (a,b) as select t1.a as a, t2.a as b from t1, t2;
|
||||
update v3 set a= 10 where a=1;
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
# view without primary key
|
||||
create view v2 (a,b) as select t1.b as a, t2.a as b from t1, t2;
|
||||
set updatable_views_with_limit=NO;
|
||||
-- error 1288
|
||||
update v2 set a= 10 where a=200 limit 1;
|
||||
set updatable_views_with_limit=DEFAULT;
|
||||
# just view selects
|
||||
select * from v3;
|
||||
select * from v2;
|
||||
# prepare statement with updating join view
|
||||
set @a= 10;
|
||||
set @b= 100;
|
||||
prepare stmt1 from "update v3 set a= ? where a=?";
|
||||
execute stmt1 using @a,@b;
|
||||
select * from v3;
|
||||
set @a= 300;
|
||||
set @b= 10;
|
||||
execute stmt1 using @a,@b;
|
||||
select * from v3;
|
||||
deallocate prepare stmt1;
|
||||
drop view v3,v2;
|
||||
drop tables t1,t2;
|
||||
|
||||
#
|
||||
# inserting/deleting join view
|
||||
#
|
||||
create table t1 (a int, primary key (a), b int);
|
||||
create table t2 (a int, primary key (a), b int);
|
||||
insert into t2 values (1000, 2000);
|
||||
create view v3 (a,b) as select t1.a as a, t2.a as b from t1, t2;
|
||||
# inserting into join view without field list
|
||||
-- error 1394
|
||||
insert into v3 values (1,2);
|
||||
-- error 1394
|
||||
insert into v3 select * from t2;
|
||||
# inserting in several tables of join view
|
||||
-- error 1393
|
||||
insert into v3(a,b) values (1,2);
|
||||
-- error 1393
|
||||
insert into v3(a,b) select * from t2;
|
||||
# correct inserts into join view
|
||||
insert into v3(a) values (1);
|
||||
insert into v3(b) values (10);
|
||||
insert into v3(a) select a from t2;
|
||||
insert into v3(b) select b from t2;
|
||||
insert into v3(a) values (1) on duplicate key update a=a+10000+VALUES(a);
|
||||
select * from t1;
|
||||
select * from t2;
|
||||
# try delete from join view
|
||||
-- error 1395
|
||||
delete from v3;
|
||||
-- error 1395
|
||||
delete v3,t1 from v3,t1;
|
||||
# delete from t1 just to reduce result set size
|
||||
delete from t1;
|
||||
# prepare statement with insert join view
|
||||
prepare stmt1 from "insert into v3(a) values (?);";
|
||||
set @a= 100;
|
||||
execute stmt1 using @a;
|
||||
set @a= 300;
|
||||
execute stmt1 using @a;
|
||||
deallocate prepare stmt1;
|
||||
prepare stmt1 from "insert into v3(a) select ?;";
|
||||
set @a= 101;
|
||||
execute stmt1 using @a;
|
||||
set @a= 301;
|
||||
execute stmt1 using @a;
|
||||
deallocate prepare stmt1;
|
||||
select * from v3;
|
||||
|
||||
drop view v3;
|
||||
drop tables t1,t2;
|
||||
|
Reference in New Issue
Block a user