⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 view.test

📁 视频监控网络部分的协议ddns,的模块的实现代码,请大家大胆指正.
💻 TEST
📖 第 1 页 / 共 5 页
字号:
INSERT INTO t1 VALUES(5,'david'); INSERT INTO t1 VALUES(6,'kent'); INSERT INTO t1 VALUES(7,'carsten'); INSERT INTO t1 VALUES(8,'ranger'); INSERT INTO t1 VALUES(10,'matt'); CREATE TABLE t2 (col1 int, col2 int, col3 char(1)); INSERT INTO t2 VALUES (1,1,'y'); INSERT INTO t2 VALUES (1,2,'y'); INSERT INTO t2 VALUES (2,1,'n'); INSERT INTO t2 VALUES (3,1,'n'); INSERT INTO t2 VALUES (4,1,'y'); INSERT INTO t2 VALUES (4,2,'n'); INSERT INTO t2 VALUES (4,3,'n'); INSERT INTO t2 VALUES (6,1,'n'); INSERT INTO t2 VALUES (8,1,'y'); CREATE VIEW v1 AS SELECT * FROM t1; SELECT a.col1,a.col2,b.col2,b.col3   FROM t1 a LEFT JOIN t2 b ON a.col1=b.col1    WHERE b.col2 IS NULL OR           b.col2=(SELECT MAX(col2) FROM t2 b WHERE b.col1=a.col1);SELECT a.col1,a.col2,b.col2,b.col3   FROM v1 a LEFT JOIN t2 b ON a.col1=b.col1    WHERE b.col2 IS NULL OR           b.col2=(SELECT MAX(col2) FROM t2 b WHERE b.col1=a.col1);CREATE VIEW v2 AS SELECT * FROM t2; SELECT a.col1,a.col2,b.col2,b.col3  FROM v2 b RIGHT JOIN v1 a ON a.col1=b.col1    WHERE b.col2 IS NULL OR          b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1); # Tests from the report for bug #6107SELECT a.col1,a.col2,b.col2,b.col3  FROM v2 b RIGHT JOIN v1 a ON a.col1=b.col1    WHERE a.col1 IN (1,5,9) AND         (b.col2 IS NULL OR          b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1)); CREATE VIEW v3 AS SELECT * FROM t1 WHERE col1 IN (1,5,9);SELECT a.col1,a.col2,b.col2,b.col3  FROM v2 b RIGHT JOIN v3 a ON a.col1=b.col1    WHERE b.col2 IS NULL OR          b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1);  DROP VIEW v1,v2,v3;DROP TABLE t1,t2;## BUG#8490 Select from views containing subqueries causes server to hang # forever.#create table t1 as select 1 A union select 2 union select 3;create table t2 as select * from t1;create view v1 as select * from t1 where a in (select * from t2);select * from v1 A, v1 B where A.a = B.a;create table t3 as select a a,a b from t2;create view v2 as select * from t3 where   a in (select * from t1) or b in (select * from t2);select * from v2 A, v2 B where A.a = B.b;drop view v1, v2;drop table t1, t2, t3;## Test case for bug #8528: select from view over multi-table view#CREATE TABLE t1 (a int);CREATE TABLE t2 (b int);INSERT INTO t1 VALUES (1), (2), (3), (4);INSERT INTO t2 VALUES (4), (2);CREATE VIEW v1 AS SELECT * FROM t1,t2 WHERE t1.a=t2.b;SELECT * FROM v1;CREATE VIEW v2 AS SELECT * FROM v1;SELECT * FROM v2;DROP VIEW v2,v1;DROP TABLE t1, t2;## Correct restoring view name in SP table locking BUG#9758#create table t1 (a int);create view v1 as select sum(a) from t1 group by a;delimiter //;create procedure p1()beginselect * from v1;end//delimiter ;//call p1();call p1();drop procedure p1;drop view v1;drop table t1;## Bug#7422 "order by" doesn't work#CREATE TABLE t1(a char(2) primary key, b char(2));CREATE TABLE t2(a char(2), b char(2), index i(a));INSERT INTO t1 VALUES ('a','1'), ('b','2');INSERT INTO t2 VALUES ('a','5'), ('a','6'), ('b','5'), ('b','6');CREATE VIEW v1 AS  SELECT t1.b as c, t2.b as d FROM t1,t2 WHERE t1.a=t2.a;SELECT d, c FROM v1 ORDER BY d,c;DROP VIEW v1;DROP TABLE t1, t2;## using sum(distinct ) & avg(distinct ) in views (BUG#7015)#create table t1 (s1 int);create view  v1 as select sum(distinct s1) from t1;select * from v1;drop view v1;create view  v1 as select avg(distinct s1) from t1;select * from v1;drop view v1;drop table t1;## using cast(... as decimal) in views (BUG#11387);#create view v1 as select cast(1 as decimal);select * from v1;drop view v1;## Bug#11298 insert into select from VIEW produces incorrect result when #           using ORDER BYcreate table t1(f1 int);create table t2(f2 int);insert into t1 values(1),(2),(3);insert into t2 values(1),(2),(3);create view v1 as select * from t1,t2 where f1=f2;create table t3 (f1 int, f2 int);insert into t3 select * from v1 order by 1;select * from t3;drop view v1;drop table t1,t2,t3;## Generation unique names for columns, and correct names check (BUG#7448)## names with ' and \create view v1 as select '\\','\\shazam';select * from v1;drop view v1;create view v1 as select '\'','\shazam';select * from v1;drop view v1;# autogenerated names differ by case onlycreate view v1 as select 'k','K';select * from v1;drop view v1;create table t1 (s1 int);# same autogenerated namescreate view v1 as select s1, 's1' from t1;select * from v1;drop view v1;create view v1 as select 's1', s1 from t1;select * from v1;drop view v1;# set name as one of expected autogeneratedcreate view v1 as select 's1', s1, 1 as My_exp_s1 from t1;select * from v1;drop view v1;create view v1 as select 1 as My_exp_s1, 's1', s1  from t1;select * from v1;drop view v1;# set name conflict with autogenerated namescreate view v1 as select 1 as s1, 's1', 's1' from t1;select * from v1;drop view v1;create view v1 as select 's1', 's1', 1 as s1 from t1;select * from v1;drop view v1;# underlying field name conflict with autogenerated namescreate view v1 as select s1, 's1', 's1' from t1;select * from v1;drop view v1;create view v1 as select 's1', 's1', s1 from t1;select * from v1;drop view v1;# underlying field name conflict with set name-- error 1060create view v1 as select 1 as s1, 's1', s1 from t1;-- error 1060create view v1 as select 's1', s1, 1 as s1 from t1;drop table t1;# set names differ by case only-- error 1060create view v1(k, K) as select 1,2;## using time_format in view (BUG#7521)#create view v1 as SELECT TIME_FORMAT(SEC_TO_TIME(3600),'%H:%i') as t;select * from v1;drop view v1;## evaluation constant functions in WHERE (BUG#4663)#create table t1 (a timestamp default now());create table t2 (b timestamp default now());create view v1 as select a,b,t1.a < now() from t1,t2 where t1.a < now();SHOW CREATE VIEW v1;drop view v1;drop table t1, t2;CREATE TABLE t1 ( a varchar(50) );CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = CURRENT_USER();SHOW CREATE VIEW v1;DROP VIEW v1;CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = VERSION();SHOW CREATE VIEW v1;DROP VIEW v1;CREATE VIEW v1 AS SELECT * FROM t1 WHERE a = DATABASE();SHOW CREATE VIEW v1;DROP VIEW v1;DROP TABLE t1;## checking views after some view with error (BUG#11337)#CREATE TABLE t1 (col1 time);CREATE TABLE t2 (col1 time);CREATE VIEW v1 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t1;CREATE VIEW v2 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t2;CREATE VIEW v3 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t1;CREATE VIEW v4 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t2;CREATE VIEW v5 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t1;CREATE VIEW v6 AS SELECT CONVERT_TZ(col1,'GMT','MET') FROM t2;DROP TABLE t1;CHECK TABLE v1, v2, v3, v4, v5, v6;drop view v1, v2, v3, v4, v5, v6;drop table t2;--disable_warningsdrop function if exists f1;drop function if exists f2;--enable_warningsCREATE TABLE t1 (col1 time);CREATE TABLE t2 (col1 time);CREATE TABLE t3 (col1 time);create function f1 () returns int return (select max(col1) from t1);create function f2 () returns int return (select max(col1) from t2);CREATE VIEW v1 AS SELECT f1() FROM t3;CREATE VIEW v2 AS SELECT f2() FROM t3;CREATE VIEW v3 AS SELECT f1() FROM t3;CREATE VIEW v4 AS SELECT f2() FROM t3;CREATE VIEW v5 AS SELECT f1() FROM t3;CREATE VIEW v6 AS SELECT f2() FROM t3;drop function f1;CHECK TABLE v1, v2, v3, v4, v5, v6;create function f1 () returns int return (select max(col1) from t1);DROP TABLE t1;CHECK TABLE v1, v2, v3, v4, v5, v6;drop function f1;drop function f2;drop view v1, v2, v3, v4, v5, v6;drop table t2,t3;## bug #11325 Wrong date comparison in views#create table t1 (f1 date);insert into t1 values ('2005-01-01'),('2005-02-02');create view v1 as select * from t1;select * from v1 where f1='2005.02.02';select * from v1 where '2005.02.02'=f1;drop view v1;drop table t1;## using encrypt & substring_index in view (BUG#7024)#CREATE VIEW v1 AS SELECT ENCRYPT("dhgdhgd");disable_result_log;SELECT * FROM v1;enable_result_log;drop view v1;CREATE VIEW v1 AS SELECT SUBSTRING_INDEX("dkjhgd:kjhdjh", ":", 1);SELECT * FROM v1;drop view v1;## hide underlying tables names in case of imposibility to update (BUG#10773)#create table t1 (f59 int, f60 int, f61 int);insert into t1 values (19,41,32);create view v1 as select f59, f60 from t1 where f59 in           (select f59 from t1);-- error 1288update v1 set f60=2345;-- error 1443update t1 set f60=(select max(f60) from v1);drop view v1;drop table t1;## Using var_samp with view (BUG#10651)#create table t1 (s1 int);create view v1 as select var_samp(s1) from t1;show create view v1;drop view v1;drop table t1;## Correct inserting data check (absence of default value) for view# underlying tables (BUG#6443)#set sql_mode='strict_all_tables';CREATE TABLE t1 (col1 INT NOT NULL, col2 INT NOT NULL);CREATE VIEW v1 (vcol1) AS SELECT col1 FROM t1;CREATE VIEW v2 (vcol1) AS SELECT col1 FROM t1 WHERE col2 > 2;-- error 1364INSERT INTO t1 (col1) VALUES(12);-- error 1423INSERT INTO v1 (vcol1) VALUES(12);-- error 1423INSERT INTO v2 (vcol1) VALUES(12);set sql_mode=default;drop view v2,v1;drop table t1;## Bug#11399 Use an alias in a select statement on a view#create table t1 (f1 int);insert into t1 values (1);create view v1 as select f1 from t1;select f1 as alias from v1;drop view v1;drop table t1;## Test for bug #6120: SP cache to be invalidated when altering a view#CREATE TABLE t1 (s1 int, s2 int);INSERT  INTO t1 VALUES (1,2);CREATE VIEW v1 AS SELECT s2 AS s1, s1 AS s2 FROM t1;SELECT * FROM v1;CREATE PROCEDURE p1 () SELECT * FROM v1;CALL p1();ALTER VIEW v1 AS SELECT s1 AS s1, s2 AS s2 FROM t1;CALL p1();DROP VIEW v1;CREATE VIEW v1 AS SELECT s2 AS s1, s1 AS s2 FROM t1;CALL p1();DROP PROCEDURE p1;DROP VIEW v1;DROP TABLE t1;## Test for bug #11709 View was ordered by wrong column#create table t1 (f1 int, f2 int);create view v1 as select f1 as f3, f2 as f1 from t1;insert into t1 values (1,3),(2,1),(3,2);select * from v1 order by f1;drop view v1;drop table t1;## Test for bug #11771: wrong query_id in SELECT * FROM <view>#CREATE TABLE t1 (f1 char);INSERT INTO t1 VALUES ('A');CREATE VIEW  v1 AS SELECT * FROM t1;INSERT INTO t1 VALUES('B');SELECT * FROM v1;SELECT * FROM t1;DROP VIEW v1;DROP TABLE t1;## opening table in correct locking mode (BUG#9597)#CREATE TABLE t1 ( bug_table_seq   INTEGER NOT NULL);CREATE OR REPLACE VIEW v1 AS SELECT * from t1;DROP PROCEDURE IF EXISTS p1;delimiter //;CREATE PROCEDURE p1 ( )BEGIN        DO (SELECT  @next := IFNULL(max(bug_table_seq),0) + 1 FROM v1);        INSERT INTO t1 VALUES (1);END //delimiter ;//CALL p1();DROP PROCEDURE p1;DROP VIEW v1;DROP TABLE t1;## Bug #11335 View redefines column types#create table t1 (f1 tinyint(1), f2 char(1), f3 varchar(1), f4 geometry, f5 datetime);create view v1 as select * from t1;desc v1;drop view v1;drop table t1;## Bug #11760 Typo in Item_func_add_time::print() results in NULLs returned#             subtime() in viewcreate table t1(f1 datetime);insert into t1 values('2005.01.01 12:0:0');create view v1 as select f1, subtime(f1, '1:1:1') as sb from t1;select * from v1;drop view v1;drop table t1;## Test for bug #11412: query over a multitable view with GROUP_CONCAT#CREATE TABLE t1 (  aid int PRIMARY KEY,  fn varchar(20) NOT NULL,  ln varchar(20) NOT NULL);CREATE TABLE t2 (  aid int NOT NULL,  pid int NOT NULL);INSERT INTO t1 VALUES(1,'a','b'), (2,'c','d');INSERT INTO t2 values (1,1), (2,1), (2,2);CREATE VIEW v1 AS SELECT t1.*,t2.pid FROM t1,t2 WHERE t1.aid = t2.aid;SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM t1,t2   WHERE t1.aid = t2.aid GROUP BY pid;SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM v1 GROUP BY pid;DROP VIEW v1;DROP TABLE t1,t2;## Test for bug #12382: SELECT * FROM view after INSERT command#CREATE TABLE t1 (id int PRIMARY KEY, f varchar(255));CREATE VIEW v1 AS SELECT id, f FROM t1 WHERE id <= 2;INSERT INTO t1 VALUES (2, 'foo2');INSERT INTO t1 VALUES (1, 'foo1');SELECT * FROM v1;SELECT * FROM v1;DROP VIEW v1;DROP TABLE t1;## Test for bug #12470: crash for a simple select from a view defined#                      as a join over 5 tablesCREATE TABLE t1 (pk int PRIMARY KEY, b int);CREATE TABLE t2 (pk int PRIMARY KEY, fk int, INDEX idx(fk));CREATE TABLE t3 (pk int PRIMARY KEY, fk int, INDEX idx(fk));CREATE TABLE t4 (pk int PRIMARY KEY, fk int, INDEX idx(fk));CREATE TABLE t5 (pk int PRIMARY KEY, fk int, INDEX idx(fk));CREATE VIEW v1 AS  SELECT t1.pk as a FROM t1,t2,t3,t4,t5    WHERE t1.b IS NULL AND          t1.pk=t2.fk AND t2.pk=t3.fk AND t3.pk=t4.fk AND t4.pk=t5.fk;SELECT a FROM v1;DROP VIEW v1;DROP TABLE t1,t2,t3,t4,t5;## Bug #12298 Typo in  function name results in erroneous view being created.#create view v1 as select timestampdiff(day,'1997-01-01 00:00:00','1997-01-02 00:00:00') as f1;select * from v1;drop view v1;## repeatable CREATE VIEW statement BUG#12468#create table t1(a int);create procedure p1() create view v1 as select * from t1;drop table t1;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -