~mathiaz/ubuntu/lucid/mysql-dfsg-5.1/zap-bug-552053

« back to all changes in this revision

Viewing changes to mysql-test/t/view.test

  • Committer: Bazaar Package Importer
  • Author(s): Mathias Gug
  • Date: 2009-06-25 12:55:45 UTC
  • mfrom: (1.1.2 upstream) (0.1.3 experimental)
  • Revision ID: james.westby@ubuntu.com-20090625125545-m8ogs96zzsri74xe
Tags: 5.1.34-1ubuntu1
* Merge from debian experimental (and 5.0 from main), remaining changes:
  - debian/mysql-server-5.1.config:
    + ask for MySQL root password at priority high instead of medium so
      that the password prompt is seen on a default install. (LP: #319843)
    + don't ask for root password when upgrading from a 5.0 install.
  - debian/control:
    + Make libmysqlclient16-dev a transitional package depending on
      libmysqlclient-dev.
    + Make libmysqlclient-dev conflict with libmysqlclient15-dev.
    + Don't build mysql-server, mysql-client, mysql-common and
      libmysqlclient15-dev binary packages since they're still provided
      by mysql-dfsg-5.0.
    + Make mysql-{client,server}-5.1 packages conflict and
      replace mysql-{client,server}-5.0, but not provide
      mysql-{client,server}.
    + Depend on a specific version of mysql-common rather than the src
      version of mysql-dfsg-5.1 since mysql-common is currently part of
      mysql-dfsg-5.0.
    + Lower mailx from a Recommends to a Suggests to avoid pulling in
      a full MTA on all installs of mysql-server. (LP: #259477)
  - debian/rules:
    + added -fno-strict-aliasing to CFLAGS to get around mysql testsuite
      build failures.
    + install mysql-test and sql-bench to /usr/share/mysql/ rather than
      /usr/.
  - debian/additions/debian-start.inc.sh: support ANSI mode (LP: #310211)
  - Add AppArmor profile:
    - debian/apparmor-profile: apparmor profile.
    - debian/rules, debian/mysql-server-5.0.files: install apparmor profile.
    - debian/mysql-server-5.0.dirs: add etc/apparmor.d/force-complain
    - debian/mysql-server-5.0.postrm: remove symlink in force-complain/ on
      purge.
    - debian/mysql-server-5.1.README.Debian: add apparmor documentation.
    - debian/additions/my.cnf: Add warning about apparmor. (LP: #201799)
    - debian/mysql-server-5.1.postinst: reload apparmor profiles.
  - debian/additions/my.cnf: remove language option. Error message files are
    located in a different directory in MySQL 5.0. Setting the language
    option to use /usr/share/mysql/english breaks 5.0. Both 5.0 and 5.1
    use a default value that works. (LP: #316974)
  - debian/mysql-server-5.1.mysql.init:
    + Clearly indicate that we do not support running multiple instances
      of mysqld by duplicating the init script.
      (closes: #314785, #324834, #435165, #444216)
    + Properly parameterize all existing references to the mysql config
      file (/etc/mysql/my.cnf).
  - debian/mysql-server-5.0.postinst: Clear out the second password
    when setting up mysql. (LP: #344816)
  - mysql-server-core-5.1 package for files needed by Akonadi:
    + debian/control: create mysql-server-core-5.1 package.
    + debian/mysql-server-core-5.1.files, debian/mysql-server-5.1.files:
      move core mysqld files to mysql-server-core-5.1 package.
  - Don't package sql-bench and mysql-test file.
* Dropped changes:
  - debian/patches/92_ssl_test_cert.dpatch: certificate expiration in
    test suite (LP: #323755). Included upstream.
* Dropped from 5.0:
  - apparmor profile:
    - debian/control: Recommends apparmor >= 2.1+1075-0ubuntu6. All version
      of apparmor-profile (>hardy) are higher than this version.
    - debian/mysql-server-5.0.preinst: create symlink for force-complain/
      on pre-feisty upgrades, upgrades where apparmor-profiles profile is
      unchanged (ie non-enforcing) and upgrades where the profile
      doesn't exist. Support for pre-hardy upgrades is no longer needed.
* debian/mysql-server-5.1.postinst: fix debian-sys-maint user creation.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
#
11
11
 
12
12
# create view on nonexistent table
 
13
-- error ER_NO_SUCH_TABLE
13
14
create view v1 (c,d) as select a,b from t1;
14
15
 
15
16
create temporary table t1 (a int, b int);
16
17
# view on temporary table
 
18
-- error ER_VIEW_SELECT_TMPTABLE
17
19
create view v1 (c) as select b+1 from t1;
18
20
drop table t1;
19
21
 
42
42
select c from v1;
43
43
show create table v1;
44
44
show create view v1;
 
45
-- error ER_WRONG_OBJECT
45
46
show create view t1;
46
47
drop table t1;
47
48
 
48
49
# try to use fields from underlying table
 
50
-- error ER_BAD_FIELD_ERROR
49
51
select a from v1;
 
52
-- error ER_BAD_FIELD_ERROR
50
53
select v1.a from v1;
 
54
-- error ER_BAD_FIELD_ERROR
51
55
select b from v1;
 
56
-- error ER_BAD_FIELD_ERROR
52
57
select v1.b from v1;
53
58
 
54
59
# view with different algorithms (explain output differs)
64
64
explain extended select c from v2;
65
65
 
66
66
# try to use underlying table fields in VIEW creation process
 
67
-- error ER_BAD_FIELD_ERROR
67
68
create view v3 (c) as select a+1 from v1;
 
69
-- error ER_BAD_FIELD_ERROR
68
70
create view v3 (c) as select b+1 from v1;
69
71
 
70
72
 
104
104
select * from v2;
105
105
 
106
106
# try to create VIEW with name of existing VIEW
 
107
-- error ER_TABLE_EXISTS_ERROR
107
108
create view v1 (c,d,e,f) as select a,b, a in (select a+2 from t1), a = all (select a from t1) from t1;
108
109
 
109
110
# 'or replace' should work in this case
112
112
 
113
113
# try to ALTER unexisting VIEW
114
114
drop view v2;
 
115
-- error ER_NO_SUCH_TABLE
115
116
alter view v2 as select c, d from v1;
116
117
 
117
118
# 'or replace' on unexisting view
126
126
select * from v2;
127
127
 
128
128
# try to drop nonexistent VIEW
 
129
-- error ER_BAD_TABLE_ERROR
129
130
drop view v100;
130
131
 
131
132
# try to drop table with DROP VIEW
 
133
-- error ER_WRONG_OBJECT
132
134
drop view t1;
133
135
 
134
136
# try to drop VIEW with DROP TABLE
 
137
-- error ER_BAD_TABLE_ERROR
135
138
drop table v1;
136
139
 
137
140
# try to drop table with DROP VIEW
175
175
# syntax compatibility
176
176
#
177
177
create table t1 (a int);
 
178
-- error ER_VIEW_NONUPD_CHECK
178
179
create view v1 as select distinct a from t1 WITH CHECK OPTION;
179
180
create view v1 as select a from t1 WITH CHECK OPTION;
180
181
create view v2 as select a from t1 WITH CASCADED CHECK OPTION;
232
232
select is_updatable from information_schema.views where table_name='v2';
233
233
select is_updatable from information_schema.views where table_name='v1';
234
234
# try to update expression
 
235
-- error ER_NONUPDATEABLE_COLUMN
235
236
update v1 set c=a+c;
236
237
# try to update VIEW with forced TEMPORARY TABLE algorithm
 
238
-- error ER_NON_UPDATABLE_TABLE
237
239
update v2 set a=a+c;
238
240
# updatable field of updateable view
239
241
update v1 set a=a+c;
254
254
create view v1 (a,c) as select a, b+1 from t1;
255
255
create algorithm=temptable view v2 (a,c) as select a, b+1 from t1;
256
256
# try to update expression
 
257
-- error ER_NONUPDATEABLE_COLUMN
257
258
update t2,v1 set v1.c=v1.a+v1.c where t2.x=v1.a;
258
259
# try to update VIEW with forced TEMPORARY TABLE algorithm
 
260
-- error ER_NON_UPDATABLE_TABLE
259
261
update t2,v2 set v2.a=v2.v2.a+c where t2.x=v2.a;
260
262
# updatable field of updateable view
261
263
update t2,v1 set v1.a=v1.a+v1.c where t2.x=v1.a;
292
292
create view v1 (a,c) as select a, b+1 from t1;
293
293
create algorithm=temptable view v2 (a,c) as select a, b+1 from t1;
294
294
# try to update VIEW with forced TEMPORARY TABLE algorithm
 
295
-- error ER_NON_UPDATABLE_TABLE
295
296
delete from v2 where c < 4;
296
297
# updatable field of updateable view
297
298
delete from v1 where c < 4;
311
311
create view v1 (a,c) as select a, b+1 from t1;
312
312
create algorithm=temptable view v2 (a,c) as select a, b+1 from t1;
313
313
# try to update VIEW with forced TEMPORARY TABLE algorithm
 
314
-- error ER_NON_UPDATABLE_TABLE
314
315
delete v2 from t2,v2 where t2.x=v2.a;
315
316
# updatable field of updateable view
316
317
delete v1 from t2,v1 where t2.x=v1.a;
331
331
update v1 set x=x+1;
332
332
update v2 set x=x+1;
333
333
update v1 set x=x+1 limit 1;
 
334
-- error ER_NON_UPDATABLE_TABLE
334
335
update v2 set x=x+1 limit 1;
335
336
set updatable_views_with_limit=YES;
336
337
update v1 set x=x+1 limit 1;
424
424
insert into t1 values (1), (2), (3), (200);
425
425
create ALGORITHM=TEMPTABLE view v1 (x) as select a from t1;
426
426
create view v2 (y) as select x from v1;
 
427
-- error ER_NON_UPDATABLE_TABLE
427
428
update v2 set y=10 where y=2;
428
429
drop table t1;
429
430
drop view v1,v2;
479
479
create view v1 as select * from t1;
480
480
drop table t1;
481
481
create table t1 (col1 char(5),newcol2 char(5));
 
482
-- error ER_VIEW_INVALID
482
483
insert into v1 values('a','aa');
483
484
drop table t1;
 
485
-- error ER_VIEW_INVALID
484
486
select * from v1;
485
487
drop view v1;
486
488
 
487
489
#
488
490
# check of duplication of column names
489
491
#
 
492
-- error ER_DUP_FIELDNAME
490
493
create view v1 (a,a) as select 'a','a';
491
494
 
492
495
#
559
559
#
560
560
# error on preparation
561
561
#
 
562
-- error ER_NO_TABLES_USED
562
563
CREATE VIEW v02 AS SELECT * FROM DUAL;
563
564
SHOW TABLES;
564
565
 
575
575
#
576
576
create table t1 (col1 int,col2 char(22));
577
577
create view v1 as select * from t1;
 
578
-- error ER_WRONG_OBJECT
578
579
create index i1 on v1 (col1);
579
580
drop view v1;
580
581
drop table t1;
735
735
create table t1 (s1 int);
736
736
create view v1 as select x1() from t1;
737
737
drop function x1;
 
738
-- error ER_VIEW_INVALID
738
739
select * from v1;
739
740
--replace_column 8 # 12 # 13 #
740
741
show table status;
794
794
create view v1 as select a from t1;
795
795
create view v3 as select a from t1;
796
796
create database mysqltest;
 
797
-- error ER_FORBID_SCHEMA_CHANGE
797
798
rename table v1 to mysqltest.v1;
798
799
rename table v1 to v2;
799
 
--error 1050
 
800
--error ER_TABLE_EXISTS_ERROR
800
801
rename table v3 to v1, v2 to t1;
801
802
drop table t1;
802
803
drop view v2,v3;
810
810
create view v2 as select * from v1 union all select * from v1;
811
811
create view v3 as select * from v2 where 1 = (select `1` from v2);
812
812
create view v4 as select * from v3;
 
813
-- error ER_SUBQUERY_NO_1_ROW
813
814
select * from v4;
814
815
drop view v4, v3, v2, v1;
815
816
 
816
817
#
817
818
# VIEW over SELECT with prohibited clauses
818
819
#
 
820
-- error ER_VIEW_SELECT_CLAUSE
819
821
create view v1 as select 5 into @w;
 
822
-- error ER_VIEW_SELECT_CLAUSE
820
823
create view v1 as select 5 into outfile 'ttt';
821
824
create table t1 (a int);
 
825
-- error ER_VIEW_SELECT_CLAUSE
822
826
create view v1 as select a from t1 procedure analyse();
823
827
-- error ER_VIEW_SELECT_DERIVED
824
828
create view v1 as select 1 from (select 1) as d1;
848
848
create view v1 as select * from t1;
849
849
create view v2 as select * from v1;
850
850
create view v3 as select v2.col1 from v2,t2 where v2.col1 = t2.col1;
 
851
-- error ER_VIEW_PREVENT_UPDATE
851
852
update v2 set col1 = (select max(col1) from v1);
 
853
-- error ER_VIEW_PREVENT_UPDATE
852
854
update v2 set col1 = (select max(col1) from t1);
 
855
-- error ER_UPDATE_TABLE_USED
853
856
update v2 set col1 = (select max(col1) from v2);
 
857
-- error ER_VIEW_PREVENT_UPDATE
854
858
update v2,t2 set v2.col1 = (select max(col1) from v1) where v2.col1 = t2.col1;
 
859
-- error ER_VIEW_PREVENT_UPDATE
855
860
update t1,t2 set t1.col1 = (select max(col1) from v1) where t1.col1 = t2.col1;
 
861
-- error ER_UPDATE_TABLE_USED
856
862
update v1,t2 set v1.col1 = (select max(col1) from v1) where v1.col1 = t2.col1;
 
863
-- error ER_VIEW_PREVENT_UPDATE
857
864
update t2,v2 set v2.col1 = (select max(col1) from v1) where v2.col1 = t2.col1;
 
865
-- error ER_VIEW_PREVENT_UPDATE
858
866
update t2,t1 set t1.col1 = (select max(col1) from v1) where t1.col1 = t2.col1;
 
867
-- error ER_VIEW_PREVENT_UPDATE
859
868
update t2,v1 set v1.col1 = (select max(col1) from v1) where v1.col1 = t2.col1;
 
869
-- error ER_VIEW_PREVENT_UPDATE
860
870
update v2,t2 set v2.col1 = (select max(col1) from t1) where v2.col1 = t2.col1;
 
871
-- error ER_UPDATE_TABLE_USED
861
872
update t1,t2 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1;
 
873
-- error ER_VIEW_PREVENT_UPDATE
862
874
update v1,t2 set v1.col1 = (select max(col1) from t1) where v1.col1 = t2.col1;
 
875
-- error ER_UPDATE_TABLE_USED
863
876
update t2,v2 set v2.col1 = (select max(col1) from t1) where v2.col1 = t2.col1;
 
877
-- error ER_UPDATE_TABLE_USED
864
878
update t2,t1 set t1.col1 = (select max(col1) from t1) where t1.col1 = t2.col1;
 
879
-- error ER_UPDATE_TABLE_USED
865
880
update t2,v1 set v1.col1 = (select max(col1) from t1) where v1.col1 = t2.col1;
 
881
-- error ER_UPDATE_TABLE_USED
866
882
update v2,t2 set v2.col1 = (select max(col1) from v2) where v2.col1 = t2.col1;
 
883
-- error ER_VIEW_PREVENT_UPDATE
867
884
update t1,t2 set t1.col1 = (select max(col1) from v2) where t1.col1 = t2.col1;
 
885
-- error ER_VIEW_PREVENT_UPDATE
868
886
update v1,t2 set v1.col1 = (select max(col1) from v2) where v1.col1 = t2.col1;
 
887
-- error ER_VIEW_PREVENT_UPDATE
869
888
update t2,v2 set v2.col1 = (select max(col1) from v2) where v2.col1 = t2.col1;
 
889
-- error ER_VIEW_PREVENT_UPDATE
870
890
update t2,t1 set t1.col1 = (select max(col1) from v2) where t1.col1 = t2.col1;
 
891
-- error ER_VIEW_PREVENT_UPDATE
871
892
update t2,v1 set v1.col1 = (select max(col1) from v2) where v1.col1 = t2.col1;
 
893
-- error ER_VIEW_PREVENT_UPDATE
872
894
update v3 set v3.col1 = (select max(col1) from v1);
 
895
-- error ER_VIEW_PREVENT_UPDATE
873
896
update v3 set v3.col1 = (select max(col1) from t1);
 
897
-- error ER_VIEW_PREVENT_UPDATE
874
898
update v3 set v3.col1 = (select max(col1) from v2);
 
899
-- error ER_UPDATE_TABLE_USED
875
900
update v3 set v3.col1 = (select max(col1) from v3);
 
901
-- error ER_VIEW_PREVENT_UPDATE
876
902
delete from v2 where col1 = (select max(col1) from v1);
 
903
-- error ER_VIEW_PREVENT_UPDATE
877
904
delete from v2 where col1 = (select max(col1) from t1);
 
905
-- error ER_UPDATE_TABLE_USED
878
906
delete from v2 where col1 = (select max(col1) from v2);
 
907
-- error ER_VIEW_PREVENT_UPDATE
879
908
delete v2 from v2,t2 where (select max(col1) from v1) > 0 and v2.col1 = t2.col1;
 
909
-- error ER_VIEW_PREVENT_UPDATE
880
910
delete t1 from t1,t2 where (select max(col1) from v1) > 0 and t1.col1 = t2.col1;
 
911
-- error ER_UPDATE_TABLE_USED
881
912
delete v1 from v1,t2 where (select max(col1) from v1) > 0 and v1.col1 = t2.col1;
 
913
-- error ER_VIEW_PREVENT_UPDATE
882
914
delete v2 from v2,t2 where (select max(col1) from t1) > 0 and v2.col1 = t2.col1;
 
915
-- error ER_UPDATE_TABLE_USED
883
916
delete t1 from t1,t2 where (select max(col1) from t1) > 0 and t1.col1 = t2.col1;
 
917
-- error ER_VIEW_PREVENT_UPDATE
884
918
delete v1 from v1,t2 where (select max(col1) from t1) > 0 and v1.col1 = t2.col1;
 
919
-- error ER_UPDATE_TABLE_USED
885
920
delete v2 from v2,t2 where (select max(col1) from v2) > 0 and v2.col1 = t2.col1;
 
921
-- error ER_VIEW_PREVENT_UPDATE
886
922
delete t1 from t1,t2 where (select max(col1) from v2) > 0 and t1.col1 = t2.col1;
 
923
-- error ER_VIEW_PREVENT_UPDATE
887
924
delete v1 from v1,t2 where (select max(col1) from v2) > 0 and v1.col1 = t2.col1;
 
925
-- error ER_VIEW_PREVENT_UPDATE
888
926
insert into v2 values ((select max(col1) from v1));
 
927
-- error ER_VIEW_PREVENT_UPDATE
889
928
insert into t1 values ((select max(col1) from v1));
 
929
-- error ER_VIEW_PREVENT_UPDATE
890
930
insert into v2 values ((select max(col1) from v1));
 
931
-- error ER_VIEW_PREVENT_UPDATE
891
932
insert into v2 values ((select max(col1) from t1));
 
933
-- error ER_UPDATE_TABLE_USED
892
934
insert into t1 values ((select max(col1) from t1));
 
935
-- error ER_VIEW_PREVENT_UPDATE
893
936
insert into v2 values ((select max(col1) from t1));
 
937
-- error ER_UPDATE_TABLE_USED
894
938
insert into v2 values ((select max(col1) from v2));
 
939
-- error ER_VIEW_PREVENT_UPDATE
895
940
insert into t1 values ((select max(col1) from v2));
 
941
-- error ER_UPDATE_TABLE_USED
896
942
insert into v2 values ((select max(col1) from v2));
 
943
-- error ER_VIEW_PREVENT_UPDATE
897
944
insert into v3 (col1) values ((select max(col1) from v1));
 
945
-- error ER_VIEW_PREVENT_UPDATE
898
946
insert into v3 (col1) values ((select max(col1) from t1));
 
947
-- error ER_VIEW_PREVENT_UPDATE
899
948
insert into v3 (col1) values ((select max(col1) from v2));
900
 
#check with TZ tables in list
 
949
# check with TZ tables in list
 
950
-- error ER_VIEW_PREVENT_UPDATE
901
951
insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from v2));
902
952
insert into v3 (col1) values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2));
 
953
-- error ER_BAD_NULL_ERROR
903
954
insert into t3 values ((select CONVERT_TZ('20050101000000','UTC','MET') from t2));
904
955
# temporary table algorithm view should be equal to subquery in the from clause
905
956
create algorithm=temptable view v4 as select * from t1;
966
966
#
967
967
create table t1 (s1 int);
968
968
create view v1 as select * from t1;
 
969
-- error ER_WRONG_OBJECT
969
970
handler v1 open as xx;
970
971
drop view v1;
971
972
drop table t1;
1014
1014
create view v1 as select * from t1;
1015
1015
lock tables t1 read, v1 read;
1016
1016
select * from v1;
 
1017
-- error ER_TABLE_NOT_LOCKED
1017
1018
select * from t2;
1018
1019
drop view v1;
1019
1020
drop table t1, t2;
1026
1026
create view v1 as select * from t1 where a < 2 with check option;
1027
1027
# simple insert
1028
1028
insert into v1 values(1);
 
1029
-- error ER_VIEW_CHECK_FAILED
1029
1030
insert into v1 values(3);
1030
1031
# simple insert with ignore
1031
1032
insert ignore into v1 values (2),(3),(0);
1035
1035
delete from t1;
1036
1036
# INSERT SELECT test
1037
1037
insert into v1 SELECT 1;
 
1038
-- error ER_VIEW_CHECK_FAILED
1038
1039
insert into v1 SELECT 3;
1039
1040
# prepare data for next check
1040
1041
create table t2 (a int);
1043
1043
# INSERT SELECT with ignore test
1044
1044
insert ignore into v1 SELECT a from t2;
1045
1045
select * from t1 order by a desc;
1046
 
#simple UPDATE test
 
1046
# simple UPDATE test
1047
1047
update v1 set a=-1 where a=0;
 
1048
-- error ER_VIEW_CHECK_FAILED
1048
1049
update v1 set a=2 where a=1;
1049
1050
select * from t1 order by a desc;
1050
1051
# prepare data for next check
1072
1072
create view v3 as select * from v1 where a > 0 with cascaded check option;
1073
1073
insert into v2 values (1);
1074
1074
insert into v3 values (1);
 
1075
-- error ER_VIEW_CHECK_FAILED
1075
1076
insert into v2 values (0);
 
1077
-- error ER_VIEW_CHECK_FAILED
1076
1078
insert into v3 values (0);
1077
1079
insert into v2 values (2);
 
1080
-- error ER_VIEW_CHECK_FAILED
1078
1081
insert into v3 values (2);
1079
1082
select * from t1;
1080
1083
drop view v3,v2,v1;
1089
1089
create table t1 (a int, primary key (a));
1090
1090
create view v1 as select * from t1 where a < 2 with check option;
1091
1091
insert into v1 values (1) on duplicate key update a=2;
 
1092
-- error ER_VIEW_CHECK_FAILED
1092
1093
insert into v1 values (1) on duplicate key update a=2;
1093
1094
insert ignore into v1 values (1) on duplicate key update a=2;
1094
1095
select * from t1;
1102
1102
create table t1 (s1 int);
1103
1103
create view v1 as select * from t1;
1104
1104
create view v2 as select * from v1;
 
1105
-- error ER_NO_SUCH_TABLE
1105
1106
alter view v1 as select * from v2;
 
1107
-- error ER_NO_SUCH_TABLE
1106
1108
alter view v1 as select * from v1;
 
1109
-- error ER_NO_SUCH_TABLE
1107
1110
create or replace view v1 as select * from v2;
 
1111
-- error ER_NO_SUCH_TABLE
1108
1112
create or replace view v1 as select * from v1;
1109
1113
drop view v2,v1;
1110
1114
drop table t1;
1143
1143
# check it with check option
1144
1144
alter view v2 as select * from t2 where s1 in (select s1 from t1) with check option;
1145
1145
insert into v2 values (5);
 
1146
-- error ER_VIEW_CHECK_FAILED
1146
1147
update v2 set s1 = 1;
1147
1148
insert into t1 values (1);
1148
1149
update v2 set s1 = 1;
1175
1175
create table t1 (s1 tinyint);
1176
1176
create view v1 as select * from t1 where s1 <> 0 with local check option;
1177
1177
create view v2 as select * from v1 with cascaded check option;
 
1178
-- error ER_VIEW_CHECK_FAILED
1178
1179
insert into v2 values (0);
1179
1180
drop view v2, v1;
1180
1181
drop table t1;
1186
1186
create table t1 (s1 int);
1187
1187
create view v1 as select * from t1 where s1 < 5 with check option;
1188
1188
#single value
 
1189
-- error ER_VIEW_CHECK_FAILED
1189
1190
insert ignore into v1 values (6);
1190
1191
#several values
1191
1192
insert ignore into v1 values (6),(3);
1200
1200
create table t1 (s1 tinyint);
1201
1201
create trigger t1_bi before insert on t1 for each row set new.s1 = 500;
1202
1202
create view v1 as select * from t1 where s1 <> 127 with check option;
 
1203
-- error ER_VIEW_CHECK_FAILED
1203
1204
insert into v1 values (0);
1204
1205
select * from v1;
1205
1206
select * from t1;
1214
1214
create table t1 (s1 tinyint);
1215
1215
create view v1 as select * from t1 where s1 <> 0;
1216
1216
create view v2 as select * from v1 where s1 <> 1 with cascaded check option;
 
1217
-- error ER_VIEW_CHECK_FAILED
1217
1218
insert into v2 values (0);
1218
1219
select * from v2;
1219
1220
select * from t1;
1227
1227
# fixed length fields
1228
1228
create table t1 (a int, b char(10));
1229
1229
create view v1 as select * from t1 where a != 0 with check option;
1230
 
load data infile '../std_data_ln/loaddata3.dat' into table v1 fields terminated by '' enclosed by '' ignore 1 lines;
 
1230
-- error ER_VIEW_CHECK_FAILED
 
1231
load data infile '../../std_data/loaddata3.dat' into table v1 fields terminated by '' enclosed by '' ignore 1 lines;
1231
1232
select * from t1;
1232
1233
select * from v1;
1233
1234
delete from t1;
1234
 
load data infile '../std_data_ln/loaddata3.dat' ignore into table v1 fields terminated by '' enclosed by '' ignore 1 lines;
 
1235
load data infile '../../std_data/loaddata3.dat' ignore into table v1 fields terminated by '' enclosed by '' ignore 1 lines;
1235
1236
select * from t1 order by a,b;
1236
1237
select * from v1 order by a,b;
1237
1238
drop view v1;
1240
1240
# variable length fields
1241
1241
create table t1 (a text, b text);
1242
1242
create view v1 as select * from t1 where a <> 'Field A' with check option;
1243
 
load data infile '../std_data_ln/loaddata2.dat' into table v1 fields terminated by ',' enclosed by '''';
 
1243
-- error ER_VIEW_CHECK_FAILED
 
1244
load data infile '../../std_data/loaddata2.dat' into table v1 fields terminated by ',' enclosed by '''';
1244
1245
select concat('|',a,'|'), concat('|',b,'|') from t1;
1245
1246
select concat('|',a,'|'), concat('|',b,'|') from v1;
1246
1247
delete from t1;
1247
 
load data infile '../std_data_ln/loaddata2.dat' ignore into table v1 fields terminated by ',' enclosed by '''';
 
1248
load data infile '../../std_data/loaddata2.dat' ignore into table v1 fields terminated by ',' enclosed by '''';
1248
1249
select concat('|',a,'|'), concat('|',b,'|') from t1;
1249
1250
select concat('|',a,'|'), concat('|',b,'|') from v1;
1250
1251
drop view v1;
1321
1321
# view without primary key
1322
1322
create view v2 (a,b) as select t1.b as a, t2.a as b from t1, t2;
1323
1323
set updatable_views_with_limit=NO;
 
1324
-- error ER_NON_UPDATABLE_TABLE
1324
1325
update v2 set a= 10 where a=200 limit 1;
1325
1326
set updatable_views_with_limit=DEFAULT;
1326
1327
# just view selects
1349
1349
insert into t2 values (1000, 2000);
1350
1350
create view v3 (a,b) as select t1.a as a, t2.a as b from t1, t2;
1351
1351
# inserting into join view without field list
 
1352
-- error ER_VIEW_NO_INSERT_FIELD_LIST
1352
1353
insert into v3 values (1,2);
 
1354
-- error ER_VIEW_NO_INSERT_FIELD_LIST
1353
1355
insert into v3 select * from t2;
1354
1356
# inserting in several tables of join view
 
1357
-- error ER_VIEW_MULTIUPDATE
1355
1358
insert into v3(a,b) values (1,2);
 
1359
-- error ER_VIEW_MULTIUPDATE
1356
1360
insert into v3(a,b) select * from t2;
1357
1361
# correct inserts into join view
1358
1362
insert into v3(a) values (1);
1367
1367
select * from t1;
1368
1368
select * from t2;
1369
1369
# try delete from join view
 
1370
-- error ER_VIEW_DELETE_MERGE_VIEW
1370
1371
delete from v3;
 
1372
-- error ER_VIEW_DELETE_MERGE_VIEW
1371
1373
delete v3,t1 from v3,t1;
 
1374
-- error ER_VIEW_DELETE_MERGE_VIEW
1372
1375
delete t1,v3 from t1,v3;
1373
1376
# delete from t1 just to reduce result set size
1374
1377
delete from t1;
1394
1394
drop tables t1,t2;
1395
1395
 
1396
1396
#
1397
 
# View field names should be case insensitive 
 
1397
# View field names should be case insensitive
1398
1398
#
1399
1399
create table t1(f1 int);
1400
1400
create view v1 as select f1 from t1;
1403
1403
drop table t1;
1404
1404
 
1405
1405
#
1406
 
# Resolving view fields in subqueries in VIEW (Bug #6394)
 
1406
# Resolving view fields in subqueries in VIEW (Bug#6394)
1407
1407
#
1408
1408
create table t1(c1 int);
1409
1409
create table t2(c2 int);
1420
1420
drop table t1, t2;
1421
1421
 
1422
1422
#
1423
 
# view over other view setup (BUG#7433)
 
1423
# view over other view setup (Bug#7433)
1424
1424
#
1425
1425
CREATE TABLE t1 (C1 INT, C2 INT);
1426
1426
CREATE TABLE t2 (C2 INT);
1431
1431
drop table t1, t2;
1432
1432
 
1433
1433
#
1434
 
# view and group_concat() (BUG#7116)
 
1434
# view and group_concat() (Bug#7116)
1435
1435
#
1436
 
create table t1 (col1 char(5),col2 int,col3 int); 
1437
 
insert into t1 values ('one',10,25), ('two',10,50), ('two',10,50), ('one',20,25), ('one',30,25); 
 
1436
create table t1 (col1 char(5),col2 int,col3 int);
 
1437
insert into t1 values ('one',10,25), ('two',10,50), ('two',10,50), ('one',20,25), ('one',30,25);
1438
1438
create view v1 as select * from t1;
1439
1439
select col1,group_concat(col2,col3) from t1 group by col1;
1440
1440
select col1,group_concat(col2,col3) from v1 group by col1;
1442
1442
drop table t1;
1443
1443
 
1444
1444
#
1445
 
# Item_ref resolved as view field (BUG#6894)
 
1445
# Item_ref resolved as view field (Bug#6894)
1446
1446
#
1447
1447
create table t1 (s1 int, s2 char);
1448
1448
create view v1 as select s1, s2 from t1;
 
1449
-- error ER_BAD_FIELD_ERROR
1449
1450
select s2 from v1 vq1 where 2 = (select count(*) from v1 vq2 having vq1.s2 = vq2.s2);
1450
1451
select s2 from v1 vq1 where 2 = (select count(*) aa from v1 vq2 having vq1.s2 = aa);
1451
1452
drop view v1;
1452
1453
drop table t1;
1453
1454
 
1454
1455
#
1455
 
# Test case for bug #9398 CREATE TABLE with SELECT from a multi-table view
 
1456
# Test case for Bug#9398 CREATE TABLE with SELECT from a multi-table view
1456
1457
#
1457
1458
CREATE TABLE t1 (a1 int);
1458
1459
CREATE TABLE t2 (a2 int);
1469
1469
DROP TABLE t1,t2,t3;
1470
1470
 
1471
1471
#
1472
 
# Test for BUG#8703 "insert into table select from view crashes"
 
1472
# Test for Bug#8703 insert into table select from view crashes
1473
1473
#
1474
1474
create table t1 (a int);
1475
1475
create table t2 like t1;
1481
1481
drop table t1,t2,t3;
1482
1482
 
1483
1483
#
1484
 
# Test for BUG #6106: query over a view using subquery for the underlying table
 
1484
# Test for Bug#6106 query over a view using subquery for the underlying table
1485
1485
#
1486
1486
 
1487
 
CREATE TABLE t1 (col1 int PRIMARY KEY, col2 varchar(10)); 
1488
 
INSERT INTO t1 VALUES(1,'trudy'); 
1489
 
INSERT INTO t1 VALUES(2,'peter'); 
1490
 
INSERT INTO t1 VALUES(3,'sanja'); 
1491
 
INSERT INTO t1 VALUES(4,'monty'); 
1492
 
INSERT INTO t1 VALUES(5,'david'); 
1493
 
INSERT INTO t1 VALUES(6,'kent'); 
1494
 
INSERT INTO t1 VALUES(7,'carsten'); 
1495
 
INSERT INTO t1 VALUES(8,'ranger'); 
1496
 
INSERT INTO t1 VALUES(10,'matt'); 
1497
 
CREATE TABLE t2 (col1 int, col2 int, col3 char(1)); 
1498
 
INSERT INTO t2 VALUES (1,1,'y'); 
1499
 
INSERT INTO t2 VALUES (1,2,'y'); 
1500
 
INSERT INTO t2 VALUES (2,1,'n'); 
1501
 
INSERT INTO t2 VALUES (3,1,'n'); 
1502
 
INSERT INTO t2 VALUES (4,1,'y'); 
1503
 
INSERT INTO t2 VALUES (4,2,'n'); 
1504
 
INSERT INTO t2 VALUES (4,3,'n'); 
1505
 
INSERT INTO t2 VALUES (6,1,'n'); 
 
1487
CREATE TABLE t1 (col1 int PRIMARY KEY, col2 varchar(10));
 
1488
INSERT INTO t1 VALUES(1,'trudy');
 
1489
INSERT INTO t1 VALUES(2,'peter');
 
1490
INSERT INTO t1 VALUES(3,'sanja');
 
1491
INSERT INTO t1 VALUES(4,'monty');
 
1492
INSERT INTO t1 VALUES(5,'david');
 
1493
INSERT INTO t1 VALUES(6,'kent');
 
1494
INSERT INTO t1 VALUES(7,'carsten');
 
1495
INSERT INTO t1 VALUES(8,'ranger');
 
1496
INSERT INTO t1 VALUES(10,'matt');
 
1497
CREATE TABLE t2 (col1 int, col2 int, col3 char(1));
 
1498
INSERT INTO t2 VALUES (1,1,'y');
 
1499
INSERT INTO t2 VALUES (1,2,'y');
 
1500
INSERT INTO t2 VALUES (2,1,'n');
 
1501
INSERT INTO t2 VALUES (3,1,'n');
 
1502
INSERT INTO t2 VALUES (4,1,'y');
 
1503
INSERT INTO t2 VALUES (4,2,'n');
 
1504
INSERT INTO t2 VALUES (4,3,'n');
 
1505
INSERT INTO t2 VALUES (6,1,'n');
1506
1506
INSERT INTO t2 VALUES (8,1,'y');
1507
 
 
1508
 
CREATE VIEW v1 AS SELECT * FROM t1; 
1509
 
 
1510
 
SELECT a.col1,a.col2,b.col2,b.col3 
 
1507
 
 
1508
CREATE VIEW v1 AS SELECT * FROM t1;
 
1509
 
 
1510
SELECT a.col1,a.col2,b.col2,b.col3
1511
1511
  FROM t1 a LEFT JOIN t2 b ON a.col1=b.col1
1512
 
    WHERE b.col2 IS NULL OR 
 
1512
    WHERE b.col2 IS NULL OR
1513
1513
          b.col2=(SELECT MAX(col2) FROM t2 b WHERE b.col1=a.col1);
1514
1514
 
1515
 
SELECT a.col1,a.col2,b.col2,b.col3 
 
1515
SELECT a.col1,a.col2,b.col2,b.col3
1516
1516
  FROM v1 a LEFT JOIN t2 b ON a.col1=b.col1
1517
 
    WHERE b.col2 IS NULL OR 
 
1517
    WHERE b.col2 IS NULL OR
1518
1518
          b.col2=(SELECT MAX(col2) FROM t2 b WHERE b.col1=a.col1);
1519
1519
 
1520
 
CREATE VIEW v2 AS SELECT * FROM t2; 
 
1520
CREATE VIEW v2 AS SELECT * FROM t2;
1521
1521
 
1522
1522
SELECT a.col1,a.col2,b.col2,b.col3
1523
1523
  FROM v2 b RIGHT JOIN v1 a ON a.col1=b.col1
1524
1524
    WHERE b.col2 IS NULL OR
1525
 
          b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1); 
 
1525
          b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1);
1526
1526
 
1527
 
# Tests from the report for bug #6107
 
1527
# Tests from the report for Bug#6107
1528
1528
 
1529
1529
SELECT a.col1,a.col2,b.col2,b.col3
1530
1530
  FROM v2 b RIGHT JOIN v1 a ON a.col1=b.col1
1531
1531
    WHERE a.col1 IN (1,5,9) AND
1532
1532
         (b.col2 IS NULL OR
1533
 
          b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1)); 
 
1533
          b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1));
1534
1534
 
1535
1535
CREATE VIEW v3 AS SELECT * FROM t1 WHERE col1 IN (1,5,9);
1536
1536
 
1537
1537
SELECT a.col1,a.col2,b.col2,b.col3
1538
1538
  FROM v2 b RIGHT JOIN v3 a ON a.col1=b.col1
1539
1539
    WHERE b.col2 IS NULL OR
1540
 
          b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1); 
1541
 
 
 
1540
          b.col2=(SELECT MAX(col2) FROM v2 b WHERE b.col1=a.col1);
 
1541
 
1542
1542
DROP VIEW v1,v2,v3;
1543
1543
DROP TABLE t1,t2;
1544
1544
 
1545
1545
#
1546
 
# BUG#8490 Select from views containing subqueries causes server to hang 
1547
 
# forever.
 
1546
# Bug#8490 Select from views containing subqueries causes server to hang
 
1547
#          forever.
1548
1548
#
1549
1549
create table t1 as select 1 A union select 2 union select 3;
1550
1550
create table t2 as select * from t1;
1551
1551
create view v1 as select * from t1 where a in (select * from t2);
1552
1552
select * from v1 A, v1 B where A.a = B.a;
1553
1553
create table t3 as select a a,a b from t2;
1554
 
create view v2 as select * from t3 where 
 
1554
create view v2 as select * from t3 where
1555
1555
  a in (select * from t1) or b in (select * from t2);
1556
1556
select * from v2 A, v2 B where A.a = B.b;
1557
1557
drop view v1, v2;
1558
1558
drop table t1, t2, t3;
1559
1559
 
1560
1560
#
1561
 
# Test case for bug #8528: select from view over multi-table view
 
1561
# Test case for Bug#8528 select from view over multi-table view
1562
1562
#
1563
1563
CREATE TABLE t1 (a int);
1564
1564
CREATE TABLE t2 (b int);
1574
1574
 
1575
1575
DROP TABLE t1, t2;
1576
1576
#
1577
 
# Correct restoring view name in SP table locking BUG#9758
 
1577
# Correct restoring view name in SP table locking Bug#9758
1578
1578
#
1579
1579
create table t1 (a int);
1580
1580
create view v1 as select sum(a) from t1 group by a;
1603
1603
DROP VIEW v1;
1604
1604
DROP TABLE t1, t2;
1605
1605
#
1606
 
# using sum(distinct ) & avg(distinct ) in views (BUG#7015)
 
1606
# using sum(distinct ) & avg(distinct ) in views (Bug#7015)
1607
1607
#
1608
1608
create table t1 (s1 int);
1609
1609
create view  v1 as select sum(distinct s1) from t1;
1615
1615
drop table t1;
1616
1616
 
1617
1617
#
1618
 
# using cast(... as decimal) in views (BUG#11387);
 
1618
# using cast(... as decimal) in views (Bug#11387);
1619
1619
#
1620
1620
create view v1 as select cast(1 as decimal);
1621
1621
select * from v1;
1622
1622
drop view v1;
1623
1623
 
1624
1624
#
1625
 
# Bug#11298 insert into select from VIEW produces incorrect result when 
 
1625
# Bug#11298 insert into select from VIEW produces incorrect result when
1626
1626
#           using ORDER BY
1627
1627
create table t1(f1 int);
1628
1628
create table t2(f2 int);
1636
1636
drop table t1,t2,t3;
1637
1637
 
1638
1638
#
1639
 
# Generation unique names for columns, and correct names check (BUG#7448)
 
1639
# Generation unique names for columns, and correct names check (Bug#7448)
1640
1640
#
1641
1641
# names with ' and \
1642
1642
create view v1 as select '\\','\\shazam';
1679
1679
select * from v1;
1680
1680
drop view v1;
1681
1681
# underlying field name conflict with set name
 
1682
-- error ER_DUP_FIELDNAME
1682
1683
create view v1 as select 1 as s1, 's1', s1 from t1;
 
1684
-- error ER_DUP_FIELDNAME
1683
1685
create view v1 as select 's1', s1, 1 as s1 from t1;
1684
1686
drop table t1;
1685
1687
# set names differ by case only
 
1688
-- error ER_DUP_FIELDNAME
1686
1689
create view v1(k, K) as select 1,2;
1687
1690
 
1688
1691
#
1689
 
# using time_format in view (BUG#7521)
 
1692
# using time_format in view (Bug#7521)
1690
1693
#
1691
1694
create view v1 as SELECT TIME_FORMAT(SEC_TO_TIME(3600),'%H:%i') as t;
1692
1695
select * from v1;
1693
1696
drop view v1;
1694
1697
 
1695
1698
#
1696
 
# evaluation constant functions in WHERE (BUG#4663)
 
1699
# evaluation constant functions in WHERE (Bug#4663)
1697
1700
#
1698
1701
create table t1 (a timestamp default now());
1699
1702
create table t2 (b timestamp default now());
1717
1717
DROP TABLE t1;
1718
1718
 
1719
1719
#
1720
 
# checking views after some view with error (BUG#11337)
 
1720
# checking views after some view with error (Bug#11337)
1721
1721
#
1722
1722
CREATE TABLE t1 (col1 time);
1723
1723
CREATE TABLE t2 (col1 time);
1758
1758
drop table t2,t3;
1759
1759
 
1760
1760
#
1761
 
# bug #11325 Wrong date comparison in views
 
1761
# Bug#11325 Wrong date comparison in views
1762
1762
#
1763
1763
create table t1 (f1 date);
1764
1764
insert into t1 values ('2005-01-01'),('2005-02-02');
1769
1769
drop table t1;
1770
1770
 
1771
1771
#
1772
 
# using encrypt & substring_index in view (BUG#7024)
 
1772
# using encrypt & substring_index in view (Bug#7024)
1773
1773
#
1774
1774
CREATE VIEW v1 AS SELECT ENCRYPT("dhgdhgd");
1775
1775
disable_result_log;
1781
1781
drop view v1;
1782
1782
 
1783
1783
#
1784
 
# hide underlying tables names in case of imposibility to update (BUG#10773)
 
1784
# hide underlying tables names in case of imposibility to update (Bug#10773)
1785
1785
#
1786
1786
create table t1 (f59 int, f60 int, f61 int);
1787
1787
insert into t1 values (19,41,32);
1788
 
create view v1 as select f59, f60 from t1 where f59 in  
 
1788
create view v1 as select f59, f60 from t1 where f59 in
1789
1789
         (select f59 from t1);
 
1790
-- error ER_NON_UPDATABLE_TABLE
1790
1791
update v1 set f60=2345;
 
1792
-- error ER_VIEW_PREVENT_UPDATE
1791
1793
update t1 set f60=(select max(f60) from v1);
1792
1794
drop view v1;
1793
1795
drop table t1;
1794
1796
 
1795
1797
#
1796
 
# Using var_samp with view (BUG#10651)
 
1798
# Using var_samp with view (Bug#10651)
1797
1799
#
1798
1800
create table t1 (s1 int);
1799
1801
create view v1 as select var_samp(s1) from t1;
1803
1803
drop view v1;
1804
1804
drop table t1;
1805
1805
 
 
1806
 
1806
1807
#
1807
1808
# Correct inserting data check (absence of default value) for view
1808
 
# underlying tables (BUG#6443)
 
1809
# underlying tables (Bug#6443)
1809
1810
#
1810
1811
set sql_mode='strict_all_tables';
1811
1812
CREATE TABLE t1 (col1 INT NOT NULL, col2 INT NOT NULL);
1812
1813
CREATE VIEW v1 (vcol1) AS SELECT col1 FROM t1;
1813
1814
CREATE VIEW v2 (vcol1) AS SELECT col1 FROM t1 WHERE col2 > 2;
 
1815
-- error ER_NO_DEFAULT_FOR_FIELD
1814
1816
INSERT INTO t1 (col1) VALUES(12);
 
1817
-- error ER_NO_DEFAULT_FOR_VIEW_FIELD
1815
1818
INSERT INTO v1 (vcol1) VALUES(12);
 
1819
-- error ER_NO_DEFAULT_FOR_VIEW_FIELD
1816
1820
INSERT INTO v2 (vcol1) VALUES(12);
1817
1821
set sql_mode=default;
1818
1822
drop view v2,v1;
1819
1823
drop table t1;
1820
1824
 
 
1825
 
1821
1826
#
1822
1827
# Bug#11399 Use an alias in a select statement on a view
1823
1828
#
1831
1833
drop view v1;
1832
1834
drop table t1;
1833
1835
 
 
1836
 
1834
1837
#
1835
 
# Test for bug #6120: SP cache to be invalidated when altering a view
 
1838
# Test for Bug#6120 SP cache to be invalidated when altering a view
1836
1839
#
1837
1840
 
1838
1841
CREATE TABLE t1 (s1 int, s2 int);
1851
1854
DROP VIEW v1;
1852
1855
DROP TABLE t1;
1853
1856
 
 
1857
 
1854
1858
#
1855
 
# Test for bug #11709 View was ordered by wrong column
 
1859
# Test for Bug#11709 View was ordered by wrong column
1856
1860
#
1857
1861
create table t1 (f1 int, f2 int);
1858
1862
create view v1 as select f1 as f3, f2 as f1 from t1;
1861
1865
drop view v1;
1862
1866
drop table t1;
1863
1867
 
 
1868
 
1864
1869
#
1865
 
# Test for bug #11771: wrong query_id in SELECT * FROM <view>
 
1870
# Test for Bug#11771 wrong query_id in SELECT * FROM <view>
1866
1871
#
1867
1872
CREATE TABLE t1 (f1 char);
1868
1873
INSERT INTO t1 VALUES ('A');
1875
1880
DROP VIEW v1;
1876
1881
DROP TABLE t1;
1877
1882
 
 
1883
 
1878
1884
#
1879
 
# opening table in correct locking mode (BUG#9597)
 
1885
# opening table in correct locking mode (Bug#9597)
1880
1886
#
1881
1887
CREATE TABLE t1 ( bug_table_seq   INTEGER NOT NULL);
1882
1888
CREATE OR REPLACE VIEW v1 AS SELECT * from t1;
1893
1899
DROP VIEW v1;
1894
1900
DROP TABLE t1;
1895
1901
 
 
1902
 
1896
1903
#
1897
 
# Bug #11760 Typo in Item_func_add_time::print() results in NULLs returned
 
1904
# Bug#11760 Typo in Item_func_add_time::print() results in NULLs returned
1898
1905
#             subtime() in view
1899
1906
create table t1(f1 datetime);
1900
1907
insert into t1 values('2005.01.01 12:0:0');
1903
1910
drop view v1;
1904
1911
drop table t1;
1905
1912
 
 
1913
 
1906
1914
#
1907
 
# Test for bug #11412: query over a multitable view with GROUP_CONCAT
 
1915
# Test for Bug#11412 query over a multitable view with GROUP_CONCAT
1908
1916
#
1909
1917
CREATE TABLE t1 (
1910
1918
  aid int PRIMARY KEY,
1920
1928
 
1921
1929
CREATE VIEW v1 AS SELECT t1.*,t2.pid FROM t1,t2 WHERE t1.aid = t2.aid;
1922
1930
 
1923
 
SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM t1,t2 
 
1931
SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM t1,t2
1924
1932
  WHERE t1.aid = t2.aid GROUP BY pid;
1925
1933
SELECT pid,GROUP_CONCAT(CONCAT(fn,' ',ln) ORDER BY 1) FROM v1 GROUP BY pid;
1926
1934
 
1927
1935
DROP VIEW v1;
1928
1936
DROP TABLE t1,t2;
1929
1937
 
 
1938
 
1930
1939
#
1931
 
# Test for bug #12382: SELECT * FROM view after INSERT command
 
1940
# Test for Bug#12382 SELECT * FROM view after INSERT command
1932
1941
#
1933
1942
 
1934
1943
CREATE TABLE t1 (id int PRIMARY KEY, f varchar(255));
1942
1951
DROP VIEW v1;
1943
1952
DROP TABLE t1;
1944
1953
 
 
1954
 
1945
1955
#
1946
 
# Test for bug #12470: crash for a simple select from a view defined
1947
 
#                      as a join over 5 tables
 
1956
# Test for Bug#12470 crash for a simple select from a view defined
 
1957
#                    as a join over 5 tables
1948
1958
 
1949
1959
CREATE TABLE t1 (pk int PRIMARY KEY, b int);
1950
1960
CREATE TABLE t2 (pk int PRIMARY KEY, fk int, INDEX idx(fk));
1961
1971
DROP VIEW v1;
1962
1972
DROP TABLE t1,t2,t3,t4,t5;
1963
1973
 
 
1974
 
1964
1975
#
1965
 
# Bug #12298 Typo in  function name results in erroneous view being created.
 
1976
# Bug#12298 Typo in function name results in erroneous view being created.
1966
1977
#
1967
1978
create view v1 as select timestampdiff(day,'1997-01-01 00:00:00','1997-01-02 00:00:00') as f1;
1968
1979
select * from v1;
1969
1980
drop view v1;
1970
1981
 
1971
1982
#
1972
 
# repeatable CREATE VIEW statement BUG#12468
 
1983
# repeatable CREATE VIEW statement Bug#12468
1973
1984
#
1974
1985
create table t1(a int);
1975
1986
create procedure p1() create view v1 as select * from t1;
1976
1987
drop table t1;
 
1988
-- error ER_NO_SUCH_TABLE
1977
1989
call p1();
 
1990
-- error ER_NO_SUCH_TABLE
1978
1991
call p1();
1979
1992
drop procedure p1;
1980
1993
 
 
1994
 
1981
1995
#
1982
 
# Bug #10624 Views with multiple UNION and UNION ALL produce incorrect results
 
1996
# Bug#10624 Views with multiple UNION and UNION ALL produce incorrect results
1983
1997
#
1984
1998
create table t1 (f1 int);
1985
1999
create table t2 (f1 int);
1991
2003
select * from v1;
1992
2004
drop view v1;
1993
2005
drop table t1,t2;
1994
 
#
1995
 
# Test for bug #10970: view referring a temporary table indirectly
1996
 
#                     
 
2006
 
 
2007
 
 
2008
#
 
2009
# Test for Bug#10970 view referring a temporary table indirectly
 
2010
#
1997
2011
 
1998
2012
CREATE TEMPORARY TABLE t1 (a int);
1999
2013
CREATE FUNCTION f1 () RETURNS int RETURN (SELECT COUNT(*) FROM t1);
 
2014
-- error ER_VIEW_SELECT_TMPTABLE
2000
2015
CREATE VIEW v1 AS SELECT f1();
2001
2016
 
2002
2017
DROP FUNCTION f1;
2003
2018
DROP TABLE t1;
2004
2019
 
 
2020
 
2005
2021
#
2006
 
# BUG #12533 (crash on DESCRIBE <view> after renaming base table column)
 
2022
# Bug#12533 (crash on DESCRIBE <view> after renaming base table column)
2007
2023
#
2008
2024
--disable_warnings
2009
2025
DROP TABLE IF EXISTS t1;
2016
2031
DESCRIBE v1;
2017
2032
 
2018
2033
ALTER TABLE t1 CHANGE COLUMN f4 f4x CHAR(5);
2019
 
--error 1356
 
2034
--error ER_VIEW_INVALID
2020
2035
DESCRIBE v1;
2021
2036
DROP TABLE t1;
2022
2037
DROP VIEW v1;
2023
2038
 
2024
 
2025
 
# Bug #12489 wrongly printed strcmp() function results in creation of broken
 
2039
 
 
2040
#
 
2041
# Bug#12489 wrongly printed strcmp() function results in creation of broken
2026
2042
#            view
2027
2043
create table t1 (f1 char);
2028
2044
create view v1 as select strcmp(f1,'a') from t1;
2030
2046
drop view v1;
2031
2047
drop table t1;
2032
2048
 
 
2049
 
2033
2050
#
2034
 
# Bug #12922 if(sum(),...) with group from view returns wrong results 
 
2051
# Bug#12922 if(sum(),...) with group from view returns wrong results
2035
2052
#
2036
2053
create table t1 (f1 int, f2 int,f3 int);
2037
2054
insert into t1 values (1,10,20),(2,0,0);
2039
2056
select if(sum(f1)>1,f2,f3) from v1 group by f1;
2040
2057
drop view v1;
2041
2058
drop table t1;
2042
 
# BUG#12941
 
2059
 
 
2060
 
 
2061
# Bug#12941
2043
2062
#
2044
2063
--disable_warnings
2045
2064
create table t1 (
2049
2068
 
2050
2069
create table t2 (
2051
2070
  r_object_id char(16) NOT NULL,
2052
 
  i_position int(11) NOT NULL, 
 
2071
  i_position int(11) NOT NULL,
2053
2072
  users_names varchar(32) default NULL
2054
2073
) Engine = InnoDB;
2055
2074
--enable_warnings
2067
2086
insert into t2 values('120001a080000542',-2, 'guser02');
2068
2087
 
2069
2088
select v1.r_object_id, v2.users_names from v1, v2
2070
 
where (v1.group_name='tstgroup1') and v2.r_object_id=v1.r_object_id 
 
2089
where (v1.group_name='tstgroup1') and v2.r_object_id=v1.r_object_id
2071
2090
order by users_names;
2072
2091
 
2073
2092
drop view v1, v2;
2074
2093
drop table t1, t2;
2075
2094
 
2076
 
#
2077
 
# Bug #6808 - Views: CREATE VIEW v ... FROM t AS v fails
2078
 
#
2079
 
 
2080
 
create table t1 (s1 int); 
 
2095
 
 
2096
#
 
2097
# Bug#6808 Views: CREATE VIEW v ... FROM t AS v fails
 
2098
#
 
2099
 
 
2100
create table t1 (s1 int);
2081
2101
create view abc as select * from t1 as abc;
2082
2102
drop table t1;
2083
2103
drop view abc;
2084
2104
 
 
2105
 
2085
2106
#
2086
 
# Bug #12993 View column rename broken in subselect
 
2107
# Bug#12993 View column rename broken in subselect
2087
2108
#
2088
2109
create table t1(f1 char(1));
2089
2110
create view v1 as select * from t1;
2091
2112
drop view v1;
2092
2113
drop table t1;
2093
2114
 
 
2115
 
2094
2116
#
2095
 
# Bug #11416 Server crash if using a view that uses function convert_tz
 
2117
# Bug#11416 Server crash if using a view that uses function convert_tz
2096
2118
#
2097
2119
create view v1 as SELECT CONVERT_TZ('2004-01-01 12:00:00','GMT','MET');
2098
2120
select * from v1;
2099
2121
drop view v1;
2100
2122
 
 
2123
 
2101
2124
#
2102
 
# Bugs #12963, #13000: wrong creation of VIEW with DAYNAME, DAYOFWEEK, and WEEKDAY
 
2125
# Bugs#12963, #13000 wrong creation of VIEW with DAYNAME, DAYOFWEEK, and WEEKDAY
2103
2126
#
2104
2127
 
2105
2128
CREATE TABLE t1 (date DATE NOT NULL);
2129
2152
DROP TABLE t1;
2130
2153
DROP VIEW  v1, v2, v3;
2131
2154
 
 
2155
 
2132
2156
#
2133
 
# Bug #13411: crash when using non-qualified view column in HAVING clause 
 
2157
# Bug#13411 crash when using non-qualified view column in HAVING clause
2134
2158
#
2135
2159
 
2136
2160
CREATE TABLE t1 ( a int, b int );
2142
2166
DROP VIEW v1;
2143
2167
DROP TABLE t1;
2144
2168
 
 
2169
 
2145
2170
#
2146
 
# Bug #13410: failed name resolution for qualified view column in HAVING 
 
2171
# Bug#13410 failed name resolution for qualified view column in HAVING
2147
2172
#
2148
2173
 
2149
2174
CREATE TABLE t1 ( a int, b int );
2157
2182
DROP VIEW v1;
2158
2183
DROP TABLE t1;
2159
2184
 
 
2185
 
2160
2186
#
2161
 
# Bug #13327 view wasn't using index for const condition
 
2187
# Bug#13327 view wasn't using index for const condition
2162
2188
#
2163
2189
 
2164
2190
CREATE TABLE t1 (a INT, b INT, INDEX(a,b));
2175
2201
DROP VIEW v1,v2;
2176
2202
DROP TABLE t1,t2,t3;
2177
2203
 
 
2204
 
2178
2205
#
2179
 
# Bug #13622 Wrong view .frm created if some field's alias contain \n
 
2206
# Bug#13622 Wrong view .frm created if some field's alias contain \n
2180
2207
#
2181
2208
create table t1 (f1 int);
2182
2209
create view v1 as select t1.f1 as '123
2185
2212
drop view v1;
2186
2213
drop table t1;
2187
2214
 
2188
 
# Bug #14466 lost sort order in GROUP_CONCAT() in a view
 
2215
 
 
2216
# Bug#14466 lost sort order in GROUP_CONCAT() in a view
2189
2217
#
2190
2218
create table t1 (f1 int, f2 int);
2191
2219
insert into t1 values(1,1),(1,2),(1,3);
2196
2224
drop view v1,v2;
2197
2225
drop table t1;
2198
2226
 
 
2227
 
2199
2228
#
2200
 
# BUG#14026 Crash on second PS execution when using views
 
2229
# Bug#14026 Crash on second PS execution when using views
2201
2230
#
2202
2231
create table t1 (x int, y int);
2203
2232
create table t2 (x int, y int, z int);
2207
2236
create view v1 as
2208
2237
select t1.x
2209
2238
from (
2210
 
  (t1 join t2 on ((t1.y = t2.y))) 
2211
 
  join 
 
2239
  (t1 join t2 on ((t1.y = t2.y)))
 
2240
  join
2212
2241
  (t3 left join t4 on (t3.y = t4.y) and (t3.z = t4.z))
2213
2242
);
2214
2243
 
2220
2249
drop view v1;
2221
2250
drop table t1,t2,t3,t4;
2222
2251
 
 
2252
 
2223
2253
#
2224
 
# Bug #14540: OPTIMIZE, ANALYZE, REPAIR applied to not a view
 
2254
# Bug#14540 OPTIMIZE, ANALYZE, REPAIR applied to not a view
2225
2255
#
2226
2256
 
2227
2257
CREATE TABLE t1(id INT);
2240
2270
 
2241
2271
 
2242
2272
#
2243
 
# BUG#14719: Views DEFINER grammar is incorrect
 
2273
# Bug#14719 Views DEFINER grammar is incorrect
2244
2274
#
2245
2275
 
2246
2276
create definer = current_user() sql security invoker view v1 as select 1;
2251
2281
show create view v1;
2252
2282
drop view v1;
2253
2283
 
 
2284
 
2254
2285
#
2255
 
# Bug #14816 test_if_order_by_key() expected only Item_fields.
 
2286
# Bug#14816 test_if_order_by_key() expected only Item_fields.
2256
2287
#
2257
2288
create table t1 (id INT, primary key(id));
2258
2289
insert into t1 values (1),(2);
2261
2292
drop view v1;
2262
2293
drop table t1;
2263
2294
 
 
2295
 
2264
2296
#
2265
 
# Bug #14850 Item_ref's values wasn't updated
 
2297
# Bug#14850 Item_ref's values wasn't updated
2266
2298
#
2267
2299
create table t1(f1 int, f2 int);
2268
2300
insert into t1 values (null, 10), (null,2);
2272
2304
drop view v1;
2273
2305
drop table t1;
2274
2306
 
 
2307
 
2275
2308
#
2276
 
# BUG#14885: incorrect SOURCE in view created in a procedure
 
2309
# Bug#14885 incorrect SOURCE in view created in a procedure
2277
2310
# TODO: here SOURCE string must be shown when it will be possible
2278
2311
#
2279
2312
--disable_warnings
2291
2324
drop view v1;
2292
2325
drop procedure p1;
2293
2326
 
 
2327
 
2294
2328
#
2295
 
# BUG#15096: using function with view for view creation
 
2329
# Bug#15096 using function with view for view creation
2296
2330
#
2297
2331
CREATE VIEW v1 AS SELECT 42 AS Meaning;
2298
2332
--disable_warnings
2312
2346
drop view v2,v1;
2313
2347
drop function f1;
2314
2348
 
 
2349
 
2315
2350
#
2316
 
# Bug#14861: aliased column names are not preserved.
 
2351
# Bug#14861 aliased column names are not preserved.
2317
2352
#
2318
2353
create table t1 (id numeric, warehouse_id numeric);
2319
2354
create view v1 as select id from t1;
2331
2366
drop view v2, v1;
2332
2367
drop table t1;
2333
2368
 
 
2369
 
2334
2370
#
2335
 
# Bug#16016: MIN/MAX optimization for views
 
2371
# Bug#16016 MIN/MAX optimization for views
2336
2372
#
2337
2373
 
2338
2374
CREATE TABLE t1 (a int PRIMARY KEY, b int);
2355
2391
DROP VIEW v1;
2356
2392
DROP TABLE t1;
2357
2393
 
 
2394
 
2358
2395
#
2359
 
# Bug#16382: grouping name is resolved against a view column name
2360
 
#            which coincides with a select column name
 
2396
# Bug#16382 grouping name is resolved against a view column name
 
2397
#           which coincides with a select column name
2361
2398
 
2362
2399
CREATE TABLE t1 (x varchar(10));
2363
2400
INSERT INTO t1 VALUES (null), ('foo'), ('bar'), (null);
2372
2409
DROP VIEW v1;
2373
2410
DROP TABLE t1;
2374
2411
 
 
2412
 
2375
2413
#
2376
 
# BUG#15943: mysql_next_result hangs on invalid SHOW CREATE VIEW
 
2414
# Bug#15943 mysql_next_result hangs on invalid SHOW CREATE VIEW
2377
2415
#
2378
2416
 
2379
2417
delimiter //;
2380
 
drop table if exists t1; 
2381
 
drop view if exists v1; 
2382
 
create table t1 (id int); 
2383
 
create view v1 as select * from t1; 
2384
 
drop table t1; 
2385
 
show create view v1; 
 
2418
drop table if exists t1;
 
2419
drop view if exists v1;
 
2420
create table t1 (id int);
 
2421
create view v1 as select * from t1;
 
2422
drop table t1;
 
2423
show create view v1;
2386
2424
drop view v1;
2387
2425
//
2388
2426
delimiter ;//
2389
2427
 
 
2428
 
2390
2429
#
2391
2430
# Bug#17726 Not checked empty list caused endless loop
2392
2431
#
2401
2440
drop view v2, v1;
2402
2441
drop table t1;
2403
2442
 
 
2443
 
2404
2444
#
2405
 
# Bug #18386: select from view over a table with ORDER BY view_col clause 
2406
 
#             given view_col is not an image of any column from the base table
 
2445
# Bug#18386 select from view over a table with ORDER BY view_col clause
 
2446
#           given view_col is not an image of any column from the base table
2407
2447
 
2408
2448
CREATE TABLE t1 (a int);
2409
2449
INSERT INTO t1 VALUES (1), (2);
2415
2455
DROP VIEW v1;
2416
2456
DROP TABLE t1;
2417
2457
 
2418
 
#
2419
 
# Bug #18237: invalid count optimization applied to an outer join with a view 
2420
 
#             
 
2458
 
 
2459
#
 
2460
# Bug#18237 invalid count optimization applied to an outer join with a view
 
2461
#
2421
2462
 
2422
2463
CREATE TABLE t1 (id int PRIMARY KEY);
2423
2464
CREATE TABLE t2 (id int PRIMARY KEY);
2436
2477
 
2437
2478
DROP TABLE t1, t2;
2438
2479
 
 
2480
 
2439
2481
#
2440
 
# Bug #16069: VIEW does return the same results as underlying SELECT
2441
 
#             with WHERE condition containing BETWEEN over dates 
 
2482
# Bug#16069 VIEW does return the same results as underlying SELECT
 
2483
#           with WHERE condition containing BETWEEN over dates
2442
2484
# Dates as strings should be casted to date type
 
2485
 
2443
2486
CREATE TABLE t1 (id int NOT NULL PRIMARY KEY,
2444
2487
                 td date DEFAULT NULL, KEY idx(td));
2445
2488
 
2446
 
INSERT INTO t1 VALUES 
 
2489
INSERT INTO t1 VALUES
2447
2490
 (1, '2005-01-01'), (2, '2005-01-02'), (3, '2005-01-02'),
2448
2491
 (4, '2005-01-03'), (5, '2005-01-04'), (6, '2005-01-05'),
2449
2492
 (7, '2005-01-05'), (8, '2005-01-05'), (9, '2005-01-06');
2456
2499
DROP VIEW v1;
2457
2500
DROP TABLE t1;
2458
2501
 
 
2502
 
2459
2503
#
2460
 
# BUG#14308: Recursive view definitions
 
2504
# Bug#14308 Recursive view definitions
2461
2505
#
2462
2506
# using view only
2463
2507
create table t1 (a int);
2487
2531
drop function f1;
2488
2532
drop view t1, v1;
2489
2533
 
 
2534
 
2490
2535
#
2491
 
# Bug #15153: CONVERT_TZ() is not allowed in all places in VIEWs
 
2536
# Bug#15153 CONVERT_TZ() is not allowed in all places in VIEWs
2492
2537
#
2493
2538
# Error was reported when one tried to use CONVERT_TZ() function
2494
2539
# select list of view which was processed using MERGE algorithm.
2499
2544
create view v1 as select convert_tz(dt, 'UTC', 'Europe/Moscow') as ldt from t1;
2500
2545
select * from v1;
2501
2546
drop view v1;
2502
 
# And in its where part 
 
2547
# And in its where part
2503
2548
create view v1 as select * from t1 where convert_tz(dt, 'UTC', 'Europe/Moscow') >= 20050101000000;
2504
2549
select * from v1;
2505
2550
# Other interesting case - a view which uses convert_tz() function
2514
2559
drop view v1, v2;
2515
2560
drop table t1;
2516
2561
 
 
2562
 
2517
2563
#
2518
 
# Bug #19490: usage of view specified by a query with GROUP BY
2519
 
#             an expression containing non-constant interval
 
2564
# Bug#19490 usage of view specified by a query with GROUP BY
 
2565
#           an expression containing non-constant interval
2520
2566
 
2521
2567
CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, d datetime);
2522
2568
 
2530
2576
DROP VIEW v1;
2531
2577
DROP TABLE t1;
2532
2578
 
 
2579
 
2533
2580
#
2534
 
# Bug#19077: A nested materialized view is used before being populated.
 
2581
# Bug#19077 A nested materialized view is used before being populated.
2535
2582
#
2536
2583
CREATE TABLE t1 (i INT, j BIGINT);
2537
2584
INSERT INTO t1 VALUES (1, 2), (2, 2), (3, 2);
2541
2588
DROP VIEW v2, v1;
2542
2589
DROP TABLE t1;
2543
2590
 
2544
 
#
2545
 
# Bug #19573: VIEW with HAVING that refers an alias name
2546
 
 
2591
 
 
2592
#
 
2593
# Bug#19573 VIEW with HAVING that refers an alias name
 
2594
#
2547
2595
 
2548
2596
CREATE TABLE t1(
2549
2597
  fName varchar(25) NOT NULL,
2551
2599
  DOB date NOT NULL,
2552
2600
  test_date date NOT NULL,
2553
2601
  uID int unsigned NOT NULL AUTO_INCREMENT PRIMARY KEY);
2554
 
 
 
2602
 
2555
2603
INSERT INTO t1(fName, lName, DOB, test_date) VALUES
2556
2604
  ('Hank', 'Hill', '1964-09-29', '2007-01-01'),
2557
2605
  ('Tom', 'Adams', '1908-02-14', '2007-01-01'),
2559
2607
 
2560
2608
CREATE VIEW v1 AS
2561
2609
  SELECT (year(test_date)-year(DOB)) AS Age
2562
 
    FROM t1 HAVING Age < 75; 
2563
 
SHOW CREATE VIEW v1;           
 
2610
    FROM t1 HAVING Age < 75;
 
2611
SHOW CREATE VIEW v1;
2564
2612
 
2565
2613
SELECT (year(test_date)-year(DOB)) AS Age FROM t1 HAVING Age < 75;
2566
2614
SELECT * FROM v1;
2568
2616
DROP VIEW v1;
2569
2617
DROP TABLE t1;
2570
2618
 
 
2619
 
2571
2620
#
2572
 
# Bug #19089: wrong inherited dafault values in temp table views
 
2621
# Bug#19089 wrong inherited dafault values in temp table views
2573
2622
#
2574
2623
 
2575
2624
CREATE TABLE t1 (id int NOT NULL PRIMARY KEY, a char(6) DEFAULT 'xxx');
2599
2648
DROP VIEW v1;
2600
2649
DROP TABLE t1,t2;
2601
2650
 
 
2651
 
2602
2652
#
2603
 
# Bug#16110: insert permitted into view col w/o default value
 
2653
# Bug#16110 insert permitted into view col w/o default value
2604
2654
#
2605
2655
CREATE TABLE t1 (a INT NOT NULL, b INT NULL DEFAULT NULL);
2606
2656
CREATE VIEW v1 AS SELECT a, b FROM t1;
2608
2658
INSERT INTO v1 (b) VALUES (2);
2609
2659
 
2610
2660
SET SQL_MODE = STRICT_ALL_TABLES;
2611
 
--error 1423
 
2661
--error ER_NO_DEFAULT_FOR_VIEW_FIELD
2612
2662
INSERT INTO v1 (b) VALUES (4);
2613
2663
SET SQL_MODE = '';
2614
2664
 
2617
2667
DROP VIEW v1;
2618
2668
DROP TABLE t1;
2619
2669
 
 
2670
 
2620
2671
#
2621
 
# Bug #18243: expression over a view column that with the REVERSE function
 
2672
# Bug#18243 expression over a view column that with the REVERSE function
2622
2673
#
2623
2674
 
2624
2675
CREATE TABLE t1 (firstname text, surname text);
2633
2684
DROP VIEW v1;
2634
2685
DROP TABLE t1;
2635
2686
 
 
2687
 
2636
2688
#
2637
 
# Bug #19714: wrong type of a view column specified by an expressions over ints
 
2689
# Bug#19714 wrong type of a view column specified by an expressions over ints
2638
2690
#
2639
2691
 
2640
2692
CREATE TABLE t1 (i int, j int);
2641
2693
CREATE VIEW v1 AS SELECT COALESCE(i,j) FROM t1;
2642
2694
DESCRIBE v1;
2643
 
CREATE TABLE t2 SELECT COALESCE(i,j) FROM t1;  
 
2695
CREATE TABLE t2 SELECT COALESCE(i,j) FROM t1;
2644
2696
DESCRIBE t2;
2645
2697
 
2646
2698
DROP VIEW v1;
2647
2699
DROP TABLE t1,t2;
2648
2700
 
 
2701
 
2649
2702
#
2650
 
# Bug #17526: views with TRIM functions
 
2703
# Bug#17526 views with TRIM functions
2651
2704
#
2652
2705
 
2653
2706
CREATE TABLE t1 (s varchar(10));
2658
2711
SELECT * FROM v1;
2659
2712
DROP VIEW v1;
2660
2713
 
2661
 
SELECT TRIM(LEADING 'y' FROM s) FROM t1; 
 
2714
SELECT TRIM(LEADING 'y' FROM s) FROM t1;
2662
2715
CREATE VIEW v1 AS SELECT TRIM(LEADING 'y' FROM s) FROM t1;
2663
2716
SELECT * FROM v1;
2664
2717
DROP VIEW v1;
2665
2718
 
2666
 
SELECT TRIM(TRAILING 'y' FROM s) FROM t1; 
 
2719
SELECT TRIM(TRAILING 'y' FROM s) FROM t1;
2667
2720
CREATE VIEW v1 AS SELECT TRIM(TRAILING 'y' FROM s) FROM t1;
2668
2721
SELECT * FROM v1;
2669
2722
DROP VIEW v1;
2670
2723
 
2671
2724
DROP TABLE t1;
2672
2725
 
 
2726
 
2673
2727
#
2674
 
#Bug #21080: ALTER VIEW makes user restate SQL SECURITY mode, and ALGORITHM
 
2728
# Bug#21080 ALTER VIEW makes user restate SQL SECURITY mode, and ALGORITHM
2675
2729
#
2676
2730
CREATE TABLE t1 (x INT, y INT);
2677
2731
CREATE ALGORITHM=TEMPTABLE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1;
2682
2736
 
2683
2737
DROP VIEW v1;
2684
2738
DROP TABLE t1;
2685
 
# Bug #21086: server crashes when VIEW defined with a SELECT with COLLATE 
2686
 
# clause is called
 
2739
 
 
2740
 
 
2741
# Bug#21086 server crashes when VIEW defined with a SELECT with COLLATE
 
2742
#           clause is called
2687
2743
#
2688
2744
CREATE TABLE t1 (s1 char);
2689
2745
INSERT INTO t1 VALUES ('Z');
2700
2756
DROP VIEW v1, v2;
2701
2757
DROP TABLE t1;
2702
2758
 
 
2759
 
2703
2760
#
2704
 
# Bug #11551: Asymmetric + undocumented behaviour of DROP VIEW and DROP TABLE
 
2761
# Bug#11551 Asymmetric + undocumented behaviour of DROP VIEW and DROP TABLE
2705
2762
#
2706
2763
CREATE TABLE t1 (id INT);
2707
2764
CREATE VIEW v1 AS SELECT id FROM t1;
2708
2765
SHOW TABLES;
2709
2766
 
2710
 
--error 1051
 
2767
--error ER_BAD_TABLE_ERROR
2711
2768
DROP VIEW v2,v1;
2712
2769
SHOW TABLES;
2713
2770
 
2714
2771
CREATE VIEW v1 AS SELECT id FROM t1;
2715
 
--error 1347
 
2772
--error ER_WRONG_OBJECT
2716
2773
DROP VIEW t1,v1;
2717
2774
SHOW TABLES;
2718
2775
 
2721
2778
DROP VIEW IF EXISTS v1;
2722
2779
--enable_warnings
2723
2780
 
 
2781
 
2724
2782
#
2725
 
# Bug #21261: Wrong access rights was required for an insert to a view
 
2783
# Bug#21261 Wrong access rights was required for an insert to a view
2726
2784
#
2727
2785
CREATE DATABASE bug21261DB;
2728
2786
USE bug21261DB;
2729
 
CONNECT (root,localhost,root,,bug21261DB);
2730
 
CONNECTION root;
 
2787
connect (root,localhost,root,,bug21261DB);
 
2788
connection root;
2731
2789
 
2732
2790
CREATE TABLE t1 (x INT);
2733
2791
CREATE SQL SECURITY INVOKER VIEW v1 AS SELECT x FROM t1;
2736
2794
CREATE TABLE t2 (y INT);
2737
2795
GRANT SELECT ON t2 TO 'user21261'@'localhost';
2738
2796
 
2739
 
CONNECT (user21261, localhost, user21261,, bug21261DB);
2740
 
CONNECTION user21261;
 
2797
connect (user21261, localhost, user21261,, bug21261DB);
 
2798
connection user21261;
2741
2799
INSERT INTO v1 (x) VALUES (5);
2742
2800
UPDATE v1 SET x=1;
2743
 
CONNECTION root;
 
2801
connection root;
2744
2802
GRANT SELECT ON v1 TO 'user21261'@'localhost';
2745
2803
GRANT SELECT ON t1 TO 'user21261'@'localhost';
2746
 
CONNECTION user21261;
 
2804
connection user21261;
2747
2805
UPDATE v1,t2 SET x=1 WHERE x=y;
2748
 
CONNECTION root;
 
2806
connection root;
2749
2807
SELECT * FROM t1;
2750
2808
REVOKE ALL PRIVILEGES, GRANT OPTION FROM 'user21261'@'localhost';
2751
2809
DROP USER 'user21261'@'localhost';
2752
2810
DROP VIEW v1;
2753
2811
DROP TABLE t1;
2754
2812
DROP DATABASE bug21261DB;
 
2813
 
 
2814
connection default;
2755
2815
USE test;
 
2816
disconnect root;
 
2817
disconnect user21261;
 
2818
 
2756
2819
 
2757
2820
#
2758
 
# Bug #15950: NOW() optimized away in VIEWs
 
2821
# Bug#15950 NOW() optimized away in VIEWs
2759
2822
#
2760
2823
create table t1 (f1 datetime);
2761
2824
create view v1 as select * from t1 where f1 between now() and now() + interval 1 minute;
2762
2825
show create view v1;
2763
2826
drop view v1;
2764
2827
drop table t1;
 
2828
 
 
2829
 
2765
2830
#
2766
 
# Test for BUG#16899: Possible buffer overflow in handling of DEFINER-clause.
 
2831
# Test for Bug#16899 Possible buffer overflow in handling of DEFINER-clause.
2767
2832
#
2768
2833
 
2769
2834
# Prepare.
2790
2855
 
2791
2856
 
2792
2857
#
2793
 
# BUG#17591: Updatable view not possible with trigger or stored
2794
 
# function 
 
2858
# Bug#17591 Updatable view not possible with trigger or stored function
2795
2859
#
2796
2860
# During prelocking phase we didn't update lock type of view tables,
2797
2861
# hence READ lock was always requested.
2835
2899
DROP VIEW v1, v2;
2836
2900
DROP TABLE t1;
2837
2901
 
2838
 
#
2839
 
# Bug #5500: wrong select_type in EXPLAIN output for queries over views
2840
 
#
2841
 
 
2842
 
CREATE TABLE t1 (s1 int); 
 
2902
 
 
2903
#
 
2904
# Bug#5500 wrong select_type in EXPLAIN output for queries over views
 
2905
#
 
2906
 
 
2907
CREATE TABLE t1 (s1 int);
2843
2908
CREATE VIEW v1 AS SELECT * FROM t1;
2844
2909
 
2845
2910
EXPLAIN SELECT * FROM t1;
2847
2912
 
2848
2913
INSERT INTO t1 VALUES (1), (3), (2);
2849
2914
 
2850
 
EXPLAIN SELECT * FROM t1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1); 
2851
 
EXPLAIN SELECT * FROM v1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1); 
 
2915
EXPLAIN SELECT * FROM t1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1);
 
2916
EXPLAIN SELECT * FROM v1 t WHERE t.s1+1 < (SELECT MAX(t1.s1) FROM t1);
2852
2917
 
2853
2918
DROP VIEW v1;
2854
2919
DROP TABLE t1;
2855
2920
 
 
2921
 
2856
2922
#
2857
 
# Bug #5505: Wrong error message on INSERT into a view
 
2923
# Bug#5505 Wrong error message on INSERT into a view
2858
2924
#
2859
2925
create table t1 (s1 int);
2860
2926
create view v1 as select s1 as a, s1 as b from t1;
2861
2927
--error ER_NON_INSERTABLE_TABLE
2862
 
insert into v1 values (1,1); 
 
2928
insert into v1 values (1,1);
2863
2929
update v1 set a = 5;
2864
2930
drop view v1;
2865
2931
drop table t1;
2866
2932
 
2867
 
#
2868
 
# Bug #21646: view qith a subquery in ON expression 
2869
 
#
2870
 
 
2871
 
CREATE TABLE t1(pk int PRIMARY KEY); 
 
2933
 
 
2934
#
 
2935
# Bug#21646 view qith a subquery in ON expression
 
2936
#
 
2937
 
 
2938
CREATE TABLE t1(pk int PRIMARY KEY);
2872
2939
CREATE TABLE t2(pk int PRIMARY KEY, fk int, ver int, org int);
2873
2940
 
2874
 
CREATE ALGORITHM=MERGE VIEW v1 AS 
 
2941
CREATE ALGORITHM=MERGE VIEW v1 AS
2875
2942
SELECT t1.*
2876
 
  FROM t1 JOIN t2 
2877
 
       ON t2.fk = t1.pk AND 
 
2943
  FROM t1 JOIN t2
 
2944
       ON t2.fk = t1.pk AND
2878
2945
          t2.ver = (SELECT MAX(t.ver) FROM t2 t WHERE t.org = t2.org);
2879
2946
SHOW WARNINGS;
2880
2947
SHOW CREATE VIEW v1;
2882
2949
DROP VIEW v1;
2883
2950
DROP TABLE t1, t2;
2884
2951
 
 
2952
 
2885
2953
#
2886
 
# Bug#19111: TRIGGERs selecting from a VIEW on the firing base table
2887
 
# fail
 
2954
# Bug#19111 TRIGGERs selecting from a VIEW on the firing base table fail
2888
2955
#
2889
2956
# Allow to select from a view on a table being modified in a trigger
2890
2957
# and stored function, since plain select is allowed there.
2915
2982
DROP VIEW v1;
2916
2983
DROP TABLE t1;
2917
2984
 
 
2985
 
2918
2986
#
2919
 
# Bug #16813 (WITH CHECK OPTION doesn't work with UPDATE)
 
2987
# Bug#16813 (WITH CHECK OPTION doesn't work with UPDATE)
2920
2988
#
2921
2989
CREATE TABLE t1(id INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY, val INT UNSIGNED NOT NULL);
2922
2990
CREATE VIEW v1 AS SELECT id, val FROM t1 WHERE val >= 1 AND val <= 5 WITH CHECK OPTION;
2923
2991
INSERT INTO v1 (val) VALUES (2);
2924
2992
INSERT INTO v1 (val) VALUES (4);
 
2993
-- error ER_VIEW_CHECK_FAILED
2925
2994
INSERT INTO v1 (val) VALUES (6);
 
2995
-- error ER_VIEW_CHECK_FAILED
2926
2996
UPDATE v1 SET val=6 WHERE id=2;
2927
2997
DROP VIEW v1;
2928
2998
DROP TABLE t1;
2929
2999
 
 
3000
 
2930
3001
#
2931
 
# BUG#22584: last_insert_id not updated after inserting a record
 
3002
# Bug#22584 last_insert_id not updated after inserting a record
2932
3003
# through a updatable view
2933
3004
#
2934
3005
# We still do not update LAST_INSERT_ID if AUTO_INCREMENT column is
2966
3035
DROP VIEW v1, v2;
2967
3036
DROP TABLE t1;
2968
3037
 
 
3038
 
2969
3039
#
2970
 
# Bug #25580: !0 as an operand in a select expression of a view
 
3040
# Bug#25580 !0 as an operand in a select expression of a view
2971
3041
#
2972
3042
 
2973
3043
CREATE VIEW v AS SELECT !0 * 5 AS x FROM DUAL;
2978
3048
 
2979
3049
DROP VIEW v;
2980
3050
 
 
3051
 
2981
3052
#
2982
 
# BUG#24293: '\Z' token is not handled correctly in views
 
3053
# Bug#24293 '\Z' token is not handled correctly in views
2983
3054
#
2984
3055
 
2985
3056
--disable_warnings
2993
3064
 
2994
3065
DROP VIEW v1;
2995
3066
 
 
3067
 
2996
3068
#
2997
 
# Bug #26124: BETWEEN over a view column of the DATETIME type
 
3069
# Bug#26124 BETWEEN over a view column of the DATETIME type
2998
3070
#
2999
3071
 
3000
3072
CREATE TABLE t1 (mydate DATETIME);
3009
3081
DROP VIEW v1;
3010
3082
DROP TABLE t1;
3011
3083
 
 
3084
 
3012
3085
#
3013
 
# Bug #25931: update of a multi-table view with check option
 
3086
# Bug#25931 update of a multi-table view with check option
3014
3087
#
3015
3088
 
3016
3089
CREATE TABLE t1 (a int);
3022
3095
  SELECT t2.b FROM t1,t2 WHERE t1.a = t2.b WITH CHECK OPTION;
3023
3096
 
3024
3097
SELECT * FROM v1;
3025
 
--error 1369
 
3098
--error ER_VIEW_CHECK_FAILED
3026
3099
UPDATE v1 SET b=3;
3027
3100
SELECT * FROM v1;
3028
3101
SELECT * FROM t1;
3031
3104
DROP VIEW v1;
3032
3105
DROP TABLE t1,t2;
3033
3106
 
 
3107
 
3034
3108
#
3035
 
# Bug#12122: Views with ORDER BY can't be resolved using MERGE algorithm.
 
3109
# Bug#12122 Views with ORDER BY can't be resolved using MERGE algorithm.
3036
3110
#
3037
3111
create table t1(f1 int, f2 int);
3038
3112
insert into t1 values(1,2),(1,3),(1,1),(2,3),(2,1),(2,2);
3046
3120
drop table t1;
3047
3121
 
3048
3122
#
3049
 
# Bug#26209: queries with GROUP BY and ORDER BY using views
 
3123
# Bug#26209 queries with GROUP BY and ORDER BY using views
3050
3124
#
3051
3125
 
3052
3126
CREATE TABLE t1 (
3065
3139
DROP VIEW v1;
3066
3140
DROP TABLE t1;
3067
3141
 
 
3142
 
3068
3143
#
3069
 
# BUG#25897: Some queries are no longer possible after a CREATE VIEW
3070
 
# fails 
 
3144
# Bug#25897 Some queries are no longer possible after a CREATE VIEW fails
3071
3145
#
3072
3146
--disable_warnings
3073
3147
DROP VIEW IF EXISTS v1;
3081
3155
--echo # Previously the following would fail.
3082
3156
eval $query;
3083
3157
 
 
3158
 
3084
3159
#
3085
 
# Bug#24532: The return data type of IS TRUE is different from similar
3086
 
# operations
 
3160
# Bug#24532 The return data type of IS TRUE is different from similar operations
3087
3161
#
3088
3162
 
3089
3163
--disable_warnings
3168
3242
drop view view_24532_b;
3169
3243
drop table table_24532;
3170
3244
 
 
3245
 
3171
3246
#
3172
 
# Bug#26560: view using subquery with a reference to an outer alias 
 
3247
# Bug#26560 view using subquery with a reference to an outer alias
3173
3248
#
3174
3249
 
3175
3250
CREATE TABLE t1 (
3180
3255
  (1, 'YES'), (2, 'NO');
3181
3256
 
3182
3257
CREATE TABLE t2 (
3183
 
  id int NOT NULL PRIMARY KEY, 
 
3258
  id int NOT NULL PRIMARY KEY,
3184
3259
  gid int NOT NULL,
3185
3260
  lid int NOT NULL,
3186
3261
  dt date
3208
3283
DROP VIEW v1;
3209
3284
DROP table t1,t2;
3210
3285
 
 
3286
 
3211
3287
#
3212
 
# Bug#27786: Inconsistent Operation Performing UNION On View With ORDER BY 
 
3288
# Bug#27786 Inconsistent Operation Performing UNION On View With ORDER BY
3213
3289
#
3214
3290
CREATE TABLE t1 (a INT); INSERT INTO t1 VALUES (1),(2),(3);
3215
3291
CREATE VIEW v1 AS SELECT a FROM t1 ORDER BY a;
3224
3300
DROP VIEW v1;
3225
3301
DROP TABLE t1;
3226
3302
 
 
3303
 
3227
3304
#
3228
 
# Bug #27921 View ignores precision for CAST()
 
3305
# Bug#27921 View ignores precision for CAST()
3229
3306
#
3230
3307
CREATE VIEW v1 AS SELECT CAST( 1.23456789 AS DECIMAL( 7,5 ) ) AS col;
3231
3308
SELECT * FROM v1;
3236
3313
SHOW CREATE VIEW v1;
3237
3314
DROP VIEW v1;
3238
3315
 
 
3316
 
3239
3317
#
3240
 
# Bug #28716: CHECK OPTION expression is evaluated over expired record buffers
3241
 
# when VIEW is updated via temporary tables
 
3318
# Bug#28716 CHECK OPTION expression is evaluated over expired record buffers
 
3319
#           when VIEW is updated via temporary tables
3242
3320
#
3243
3321
CREATE TABLE t1 (a INT);
3244
3322
CREATE TABLE t2 (b INT, c INT DEFAULT 0);
3252
3330
DROP VIEW v1;
3253
3331
DROP TABLE t1,t2;
3254
3332
 
 
3333
 
3255
3334
#
3256
 
# Bug #28561: update on multi-table view with CHECK OPTION and
3257
 
#             a subquery in WHERE condition
 
3335
# Bug#28561 update on multi-table view with CHECK OPTION and a subquery
 
3336
#           in WHERE condition
3258
3337
#
3259
3338
 
3260
3339
CREATE TABLE t1 (id int);
3262
3341
INSERT INTO t1 (id) VALUES (1);
3263
3342
INSERT INTO t2 (id) VALUES (1);
3264
3343
 
3265
 
CREATE VIEW v1 AS 
3266
 
  SELECT t2.c FROM t1, t2 
 
3344
CREATE VIEW v1 AS
 
3345
  SELECT t2.c FROM t1, t2
3267
3346
    WHERE t1.id=t2.id AND 1 IN (SELECT id FROM t1) WITH CHECK OPTION;
3268
3347
 
3269
3348
UPDATE v1 SET c=1;
3271
3350
DROP VIEW v1;
3272
3351
DROP TABLE t1,t2;
3273
3352
 
 
3353
 
3274
3354
#
3275
 
# Bug #27827: CHECK OPTION ignores ON conditions when updating
3276
 
#             a multi-table view with CHECK OPTION.
 
3355
# Bug#27827 CHECK OPTION ignores ON conditions when updating
 
3356
#           a multi-table view with CHECK OPTION.
3277
3357
#
3278
3358
 
3279
3359
CREATE TABLE t1 (a1 INT, c INT DEFAULT 0);
3289
3369
  SELECT t1.a1, t1.c FROM t1 JOIN t2 ON t1.a1=t2.a2 AND t1.c < 3
3290
3370
    WITH CHECK OPTION;
3291
3371
SELECT * FROM v1;
3292
 
--error 1369
 
3372
--error ER_VIEW_CHECK_FAILED
3293
3373
UPDATE v1 SET c=3;
3294
3374
PREPARE t FROM 'UPDATE v1 SET c=3';
3295
 
--error 1369
3296
 
EXECUTE t;
3297
 
--error 1369
3298
 
EXECUTE t;
3299
 
--error 1369
 
3375
--error ER_VIEW_CHECK_FAILED
 
3376
EXECUTE t;
 
3377
--error ER_VIEW_CHECK_FAILED
 
3378
EXECUTE t;
 
3379
--error ER_VIEW_CHECK_FAILED
3300
3380
INSERT INTO v1(a1, c) VALUES (3, 3);
3301
3381
UPDATE v1 SET c=1 WHERE a1=1;
3302
3382
SELECT * FROM v1;
3307
3387
  JOIN (t3 JOIN t4 ON t3.a3=t4.a4)
3308
3388
    ON t2.a2=t3.a3 WITH CHECK OPTION;
3309
3389
SELECT * FROM v2;
3310
 
--error 1369
 
3390
--error ER_VIEW_CHECK_FAILED
3311
3391
UPDATE v2 SET c=3;
3312
3392
PREPARE t FROM 'UPDATE v2 SET c=3';
3313
 
--error 1369
3314
 
EXECUTE t;
3315
 
--error 1369
3316
 
EXECUTE t;
3317
 
--error 1369
 
3393
--error ER_VIEW_CHECK_FAILED
 
3394
EXECUTE t;
 
3395
--error ER_VIEW_CHECK_FAILED
 
3396
EXECUTE t;
 
3397
--error ER_VIEW_CHECK_FAILED
3318
3398
INSERT INTO v2(a1, c) VALUES (3, 3);
3319
3399
UPDATE v2 SET c=2 WHERE a1=1;
3320
3400
SELECT * FROM v2;
3323
3403
DROP VIEW v1,v2;
3324
3404
DROP TABLE t1,t2,t3,t4;
3325
3405
 
 
3406
 
3326
3407
#
3327
 
# Bug #29104: assertion abort for a query with a view column reference
3328
 
#             in the GROUP BY list and a condition requiring the value  
3329
 
#             of another view column to be equal to a constant
 
3408
# Bug#29104 assertion abort for a query with a view column reference
 
3409
#           in the GROUP BY list and a condition requiring the value
 
3410
#           of another view column to be equal to a constant
3330
3411
#
3331
3412
 
3332
3413
CREATE TABLE t1 (a int, b int);
3347
3428
DROP VIEW v1;
3348
3429
DROP TABLE t1;
3349
3430
 
 
3431
 
3350
3432
#
3351
 
# Bug #29392: SELECT over a multi-table view with ORDER BY  
3352
 
#             selecting the same view column with two different aliases  
 
3433
# Bug#29392 SELECT over a multi-table view with ORDER BY
 
3434
#           selecting the same view column with two different aliases
3353
3435
#
3354
3436
 
3355
3437
CREATE TABLE t1 (
3373
3455
  INDEX idx_app_name(app_name)
3374
3456
);
3375
3457
 
3376
 
CREATE VIEW v1 AS 
 
3458
CREATE VIEW v1 AS
3377
3459
SELECT profile.person_id AS person_id
3378
3460
  FROM t1 profile, t2 userrole, t3 role
3379
3461
    WHERE userrole.person_id = profile.person_id AND
3387
3469
INSERT INTO t2 VALUES
3388
3470
  (1,3,6),(2,4,7),(3,5,8),(4,6,9),(5,1,6),(6,1,7),(7,1,8),(8,1,9),(9,1,10);
3389
3471
 
3390
 
INSERT INTO t3 VALUES 
 
3472
INSERT INTO t3 VALUES
3391
3473
  (1,'NUCANS_APP_USER','NUCANSAPP'),(2,'NUCANS_TRGAPP_USER','NUCANSAPP'),
3392
3474
  (3,'IA_INTAKE_COORDINATOR','IACANS'),(4,'IA_SCREENER','IACANS'),
3393
3475
  (5,'IA_SUPERVISOR','IACANS'),(6,'IA_READONLY','IACANS'),
3394
3476
  (7,'SOC_USER','SOCCANS'),(8,'CAYIT_USER','CAYITCANS'),
3395
3477
  (9,'RTOS_DCFSPOS_SUPERVISOR','RTOS');
3396
 
 
 
3478
 
3397
3479
EXPLAIN SELECT t.person_id AS a, t.person_id AS b FROM v1 t WHERE t.person_id=6;
3398
3480
SELECT t.person_id AS a, t.person_id AS b FROM v1 t WHERE t.person_id=6;
3399
3481
 
3400
3482
DROP VIEW v1;
3401
3483
DROP TABLE t1,t2,t3;
3402
3484
 
 
3485
 
3403
3486
#
3404
 
# Bug#30020: Insufficient check led to a wrong info provided by the
3405
 
#            information schema table.
 
3487
# Bug#30020 Insufficient check led to a wrong info provided by the
 
3488
#           information schema table.
3406
3489
#
3407
3490
create table t1 (i int);
3408
3491
insert into t1 values (1), (2), (1), (3), (2), (4);
3409
3492
create view v1 as select distinct i from t1;
3410
3493
select * from v1;
3411
 
select table_name, is_updatable from information_schema.views 
 
3494
select table_name, is_updatable from information_schema.views
3412
3495
   where table_name = 'v1';
3413
3496
drop view v1;
3414
3497
drop table t1;
3415
3498
 
 
3499
 
3416
3500
#
3417
 
# Bug #28701: SELECTs from VIEWs completely ignore USE/FORCE KEY, allowing
3418
 
# invalid statements
 
3501
# Bug#28701 SELECTs from VIEWs completely ignore USE/FORCE KEY, allowing
 
3502
#           invalid statements
3419
3503
#
3420
3504
 
3421
3505
CREATE TABLE t1 (a INT);
3431
3515
DROP VIEW v1;
3432
3516
DROP TABLE t1;
3433
3517
 
 
3518
 
3434
3519
#
3435
 
# Bug #28702: VIEWs defined with USE/FORCE KEY ignore that request
 
3520
# Bug#28702 VIEWs defined with USE/FORCE KEY ignore that request
3436
3521
#
3437
3522
CREATE TABLE t1 (a INT NOT NULL AUTO_INCREMENT, b INT NOT NULL DEFAULT 0,
3438
3523
                 PRIMARY KEY(a), KEY (b));
3452
3537
DROP VIEW v3;
3453
3538
DROP TABLE t1;
3454
3539
 
 
3540
 
3455
3541
--echo #
3456
 
--echo # Bug#29477: Not all fields of the target table were checked to have
3457
 
--echo #            a default value when inserting into a view.
 
3542
--echo # Bug#29477 Not all fields of the target table were checked to have
 
3543
--echo #           a default value when inserting into a view.
3458
3544
--echo #
3459
3545
create table t1(f1 int, f2 int not null);
3460
3546
create view v1 as select f1 from t1;
3467
3553
drop view v1;
3468
3554
drop table t1;
3469
3555
 
 
3556
 
3470
3557
#
3471
 
# Bug #33389: Selecting from a view into a table from within SP or trigger 
3472
 
#             crashes server
 
3558
# Bug#33389 Selecting from a view into a table from within SP or trigger
 
3559
#           crashes server
3473
3560
#
3474
3561
 
3475
3562
create table t1 (a int, key(a));
3476
3563
create table t2 (c int);
3477
 
                   
 
3564
 
3478
3565
create view v1 as select a b from t1;
3479
 
create view v2 as select 1 a from t2, v1 where c in 
 
3566
create view v2 as select 1 a from t2, v1 where c in
3480
3567
                  (select 1 from t1 where b = a);
3481
 
                   
 
3568
 
3482
3569
insert into t1 values (1), (1);
3483
3570
insert into t2 values (1), (1);
3484
 
                   
 
3571
 
3485
3572
prepare stmt from "select * from v2 where a = 1";
3486
 
execute stmt; 
 
3573
execute stmt;
3487
3574
 
3488
3575
drop view v1, v2;
3489
3576
drop table t1, t2;
3490
3577
 
 
3578
 
3491
3579
#
3492
 
# Bug #33049: Assert while running test-as3ap test(mysql-bench suite)
 
3580
# Bug#33049 Assert while running test-as3ap test(mysql-bench suite)
3493
3581
#
3494
3582
 
3495
3583
CREATE TABLE t1 (a INT);
3504
3592
###########################################################################
3505
3593
 
3506
3594
--echo # -----------------------------------------------------------------
3507
 
--echo # -- Bug#34337: Server crash when Altering a view using a table name.
 
3595
--echo # -- Bug#34337 Server crash when Altering a view using a table name.
3508
3596
--echo # -----------------------------------------------------------------
3509
3597
--echo
3510
3598
 
3534
3622
###########################################################################
3535
3623
 
3536
3624
--echo # -----------------------------------------------------------------
3537
 
--echo # -- Bug#35193: VIEW query is rewritten without "FROM DUAL",
3538
 
--echo # --            causing syntax error
 
3625
--echo # -- Bug#35193 VIEW query is rewritten without "FROM DUAL",
 
3626
--echo # --           causing syntax error
3539
3627
--echo # -----------------------------------------------------------------
3540
3628
--echo
3541
3629
 
3557
3645
###########################################################################
3558
3646
 
3559
3647
#
3560
 
# Bug#39040: valgrind errors/crash when creating views with binlog logging 
3561
 
# enabled
 
3648
# Bug#39040 valgrind errors/crash when creating views with binlog logging
 
3649
#           enabled
3562
3650
#
3563
3651
# Bug is visible only when running in valgrind with binary logging.
3564
3652
CREATE VIEW v1 AS SELECT 1;
3565
3653
DROP VIEW v1;
3566
3654
 
 
3655
 
3567
3656
#
3568
 
# Bug #33461: SELECT ... FROM <view> USE INDEX (...) throws an error
 
3657
# Bug#33461 SELECT ... FROM <view> USE INDEX (...) throws an error
3569
3658
#
3570
3659
 
3571
3660
CREATE TABLE t1 (c1 INT PRIMARY KEY, c2 INT, INDEX (c2));
3616
3705
 
3617
3706
--echo
3618
3707
--echo #
3619
 
--echo # Bug#26676: VIEW using old table schema in a session.
 
3708
--echo # Bug#26676 VIEW using old table schema in a session.
3620
3709
--echo #
3621
3710
--echo
3622
3711
 
3668
3757
###########################################################################
3669
3758
 
3670
3759
--echo # -----------------------------------------------------------------
3671
 
--echo # -- Bug#32538: View definition picks up character set, but not collation
 
3760
--echo # -- Bug#32538 View definition picks up character set, but not collation
3672
3761
--echo # -----------------------------------------------------------------
3673
3762
--echo
3674
3763